@frontile/forms 0.16.2 → 0.17.0-alpha.0
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/form-checkbox-group.d.ts +8 -1
- package/declarations/components/form-checkbox-group.d.ts.map +1 -1
- package/declarations/components/form-checkbox.d.ts +9 -1
- package/declarations/components/form-checkbox.d.ts.map +1 -1
- package/declarations/components/form-field/checkbox.d.ts +3 -1
- package/declarations/components/form-field/checkbox.d.ts.map +1 -1
- package/declarations/components/form-field/feedback.d.ts +3 -1
- package/declarations/components/form-field/feedback.d.ts.map +1 -1
- package/declarations/components/form-field/hint.d.ts +3 -1
- package/declarations/components/form-field/hint.d.ts.map +1 -1
- package/declarations/components/form-field/input.d.ts +3 -1
- package/declarations/components/form-field/input.d.ts.map +1 -1
- package/declarations/components/form-field/label.d.ts +3 -1
- package/declarations/components/form-field/label.d.ts.map +1 -1
- package/declarations/components/form-field/radio.d.ts +3 -1
- package/declarations/components/form-field/radio.d.ts.map +1 -1
- package/declarations/components/form-field/textarea.d.ts +3 -1
- package/declarations/components/form-field/textarea.d.ts.map +1 -1
- package/declarations/components/form-field.d.ts +1 -1
- package/declarations/components/form-field.d.ts.map +1 -1
- package/declarations/components/form-input.d.ts +10 -1
- package/declarations/components/form-input.d.ts.map +1 -1
- package/declarations/components/form-radio-group.d.ts +8 -1
- package/declarations/components/form-radio-group.d.ts.map +1 -1
- package/declarations/components/form-radio.d.ts +9 -1
- package/declarations/components/form-radio.d.ts.map +1 -1
- package/declarations/components/form-select.d.ts +8 -1
- package/declarations/components/form-select.d.ts.map +1 -1
- package/declarations/components/form-textarea.d.ts +7 -0
- package/declarations/components/form-textarea.d.ts.map +1 -1
- package/dist/components/form-checkbox-group.js +25 -3
- package/dist/components/form-checkbox-group.js.map +1 -1
- package/dist/components/form-checkbox.js +35 -6
- package/dist/components/form-checkbox.js.map +1 -1
- package/dist/components/form-field/checkbox.js +11 -3
- package/dist/components/form-field/checkbox.js.map +1 -1
- package/dist/components/form-field/feedback.js +12 -5
- package/dist/components/form-field/feedback.js.map +1 -1
- package/dist/components/form-field/hint.js +13 -6
- package/dist/components/form-field/hint.js.map +1 -1
- package/dist/components/form-field/input.js +11 -3
- package/dist/components/form-field/input.js.map +1 -1
- package/dist/components/form-field/label.js +13 -6
- package/dist/components/form-field/label.js.map +1 -1
- package/dist/components/form-field/radio.js +11 -3
- package/dist/components/form-field/radio.js.map +1 -1
- package/dist/components/form-field/textarea.js +11 -3
- package/dist/components/form-field/textarea.js.map +1 -1
- package/dist/components/form-field.js.map +1 -1
- package/dist/components/form-input.js +29 -4
- package/dist/components/form-input.js.map +1 -1
- package/dist/components/form-radio-group.js +25 -3
- package/dist/components/form-radio-group.js.map +1 -1
- package/dist/components/form-radio.js +35 -6
- package/dist/components/form-radio.js.map +1 -1
- package/dist/components/form-select.js +25 -3
- package/dist/components/form-select.js.map +1 -1
- package/dist/components/form-textarea.js +30 -5
- package/dist/components/form-textarea.js.map +1 -1
- package/package.json +6 -15
- package/tailwind/default-options.js +0 -299
- package/tailwind/index.js +0 -83
|
@@ -2,7 +2,7 @@ import _applyDecoratedDescriptor from '@babel/runtime/helpers/esm/applyDecorated
|
|
|
2
2
|
import Component from '@glimmer/component';
|
|
3
3
|
import { action } from '@ember/object';
|
|
4
4
|
import { on } from '@ember/modifier';
|
|
5
|
-
import
|
|
5
|
+
import { useStyles } from '@frontile/theme';
|
|
6
6
|
import { precompileTemplate } from '@ember/template-compilation';
|
|
7
7
|
import { setComponentTemplate } from '@ember/component';
|
|
8
8
|
|
|
@@ -18,9 +18,17 @@ let FormFieldCheckbox = (_class = (_class2 = class FormFieldCheckbox extends Com
|
|
|
18
18
|
this.args.onChange(value1, event1);
|
|
19
19
|
}
|
|
20
20
|
}
|
|
21
|
-
|
|
21
|
+
get classes() {
|
|
22
|
+
const {
|
|
23
|
+
checkbox: checkbox1
|
|
24
|
+
} = useStyles();
|
|
25
|
+
return checkbox1({
|
|
26
|
+
size: this.args.size,
|
|
27
|
+
class: this.args.class
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
}, setComponentTemplate(precompileTemplate("\n <input {{on \"change\" this.handleChange}} id={{@id}} name={{@name}} checked={{this.isChecked}} type=\"checkbox\" class={{this.classes}} data-test-id=\"form-field-checkbox\" ...attributes />\n ", {
|
|
22
31
|
scope: () => ({
|
|
23
|
-
useFrontileClass,
|
|
24
32
|
on
|
|
25
33
|
}),
|
|
26
34
|
strictMode: true
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"checkbox.js","sources":["../../../src/components/form-field/checkbox.gts"],"sourcesContent":["import { template } from \"@ember/template-compiler\";\nimport Component from '@glimmer/component';\nimport { action } from '@ember/object';\nimport { on } from '@ember/modifier';\nimport
|
|
1
|
+
{"version":3,"file":"checkbox.js","sources":["../../../src/components/form-field/checkbox.gts"],"sourcesContent":["import { template } from \"@ember/template-compiler\";\nimport Component from '@glimmer/component';\nimport { action } from '@ember/object';\nimport { on } from '@ember/modifier';\nimport { useStyles } from '@frontile/theme';\nexport interface FormFieldCheckboxArgs {\n id?: string;\n checked?: boolean;\n name?: string;\n size?: 'sm' | 'md' | 'lg';\n class?: string;\n // Callback when onchange is triggered\n onChange?: (value: boolean, event: Event) => void;\n}\nexport interface FormFieldCheckboxSignature {\n Args: FormFieldCheckboxArgs;\n Element: HTMLInputElement;\n}\nexport default class FormFieldCheckbox extends Component<FormFieldCheckboxSignature> {\n get isChecked(): boolean {\n return !!this.args.checked;\n }\n @action\n handleChange(event1: Event): void {\n event1.preventDefault();\n const value1 = !this.args.checked;\n if (typeof this.args.onChange === 'function') {\n this.args.onChange(value1, event1);\n }\n }\n get classes() {\n const { checkbox: checkbox1 } = useStyles();\n return checkbox1({\n size: this.args.size,\n class: this.args.class\n });\n }\n static{\n template(`\n <input\n {{on \"change\" this.handleChange}}\n id={{@id}}\n name={{@name}}\n checked={{this.isChecked}}\n type=\"checkbox\"\n class={{this.classes}}\n data-test-id=\"form-field-checkbox\"\n ...attributes\n />\n `, {\n component: this,\n eval () {\n return eval(arguments[0]);\n }\n });\n }\n}\n"],"names":["FormFieldCheckbox","_class","_class2","Component","isChecked","args","checked","handleChange","event1","preventDefault","value1","onChange","classes","checkbox","checkbox1","useStyles","size","class","setComponentTemplate","precompileTemplate","scope","on","strictMode","_applyDecoratedDescriptor","prototype","action","Object","getOwnPropertyDescriptor"],"mappings":";;;;;;;;;AAkBqBA,IAAAA,iBAAiB,IAAAC,MAAA,IAAAC,OAAA,GAAvB,MAAMF,iBAAiB,SAASG,SAAS,CAA6B;EACjF,IAAIC,SAASA,GAAY;AACrB,IAAA,OAAO,CAAC,CAAC,IAAI,CAACC,IAAI,CAACC,OAAO,CAAA;AAC9B,GAAA;EAEAC,YAAYA,CAACC,MAAa,EAAQ;IAC9BA,MAAM,CAACC,cAAc,EAAE,CAAA;AACvB,IAAA,MAAMC,MAAM,GAAG,CAAC,IAAI,CAACL,IAAI,CAACC,OAAO,CAAA;IACjC,IAAI,OAAO,IAAI,CAACD,IAAI,CAACM,QAAQ,KAAK,UAAU,EAAE;MAC1C,IAAI,CAACN,IAAI,CAACM,QAAQ,CAACD,MAAM,EAAEF,MAAM,CAAC,CAAA;AACtC,KAAA;AACJ,GAAA;EACA,IAAII,OAAOA,GAAG;IACV,MAAM;AAAEC,MAAAA,QAAQ,EAAEC,SAAAA;KAAW,GAAGC,SAAS,EAAE,CAAA;AAC3C,IAAA,OAAOD,SAAS,CAAC;AACbE,MAAAA,IAAI,EAAE,IAAI,CAACX,IAAI,CAACW,IAAI;AACpBC,MAAAA,KAAK,EAAE,IAAI,CAACZ,IAAI,CAACY,KAAAA;AACrB,KAAC,CAAC,CAAA;AACN,GAAA;AAoBJ,CAAC,EAAAC,oBAAA,CAlBOC,kBAAA,CAWH,0MAAA,EAAA;AAAAC,EAAAA,KAAA,EAAAA,OAAA;AAAAC,IAAAA,EAAAA;AAAA,GAAA,CAAA;EAAAC,UAAA,EAAA,IAAA;AAKG,CAAC,CAAC,EAAApB,OAAA,CAAAA,EAAAA,OAAA,CAAAqB,GAAAA,yBAAA,CAAAtB,MAAA,CAAAuB,SAAA,EAhCLC,cAAAA,EAAAA,CAAAA,MAAM,GAAAC,MAAA,CAAAC,wBAAA,CAAA1B,MAAA,CAAAuB,SAAA,EAAA,cAAA,CAAA,EAAAvB,MAAA,CAAAuB,SAAA,CAAA,GAAAvB,MAAA;;;;"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import Component from '@glimmer/component';
|
|
2
|
-
import
|
|
2
|
+
import { useStyles } from '@frontile/theme';
|
|
3
3
|
import { precompileTemplate } from '@ember/template-compilation';
|
|
4
4
|
import { setComponentTemplate } from '@ember/component';
|
|
5
5
|
|
|
@@ -8,6 +8,16 @@ class FormFieldFeedback extends Component {
|
|
|
8
8
|
get isError() {
|
|
9
9
|
return typeof this.args.errors !== 'undefined' || this.args.isError === true;
|
|
10
10
|
}
|
|
11
|
+
get classes() {
|
|
12
|
+
const {
|
|
13
|
+
feedback: feedback1
|
|
14
|
+
} = useStyles();
|
|
15
|
+
return feedback1({
|
|
16
|
+
size: this.args.size,
|
|
17
|
+
isError: this.isError,
|
|
18
|
+
class: this.args.class
|
|
19
|
+
});
|
|
20
|
+
}
|
|
11
21
|
get errorMessage() {
|
|
12
22
|
if (!this.args.errors) return '';
|
|
13
23
|
if (typeof this.args.errors === 'string') {
|
|
@@ -18,10 +28,7 @@ class FormFieldFeedback extends Component {
|
|
|
18
28
|
}
|
|
19
29
|
}
|
|
20
30
|
_class = FormFieldFeedback;
|
|
21
|
-
setComponentTemplate(precompileTemplate("\n <div id={{@id}} class={{
|
|
22
|
-
scope: () => ({
|
|
23
|
-
useFrontileClass
|
|
24
|
-
}),
|
|
31
|
+
setComponentTemplate(precompileTemplate("\n <div id={{@id}} class={{this.classes}} data-test-id=\"form-field-feedback\" aria-live={{if this.isError \"assertive\" \"polite\"}} ...attributes>\n {{this.errorMessage}}\n {{yield}}\n </div>\n ", {
|
|
25
32
|
strictMode: true
|
|
26
33
|
}), _class);
|
|
27
34
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"feedback.js","sources":["../../../src/components/form-field/feedback.gts"],"sourcesContent":["import { template } from \"@ember/template-compiler\";\nimport Component from '@glimmer/component';\nimport
|
|
1
|
+
{"version":3,"file":"feedback.js","sources":["../../../src/components/form-field/feedback.gts"],"sourcesContent":["import { template } from \"@ember/template-compiler\";\nimport Component from '@glimmer/component';\nimport { useStyles } from '@frontile/theme';\nexport interface FormFieldFeedbackArgs {\n id?: string;\n isError?: boolean;\n errors?: string[] | string;\n size?: 'sm' | 'md' | 'lg';\n class?: string;\n}\nexport interface FormFieldFeedbackSignature {\n Args: FormFieldFeedbackArgs;\n Element: HTMLDivElement;\n Blocks: {\n default: [];\n };\n}\nexport default class FormFieldFeedback extends Component<FormFieldFeedbackSignature> {\n get isError(): boolean {\n return (typeof this.args.errors !== 'undefined' || this.args.isError === true);\n }\n get classes() {\n const { feedback: feedback1 } = useStyles();\n return feedback1({\n size: this.args.size,\n isError: this.isError,\n class: this.args.class\n });\n }\n get errorMessage(): string {\n if (!this.args.errors) return '';\n if (typeof this.args.errors === 'string') {\n return this.args.errors;\n } else {\n return this.args.errors.join('; ');\n }\n }\n static{\n template(`\n <div\n id={{@id}}\n class={{this.classes}}\n data-test-id=\"form-field-feedback\"\n aria-live={{if this.isError \"assertive\" \"polite\"}}\n ...attributes\n >\n {{this.errorMessage}}\n {{yield}}\n </div>\n `, {\n component: this,\n eval () {\n return eval(arguments[0]);\n }\n });\n }\n}\n"],"names":["FormFieldFeedback","Component","isError","args","errors","classes","feedback","feedback1","useStyles","size","class","errorMessage","join","_class","setComponentTemplate","precompileTemplate","strictMode"],"mappings":";;;;;;AAiBe,MAAMA,iBAAiB,SAASC,SAAS,CAA6B;EACjF,IAAIC,OAAOA,GAAY;AACnB,IAAA,OAAQ,OAAO,IAAI,CAACC,IAAI,CAACC,MAAM,KAAK,WAAW,IAAI,IAAI,CAACD,IAAI,CAACD,OAAO,KAAK,IAAI,CAAA;AACjF,GAAA;EACA,IAAIG,OAAOA,GAAG;IACV,MAAM;AAAEC,MAAAA,QAAQ,EAAEC,SAAAA;KAAW,GAAGC,SAAS,EAAE,CAAA;AAC3C,IAAA,OAAOD,SAAS,CAAC;AACbE,MAAAA,IAAI,EAAE,IAAI,CAACN,IAAI,CAACM,IAAI;MACpBP,OAAO,EAAE,IAAI,CAACA,OAAO;AACrBQ,MAAAA,KAAK,EAAE,IAAI,CAACP,IAAI,CAACO,KAAAA;AACrB,KAAC,CAAC,CAAA;AACN,GAAA;EACA,IAAIC,YAAYA,GAAW;IACvB,IAAI,CAAC,IAAI,CAACR,IAAI,CAACC,MAAM,EAAE,OAAO,EAAE,CAAA;IAChC,IAAI,OAAO,IAAI,CAACD,IAAI,CAACC,MAAM,KAAK,QAAQ,EAAE;AACtC,MAAA,OAAO,IAAI,CAACD,IAAI,CAACC,MAAM,CAAA;AAC3B,KAAC,MAAM;MACH,OAAO,IAAI,CAACD,IAAI,CAACC,MAAM,CAACQ,IAAI,CAAC,IAAI,CAAC,CAAA;AACtC,KAAA;AACJ,GAAA;AAoBJ,CAAA;AAACC,MAAA,GAvCoBb,iBAAiB,CAAA;AAqB9Bc,oBAAA,CAAAC,kBAAA,CAWH,uNAAA,EAAA;EAAAC,UAAA,EAAA,IAAA;AAKG,CAAC,CAAC,EAAAH,MAAA,CAAA;;;;"}
|
|
@@ -1,15 +1,22 @@
|
|
|
1
1
|
import Component from '@glimmer/component';
|
|
2
|
-
import
|
|
2
|
+
import { useStyles } from '@frontile/theme';
|
|
3
3
|
import { precompileTemplate } from '@ember/template-compilation';
|
|
4
4
|
import { setComponentTemplate } from '@ember/component';
|
|
5
5
|
|
|
6
6
|
var _class;
|
|
7
|
-
class FormFieldHint extends Component {
|
|
7
|
+
class FormFieldHint extends Component {
|
|
8
|
+
get classes() {
|
|
9
|
+
const {
|
|
10
|
+
hint: hint1
|
|
11
|
+
} = useStyles();
|
|
12
|
+
return hint1({
|
|
13
|
+
size: this.args.size,
|
|
14
|
+
class: this.args.class
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
}
|
|
8
18
|
_class = FormFieldHint;
|
|
9
|
-
setComponentTemplate(precompileTemplate("\n <div id={{@id}} class={{
|
|
10
|
-
scope: () => ({
|
|
11
|
-
useFrontileClass
|
|
12
|
-
}),
|
|
19
|
+
setComponentTemplate(precompileTemplate("\n <div id={{@id}} class={{this.classes}} data-test-id=\"form-field-hint\" ...attributes>\n {{yield}}\n </div>\n ", {
|
|
13
20
|
strictMode: true
|
|
14
21
|
}), _class);
|
|
15
22
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hint.js","sources":["../../../src/components/form-field/hint.gts"],"sourcesContent":["import { template } from \"@ember/template-compiler\";\nimport Component from '@glimmer/component';\nimport
|
|
1
|
+
{"version":3,"file":"hint.js","sources":["../../../src/components/form-field/hint.gts"],"sourcesContent":["import { template } from \"@ember/template-compiler\";\nimport Component from '@glimmer/component';\nimport { useStyles } from '@frontile/theme';\nexport interface FormFieldHintArgs {\n id?: string;\n size?: 'sm' | 'md' | 'lg';\n class?: string;\n}\nexport interface FormFieldHintSignature {\n Args: FormFieldHintArgs;\n Element: HTMLDivElement;\n Blocks: {\n default: [];\n };\n}\nexport default class FormFieldHint extends Component<FormFieldHintSignature> {\n get classes() {\n const { hint: hint1 } = useStyles();\n return hint1({\n size: this.args.size,\n class: this.args.class\n });\n }\n static{\n template(`\n <div\n id={{@id}}\n class={{this.classes}}\n data-test-id=\"form-field-hint\"\n ...attributes\n >\n {{yield}}\n </div>\n `, {\n component: this,\n eval () {\n return eval(arguments[0]);\n }\n });\n }\n}\n"],"names":["FormFieldHint","Component","classes","hint","hint1","useStyles","size","args","class","_class","setComponentTemplate","precompileTemplate","strictMode"],"mappings":";;;;;;AAee,MAAMA,aAAa,SAASC,SAAS,CAAyB;EACzE,IAAIC,OAAOA,GAAG;IACV,MAAM;AAAEC,MAAAA,IAAI,EAAEC,KAAAA;KAAO,GAAGC,SAAS,EAAE,CAAA;AACnC,IAAA,OAAOD,KAAK,CAAC;AACTE,MAAAA,IAAI,EAAE,IAAI,CAACC,IAAI,CAACD,IAAI;AACpBE,MAAAA,KAAK,EAAE,IAAI,CAACD,IAAI,CAACC,KAAAA;AACrB,KAAC,CAAC,CAAA;AACN,GAAA;AAkBJ,CAAA;AAACC,MAAA,GAzBoBT,aAAa,CAAA;AAS1BU,oBAAA,CAAAC,kBAAA,CASH,+HAAA,EAAA;EAAAC,UAAA,EAAA,IAAA;AAKG,CAAC,CAAC,EAAAH,MAAA,CAAA;;;;"}
|
|
@@ -2,7 +2,7 @@ import _applyDecoratedDescriptor from '@babel/runtime/helpers/esm/applyDecorated
|
|
|
2
2
|
import Component from '@glimmer/component';
|
|
3
3
|
import { action } from '@ember/object';
|
|
4
4
|
import { on } from '@ember/modifier';
|
|
5
|
-
import
|
|
5
|
+
import { useStyles } from '@frontile/theme';
|
|
6
6
|
import { precompileTemplate } from '@ember/template-compilation';
|
|
7
7
|
import { setComponentTemplate } from '@ember/component';
|
|
8
8
|
|
|
@@ -24,9 +24,17 @@ let FormFieldInput = (_class = (_class2 = class FormFieldInput extends Component
|
|
|
24
24
|
this.args.onChange(event1.target.value, event1);
|
|
25
25
|
}
|
|
26
26
|
}
|
|
27
|
-
|
|
27
|
+
get classes() {
|
|
28
|
+
const {
|
|
29
|
+
input: input1
|
|
30
|
+
} = useStyles();
|
|
31
|
+
return input1({
|
|
32
|
+
size: this.args.size,
|
|
33
|
+
class: this.args.class
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
}, setComponentTemplate(precompileTemplate("\n <input {{on \"input\" this.handleOnInput}} {{on \"change\" this.handleOnChange}} id={{@id}} value={{@value}} type={{this.type}} class={{this.classes}} data-test-id=\"form-field-input\" ...attributes />\n ", {
|
|
28
37
|
scope: () => ({
|
|
29
|
-
useFrontileClass,
|
|
30
38
|
on
|
|
31
39
|
}),
|
|
32
40
|
strictMode: true
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"input.js","sources":["../../../src/components/form-field/input.gts"],"sourcesContent":["import { template } from \"@ember/template-compiler\";\nimport Component from '@glimmer/component';\nimport { action } from '@ember/object';\nimport { on } from '@ember/modifier';\nimport
|
|
1
|
+
{"version":3,"file":"input.js","sources":["../../../src/components/form-field/input.gts"],"sourcesContent":["import { template } from \"@ember/template-compiler\";\nimport Component from '@glimmer/component';\nimport { action } from '@ember/object';\nimport { on } from '@ember/modifier';\nimport { useStyles } from '@frontile/theme';\nexport interface FormFieldInputArgs {\n id?: string;\n type?: string;\n size?: 'sm' | 'md' | 'lg';\n class?: string;\n value?: string;\n // Callback when oninput is triggered\n onInput?: (value: string, event: InputEvent) => void;\n // Callback when onchange is triggered\n onChange?: (value: string, event: InputEvent) => void;\n}\nexport interface FormFieldInputSignature {\n Args: FormFieldInputArgs;\n Element: HTMLInputElement;\n}\nexport default class FormFieldInput extends Component<FormFieldInputSignature> {\n get type(): string {\n if (typeof this.args.type === 'string') {\n return this.args.type;\n }\n return 'text';\n }\n @action\n handleOnInput(event1: Event): void {\n if (typeof this.args.onInput === 'function') {\n this.args.onInput((event1.target as HTMLInputElement).value, event1 as InputEvent);\n }\n }\n @action\n handleOnChange(event1: Event): void {\n if (typeof this.args.onChange === 'function') {\n this.args.onChange((event1.target as HTMLInputElement).value, event1 as InputEvent);\n }\n }\n get classes() {\n const { input: input1 } = useStyles();\n return input1({\n size: this.args.size,\n class: this.args.class\n });\n }\n static{\n template(`\n <input\n {{on \"input\" this.handleOnInput}}\n {{on \"change\" this.handleOnChange}}\n id={{@id}}\n value={{@value}}\n type={{this.type}}\n class={{this.classes}}\n data-test-id=\"form-field-input\"\n ...attributes\n />\n `, {\n component: this,\n eval () {\n return eval(arguments[0]);\n }\n });\n }\n}\n"],"names":["FormFieldInput","_class","_class2","Component","type","args","handleOnInput","event1","onInput","target","value","handleOnChange","onChange","classes","input","input1","useStyles","size","class","setComponentTemplate","precompileTemplate","scope","on","strictMode","_applyDecoratedDescriptor","prototype","action","Object","getOwnPropertyDescriptor"],"mappings":";;;;;;;;;AAoBqBA,IAAAA,cAAc,IAAAC,MAAA,IAAAC,OAAA,GAApB,MAAMF,cAAc,SAASG,SAAS,CAA0B;EAC3E,IAAIC,IAAIA,GAAW;IACf,IAAI,OAAO,IAAI,CAACC,IAAI,CAACD,IAAI,KAAK,QAAQ,EAAE;AACpC,MAAA,OAAO,IAAI,CAACC,IAAI,CAACD,IAAI,CAAA;AACzB,KAAA;AACA,IAAA,OAAO,MAAM,CAAA;AACjB,GAAA;EAEAE,aAAaA,CAACC,MAAa,EAAQ;IAC/B,IAAI,OAAO,IAAI,CAACF,IAAI,CAACG,OAAO,KAAK,UAAU,EAAE;AACzC,MAAA,IAAI,CAACH,IAAI,CAACG,OAAO,CAAED,MAAM,CAACE,MAAM,CAAsBC,KAAK,EAAEH,MAAoB,CAAC,CAAA;AACtF,KAAA;AACJ,GAAA;EAEAI,cAAcA,CAACJ,MAAa,EAAQ;IAChC,IAAI,OAAO,IAAI,CAACF,IAAI,CAACO,QAAQ,KAAK,UAAU,EAAE;AAC1C,MAAA,IAAI,CAACP,IAAI,CAACO,QAAQ,CAAEL,MAAM,CAACE,MAAM,CAAsBC,KAAK,EAAEH,MAAoB,CAAC,CAAA;AACvF,KAAA;AACJ,GAAA;EACA,IAAIM,OAAOA,GAAG;IACV,MAAM;AAAEC,MAAAA,KAAK,EAAEC,MAAAA;KAAQ,GAAGC,SAAS,EAAE,CAAA;AACrC,IAAA,OAAOD,MAAM,CAAC;AACVE,MAAAA,IAAI,EAAE,IAAI,CAACZ,IAAI,CAACY,IAAI;AACpBC,MAAAA,KAAK,EAAE,IAAI,CAACb,IAAI,CAACa,KAAAA;AACrB,KAAC,CAAC,CAAA;AACN,GAAA;AAoBJ,CAAC,EAAAC,oBAAA,CAlBOC,kBAAA,CAWH,qNAAA,EAAA;AAAAC,EAAAA,KAAA,EAAAA,OAAA;AAAAC,IAAAA,EAAAA;AAAA,GAAA,CAAA;EAAAC,UAAA,EAAA,IAAA;AAKG,CAAC,CAAC,EAAArB,OAAA,CAAA,EAAAA,OAAA,CAAAsB,GAAAA,yBAAA,CAAAvB,MAAA,CAAAwB,SAAA,EApCLC,eAAAA,EAAAA,CAAAA,MAAM,GAAAC,MAAA,CAAAC,wBAAA,CAAA3B,MAAA,CAAAwB,SAAA,EAAAxB,eAAAA,CAAAA,EAAAA,MAAA,CAAAwB,SAAA,CAAA,EAAAD,yBAAA,CAAAvB,MAAA,CAAAwB,SAAA,EAAA,gBAAA,EAAA,CAMNC,MAAM,CAAAC,EAAAA,MAAA,CAAAC,wBAAA,CAAA3B,MAAA,CAAAwB,SAAA,qBAAAxB,MAAA,CAAAwB,SAAA,CAAA,GAAAxB,MAAA;;;;"}
|
|
@@ -1,15 +1,22 @@
|
|
|
1
1
|
import Component from '@glimmer/component';
|
|
2
|
-
import
|
|
2
|
+
import { useStyles } from '@frontile/theme';
|
|
3
3
|
import { precompileTemplate } from '@ember/template-compilation';
|
|
4
4
|
import { setComponentTemplate } from '@ember/component';
|
|
5
5
|
|
|
6
6
|
var _class;
|
|
7
|
-
class FormFieldLabel extends Component {
|
|
7
|
+
class FormFieldLabel extends Component {
|
|
8
|
+
get classes() {
|
|
9
|
+
const {
|
|
10
|
+
label: label1
|
|
11
|
+
} = useStyles();
|
|
12
|
+
return label1({
|
|
13
|
+
size: this.args.size,
|
|
14
|
+
class: this.args.class
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
}
|
|
8
18
|
_class = FormFieldLabel;
|
|
9
|
-
setComponentTemplate(precompileTemplate("\n <label for={{@for}} class={{
|
|
10
|
-
scope: () => ({
|
|
11
|
-
useFrontileClass
|
|
12
|
-
}),
|
|
19
|
+
setComponentTemplate(precompileTemplate("\n <label for={{@for}} class={{this.classes}} data-test-id=\"form-field-label\" ...attributes>\n {{yield}}\n </label>\n ", {
|
|
13
20
|
strictMode: true
|
|
14
21
|
}), _class);
|
|
15
22
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"label.js","sources":["../../../src/components/form-field/label.gts"],"sourcesContent":["import { template } from \"@ember/template-compiler\";\nimport Component from '@glimmer/component';\nimport
|
|
1
|
+
{"version":3,"file":"label.js","sources":["../../../src/components/form-field/label.gts"],"sourcesContent":["import { template } from \"@ember/template-compiler\";\nimport Component from '@glimmer/component';\nimport { useStyles } from '@frontile/theme';\nexport interface FormFieldLabelArgs {\n for?: string;\n size?: 'sm' | 'md' | 'lg';\n class?: string;\n}\nexport interface FormFieldLabelSignature {\n Args: FormFieldLabelArgs;\n Element: HTMLLabelElement;\n Blocks: {\n default: [];\n };\n}\nexport default class FormFieldLabel extends Component<FormFieldLabelSignature> {\n get classes() {\n const { label: label1 } = useStyles();\n return label1({\n size: this.args.size,\n class: this.args.class\n });\n }\n static{\n template(`\n <label\n for={{@for}}\n class={{this.classes}}\n data-test-id=\"form-field-label\"\n ...attributes\n >\n {{yield}}\n </label>\n `, {\n component: this,\n eval () {\n return eval(arguments[0]);\n }\n });\n }\n}\n"],"names":["FormFieldLabel","Component","classes","label","label1","useStyles","size","args","class","_class","setComponentTemplate","precompileTemplate","strictMode"],"mappings":";;;;;;AAee,MAAMA,cAAc,SAASC,SAAS,CAA0B;EAC3E,IAAIC,OAAOA,GAAG;IACV,MAAM;AAAEC,MAAAA,KAAK,EAAEC,MAAAA;KAAQ,GAAGC,SAAS,EAAE,CAAA;AACrC,IAAA,OAAOD,MAAM,CAAC;AACVE,MAAAA,IAAI,EAAE,IAAI,CAACC,IAAI,CAACD,IAAI;AACpBE,MAAAA,KAAK,EAAE,IAAI,CAACD,IAAI,CAACC,KAAAA;AACrB,KAAC,CAAC,CAAA;AACN,GAAA;AAkBJ,CAAA;AAACC,MAAA,GAzBoBT,cAAc,CAAA;AAS3BU,oBAAA,CAAAC,kBAAA,CASH,sIAAA,EAAA;EAAAC,UAAA,EAAA,IAAA;AAKG,CAAC,CAAC,EAAAH,MAAA,CAAA;;;;"}
|
|
@@ -2,7 +2,7 @@ import _applyDecoratedDescriptor from '@babel/runtime/helpers/esm/applyDecorated
|
|
|
2
2
|
import Component from '@glimmer/component';
|
|
3
3
|
import { action } from '@ember/object';
|
|
4
4
|
import { on } from '@ember/modifier';
|
|
5
|
-
import
|
|
5
|
+
import { useStyles } from '@frontile/theme';
|
|
6
6
|
import { precompileTemplate } from '@ember/template-compilation';
|
|
7
7
|
import { setComponentTemplate } from '@ember/component';
|
|
8
8
|
|
|
@@ -17,9 +17,17 @@ let FormFieldRadio = (_class = (_class2 = class FormFieldRadio extends Component
|
|
|
17
17
|
this.args.onChange(this.args.value, event1);
|
|
18
18
|
}
|
|
19
19
|
}
|
|
20
|
-
|
|
20
|
+
get classes() {
|
|
21
|
+
const {
|
|
22
|
+
radio: radio1
|
|
23
|
+
} = useStyles();
|
|
24
|
+
return radio1({
|
|
25
|
+
size: this.args.size,
|
|
26
|
+
class: this.args.class
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
}, setComponentTemplate(precompileTemplate("\n <input {{on \"change\" this.handleChange}} id={{@id}} name={{@name}} value={{@value}} checked={{this.isChecked}} type=\"radio\" class={{this.classes}} data-test-id=\"form-field-radio\" ...attributes />\n ", {
|
|
21
30
|
scope: () => ({
|
|
22
|
-
useFrontileClass,
|
|
23
31
|
on
|
|
24
32
|
}),
|
|
25
33
|
strictMode: true
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"radio.js","sources":["../../../src/components/form-field/radio.gts"],"sourcesContent":["import { template } from \"@ember/template-compiler\";\nimport Component from '@glimmer/component';\nimport { action } from '@ember/object';\nimport { on } from '@ember/modifier';\nimport
|
|
1
|
+
{"version":3,"file":"radio.js","sources":["../../../src/components/form-field/radio.gts"],"sourcesContent":["import { template } from \"@ember/template-compiler\";\nimport Component from '@glimmer/component';\nimport { action } from '@ember/object';\nimport { on } from '@ember/modifier';\nimport { useStyles } from '@frontile/theme';\nexport interface FormFieldRadioArgs {\n id?: string;\n value?: string | number | boolean;\n checked?: unknown;\n name?: string;\n size?: 'sm' | 'md' | 'lg';\n class?: string;\n // Callback when onchange is triggered\n onChange?: (value: unknown, event: Event) => void;\n}\nexport interface FormFieldRadioSignature {\n Args: FormFieldRadioArgs;\n Element: HTMLInputElement;\n}\nexport default class FormFieldRadio extends Component<FormFieldRadioSignature> {\n get isChecked(): boolean {\n return this.args.checked === this.args.value;\n }\n @action\n handleChange(event1: Event): void {\n event1.preventDefault();\n if (typeof this.args.onChange === 'function') {\n this.args.onChange(this.args.value, event1);\n }\n }\n get classes() {\n const { radio: radio1 } = useStyles();\n return radio1({\n size: this.args.size,\n class: this.args.class\n });\n }\n static{\n template(`\n <input\n {{on \"change\" this.handleChange}}\n id={{@id}}\n name={{@name}}\n value={{@value}}\n checked={{this.isChecked}}\n type=\"radio\"\n class={{this.classes}}\n data-test-id=\"form-field-radio\"\n ...attributes\n />\n `, {\n component: this,\n eval () {\n return eval(arguments[0]);\n }\n });\n }\n}\n"],"names":["FormFieldRadio","_class","_class2","Component","isChecked","args","checked","value","handleChange","event1","preventDefault","onChange","classes","radio","radio1","useStyles","size","class","setComponentTemplate","precompileTemplate","scope","on","strictMode","_applyDecoratedDescriptor","prototype","action","Object","getOwnPropertyDescriptor"],"mappings":";;;;;;;;;AAmBqBA,IAAAA,cAAc,IAAAC,MAAA,IAAAC,OAAA,GAApB,MAAMF,cAAc,SAASG,SAAS,CAA0B;EAC3E,IAAIC,SAASA,GAAY;IACrB,OAAO,IAAI,CAACC,IAAI,CAACC,OAAO,KAAK,IAAI,CAACD,IAAI,CAACE,KAAK,CAAA;AAChD,GAAA;EAEAC,YAAYA,CAACC,MAAa,EAAQ;IAC9BA,MAAM,CAACC,cAAc,EAAE,CAAA;IACvB,IAAI,OAAO,IAAI,CAACL,IAAI,CAACM,QAAQ,KAAK,UAAU,EAAE;AAC1C,MAAA,IAAI,CAACN,IAAI,CAACM,QAAQ,CAAC,IAAI,CAACN,IAAI,CAACE,KAAK,EAAEE,MAAM,CAAC,CAAA;AAC/C,KAAA;AACJ,GAAA;EACA,IAAIG,OAAOA,GAAG;IACV,MAAM;AAAEC,MAAAA,KAAK,EAAEC,MAAAA;KAAQ,GAAGC,SAAS,EAAE,CAAA;AACrC,IAAA,OAAOD,MAAM,CAAC;AACVE,MAAAA,IAAI,EAAE,IAAI,CAACX,IAAI,CAACW,IAAI;AACpBC,MAAAA,KAAK,EAAE,IAAI,CAACZ,IAAI,CAACY,KAAAA;AACrB,KAAC,CAAC,CAAA;AACN,GAAA;AAqBJ,CAAC,EAAAC,oBAAA,CAnBOC,kBAAA,CAYH,qNAAA,EAAA;AAAAC,EAAAA,KAAA,EAAAA,OAAA;AAAAC,IAAAA,EAAAA;AAAA,GAAA,CAAA;EAAAC,UAAA,EAAA,IAAA;AAKG,CAAC,CAAC,EAAApB,OAAA,CAAAA,EAAAA,OAAA,CAAAqB,GAAAA,yBAAA,CAAAtB,MAAA,CAAAuB,SAAA,EAhCLC,cAAAA,EAAAA,CAAAA,MAAM,GAAAC,MAAA,CAAAC,wBAAA,CAAA1B,MAAA,CAAAuB,SAAA,EAAA,cAAA,CAAA,EAAAvB,MAAA,CAAAuB,SAAA,CAAA,GAAAvB,MAAA;;;;"}
|
|
@@ -2,7 +2,7 @@ import _applyDecoratedDescriptor from '@babel/runtime/helpers/esm/applyDecorated
|
|
|
2
2
|
import Component from '@glimmer/component';
|
|
3
3
|
import { action } from '@ember/object';
|
|
4
4
|
import { on } from '@ember/modifier';
|
|
5
|
-
import
|
|
5
|
+
import { useStyles } from '@frontile/theme';
|
|
6
6
|
import { precompileTemplate } from '@ember/template-compilation';
|
|
7
7
|
import { setComponentTemplate } from '@ember/component';
|
|
8
8
|
|
|
@@ -18,9 +18,17 @@ let FormFieldTextarea = (_class = (_class2 = class FormFieldTextarea extends Com
|
|
|
18
18
|
this.args.onChange(event1.target.value, event1);
|
|
19
19
|
}
|
|
20
20
|
}
|
|
21
|
-
|
|
21
|
+
get classes() {
|
|
22
|
+
const {
|
|
23
|
+
textarea: textarea1
|
|
24
|
+
} = useStyles();
|
|
25
|
+
return textarea1({
|
|
26
|
+
size: this.args.size,
|
|
27
|
+
class: this.args.class
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
}, setComponentTemplate(precompileTemplate("\n <textarea {{on \"input\" this.handleOnInput}} {{on \"change\" this.handleOnChange}} id={{@id}} value={{@value}} class={{this.classes}} data-test-id=\"form-field-textarea\" ...attributes>\n </textarea>\n ", {
|
|
22
31
|
scope: () => ({
|
|
23
|
-
useFrontileClass,
|
|
24
32
|
on
|
|
25
33
|
}),
|
|
26
34
|
strictMode: true
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"textarea.js","sources":["../../../src/components/form-field/textarea.gts"],"sourcesContent":["import { template } from \"@ember/template-compiler\";\nimport Component from '@glimmer/component';\nimport { action } from '@ember/object';\nimport { on } from '@ember/modifier';\nimport
|
|
1
|
+
{"version":3,"file":"textarea.js","sources":["../../../src/components/form-field/textarea.gts"],"sourcesContent":["import { template } from \"@ember/template-compiler\";\nimport Component from '@glimmer/component';\nimport { action } from '@ember/object';\nimport { on } from '@ember/modifier';\nimport { useStyles } from '@frontile/theme';\nexport interface FormFieldTextareaArgs {\n id?: string;\n value?: string | number | boolean;\n size?: 'sm' | 'md' | 'lg';\n class?: string;\n // Callback when oninput is triggered\n onInput?: (value: string, event: InputEvent) => void;\n // Callback when onchange is triggered\n onChange?: (value: string, event: InputEvent) => void;\n}\nexport interface FormFieldTextareaSignature {\n Args: FormFieldTextareaArgs;\n Element: HTMLTextAreaElement;\n}\nexport default class FormFieldTextarea extends Component<FormFieldTextareaSignature> {\n @action\n handleOnInput(event1: Event): void {\n if (typeof this.args.onInput === 'function') {\n this.args.onInput((event1.target as HTMLInputElement).value, event1 as InputEvent);\n }\n }\n @action\n handleOnChange(event1: Event): void {\n if (typeof this.args.onChange === 'function') {\n this.args.onChange((event1.target as HTMLInputElement).value, event1 as InputEvent);\n }\n }\n get classes() {\n const { textarea: textarea1 } = useStyles();\n return textarea1({\n size: this.args.size,\n class: this.args.class\n });\n }\n static{\n template(`\n <textarea\n {{on \"input\" this.handleOnInput}}\n {{on \"change\" this.handleOnChange}}\n id={{@id}}\n value={{@value}}\n class={{this.classes}}\n data-test-id=\"form-field-textarea\"\n ...attributes\n >\n </textarea>\n `, {\n component: this,\n eval () {\n return eval(arguments[0]);\n }\n });\n }\n}\n"],"names":["FormFieldTextarea","_class","_class2","Component","handleOnInput","event1","args","onInput","target","value","handleOnChange","onChange","classes","textarea","textarea1","useStyles","size","class","setComponentTemplate","precompileTemplate","scope","on","strictMode","_applyDecoratedDescriptor","prototype","action","Object","getOwnPropertyDescriptor"],"mappings":";;;;;;;;;AAmBqBA,IAAAA,iBAAiB,IAAAC,MAAA,IAAAC,OAAA,GAAvB,MAAMF,iBAAiB,SAASG,SAAS,CAA6B;EAEjFC,aAAaA,CAACC,MAAa,EAAQ;IAC/B,IAAI,OAAO,IAAI,CAACC,IAAI,CAACC,OAAO,KAAK,UAAU,EAAE;AACzC,MAAA,IAAI,CAACD,IAAI,CAACC,OAAO,CAAEF,MAAM,CAACG,MAAM,CAAsBC,KAAK,EAAEJ,MAAoB,CAAC,CAAA;AACtF,KAAA;AACJ,GAAA;EAEAK,cAAcA,CAACL,MAAa,EAAQ;IAChC,IAAI,OAAO,IAAI,CAACC,IAAI,CAACK,QAAQ,KAAK,UAAU,EAAE;AAC1C,MAAA,IAAI,CAACL,IAAI,CAACK,QAAQ,CAAEN,MAAM,CAACG,MAAM,CAAsBC,KAAK,EAAEJ,MAAoB,CAAC,CAAA;AACvF,KAAA;AACJ,GAAA;EACA,IAAIO,OAAOA,GAAG;IACV,MAAM;AAAEC,MAAAA,QAAQ,EAAEC,SAAAA;KAAW,GAAGC,SAAS,EAAE,CAAA;AAC3C,IAAA,OAAOD,SAAS,CAAC;AACbE,MAAAA,IAAI,EAAE,IAAI,CAACV,IAAI,CAACU,IAAI;AACpBC,MAAAA,KAAK,EAAE,IAAI,CAACX,IAAI,CAACW,KAAAA;AACrB,KAAC,CAAC,CAAA;AACN,GAAA;AAoBJ,CAAC,EAAAC,oBAAA,CAlBOC,kBAAA,CAWH,uNAAA,EAAA;AAAAC,EAAAA,KAAA,EAAAA,OAAA;AAAAC,IAAAA,EAAAA;AAAA,GAAA,CAAA;EAAAC,UAAA,EAAA,IAAA;AAKG,CAAC,CAAC,EAAApB,OAAA,CAAA,EAAAA,OAAA,CAAAqB,GAAAA,yBAAA,CAAAtB,MAAA,CAAAuB,SAAA,EApCLC,eAAAA,EAAAA,CAAAA,MAAM,GAAAC,MAAA,CAAAC,wBAAA,CAAA1B,MAAA,CAAAuB,SAAA,EAAAvB,eAAAA,CAAAA,EAAAA,MAAA,CAAAuB,SAAA,CAAA,EAAAD,yBAAA,CAAAtB,MAAA,CAAAuB,SAAA,EAAA,gBAAA,EAAA,CAMNC,MAAM,CAAAC,EAAAA,MAAA,CAAAC,wBAAA,CAAA1B,MAAA,CAAAuB,SAAA,qBAAAvB,MAAA,CAAAuB,SAAA,CAAA,GAAAvB,MAAA;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"form-field.js","sources":["../../src/components/form-field.gts"],"sourcesContent":["import { template } from \"@ember/template-compiler\";\nimport Component from '@glimmer/component';\nimport { guidFor } from '@ember/object/internals';\nimport { hash } from '@ember/helper';\nimport FormFieldCheckbox from './form-field/checkbox';\nimport FormFieldFeedback from './form-field/feedback';\nimport FormFieldHint from './form-field/hint';\nimport FormFieldInput from './form-field/input';\nimport FormFieldLabel from './form-field/label';\nimport FormFieldRadio from './form-field/radio';\nimport FormFieldTextarea from './form-field/textarea';\nimport type { WithBoundArgs } from '@glint/template';\nexport interface FormFieldArgs {\n size?: 'sm' | 'lg';\n}\nexport interface FormFieldSignature {\n Args: FormFieldArgs;\n Blocks: {\n default: [{\n id: string;\n hintId: string;\n feedbackId: string;\n Label: WithBoundArgs<typeof FormFieldLabel, 'for'> & WithBoundArgs<typeof FormFieldLabel, 'size'>;\n Hint: WithBoundArgs<typeof FormFieldHint, 'id'> & WithBoundArgs<typeof FormFieldHint, 'size'>;\n Feedback: WithBoundArgs<typeof FormFieldFeedback, 'id'> & WithBoundArgs<typeof FormFieldFeedback, 'size'>;\n Input: WithBoundArgs<typeof FormFieldInput, 'id'> & WithBoundArgs<typeof FormFieldInput, 'size'>;\n Textarea: WithBoundArgs<typeof FormFieldTextarea, 'id'> & WithBoundArgs<typeof FormFieldTextarea, 'size'>;\n Checkbox: WithBoundArgs<typeof FormFieldCheckbox, 'id'> & WithBoundArgs<typeof FormFieldCheckbox, 'size'>;\n Radio: WithBoundArgs<typeof FormFieldRadio, 'id'> & WithBoundArgs<typeof FormFieldRadio, 'size'>;\n }];\n };\n Element: HTMLDivElement;\n}\nexport default class FormField extends Component<FormFieldSignature> {\n id = guidFor(this);\n get hintId(): string {\n return this.id + '-hint';\n }\n get feedbackId(): string {\n return this.id + '-feedback';\n }\n static{\n template(`\n <div ...attributes>\n {{yield\n (hash\n id=this.id\n hintId=this.hintId\n feedbackId=this.feedbackId\n Label=(component FormFieldLabel for=this.id size=@size)\n Hint=(component FormFieldHint id=this.hintId size=@size)\n Feedback=(component FormFieldFeedback id=this.feedbackId size=@size)\n Input=(component FormFieldInput id=this.id size=@size)\n Textarea=(component FormFieldTextarea id=this.id size=@size)\n Checkbox=(component FormFieldCheckbox id=this.id size=@size)\n Radio=(component FormFieldRadio id=this.id size=@size)\n )\n }}\n </div>\n `, {\n component: this,\n eval () {\n return eval(arguments[0]);\n }\n });\n }\n}\n"],"names":["FormField","Component","constructor","args","_defineProperty","guidFor","hintId","id","feedbackId","_class","setComponentTemplate","precompileTemplate","scope","hash","FormFieldLabel","FormFieldHint","FormFieldFeedback","FormFieldInput","FormFieldTextarea","FormFieldCheckbox","FormFieldRadio","strictMode"],"mappings":";;;;;;;;;;;;;;;AAiCe,MAAMA,SAAS,SAASC,SAAS,CAAqB;AAAAC,EAAAA,WAAAA,CAAA,GAAAC,IAAA,EAAA;AAAA,IAAA,KAAA,CAAA,GAAAA,IAAA,CAAA,CAAA;AAAAC,IAAAA,eAAA,CAC5DC,IAAAA,EAAAA,IAAAA,EAAAA,OAAO,CAAC,IAAI,CAAC,CAAA,CAAA;AAAA,GAAA;EAClB,IAAIC,MAAMA,GAAW;AACjB,IAAA,OAAO,IAAI,CAACC,EAAE,GAAG,OAAO,CAAA;AAC5B,GAAA;EACA,IAAIC,UAAUA,GAAW;AACrB,IAAA,OAAO,IAAI,CAACD,EAAE,GAAG,WAAW,CAAA;AAChC,GAAA;AA0BJ,CAAA;AAACE,MAAA,GAjCoBT,SAAS,CAAA;AAStBU,oBAAA,CAAAC,kBAAA,CAiBH,0hBAAA,EAAA;AAAAC,EAAAA,KAAA,EAAAA,OAAA;IAAAC,IAAA;IAAAC,cAAA;IAAAC,aAAA;IAAAC,iBAAA;IAAAC,cAAA;IAAAC,iBAAA;IAAAC,iBAAA;AAAAC,IAAAA,cAAAA;AAAA,GAAA,CAAA;EAAAC,UAAA,EAAA,IAAA;AAKG,CAAC,CAAC,EAAAZ,MAAA,CAAA;;;;"}
|
|
1
|
+
{"version":3,"file":"form-field.js","sources":["../../src/components/form-field.gts"],"sourcesContent":["import { template } from \"@ember/template-compiler\";\nimport Component from '@glimmer/component';\nimport { guidFor } from '@ember/object/internals';\nimport { hash } from '@ember/helper';\nimport FormFieldCheckbox from './form-field/checkbox';\nimport FormFieldFeedback from './form-field/feedback';\nimport FormFieldHint from './form-field/hint';\nimport FormFieldInput from './form-field/input';\nimport FormFieldLabel from './form-field/label';\nimport FormFieldRadio from './form-field/radio';\nimport FormFieldTextarea from './form-field/textarea';\nimport type { WithBoundArgs } from '@glint/template';\nexport interface FormFieldArgs {\n size?: 'sm' | 'md' | 'lg';\n}\nexport interface FormFieldSignature {\n Args: FormFieldArgs;\n Blocks: {\n default: [{\n id: string;\n hintId: string;\n feedbackId: string;\n Label: WithBoundArgs<typeof FormFieldLabel, 'for'> & WithBoundArgs<typeof FormFieldLabel, 'size'>;\n Hint: WithBoundArgs<typeof FormFieldHint, 'id'> & WithBoundArgs<typeof FormFieldHint, 'size'>;\n Feedback: WithBoundArgs<typeof FormFieldFeedback, 'id'> & WithBoundArgs<typeof FormFieldFeedback, 'size'>;\n Input: WithBoundArgs<typeof FormFieldInput, 'id'> & WithBoundArgs<typeof FormFieldInput, 'size'>;\n Textarea: WithBoundArgs<typeof FormFieldTextarea, 'id'> & WithBoundArgs<typeof FormFieldTextarea, 'size'>;\n Checkbox: WithBoundArgs<typeof FormFieldCheckbox, 'id'> & WithBoundArgs<typeof FormFieldCheckbox, 'size'>;\n Radio: WithBoundArgs<typeof FormFieldRadio, 'id'> & WithBoundArgs<typeof FormFieldRadio, 'size'>;\n }];\n };\n Element: HTMLDivElement;\n}\nexport default class FormField extends Component<FormFieldSignature> {\n id = guidFor(this);\n get hintId(): string {\n return this.id + '-hint';\n }\n get feedbackId(): string {\n return this.id + '-feedback';\n }\n static{\n template(`\n <div ...attributes>\n {{yield\n (hash\n id=this.id\n hintId=this.hintId\n feedbackId=this.feedbackId\n Label=(component FormFieldLabel for=this.id size=@size)\n Hint=(component FormFieldHint id=this.hintId size=@size)\n Feedback=(component FormFieldFeedback id=this.feedbackId size=@size)\n Input=(component FormFieldInput id=this.id size=@size)\n Textarea=(component FormFieldTextarea id=this.id size=@size)\n Checkbox=(component FormFieldCheckbox id=this.id size=@size)\n Radio=(component FormFieldRadio id=this.id size=@size)\n )\n }}\n </div>\n `, {\n component: this,\n eval () {\n return eval(arguments[0]);\n }\n });\n }\n}\n"],"names":["FormField","Component","constructor","args","_defineProperty","guidFor","hintId","id","feedbackId","_class","setComponentTemplate","precompileTemplate","scope","hash","FormFieldLabel","FormFieldHint","FormFieldFeedback","FormFieldInput","FormFieldTextarea","FormFieldCheckbox","FormFieldRadio","strictMode"],"mappings":";;;;;;;;;;;;;;;AAiCe,MAAMA,SAAS,SAASC,SAAS,CAAqB;AAAAC,EAAAA,WAAAA,CAAA,GAAAC,IAAA,EAAA;AAAA,IAAA,KAAA,CAAA,GAAAA,IAAA,CAAA,CAAA;AAAAC,IAAAA,eAAA,CAC5DC,IAAAA,EAAAA,IAAAA,EAAAA,OAAO,CAAC,IAAI,CAAC,CAAA,CAAA;AAAA,GAAA;EAClB,IAAIC,MAAMA,GAAW;AACjB,IAAA,OAAO,IAAI,CAACC,EAAE,GAAG,OAAO,CAAA;AAC5B,GAAA;EACA,IAAIC,UAAUA,GAAW;AACrB,IAAA,OAAO,IAAI,CAACD,EAAE,GAAG,WAAW,CAAA;AAChC,GAAA;AA0BJ,CAAA;AAACE,MAAA,GAjCoBT,SAAS,CAAA;AAStBU,oBAAA,CAAAC,kBAAA,CAiBH,0hBAAA,EAAA;AAAAC,EAAAA,KAAA,EAAAA,OAAA;IAAAC,IAAA;IAAAC,cAAA;IAAAC,aAAA;IAAAC,iBAAA;IAAAC,cAAA;IAAAC,iBAAA;IAAAC,iBAAA;AAAAC,IAAAA,cAAAA;AAAA,GAAA,CAAA;EAAAC,UAAA,EAAA,IAAA;AAKG,CAAC,CAAC,EAAAZ,MAAA,CAAA;;;;"}
|
|
@@ -7,7 +7,7 @@ import { action } from '@ember/object';
|
|
|
7
7
|
import { tracked } from '@glimmer/tracking';
|
|
8
8
|
import { concat } from '@ember/helper';
|
|
9
9
|
import { on } from '@ember/modifier';
|
|
10
|
-
import
|
|
10
|
+
import { useStyles } from '@frontile/theme';
|
|
11
11
|
import FormField from './form-field.js';
|
|
12
12
|
import { precompileTemplate } from '@ember/template-compilation';
|
|
13
13
|
import { setComponentTemplate } from '@ember/component';
|
|
@@ -48,12 +48,37 @@ let FormInputBase = (_class = class FormInputBase extends Component {
|
|
|
48
48
|
return false;
|
|
49
49
|
}
|
|
50
50
|
}), _applyDecoratedDescriptor(_class.prototype, "handleFocusIn", [action], Object.getOwnPropertyDescriptor(_class.prototype, "handleFocusIn"), _class.prototype), _applyDecoratedDescriptor(_class.prototype, "handleFocusOut", [action], Object.getOwnPropertyDescriptor(_class.prototype, "handleFocusOut"), _class.prototype)), _class);
|
|
51
|
-
class FormInput extends FormInputBase {
|
|
51
|
+
class FormInput extends FormInputBase {
|
|
52
|
+
get classes() {
|
|
53
|
+
const {
|
|
54
|
+
formInput: formInput1
|
|
55
|
+
} = useStyles();
|
|
56
|
+
const {
|
|
57
|
+
base: base1,
|
|
58
|
+
label: label1,
|
|
59
|
+
input: input1,
|
|
60
|
+
hint: hint1,
|
|
61
|
+
feedback: feedback1
|
|
62
|
+
} = formInput1({
|
|
63
|
+
size: this.args.size
|
|
64
|
+
});
|
|
65
|
+
return {
|
|
66
|
+
base: base1({
|
|
67
|
+
class: this.args.containerClass
|
|
68
|
+
}),
|
|
69
|
+
label: label1(),
|
|
70
|
+
input: input1({
|
|
71
|
+
class: this.args.inputClass
|
|
72
|
+
}),
|
|
73
|
+
hint: hint1(),
|
|
74
|
+
feedback: feedback1()
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
}
|
|
52
78
|
_class3 = FormInput;
|
|
53
|
-
setComponentTemplate(precompileTemplate("\n <FormField @size={{@size}} class={{
|
|
79
|
+
setComponentTemplate(precompileTemplate("\n <FormField @size={{@size}} class={{this.classes.base}} as |f|>\n {{#if @label}}\n <f.Label @class={{this.classes.label}}>\n {{@label}}\n </f.Label>\n {{/if}}\n\n {{#if @hint}}\n <f.Hint @class={{this.classes.hint}}>\n {{@hint}}\n </f.Hint>\n {{/if}}\n\n <f.Input {{on \"focus\" this.handleFocusIn}} {{on \"blur\" this.handleFocusOut}} @onInput={{@onInput}} @onChange={{@onChange}} @value={{@value}} @type={{@type}} @class={{this.classes.input}} aria-invalid={{if this.showErrorFeedback \"true\"}} aria-describedby=\"{{if @hint f.hintId}}{{if this.showErrorFeedback (concat \" \" f.feedbackId)}}\" ...attributes />\n\n {{yield}}\n\n {{#if this.showErrorFeedback}}\n <f.Feedback @class={{this.classes.feedback}} @errors={{@errors}} />\n {{/if}}\n </FormField>\n ", {
|
|
54
80
|
scope: () => ({
|
|
55
81
|
FormField,
|
|
56
|
-
useFrontileClass,
|
|
57
82
|
concat,
|
|
58
83
|
on
|
|
59
84
|
}),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"form-input.js","sources":["../../src/components/form-input.gts"],"sourcesContent":["import { template } from \"@ember/template-compiler\";\nimport Component from '@glimmer/component';\nimport { action } from '@ember/object';\nimport { tracked } from '@glimmer/tracking';\nimport { concat } from '@ember/helper';\nimport { on } from '@ember/modifier';\nimport
|
|
1
|
+
{"version":3,"file":"form-input.js","sources":["../../src/components/form-input.gts"],"sourcesContent":["import { template } from \"@ember/template-compiler\";\nimport Component from '@glimmer/component';\nimport { action } from '@ember/object';\nimport { tracked } from '@glimmer/tracking';\nimport { concat } from '@ember/helper';\nimport { on } from '@ember/modifier';\nimport { useStyles } from '@frontile/theme';\nimport FormField from './form-field';\nexport interface FormInputArgs {\n /**\n * The value to be used in the input.\n * You must also pass `onChange` or `onInput` to update its value.\n */ value: string | undefined;\n /**\n * The input type\n * @defaultValue 'text'\n */ type?: string;\n /** The group label */ label?: string;\n /** A help text to be displayed */ hint?: string;\n /** If the form has been submitted, used to force displaying errors */ hasSubmitted?: boolean;\n /** If has errors */ hasError?: boolean;\n /** Force displaying errors */ showError?: boolean;\n /** A list of errors or a single text describing the error */ errors?: string[] | string;\n /** CSS classes to be added in the container element */ containerClass?: string;\n /** The size */ size?: 'sm' | 'md' | 'lg';\n /** CSS classes to be added in the input element */ inputClass?: string;\n /** Callback when oninput is triggered */ onInput?: (value: string, event: InputEvent) => void;\n /** Callback when onchange is triggered */ onChange?: (value: string, event: InputEvent) => void;\n /** Callback when onfocus is triggered */ onFocusIn?: (event: FocusEvent) => void;\n /** Callback when onblur is triggered */ onFocusOut?: (event: FocusEvent) => void;\n}\nexport interface FormInputBaseSignature {\n Args: FormInputArgs;\n}\nexport interface FormInputSignature extends FormInputBaseSignature {\n Element: HTMLInputElement;\n Blocks: {\n default: [];\n };\n}\nexport class FormInputBase<T extends FormInputBaseSignature> extends Component<T> {\n @tracked\n shouldShowErrorFeedback = false;\n get showErrorFeedback(): boolean {\n if (this.args.hasError === false) {\n return false;\n }\n if ((this.args.showError || this.args.hasSubmitted || this.shouldShowErrorFeedback) && this.args.errors && this.args.errors.length > 0) {\n return true;\n } else {\n return false;\n }\n }\n @action\n handleFocusIn(event1: FocusEvent): void {\n this.shouldShowErrorFeedback = false;\n if (typeof this.args.onFocusIn === 'function') {\n this.args.onFocusIn(event1);\n }\n }\n @action\n handleFocusOut(event1: FocusEvent): void {\n this.shouldShowErrorFeedback = true;\n if (typeof this.args.onFocusOut === 'function') {\n this.args.onFocusOut(event1);\n }\n }\n}\nexport default class FormInput extends FormInputBase<FormInputSignature> {\n get classes() {\n const { formInput: formInput1 } = useStyles();\n const { base: base1, label: label1, input: input1, hint: hint1, feedback: feedback1 } = formInput1({\n size: this.args.size\n });\n return {\n base: base1({\n class: this.args.containerClass\n }),\n label: label1(),\n input: input1({\n class: this.args.inputClass\n }),\n hint: hint1(),\n feedback: feedback1()\n };\n }\n static{\n template(`\n <FormField @size={{@size}} class={{this.classes.base}} as |f|>\n {{#if @label}}\n <f.Label @class={{this.classes.label}}>\n {{@label}}\n </f.Label>\n {{/if}}\n\n {{#if @hint}}\n <f.Hint @class={{this.classes.hint}}>\n {{@hint}}\n </f.Hint>\n {{/if}}\n\n <f.Input\n {{on \"focus\" this.handleFocusIn}}\n {{on \"blur\" this.handleFocusOut}}\n @onInput={{@onInput}}\n @onChange={{@onChange}}\n @value={{@value}}\n @type={{@type}}\n @class={{this.classes.input}}\n aria-invalid={{if this.showErrorFeedback \"true\"}}\n aria-describedby=\"{{if @hint f.hintId}}{{if\n this.showErrorFeedback\n (concat ' ' f.feedbackId)\n }}\"\n ...attributes\n />\n\n {{yield}}\n\n {{#if this.showErrorFeedback}}\n <f.Feedback @class={{this.classes.feedback}} @errors={{@errors}} />\n {{/if}}\n </FormField>\n `, {\n component: this,\n eval () {\n return eval(arguments[0]);\n }\n });\n }\n}\n"],"names":["FormInputBase","_class","Component","constructor","args","_initializerDefineProperty","_descriptor","showErrorFeedback","hasError","showError","hasSubmitted","shouldShowErrorFeedback","errors","length","handleFocusIn","event1","onFocusIn","handleFocusOut","onFocusOut","_applyDecoratedDescriptor","prototype","tracked","configurable","enumerable","writable","initializer","action","Object","getOwnPropertyDescriptor","FormInput","classes","formInput","formInput1","useStyles","base","base1","label","label1","input","input1","hint","hint1","feedback","feedback1","size","class","containerClass","inputClass","_class3","setComponentTemplate","precompileTemplate","scope","FormField","concat","on","strictMode"],"mappings":"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"}
|
|
@@ -8,7 +8,7 @@ import { tracked } from '@glimmer/tracking';
|
|
|
8
8
|
import { concat } from '@ember/helper';
|
|
9
9
|
import FormRadio from './form-radio.js';
|
|
10
10
|
import FormField from './form-field.js';
|
|
11
|
-
import
|
|
11
|
+
import { useStyles } from '@frontile/theme';
|
|
12
12
|
import { precompileTemplate } from '@ember/template-compilation';
|
|
13
13
|
import { setComponentTemplate } from '@ember/component';
|
|
14
14
|
|
|
@@ -34,10 +34,32 @@ let FormRadioGroup = (_class = (_class2 = class FormRadioGroup extends Component
|
|
|
34
34
|
this.args.onChange(value1, event1);
|
|
35
35
|
}
|
|
36
36
|
}
|
|
37
|
-
|
|
37
|
+
get classes() {
|
|
38
|
+
const {
|
|
39
|
+
formRadioGroup: formRadioGroup1
|
|
40
|
+
} = useStyles();
|
|
41
|
+
const {
|
|
42
|
+
base: base1,
|
|
43
|
+
label: label1,
|
|
44
|
+
formRadio: formRadio1,
|
|
45
|
+
hint: hint1,
|
|
46
|
+
feedback: feedback1
|
|
47
|
+
} = formRadioGroup1({
|
|
48
|
+
isInline: this.args.isInline
|
|
49
|
+
});
|
|
50
|
+
return {
|
|
51
|
+
base: base1({
|
|
52
|
+
class: this.args.containerClass
|
|
53
|
+
}),
|
|
54
|
+
label: label1(),
|
|
55
|
+
hint: hint1(),
|
|
56
|
+
feedback: feedback1(),
|
|
57
|
+
formRadio: formRadio1()
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
}, setComponentTemplate(precompileTemplate("\n <FormField @size={{@size}} class={{this.classes.base}} role=\"radiogroup\" ...attributes as |f|>\n {{#if @label}}\n <f.Label @class={{this.classes.label}}>\n {{@label}}\n </f.Label>\n {{/if}}\n\n {{#if @hint}}\n <f.Hint @class={{this.classes.hint}}>\n\n {{@hint}}\n </f.Hint>\n {{/if}}\n\n {{yield (component FormRadio checked=@value privateContainerClass=this.classes.formRadio _parentOnChange=this.handleChange size=@size name=(concat f.id \"-radio-group\"))}}\n\n {{#if this.showErrorFeedback}}\n <f.Feedback @class={{this.classes.feedback}} @errors={{@errors}} />\n {{/if}}\n </FormField>\n ", {
|
|
38
61
|
scope: () => ({
|
|
39
62
|
FormField,
|
|
40
|
-
useFrontileClass,
|
|
41
63
|
FormRadio,
|
|
42
64
|
concat
|
|
43
65
|
}),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"form-radio-group.js","sources":["../../src/components/form-radio-group.gts"],"sourcesContent":["import { template } from \"@ember/template-compiler\";\nimport Component from '@glimmer/component';\nimport { action } from '@ember/object';\nimport { tracked } from '@glimmer/tracking';\nimport { concat } from '@ember/helper';\nimport FormRadio from './form-radio';\nimport FormField from './form-field';\nimport
|
|
1
|
+
{"version":3,"file":"form-radio-group.js","sources":["../../src/components/form-radio-group.gts"],"sourcesContent":["import { template } from \"@ember/template-compiler\";\nimport Component from '@glimmer/component';\nimport { action } from '@ember/object';\nimport { tracked } from '@glimmer/tracking';\nimport { concat } from '@ember/helper';\nimport FormRadio from './form-radio';\nimport FormField from './form-field';\nimport { useStyles } from '@frontile/theme';\nimport type { WithBoundArgs } from '@glint/template';\nexport interface FormRadioGroupArgs {\n value: string | number | boolean | undefined;\n /** The group label */ label?: string;\n /** A help text to be displayed */ hint?: string;\n /** If the form has been submitted, used to force displaying errors */ hasSubmitted?: boolean;\n /** If has errors */ hasError?: boolean;\n /** Force displaying errors */ showError?: boolean;\n /** A list of errors or a single text describing the error */ errors?: string[] | string;\n /** CSS classes to be added in the container element */ containerClass?: string;\n /** The size */ size?: 'sm' | 'md' | 'lg';\n /** If the Checkbox should be in one line */ isInline?: boolean;\n /** Default callback added to the yielded FormRadio component, called when onchange is triggered */ onChange?: (value: unknown, event: Event) => void;\n}\nexport interface FormRadioGroupSignature {\n Args: FormRadioGroupArgs;\n Blocks: {\n default: [radio: WithBoundArgs<typeof FormRadio, 'checked'> & WithBoundArgs<typeof FormRadio, 'privateContainerClass'> & WithBoundArgs<typeof FormRadio, '_parentOnChange'> & WithBoundArgs<typeof FormRadio, 'size'> & WithBoundArgs<typeof FormRadio, 'name'>];\n };\n Element: HTMLDivElement;\n}\nexport default class FormRadioGroup extends Component<FormRadioGroupSignature> {\n @tracked\n shouldShowErrorFeedback = false;\n get showErrorFeedback(): boolean {\n if (this.args.hasError === false) {\n return false;\n }\n if ((this.args.showError || this.args.hasSubmitted || this.shouldShowErrorFeedback) && this.args.errors && this.args.errors.length > 0) {\n return true;\n } else {\n return false;\n }\n }\n @action\n handleChange(value1: unknown, event1: Event): void {\n this.shouldShowErrorFeedback = true;\n if (typeof this.args.onChange === 'function') {\n this.args.onChange(value1, event1);\n }\n }\n get classes() {\n const { formRadioGroup: formRadioGroup1 } = useStyles();\n const { base: base1, label: label1, formRadio: formRadio1, hint: hint1, feedback: feedback1 } = formRadioGroup1({\n isInline: this.args.isInline\n });\n return {\n base: base1({\n class: this.args.containerClass\n }),\n label: label1(),\n hint: hint1(),\n feedback: feedback1(),\n formRadio: formRadio1()\n };\n }\n static{\n template(`\n <FormField\n @size={{@size}}\n class={{this.classes.base}}\n role=\"radiogroup\"\n ...attributes\n as |f|\n >\n {{#if @label}}\n <f.Label @class={{this.classes.label}}>\n {{@label}}\n </f.Label>\n {{/if}}\n\n {{#if @hint}}\n <f.Hint @class={{this.classes.hint}}>\n\n {{@hint}}\n </f.Hint>\n {{/if}}\n\n {{yield\n (component\n FormRadio\n checked=@value\n privateContainerClass=this.classes.formRadio\n _parentOnChange=this.handleChange\n size=@size\n name=(concat f.id \"-radio-group\")\n )\n }}\n\n {{#if this.showErrorFeedback}}\n <f.Feedback @class={{this.classes.feedback}} @errors={{@errors}} />\n {{/if}}\n </FormField>\n `, {\n component: this,\n eval () {\n return eval(arguments[0]);\n }\n });\n }\n}\n"],"names":["FormRadioGroup","_class","_class2","Component","constructor","args","_initializerDefineProperty","_descriptor","showErrorFeedback","hasError","showError","hasSubmitted","shouldShowErrorFeedback","errors","length","handleChange","value1","event1","onChange","classes","formRadioGroup","formRadioGroup1","useStyles","base","base1","label","label1","formRadio","formRadio1","hint","hint1","feedback","feedback1","isInline","class","containerClass","setComponentTemplate","precompileTemplate","scope","FormField","FormRadio","concat","strictMode","_applyDecoratedDescriptor","prototype","tracked","configurable","enumerable","writable","initializer","action","Object","getOwnPropertyDescriptor"],"mappings":";;;;;;;;;;;;;;;AA6BqBA,IAAAA,cAAc,IAAAC,MAAA,IAAAC,OAAA,GAApB,MAAMF,cAAc,SAASG,SAAS,CAA0B;AAAAC,EAAAA,WAAAA,CAAA,GAAAC,IAAA,EAAA;AAAA,IAAA,KAAA,CAAA,GAAAA,IAAA,CAAA,CAAA;AAAAC,IAAAA,0BAAA,kCAAAC,WAAA,EAAA,IAAA,CAAA,CAAA;AAAA,GAAA;EAG3E,IAAIC,iBAAiBA,GAAY;AAC7B,IAAA,IAAI,IAAI,CAACH,IAAI,CAACI,QAAQ,KAAK,KAAK,EAAE;AAC9B,MAAA,OAAO,KAAK,CAAA;AAChB,KAAA;AACA,IAAA,IAAI,CAAC,IAAI,CAACJ,IAAI,CAACK,SAAS,IAAI,IAAI,CAACL,IAAI,CAACM,YAAY,IAAI,IAAI,CAACC,uBAAuB,KAAK,IAAI,CAACP,IAAI,CAACQ,MAAM,IAAI,IAAI,CAACR,IAAI,CAACQ,MAAM,CAACC,MAAM,GAAG,CAAC,EAAE;AACpI,MAAA,OAAO,IAAI,CAAA;AACf,KAAC,MAAM;AACH,MAAA,OAAO,KAAK,CAAA;AAChB,KAAA;AACJ,GAAA;AAEAC,EAAAA,YAAYA,CAACC,MAAe,EAAEC,MAAa,EAAQ;IAC/C,IAAI,CAACL,uBAAuB,GAAG,IAAI,CAAA;IACnC,IAAI,OAAO,IAAI,CAACP,IAAI,CAACa,QAAQ,KAAK,UAAU,EAAE;MAC1C,IAAI,CAACb,IAAI,CAACa,QAAQ,CAACF,MAAM,EAAEC,MAAM,CAAC,CAAA;AACtC,KAAA;AACJ,GAAA;EACA,IAAIE,OAAOA,GAAG;IACV,MAAM;AAAEC,MAAAA,cAAc,EAAEC,eAAAA;KAAiB,GAAGC,SAAS,EAAE,CAAA;IACvD,MAAM;AAAEC,MAAAA,IAAI,EAAEC,KAAK;AAAEC,MAAAA,KAAK,EAAEC,MAAM;AAAEC,MAAAA,SAAS,EAAEC,UAAU;AAAEC,MAAAA,IAAI,EAAEC,KAAK;AAAEC,MAAAA,QAAQ,EAAEC,SAAAA;KAAW,GAAGX,eAAe,CAAC;AAC5GY,MAAAA,QAAQ,EAAE,IAAI,CAAC5B,IAAI,CAAC4B,QAAAA;AACxB,KAAC,CAAC,CAAA;IACF,OAAO;MACHV,IAAI,EAAEC,KAAK,CAAC;AACRU,QAAAA,KAAK,EAAE,IAAI,CAAC7B,IAAI,CAAC8B,cAAAA;AACrB,OAAC,CAAC;MACFV,KAAK,EAAEC,MAAM,EAAE;MACfG,IAAI,EAAEC,KAAK,EAAE;MACbC,QAAQ,EAAEC,SAAS,EAAE;MACrBL,SAAS,EAAEC,UAAU,EAAC;KACzB,CAAA;AACL,GAAA;AA6CJ,CAAC,EAAAQ,oBAAA,CA3COC,kBAAA,CAoCH,urBAAA,EAAA;AAAAC,EAAAA,KAAA,EAAAA,OAAA;IAAAC,SAAA;IAAAC,SAAA;AAAAC,IAAAA,MAAAA;AAAA,GAAA,CAAA;EAAAC,UAAA,EAAA,IAAA;AAKG,CAAC,CAAC,EAAAxC,OAAA,CAAA,EAAAA,OAAA,CAAAK,GAAAA,WAAA,GAAAoC,yBAAA,CAAA1C,MAAA,CAAA2C,SAAA,8BA5ELC,OAAO,CAAA,EAAA;EAAAC,YAAA,EAAA,IAAA;EAAAC,UAAA,EAAA,IAAA;EAAAC,QAAA,EAAA,IAAA;AAAAC,EAAAA,WAAA,cAAA;AAAA,IAAA,OACkB,KAAK,CAAA;AAAA,GAAA;AAAA,CAAAN,CAAAA,EAAAA,yBAAA,CAAA1C,MAAA,CAAA2C,SAAA,EAW9BM,cAAAA,EAAAA,CAAAA,MAAM,GAAAC,MAAA,CAAAC,wBAAA,CAAAnD,MAAA,CAAA2C,SAAA,EAAA,cAAA,CAAA,EAAA3C,MAAA,CAAA2C,SAAA,IAAA3C,MAAA;;;;"}
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import _applyDecoratedDescriptor from '@babel/runtime/helpers/esm/applyDecoratedDescriptor';
|
|
2
2
|
import Component from '@glimmer/component';
|
|
3
3
|
import { action } from '@ember/object';
|
|
4
|
-
import { array } from '@ember/helper';
|
|
5
4
|
import FormField from './form-field.js';
|
|
6
|
-
import
|
|
5
|
+
import { useStyles } from '@frontile/theme';
|
|
7
6
|
import { precompileTemplate } from '@ember/template-compilation';
|
|
8
7
|
import { setComponentTemplate } from '@ember/component';
|
|
9
8
|
|
|
@@ -21,11 +20,41 @@ let FormRadio = (_class = (_class2 = class FormRadio extends Component {
|
|
|
21
20
|
get isChecked() {
|
|
22
21
|
return this.args.checked == this.args.value;
|
|
23
22
|
}
|
|
24
|
-
|
|
23
|
+
get classes() {
|
|
24
|
+
const {
|
|
25
|
+
formRadio: formRadio1
|
|
26
|
+
} = useStyles();
|
|
27
|
+
const {
|
|
28
|
+
base: base1,
|
|
29
|
+
label: label1,
|
|
30
|
+
radio: radio1,
|
|
31
|
+
hint: hint1,
|
|
32
|
+
labelContainer: labelContainer1,
|
|
33
|
+
inputContainer: inputContainer1
|
|
34
|
+
} = formRadio1({
|
|
35
|
+
size: this.args.size
|
|
36
|
+
});
|
|
37
|
+
let containerClasses1 = '';
|
|
38
|
+
if (this.args.containerClass) {
|
|
39
|
+
containerClasses1 = this.args.containerClass;
|
|
40
|
+
}
|
|
41
|
+
if (this.args.privateContainerClass) {
|
|
42
|
+
containerClasses1 += ' ' + this.args.privateContainerClass;
|
|
43
|
+
}
|
|
44
|
+
return {
|
|
45
|
+
base: base1({
|
|
46
|
+
class: containerClasses1
|
|
47
|
+
}),
|
|
48
|
+
label: label1(),
|
|
49
|
+
inputContainer: inputContainer1(),
|
|
50
|
+
labelContainer: labelContainer1(),
|
|
51
|
+
hint: hint1(),
|
|
52
|
+
radio: radio1()
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
}, setComponentTemplate(precompileTemplate("\n <FormField @size={{@size}} class={{this.classes.base}} as |f|>\n <div class={{this.classes.labelContainer}}>\n <div class={{this.classes.inputContainer}}>\n {{!-- Zero-width space character, used to align checkbox properly --}}\n {{!-- eslint-disable no-irregular-whitespace--}}\n \u200B\n <f.Radio @onChange={{this.handleChange}} @value={{@value}} @checked={{@checked}} @name={{@name}} @class={{this.classes.radio}} aria-describedby={{if @hint f.hintId}} ...attributes />\n </div>\n\n <f.Label @class={{this.classes.label}}>\n {{#if (has-block)}}\n {{yield}}\n {{else}}\n {{@label}}\n {{/if}}\n </f.Label>\n </div>\n\n {{#if @hint}}\n <f.Hint @class={{this.classes.hint}}>\n {{@hint}}\n </f.Hint>\n {{/if}}\n </FormField>\n ", {
|
|
25
56
|
scope: () => ({
|
|
26
|
-
FormField
|
|
27
|
-
useFrontileClass,
|
|
28
|
-
array
|
|
57
|
+
FormField
|
|
29
58
|
}),
|
|
30
59
|
strictMode: true
|
|
31
60
|
}), _class2), _class2), (_applyDecoratedDescriptor(_class.prototype, "handleChange", [action], Object.getOwnPropertyDescriptor(_class.prototype, "handleChange"), _class.prototype)), _class);
|