@frontile/forms 0.17.0-beta.2 → 0.17.0-beta.21
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/checkbox-group.d.ts +6 -7
- package/declarations/components/checkbox.d.ts +5 -6
- package/declarations/components/form-control.d.ts +0 -1
- package/declarations/components/form-description.d.ts +0 -1
- package/declarations/components/form-feedback.d.ts +0 -1
- package/declarations/components/form.d.ts +2 -3
- package/declarations/components/icons.d.ts +0 -1
- package/declarations/components/input.d.ts +12 -12
- package/declarations/components/label.d.ts +4 -5
- package/declarations/components/native-select.d.ts +7 -8
- package/declarations/components/radio-group.d.ts +6 -7
- package/declarations/components/radio.d.ts +5 -6
- package/declarations/components/select.d.ts +129 -16
- package/declarations/components/switch.d.ts +147 -0
- package/declarations/components/textarea.d.ts +6 -7
- package/declarations/index.d.ts +1 -1
- package/declarations/template-registry.d.ts +0 -1
- package/declarations/test-support.d.ts +2 -0
- package/declarations/utils/index.d.ts +0 -1
- package/dist/_app_/components/switch.js +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 +19 -36
- package/dist/components/form.js.map +1 -1
- package/dist/components/icons.js.map +1 -1
- package/dist/components/input.js +30 -27
- 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/switch.js +60 -0
- package/dist/components/switch.js.map +1 -0
- package/dist/components/textarea.js +18 -10
- package/dist/components/textarea.js.map +1 -1
- package/dist/index-CeaQc-U7.js.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.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 +55 -55
- package/declarations/components/checkbox-group.d.ts.map +0 -1
- package/declarations/components/checkbox.d.ts.map +0 -1
- package/declarations/components/form-control.d.ts.map +0 -1
- package/declarations/components/form-description.d.ts.map +0 -1
- package/declarations/components/form-feedback.d.ts.map +0 -1
- package/declarations/components/form.d.ts.map +0 -1
- package/declarations/components/icons.d.ts.map +0 -1
- package/declarations/components/input.d.ts.map +0 -1
- package/declarations/components/label.d.ts.map +0 -1
- package/declarations/components/native-select.d.ts.map +0 -1
- package/declarations/components/radio-group.d.ts.map +0 -1
- package/declarations/components/radio.d.ts.map +0 -1
- package/declarations/components/select.d.ts.map +0 -1
- package/declarations/components/textarea.d.ts.map +0 -1
- package/declarations/index-CeaQc-U7.d.ts +0 -3
- package/declarations/index-CeaQc-U7.d.ts.map +0 -1
- package/declarations/index.d.ts.map +0 -1
- package/declarations/template-registry.d.ts.map +0 -1
- 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-
|
|
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-
|
|
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-
|
|
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-
|
|
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-
|
|
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-
|
|
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
|
package/declarations/index.d.ts
CHANGED
|
@@ -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","
|
|
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
|
-
|
|
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,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
|
-
|
|
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,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","
|
|
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","
|
|
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;;;;"}
|
package/dist/components/form.js
CHANGED
|
@@ -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
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
const
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
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
|