@frontile/forms 0.18.0-alpha.2 → 0.18.0-alpha.20

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (87) hide show
  1. package/declarations/index.d.ts +1 -17
  2. package/declarations/template-registry.d.ts +1 -15
  3. package/declarations/test-support.d.ts +1 -2
  4. package/dist/index.js +13 -15
  5. package/dist/index.js.map +1 -1
  6. package/dist/test-support.js +1 -1336
  7. package/dist/test-support.js.map +1 -1
  8. package/package.json +15 -41
  9. package/declarations/components/checkbox-group.d.ts +0 -42
  10. package/declarations/components/checkbox.d.ts +0 -40
  11. package/declarations/components/field-types.d.ts +0 -14
  12. package/declarations/components/field.d.ts +0 -85
  13. package/declarations/components/form-control.d.ts +0 -47
  14. package/declarations/components/form-description.d.ts +0 -18
  15. package/declarations/components/form-feedback.d.ts +0 -22
  16. package/declarations/components/form.d.ts +0 -254
  17. package/declarations/components/icons.d.ts +0 -7
  18. package/declarations/components/input.d.ts +0 -145
  19. package/declarations/components/label.d.ts +0 -40
  20. package/declarations/components/native-select.d.ts +0 -154
  21. package/declarations/components/radio-group.d.ts +0 -43
  22. package/declarations/components/radio.d.ts +0 -41
  23. package/declarations/components/select.d.ts +0 -531
  24. package/declarations/components/switch.d.ts +0 -152
  25. package/declarations/components/textarea.d.ts +0 -69
  26. package/declarations/utils/index.d.ts +0 -3
  27. package/declarations/utils/nested-data.d.ts +0 -44
  28. package/declarations/utils/standard-validator.d.ts +0 -151
  29. package/dist/_app_/components/checkbox-group.js +0 -1
  30. package/dist/_app_/components/checkbox.js +0 -1
  31. package/dist/_app_/components/field-types.js +0 -1
  32. package/dist/_app_/components/field.js +0 -1
  33. package/dist/_app_/components/form-control.js +0 -1
  34. package/dist/_app_/components/form-description.js +0 -1
  35. package/dist/_app_/components/form-feedback.js +0 -1
  36. package/dist/_app_/components/form.js +0 -1
  37. package/dist/_app_/components/icons.js +0 -1
  38. package/dist/_app_/components/input.js +0 -1
  39. package/dist/_app_/components/label.js +0 -1
  40. package/dist/_app_/components/native-select.js +0 -1
  41. package/dist/_app_/components/radio-group.js +0 -1
  42. package/dist/_app_/components/radio.js +0 -1
  43. package/dist/_app_/components/select.js +0 -1
  44. package/dist/_app_/components/switch.js +0 -1
  45. package/dist/_app_/components/textarea.js +0 -1
  46. package/dist/components/checkbox-group.js +0 -29
  47. package/dist/components/checkbox-group.js.map +0 -1
  48. package/dist/components/checkbox.js +0 -50
  49. package/dist/components/checkbox.js.map +0 -1
  50. package/dist/components/field-types.js +0 -2
  51. package/dist/components/field-types.js.map +0 -1
  52. package/dist/components/field.js +0 -103
  53. package/dist/components/field.js.map +0 -1
  54. package/dist/components/form-control.js +0 -61
  55. package/dist/components/form-control.js.map +0 -1
  56. package/dist/components/form-description.js +0 -24
  57. package/dist/components/form-description.js.map +0 -1
  58. package/dist/components/form-feedback.js +0 -36
  59. package/dist/components/form-feedback.js.map +0 -1
  60. package/dist/components/form.js +0 -13
  61. package/dist/components/form.js.map +0 -1
  62. package/dist/components/icons.js +0 -13
  63. package/dist/components/icons.js.map +0 -1
  64. package/dist/components/input.js +0 -106
  65. package/dist/components/input.js.map +0 -1
  66. package/dist/components/label.js +0 -23
  67. package/dist/components/label.js.map +0 -1
  68. package/dist/components/native-select.js +0 -134
  69. package/dist/components/native-select.js.map +0 -1
  70. package/dist/components/radio-group.js +0 -29
  71. package/dist/components/radio-group.js.map +0 -1
  72. package/dist/components/radio.js +0 -49
  73. package/dist/components/radio.js.map +0 -1
  74. package/dist/components/select.js +0 -386
  75. package/dist/components/select.js.map +0 -1
  76. package/dist/components/switch.js +0 -63
  77. package/dist/components/switch.js.map +0 -1
  78. package/dist/components/textarea.js +0 -53
  79. package/dist/components/textarea.js.map +0 -1
  80. package/dist/form-CVuJDJUq.js +0 -726
  81. package/dist/form-CVuJDJUq.js.map +0 -1
  82. package/dist/index-6gTa9ocT.js +0 -23
  83. package/dist/index-6gTa9ocT.js.map +0 -1
  84. package/dist/index-CeaQc-U7.js +0 -23
  85. package/dist/index-CeaQc-U7.js.map +0 -1
  86. package/dist/runtime-BPCpkOf1-B5Lbloj7.js +0 -67
  87. package/dist/runtime-BPCpkOf1-B5Lbloj7.js.map +0 -1
@@ -1,69 +0,0 @@
1
- import Component from '@glimmer/component';
2
- import { type FormControlSharedArgs } from './form-control';
3
- import { type TextareaSlots, type TextareaVariants, type SlotsToClasses } from '@frontile/theme';
4
- interface Args extends FormControlSharedArgs {
5
- id?: string;
6
- value?: string | number | boolean;
7
- name?: string;
8
- size?: TextareaVariants['size'];
9
- classes?: SlotsToClasses<TextareaSlots>;
10
- onInput?: (value: string, event: InputEvent) => void;
11
- onChange?: (value: string, event: InputEvent) => void;
12
- onBlur?: () => void;
13
- }
14
- interface TextareaSignature {
15
- Args: Args;
16
- Element: HTMLTextAreaElement;
17
- }
18
- declare class Textarea extends Component<TextareaSignature> {
19
- handleOnInput(event: Event): void;
20
- handleOnChange(event: Event): void;
21
- handleOnBlur(): void;
22
- get classes(): {
23
- base: (slotProps?: ({
24
- size?: "sm" | "md" | "lg" | undefined;
25
- startContentPointerEvents?: "none" | "auto" | undefined;
26
- endContentPointerEvents?: "none" | "auto" | undefined;
27
- hasStartContent?: boolean | undefined;
28
- hasEndContent?: boolean | undefined;
29
- } & import("tailwind-variants").ClassProp<import("tailwind-variants").ClassValue>) | undefined) => string;
30
- innerContainer: (slotProps?: ({
31
- size?: "sm" | "md" | "lg" | undefined;
32
- startContentPointerEvents?: "none" | "auto" | undefined;
33
- endContentPointerEvents?: "none" | "auto" | undefined;
34
- hasStartContent?: boolean | undefined;
35
- hasEndContent?: boolean | undefined;
36
- } & import("tailwind-variants").ClassProp<import("tailwind-variants").ClassValue>) | undefined) => string;
37
- startContent: (slotProps?: ({
38
- size?: "sm" | "md" | "lg" | undefined;
39
- startContentPointerEvents?: "none" | "auto" | undefined;
40
- endContentPointerEvents?: "none" | "auto" | undefined;
41
- hasStartContent?: boolean | undefined;
42
- hasEndContent?: boolean | undefined;
43
- } & import("tailwind-variants").ClassProp<import("tailwind-variants").ClassValue>) | undefined) => string;
44
- endContent: (slotProps?: ({
45
- size?: "sm" | "md" | "lg" | undefined;
46
- startContentPointerEvents?: "none" | "auto" | undefined;
47
- endContentPointerEvents?: "none" | "auto" | undefined;
48
- hasStartContent?: boolean | undefined;
49
- hasEndContent?: boolean | undefined;
50
- } & import("tailwind-variants").ClassProp<import("tailwind-variants").ClassValue>) | undefined) => string;
51
- input: (slotProps?: ({
52
- size?: "sm" | "md" | "lg" | undefined;
53
- startContentPointerEvents?: "none" | "auto" | undefined;
54
- endContentPointerEvents?: "none" | "auto" | undefined;
55
- hasStartContent?: boolean | undefined;
56
- hasEndContent?: boolean | undefined;
57
- } & import("tailwind-variants").ClassProp<import("tailwind-variants").ClassValue>) | undefined) => string;
58
- } & {
59
- input: (slotProps?: ({
60
- size?: "sm" | "md" | "lg" | undefined;
61
- startContentPointerEvents?: "none" | "auto" | undefined;
62
- endContentPointerEvents?: "none" | "auto" | undefined;
63
- hasStartContent?: boolean | undefined;
64
- hasEndContent?: boolean | undefined;
65
- } & import("tailwind-variants").ClassProp<import("tailwind-variants").ClassValue>) | undefined) => string;
66
- } & {};
67
- }
68
- export { Textarea, type TextareaSignature };
69
- export default Textarea;
@@ -1,3 +0,0 @@
1
- declare function triggerFormInputEvent(element?: HTMLElement | null): void;
2
- export { triggerFormInputEvent };
3
- export { flattenData, unflattenData, hasNestedData, deepEqual } from './nested-data';
@@ -1,44 +0,0 @@
1
- /**
2
- * Utility functions for working with nested data structures in forms.
3
- * These functions convert between nested objects and flat dotted-path notation.
4
- */
5
- /**
6
- * Flattens a nested object into a flat object with dotted-path keys.
7
- *
8
- * @example
9
- * flattenData({name: {first: 'John', last: 'Doe'}, email: 'john@example.com'})
10
- * // Returns: {'name.first': 'John', 'name.last': 'Doe', 'email': 'john@example.com'}
11
- *
12
- * @param data - The nested data object to flatten
13
- * @param prefix - Internal parameter for recursion (parent path)
14
- * @returns A flat object with dotted-path keys
15
- */
16
- export declare function flattenData<T = unknown>(data: Record<string, unknown>, prefix?: string): Record<string, T>;
17
- /**
18
- * Unflattens a flat object with dotted-path keys into a nested object structure.
19
- *
20
- * @example
21
- * unflattenData({'name.first': 'John', 'name.last': 'Doe', 'email': 'john@example.com'})
22
- * // Returns: {name: {first: 'John', last: 'Doe'}, email: 'john@example.com'}
23
- *
24
- * @param data - The flat data object with dotted-path keys
25
- * @returns A nested object structure
26
- */
27
- export declare function unflattenData<T = unknown>(data: Record<string, unknown>): Record<string, T>;
28
- /**
29
- * Checks if the data structure contains any nested objects.
30
- * If true, we need to handle it as nested data.
31
- *
32
- * @param data - The data object to check
33
- * @returns True if the data contains nested plain objects
34
- */
35
- export declare function hasNestedData(data: Record<string, unknown>): boolean;
36
- /**
37
- * Deep equality comparison for nested objects.
38
- * Handles primitives, arrays, and nested objects.
39
- *
40
- * @param a - First value to compare
41
- * @param b - Second value to compare
42
- * @returns True if values are deeply equal
43
- */
44
- export declare function deepEqual(a: unknown, b: unknown): boolean;
@@ -1,151 +0,0 @@
1
- import type { StandardSchemaV1 } from '@standard-schema/spec';
2
- /**
3
- * The issues collection returned by a Standard Schema validation failure.
4
- */
5
- export type Issues = readonly StandardSchemaV1.Issue[];
6
- /**
7
- * The return type of a validator function.
8
- * Resolves to the issues (when validation fails) or undefined
9
- * (when it succeeds).
10
- */
11
- export type ValidatorReturn = Promise<Issues | undefined>;
12
- /**
13
- * StandardSchemaV1 issues as either a promise or synchronous. If there are
14
- * no issues, `undefined` is returned.
15
- */
16
- export type CustomValidatorReturn = ValidatorReturn | Issues | undefined;
17
- /**
18
- * A custom validator function.
19
- * If there are errors, they are returned by the validator as
20
- * StandardSchemaV1 issues. If there are no errors, nothing is returned.
21
- */
22
- export type CustomValidatorFn<Input = unknown> = (input: Input) => CustomValidatorReturn;
23
- /**
24
- * Provides convenience methods for validating data using Standard Schema.
25
- * Also supports custom validator functions that return issues in the
26
- * Standard Schema format.
27
- *
28
- * Most of the time you should use `validateAll` or `validateFieldAll` to
29
- * validate data. Schema and custom validation are optional arguments
30
- * to these methods. This is useful because schema and custom validation
31
- * must both be optional in the form component, which is the primary use
32
- * case for this class.
33
- *
34
- * Note: all methods are static, so you do not need to instantiate
35
- * this class.
36
- *
37
- * @see https://standardschema.dev/
38
- */
39
- declare class StandardValidator {
40
- private constructor();
41
- /**
42
- * Validates data against the provided standard schema.
43
- * If there are errors, they are returned. Otherwise, nothing is returned.
44
- * This provides a boolean indication of outcome: if there is a return
45
- * value, validation failed. Otherwise, validation succeeded.
46
- * @see https://standardschema.dev/
47
- *
48
- * @example
49
- * const input = …; // your data to validate
50
- * const schema = …; // your standard schema
51
- * const issues = await StandardValidator.validate(input, schema);
52
- *
53
- * @param input The input to validate.
54
- * @param schema The standard schema to validate against.
55
- * @return The issues if validation failed, otherwise undefined.
56
- */
57
- static validate<I, O>(input: I, schema: StandardSchemaV1<I, O>): ValidatorReturn;
58
- /**
59
- * Validates a single field within the input data using the provided
60
- * standard schema. If there are issues related to the specified field,
61
- * they are returned. Otherwise, nothing is returned.
62
- *
63
- * Note: because standard schema does not provide a way to validate
64
- * individual fields, this method filters the issues returned by the
65
- * schema validation to find those related to the specified field.
66
- * @see https://standardschema.dev/
67
- *
68
- * @param input The input data to validate.
69
- * @param fieldName The name of the field to validate.
70
- * @param schema The standard schema to validate against.
71
- * @returns The issues related to the specified field if validation failed,
72
- * otherwise undefined.
73
- */
74
- static validateField<I, O>(input: I, fieldName: string, schema: StandardSchemaV1<I, O>): ValidatorReturn;
75
- /**
76
- * Validates input using a custom validator function.
77
- * If there are errors, they are returned by the validator as
78
- * StandardSchemaV1 issues. If there are no errors, nothing is returned.
79
- * @see https://standardschema.dev/
80
- *
81
- * @param input The input data to validate.
82
- * @param customValidator The custom validator function to use.
83
- * @returns The issues if validation failed, otherwise undefined.
84
- */
85
- static validateCustom<I>(input: I, customValidator: CustomValidatorFn<I>): ValidatorReturn;
86
- /**
87
- * Validates a single field within the input data using a custom validator
88
- * function. If there are issues related to the specified field, they are
89
- * returned. Otherwise, nothing is returned.
90
- *
91
- * Note: because custom validators may return issues for multiple fields,
92
- * this method filters the issues returned by the custom validator to find
93
- * those related to the specified field.
94
- * @see https://standardschema.dev/
95
- *
96
- * @param input The input data to validate.
97
- * @param fieldName The name of the field to validate.
98
- * @param customValidator The custom validator function to use.
99
- * @returns The issues related to the specified field if validation failed,
100
- * otherwise undefined.
101
- */
102
- static validateFieldCustom<I>(input: I, fieldName: string, customValidator: CustomValidatorFn<I>): ValidatorReturn;
103
- /**
104
- * Validates input data using both a standard schema and a custom validator
105
- * function, merging any issues found by either method. If there are issues,
106
- * they are returned. Otherwise, nothing is returned. This method runs both
107
- * validations in parallel.
108
- *
109
- * Note: `schema` and `customValidator` are both optional. If either the
110
- * schema or custom validator is not provided, that validation is skipped.
111
- * @see https://standardschema.dev/
112
- *
113
- * @param input The input data to validate.
114
- * @param schema Optional standard schema to validate against.
115
- * @param customValidator Optional custom validator function to use.
116
- * @returns issues if validation failed, otherwise undefined.
117
- */
118
- static validateAll<I, O>(input: I, schema?: StandardSchemaV1<I, O>, customValidator?: CustomValidatorFn<I>): ValidatorReturn;
119
- /**
120
- * Validates a single field within the input data using both a standard
121
- * schema and a custom validator function, merging any issues found by
122
- * either method. If there are issues related to the specified field,
123
- * they are returned. Otherwise, nothing is returned. This method runs
124
- * both validations in parallel.
125
- *
126
- * Note: `schema` and `customValidator` are both optional. If either the
127
- * schema or custom validator is not provided, that validation is skipped.
128
- * @see https://standardschema.dev/
129
- *
130
- * @param input The input data to validate.
131
- * @param fieldName The name of the field to validate.
132
- * @param schema Optional standard schema to validate against.
133
- * @param customValidator Optional custom validator function to use.
134
- * @returns The issues related to the specified field if validation failed,
135
- * otherwise undefined.
136
- */
137
- static validateFieldAll<I, O>(input: I, fieldName: string, schema?: StandardSchemaV1<I, O>, customValidator?: CustomValidatorFn<I>): ValidatorReturn;
138
- /**
139
- * Filters issues to those related to the specified field name.
140
- * Supports both simple field names and dotted notation for nested fields.
141
- *
142
- * @param issues The issues to filter.
143
- * @param fieldName The name of the field to filter by (e.g., "email" or
144
- * "profile.contact.email").
145
- * @returns The issues related to the specified field, or undefined if
146
- * there are none.
147
- */
148
- static filterFieldIssues(issues: Issues, fieldName: string): Issues | undefined;
149
- }
150
- export { StandardValidator };
151
- export default StandardValidator;
@@ -1 +0,0 @@
1
- export { default } from "@frontile/forms/components/checkbox-group";
@@ -1 +0,0 @@
1
- export { default } from "@frontile/forms/components/checkbox";
@@ -1 +0,0 @@
1
- export { default } from "@frontile/forms/components/field-types";
@@ -1 +0,0 @@
1
- export { default } from "@frontile/forms/components/field";
@@ -1 +0,0 @@
1
- export { default } from "@frontile/forms/components/form-control";
@@ -1 +0,0 @@
1
- export { default } from "@frontile/forms/components/form-description";
@@ -1 +0,0 @@
1
- export { default } from "@frontile/forms/components/form-feedback";
@@ -1 +0,0 @@
1
- export { default } from "@frontile/forms/components/form";
@@ -1 +0,0 @@
1
- export { default } from "@frontile/forms/components/icons";
@@ -1 +0,0 @@
1
- export { default } from "@frontile/forms/components/input";
@@ -1 +0,0 @@
1
- export { default } from "@frontile/forms/components/label";
@@ -1 +0,0 @@
1
- export { default } from "@frontile/forms/components/native-select";
@@ -1 +0,0 @@
1
- export { default } from "@frontile/forms/components/radio-group";
@@ -1 +0,0 @@
1
- export { default } from "@frontile/forms/components/radio";
@@ -1 +0,0 @@
1
- export { default } from "@frontile/forms/components/select";
@@ -1 +0,0 @@
1
- export { default } from "@frontile/forms/components/switch";
@@ -1 +0,0 @@
1
- export { default } from "@frontile/forms/components/textarea";
@@ -1,29 +0,0 @@
1
- import Component from '@glimmer/component';
2
- import { Checkbox } from './checkbox.js';
3
- import { FormControl } from './form-control.js';
4
- import { useStyles } from '@frontile/theme';
5
- import { precompileTemplate } from '@ember/template-compilation';
6
- import { setComponentTemplate } from '@ember/component';
7
-
8
- class CheckboxGroup extends Component {
9
- get classes() {
10
- const {
11
- checkboxGroup
12
- } = useStyles();
13
- return checkboxGroup({
14
- size: this.args.size
15
- });
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 isDisabled=@isDisabled) to=\"default\"}}\n </div>\n </FormControl>\n ", {
19
- strictMode: true,
20
- scope: () => ({
21
- FormControl,
22
- Checkbox
23
- })
24
- }), this);
25
- }
26
- }
27
-
28
- export { CheckboxGroup, CheckboxGroup as default };
29
- //# sourceMappingURL=checkbox-group.js.map
@@ -1 +0,0 @@
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: [\n Checkbox: WithBoundArgs<\n typeof Checkbox,\n 'name' | 'onChange' | 'isDisabled'\n >\n ];\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\n Checkbox\n name=@name\n onChange=@onChange\n size=@size\n isDisabled=@isDisabled\n )\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":";;;;;;;AAqCA,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,8mBAAA,EA8BA;MAAAC,UAAA,EAAA,IAAA;AAAAC,MAAAA,KAAA,EAAAA,OAAA;QAAAC,WAAA;AAAAC,QAAAA;AAAA,OAAA;KAAU,CAAA,EAAV,IAAW,CAAA;AAAD;AACZ;;;;"}
@@ -1,50 +0,0 @@
1
- import Component from '@glimmer/component';
2
- import { action } from '@ember/object';
3
- import { on } from '@ember/modifier';
4
- import { FormControl } from './form-control.js';
5
- import { useStyles } from '@frontile/theme';
6
- import { precompileTemplate } from '@ember/template-compilation';
7
- import { setComponentTemplate } from '@ember/component';
8
- import { a as decorateMethodV2 } from '../runtime-BPCpkOf1-B5Lbloj7.js';
9
-
10
- class Checkbox extends Component {
11
- get isChecked() {
12
- return !!this.args.checked;
13
- }
14
- handleChange(event) {
15
- event.preventDefault();
16
- const value = !this.args.checked;
17
- if (typeof this.args.onChange === 'function') {
18
- this.args.onChange(value, event);
19
- }
20
- }
21
- static {
22
- decorateMethodV2(this.prototype, "handleChange", [action]);
23
- }
24
- handleBlur() {
25
- this.args.onBlur?.();
26
- }
27
- static {
28
- decorateMethodV2(this.prototype, "handleBlur", [action]);
29
- }
30
- get classes() {
31
- const {
32
- checkbox
33
- } = useStyles();
34
- return checkbox({
35
- size: this.args.size
36
- });
37
- }
38
- static {
39
- 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}} {{on \"blur\" this.handleBlur}} id={{c.id}} name={{@name}} checked={{this.isChecked}} type=\"checkbox\" disabled={{@isDisabled}} 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 ", {
40
- strictMode: true,
41
- scope: () => ({
42
- FormControl,
43
- on
44
- })
45
- }), this);
46
- }
47
- }
48
-
49
- export { Checkbox, Checkbox as default };
50
- //# sourceMappingURL=checkbox.js.map
@@ -1 +0,0 @@
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 /*\n * Callback when onblur is triggered\n */\n onBlur?: () => 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 @action handleBlur(): void {\n this.args.onBlur?.();\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 {{on \"blur\" this.handleBlur}}\n id={{c.id}}\n name={{@name}}\n checked={{this.isChecked}}\n type=\"checkbox\"\n disabled={{@isDisabled}}\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","handleBlur","onBlur","classes","checkbox","useStyles","size","setComponentTemplate","precompileTemplate","strictMode","scope","FormControl","on"],"mappings":";;;;;;;;;AAiCA,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;AAUOC,EAAAA,UAAAA,GAAmB;AACzB,IAAA,IAAI,CAACV,IAAI,CAACW,MAAM,IAAA;AAClB,EAAA;AAAA,EAAA;IAAAJ,gBAAA,CAAA,IAAA,CAAAC,SAAA,EAAA,YAAA,EAAA,CAFCC,MAAA,CAAA,CAAA;AAAA;EAID,IAAIG,OAAAA,GAAU;IACZ,MAAM;AAAEC,MAAAA;KAAU,GAAGC,SAAA,EAAA;AACrB,IAAA,OAAOD,QAAA,CAAS;AACdE,MAAAA,IAAA,EAAM,IAAI,CAACf,IAAI,CAACe;AAClB,KAAA,CAAA;AACF,EAAA;AAEA,EAAA;IAAAC,oBAAA,CAAAC,kBAAA,CAAA,qgCAAA,EAsCA;MAAAC,UAAA,EAAA,IAAA;AAAAC,MAAAA,KAAA,EAAAA,OAAA;QAAAC,WAAA;AAAAC,QAAAA;AAAA,OAAA;KAAU,CAAA,EAAV,IAAW,CAAA;AAAD;AACZ;;;;"}
@@ -1,2 +0,0 @@
1
-
2
- //# sourceMappingURL=field-types.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"field-types.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
@@ -1,103 +0,0 @@
1
- import Component from '@glimmer/component';
2
- import { hash } from '@ember/helper';
3
- import { get, action } from '@ember/object';
4
- import { debounce } from '@ember/runloop';
5
- import { Checkbox } from './checkbox.js';
6
- import { CheckboxGroup } from './checkbox-group.js';
7
- import { Input } from './input.js';
8
- import { Radio } from './radio.js';
9
- import { RadioGroup } from './radio-group.js';
10
- import { Select } from './select.js';
11
- import { Switch } from './switch.js';
12
- import { Textarea } from './textarea.js';
13
- import { precompileTemplate } from '@ember/template-compilation';
14
- import { setComponentTemplate } from '@ember/component';
15
- import { a as decorateMethodV2 } from '../runtime-BPCpkOf1-B5Lbloj7.js';
16
-
17
- /**
18
- * Field is a component wrapper that provides conveniences for form fields.
19
- * It automatically binds the appropriate form errors by name to yielded
20
- * components.
21
- */
22
- class Field extends Component {
23
- /**
24
- * Returns the validation errors for the field.
25
- * Supports dotted field names (e.g., 'profile.email').
26
- */
27
- get fieldErrors() {
28
- return this.args.errors?.[this.args.name];
29
- }
30
- /** The events on which validation should run. Defaults to ['change']. */
31
- get validateOn() {
32
- return this.args.validateOn ?? ['change'];
33
- }
34
- /**
35
- * Returns the current value for the field from formData.
36
- * Supports both flat and dotted field names (e.g., 'email' or 'profile.email').
37
- * Uses Ember's get() which handles both flat keys and dotted paths.
38
- */
39
- get fieldValue() {
40
- if (!this.args.formData) return undefined;
41
- // Ember's get() handles both flat keys and dotted paths correctly
42
- return get(this.args.formData, this.args.name);
43
- }
44
- /**
45
- * Validates the field by calling the validateField function passed in args.
46
- */
47
- validateField() {
48
- this.args.validateField?.(this.args.formData, this.args.name);
49
- }
50
- /**
51
- * Validates the field on change if change validation is enabled.
52
- */
53
- handleChange() {
54
- if (this.validateOn?.includes('change')) {
55
- this.validateField();
56
- }
57
- }
58
- /**
59
- * Validates the field on input if input validation is enabled.
60
- * Debounces validation to avoid excessive validation calls on every keystroke.
61
- */
62
- static {
63
- decorateMethodV2(this.prototype, "handleChange", [action]);
64
- }
65
- handleInput() {
66
- if (this.validateOn?.includes('input')) {
67
- debounce(this, this.validateField, 300);
68
- }
69
- }
70
- /**
71
- * Validates the field on blur if blur validation is enabled.
72
- */
73
- static {
74
- decorateMethodV2(this.prototype, "handleInput", [action]);
75
- }
76
- handleBlur() {
77
- if (this.validateOn.includes('blur')) {
78
- this.validateField();
79
- }
80
- }
81
- static {
82
- decorateMethodV2(this.prototype, "handleBlur", [action]);
83
- }
84
- static {
85
- setComponentTemplate(precompileTemplate("\n {{!-- @glint-nocheck component generics (radio, radio-group, select) trigger: type instantiation is excessively deep and possibly infinite --}}\n {{yield (hash Checkbox=(component Checkbox name=@name errors=this.fieldErrors checked=this.fieldValue isDisabled=@disabled onChange=this.handleChange onBlur=this.handleBlur) CheckboxGroup=(component CheckboxGroup name=@name errors=this.fieldErrors isDisabled=@disabled) Input=(component Input name=@name errors=this.fieldErrors value=this.fieldValue isDisabled=@disabled onChange=this.handleChange onInput=this.handleInput onBlur=this.handleBlur) Radio=(component Radio name=@name errors=this.fieldErrors checkedValue=this.fieldValue isDisabled=@disabled onChange=this.handleChange onBlur=this.handleBlur) RadioGroup=(component RadioGroup name=@name errors=this.fieldErrors value=this.fieldValue isDisabled=@disabled onChange=this.handleChange) SingleSelect=(component Select name=@name errors=this.fieldErrors selectedKey=this.fieldValue isDisabled=@disabled onBlur=this.handleBlur) MultiSelect=(component Select selectionMode=\"multiple\" name=@name errors=this.fieldErrors selectedKeys=this.fieldValue isDisabled=@disabled onBlur=this.handleBlur) Switch=(component Switch name=@name errors=this.fieldErrors isSelected=this.fieldValue isDisabled=@disabled onChange=this.handleChange onBlur=this.handleBlur) Textarea=(component Textarea name=@name errors=this.fieldErrors value=this.fieldValue isDisabled=@disabled onChange=this.handleChange onInput=this.handleInput onBlur=this.handleBlur)) to=\"default\"}}\n ", {
86
- strictMode: true,
87
- scope: () => ({
88
- hash,
89
- Checkbox,
90
- CheckboxGroup,
91
- Input,
92
- Radio,
93
- RadioGroup,
94
- Select,
95
- Switch,
96
- Textarea
97
- })
98
- }), this);
99
- }
100
- }
101
-
102
- export { Field, Field as default };
103
- //# sourceMappingURL=field.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"field.js","sources":["../../src/components/field.gts"],"sourcesContent":["import Component from '@glimmer/component';\nimport { hash } from '@ember/helper';\nimport { action, get } from '@ember/object';\nimport { debounce } from '@ember/runloop';\nimport Checkbox from './checkbox';\nimport CheckboxGroup from './checkbox-group';\nimport Input from './input';\nimport Radio from './radio';\nimport RadioGroup from './radio-group';\nimport Select from './select';\nimport Switch from './switch';\nimport Textarea from './textarea';\n\nimport type { WithBoundArgs } from '@glint/template';\nimport type { FormDataCompiled, FormErrors } from './form';\nimport type { SelectSignature } from './select';\nimport type { WithBoundArgsForSignature } from './field-types';\n\ntype BoundSingleSelect<S = unknown> = WithBoundArgsForSignature<\n SelectSignature<S>,\n 'name' | 'errors' | 'selectedKey' | 'onBlur' | 'isDisabled'\n>;\n\ntype BoundMultiSelect<S = unknown> = WithBoundArgsForSignature<\n SelectSignature<S>,\n 'selectionMode' | 'name' | 'errors' | 'selectedKeys' | 'onBlur' | 'isDisabled'\n>;\n\ninterface FieldSignature<T extends Record<string, unknown> = FormDataCompiled> {\n Element: HTMLElement;\n Args: {\n /** The name of the form field. */\n name: string;\n /** The validation errors for the form, keyed by field name. */\n errors?: FormErrors;\n /** The form data as key/value pairs. */\n formData?: T;\n /** Whether the field should be disabled. */\n disabled?: boolean;\n /** When to run validation. */\n validateOn?: ('change' | 'input' | 'blur')[];\n /** Function to validate a single field by name. */\n validateField?: (data: T, name: string) => Promise<FormErrors | undefined>;\n };\n Blocks: {\n default: [\n {\n Checkbox: WithBoundArgs<\n typeof Checkbox,\n 'name' | 'errors' | 'checked' | 'onChange' | 'onBlur' | 'isDisabled'\n >;\n CheckboxGroup: WithBoundArgs<\n typeof CheckboxGroup,\n 'name' | 'errors' | 'isDisabled'\n >;\n Input: WithBoundArgs<\n typeof Input,\n | 'name'\n | 'errors'\n | 'value'\n | 'onChange'\n | 'onInput'\n | 'onBlur'\n | 'isDisabled'\n >;\n Radio: WithBoundArgs<\n typeof Radio,\n | 'name'\n | 'errors'\n | 'checkedValue'\n | 'onChange'\n | 'onBlur'\n | 'isDisabled'\n >;\n RadioGroup: WithBoundArgs<\n typeof RadioGroup,\n 'name' | 'errors' | 'value' | 'onChange' | 'isDisabled'\n >;\n SingleSelect: BoundSingleSelect;\n MultiSelect: BoundMultiSelect;\n Switch: WithBoundArgs<\n typeof Switch,\n | 'name'\n | 'errors'\n | 'isSelected'\n | 'onChange'\n | 'onBlur'\n | 'isDisabled'\n >;\n Textarea: WithBoundArgs<\n typeof Textarea,\n | 'name'\n | 'errors'\n | 'value'\n | 'onChange'\n | 'onInput'\n | 'onBlur'\n | 'isDisabled'\n >;\n }\n ];\n };\n}\n\n/**\n * Field is a component wrapper that provides conveniences for form fields.\n * It automatically binds the appropriate form errors by name to yielded\n * components.\n */\nclass Field<\n T extends Record<string, unknown> = FormDataCompiled\n> extends Component<FieldSignature<T>> {\n /**\n * Returns the validation errors for the field.\n * Supports dotted field names (e.g., 'profile.email').\n */\n get fieldErrors() {\n return this.args.errors?.[this.args.name];\n }\n\n /** The events on which validation should run. Defaults to ['change']. */\n get validateOn(): ('change' | 'input' | 'blur')[] {\n return this.args.validateOn ?? ['change'];\n }\n\n /**\n * Returns the current value for the field from formData.\n * Supports both flat and dotted field names (e.g., 'email' or 'profile.email').\n * Uses Ember's get() which handles both flat keys and dotted paths.\n */\n get fieldValue() {\n if (!this.args.formData) return undefined;\n\n // Ember's get() handles both flat keys and dotted paths correctly\n return get(this.args.formData, this.args.name);\n }\n\n /**\n * Validates the field by calling the validateField function passed in args.\n */\n validateField() {\n this.args.validateField?.(this.args.formData as T, this.args.name);\n }\n\n /**\n * Validates the field on change if change validation is enabled.\n */\n @action\n handleChange() {\n if (this.validateOn?.includes('change')) {\n this.validateField();\n }\n }\n\n /**\n * Validates the field on input if input validation is enabled.\n * Debounces validation to avoid excessive validation calls on every keystroke.\n */\n @action\n handleInput() {\n if (this.validateOn?.includes('input')) {\n debounce(this, this.validateField, 300);\n }\n }\n\n /**\n * Validates the field on blur if blur validation is enabled.\n */\n @action\n handleBlur() {\n if (this.validateOn.includes('blur')) {\n this.validateField();\n }\n }\n\n <template>\n {{! @glint-nocheck component generics (radio, radio-group, select) trigger: type instantiation is excessively deep and possibly infinite }}\n {{yield\n (hash\n Checkbox=(component\n Checkbox\n name=@name\n errors=this.fieldErrors\n checked=this.fieldValue\n isDisabled=@disabled\n onChange=this.handleChange\n onBlur=this.handleBlur\n )\n CheckboxGroup=(component\n CheckboxGroup name=@name errors=this.fieldErrors isDisabled=@disabled\n )\n Input=(component\n Input\n name=@name\n errors=this.fieldErrors\n value=this.fieldValue\n isDisabled=@disabled\n onChange=this.handleChange\n onInput=this.handleInput\n onBlur=this.handleBlur\n )\n Radio=(component\n Radio\n name=@name\n errors=this.fieldErrors\n checkedValue=this.fieldValue\n isDisabled=@disabled\n onChange=this.handleChange\n onBlur=this.handleBlur\n )\n RadioGroup=(component\n RadioGroup\n name=@name\n errors=this.fieldErrors\n value=this.fieldValue\n isDisabled=@disabled\n onChange=this.handleChange\n )\n SingleSelect=(component\n Select\n name=@name\n errors=this.fieldErrors\n selectedKey=this.fieldValue\n isDisabled=@disabled\n onBlur=this.handleBlur\n )\n MultiSelect=(component\n Select\n selectionMode=\"multiple\"\n name=@name\n errors=this.fieldErrors\n selectedKeys=this.fieldValue\n isDisabled=@disabled\n onBlur=this.handleBlur\n )\n Switch=(component\n Switch\n name=@name\n errors=this.fieldErrors\n isSelected=this.fieldValue\n isDisabled=@disabled\n onChange=this.handleChange\n onBlur=this.handleBlur\n )\n Textarea=(component\n Textarea\n name=@name\n errors=this.fieldErrors\n value=this.fieldValue\n isDisabled=@disabled\n onChange=this.handleChange\n onInput=this.handleInput\n onBlur=this.handleBlur\n )\n )\n to=\"default\"\n }}\n </template>\n}\n\nexport { Field, type FieldSignature };\nexport default Field;\n"],"names":["Field","Component","fieldErrors","args","errors","name","validateOn","fieldValue","formData","undefined","get","validateField","handleChange","includes","n","prototype","action","handleInput","debounce","handleBlur","setComponentTemplate","precompileTemplate","strictMode","scope","hash","Checkbox","CheckboxGroup","Input","Radio","RadioGroup","Select","Switch","Textarea"],"mappings":";;;;;;;;;;;;;;;;AAwGA;;;;;AAKA,MAAMA,KAAA,SAEIC,SAAA,CAAyB;AACjC;;;AAGC;EACD,IAAIC,WAAAA,GAAc;IAChB,OAAO,IAAI,CAACC,IAAI,CAACC,MAAM,GAAG,IAAI,CAACD,IAAI,CAACE,IAAI,CAAC;AAC3C,EAAA;AAEA;EACA,IAAIC,UAAAA,GAA8C;IAChD,OAAO,IAAI,CAACH,IAAI,CAACG,UAAU,IAAI,CAAC,QAAA,CAAS;AAC3C,EAAA;AAEA;;;;AAIC;EACD,IAAIC,UAAAA,GAAa;IACf,IAAI,CAAC,IAAI,CAACJ,IAAI,CAACK,QAAQ,EAAE,OAAOC,SAAA;AAEhC;AACA,IAAA,OAAOC,GAAA,CAAI,IAAI,CAACP,IAAI,CAACK,QAAQ,EAAE,IAAI,CAACL,IAAI,CAACE,IAAI,CAAA;AAC/C,EAAA;AAEA;;AAEC;AACDM,EAAAA,aAAAA,GAAgB;AACd,IAAA,IAAI,CAACR,IAAI,CAACQ,aAAa,GAAG,IAAI,CAACR,IAAI,CAACK,QAAQ,EAAO,IAAI,CAACL,IAAI,CAACE,IAAI,CAAA;AACnE,EAAA;AAEA;;AAEC;AAEDO,EAAAA,YAAAA,GAAe;IACb,IAAI,IAAI,CAACN,UAAU,EAAEO,SAAS,QAAA,CAAA,EAAW;MACvC,IAAI,CAACF,aAAa,EAAA;AACpB,IAAA;AACF,EAAA;AAEA;;;AAGC;AAHD,EAAA;IAAAG,gBAAA,CAAA,IAAA,CAAAC,SAAA,EAAA,cAAA,EAAA,CAPCC,MAAA,CAAA,CAAA;AAAA;AAYDC,EAAAA,WAAAA,GAAc;IACZ,IAAI,IAAI,CAACX,UAAU,EAAEO,SAAS,OAAA,CAAA,EAAU;MACtCK,QAAA,CAAS,IAAI,EAAE,IAAI,CAACP,aAAa,EAAE,GAAA,CAAA;AACrC,IAAA;AACF,EAAA;AAEA;;AAEC;AAFD,EAAA;IAAAG,gBAAA,CAAA,IAAA,CAAAC,SAAA,EAAA,aAAA,EAAA,CAPCC,MAAA,CAAA,CAAA;AAAA;AAWDG,EAAAA,UAAAA,GAAa;IACX,IAAI,IAAI,CAACb,UAAU,CAACO,QAAQ,CAAC,MAAA,CAAA,EAAS;MACpC,IAAI,CAACF,aAAa,EAAA;AACpB,IAAA;AACF,EAAA;AAAA,EAAA;IAAAG,gBAAA,CAAA,IAAA,CAAAC,SAAA,EAAA,YAAA,EAAA,CALCC,MAAA,CAAA,CAAA;AAAA;AAOD,EAAA;IAAAI,oBAAA,CAAAC,kBAAA,CAAA,miDAAA,EAkFA;MAAAC,UAAA,EAAA,IAAA;AAAAC,MAAAA,KAAA,EAAAA,OAAA;QAAAC,IAAA;QAAAC,QAAA;QAAAC,aAAA;QAAAC,KAAA;QAAAC,KAAA;QAAAC,UAAA;QAAAC,MAAA;QAAAC,MAAA;AAAAC,QAAAA;AAAA,OAAA;KAAU,CAAA,EAAV,IAAW,CAAA;AAAD;AACZ;;;;"}
@@ -1,61 +0,0 @@
1
- import Component from '@glimmer/component';
2
- import { guidFor } from '@ember/object/internals';
3
- import { hash } from '@ember/helper';
4
- import { FormFeedback } from './form-feedback.js';
5
- import { FormDescription } from './form-description.js';
6
- import { Label } from './label.js';
7
- import { precompileTemplate } from '@ember/template-compilation';
8
- import { setComponentTemplate } from '@ember/component';
9
-
10
- function or(arg1, arg2) {
11
- return !!(arg1 || arg2);
12
- }
13
- class FormControl extends Component {
14
- id = this.args.id || guidFor(this);
15
- get descriptionId() {
16
- return this.id + '-description';
17
- }
18
- get feedbackId() {
19
- return this.id + '-feedback';
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
- };
33
- get isInvalid() {
34
- if (this.args.isInvalid || this.args.errors && this.args.errors.length > 0) {
35
- return true;
36
- } else {
37
- return false;
38
- }
39
- }
40
- get showErrorFeedback() {
41
- if (!(this.args.preventErrorFeedback === true) && this.isInvalid) {
42
- return true;
43
- }
44
- return false;
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
- }
58
- }
59
-
60
- export { FormControl, FormControl as default };
61
- //# sourceMappingURL=form-control.js.map