Skip to content

Commit

Permalink
Merge pull request #57 from CrowdStrike/update-glint
Browse files Browse the repository at this point in the history
Update to Glint 1.0.0-beta.3
  • Loading branch information
simonihmig authored Feb 27, 2023
2 parents b644d69 + a9ad475 commit 5bf3616
Show file tree
Hide file tree
Showing 10 changed files with 284 additions and 178 deletions.
8 changes: 4 additions & 4 deletions docs-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@
"@embroider/webpack": "^2.0.0",
"@glimmer/component": "^1.1.2",
"@glimmer/tracking": "^1.1.2",
"@glint/core": "^0.9.6",
"@glint/environment-ember-loose": "^0.9.6",
"@glint/environment-ember-template-imports": "^0.9.6",
"@glint/template": "^0.9.6",
"@glint/core": "^1.0.0-beta.3",
"@glint/environment-ember-loose": "^1.0.0-beta.3",
"@glint/environment-ember-template-imports": "^1.0.0-beta.3",
"@glint/template": "^1.0.0-beta.3",
"@nullvoxpopuli/eslint-configs": "3.0.2",
"@tailwindcss/typography": "^0.5.7",
"@tsconfig/ember": "^2.0.0",
Expand Down
5 changes: 3 additions & 2 deletions packages/changeset-validations/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,9 @@
"@babel/plugin-syntax-decorators": "^7.17.0",
"@embroider/addon-dev": "^3.0.0",
"@glimmer/component": "^1.1.2",
"@glint/core": "^0.9.7",
"@glint/environment-ember-loose": "^0.9.7",
"@glint/core": "^1.0.0-beta.3",
"@glint/environment-ember-loose": "^1.0.0-beta.3",
"@glint/template": "^1.0.0-beta.3",
"@tsconfig/ember": "^1.0.0",
"@types/ember": "^4.0.0",
"@types/ember__object": "^4.0.0",
Expand Down
8 changes: 4 additions & 4 deletions packages/ember-headless-form/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"@babel/runtime": "^7.20.7",
"@embroider/addon-shim": "^1.0.0",
"@ember/test-waiters": "^3.0.2",
"@embroider/util": "^1.9.0",
"@embroider/util": "^1.10.0",
"ember-modifier": "^4.0.0",
"tracked-built-ins": "^3.1.0"
},
Expand All @@ -49,9 +49,9 @@
"@embroider/addon-dev": "^3.0.0",
"@glimmer/component": "^1.1.2",
"@glimmer/tracking": "^1.1.2",
"@glint/core": "^0.9.7",
"@glint/environment-ember-loose": "^0.9.7",
"@glint/template": "^0.9.7",
"@glint/core": "^1.0.0-beta.3",
"@glint/environment-ember-loose": "^1.0.0-beta.3",
"@glint/template": "^1.0.0-beta.3",
"@nullvoxpopuli/eslint-configs": "^3.0.2",
"@tsconfig/ember": "^1.0.0",
"@types/ember": "^4.0.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@ import Component from '@glimmer/component';
import LabelComponent from '../label';
import RadioInputComponent from './radio/input';

import type { HeadlessFormLabelComponentSignature } from '../label';
import type { HeadlessFormControlRadioInputComponentSignature } from './radio/input';
import type { ComponentLike, WithBoundArgs } from '@glint/template';
import type { WithBoundArgs } from '@glint/template';

export interface HeadlessFormControlRadioComponentSignature {
Args: {
Expand Down Expand Up @@ -52,10 +50,8 @@ export interface HeadlessFormControlRadioComponentSignature {
}

export default class HeadlessFormControlRadioComponent extends Component<HeadlessFormControlRadioComponentSignature> {
LabelComponent: ComponentLike<HeadlessFormLabelComponentSignature> =
LabelComponent;
RadioInputComponent: ComponentLike<HeadlessFormControlRadioInputComponentSignature> =
RadioInputComponent;
LabelComponent = LabelComponent;
RadioInputComponent = RadioInputComponent;

get isChecked(): boolean {
return this.args.selected === this.args.value;
Expand Down
35 changes: 10 additions & 25 deletions packages/ember-headless-form/src/-private/components/field.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,13 @@ import type {
ErrorRecord,
FieldValidateCallback,
FormData,
FormKey,
RegisterFieldCallback,
UnregisterFieldCallback,
UserData,
ValidationError,
} from '../types';
import type { FormKey, UserData, ValidationError } from '../types';
import type { HeadlessFormControlCheckboxComponentSignature } from './control/checkbox';
import type { HeadlessFormControlInputComponentSignature } from './control/input';
import type { HeadlessFormControlRadioComponentSignature } from './control/radio';
import type { HeadlessFormControlTextareaComponentSignature } from './control/textarea';
import type { HeadlessFormErrorsComponentSignature } from './errors';
import type { HeadlessFormLabelComponentSignature } from './label';
import type {
ComponentLike,
ModifierLike,
WithBoundArgs,
} from '@glint/template';
import type { ModifierLike, WithBoundArgs } from '@glint/template';

export interface HeadlessFormFieldComponentSignature<
DATA extends UserData,
Expand Down Expand Up @@ -202,19 +194,12 @@ export default class HeadlessFormFieldComponent<
DATA extends FormData,
KEY extends FormKey<FormData<DATA>> = FormKey<FormData<DATA>>
> extends Component<HeadlessFormFieldComponentSignature<DATA, KEY>> {
LabelComponent: ComponentLike<HeadlessFormLabelComponentSignature> =
LabelComponent;
InputComponent: ComponentLike<HeadlessFormControlInputComponentSignature> =
InputComponent;
CheckboxComponent: ComponentLike<HeadlessFormControlCheckboxComponentSignature> =
CheckboxComponent;
ErrorsComponent: ComponentLike<
HeadlessFormErrorsComponentSignature<DATA[KEY]>
> = ErrorsComponent;
TextareaComponent: ComponentLike<HeadlessFormControlTextareaComponentSignature> =
TextareaComponent;
RadioComponent: ComponentLike<HeadlessFormControlRadioComponentSignature> =
RadioComponent;
LabelComponent = LabelComponent;
InputComponent = InputComponent;
CheckboxComponent = CheckboxComponent;
ErrorsComponent = ErrorsComponent<DATA[KEY]>;
TextareaComponent = TextareaComponent;
RadioComponent = RadioComponent;
CaptureEventsModifier = CaptureEventsModifier;

constructor(
Expand Down
10 changes: 2 additions & 8 deletions packages/ember-headless-form/src/components/headless-form.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import { TrackedObject } from 'tracked-built-ins';
import FieldComponent from '../-private/components/field';
import { mergeErrorRecord } from '../-private/utils';

import type { HeadlessFormFieldComponentSignature } from '../-private/components/field';
import type {
ErrorRecord,
FieldRegistrationData,
Expand All @@ -22,11 +21,7 @@ import type {
UserData,
ValidationError,
} from '../-private/types';
import type {
ComponentLike,
ModifierLike,
WithBoundArgs,
} from '@glint/template';
import type { ModifierLike, WithBoundArgs } from '@glint/template';

type ValidateOn = 'change' | 'focusout' | 'submit' | 'input';

Expand Down Expand Up @@ -154,8 +149,7 @@ class FieldData<
export default class HeadlessFormComponent<
DATA extends UserData
> extends Component<HeadlessFormComponentSignature<DATA>> {
FieldComponent: ComponentLike<HeadlessFormFieldComponentSignature<DATA>> =
FieldComponent;
FieldComponent = FieldComponent<DATA>;

// we cannot use (modifier "on") directly in the template due to https://github.com/emberjs/ember.js/issues/19869
on = on;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,28 @@

import '@glint/environment-ember-loose';

import Helper from '@ember/component/helper';

import { ComponentLike } from '@glint/template';

import type HeadlessFormRegistry from '../src/template-registry';
import type TemplateRegistry from '@glint/environment-ember-loose/registry';

// Taken from https://github.com/embroider-build/embroider/blob/main/packages/util/index.d.ts, which is still unreleased.
// @todo Remove once this is publicly available
declare function ensureSafeComponent<C extends string | ComponentLike<S>, S>(
component: C,
thingWithOwner: unknown
): C extends string ? ComponentLike<unknown> : C;
// importing this directly from the published types (https://github.com/embroider-build/embroider/blob/main/packages/util/index.d.ts) does not work,
// see point 3 in Dan's comment here: https://github.com/typed-ember/glint/issues/518#issuecomment-1400306133
declare class EnsureSafeComponentHelper<
// eslint-disable-next-line @typescript-eslint/no-explicit-any
C extends string | ComponentLike<any>
> extends Helper<{
Args: {
Positional: [component: C];
};
Return: C extends keyof TemplateRegistry
? TemplateRegistry[C]
: C extends string
? ComponentLike<unknown>
: C;
}> {}

declare module '@glint/environment-ember-loose/registry' {
// Remove this once entries have been added! 👇
Expand All @@ -21,7 +33,7 @@ declare module '@glint/environment-ember-loose/registry' {
// Add any registry entries from other addons here that your addon itself uses (in non-strict mode templates)
// See https://typed-ember.gitbook.io/glint/using-glint/ember/using-addons

'ensure-safe-component': typeof ensureSafeComponent;
'ensure-safe-component': typeof EnsureSafeComponentHelper;

// eslint-disable-next-line @typescript-eslint/no-explicit-any -- effectively skipping type checks until https://github.com/typed-ember/glint/issues/410 is resolved
modifier: any;
Expand Down
5 changes: 3 additions & 2 deletions packages/yup/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,9 @@
"@babel/plugin-syntax-decorators": "^7.17.0",
"@embroider/addon-dev": "^3.0.0",
"@glimmer/component": "^1.1.2",
"@glint/core": "^0.9.7",
"@glint/environment-ember-loose": "^0.9.7",
"@glint/core": "^1.0.0-beta.3",
"@glint/environment-ember-loose": "^1.0.0-beta.3",
"@glint/template": "^1.0.0-beta.3",
"@tsconfig/ember": "^1.0.0",
"@types/ember": "^4.0.0",
"@types/ember__object": "^4.0.0",
Expand Down
Loading

0 comments on commit 5bf3616

Please sign in to comment.