@frontile/forms 0.17.0-beta.2 → 0.17.0-beta.20

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (76) hide show
  1. package/declarations/components/checkbox-group.d.ts +6 -7
  2. package/declarations/components/checkbox.d.ts +5 -6
  3. package/declarations/components/form-control.d.ts +0 -1
  4. package/declarations/components/form-description.d.ts +0 -1
  5. package/declarations/components/form-feedback.d.ts +0 -1
  6. package/declarations/components/form.d.ts +2 -3
  7. package/declarations/components/icons.d.ts +0 -1
  8. package/declarations/components/input.d.ts +12 -12
  9. package/declarations/components/label.d.ts +4 -5
  10. package/declarations/components/native-select.d.ts +7 -8
  11. package/declarations/components/radio-group.d.ts +6 -7
  12. package/declarations/components/radio.d.ts +5 -6
  13. package/declarations/components/select.d.ts +129 -16
  14. package/declarations/components/switch.d.ts +147 -0
  15. package/declarations/components/textarea.d.ts +6 -7
  16. package/declarations/index.d.ts +1 -1
  17. package/declarations/template-registry.d.ts +0 -1
  18. package/declarations/test-support.d.ts +2 -0
  19. package/declarations/utils/index.d.ts +0 -1
  20. package/dist/_app_/components/switch.js +1 -0
  21. package/dist/components/checkbox-group.js +9 -9
  22. package/dist/components/checkbox-group.js.map +1 -1
  23. package/dist/components/checkbox.js +15 -10
  24. package/dist/components/checkbox.js.map +1 -1
  25. package/dist/components/form-control.js +25 -29
  26. package/dist/components/form-control.js.map +1 -1
  27. package/dist/components/form-description.js +5 -5
  28. package/dist/components/form-description.js.map +1 -1
  29. package/dist/components/form-feedback.js +5 -5
  30. package/dist/components/form-feedback.js.map +1 -1
  31. package/dist/components/form.js +19 -36
  32. package/dist/components/form.js.map +1 -1
  33. package/dist/components/icons.js.map +1 -1
  34. package/dist/components/input.js +30 -27
  35. package/dist/components/input.js.map +1 -1
  36. package/dist/components/label.js +5 -5
  37. package/dist/components/label.js.map +1 -1
  38. package/dist/components/native-select.js +42 -42
  39. package/dist/components/native-select.js.map +1 -1
  40. package/dist/components/radio-group.js +9 -9
  41. package/dist/components/radio-group.js.map +1 -1
  42. package/dist/components/radio.js +15 -10
  43. package/dist/components/radio.js.map +1 -1
  44. package/dist/components/select.js +106 -72
  45. package/dist/components/select.js.map +1 -1
  46. package/dist/components/switch.js +60 -0
  47. package/dist/components/switch.js.map +1 -0
  48. package/dist/components/textarea.js +18 -10
  49. package/dist/components/textarea.js.map +1 -1
  50. package/dist/index-CeaQc-U7.js.map +1 -1
  51. package/dist/index.js +1 -0
  52. package/dist/index.js.map +1 -1
  53. package/dist/runtime-BPCpkOf1-BKOwiRJp.js +67 -0
  54. package/dist/runtime-BPCpkOf1-BKOwiRJp.js.map +1 -0
  55. package/dist/test-support.js +1337 -0
  56. package/dist/test-support.js.map +1 -0
  57. package/package.json +55 -55
  58. package/declarations/components/checkbox-group.d.ts.map +0 -1
  59. package/declarations/components/checkbox.d.ts.map +0 -1
  60. package/declarations/components/form-control.d.ts.map +0 -1
  61. package/declarations/components/form-description.d.ts.map +0 -1
  62. package/declarations/components/form-feedback.d.ts.map +0 -1
  63. package/declarations/components/form.d.ts.map +0 -1
  64. package/declarations/components/icons.d.ts.map +0 -1
  65. package/declarations/components/input.d.ts.map +0 -1
  66. package/declarations/components/label.d.ts.map +0 -1
  67. package/declarations/components/native-select.d.ts.map +0 -1
  68. package/declarations/components/radio-group.d.ts.map +0 -1
  69. package/declarations/components/radio.d.ts.map +0 -1
  70. package/declarations/components/select.d.ts.map +0 -1
  71. package/declarations/components/textarea.d.ts.map +0 -1
  72. package/declarations/index-CeaQc-U7.d.ts +0 -3
  73. package/declarations/index-CeaQc-U7.d.ts.map +0 -1
  74. package/declarations/index.d.ts.map +0 -1
  75. package/declarations/template-registry.d.ts.map +0 -1
  76. package/declarations/utils/index.d.ts.map +0 -1
@@ -0,0 +1,147 @@
1
+ import Component from '@glimmer/component';
2
+ import { type FormControlSharedArgs } from './form-control';
3
+ import { type SwitchVariants, type SwitchSlots, type SlotsToClasses } from '@frontile/theme';
4
+ import type Owner from '@ember/owner';
5
+ interface Args extends FormControlSharedArgs {
6
+ /**
7
+ * Controls the current selected state of the Switch.
8
+ * When provided a boolean value, the component operates in a controlled mode.
9
+ */
10
+ isSelected?: boolean;
11
+ /**
12
+ * Sets the initial selected state of the Switch when used in uncontrolled mode.
13
+ * @defaultValue false
14
+ */
15
+ defaultSelected?: boolean;
16
+ /**
17
+ * The name attribute for the input element.
18
+ * Useful for form submissions.
19
+ */
20
+ name?: string;
21
+ /**
22
+ * The size of the Switch.
23
+ */
24
+ size?: SwitchVariants['size'];
25
+ /**
26
+ * The visual intent (e.g., color or style) of the Switch.
27
+ * @defaultValue 'primary'
28
+ */
29
+ intent?: SwitchVariants['intent'];
30
+ /**
31
+ * Custom classes to style different slots of the Switch component.
32
+ */
33
+ classes?: SlotsToClasses<SwitchSlots>;
34
+ /**
35
+ * Whether the Switch is disabled.
36
+ * When true, user interaction is prevented.
37
+ */
38
+ isDisabled?: boolean;
39
+ /**
40
+ * Callback triggered when the Switch value changes.
41
+ * Receives the new boolean value and, optionally, the triggering Event.
42
+ */
43
+ onChange?: ((value: boolean, event: Event) => void) | ((value: boolean) => void);
44
+ }
45
+ interface SwitchSignature {
46
+ Args: Args;
47
+ Blocks: {
48
+ startContent: [];
49
+ thumbContent: [{
50
+ isSelected: boolean;
51
+ }];
52
+ endContent: [];
53
+ };
54
+ Element: HTMLInputElement;
55
+ }
56
+ declare class Switch extends Component<SwitchSignature> {
57
+ _isSelected: boolean;
58
+ constructor(owner: Owner, args: Args);
59
+ get isControlled(): boolean;
60
+ get isSelected(): boolean;
61
+ handleChange: (event: Event) => void;
62
+ get classes(): {
63
+ base: (slotProps?: ({
64
+ intent?: "default" | "primary" | "success" | "danger" | "warning" | undefined;
65
+ size?: "sm" | "md" | "lg" | undefined;
66
+ isDisabled?: boolean | undefined;
67
+ } & import("tailwind-variants").ClassProp<import("tailwind-variants").ClassValue>) | undefined) => string;
68
+ labelContainer: (slotProps?: ({
69
+ intent?: "default" | "primary" | "success" | "danger" | "warning" | undefined;
70
+ size?: "sm" | "md" | "lg" | undefined;
71
+ isDisabled?: boolean | undefined;
72
+ } & import("tailwind-variants").ClassProp<import("tailwind-variants").ClassValue>) | undefined) => string;
73
+ label: (slotProps?: ({
74
+ intent?: "default" | "primary" | "success" | "danger" | "warning" | undefined;
75
+ size?: "sm" | "md" | "lg" | undefined;
76
+ isDisabled?: boolean | undefined;
77
+ } & import("tailwind-variants").ClassProp<import("tailwind-variants").ClassValue>) | undefined) => string;
78
+ wrapper: (slotProps?: ({
79
+ intent?: "default" | "primary" | "success" | "danger" | "warning" | undefined;
80
+ size?: "sm" | "md" | "lg" | undefined;
81
+ isDisabled?: boolean | undefined;
82
+ } & import("tailwind-variants").ClassProp<import("tailwind-variants").ClassValue>) | undefined) => string;
83
+ hiddenInput: (slotProps?: ({
84
+ intent?: "default" | "primary" | "success" | "danger" | "warning" | undefined;
85
+ size?: "sm" | "md" | "lg" | undefined;
86
+ isDisabled?: boolean | undefined;
87
+ } & import("tailwind-variants").ClassProp<import("tailwind-variants").ClassValue>) | undefined) => string;
88
+ thumb: (slotProps?: ({
89
+ intent?: "default" | "primary" | "success" | "danger" | "warning" | undefined;
90
+ size?: "sm" | "md" | "lg" | undefined;
91
+ isDisabled?: boolean | undefined;
92
+ } & import("tailwind-variants").ClassProp<import("tailwind-variants").ClassValue>) | undefined) => string;
93
+ startContent: (slotProps?: ({
94
+ intent?: "default" | "primary" | "success" | "danger" | "warning" | undefined;
95
+ size?: "sm" | "md" | "lg" | undefined;
96
+ isDisabled?: boolean | undefined;
97
+ } & import("tailwind-variants").ClassProp<import("tailwind-variants").ClassValue>) | undefined) => string;
98
+ endContent: (slotProps?: ({
99
+ intent?: "default" | "primary" | "success" | "danger" | "warning" | undefined;
100
+ size?: "sm" | "md" | "lg" | undefined;
101
+ isDisabled?: boolean | undefined;
102
+ } & import("tailwind-variants").ClassProp<import("tailwind-variants").ClassValue>) | undefined) => string;
103
+ } & {
104
+ base: (slotProps?: ({
105
+ intent?: "default" | "primary" | "success" | "danger" | "warning" | undefined;
106
+ size?: "sm" | "md" | "lg" | undefined;
107
+ isDisabled?: boolean | undefined;
108
+ } & import("tailwind-variants").ClassProp<import("tailwind-variants").ClassValue>) | undefined) => string;
109
+ labelContainer: (slotProps?: ({
110
+ intent?: "default" | "primary" | "success" | "danger" | "warning" | undefined;
111
+ size?: "sm" | "md" | "lg" | undefined;
112
+ isDisabled?: boolean | undefined;
113
+ } & import("tailwind-variants").ClassProp<import("tailwind-variants").ClassValue>) | undefined) => string;
114
+ label: (slotProps?: ({
115
+ intent?: "default" | "primary" | "success" | "danger" | "warning" | undefined;
116
+ size?: "sm" | "md" | "lg" | undefined;
117
+ isDisabled?: boolean | undefined;
118
+ } & import("tailwind-variants").ClassProp<import("tailwind-variants").ClassValue>) | undefined) => string;
119
+ wrapper: (slotProps?: ({
120
+ intent?: "default" | "primary" | "success" | "danger" | "warning" | undefined;
121
+ size?: "sm" | "md" | "lg" | undefined;
122
+ isDisabled?: boolean | undefined;
123
+ } & import("tailwind-variants").ClassProp<import("tailwind-variants").ClassValue>) | undefined) => string;
124
+ hiddenInput: (slotProps?: ({
125
+ intent?: "default" | "primary" | "success" | "danger" | "warning" | undefined;
126
+ size?: "sm" | "md" | "lg" | undefined;
127
+ isDisabled?: boolean | undefined;
128
+ } & import("tailwind-variants").ClassProp<import("tailwind-variants").ClassValue>) | undefined) => string;
129
+ thumb: (slotProps?: ({
130
+ intent?: "default" | "primary" | "success" | "danger" | "warning" | undefined;
131
+ size?: "sm" | "md" | "lg" | undefined;
132
+ isDisabled?: boolean | undefined;
133
+ } & import("tailwind-variants").ClassProp<import("tailwind-variants").ClassValue>) | undefined) => string;
134
+ startContent: (slotProps?: ({
135
+ intent?: "default" | "primary" | "success" | "danger" | "warning" | undefined;
136
+ size?: "sm" | "md" | "lg" | undefined;
137
+ isDisabled?: boolean | undefined;
138
+ } & import("tailwind-variants").ClassProp<import("tailwind-variants").ClassValue>) | undefined) => string;
139
+ endContent: (slotProps?: ({
140
+ intent?: "default" | "primary" | "success" | "danger" | "warning" | undefined;
141
+ size?: "sm" | "md" | "lg" | undefined;
142
+ isDisabled?: boolean | undefined;
143
+ } & import("tailwind-variants").ClassProp<import("tailwind-variants").ClassValue>) | undefined) => string;
144
+ } & {};
145
+ }
146
+ export { Switch, type SwitchSignature };
147
+ export default Switch;
@@ -24,35 +24,35 @@ declare class Textarea extends Component<TextareaSignature> {
24
24
  endContentPointerEvents?: "none" | "auto" | undefined;
25
25
  hasStartContent?: boolean | undefined;
26
26
  hasEndContent?: boolean | undefined;
27
- } & import("tailwind-variants").ClassProp<import("tailwind-merge").ClassNameValue>) | undefined) => string;
27
+ } & import("tailwind-variants").ClassProp<import("tailwind-variants").ClassValue>) | undefined) => string;
28
28
  innerContainer: (slotProps?: ({
29
29
  size?: "sm" | "md" | "lg" | undefined;
30
30
  startContentPointerEvents?: "none" | "auto" | undefined;
31
31
  endContentPointerEvents?: "none" | "auto" | undefined;
32
32
  hasStartContent?: boolean | undefined;
33
33
  hasEndContent?: boolean | undefined;
34
- } & import("tailwind-variants").ClassProp<import("tailwind-merge").ClassNameValue>) | undefined) => string;
34
+ } & import("tailwind-variants").ClassProp<import("tailwind-variants").ClassValue>) | undefined) => string;
35
35
  startContent: (slotProps?: ({
36
36
  size?: "sm" | "md" | "lg" | undefined;
37
37
  startContentPointerEvents?: "none" | "auto" | undefined;
38
38
  endContentPointerEvents?: "none" | "auto" | undefined;
39
39
  hasStartContent?: boolean | undefined;
40
40
  hasEndContent?: boolean | undefined;
41
- } & import("tailwind-variants").ClassProp<import("tailwind-merge").ClassNameValue>) | undefined) => string;
41
+ } & import("tailwind-variants").ClassProp<import("tailwind-variants").ClassValue>) | undefined) => string;
42
42
  endContent: (slotProps?: ({
43
43
  size?: "sm" | "md" | "lg" | undefined;
44
44
  startContentPointerEvents?: "none" | "auto" | undefined;
45
45
  endContentPointerEvents?: "none" | "auto" | undefined;
46
46
  hasStartContent?: boolean | undefined;
47
47
  hasEndContent?: boolean | undefined;
48
- } & import("tailwind-variants").ClassProp<import("tailwind-merge").ClassNameValue>) | undefined) => string;
48
+ } & import("tailwind-variants").ClassProp<import("tailwind-variants").ClassValue>) | undefined) => string;
49
49
  input: (slotProps?: ({
50
50
  size?: "sm" | "md" | "lg" | undefined;
51
51
  startContentPointerEvents?: "none" | "auto" | undefined;
52
52
  endContentPointerEvents?: "none" | "auto" | undefined;
53
53
  hasStartContent?: boolean | undefined;
54
54
  hasEndContent?: boolean | undefined;
55
- } & import("tailwind-variants").ClassProp<import("tailwind-merge").ClassNameValue>) | undefined) => string;
55
+ } & import("tailwind-variants").ClassProp<import("tailwind-variants").ClassValue>) | undefined) => string;
56
56
  } & {
57
57
  input: (slotProps?: ({
58
58
  size?: "sm" | "md" | "lg" | undefined;
@@ -60,9 +60,8 @@ declare class Textarea extends Component<TextareaSignature> {
60
60
  endContentPointerEvents?: "none" | "auto" | undefined;
61
61
  hasStartContent?: boolean | undefined;
62
62
  hasEndContent?: boolean | undefined;
63
- } & import("tailwind-variants").ClassProp<import("tailwind-merge").ClassNameValue>) | undefined) => string;
63
+ } & import("tailwind-variants").ClassProp<import("tailwind-variants").ClassValue>) | undefined) => string;
64
64
  } & {};
65
65
  }
66
66
  export { Textarea, type TextareaSignature };
67
67
  export default Textarea;
68
- //# sourceMappingURL=textarea.d.ts.map
@@ -11,4 +11,4 @@ export * from './components/textarea';
11
11
  export * from './components/radio';
12
12
  export * from './components/radio-group';
13
13
  export * from './components/form-control';
14
- //# sourceMappingURL=index.d.ts.map
14
+ export * from './components/switch';
@@ -13,4 +13,3 @@ export default interface Registry {
13
13
  CheckboxGroup: typeof CheckboxGroup;
14
14
  RadioGroup: typeof RadioGroup;
15
15
  }
16
- //# sourceMappingURL=template-registry.d.ts.map
@@ -0,0 +1,2 @@
1
+ export declare function selectOptionByKey(selectSelector: string, key: string): Promise<void>;
2
+ export declare function toggleOptionByKey(selectSelector: string, key: string): Promise<void>;
@@ -1,3 +1,2 @@
1
1
  declare function triggerFormInputEvent(element?: HTMLElement | null): void;
2
2
  export { triggerFormInputEvent };
3
- //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ export { default } from "@frontile/forms/components/switch";
@@ -5,7 +5,6 @@ import { useStyles } from '@frontile/theme';
5
5
  import { precompileTemplate } from '@ember/template-compilation';
6
6
  import { setComponentTemplate } from '@ember/component';
7
7
 
8
- var _CheckboxGroup;
9
8
  class CheckboxGroup extends Component {
10
9
  get classes() {
11
10
  const {
@@ -15,15 +14,16 @@ class CheckboxGroup extends Component {
15
14
  size: this.args.size
16
15
  });
17
16
  }
17
+ static {
18
+ setComponentTemplate(precompileTemplate("\n <FormControl @size={{@size}} @isRequired={{@isRequired}} @description={{@description}} @errors={{@errors}} @isInvalid={{@isInvalid}} @class={{this.classes.base class=@classes.base}} ...attributes as |c|>\n <c.Label @class={{this.classes.label class=@classes.label}}>\n {{@label}}\n </c.Label>\n <div class={{this.classes.optionsContainer class=@classes.optionsContainer}} data-orientation={{if @orientation @orientation \"vertical\"}}>\n {{yield (component Checkbox name=@name onChange=@onChange size=@size) to=\"default\"}}\n </div>\n </FormControl>\n ", {
19
+ strictMode: true,
20
+ scope: () => ({
21
+ FormControl,
22
+ Checkbox
23
+ })
24
+ }), this);
25
+ }
18
26
  }
19
- _CheckboxGroup = CheckboxGroup;
20
- setComponentTemplate(precompileTemplate("\n <FormControl @size={{@size}} @isRequired={{@isRequired}} @description={{@description}} @errors={{@errors}} @isInvalid={{@isInvalid}} @class={{this.classes.base class=@classes.base}} ...attributes as |c|>\n <c.Label @class={{this.classes.label class=@classes.label}}>\n {{@label}}\n </c.Label>\n <div class={{this.classes.optionsContainer class=@classes.optionsContainer}} data-orientation={{if @orientation @orientation \"vertical\"}}>\n {{yield (component Checkbox name=@name onChange=@onChange size=@size) to=\"default\"}}\n </div>\n </FormControl>\n ", {
21
- strictMode: true,
22
- scope: () => ({
23
- FormControl,
24
- Checkbox
25
- })
26
- }), _CheckboxGroup);
27
27
 
28
28
  export { CheckboxGroup, CheckboxGroup as default };
29
29
  //# sourceMappingURL=checkbox-group.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"checkbox-group.js","sources":["../../src/components/checkbox-group.gts"],"sourcesContent":["import Component from '@glimmer/component';\nimport { Checkbox, type CheckboxSignature } from './checkbox';\nimport { FormControl, type FormControlSharedArgs } from './form-control';\nimport {\n useStyles,\n type CheckboxGroupVariants,\n type CheckboxGroupSlots,\n type SlotsToClasses\n} from '@frontile/theme';\nimport type { WithBoundArgs } from '@glint/template';\n\ninterface Args extends FormControlSharedArgs {\n name?: string;\n onChange?: CheckboxSignature['Args']['onChange'];\n size?: CheckboxGroupVariants['size'];\n classes?: SlotsToClasses<CheckboxGroupSlots>;\n\n /*\n *\n * @defaultValue 'vertical'\n */\n orientation?: 'horizontal' | 'vertical';\n}\n\ninterface CheckboxGroupSignature {\n Args: Args;\n Blocks: {\n default: [Checkbox: WithBoundArgs<typeof Checkbox, 'name' | 'onChange'>];\n };\n Element: HTMLDivElement;\n}\n\nclass CheckboxGroup extends Component<CheckboxGroupSignature> {\n get classes() {\n const { checkboxGroup } = useStyles();\n return checkboxGroup({\n size: this.args.size\n });\n }\n\n <template>\n <FormControl\n @size={{@size}}\n @isRequired={{@isRequired}}\n @description={{@description}}\n @errors={{@errors}}\n @isInvalid={{@isInvalid}}\n @class={{this.classes.base class=@classes.base}}\n ...attributes\n as |c|\n >\n <c.Label @class={{this.classes.label class=@classes.label}}>\n {{@label}}\n </c.Label>\n <div\n class={{this.classes.optionsContainer class=@classes.optionsContainer}}\n data-orientation={{if @orientation @orientation \"vertical\"}}\n >\n {{yield\n (component Checkbox name=@name onChange=@onChange size=@size)\n to=\"default\"\n }}\n </div>\n </FormControl>\n </template>\n}\n\nexport { CheckboxGroup, type CheckboxGroupSignature };\nexport default CheckboxGroup;\n"],"names":["CheckboxGroup","Component","classes","checkboxGroup","useStyles","size","args","_CheckboxGroup","setComponentTemplate","precompileTemplate","strictMode","scope","FormControl","Checkbox"],"mappings":";;;;;;;;AAgCA,MAAMA,sBAAsBC,SAAU,CAAA;EACpC,IAAIC,OAAUA,GAAA;IACZ,MAAM;AAAEC,MAAAA;KAAe,GAAGC,SAAA,EAAA;AAC1B,IAAA,OAAOD,aAAc,CAAA;AACnBE,MAAAA,IAAA,EAAM,IAAI,CAACC,IAAI,CAACD;AAClB,KAAA,CAAA;AACF;AA2BF;AAAAE,cAAA,GAjCMP;AAQJQ,oBAAA,CAAAC,kBAAA,CAwBA,ulBAAA,EAAA;EAAAC,UAAA,EAAA,IAAA;AAAAC,EAAAA,KAAA,EAAAA,OAAA;IAAAC,WAAA;AAAAC,IAAAA;AAAA,GAAA;AAAU,CAAA,CAAA,EAAAN,cAAA,CAAA;;;;"}
1
+ {"version":3,"file":"checkbox-group.js","sources":["../../src/components/checkbox-group.gts"],"sourcesContent":["import Component from '@glimmer/component';\nimport { Checkbox, type CheckboxSignature } from './checkbox';\nimport { FormControl, type FormControlSharedArgs } from './form-control';\nimport {\n useStyles,\n type CheckboxGroupVariants,\n type CheckboxGroupSlots,\n type SlotsToClasses\n} from '@frontile/theme';\nimport type { WithBoundArgs } from '@glint/template';\n\ninterface Args extends FormControlSharedArgs {\n name?: string;\n onChange?: CheckboxSignature['Args']['onChange'];\n size?: CheckboxGroupVariants['size'];\n classes?: SlotsToClasses<CheckboxGroupSlots>;\n\n /*\n *\n * @defaultValue 'vertical'\n */\n orientation?: 'horizontal' | 'vertical';\n}\n\ninterface CheckboxGroupSignature {\n Args: Args;\n Blocks: {\n default: [Checkbox: WithBoundArgs<typeof Checkbox, 'name' | 'onChange'>];\n };\n Element: HTMLDivElement;\n}\n\nclass CheckboxGroup extends Component<CheckboxGroupSignature> {\n get classes() {\n const { checkboxGroup } = useStyles();\n return checkboxGroup({\n size: this.args.size\n });\n }\n\n <template>\n <FormControl\n @size={{@size}}\n @isRequired={{@isRequired}}\n @description={{@description}}\n @errors={{@errors}}\n @isInvalid={{@isInvalid}}\n @class={{this.classes.base class=@classes.base}}\n ...attributes\n as |c|\n >\n <c.Label @class={{this.classes.label class=@classes.label}}>\n {{@label}}\n </c.Label>\n <div\n class={{this.classes.optionsContainer class=@classes.optionsContainer}}\n data-orientation={{if @orientation @orientation \"vertical\"}}\n >\n {{yield\n (component Checkbox name=@name onChange=@onChange size=@size)\n to=\"default\"\n }}\n </div>\n </FormControl>\n </template>\n}\n\nexport { CheckboxGroup, type CheckboxGroupSignature };\nexport default CheckboxGroup;\n"],"names":["CheckboxGroup","Component","classes","checkboxGroup","useStyles","size","args","setComponentTemplate","precompileTemplate","strictMode","scope","FormControl","Checkbox"],"mappings":";;;;;;;AAgCA,MAAMA,sBAAsBC,SAAA,CAAU;EACpC,IAAIC,OAAAA,GAAU;IACZ,MAAM;AAAEC,MAAAA;KAAe,GAAGC,SAAA,EAAA;AAC1B,IAAA,OAAOD,aAAA,CAAc;AACnBE,MAAAA,IAAA,EAAM,IAAI,CAACC,IAAI,CAACD;AAClB,KAAA,CAAA;AACF,EAAA;AAEA,EAAA;IAAAE,oBAAA,CAAAC,kBAAA,CAAA,ulBAAA,EAwBA;MAAAC,UAAA,EAAA,IAAA;AAAAC,MAAAA,KAAA,EAAAA,OAAA;QAAAC,WAAA;AAAAC,QAAAA;AAAA,OAAA;KAAU,CAAA,EAAV,IAAW,CAAA;AAAD;AACZ;;;;"}
@@ -1,4 +1,3 @@
1
- import _applyDecoratedDescriptor from '@babel/runtime/helpers/esm/applyDecoratedDescriptor';
2
1
  import Component from '@glimmer/component';
3
2
  import { action } from '@ember/object';
4
3
  import { on } from '@ember/modifier';
@@ -6,9 +5,9 @@ import { FormControl } from './form-control.js';
6
5
  import { useStyles } from '@frontile/theme';
7
6
  import { precompileTemplate } from '@ember/template-compilation';
8
7
  import { setComponentTemplate } from '@ember/component';
8
+ import { d as decorateMethodV2 } from '../runtime-BPCpkOf1-BKOwiRJp.js';
9
9
 
10
- var _class, _Checkbox;
11
- let Checkbox = (_class = (_Checkbox = class Checkbox extends Component {
10
+ class Checkbox extends Component {
12
11
  get isChecked() {
13
12
  return !!this.args.checked;
14
13
  }
@@ -19,6 +18,9 @@ let Checkbox = (_class = (_Checkbox = class Checkbox extends Component {
19
18
  this.args.onChange(value, event);
20
19
  }
21
20
  }
21
+ static {
22
+ decorateMethodV2(this.prototype, "handleChange", [action]);
23
+ }
22
24
  get classes() {
23
25
  const {
24
26
  checkbox
@@ -27,13 +29,16 @@ let Checkbox = (_class = (_Checkbox = class Checkbox extends Component {
27
29
  size: this.args.size
28
30
  });
29
31
  }
30
- }, setComponentTemplate(precompileTemplate("\n <FormControl @isInvalid={{@isInvalid}} @errors={{@errors}} @size={{@size}} @isRequired={{@isRequired}} @class={{this.classes.base class=@classes.base}} @preventErrorFeedback={{true}} as |c|>\n <input {{on \"change\" this.handleChange}} id={{c.id}} name={{@name}} checked={{this.isChecked}} type=\"checkbox\" class={{this.classes.input class=@classes.input}} data-component=\"checkbox\" aria-invalid={{if c.isInvalid \"true\"}} aria-describedby={{c.describedBy @description c.isInvalid}} ...attributes />\n <div class={{this.classes.labelContainer class=@classes.labelContainer}}>\n {{#if @label}}\n <c.Label @class={{this.classes.label class=@classes.label}}>\n {{@label}}\n </c.Label>\n {{/if}}\n {{#if @description}}\n <c.Description>{{@description}}</c.Description>\n {{/if}}\n {{#if c.isInvalid}}\n <c.Feedback />\n {{/if}}\n </div>\n </FormControl>\n ", {
31
- strictMode: true,
32
- scope: () => ({
33
- FormControl,
34
- on
35
- })
36
- }), _Checkbox), _Checkbox), _applyDecoratedDescriptor(_class.prototype, "handleChange", [action], Object.getOwnPropertyDescriptor(_class.prototype, "handleChange"), _class.prototype), _class);
32
+ static {
33
+ setComponentTemplate(precompileTemplate("\n <FormControl @isInvalid={{@isInvalid}} @errors={{@errors}} @size={{@size}} @isRequired={{@isRequired}} @class={{this.classes.base class=@classes.base}} @preventErrorFeedback={{true}} as |c|>\n <input {{on \"change\" this.handleChange}} id={{c.id}} name={{@name}} checked={{this.isChecked}} type=\"checkbox\" class={{this.classes.input class=@classes.input}} data-component=\"checkbox\" aria-invalid={{if c.isInvalid \"true\"}} aria-describedby={{c.describedBy @description c.isInvalid}} ...attributes />\n <div class={{this.classes.labelContainer class=@classes.labelContainer}}>\n {{#if @label}}\n <c.Label @class={{this.classes.label class=@classes.label}}>\n {{@label}}\n </c.Label>\n {{/if}}\n {{#if @description}}\n <c.Description>{{@description}}</c.Description>\n {{/if}}\n {{#if c.isInvalid}}\n <c.Feedback />\n {{/if}}\n </div>\n </FormControl>\n ", {
34
+ strictMode: true,
35
+ scope: () => ({
36
+ FormControl,
37
+ on
38
+ })
39
+ }), this);
40
+ }
41
+ }
37
42
 
38
43
  export { Checkbox, Checkbox as default };
39
44
  //# sourceMappingURL=checkbox.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"checkbox.js","sources":["../../src/components/checkbox.gts"],"sourcesContent":["import Component from '@glimmer/component';\nimport { action } from '@ember/object';\nimport { on } from '@ember/modifier';\nimport { FormControl, type FormControlSharedArgs } from './form-control';\nimport {\n useStyles,\n type CheckboxVariants,\n type CheckboxSlots,\n type SlotsToClasses\n} from '@frontile/theme';\n\ninterface Args extends FormControlSharedArgs {\n checked?: boolean;\n name?: string;\n size?: CheckboxVariants['size'];\n classes?: SlotsToClasses<CheckboxSlots>;\n\n /*\n * Callback when onchange is triggered\n */\n onChange?: (value: boolean, event: Event) => void;\n}\n\ninterface CheckboxSignature {\n Args: Args;\n Element: HTMLInputElement;\n}\n\nclass Checkbox extends Component<CheckboxSignature> {\n get isChecked(): boolean {\n return !!this.args.checked;\n }\n\n @action handleChange(event: Event): void {\n event.preventDefault();\n\n const value = !this.args.checked;\n\n if (typeof this.args.onChange === 'function') {\n this.args.onChange(value, event);\n }\n }\n\n get classes() {\n const { checkbox } = useStyles();\n return checkbox({\n size: this.args.size\n });\n }\n\n <template>\n <FormControl\n @isInvalid={{@isInvalid}}\n @errors={{@errors}}\n @size={{@size}}\n @isRequired={{@isRequired}}\n @class={{this.classes.base class=@classes.base}}\n @preventErrorFeedback={{true}}\n as |c|\n >\n <input\n {{on \"change\" this.handleChange}}\n id={{c.id}}\n name={{@name}}\n checked={{this.isChecked}}\n type=\"checkbox\"\n class={{this.classes.input class=@classes.input}}\n data-component=\"checkbox\"\n aria-invalid={{if c.isInvalid \"true\"}}\n aria-describedby={{c.describedBy @description c.isInvalid}}\n ...attributes\n />\n <div class={{this.classes.labelContainer class=@classes.labelContainer}}>\n {{#if @label}}\n <c.Label @class={{this.classes.label class=@classes.label}}>\n {{@label}}\n </c.Label>\n {{/if}}\n {{#if @description}}\n <c.Description>{{@description}}</c.Description>\n {{/if}}\n {{#if c.isInvalid}}\n <c.Feedback />\n {{/if}}\n </div>\n </FormControl>\n </template>\n}\n\nexport { Checkbox, type CheckboxSignature };\nexport default Checkbox;\n"],"names":["Checkbox","Component","isChecked","args","checked","handleChange","event","preventDefault","value","onChange","classes","checkbox","useStyles","size","setComponentTemplate","precompileTemplate","strictMode","scope","FormControl","on","_Checkbox","_applyDecoratedDescriptor","_class","prototype","action","Object","getOwnPropertyDescriptor"],"mappings":";;;;;;;;;;AA4BMA,IAAAA,kCAAN,MAAMA,iBAAiBC,SAAU,CAAA;EAC/B,IAAIC,SAAAA,GAAqB;AACvB,IAAA,OAAO,CAAC,CAAC,IAAI,CAACC,IAAI,CAACC,OAAO;AAC5B;EAEQC,YAAAA,CAAaC,KAAY,EAAQ;IACvCA,KAAA,CAAMC,cAAc,EAAA;AAEpB,IAAA,MAAMC,QAAQ,CAAC,IAAI,CAACL,IAAI,CAACC,OAAO;IAEhC,IAAI,OAAO,IAAI,CAACD,IAAI,CAACM,QAAQ,KAAK,UAAY,EAAA;MAC5C,IAAI,CAACN,IAAI,CAACM,QAAQ,CAACD,KAAO,EAAAF,KAAA,CAAA;AAC5B;AACF;EAEA,IAAII,OAAUA,GAAA;IACZ,MAAM;AAAEC,MAAAA;KAAU,GAAGC,SAAA,EAAA;AACrB,IAAA,OAAOD,QAAS,CAAA;AACdE,MAAAA,IAAA,EAAM,IAAI,CAACV,IAAI,CAACU;AAClB,KAAA,CAAA;AACF;AAuCF,CAAA,EAAAC,oBAAA,CArCEC,kBAAA,CAoCA,48BAAA,EAAA;EAAAC,UAAA,EAAA,IAAA;AAAAC,EAAAA,KAAA,EAAAA,OAAA;IAAAC,WAAA;AAAAC,IAAAA;AAAA,GAAA;AAAU,CAAA,CAAA,EAAAC,SAAA,CAAAA,EAAAA,SAAA,CAAAC,EAAAA,yBAAA,CAAAC,MAAA,CAAAC,SAAA,EArDTC,cAAAA,EAAAA,CAAAA,MAAA,GAAAC,MAAA,CAAAC,wBAAA,CAAAJ,MAAA,CAAAC,SAAA,EAAA,cAAA,CAAA,EAAAD,MAAA,CAAAC,SAAA,CAAA,EAAAD,MAAA;;;;"}
1
+ {"version":3,"file":"checkbox.js","sources":["../../src/components/checkbox.gts"],"sourcesContent":["import Component from '@glimmer/component';\nimport { action } from '@ember/object';\nimport { on } from '@ember/modifier';\nimport { FormControl, type FormControlSharedArgs } from './form-control';\nimport {\n useStyles,\n type CheckboxVariants,\n type CheckboxSlots,\n type SlotsToClasses\n} from '@frontile/theme';\n\ninterface Args extends FormControlSharedArgs {\n checked?: boolean;\n name?: string;\n size?: CheckboxVariants['size'];\n classes?: SlotsToClasses<CheckboxSlots>;\n\n /*\n * Callback when onchange is triggered\n */\n onChange?: (value: boolean, event: Event) => void;\n}\n\ninterface CheckboxSignature {\n Args: Args;\n Element: HTMLInputElement;\n}\n\nclass Checkbox extends Component<CheckboxSignature> {\n get isChecked(): boolean {\n return !!this.args.checked;\n }\n\n @action handleChange(event: Event): void {\n event.preventDefault();\n\n const value = !this.args.checked;\n\n if (typeof this.args.onChange === 'function') {\n this.args.onChange(value, event);\n }\n }\n\n get classes() {\n const { checkbox } = useStyles();\n return checkbox({\n size: this.args.size\n });\n }\n\n <template>\n <FormControl\n @isInvalid={{@isInvalid}}\n @errors={{@errors}}\n @size={{@size}}\n @isRequired={{@isRequired}}\n @class={{this.classes.base class=@classes.base}}\n @preventErrorFeedback={{true}}\n as |c|\n >\n <input\n {{on \"change\" this.handleChange}}\n id={{c.id}}\n name={{@name}}\n checked={{this.isChecked}}\n type=\"checkbox\"\n class={{this.classes.input class=@classes.input}}\n data-component=\"checkbox\"\n aria-invalid={{if c.isInvalid \"true\"}}\n aria-describedby={{c.describedBy @description c.isInvalid}}\n ...attributes\n />\n <div class={{this.classes.labelContainer class=@classes.labelContainer}}>\n {{#if @label}}\n <c.Label @class={{this.classes.label class=@classes.label}}>\n {{@label}}\n </c.Label>\n {{/if}}\n {{#if @description}}\n <c.Description>{{@description}}</c.Description>\n {{/if}}\n {{#if c.isInvalid}}\n <c.Feedback />\n {{/if}}\n </div>\n </FormControl>\n </template>\n}\n\nexport { Checkbox, type CheckboxSignature };\nexport default Checkbox;\n"],"names":["Checkbox","Component","isChecked","args","checked","handleChange","event","preventDefault","value","onChange","n","prototype","action","classes","checkbox","useStyles","size","setComponentTemplate","precompileTemplate","strictMode","scope","FormControl","on"],"mappings":";;;;;;;;;AA4BA,MAAMA,iBAAiBC,SAAA,CAAU;EAC/B,IAAIC,SAAAA,GAAqB;AACvB,IAAA,OAAO,CAAC,CAAC,IAAI,CAACC,IAAI,CAACC,OAAO;AAC5B,EAAA;EAEQC,YAAAA,CAAaC,KAAY,EAAQ;IACvCA,KAAA,CAAMC,cAAc,EAAA;AAEpB,IAAA,MAAMC,QAAQ,CAAC,IAAI,CAACL,IAAI,CAACC,OAAO;IAEhC,IAAI,OAAO,IAAI,CAACD,IAAI,CAACM,QAAQ,KAAK,UAAA,EAAY;MAC5C,IAAI,CAACN,IAAI,CAACM,QAAQ,CAACD,KAAA,EAAOF,KAAA,CAAA;AAC5B,IAAA;AACF,EAAA;AAAA,EAAA;IAAAI,gBAAA,CAAA,IAAA,CAAAC,SAAA,EAAA,cAAA,EAAA,CARCC,MAAA,CAAA,CAAA;AAAA;EAUD,IAAIC,OAAAA,GAAU;IACZ,MAAM;AAAEC,MAAAA;KAAU,GAAGC,SAAA,EAAA;AACrB,IAAA,OAAOD,QAAA,CAAS;AACdE,MAAAA,IAAA,EAAM,IAAI,CAACb,IAAI,CAACa;AAClB,KAAA,CAAA;AACF,EAAA;AAEA,EAAA;IAAAC,oBAAA,CAAAC,kBAAA,CAAA,48BAAA,EAoCA;MAAAC,UAAA,EAAA,IAAA;AAAAC,MAAAA,KAAA,EAAAA,OAAA;QAAAC,WAAA;AAAAC,QAAAA;AAAA,OAAA;KAAU,CAAA,EAAV,IAAW,CAAA;AAAD;AACZ;;;;"}
@@ -1,4 +1,3 @@
1
- import _defineProperty from '@babel/runtime/helpers/esm/defineProperty';
2
1
  import Component from '@glimmer/component';
3
2
  import { guidFor } from '@ember/object/internals';
4
3
  import { hash } from '@ember/helper';
@@ -8,33 +7,29 @@ import { Label } from './label.js';
8
7
  import { precompileTemplate } from '@ember/template-compilation';
9
8
  import { setComponentTemplate } from '@ember/component';
10
9
 
11
- var _FormControl;
12
10
  function or(arg1, arg2) {
13
11
  return !!(arg1 || arg2);
14
12
  }
15
13
  class FormControl extends Component {
16
- constructor(...args) {
17
- super(...args);
18
- _defineProperty(this, "id", this.args.id || guidFor(this));
19
- _defineProperty(this, "describedBy", (hasDescription, hasFeedback) => {
20
- const ids = [];
21
- if (hasDescription) {
22
- ids.push(this.descriptionId);
23
- }
24
- if (hasFeedback) {
25
- ids.push(this.feedbackId);
26
- }
27
- if (ids.length > 0) {
28
- return ids.join(' ');
29
- }
30
- });
31
- }
14
+ id = this.args.id || guidFor(this);
32
15
  get descriptionId() {
33
16
  return this.id + '-description';
34
17
  }
35
18
  get feedbackId() {
36
19
  return this.id + '-feedback';
37
20
  }
21
+ describedBy = (hasDescription, hasFeedback) => {
22
+ const ids = [];
23
+ if (hasDescription) {
24
+ ids.push(this.descriptionId);
25
+ }
26
+ if (hasFeedback) {
27
+ ids.push(this.feedbackId);
28
+ }
29
+ if (ids.length > 0) {
30
+ return ids.join(' ');
31
+ }
32
+ };
38
33
  get isInvalid() {
39
34
  if (this.args.isInvalid || this.args.errors && this.args.errors.length > 0) {
40
35
  return true;
@@ -48,18 +43,19 @@ class FormControl extends Component {
48
43
  }
49
44
  return false;
50
45
  }
46
+ static {
47
+ setComponentTemplate(precompileTemplate("\n <div class={{@class}} ...attributes>\n {{#if (or @label (has-block \"label\"))}}\n <Label @for={{this.id}} @isRequired={{@isRequired}} @size={{@size}}>\n {{@label}}\n {{yield to=\"label\"}}\n </Label>\n {{/if}}\n\n {{#if (or @description (has-block \"Description\"))}}\n <Description @id={{this.descriptionId}} @size={{@size}}>\n {{@description}}\n {{yield to=\"description\"}}\n </Description>\n {{/if}}\n\n {{yield (hash id=this.id isInvalid=this.isInvalid describedBy=this.describedBy Label=(component Label for=this.id size=@size isRequired=@isRequired) Description=(component Description id=this.descriptionId size=@size) Feedback=(component Feedback id=this.feedbackId size=@size messages=@errors intent=\"danger\")) to=\"default\"}}\n\n {{#if this.showErrorFeedback}}\n <Feedback @id={{this.feedbackId}} @size={{@size}} @messages={{@errors}} @intent=\"danger\" />\n {{/if}}\n </div>\n ", {
48
+ strictMode: true,
49
+ scope: () => ({
50
+ or,
51
+ Label,
52
+ Description: FormDescription,
53
+ hash,
54
+ Feedback: FormFeedback
55
+ })
56
+ }), this);
57
+ }
51
58
  }
52
- _FormControl = FormControl;
53
- setComponentTemplate(precompileTemplate("\n <div class={{@class}} ...attributes>\n {{#if (or @label (has-block \"label\"))}}\n <Label @for={{this.id}} @isRequired={{@isRequired}} @size={{@size}}>\n {{@label}}\n {{yield to=\"label\"}}\n </Label>\n {{/if}}\n\n {{#if (or @description (has-block \"Description\"))}}\n <Description @id={{this.descriptionId}} @size={{@size}}>\n {{@description}}\n {{yield to=\"description\"}}\n </Description>\n {{/if}}\n\n {{yield (hash id=this.id isInvalid=this.isInvalid describedBy=this.describedBy Label=(component Label for=this.id size=@size isRequired=@isRequired) Description=(component Description id=this.descriptionId size=@size) Feedback=(component Feedback id=this.feedbackId size=@size messages=@errors intent=\"danger\")) to=\"default\"}}\n\n {{#if this.showErrorFeedback}}\n <Feedback @id={{this.feedbackId}} @size={{@size}} @messages={{@errors}} @intent=\"danger\" />\n {{/if}}\n </div>\n ", {
54
- strictMode: true,
55
- scope: () => ({
56
- or,
57
- Label,
58
- Description: FormDescription,
59
- hash,
60
- Feedback: FormFeedback
61
- })
62
- }), _FormControl);
63
59
 
64
60
  export { FormControl, FormControl as default };
65
61
  //# sourceMappingURL=form-control.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"form-control.js","sources":["../../src/components/form-control.gts"],"sourcesContent":["import Component from '@glimmer/component';\nimport { guidFor } from '@ember/object/internals';\nimport { hash } from '@ember/helper';\nimport Feedback from './form-feedback';\nimport Description from './form-description';\nimport Label from './label';\nimport type { WithBoundArgs } from '@glint/template';\n\ninterface FormControlSharedArgs {\n label?: string;\n isRequired?: boolean;\n description?: string;\n errors?: string[] | string;\n isInvalid?: boolean;\n}\n\ninterface Args extends FormControlSharedArgs {\n id?: string;\n size?: 'sm' | 'md' | 'lg';\n preventErrorFeedback?: boolean;\n class?: string;\n}\n\ninterface FormControlSignature {\n Args: Args;\n Blocks: {\n default: [\n {\n id: string;\n isInvalid: boolean;\n describedBy: (\n hasDescription?: string | boolean,\n hasFeedback?: string | boolean\n ) => string | undefined;\n Label: WithBoundArgs<typeof Label, 'for' | 'size' | 'isRequired'>;\n Description: WithBoundArgs<typeof Description, 'id' | 'size'>;\n Feedback: WithBoundArgs<\n typeof Feedback,\n 'id' | 'size' | 'messages' | 'intent'\n >;\n }\n ];\n label: [];\n description: [];\n };\n Element: HTMLDivElement;\n}\n\nfunction or(arg1: unknown, arg2: unknown): boolean {\n return !!(arg1 || arg2);\n}\n\nclass FormControl extends Component<FormControlSignature> {\n id = this.args.id || guidFor(this);\n\n get descriptionId(): string {\n return this.id + '-description';\n }\n\n get feedbackId(): string {\n return this.id + '-feedback';\n }\n\n describedBy = (\n hasDescription?: string | boolean,\n hasFeedback?: string | boolean\n ): string | undefined => {\n const ids = [];\n\n if (hasDescription) {\n ids.push(this.descriptionId);\n }\n\n if (hasFeedback) {\n ids.push(this.feedbackId);\n }\n\n if (ids.length > 0) {\n return ids.join(' ');\n }\n };\n\n get isInvalid(): boolean {\n if (\n this.args.isInvalid ||\n (this.args.errors && this.args.errors.length > 0)\n ) {\n return true;\n } else {\n return false;\n }\n }\n\n get showErrorFeedback(): boolean {\n if (!(this.args.preventErrorFeedback === true) && this.isInvalid) {\n return true;\n }\n return false;\n }\n\n <template>\n <div class={{@class}} ...attributes>\n {{#if (or @label (has-block \"label\"))}}\n <Label @for={{this.id}} @isRequired={{@isRequired}} @size={{@size}}>\n {{@label}}\n {{yield to=\"label\"}}\n </Label>\n {{/if}}\n\n {{#if (or @description (has-block \"Description\"))}}\n <Description @id={{this.descriptionId}} @size={{@size}}>\n {{@description}}\n {{yield to=\"description\"}}\n </Description>\n {{/if}}\n\n {{yield\n (hash\n id=this.id\n isInvalid=this.isInvalid\n describedBy=this.describedBy\n Label=(component Label for=this.id size=@size isRequired=@isRequired)\n Description=(component Description id=this.descriptionId size=@size)\n Feedback=(component\n Feedback\n id=this.feedbackId\n size=@size\n messages=@errors\n intent=\"danger\"\n )\n )\n to=\"default\"\n }}\n\n {{#if this.showErrorFeedback}}\n <Feedback\n @id={{this.feedbackId}}\n @size={{@size}}\n @messages={{@errors}}\n @intent=\"danger\"\n />\n {{/if}}\n </div>\n </template>\n}\n\nexport { FormControl, type FormControlSignature, type FormControlSharedArgs };\nexport default FormControl;\n"],"names":["or","arg1","arg2","FormControl","Component","constructor","args","_defineProperty","id","guidFor","hasDescription","hasFeedback","ids","push","descriptionId","feedbackId","length","join","isInvalid","errors","showErrorFeedback","preventErrorFeedback","_FormControl","setComponentTemplate","precompileTemplate","strictMode","scope","Label","Description","hash","Feedback"],"mappings":";;;;;;;;;;;AAgDA,SAASA,GAAGC,IAAa,EAAEC,IAAa,EAAU;AAChD,EAAA,OAAO,CAAC,EAAED,IAAA,IAAQC,IAAI,CAAA;AACxB;AAEA,MAAMC,oBAAoBC,SAAU,CAAA;AAAAC,EAAAA,WAAAA,CAAA,GAAAC,IAAA,EAAA;AAAA,IAAA,KAAA,CAAA,GAAAA,IAAA,CAAA;IAAAC,eAAA,CAAA,IAAA,EAAA,IAAA,EAC7B,IAAI,CAACD,IAAI,CAACE,EAAE,IAAIC,OAAA,CAAQ,IAAI,CAAE,CAAA;AAAAF,IAAAA,eAAA,CAUrB,IAAA,EAAA,aAAA,EAAA,CACZG,cAAiC,EACjCC,WAA8B,KACX;MACnB,MAAMC,MAAM,EAAE;AAEd,MAAA,IAAIF,cAAgB,EAAA;AAClBE,QAAAA,GAAA,CAAIC,IAAI,CAAC,IAAI,CAACC,aAAa,CAAA;AAC7B;AAEA,MAAA,IAAIH,WAAa,EAAA;AACfC,QAAAA,GAAA,CAAIC,IAAI,CAAC,IAAI,CAACE,UAAU,CAAA;AAC1B;AAEA,MAAA,IAAIH,GAAA,CAAII,MAAM,GAAG,CAAG,EAAA;AAClB,QAAA,OAAOJ,GAAA,CAAIK,IAAI,CAAC,GAAA,CAAA;AAClB;KACA,CAAA;AAAA;EAzBF,IAAIH,aAAAA,GAAwB;AAC1B,IAAA,OAAO,IAAI,CAACN,EAAE,GAAG,cAAA;AACnB;EAEA,IAAIO,UAAAA,GAAqB;AACvB,IAAA,OAAO,IAAI,CAACP,EAAE,GAAG,WAAA;AACnB;EAqBA,IAAIU,SAAAA,GAAqB;IACvB,IACE,IAAI,CAACZ,IAAI,CAACY,SAAS,IAClB,IAAI,CAACZ,IAAI,CAACa,MAAM,IAAI,IAAI,CAACb,IAAI,CAACa,MAAM,CAACH,MAAM,GAAG,CAC/C,EAAA;AACA,MAAA,OAAO,IAAA;AACT,KAAO,MAAA;AACL,MAAA,OAAO,KAAA;AACT;AACF;EAEA,IAAII,iBAAAA,GAA6B;AAC/B,IAAA,IAAI,EAAE,IAAI,CAACd,IAAI,CAACe,oBAAoB,KAAK,IAAI,CAAA,IAAK,IAAI,CAACH,SAAS,EAAE;AAChE,MAAA,OAAO,IAAA;AACT;AACA,IAAA,OAAO,KAAA;AACT;AA8CF;AAAAI,YAAA,GA5FMnB;AAgDJoB,oBAAA,CAAAC,kBAAA,CA2CA,k/BAAA,EAAA;EAAAC,UAAA,EAAA,IAAA;AAAAC,EAAAA,KAAA,EAAAA,OAAA;IAAA1B,EAAA;IAAA2B,KAAA;iBAAAC,eAAA;IAAAC,IAAA;AAAAC,cAAAA;AAAA,GAAA;AAAU,CAAA,CAAA,EAAAR,YAAA,CAAA;;;;"}
1
+ {"version":3,"file":"form-control.js","sources":["../../src/components/form-control.gts"],"sourcesContent":["import Component from '@glimmer/component';\nimport { guidFor } from '@ember/object/internals';\nimport { hash } from '@ember/helper';\nimport Feedback from './form-feedback';\nimport Description from './form-description';\nimport Label from './label';\nimport type { WithBoundArgs } from '@glint/template';\n\ninterface FormControlSharedArgs {\n label?: string;\n isRequired?: boolean;\n description?: string;\n errors?: string[] | string;\n isInvalid?: boolean;\n}\n\ninterface Args extends FormControlSharedArgs {\n id?: string;\n size?: 'sm' | 'md' | 'lg';\n preventErrorFeedback?: boolean;\n class?: string;\n}\n\ninterface FormControlSignature {\n Args: Args;\n Blocks: {\n default: [\n {\n id: string;\n isInvalid: boolean;\n describedBy: (\n hasDescription?: string | boolean,\n hasFeedback?: string | boolean\n ) => string | undefined;\n Label: WithBoundArgs<typeof Label, 'for' | 'size' | 'isRequired'>;\n Description: WithBoundArgs<typeof Description, 'id' | 'size'>;\n Feedback: WithBoundArgs<\n typeof Feedback,\n 'id' | 'size' | 'messages' | 'intent'\n >;\n }\n ];\n label: [];\n description: [];\n };\n Element: HTMLDivElement;\n}\n\nfunction or(arg1: unknown, arg2: unknown): boolean {\n return !!(arg1 || arg2);\n}\n\nclass FormControl extends Component<FormControlSignature> {\n id = this.args.id || guidFor(this);\n\n get descriptionId(): string {\n return this.id + '-description';\n }\n\n get feedbackId(): string {\n return this.id + '-feedback';\n }\n\n describedBy = (\n hasDescription?: string | boolean,\n hasFeedback?: string | boolean\n ): string | undefined => {\n const ids = [];\n\n if (hasDescription) {\n ids.push(this.descriptionId);\n }\n\n if (hasFeedback) {\n ids.push(this.feedbackId);\n }\n\n if (ids.length > 0) {\n return ids.join(' ');\n }\n };\n\n get isInvalid(): boolean {\n if (\n this.args.isInvalid ||\n (this.args.errors && this.args.errors.length > 0)\n ) {\n return true;\n } else {\n return false;\n }\n }\n\n get showErrorFeedback(): boolean {\n if (!(this.args.preventErrorFeedback === true) && this.isInvalid) {\n return true;\n }\n return false;\n }\n\n <template>\n <div class={{@class}} ...attributes>\n {{#if (or @label (has-block \"label\"))}}\n <Label @for={{this.id}} @isRequired={{@isRequired}} @size={{@size}}>\n {{@label}}\n {{yield to=\"label\"}}\n </Label>\n {{/if}}\n\n {{#if (or @description (has-block \"Description\"))}}\n <Description @id={{this.descriptionId}} @size={{@size}}>\n {{@description}}\n {{yield to=\"description\"}}\n </Description>\n {{/if}}\n\n {{yield\n (hash\n id=this.id\n isInvalid=this.isInvalid\n describedBy=this.describedBy\n Label=(component Label for=this.id size=@size isRequired=@isRequired)\n Description=(component Description id=this.descriptionId size=@size)\n Feedback=(component\n Feedback\n id=this.feedbackId\n size=@size\n messages=@errors\n intent=\"danger\"\n )\n )\n to=\"default\"\n }}\n\n {{#if this.showErrorFeedback}}\n <Feedback\n @id={{this.feedbackId}}\n @size={{@size}}\n @messages={{@errors}}\n @intent=\"danger\"\n />\n {{/if}}\n </div>\n </template>\n}\n\nexport { FormControl, type FormControlSignature, type FormControlSharedArgs };\nexport default FormControl;\n"],"names":["or","arg1","arg2","FormControl","Component","id","args","guidFor","descriptionId","feedbackId","describedBy","hasDescription","hasFeedback","ids","push","length","join","isInvalid","errors","showErrorFeedback","preventErrorFeedback","setComponentTemplate","precompileTemplate","strictMode","scope","Label","Description","hash","Feedback"],"mappings":";;;;;;;;;AAgDA,SAASA,GAAGC,IAAa,EAAEC,IAAa,EAAU;AAChD,EAAA,OAAO,CAAC,EAAED,IAAA,IAAQC,IAAI,CAAA;AACxB;AAEA,MAAMC,oBAAoBC,SAAA,CAAU;EAClCC,EAAA,GAAK,IAAI,CAACC,IAAI,CAACD,EAAE,IAAIE,OAAA,CAAQ,IAAI,CAAA;EAEjC,IAAIC,aAAAA,GAAwB;AAC1B,IAAA,OAAO,IAAI,CAACH,EAAE,GAAG,cAAA;AACnB,EAAA;EAEA,IAAII,UAAAA,GAAqB;AACvB,IAAA,OAAO,IAAI,CAACJ,EAAE,GAAG,WAAA;AACnB,EAAA;AAEAK,EAAAA,WAAA,GAAcA,CACZC,cAAiC,EACjCC,WAA8B,KACX;IACnB,MAAMC,MAAM,EAAE;AAEd,IAAA,IAAIF,cAAA,EAAgB;AAClBE,MAAAA,GAAA,CAAIC,IAAI,CAAC,IAAI,CAACN,aAAa,CAAA;AAC7B,IAAA;AAEA,IAAA,IAAII,WAAA,EAAa;AACfC,MAAAA,GAAA,CAAIC,IAAI,CAAC,IAAI,CAACL,UAAU,CAAA;AAC1B,IAAA;AAEA,IAAA,IAAII,GAAA,CAAIE,MAAM,GAAG,CAAA,EAAG;AAClB,MAAA,OAAOF,GAAA,CAAIG,IAAI,CAAC,GAAA,CAAA;AAClB,IAAA;EACF,CAAA;EAEA,IAAIC,SAAAA,GAAqB;IACvB,IACE,IAAI,CAACX,IAAI,CAACW,SAAS,IAClB,IAAI,CAACX,IAAI,CAACY,MAAM,IAAI,IAAI,CAACZ,IAAI,CAACY,MAAM,CAACH,MAAM,GAAG,CAAC,EAChD;AACA,MAAA,OAAO,IAAA;AACT,IAAA,CAAA,MAAO;AACL,MAAA,OAAO,KAAA;AACT,IAAA;AACF,EAAA;EAEA,IAAII,iBAAAA,GAA6B;AAC/B,IAAA,IAAI,EAAE,IAAI,CAACb,IAAI,CAACc,oBAAoB,KAAK,IAAI,CAAA,IAAK,IAAI,CAACH,SAAS,EAAE;AAChE,MAAA,OAAO,IAAA;AACT,IAAA;AACA,IAAA,OAAO,KAAA;AACT,EAAA;AAEA,EAAA;IAAAI,oBAAA,CAAAC,kBAAA,CAAA,k/BAAA,EA2CA;MAAAC,UAAA,EAAA,IAAA;AAAAC,MAAAA,KAAA,EAAAA,OAAA;QAAAxB,EAAA;QAAAyB,KAAA;qBAAAC,eAAA;QAAAC,IAAA;AAAAC,kBAAAA;AAAA,OAAA;KAAU,CAAA,EAAV,IAAW,CAAA;AAAD;AACZ;;;;"}
@@ -3,7 +3,6 @@ import { useStyles } from '@frontile/theme';
3
3
  import { precompileTemplate } from '@ember/template-compilation';
4
4
  import { setComponentTemplate } from '@ember/component';
5
5
 
6
- var _FormDescription;
7
6
  class FormDescription extends Component {
8
7
  get classes() {
9
8
  const {
@@ -14,11 +13,12 @@ class FormDescription extends Component {
14
13
  class: this.args.class
15
14
  });
16
15
  }
16
+ static {
17
+ setComponentTemplate(precompileTemplate("\n <div id={{@id}} class={{this.classes}} data-component=\"form-description\" ...attributes>\n {{yield}}\n </div>\n ", {
18
+ strictMode: true
19
+ }), this);
20
+ }
17
21
  }
18
- _FormDescription = FormDescription;
19
- setComponentTemplate(precompileTemplate("\n <div id={{@id}} class={{this.classes}} data-component=\"form-description\" ...attributes>\n {{yield}}\n </div>\n ", {
20
- strictMode: true
21
- }), _FormDescription);
22
22
 
23
23
  export { FormDescription, FormDescription as default };
24
24
  //# sourceMappingURL=form-description.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"form-description.js","sources":["../../src/components/form-description.gts"],"sourcesContent":["import Component from '@glimmer/component';\nimport { useStyles, type FormDescriptionVariants } from '@frontile/theme';\n\ninterface FormDescriptionSignature {\n Args: {\n id?: string;\n /*\n * @defaultValue 'md'\n */\n size?: FormDescriptionVariants['size'];\n\n class?: string;\n };\n Element: HTMLDivElement;\n Blocks: {\n default: [];\n };\n}\n\nclass FormDescription extends Component<FormDescriptionSignature> {\n get classes() {\n const { formDescription } = useStyles();\n\n return formDescription({\n size: this.args.size || 'md',\n class: this.args.class\n });\n }\n\n <template>\n <div\n id={{@id}}\n class={{this.classes}}\n data-component=\"form-description\"\n ...attributes\n >\n {{yield}}\n </div>\n </template>\n}\n\nexport { FormDescription, type FormDescriptionSignature };\nexport default FormDescription;\n"],"names":["FormDescription","Component","classes","formDescription","useStyles","size","args","class","_FormDescription","setComponentTemplate","precompileTemplate","strictMode"],"mappings":";;;;;;AAmBA,MAAMA,wBAAwBC,SAAU,CAAA;EACtC,IAAIC,OAAUA,GAAA;IACZ,MAAM;AAAEC,MAAAA;KAAiB,GAAGC,SAAA,EAAA;AAE5B,IAAA,OAAOD,eAAgB,CAAA;AACrBE,MAAAA,IAAA,EAAM,IAAI,CAACC,IAAI,CAACD,IAAI,IAAI,IAAA;AACxBE,MAAAA,KAAA,EAAO,IAAI,CAACD,IAAI,CAACC;AACnB,KAAA,CAAA;AACF;AAYF;AAAAC,gBAAA,GApBMR;AAUJS,oBAAA,CAAAC,kBAAA,CASA,kIAAA,EAAA;EAAAC,UAAA,EAAA;AAAU,CAAA,CAAA,EAAAH,gBAAA,CAAA;;;;"}
1
+ {"version":3,"file":"form-description.js","sources":["../../src/components/form-description.gts"],"sourcesContent":["import Component from '@glimmer/component';\nimport { useStyles, type FormDescriptionVariants } from '@frontile/theme';\n\ninterface FormDescriptionSignature {\n Args: {\n id?: string;\n /*\n * @defaultValue 'md'\n */\n size?: FormDescriptionVariants['size'];\n\n class?: string;\n };\n Element: HTMLDivElement;\n Blocks: {\n default: [];\n };\n}\n\nclass FormDescription extends Component<FormDescriptionSignature> {\n get classes() {\n const { formDescription } = useStyles();\n\n return formDescription({\n size: this.args.size || 'md',\n class: this.args.class\n });\n }\n\n <template>\n <div\n id={{@id}}\n class={{this.classes}}\n data-component=\"form-description\"\n ...attributes\n >\n {{yield}}\n </div>\n </template>\n}\n\nexport { FormDescription, type FormDescriptionSignature };\nexport default FormDescription;\n"],"names":["FormDescription","Component","classes","formDescription","useStyles","size","args","class","setComponentTemplate","precompileTemplate","strictMode"],"mappings":";;;;;AAmBA,MAAMA,wBAAwBC,SAAA,CAAU;EACtC,IAAIC,OAAAA,GAAU;IACZ,MAAM;AAAEC,MAAAA;KAAiB,GAAGC,SAAA,EAAA;AAE5B,IAAA,OAAOD,eAAA,CAAgB;AACrBE,MAAAA,IAAA,EAAM,IAAI,CAACC,IAAI,CAACD,IAAI,IAAI,IAAA;AACxBE,MAAAA,KAAA,EAAO,IAAI,CAACD,IAAI,CAACC;AACnB,KAAA,CAAA;AACF,EAAA;AAEA,EAAA;IAAAC,oBAAA,CAAAC,kBAAA,CAAA,kIAAA,EASA;MAAAC,UAAA,EAAA;KAAU,CAAA,EAAV,IAAW,CAAA;AAAD;AACZ;;;;"}
@@ -3,7 +3,6 @@ import { useStyles } from '@frontile/theme';
3
3
  import { precompileTemplate } from '@ember/template-compilation';
4
4
  import { setComponentTemplate } from '@ember/component';
5
5
 
6
- var _FormFeedback;
7
6
  class FormFeedback extends Component {
8
7
  get isError() {
9
8
  return typeof this.args.messages !== 'undefined' && (this.args.intent === 'danger' || typeof this.args.intent === 'undefined');
@@ -26,11 +25,12 @@ class FormFeedback extends Component {
26
25
  return this.args.messages.join('; ');
27
26
  }
28
27
  }
28
+ static {
29
+ setComponentTemplate(precompileTemplate("\n <div id={{@id}} class={{this.classes}} data-component=\"form-feedback\" aria-live={{if this.isError \"assertive\" \"polite\"}} ...attributes>\n {{this.messageText}}\n {{yield}}\n </div>\n ", {
30
+ strictMode: true
31
+ }), this);
32
+ }
29
33
  }
30
- _FormFeedback = FormFeedback;
31
- setComponentTemplate(precompileTemplate("\n <div id={{@id}} class={{this.classes}} data-component=\"form-feedback\" aria-live={{if this.isError \"assertive\" \"polite\"}} ...attributes>\n {{this.messageText}}\n {{yield}}\n </div>\n ", {
32
- strictMode: true
33
- }), _FormFeedback);
34
34
 
35
35
  export { FormFeedback, FormFeedback as default };
36
36
  //# sourceMappingURL=form-feedback.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"form-feedback.js","sources":["../../src/components/form-feedback.gts"],"sourcesContent":["import Component from '@glimmer/component';\nimport { useStyles, type FormFeedbackVariants } from '@frontile/theme';\n\ninterface FormFeedbackSignature {\n Args: {\n id?: string;\n /*\n * A list of messages or a single message string\n */\n messages?: string[] | string;\n\n /*\n * The intent of the feedback\n * @defaultValue 'danger'\n */\n intent?: FormFeedbackVariants['intent'];\n\n /*\n * @defaultValue 'md'\n */\n size?: FormFeedbackVariants['size'];\n class?: string;\n };\n Element: HTMLDivElement;\n Blocks: {\n default: [];\n };\n}\n\nclass FormFeedback extends Component<FormFeedbackSignature> {\n get isError(): boolean {\n return (\n typeof this.args.messages !== 'undefined' &&\n (this.args.intent === 'danger' || typeof this.args.intent === 'undefined')\n );\n }\n\n get classes() {\n const { formFeedback } = useStyles();\n\n return formFeedback({\n size: this.args.size || 'md',\n intent: this.args.intent || 'danger',\n class: this.args.class\n });\n }\n\n get messageText(): string {\n if (!this.args.messages) return '';\n\n if (typeof this.args.messages === 'string') {\n return this.args.messages;\n } else {\n return this.args.messages.join('; ');\n }\n }\n\n <template>\n <div\n id={{@id}}\n class={{this.classes}}\n data-component=\"form-feedback\"\n aria-live={{if this.isError \"assertive\" \"polite\"}}\n ...attributes\n >\n {{this.messageText}}\n {{yield}}\n </div>\n </template>\n}\n\nexport { FormFeedback, type FormFeedbackSignature };\nexport default FormFeedback;\n"],"names":["FormFeedback","Component","isError","args","messages","intent","classes","formFeedback","useStyles","size","class","messageText","join","_FormFeedback","setComponentTemplate","precompileTemplate","strictMode"],"mappings":";;;;;;AA6BA,MAAMA,qBAAqBC,SAAU,CAAA;EACnC,IAAIC,OAAAA,GAAmB;IACrB,OACE,OAAO,IAAI,CAACC,IAAI,CAACC,QAAQ,KAAK,WAC9B,KAAC,IAAI,CAACD,IAAI,CAACE,MAAM,KAAK,QAAA,IAAY,OAAO,IAAI,CAACF,IAAI,CAACE,MAAM,KAAK,WAAW,CAC3E;AACF;EAEA,IAAIC,OAAUA,GAAA;IACZ,MAAM;AAAEC,MAAAA;KAAc,GAAGC,SAAA,EAAA;AAEzB,IAAA,OAAOD,YAAa,CAAA;AAClBE,MAAAA,IAAA,EAAM,IAAI,CAACN,IAAI,CAACM,IAAI,IAAI,IAAA;AACxBJ,MAAAA,MAAA,EAAQ,IAAI,CAACF,IAAI,CAACE,MAAM,IAAI,QAAA;AAC5BK,MAAAA,KAAA,EAAO,IAAI,CAACP,IAAI,CAACO;AACnB,KAAA,CAAA;AACF;EAEA,IAAIC,WAAAA,GAAsB;IACxB,IAAI,CAAC,IAAI,CAACR,IAAI,CAACC,QAAQ,EAAE,OAAO,EAAA;IAEhC,IAAI,OAAO,IAAI,CAACD,IAAI,CAACC,QAAQ,KAAK,QAAU,EAAA;AAC1C,MAAA,OAAO,IAAI,CAACD,IAAI,CAACC,QAAQ;AAC3B,KAAO,MAAA;MACL,OAAO,IAAI,CAACD,IAAI,CAACC,QAAQ,CAACQ,IAAI,CAAC,IAAA,CAAA;AACjC;AACF;AAcF;AAAAC,aAAA,GAxCMb;AA4BJc,oBAAA,CAAAC,kBAAA,CAWA,kNAAA,EAAA;EAAAC,UAAA,EAAA;AAAU,CAAA,CAAA,EAAAH,aAAA,CAAA;;;;"}
1
+ {"version":3,"file":"form-feedback.js","sources":["../../src/components/form-feedback.gts"],"sourcesContent":["import Component from '@glimmer/component';\nimport { useStyles, type FormFeedbackVariants } from '@frontile/theme';\n\ninterface FormFeedbackSignature {\n Args: {\n id?: string;\n /*\n * A list of messages or a single message string\n */\n messages?: string[] | string;\n\n /*\n * The intent of the feedback\n * @defaultValue 'danger'\n */\n intent?: FormFeedbackVariants['intent'];\n\n /*\n * @defaultValue 'md'\n */\n size?: FormFeedbackVariants['size'];\n class?: string;\n };\n Element: HTMLDivElement;\n Blocks: {\n default: [];\n };\n}\n\nclass FormFeedback extends Component<FormFeedbackSignature> {\n get isError(): boolean {\n return (\n typeof this.args.messages !== 'undefined' &&\n (this.args.intent === 'danger' || typeof this.args.intent === 'undefined')\n );\n }\n\n get classes() {\n const { formFeedback } = useStyles();\n\n return formFeedback({\n size: this.args.size || 'md',\n intent: this.args.intent || 'danger',\n class: this.args.class\n });\n }\n\n get messageText(): string {\n if (!this.args.messages) return '';\n\n if (typeof this.args.messages === 'string') {\n return this.args.messages;\n } else {\n return this.args.messages.join('; ');\n }\n }\n\n <template>\n <div\n id={{@id}}\n class={{this.classes}}\n data-component=\"form-feedback\"\n aria-live={{if this.isError \"assertive\" \"polite\"}}\n ...attributes\n >\n {{this.messageText}}\n {{yield}}\n </div>\n </template>\n}\n\nexport { FormFeedback, type FormFeedbackSignature };\nexport default FormFeedback;\n"],"names":["FormFeedback","Component","isError","args","messages","intent","classes","formFeedback","useStyles","size","class","messageText","join","setComponentTemplate","precompileTemplate","strictMode"],"mappings":";;;;;AA6BA,MAAMA,qBAAqBC,SAAA,CAAU;EACnC,IAAIC,OAAAA,GAAmB;IACrB,OACE,OAAO,IAAI,CAACC,IAAI,CAACC,QAAQ,KAAK,WAAA,KAC7B,IAAI,CAACD,IAAI,CAACE,MAAM,KAAK,QAAA,IAAY,OAAO,IAAI,CAACF,IAAI,CAACE,MAAM,KAAK,WAAW,CAC3E;AACF,EAAA;EAEA,IAAIC,OAAAA,GAAU;IACZ,MAAM;AAAEC,MAAAA;KAAc,GAAGC,SAAA,EAAA;AAEzB,IAAA,OAAOD,YAAA,CAAa;AAClBE,MAAAA,IAAA,EAAM,IAAI,CAACN,IAAI,CAACM,IAAI,IAAI,IAAA;AACxBJ,MAAAA,MAAA,EAAQ,IAAI,CAACF,IAAI,CAACE,MAAM,IAAI,QAAA;AAC5BK,MAAAA,KAAA,EAAO,IAAI,CAACP,IAAI,CAACO;AACnB,KAAA,CAAA;AACF,EAAA;EAEA,IAAIC,WAAAA,GAAsB;IACxB,IAAI,CAAC,IAAI,CAACR,IAAI,CAACC,QAAQ,EAAE,OAAO,EAAA;IAEhC,IAAI,OAAO,IAAI,CAACD,IAAI,CAACC,QAAQ,KAAK,QAAA,EAAU;AAC1C,MAAA,OAAO,IAAI,CAACD,IAAI,CAACC,QAAQ;AAC3B,IAAA,CAAA,MAAO;MACL,OAAO,IAAI,CAACD,IAAI,CAACC,QAAQ,CAACQ,IAAI,CAAC,IAAA,CAAA;AACjC,IAAA;AACF,EAAA;AAEA,EAAA;IAAAC,oBAAA,CAAAC,kBAAA,CAAA,kNAAA,EAWA;MAAAC,UAAA,EAAA;KAAU,CAAA,EAAV,IAAW,CAAA;AAAD;AACZ;;;;"}
@@ -1,47 +1,30 @@
1
- import _defineProperty from '@babel/runtime/helpers/esm/defineProperty';
2
1
  import Component from '@glimmer/component';
3
2
  import { on } from '@ember/modifier';
3
+ import { dataFrom } from 'form-data-utils';
4
4
  import { precompileTemplate } from '@ember/template-compilation';
5
5
  import { setComponentTemplate } from '@ember/component';
6
6
 
7
- var _Form;
8
7
  class Form extends Component {
9
- constructor(...args) {
10
- super(...args);
11
- _defineProperty(this, "handleInput", (event, eventType = 'input') => {
12
- const form = event.currentTarget;
13
- if (form instanceof HTMLFormElement) {
14
- let formData = new FormData(form);
15
- for (let i = 0; i < form.elements.length; i++) {
16
- const element = form.elements[i];
17
- if (element.type === 'select-multiple') {
18
- const selectedValues = [];
19
- for (let j = 0; j < element.options.length; j++) {
20
- const option = element.options[j];
21
- if (option && option.selected) {
22
- selectedValues.push(option.value);
23
- }
24
- }
25
- formData.append(element.name, selectedValues.join(','));
26
- }
27
- }
28
- let data = Object.fromEntries(formData.entries());
29
- this.args.onChange(data, eventType, event);
30
- }
31
- });
32
- _defineProperty(this, "handleSubmit", event => {
33
- event.preventDefault();
34
- this.handleInput(event, 'submit');
35
- });
8
+ handleInput = (event, eventType = 'input') => {
9
+ const form = event.currentTarget;
10
+ if (form instanceof HTMLFormElement) {
11
+ const data = dataFrom(event);
12
+ this.args.onChange(data, eventType, event);
13
+ }
14
+ };
15
+ handleSubmit = event => {
16
+ event.preventDefault();
17
+ this.handleInput(event, 'submit');
18
+ };
19
+ static {
20
+ setComponentTemplate(precompileTemplate("\n <form {{on \"input\" this.handleInput}} {{on \"submit\" this.handleSubmit}} ...attributes>\n {{yield}}\n </form>\n ", {
21
+ strictMode: true,
22
+ scope: () => ({
23
+ on
24
+ })
25
+ }), this);
36
26
  }
37
27
  }
38
- _Form = Form;
39
- setComponentTemplate(precompileTemplate("\n <form {{on \"input\" this.handleInput}} {{on \"submit\" this.handleSubmit}} ...attributes>\n {{yield}}\n </form>\n ", {
40
- strictMode: true,
41
- scope: () => ({
42
- on
43
- })
44
- }), _Form);
45
28
 
46
29
  export { Form, Form as default };
47
30
  //# sourceMappingURL=form.js.map