@frontile/forms 0.17.0-beta.5 → 0.17.0-beta.7
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.
- package/declarations/components/select.d.ts +116 -4
- package/declarations/components/select.d.ts.map +1 -1
- package/declarations/test-support.d.ts +3 -0
- package/declarations/test-support.d.ts.map +1 -0
- package/dist/components/checkbox-group.js +9 -9
- package/dist/components/checkbox-group.js.map +1 -1
- package/dist/components/checkbox.js +15 -10
- package/dist/components/checkbox.js.map +1 -1
- package/dist/components/form-control.js +25 -29
- package/dist/components/form-control.js.map +1 -1
- package/dist/components/form-description.js +5 -5
- package/dist/components/form-description.js.map +1 -1
- package/dist/components/form-feedback.js +5 -5
- package/dist/components/form-feedback.js.map +1 -1
- package/dist/components/form.js +28 -32
- package/dist/components/form.js.map +1 -1
- package/dist/components/input.js +28 -25
- package/dist/components/input.js.map +1 -1
- package/dist/components/label.js +5 -5
- package/dist/components/label.js.map +1 -1
- package/dist/components/native-select.js +42 -42
- package/dist/components/native-select.js.map +1 -1
- package/dist/components/radio-group.js +9 -9
- package/dist/components/radio-group.js.map +1 -1
- package/dist/components/radio.js +15 -10
- package/dist/components/radio.js.map +1 -1
- package/dist/components/select.js +106 -72
- package/dist/components/select.js.map +1 -1
- package/dist/components/textarea.js +18 -10
- package/dist/components/textarea.js.map +1 -1
- package/dist/runtime-BPCpkOf1-BKOwiRJp.js +67 -0
- package/dist/runtime-BPCpkOf1-BKOwiRJp.js.map +1 -0
- package/dist/test-support.js +1337 -0
- package/dist/test-support.js.map +1 -0
- package/package.json +45 -47
- package/declarations/index-CeaQc-U7.d.ts +0 -3
- package/declarations/index-CeaQc-U7.d.ts.map +0 -1
|
@@ -5,10 +5,33 @@ import { type SelectSlots, type SelectVariants, type SlotsToClasses } from '@fro
|
|
|
5
5
|
import { type PopoverSignature, type ContentSignature } from '@frontile/overlays';
|
|
6
6
|
import { type FormControlSharedArgs } from './form-control';
|
|
7
7
|
interface SelectArgs<T> extends Pick<PopoverSignature['Args'], 'placement' | 'flipOptions' | 'middleware' | 'shiftOptions' | 'offsetOptions' | 'strategy' | 'didClose'>, Pick<ListboxSignature<T>['Args'], 'appearance' | 'intent' | 'selectedKeys' | 'disabledKeys' | 'allowEmpty' | 'onSelectionChange' | 'items' | 'onAction'>, Pick<ContentSignature['Args'], 'renderInPlace' | 'target' | 'transitionDuration' | 'backdrop' | 'disableTransitions' | 'focusTrapOptions' | 'closeOnOutsideClick' | 'closeOnEscapeKey' | 'backdropTransition' | 'transition'>, FormControlSharedArgs {
|
|
8
|
+
/**
|
|
9
|
+
* Determines the selection mode of the select component.
|
|
10
|
+
* - 'single': Only one item can be selected at a time.
|
|
11
|
+
* - 'multiple': Allows multiple selections.
|
|
12
|
+
* @defaultValue 'single'
|
|
13
|
+
*/
|
|
8
14
|
selectionMode?: 'single' | 'multiple';
|
|
15
|
+
/**
|
|
16
|
+
* The unique identifier for the select component.
|
|
17
|
+
*/
|
|
9
18
|
id?: string;
|
|
19
|
+
/**
|
|
20
|
+
* Defines the input size of the select.
|
|
21
|
+
*/
|
|
10
22
|
inputSize?: SelectVariants['size'];
|
|
11
|
-
|
|
23
|
+
/**
|
|
24
|
+
* Defines the size of the popover dropdown.
|
|
25
|
+
* - 'sm': Small
|
|
26
|
+
* - 'md': Medium
|
|
27
|
+
* - 'lg': Large
|
|
28
|
+
* 'trigger': Same size as the trigger
|
|
29
|
+
* @defaultValue 'trigger'
|
|
30
|
+
*/
|
|
31
|
+
popoverSize?: 'sm' | 'md' | 'lg' | 'trigger';
|
|
32
|
+
/**
|
|
33
|
+
* Custom classes to style different slots within the select component.
|
|
34
|
+
*/
|
|
12
35
|
classes?: SlotsToClasses<SelectSlots>;
|
|
13
36
|
/**
|
|
14
37
|
* Whether the select should close upon selecting an item.
|
|
@@ -17,19 +40,54 @@ interface SelectArgs<T> extends Pick<PopoverSignature['Args'], 'placement' | 'fl
|
|
|
17
40
|
*/
|
|
18
41
|
closeOnItemSelect?: boolean;
|
|
19
42
|
/**
|
|
43
|
+
* Whether scrolling should be blocked when the select dropdown is open.
|
|
44
|
+
*
|
|
20
45
|
* @defaultValue true
|
|
21
46
|
*/
|
|
22
47
|
blockScroll?: boolean;
|
|
23
48
|
/**
|
|
24
|
-
*
|
|
49
|
+
* Whether the focus trap should be disabled when the dropdown is open.
|
|
50
|
+
*
|
|
51
|
+
* @defaultValue true
|
|
25
52
|
*/
|
|
26
53
|
disableFocusTrap?: boolean;
|
|
54
|
+
/**
|
|
55
|
+
* The placeholder text displayed when no option is selected.
|
|
56
|
+
*/
|
|
27
57
|
placeholder?: string;
|
|
58
|
+
/**
|
|
59
|
+
* Whether the select should be disabled, preventing user interaction.
|
|
60
|
+
*/
|
|
28
61
|
isDisabled?: boolean;
|
|
62
|
+
/**
|
|
63
|
+
* Allows filtering of the items in the select dropdown.
|
|
64
|
+
* If true, a search input is displayed for filtering.
|
|
65
|
+
*
|
|
66
|
+
* @defaultValue false
|
|
67
|
+
*/
|
|
68
|
+
isFilterable?: boolean;
|
|
69
|
+
/**
|
|
70
|
+
* Function to filter the items in the select.
|
|
71
|
+
* The default implementation performs a case-insensitive search.
|
|
72
|
+
*
|
|
73
|
+
* @param itemValue - The value of an item in the dropdown.
|
|
74
|
+
* @param filterValue - The user's input in the filter/search box.
|
|
75
|
+
* @returns A boolean indicating whether the item should be shown.
|
|
76
|
+
*/
|
|
77
|
+
filter?: (itemValue: string, filterValue: string) => boolean;
|
|
78
|
+
/**
|
|
79
|
+
* If true, the select will show a loading spinner instead of the dropdown icon.
|
|
80
|
+
*/
|
|
81
|
+
isLoading?: boolean;
|
|
82
|
+
/**
|
|
83
|
+
* The name attribute for the select component, useful for form submissions.
|
|
84
|
+
*/
|
|
29
85
|
name?: string;
|
|
30
86
|
/**
|
|
31
|
-
* Whether to include a clear button.
|
|
32
|
-
*
|
|
87
|
+
* Whether to include a clear button in the select component.
|
|
88
|
+
* If enabled, this allows users to clear the selection.
|
|
89
|
+
* This option ignores the `allowEmpty` setting.
|
|
90
|
+
*
|
|
33
91
|
* @defaultValue false
|
|
34
92
|
*/
|
|
35
93
|
isClearable?: boolean;
|
|
@@ -49,19 +107,43 @@ interface SelectArgs<T> extends Pick<PopoverSignature['Args'], 'placement' | 'fl
|
|
|
49
107
|
* @defaultValue 'none'
|
|
50
108
|
*/
|
|
51
109
|
endContentPointerEvents?: 'none' | 'auto';
|
|
110
|
+
/**
|
|
111
|
+
* If true, hides the empty content when there are no options available.
|
|
112
|
+
*
|
|
113
|
+
* @defaultValue false
|
|
114
|
+
*/
|
|
115
|
+
hideEmptyContent?: boolean;
|
|
52
116
|
}
|
|
53
117
|
interface SelectSignature<T> {
|
|
54
118
|
Args: SelectArgs<T>;
|
|
55
119
|
Element: HTMLDivElement;
|
|
56
120
|
Blocks: ListboxSignature<T>['Blocks'] & {
|
|
121
|
+
/**
|
|
122
|
+
* Content to display at the **beginning** of the select component.
|
|
123
|
+
* This can be an icon, a label, or any custom UI element.
|
|
124
|
+
*
|
|
125
|
+
* Example: A search icon or a custom label.
|
|
126
|
+
*/
|
|
57
127
|
startContent: [];
|
|
128
|
+
/**
|
|
129
|
+
* Content to display at the **end** of the select component.
|
|
130
|
+
* This can be an icon, a button, or any custom UI element.
|
|
131
|
+
*
|
|
132
|
+
* Example: A clear button or a dropdown arrow.
|
|
133
|
+
*/
|
|
58
134
|
endContent: [];
|
|
135
|
+
/**
|
|
136
|
+
* The content to display when there are no available options.
|
|
137
|
+
* If `hideEmptyContent` argument is true, this content will not be shown.
|
|
138
|
+
*/
|
|
139
|
+
emptyContent: [];
|
|
59
140
|
};
|
|
60
141
|
}
|
|
61
142
|
declare class Select<T = unknown> extends Component<SelectSignature<T>> {
|
|
62
143
|
nodes: ListItem[];
|
|
63
144
|
isOpen: boolean;
|
|
64
145
|
_selectedKeys: string[];
|
|
146
|
+
filterValue?: string;
|
|
65
147
|
containerRef: {
|
|
66
148
|
readonly element: HTMLDivElement | undefined;
|
|
67
149
|
setup: import("ember-modifier").FunctionBasedModifier<{
|
|
@@ -72,14 +154,26 @@ declare class Select<T = unknown> extends Component<SelectSignature<T>> {
|
|
|
72
154
|
Element: HTMLDivElement;
|
|
73
155
|
}>;
|
|
74
156
|
};
|
|
157
|
+
triggerRef: {
|
|
158
|
+
readonly element: HTMLInputElement | HTMLButtonElement | undefined;
|
|
159
|
+
setup: import("ember-modifier").FunctionBasedModifier<{
|
|
160
|
+
Args: {
|
|
161
|
+
Positional: unknown[];
|
|
162
|
+
Named: import("ember-modifier/-private/signature").EmptyObject;
|
|
163
|
+
};
|
|
164
|
+
Element: HTMLInputElement | HTMLButtonElement;
|
|
165
|
+
}>;
|
|
166
|
+
};
|
|
75
167
|
onSelectionChange: (keys: string[]) => void;
|
|
76
168
|
onOpenChange: (isOpen: boolean) => void;
|
|
169
|
+
onFilterChange: (event: Event) => void;
|
|
77
170
|
get selectedKeys(): string[];
|
|
78
171
|
get blockScroll(): boolean;
|
|
79
172
|
get disableFocusTrap(): boolean;
|
|
80
173
|
onAction: (key: string) => void;
|
|
81
174
|
clearSelectedKeys: (event: Event) => void;
|
|
82
175
|
onItemsChange: (nodes: ListItem[], _: "add" | "remove") => void;
|
|
176
|
+
didClose: () => void;
|
|
83
177
|
get selectedText(): string;
|
|
84
178
|
get selectedTextValue(): string;
|
|
85
179
|
get backdrop(): "blur" | "none" | "transparent" | "faded";
|
|
@@ -155,8 +249,26 @@ declare class Select<T = unknown> extends Component<SelectSignature<T>> {
|
|
|
155
249
|
hasStartContent?: boolean | undefined;
|
|
156
250
|
hasEndContent?: boolean | undefined;
|
|
157
251
|
} & import("tailwind-variants").ClassProp<import("tailwind-merge").ClassNameValue>) | undefined) => string;
|
|
252
|
+
input: (slotProps?: ({
|
|
253
|
+
size?: "sm" | "md" | "lg" | undefined;
|
|
254
|
+
startContentPointerEvents?: "none" | "auto" | undefined;
|
|
255
|
+
endContentPointerEvents?: "none" | "auto" | undefined;
|
|
256
|
+
hasStartContent?: boolean | undefined;
|
|
257
|
+
hasEndContent?: boolean | undefined;
|
|
258
|
+
} & import("tailwind-variants").ClassProp<import("tailwind-merge").ClassNameValue>) | undefined) => string;
|
|
259
|
+
emptyContent: (slotProps?: ({
|
|
260
|
+
size?: "sm" | "md" | "lg" | undefined;
|
|
261
|
+
startContentPointerEvents?: "none" | "auto" | undefined;
|
|
262
|
+
endContentPointerEvents?: "none" | "auto" | undefined;
|
|
263
|
+
hasStartContent?: boolean | undefined;
|
|
264
|
+
hasEndContent?: boolean | undefined;
|
|
265
|
+
} & import("tailwind-variants").ClassProp<import("tailwind-merge").ClassNameValue>) | undefined) => string;
|
|
158
266
|
} & {};
|
|
159
267
|
get isClearable(): boolean | undefined;
|
|
268
|
+
get filterFieldValue(): string;
|
|
269
|
+
get filteredItems(): T[] | undefined;
|
|
270
|
+
get showEmptyContent(): boolean;
|
|
271
|
+
get autoActivateMode(): 'first' | 'selected';
|
|
160
272
|
}
|
|
161
273
|
export { Select, type SelectSignature };
|
|
162
274
|
export default Select;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"select.d.ts","sourceRoot":"","sources":["../../src/components/select.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"select.d.ts","sourceRoot":"","sources":["../../src/components/select.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"test-support.d.ts","sourceRoot":"","sources":["../src/test-support.ts"],"names":[],"mappings":"AAEA,wBAAgB,iBAAiB,CAC/B,cAAc,EAAE,MAAM,EACtB,GAAG,EAAE,MAAM,GACV,OAAO,CAAC,IAAI,CAAC,CAEf;AAED,wBAAgB,iBAAiB,CAC/B,cAAc,EAAE,MAAM,EACtB,GAAG,EAAE,MAAM,GACV,OAAO,CAAC,IAAI,CAAC,CAEf"}
|
|
@@ -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","
|
|
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,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;AAEA,EAAA;IAAAE,oBAAA,CAAAC,kBAAA,CAwBA,ulBAAA,EAAA;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
|
-
|
|
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
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
})
|
|
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"
|
|
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,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;AAAA,EAAA;IAAAI,gBAAA,CAAA,IAAA,CAAAC,SAAA,EAAA,cAAA,EAAA,CARCC,MAAA,CAAA,CAAA;AAAA;EAUD,IAAIC,OAAUA,GAAA;IACZ,MAAM;AAAEC,MAAAA;KAAU,GAAGC,SAAA,EAAA;AACrB,IAAA,OAAOD,QAAS,CAAA;AACdE,MAAAA,IAAA,EAAM,IAAI,CAACb,IAAI,CAACa;AAClB,KAAA,CAAA;AACF;AAEA,EAAA;IAAAC,oBAAA,CAAAC,kBAAA,CAoCA,48BAAA,EAAA;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
|
-
|
|
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","
|
|
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,SAAU,CAAA;EAClCC,EAAK,GAAA,IAAI,CAACC,IAAI,CAACD,EAAE,IAAIE,OAAA,CAAQ,IAAI,CAAE;EAEnC,IAAIC,aAAAA,GAAwB;AAC1B,IAAA,OAAO,IAAI,CAACH,EAAE,GAAG,cAAA;AACnB;EAEA,IAAII,UAAAA,GAAqB;AACvB,IAAA,OAAO,IAAI,CAACJ,EAAE,GAAG,WAAA;AACnB;AAEAK,EAAAA,WAAA,GAAcA,CACZC,cAAiC,EACjCC,WAA8B,KACX;IACnB,MAAMC,MAAM,EAAE;AAEd,IAAA,IAAIF,cAAgB,EAAA;AAClBE,MAAAA,GAAA,CAAIC,IAAI,CAAC,IAAI,CAACN,aAAa,CAAA;AAC7B;AAEA,IAAA,IAAII,WAAa,EAAA;AACfC,MAAAA,GAAA,CAAIC,IAAI,CAAC,IAAI,CAACL,UAAU,CAAA;AAC1B;AAEA,IAAA,IAAII,GAAA,CAAIE,MAAM,GAAG,CAAG,EAAA;AAClB,MAAA,OAAOF,GAAA,CAAIG,IAAI,CAAC,GAAA,CAAA;AAClB;GACA;EAEF,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,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,CAACb,IAAI,CAACc,oBAAoB,KAAK,IAAI,CAAA,IAAK,IAAI,CAACH,SAAS,EAAE;AAChE,MAAA,OAAO,IAAA;AACT;AACA,IAAA,OAAO,KAAA;AACT;AAEA,EAAA;IAAAI,oBAAA,CAAAC,kBAAA,CA2CA,k/BAAA,EAAA;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","
|
|
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,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;AAEA,EAAA;IAAAC,oBAAA,CAAAC,kBAAA,CASA,kIAAA,EAAA;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","
|
|
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,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;AAEA,EAAA;IAAAC,oBAAA,CAAAC,kBAAA,CAWA,kNAAA,EAAA;MAAAC,UAAA,EAAA;KAAU,CAAA,EAAV,IAAW,CAAA;AAAD;AACZ;;;;"}
|
package/dist/components/form.js
CHANGED
|
@@ -1,47 +1,43 @@
|
|
|
1
|
-
import _defineProperty from '@babel/runtime/helpers/esm/defineProperty';
|
|
2
1
|
import Component from '@glimmer/component';
|
|
3
2
|
import { on } from '@ember/modifier';
|
|
4
3
|
import { precompileTemplate } from '@ember/template-compilation';
|
|
5
4
|
import { setComponentTemplate } from '@ember/component';
|
|
6
5
|
|
|
7
|
-
var _Form;
|
|
8
6
|
class Form extends Component {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
const
|
|
17
|
-
|
|
18
|
-
const
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
if (option && option.selected) {
|
|
22
|
-
selectedValues.push(option.value);
|
|
23
|
-
}
|
|
7
|
+
handleInput = (event, eventType = 'input') => {
|
|
8
|
+
const form = event.currentTarget;
|
|
9
|
+
if (form instanceof HTMLFormElement) {
|
|
10
|
+
let formData = new FormData(form);
|
|
11
|
+
for (let i = 0; i < form.elements.length; i++) {
|
|
12
|
+
const element = form.elements[i];
|
|
13
|
+
if (element.type === 'select-multiple') {
|
|
14
|
+
const selectedValues = [];
|
|
15
|
+
for (let j = 0; j < element.options.length; j++) {
|
|
16
|
+
const option = element.options[j];
|
|
17
|
+
if (option && option.selected) {
|
|
18
|
+
selectedValues.push(option.value);
|
|
24
19
|
}
|
|
25
|
-
formData.append(element.name, selectedValues.join(','));
|
|
26
20
|
}
|
|
21
|
+
formData.append(element.name, selectedValues.join(','));
|
|
27
22
|
}
|
|
28
|
-
let data = Object.fromEntries(formData.entries());
|
|
29
|
-
this.args.onChange(data, eventType, event);
|
|
30
23
|
}
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
24
|
+
let data = Object.fromEntries(formData.entries());
|
|
25
|
+
this.args.onChange(data, eventType, event);
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
handleSubmit = event => {
|
|
29
|
+
event.preventDefault();
|
|
30
|
+
this.handleInput(event, 'submit');
|
|
31
|
+
};
|
|
32
|
+
static {
|
|
33
|
+
setComponentTemplate(precompileTemplate("\n <form {{on \"input\" this.handleInput}} {{on \"submit\" this.handleSubmit}} ...attributes>\n {{yield}}\n </form>\n ", {
|
|
34
|
+
strictMode: true,
|
|
35
|
+
scope: () => ({
|
|
36
|
+
on
|
|
37
|
+
})
|
|
38
|
+
}), this);
|
|
36
39
|
}
|
|
37
40
|
}
|
|
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
41
|
|
|
46
42
|
export { Form, Form as default };
|
|
47
43
|
//# sourceMappingURL=form.js.map
|