@ember-eui/validated-form 13.0.5 → 14.1.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/-private/random-id.d.ts.map +1 -1
- package/declarations/components/validated-form/field-base.d.ts +33 -4
- package/declarations/components/validated-form/field-base.d.ts.map +1 -1
- package/declarations/components/validated-form/field-checkbox-group.d.ts +12 -1
- package/declarations/components/validated-form/field-checkbox-group.d.ts.map +1 -1
- package/declarations/components/validated-form/field-combo-box.d.ts +14 -1
- package/declarations/components/validated-form/field-combo-box.d.ts.map +1 -1
- package/declarations/components/validated-form/field-dual-range-slider.d.ts +17 -1
- package/declarations/components/validated-form/field-dual-range-slider.d.ts.map +1 -1
- package/declarations/components/validated-form/field-markdown-editor.d.ts +13 -1
- package/declarations/components/validated-form/field-markdown-editor.d.ts.map +1 -1
- package/declarations/components/validated-form/field-number.d.ts +12 -1
- package/declarations/components/validated-form/field-number.d.ts.map +1 -1
- package/declarations/components/validated-form/field-password.d.ts +12 -1
- package/declarations/components/validated-form/field-password.d.ts.map +1 -1
- package/declarations/components/validated-form/field-radio-group.d.ts +11 -7
- package/declarations/components/validated-form/field-radio-group.d.ts.map +1 -1
- package/declarations/components/validated-form/field-range-slider.d.ts +11 -1
- package/declarations/components/validated-form/field-range-slider.d.ts.map +1 -1
- package/declarations/components/validated-form/field-select.d.ts +11 -1
- package/declarations/components/validated-form/field-select.d.ts.map +1 -1
- package/declarations/components/validated-form/field-switch.d.ts +12 -1
- package/declarations/components/validated-form/field-switch.d.ts.map +1 -1
- package/declarations/components/validated-form/field-text-area.d.ts +17 -0
- package/declarations/components/validated-form/field-text-area.d.ts.map +1 -1
- package/declarations/components/validated-form/field-text.d.ts +9 -0
- package/declarations/components/validated-form/field-text.d.ts.map +1 -1
- package/declarations/components/validated-form.d.ts +37 -1
- package/declarations/components/validated-form.d.ts.map +1 -1
- package/declarations/utils/build-validation-messages.d.ts.map +1 -1
- package/declarations/validators/messages.d.ts +44 -1
- package/declarations/validators/messages.d.ts.map +1 -1
- package/dist/-private/random-id.js +1 -0
- package/dist/-private/random-id.js.map +1 -1
- package/dist/components/default-theme.js.map +1 -1
- package/dist/components/validated-form/field-base.js +3 -3
- package/dist/components/validated-form/field-base.js.map +1 -1
- package/dist/components/validated-form/field-checkbox-group.js +4 -4
- package/dist/components/validated-form/field-checkbox-group.js.map +1 -1
- package/dist/components/validated-form/field-combo-box.js +2 -2
- package/dist/components/validated-form/field-combo-box.js.map +1 -1
- package/dist/components/validated-form/field-dual-range-slider.js +2 -4
- package/dist/components/validated-form/field-dual-range-slider.js.map +1 -1
- package/dist/components/validated-form/field-markdown-editor.js +2 -6
- package/dist/components/validated-form/field-markdown-editor.js.map +1 -1
- package/dist/components/validated-form/field-number.js +1 -2
- package/dist/components/validated-form/field-number.js.map +1 -1
- package/dist/components/validated-form/field-password.js +1 -2
- package/dist/components/validated-form/field-password.js.map +1 -1
- package/dist/components/validated-form/field-radio-group.js +4 -24
- package/dist/components/validated-form/field-radio-group.js.map +1 -1
- package/dist/components/validated-form/field-range-slider.js +1 -3
- package/dist/components/validated-form/field-range-slider.js.map +1 -1
- package/dist/components/validated-form/field-select.js +1 -2
- package/dist/components/validated-form/field-select.js.map +1 -1
- package/dist/components/validated-form/field-switch.js +2 -4
- package/dist/components/validated-form/field-switch.js.map +1 -1
- package/dist/components/validated-form/field-text-area.js +1 -1
- package/dist/components/validated-form/field-text-area.js.map +1 -1
- package/dist/components/validated-form/field-text.js +1 -2
- package/dist/components/validated-form/field-text.js.map +1 -1
- package/dist/components/validated-form.js +3 -3
- package/dist/components/validated-form.js.map +1 -1
- package/dist/utils/build-validation-messages.js +13 -5
- package/dist/utils/build-validation-messages.js.map +1 -1
- package/dist/utils/get-messages.js.map +1 -1
- package/dist/utils/validation-errors.js.map +1 -1
- package/dist/utils/with-defaults.js.map +1 -1
- package/dist/validators/messages.js.map +1 -1
- package/package.json +57 -34
- /package/{addon-main.js → addon-main.cjs} +0 -0
|
@@ -4,29 +4,65 @@ import type Owner from '@ember/owner';
|
|
|
4
4
|
import type { IValidatedFormTheme } from './default-theme';
|
|
5
5
|
import type FieldBase from './validated-form/field-base';
|
|
6
6
|
import type { EuiFormSignature } from '@ember-eui/core/components/eui-form';
|
|
7
|
+
/**
|
|
8
|
+
* A form whose fields validate their own values with ember-validators
|
|
9
|
+
* (`@validations`) or functions (`@customValidations`). Errors show once a
|
|
10
|
+
* field is touched; submitting calls `@onSubmit` only when all fields are
|
|
11
|
+
* valid.
|
|
12
|
+
*/
|
|
7
13
|
export interface ValidatedFormSignature {
|
|
8
14
|
Element: EuiFormSignature['Element'];
|
|
9
15
|
Args: {
|
|
16
|
+
/** Id of the form; fields join it with `form=`. Defaults to a random id. */
|
|
10
17
|
id?: string;
|
|
18
|
+
/** @private Nested forms register with their parent form. */
|
|
11
19
|
register?: (child: ValidatedFormComponent) => void;
|
|
20
|
+
/** @private Nested forms register with their parent form. */
|
|
12
21
|
unregister?: (child: ValidatedFormComponent) => void;
|
|
22
|
+
/** @private */
|
|
13
23
|
addChild?: (child: FieldBase) => void;
|
|
24
|
+
/** @private */
|
|
14
25
|
removeChild?: (child: FieldBase) => void;
|
|
26
|
+
/** Called on submit while a field is invalid (all fields show their errors). */
|
|
15
27
|
onInvalid?: () => void;
|
|
16
|
-
|
|
28
|
+
/**
|
|
29
|
+
* Called on submit when every field is valid. If it returns a promise
|
|
30
|
+
* that rejects, the fields are marked touched again.
|
|
31
|
+
*/
|
|
32
|
+
onSubmit?: () => void | Promise<void>;
|
|
33
|
+
/** Called when the form is reset. */
|
|
17
34
|
onReset?: (e: Event) => void;
|
|
35
|
+
/**
|
|
36
|
+
* Called when the form's validity or touched state changes, e.g. to
|
|
37
|
+
* disable the submit button while invalid.
|
|
38
|
+
*/
|
|
18
39
|
onValidityChange?: (isValid: boolean, isTouched: boolean, isInvalidAndTouched: boolean) => void;
|
|
40
|
+
/** Replaces the yielded field components (see the theme docs). */
|
|
19
41
|
theme?: Partial<IValidatedFormTheme>;
|
|
42
|
+
/** Disables every field. */
|
|
20
43
|
isDisabled?: boolean;
|
|
44
|
+
/** Makes every field full width. */
|
|
21
45
|
fullWidth?: boolean;
|
|
46
|
+
/** Compressed fields, for dense forms. */
|
|
22
47
|
compressed?: boolean;
|
|
48
|
+
/** `'form'` (the default) or `'div'`. */
|
|
23
49
|
tagName?: EuiFormSignature['Args']['tagName'];
|
|
50
|
+
/** Shows `@error` in a callout above the form, see EuiForm. */
|
|
24
51
|
isInvalid?: EuiFormSignature['Args']['isInvalid'];
|
|
52
|
+
/** See EuiForm's `@invalidCallout`. */
|
|
25
53
|
invalidCallout?: EuiFormSignature['Args']['invalidCallout'];
|
|
54
|
+
/** Form-level errors, see EuiForm's `@error`. */
|
|
26
55
|
error?: EuiFormSignature['Args']['error'];
|
|
56
|
+
/** Title of the errors callout. */
|
|
27
57
|
errorTitle?: EuiFormSignature['Args']['errorTitle'];
|
|
28
58
|
};
|
|
29
59
|
Blocks: {
|
|
60
|
+
/**
|
|
61
|
+
* Yields the form's state (`isValid`, `isInvalid`, `isTouched`,
|
|
62
|
+
* `isInvalidAndTouched`, `formId`) and its field components, already
|
|
63
|
+
* connected to it: `as |form|` → `<form.FieldText @label="Name"
|
|
64
|
+
* @value={{this.name}} @onChange={{…}} @validations={{…}} />`.
|
|
65
|
+
*/
|
|
30
66
|
default: [
|
|
31
67
|
{
|
|
32
68
|
onValidityChange: (isValid: boolean, isTouched: boolean, isInvalidAndTouched: boolean) => void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validated-form.d.ts","sourceRoot":"","sources":["../../src/components/validated-form.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,oBAAoB,CAAC;AAE3C,OAAO,EAAE,CAAC,EAAE,MAAM,cAAc,CAAC;AAQjC,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AAKtC,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAC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M,CAAC,OAAO,OAAO,sBAAuB,SAAQ,SAAS,CAAC,sBAAsB,CAAC;IAC1E,eAAe,EAAE,UAAU,CAAC,OAAO,CAAC,CAAC,SAAS,CAAC,CAAC,CAAoB;IAE7E,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,aAAa,CAAC,EAAE,OAAO,CAAC;IAEf,SAAS,UAAS;IAClB,SAAS,UAAS;gBAEf,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,sBAAsB,CAAC,MAAM,CAAC;IAK9D,WAAW;IAKX,IAAI,OAAO,YAEV;IAED,IAAI,mBAAmB,YAEtB;IAED,QAAQ,CAAC,KAAK,EAAE,SAAS;IAIzB,WAAW,CAAC,KAAK,EAAE,SAAS;IAKtB,YAAY,CAAC,CAAC,EAAE,KAAK;IAkB3B,WAAW,CAAC,CAAC,EAAE,KAAK;IAMpB,QAAQ,CAAC,KAAK,EAAE,SAAS;IAOzB,UAAU,CAAC,KAAK,EAAE,SAAS;IAU3B,cAAc;IAId,UAAU;IAIV,YAAY;IAIZ,qBAAqB;IAarB,cAAc;IAgBd,qBAAqB;IAOrB,UAAU,CAAC,CAAC,EAAE,UAAU;IAWxB,IAAI,KAAK;;;;;;;;;;;;;;MAIR;CAkDF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build-validation-messages.d.ts","sourceRoot":"","sources":["../../src/utils/build-validation-messages.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"build-validation-messages.d.ts","sourceRoot":"","sources":["../../src/utils/build-validation-messages.js"],"names":[],"mappings":"AAUA;;;;GAIG;AACH,kDAHW,MAAM,SAyEhB;AAED,4EAkBC"}
|
|
@@ -1,3 +1,46 @@
|
|
|
1
|
-
declare const _default:
|
|
1
|
+
declare const _default: Readonly<typeof EmberObject> & (new (owner?: import("@ember/-internals/owner").default) => EmberObject) & {
|
|
2
|
+
_regex: RegExp;
|
|
3
|
+
defaultDescription: string;
|
|
4
|
+
getDescriptionFor(attribute: string, context?: {
|
|
5
|
+
description?: string;
|
|
6
|
+
}): string;
|
|
7
|
+
getMessageFor(type: string, context?: {}): string;
|
|
8
|
+
formatMessage(message: string, context?: Record<string, unknown>): string;
|
|
9
|
+
accepted: string;
|
|
10
|
+
after: string;
|
|
11
|
+
before: string;
|
|
12
|
+
blank: string;
|
|
13
|
+
collection: string;
|
|
14
|
+
confirmation: string;
|
|
15
|
+
date: string;
|
|
16
|
+
email: string;
|
|
17
|
+
empty: string;
|
|
18
|
+
equalTo: string;
|
|
19
|
+
even: string;
|
|
20
|
+
exclusion: string;
|
|
21
|
+
greaterThan: string;
|
|
22
|
+
greaterThanOrEqualTo: string;
|
|
23
|
+
inclusion: string;
|
|
24
|
+
invalid: string;
|
|
25
|
+
lessThan: string;
|
|
26
|
+
lessThanOrEqualTo: string;
|
|
27
|
+
notAnInteger: string;
|
|
28
|
+
notANumber: string;
|
|
29
|
+
odd: string;
|
|
30
|
+
onOrAfter: string;
|
|
31
|
+
onOrBefore: string;
|
|
32
|
+
otherThan: string;
|
|
33
|
+
phone: string;
|
|
34
|
+
positive: string;
|
|
35
|
+
multipleOf: string;
|
|
36
|
+
present: string;
|
|
37
|
+
singular: string;
|
|
38
|
+
tooLong: string;
|
|
39
|
+
tooShort: string;
|
|
40
|
+
between: string;
|
|
41
|
+
url: string;
|
|
42
|
+
wrongLength: string;
|
|
43
|
+
};
|
|
2
44
|
export default _default;
|
|
45
|
+
import EmberObject from '@ember/object';
|
|
3
46
|
//# sourceMappingURL=messages.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"messages.d.ts","sourceRoot":"","sources":["../../src/validators/messages.js"],"names":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"messages.d.ts","sourceRoot":"","sources":["../../src/validators/messages.js"],"names":[],"mappings":";;;;mBAIyqB,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;wBAJlpB,eAAe"}
|
|
@@ -4,6 +4,7 @@ import { helper } from '@ember/component/helper';
|
|
|
4
4
|
// https://github.com/emberjs/ember.js/blob/master/packages/@ember/-internals/glimmer/lib/helpers/unique-id.ts
|
|
5
5
|
function randomId() {
|
|
6
6
|
//@ts-expect-error
|
|
7
|
+
// eslint-disable-next-line @typescript-eslint/restrict-plus-operands -- ember's own trick
|
|
7
8
|
return ([3e7] + -1e3 + -4e3 + -2e3 + -1e11).replace(/[0-3]/g, a => (a * 4 ^ Math.random() * 16 >> (a & 2)).toString(16));
|
|
8
9
|
}
|
|
9
10
|
var randomId$1 = helper(randomId);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"random-id.js","sources":["../../src/-private/random-id.ts"],"sourcesContent":["import { helper } from '@ember/component/helper';\n\n// Copy-pasted from the ember-source implementation:\n// https://github.com/emberjs/ember.js/blob/master/packages/@ember/-internals/glimmer/lib/helpers/unique-id.ts\nfunction randomId() {\n //@ts-expect-error\n return ([3e7] + -1e3 + -4e3 + -2e3 + -1e11).replace(/[0-3]/g, (a) =>\n ((a * 4) ^ ((Math.random() * 16) >> (a & 2))).toString(16)\n );\n}\n\nexport default helper(randomId);\n\n\n"],"names":["randomId","replace","a","Math","random","toString","helper"],"mappings":";;AAEA;AACA;AACA,SAASA,QAAQA,GAAG;AAClB;EACA,OAAO,CAAC,CAAC,GAAG,CAAC,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,KAAK,EAAEC,OAAO,CAAC,QAAQ,EAAGC,CAAC,IAC9D,CAAEA,CAAC,GAAG,CAAC,GAAMC,IAAI,CAACC,MAAM,EAAE,GAAG,EAAE,KAAMF,CAAC,GAAG,CAAC,CAAE,EAAEG,QAAQ,CAAC,EAAE,CAC3D,CAAC;AACH;AAEA,iBAAeC,MAAM,CAACN,QAAQ,CAAC
|
|
1
|
+
{"version":3,"file":"random-id.js","sources":["../../src/-private/random-id.ts"],"sourcesContent":["import { helper } from '@ember/component/helper';\n\n// Copy-pasted from the ember-source implementation:\n// https://github.com/emberjs/ember.js/blob/master/packages/@ember/-internals/glimmer/lib/helpers/unique-id.ts\nfunction randomId() {\n //@ts-expect-error\n // eslint-disable-next-line @typescript-eslint/restrict-plus-operands -- ember's own trick\n return ([3e7] + -1e3 + -4e3 + -2e3 + -1e11).replace(/[0-3]/g, (a) =>\n ((a * 4) ^ ((Math.random() * 16) >> (a & 2))).toString(16)\n );\n}\n\nexport default helper(randomId);\n\n\n"],"names":["randomId","replace","a","Math","random","toString","helper"],"mappings":";;AAEA;AACA;AACA,SAASA,QAAQA,GAAG;AAClB;AACA;EACA,OAAO,CAAC,CAAC,GAAG,CAAC,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,KAAK,EAAEC,OAAO,CAAC,QAAQ,EAAGC,CAAC,IAC9D,CAAEA,CAAC,GAAG,CAAC,GAAMC,IAAI,CAACC,MAAM,EAAE,GAAG,EAAE,KAAMF,CAAC,GAAG,CAAC,CAAE,EAAEG,QAAQ,CAAC,EAAE,CAC3D,CAAC;AACH;AAEA,iBAAeC,MAAM,CAACN,QAAQ,CAAC;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"default-theme.js","sources":["../../src/components/default-theme.ts"],"sourcesContent":["import FieldBase from './validated-form/field-base.gts';\nimport FieldCheckboxGroupComponent from './validated-form/field-checkbox-group.gts';\nimport FieldComboBoxComponent from './validated-form/field-combo-box.gts';\nimport FieldDualRangeSliderComponent from './validated-form/field-dual-range-slider.gts';\nimport FieldMarkdownEditorComponent from './validated-form/field-markdown-editor.gts';\nimport FieldNumberComponent from './validated-form/field-number.gts';\nimport FieldPasswordComponent from './validated-form/field-password.gts';\nimport FieldRadioGroupComponent from './validated-form/field-radio-group.gts';\nimport FieldRangeSliderComponent from './validated-form/field-range-slider.gts';\nimport FieldSelectComponent from './validated-form/field-select.gts';\nimport FieldSwitchComponent from './validated-form/field-switch.gts';\nimport FieldTextComponent from './validated-form/field-text.gts';\nimport FieldTextAreaComponent from './validated-form/field-text-area.gts';\n\nimport type { ComponentLike } from '@glint/template';\n\nexport interface IValidatedFormTheme {\n FieldBase: ComponentLike<any>;\n FieldNumber: ComponentLike<any>;\n FieldText: ComponentLike<any>;\n FieldPassword: ComponentLike<any>;\n FieldTextArea: ComponentLike<any>;\n FieldSelect: ComponentLike<any>;\n FieldComboBox: ComponentLike<any>;\n FieldCheckboxGroup: ComponentLike<any>;\n FieldRadioGroup: ComponentLike<any>;\n FieldRangeSlider: ComponentLike<any>;\n FieldDualRangeSlider: ComponentLike<any>;\n FieldSwitch: ComponentLike<any>;\n FieldMarkdownEditor: ComponentLike<any>;\n}\n\nexport const ValidatedFormDefaultTheme: IValidatedFormTheme = {\n FieldBase: FieldBase,\n FieldNumber: FieldNumberComponent,\n FieldText: FieldTextComponent,\n FieldPassword: FieldPasswordComponent,\n FieldTextArea: FieldTextAreaComponent,\n FieldSelect: FieldSelectComponent,\n FieldComboBox: FieldComboBoxComponent,\n FieldCheckboxGroup: FieldCheckboxGroupComponent,\n FieldRadioGroup: FieldRadioGroupComponent,\n FieldRangeSlider: FieldRangeSliderComponent,\n FieldDualRangeSlider: FieldDualRangeSliderComponent,\n FieldSwitch: FieldSwitchComponent,\n FieldMarkdownEditor: FieldMarkdownEditorComponent\n};\n\nexport default ValidatedFormDefaultTheme;"],"names":["ValidatedFormDefaultTheme","FieldBase","FieldNumber","FieldNumberComponent","FieldText","FieldTextComponent","FieldPassword","FieldPasswordComponent","FieldTextArea","FieldTextAreaComponent","FieldSelect","FieldSelectComponent","FieldComboBox","FieldComboBoxComponent","FieldCheckboxGroup","FieldCheckboxGroupComponent","FieldRadioGroup","FieldRadioGroupComponent","FieldRangeSlider","FieldRangeSliderComponent","FieldDualRangeSlider","FieldDualRangeSliderComponent","FieldSwitch","FieldSwitchComponent","FieldMarkdownEditor","FieldMarkdownEditorComponent"],"mappings":";;;;;;;;;;;;;;AAgCO,MAAMA,yBAA8C,GAAG;AAC5DC,EAAAA,SAAS,EAAEA,sBAAS;AACpBC,EAAAA,WAAW,EAAEC,wBAAoB;AACjCC,EAAAA,SAAS,EAAEC,sBAAkB;AAC7BC,EAAAA,aAAa,EAAEC,0BAAsB;AACrCC,EAAAA,aAAa,EAAEC,0BAAsB;AACrCC,EAAAA,WAAW,EAAEC,wBAAoB;AACjCC,EAAAA,aAAa,EAAEC,0BAAsB;AACrCC,EAAAA,kBAAkB,EAAEC,+BAA2B;AAC/CC,EAAAA,eAAe,EAAEC,4BAAwB;AACzCC,EAAAA,gBAAgB,EAAEC,+BAAyB;AAC3CC,EAAAA,oBAAoB,EAAEC,6BAA6B;AACnDC,EAAAA,WAAW,EAAEC,wBAAoB;AACjCC,EAAAA,mBAAmB,EAAEC;AACvB
|
|
1
|
+
{"version":3,"file":"default-theme.js","sources":["../../src/components/default-theme.ts"],"sourcesContent":["import FieldBase from './validated-form/field-base.gts';\nimport FieldCheckboxGroupComponent from './validated-form/field-checkbox-group.gts';\nimport FieldComboBoxComponent from './validated-form/field-combo-box.gts';\nimport FieldDualRangeSliderComponent from './validated-form/field-dual-range-slider.gts';\nimport FieldMarkdownEditorComponent from './validated-form/field-markdown-editor.gts';\nimport FieldNumberComponent from './validated-form/field-number.gts';\nimport FieldPasswordComponent from './validated-form/field-password.gts';\nimport FieldRadioGroupComponent from './validated-form/field-radio-group.gts';\nimport FieldRangeSliderComponent from './validated-form/field-range-slider.gts';\nimport FieldSelectComponent from './validated-form/field-select.gts';\nimport FieldSwitchComponent from './validated-form/field-switch.gts';\nimport FieldTextComponent from './validated-form/field-text.gts';\nimport FieldTextAreaComponent from './validated-form/field-text-area.gts';\n\nimport type { ComponentLike } from '@glint/template';\n\nexport interface IValidatedFormTheme {\n FieldBase: ComponentLike<any>;\n FieldNumber: ComponentLike<any>;\n FieldText: ComponentLike<any>;\n FieldPassword: ComponentLike<any>;\n FieldTextArea: ComponentLike<any>;\n FieldSelect: ComponentLike<any>;\n FieldComboBox: ComponentLike<any>;\n FieldCheckboxGroup: ComponentLike<any>;\n FieldRadioGroup: ComponentLike<any>;\n FieldRangeSlider: ComponentLike<any>;\n FieldDualRangeSlider: ComponentLike<any>;\n FieldSwitch: ComponentLike<any>;\n FieldMarkdownEditor: ComponentLike<any>;\n}\n\nexport const ValidatedFormDefaultTheme: IValidatedFormTheme = {\n FieldBase: FieldBase,\n FieldNumber: FieldNumberComponent,\n FieldText: FieldTextComponent,\n FieldPassword: FieldPasswordComponent,\n FieldTextArea: FieldTextAreaComponent,\n FieldSelect: FieldSelectComponent,\n FieldComboBox: FieldComboBoxComponent,\n FieldCheckboxGroup: FieldCheckboxGroupComponent,\n FieldRadioGroup: FieldRadioGroupComponent,\n FieldRangeSlider: FieldRangeSliderComponent,\n FieldDualRangeSlider: FieldDualRangeSliderComponent,\n FieldSwitch: FieldSwitchComponent,\n FieldMarkdownEditor: FieldMarkdownEditorComponent\n};\n\nexport default ValidatedFormDefaultTheme;"],"names":["ValidatedFormDefaultTheme","FieldBase","FieldNumber","FieldNumberComponent","FieldText","FieldTextComponent","FieldPassword","FieldPasswordComponent","FieldTextArea","FieldTextAreaComponent","FieldSelect","FieldSelectComponent","FieldComboBox","FieldComboBoxComponent","FieldCheckboxGroup","FieldCheckboxGroupComponent","FieldRadioGroup","FieldRadioGroupComponent","FieldRangeSlider","FieldRangeSliderComponent","FieldDualRangeSlider","FieldDualRangeSliderComponent","FieldSwitch","FieldSwitchComponent","FieldMarkdownEditor","FieldMarkdownEditorComponent"],"mappings":";;;;;;;;;;;;;;AAgCO,MAAMA,yBAA8C,GAAG;AAC5DC,EAAAA,SAAS,EAAEA,sBAAS;AACpBC,EAAAA,WAAW,EAAEC,wBAAoB;AACjCC,EAAAA,SAAS,EAAEC,sBAAkB;AAC7BC,EAAAA,aAAa,EAAEC,0BAAsB;AACrCC,EAAAA,aAAa,EAAEC,0BAAsB;AACrCC,EAAAA,WAAW,EAAEC,wBAAoB;AACjCC,EAAAA,aAAa,EAAEC,0BAAsB;AACrCC,EAAAA,kBAAkB,EAAEC,+BAA2B;AAC/CC,EAAAA,eAAe,EAAEC,4BAAwB;AACzCC,EAAAA,gBAAgB,EAAEC,+BAAyB;AAC3CC,EAAAA,oBAAoB,EAAEC,6BAA6B;AACnDC,EAAAA,WAAW,EAAEC,wBAAoB;AACjCC,EAAAA,mBAAmB,EAAEC;AACvB;;"}
|
|
@@ -5,7 +5,7 @@ import { later } from '@ember/runloop';
|
|
|
5
5
|
import { buildValidationMessages, notifyValidityChange } from '../../utils/build-validation-messages.js';
|
|
6
6
|
import { precompileTemplate } from '@ember/template-compilation';
|
|
7
7
|
import { setComponentTemplate } from '@ember/component';
|
|
8
|
-
import { g, i, n } from 'decorator-transforms/runtime';
|
|
8
|
+
import { g, i, n } from 'decorator-transforms/runtime-esm';
|
|
9
9
|
|
|
10
10
|
class ValidatedFormFieldBase extends Component {
|
|
11
11
|
validationProperty = 'args.value';
|
|
@@ -65,7 +65,7 @@ class ValidatedFormFieldBase extends Component {
|
|
|
65
65
|
return this.args.options || [];
|
|
66
66
|
}
|
|
67
67
|
get validationErrorMessages() {
|
|
68
|
-
|
|
68
|
+
const error = [];
|
|
69
69
|
if (this.error.length > 0) {
|
|
70
70
|
error.push(...this.error);
|
|
71
71
|
}
|
|
@@ -138,7 +138,7 @@ class ValidatedFormFieldBase extends Component {
|
|
|
138
138
|
this.formRowElement = null;
|
|
139
139
|
}
|
|
140
140
|
static {
|
|
141
|
-
setComponentTemplate(precompileTemplate("
|
|
141
|
+
setComponentTemplate(precompileTemplate("{{!--@glint-expect-error--}}\n{{yield this}}", {
|
|
142
142
|
strictMode: true
|
|
143
143
|
}), this);
|
|
144
144
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"field-base.js","sources":["../../../src/components/validated-form/field-base.gts"],"sourcesContent":["import Component from '@glimmer/component';\nimport { tracked } from '@glimmer/tracking';\nimport { action } from '@ember/object';\nimport { later } from '@ember/runloop';\nimport type Owner from '@ember/owner';\n\nimport {\n buildValidationMessages,\n notifyValidityChange\n} from '../../utils/build-validation-messages.js';\n\nimport type { ComponentLike } from '@glint/template';\n\nexport interface FieldBaseSignature<T = ComponentLike> {\n Args: {\n id?: string;\n value: any;\n label?: string;\n error?: string[];\n options?: any[];\n validations?: any;\n customValidations?: {\n validation(value: any, options?: Record<string, unknown>): boolean;\n }[];\n rowClasses?: string;\n rowExtra?: Record<string, unknown>;\n onChange: (value: any) => void;\n onValidityChange: (isValid: boolean) => void;\n register: (field: T) => void;\n unregister: (field: T) => void;\n };\n}\n\nexport default class ValidatedFormFieldBase<\n T extends FieldBaseSignature = FieldBaseSignature\n> extends Component<T> {\n validationProperty = 'args.value';\n\n //cache for comparing\n lastIsValid?: boolean;\n lastIsTouched?: boolean;\n\n @tracked _validationErrorMessages: null | string[] = null;\n\n @tracked isTouched = false;\n\n formRowElement: HTMLElement | null = null;\n\n get validations() {\n return this.args.validations || {};\n }\n\n get hasErrorMessages(): boolean {\n return !!this._validationErrorMessages?.length || this.error?.length > 0;\n }\n\n get isValid() {\n return !this.isInvalid;\n }\n\n get isInvalid() {\n return this.hasErrorMessages;\n }\n\n get isInvalidAndTouched() {\n return !!(this.isInvalid && this.isTouched);\n }\n\n get formHasBeenValidated() {\n return this.isTouched;\n }\n\n set formHasBeenValidated(value) {\n this.isTouched = value;\n }\n\n get customValidations(): {\n validation(value: any, options?: Record<string, unknown>): boolean;\n }[] {\n return this.args.customValidations || [];\n }\n\n get rowClasses(): string {\n return this.args.rowClasses || '';\n }\n\n get rowExtra() {\n return this.args.rowExtra || {};\n }\n\n get label(): string {\n return this.args.label || '';\n }\n\n get error(): string[] {\n return this.args.error || [];\n }\n\n get options(): any[] {\n return this.args.options || [];\n }\n\n get validationErrorMessages() {\n let error = [];\n\n if (this.error.length > 0) {\n error.push(...this.error);\n }\n\n if (\n this._validationErrorMessages &&\n this._validationErrorMessages.length > 0\n ) {\n error.push(...this._validationErrorMessages);\n }\n\n if (error.length === 0) {\n return null;\n }\n\n return error;\n }\n\n constructor(owner: Owner, args: T['Args']) {\n super(owner, args);\n this.args.register?.(this as unknown as ComponentLike);\n }\n\n //Should be executed by the child on start\n @action\n setValidationMessages(ele?: HTMLElement) {\n this._validationErrorMessages = buildValidationMessages.call(\n this,\n this.validationProperty\n );\n\n if (ele) {\n this.formRowElement = ele;\n }\n }\n\n //Should be executed by the child on value update\n @action\n didUpdateValue() {\n later(() => {\n if (!this.isDestroyed && !this.isDestroying) {\n this.setValidationMessages();\n this.notifyValidityChange();\n }\n }, 1);\n }\n\n @action\n notifyValidityChange() {\n notifyValidityChange(this, this.args.onValidityChange);\n }\n\n @action\n setIsTouched(val: boolean) {\n this.isTouched = val;\n this.notifyValidityChange();\n }\n\n /**\n * This is just a default handleChange, you should override this method\n * if you need to or use whatever mechanism to bubble the changed\n * value outside and then notifyValidityChanges\n *\n * @override\n * @param {*} e\n */\n @action\n handleChange(e: Event) {\n const value = (e.target as HTMLInputElement).value;\n\n this.args.onChange(value);\n this.notifyValidityChange();\n }\n\n willDestroy(): void {\n super.willDestroy();\n \n this.args.unregister?.(this as unknown as ComponentLike);\n this.formRowElement = null;\n }\n\n <template>\n {{!@glint-expect-error}}\n {{yield this}}\n </template>\n}\n"],"names":["ValidatedFormFieldBase","Component","validationProperty","lastIsValid","lastIsTouched","g","prototype","tracked","i","void 0","formRowElement","validations","args","hasErrorMessages","_validationErrorMessages","length","error","isValid","isInvalid","isInvalidAndTouched","isTouched","formHasBeenValidated","value","customValidations","rowClasses","rowExtra","label","options","validationErrorMessages","push","constructor","owner","register","setValidationMessages","ele","buildValidationMessages","call","n","action","didUpdateValue","later","isDestroyed","isDestroying","notifyValidityChange","onValidityChange","setIsTouched","val","handleChange","e","target","onChange","willDestroy","unregister","setComponentTemplate","precompileTemplate","strictMode"],"mappings":";;;;;;;;;AAiCe,MAAMA,sBAAA,SAEXC,SAAU,CAAA;AAClBC,EAAAA,kBAAA,GAAqB,YAAa;AAElC;EACAC,WAAA;EACAC,aAAA;AAAwB,EAAA;IAAAC,CAAA,CAAA,IAAA,CAAAC,SAAA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EAAA,cAAA,EAAA,CANCgC,MAAA,CAAA,CAAA;AAAA;AAQDa,EAAAA,WAAAA,GAAoB;IAClB,KAAK,CAACA,WAAA,EAAA;AAEN,IAAA,IAAI,CAACvC,IAAI,CAACwC,UAAU,GAAG,IAAmB,CAAA;IAC1C,IAAI,CAAC1C,cAAc,GAAG,IAAA;AACxB;AAEA,EAAA;IAAA2C,oBAAA,CAAAC,kBAAA,CAGA,4DAAA,EAAA;MAAAC,UAAA,EAAA;KAAU,CAAA,EAAV,IAAW,CAAA;AAAD;AACZ;;;;"}
|
|
1
|
+
{"version":3,"file":"field-base.js","sources":["../../../src/components/validated-form/field-base.gts"],"sourcesContent":["import Component from '@glimmer/component';\nimport { tracked } from '@glimmer/tracking';\nimport { action } from '@ember/object';\nimport { later } from '@ember/runloop';\nimport type Owner from '@ember/owner';\n\nimport {\n buildValidationMessages,\n notifyValidityChange\n} from '../../utils/build-validation-messages.js';\n\nimport type { ComponentLike } from '@glint/template';\n\n/**\n * Args every ValidatedForm field takes (on top of EuiFormRow's and its\n * control's). The form's yielded fields pass `register`, `unregister`,\n * `onValidityChange` and `formId` for you.\n */\nexport interface FieldBaseSignature<T = ComponentLike> {\n Args: {\n /** Id of the control; the row's label points to it. Defaults to a random id. */\n id?: string;\n /** The field's value. Update it in `@onChange`. */\n value: any;\n /** The row's label. */\n label?: string;\n /** Errors from outside (e.g. the server), shown with the validation errors. */\n error?: string[];\n /** Options, for fields with options (select, radios, checkboxes, combo box). */\n options?: any[];\n /**\n * ember-validators validations by name, e.g.\n * `(hash presence=(hash presence=true) length=(hash min=3))` or\n * `format=(hash type=\"email\")`. Errors show once the field is touched\n * (blurred, or the form submitted).\n */\n validations?: any;\n /**\n * Each validation returns `true` when valid; otherwise `false` (generic\n * \"is invalid\" message), a message string, or an ember-validators result\n * (`{ type, context }`).\n */\n customValidations?: {\n validation(\n value: any,\n options?: Record<string, unknown>\n ): boolean | string | { type?: string; context?: Record<string, unknown> };\n params?: Record<string, unknown>;\n }[];\n /** Classes for the EuiFormRow. */\n rowClasses?: string;\n /** @deprecated Has no effect. */\n rowExtra?: Record<string, unknown>;\n /** Called with the new value; update `@value` here. */\n onChange: (value: any) => void;\n /** @private Set by ValidatedForm. */\n onValidityChange: (isValid: boolean) => void;\n /** @private Set by ValidatedForm. */\n register: (field: T) => void;\n /** @private Set by ValidatedForm. */\n unregister: (field: T) => void;\n };\n}\n\nexport default class ValidatedFormFieldBase<\n T extends FieldBaseSignature = FieldBaseSignature\n> extends Component<T> {\n validationProperty = 'args.value';\n\n //cache for comparing\n lastIsValid?: boolean;\n lastIsTouched?: boolean;\n\n @tracked _validationErrorMessages: null | string[] = null;\n\n @tracked isTouched = false;\n\n formRowElement: HTMLElement | null = null;\n\n get validations() {\n return this.args.validations || {};\n }\n\n get hasErrorMessages(): boolean {\n return !!this._validationErrorMessages?.length || this.error?.length > 0;\n }\n\n get isValid() {\n return !this.isInvalid;\n }\n\n get isInvalid() {\n return this.hasErrorMessages;\n }\n\n get isInvalidAndTouched() {\n return !!(this.isInvalid && this.isTouched);\n }\n\n get formHasBeenValidated() {\n return this.isTouched;\n }\n\n set formHasBeenValidated(value) {\n this.isTouched = value;\n }\n\n get customValidations(): NonNullable<\n FieldBaseSignature['Args']['customValidations']\n > {\n return this.args.customValidations || [];\n }\n\n get rowClasses(): string {\n return this.args.rowClasses || '';\n }\n\n get rowExtra() {\n return this.args.rowExtra || {};\n }\n\n get label(): string {\n return this.args.label || '';\n }\n\n get error(): string[] {\n return this.args.error || [];\n }\n\n get options(): any[] {\n return this.args.options || [];\n }\n\n get validationErrorMessages() {\n const error = [];\n\n if (this.error.length > 0) {\n error.push(...this.error);\n }\n\n if (\n this._validationErrorMessages &&\n this._validationErrorMessages.length > 0\n ) {\n error.push(...this._validationErrorMessages);\n }\n\n if (error.length === 0) {\n return null;\n }\n\n return error;\n }\n\n constructor(owner: Owner, args: T['Args']) {\n super(owner, args);\n this.args.register?.(this as unknown as ComponentLike);\n }\n\n //Should be executed by the child on start\n @action\n setValidationMessages(ele?: HTMLElement) {\n this._validationErrorMessages = buildValidationMessages.call(\n this,\n this.validationProperty\n );\n\n if (ele) {\n this.formRowElement = ele;\n }\n }\n\n //Should be executed by the child on value update\n @action\n didUpdateValue() {\n later(() => {\n if (!this.isDestroyed && !this.isDestroying) {\n this.setValidationMessages();\n this.notifyValidityChange();\n }\n }, 1);\n }\n\n @action\n notifyValidityChange() {\n notifyValidityChange(this, this.args.onValidityChange);\n }\n\n @action\n setIsTouched(val: boolean) {\n this.isTouched = val;\n this.notifyValidityChange();\n }\n\n /**\n * This is just a default handleChange, you should override this method\n * if you need to or use whatever mechanism to bubble the changed\n * value outside and then notifyValidityChanges\n *\n * @override\n * @param {*} e\n */\n @action\n handleChange(e: Event) {\n const value = (e.target as HTMLInputElement).value;\n\n this.args.onChange(value);\n this.notifyValidityChange();\n }\n\n willDestroy(): void {\n super.willDestroy();\n \n this.args.unregister?.(this as unknown as ComponentLike);\n this.formRowElement = null;\n }\n\n <template>\n {{!@glint-expect-error}}\n {{yield this}}\n </template>\n}\n"],"names":["ValidatedFormFieldBase","Component","validationProperty","lastIsValid","lastIsTouched","g","prototype","tracked","i","formRowElement","validations","args","hasErrorMessages","_validationErrorMessages","length","error","isValid","isInvalid","isInvalidAndTouched","isTouched","formHasBeenValidated","value","customValidations","rowClasses","rowExtra","label","options","validationErrorMessages","push","constructor","owner","register","setValidationMessages","ele","buildValidationMessages","call","n","action","didUpdateValue","later","isDestroyed","isDestroying","notifyValidityChange","onValidityChange","setIsTouched","val","handleChange","e","target","onChange","willDestroy","unregister","setComponentTemplate","precompileTemplate","strictMode"],"mappings":";;;;;;;;;AAgEe,MAAMA,sBAAA,SAEXC,SAAA,CAAU;AAClBC,EAAAA,kBAAA,GAAqB,YAAA;AAErB;EACAC,WAAA;EACAC,aAAA;AAAwB,EAAA;IAAAC,CAAA,CAAA,IAAA,CAAAC,SAAA,EAAA,0BAAA,EAAA,CAEvBC,OAAA,CAAA,EAAA,Y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AA;IACnB,IAAI,CAACqB,oBAAoB,EAAA;AAC3B,EAAA;AAAA,EAAA;IAAAN,CAAA,CAAA,IAAA,CAAA9B,SAAA,EAAA,cAAA,EAAA,CANC+B,MAAA,CAAA,CAAA;AAAA;AAQDa,EAAAA,WAAAA,GAAoB;IAClB,KAAK,CAACA,WAAA,EAAA;AAEN,IAAA,IAAI,CAACvC,IAAI,CAACwC,UAAU,GAAG,IAAmB,CAAA;IAC1C,IAAI,CAAC1C,cAAc,GAAG,IAAA;AACxB,EAAA;AAEA,EAAA;IAAA2C,oBAAA,CAAAC,kBAAA,CAAA,8CAAA,EAGA;MAAAC,UAAA,EAAA;KAAU,CAAA,EAAV,IAAW,CAAA;AAAD;AACZ;;"}
|
|
@@ -10,11 +10,11 @@ import randomId from '../../-private/random-id.js';
|
|
|
10
10
|
import ValidatedFormFieldBase from './field-base.js';
|
|
11
11
|
import { precompileTemplate } from '@ember/template-compilation';
|
|
12
12
|
import { setComponentTemplate } from '@ember/component';
|
|
13
|
-
import { n } from 'decorator-transforms/runtime';
|
|
13
|
+
import { n } from 'decorator-transforms/runtime-esm';
|
|
14
14
|
|
|
15
15
|
class ValidatedFormFieldCheckboxGroup extends ValidatedFormFieldBase {
|
|
16
16
|
get value() {
|
|
17
|
-
|
|
17
|
+
const value = maybeUnwrapProxy(this.args.value);
|
|
18
18
|
return value?.toArray?.() || value;
|
|
19
19
|
}
|
|
20
20
|
get arrayToMap() {
|
|
@@ -22,7 +22,7 @@ class ValidatedFormFieldCheckboxGroup extends ValidatedFormFieldBase {
|
|
|
22
22
|
return this.transformToMap(currArr);
|
|
23
23
|
}
|
|
24
24
|
transformToMap(value = []) {
|
|
25
|
-
|
|
25
|
+
const valuesMap = value.reduce((acc, val) => {
|
|
26
26
|
acc[val] = true;
|
|
27
27
|
return acc;
|
|
28
28
|
}, {});
|
|
@@ -46,7 +46,7 @@ class ValidatedFormFieldCheckboxGroup extends ValidatedFormFieldBase {
|
|
|
46
46
|
n(this.prototype, "handleChange", [action]);
|
|
47
47
|
}
|
|
48
48
|
static {
|
|
49
|
-
setComponentTemplate(precompileTemplate("
|
|
49
|
+
setComponentTemplate(precompileTemplate("{{#let (argOrDefault @id (randomId)) as |theId|}}\n <EuiFormRow class={{this.rowClasses}} @labelType={{@labelType}} @display={{@display}} @hasEmptyLabelSpace={{@hasEmptyLabelSpace}} @fullWidth={{@fullWidth}} @hasChildLabel={{@hasChildLabel}} @label={{this.label}} @labelAppend={{@labelAppend}} @id={{theId}} @isInvalid={{this.isInvalidAndTouched}} @error={{this.validationErrorMessages}} @helpText={{@helpText}} @errorClasses={{@errorClasses}} @isFakeLabelBlock={{not (has-block \"label\")}} @isFakeHelpTextBlock={{not (has-block \"helpText\")}} {{didInsert this.setValidationMessages}} {{didUpdate this.didUpdateValue @validations}} {{didUpdate this.didUpdateValue @value}}>\n <:label>\n {{yield to=\"label\"}}\n </:label>\n\n <:field>\n <EuiCheckboxGroup class={{@fieldClasses}} @formId={{@formId}} @valueKey={{@valueKey}} @labelKey={{@labelKey}} aria-label={{@ariaLabel}} @disabled={{@disabled}} @compressed={{@compressed}} @isInvalid={{this.isInvalidAndTouched}} @options={{this.options}} @idToSelectedMap={{this.arrayToMap}} @legend={{@legend}} @onChange={{this.handleChange}} autofocus={{@autofocus}} ...attributes />\n </:field>\n <:helpText>\n {{yield to=\"helpText\"}}\n </:helpText>\n </EuiFormRow>\n{{/let}}", {
|
|
50
50
|
strictMode: true,
|
|
51
51
|
scope: () => ({
|
|
52
52
|
argOrDefault,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"field-checkbox-group.js","sources":["../../../src/components/validated-form/field-checkbox-group.gts"],"sourcesContent":["import { action } from '@ember/object';\nimport didInsert from '@ember/render-modifiers/modifiers/did-insert';\nimport didUpdate from '@ember/render-modifiers/modifiers/did-update';\nimport EuiCheckboxGroup from '@ember-eui/core/components/eui-checkbox-group';\nimport EuiFormRow from '@ember-eui/core/components/eui-form-row';\nimport { argOrDefault } from '@ember-eui/core/helpers';\nimport { maybeUnwrapProxy } from '@ember-eui/core/utils/maybe-unwrap-proxy';\n\nimport { not } from 'ember-truth-helpers';\n\nimport randomId from '../../-private/random-id.ts';\nimport ValidatedFormFieldBase from './field-base.gts';\n\nimport type { FieldBaseSignature } from './field-base.gts';\nimport type { EuiCheckboxGroupSignature } from '@ember-eui/core/components/eui-checkbox-group';\nimport type { EuiFormRowSignature } from '@ember-eui/core/components/eui-form-row';\n\nexport interface FieldCheckboxGroupSignature {\n Element: EuiCheckboxGroupSignature['Element'];\n Args: FieldBaseSignature['Args'] &\n EuiFormRowSignature['Args'] &\n EuiCheckboxGroupSignature['Args'] & {\n rowClasses?: string;\n fieldClasses?: string;\n formId?: string;\n ariaLabel?: string;\n autofocus?: boolean;\n onChange?: (
|
|
1
|
+
{"version":3,"file":"field-checkbox-group.js","sources":["../../../src/components/validated-form/field-checkbox-group.gts"],"sourcesContent":["import { action } from '@ember/object';\nimport didInsert from '@ember/render-modifiers/modifiers/did-insert';\nimport didUpdate from '@ember/render-modifiers/modifiers/did-update';\nimport EuiCheckboxGroup from '@ember-eui/core/components/eui-checkbox-group';\nimport EuiFormRow from '@ember-eui/core/components/eui-form-row';\nimport { argOrDefault } from '@ember-eui/core/helpers';\nimport { maybeUnwrapProxy } from '@ember-eui/core/utils/maybe-unwrap-proxy';\n\nimport { not } from 'ember-truth-helpers';\n\nimport randomId from '../../-private/random-id.ts';\nimport ValidatedFormFieldBase from './field-base.gts';\n\nimport type { FieldBaseSignature } from './field-base.gts';\nimport type { EuiCheckboxGroupSignature } from '@ember-eui/core/components/eui-checkbox-group';\nimport type { EuiFormRowSignature } from '@ember-eui/core/components/eui-form-row';\n\n/**\n * A validated checkbox group in an EuiFormRow. Takes FieldBase's, EuiFormRow's and\n * the control's args.\n */\nexport interface FieldCheckboxGroupSignature {\n Element: EuiCheckboxGroupSignature['Element'];\n Args: FieldBaseSignature['Args'] &\n EuiFormRowSignature['Args'] &\n EuiCheckboxGroupSignature['Args'] & {\n /** Classes for the EuiFormRow. */\n rowClasses?: string;\n /** Classes for the control. */\n fieldClasses?: string;\n /** @private Set by ValidatedForm. */\n formId?: string;\n /** Accessible label of the control. */\n ariaLabel?: string;\n /** Focuses the control on render. */\n autofocus?: boolean;\n /** Called with the ids of the checked options. */\n onChange?: (value: string[]) => void;\n /** Placeholder text. */\n placeholder?: string;\n };\n Blocks: {\n label: EuiFormRowSignature['Blocks']['label'];\n helpText: EuiFormRowSignature['Blocks']['helpText'];\n };\n}\n\nexport default class ValidatedFormFieldCheckboxGroup extends ValidatedFormFieldBase<FieldCheckboxGroupSignature> {\n get value(): string[] {\n const value = maybeUnwrapProxy(this.args.value);\n\n return value?.toArray?.() || value;\n }\n\n get arrayToMap() {\n const currArr = this.value || [];\n\n return this.transformToMap(currArr);\n }\n\n transformToMap(value: string[] = []) {\n const valuesMap = value.reduce(\n (acc, val) => {\n acc[val] = true;\n\n return acc;\n },\n {} as { [key: string]: boolean }\n );\n\n return valuesMap;\n }\n\n @action\n //@ts-expect-error\n handleChange(optionId: string) {\n const value = this.value || [];\n\n const found = value.find((v) => v === optionId);\n let newArr = [];\n\n if (found) {\n newArr = value.filter((v) => v !== optionId);\n } else {\n newArr = [...value, optionId];\n }\n\n this.args.onChange?.(newArr);\n\n this.notifyValidityChange();\n this.isTouched = true;\n }\n\n <template>\n {{#let (argOrDefault @id (randomId)) as |theId|}}\n <EuiFormRow\n class={{this.rowClasses}}\n @labelType={{@labelType}}\n @display={{@display}}\n @hasEmptyLabelSpace={{@hasEmptyLabelSpace}}\n @fullWidth={{@fullWidth}}\n @hasChildLabel={{@hasChildLabel}}\n @label={{this.label}}\n @labelAppend={{@labelAppend}}\n @id={{theId}}\n @isInvalid={{this.isInvalidAndTouched}}\n @error={{this.validationErrorMessages}}\n @helpText={{@helpText}}\n @errorClasses={{@errorClasses}}\n @isFakeLabelBlock={{not (has-block \"label\")}}\n @isFakeHelpTextBlock={{not (has-block \"helpText\")}}\n {{didInsert this.setValidationMessages}}\n {{didUpdate this.didUpdateValue @validations}}\n {{didUpdate this.didUpdateValue @value}}\n >\n <:label>\n {{yield to=\"label\"}}\n </:label>\n\n <:field>\n <EuiCheckboxGroup\n class={{@fieldClasses}}\n @formId={{@formId}}\n @valueKey={{@valueKey}}\n @labelKey={{@labelKey}}\n aria-label={{@ariaLabel}}\n @disabled={{@disabled}}\n @compressed={{@compressed}}\n @isInvalid={{this.isInvalidAndTouched}}\n @options={{this.options}}\n @idToSelectedMap={{this.arrayToMap}}\n @legend={{@legend}}\n @onChange={{this.handleChange}}\n autofocus={{@autofocus}}\n ...attributes\n />\n </:field>\n <:helpText>\n {{yield to=\"helpText\"}}\n </:helpText>\n </EuiFormRow>\n {{/let}}\n </template>\n}\n"],"names":["ValidatedFormFieldCheckboxGroup","ValidatedFormFieldBase","value","maybeUnwrapProxy","args","toArray","arrayToMap","currArr","transformToMap","valuesMap","reduce","acc","val","handleChange","optionId","found","find","v","newArr","filter","onChange","notifyValidityChange","isTouched","n","prototype","action","setComponentTemplate","precompileTemplate","strictMode","scope","argOrDefault","randomId","EuiFormRow","not","didInsert","didUpdate","EuiCheckboxGroup"],"mappings":";;;;;;;;;;;;;;AA+Ce,MAAMA,wCAAwCC,sBAAA,CAAuB;EAClF,IAAIC,KAAAA,GAAkB;IACpB,MAAMA,QAAQC,gBAAA,CAAiB,IAAI,CAACC,IAAI,CAACF,KAAK,CAAA;AAE9C,IAAA,OAAOA,OAAOG,OAAA,IAAA,IAAeH,KAAA;AAC/B,EAAA;EAEA,IAAII,UAAAA,GAAa;AACf,IAAA,MAAMC,OAAA,GAAU,IAAI,CAACL,KAAK,IAAI,EAAE;AAEhC,IAAA,OAAO,IAAI,CAACM,cAAc,CAACD,OAAA,CAAA;AAC7B,EAAA;AAEAC,EAAAA,cAAAA,CAAeN,KAAa,GAAK,EAAE,EAAE;IACnC,MAAMO,SAAA,GAAYP,KAAA,CAAMQ,MAAM,CAC5B,CAACC,GAAA,EAAKC,GAAA,KAAA;AACJD,MAAAA,GAAG,CAACC,IAAI,GAAG,IAAA;AAEX,MAAA,OAAOD,GAAA;IACT,CAAA,EACA;AAGF,IAAA,OAAOF,SAAA;AACT,EAAA;AAGA;EACAI,YAAAA,CAAaC,QAAgB,EAAE;AAC7B,IAAA,MAAMZ,KAAA,GAAQ,IAAI,CAACA,KAAK,IAAI,EAAE;IAE9B,MAAMa,QAAQb,KAAA,CAAMc,IAAI,CAAEC,KAAMA,CAAA,KAAMH,QAAA,CAAA;IACtC,IAAII,SAAS,EAAE;AAEf,IAAA,IAAIH,KAAA,EAAO;MACTG,MAAA,GAAShB,KAAA,CAAMiB,MAAM,CAAEF,KAAMA,CAAA,KAAMH,QAAA,CAAA;AACrC,IAAA,CAAA,MAAO;AACLI,MAAAA,MAAA,GAAS,CAAI,GAAAhB,KAAA,EAAOY,QAAA,CAAS;AAC/B,IAAA;AAEA,IAAA,IAAI,CAACV,IAAI,CAACgB,QAAQ,GAAGF,MAAA,CAAA;IAErB,IAAI,CAACG,oBAAoB,EAAA;IACzB,IAAI,CAACC,SAAS,GAAG,IAAA;AACnB,EAAA;AAAA,EAAA;IAAAC,CAAA,CAAA,IAAA,CAAAC,SAAA,EAAA,cAAA,EAAA,CAlBCC,MAAA,CAAA,CAAA;AAAA;AAoBD,EAAA;IAAAC,oBAAA,CAAAC,kBAAA,CAAA,uuCAAA,EAiDA;MAAAC,UAAA,EAAA,IAAA;AAAAC,MAAAA,KAAA,EAAAA,OAAA;QAAAC,YAAA;QAAAC,QAAA;QAAAC,UAAA;QAAAC,GAAA;QAAAC,SAAA;QAAAC,SAAA;AAAAC,QAAAA;AAAA,OAAA;KAAU,CAAA,EAAV,IAAW,CAAA;AAAD;AACZ;;"}
|
|
@@ -12,7 +12,7 @@ import randomId from '../../-private/random-id.js';
|
|
|
12
12
|
import ValidatedFormFieldBase from './field-base.js';
|
|
13
13
|
import { precompileTemplate } from '@ember/template-compilation';
|
|
14
14
|
import { setComponentTemplate } from '@ember/component';
|
|
15
|
-
import { n } from 'decorator-transforms/runtime';
|
|
15
|
+
import { n } from 'decorator-transforms/runtime-esm';
|
|
16
16
|
|
|
17
17
|
class ValidatedFormFieldComboBox extends ValidatedFormFieldBase {
|
|
18
18
|
validationProperty = 'args.selectedOptions';
|
|
@@ -25,7 +25,7 @@ class ValidatedFormFieldComboBox extends ValidatedFormFieldBase {
|
|
|
25
25
|
n(this.prototype, "handleChange", [action]);
|
|
26
26
|
}
|
|
27
27
|
static {
|
|
28
|
-
setComponentTemplate(precompileTemplate("
|
|
28
|
+
setComponentTemplate(precompileTemplate("{{#let (argOrDefault @id (randomId)) as |theId|}}\n <EuiFormRow class={{this.rowClasses}} @labelType={{@labelType}} @display={{@display}} @hasEmptyLabelSpace={{@hasEmptyLabelSpace}} @fullWidth={{@fullWidth}} @hasChildLabel={{@hasChildLabel}} @label={{this.label}} @labelAppend={{@labelAppend}} @id={{theId}} @isInvalid={{this.isInvalidAndTouched}} @error={{this.validationErrorMessages}} @helpText={{@helpText}} @errorClasses={{@errorClasses}} @isFakeLabelBlock={{not (has-block \"label\")}} @isFakeHelpTextBlock={{not (has-block \"helpText\")}} {{didInsert this.setValidationMessages}} {{didUpdate this.didUpdateValue @validations}} {{didUpdate this.didUpdateValue @selectedOptions}}>\n <:label>\n {{yield to=\"label\"}}\n </:label>\n <:field>\n <EuiComboBox class={{@fieldClasses}} @onChange={{this.handleChange}} @dropdownClass={{@dropdownClass}} @placeholder={{@placeholder}} @options={{this.options}} @singleSelection={{@singleSelection}} @selectedOptions={{@selectedOptions}} @searchEnabled={{argOrDefault @searchEnabled true}} @placeholderComponent={{@placeholderComponent}} @searchMessageComponent={{@searchMessageComponent}} @loadingMessage={{@loadingMessage}} @beforeOptionsComponent={{@beforeOptionsComponent}} @afterOptionsComponent={{@afterOptionsComponent}} @searchField={{@searchField}} @searchMessage={{@searchMessage}} @search={{@search}} aria-label={{@ariaLabel}} form={{@formId}} @isInvalid={{this.isInvalidAndTouched}} @isClearable={{@isClearable}} @fullWidth={{@fullWidth}} @isLoading={{@isLoading}} @readOnly={{@readOnly}} @compressed={{@compressed}} @onCreateOption={{@onCreateOption}} @matchTriggerWidth={{@matchTriggerWidth}} @customOptionText={{@customOptionText}} @onBlur={{queue (fn this.setIsTouched true) (optional @onBlur)}} @onFocus={{@onFocus}} @onClose={{@onClose}} @onOpen={{@onOpen}} @isDisabled={{@isDisabled}} @renderInPlace={{@renderInPlace}} @extra={{@extra}} ...attributes as |opt index select|>\n {{yield opt index select}}\n </EuiComboBox>\n </:field>\n <:helpText as |helpText|>\n {{yield helpText to=\"helpText\"}}\n </:helpText>\n </EuiFormRow>\n{{/let}}", {
|
|
29
29
|
strictMode: true,
|
|
30
30
|
scope: () => ({
|
|
31
31
|
argOrDefault,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"field-combo-box.js","sources":["../../../src/components/validated-form/field-combo-box.gts"],"sourcesContent":["import { fn } from '@ember/helper';\nimport { action } from '@ember/object';\nimport didInsert from '@ember/render-modifiers/modifiers/did-insert';\nimport didUpdate from '@ember/render-modifiers/modifiers/did-update';\nimport EuiComboBox from '@ember-eui/core/components/eui-combo-box';\nimport EuiFormRow from '@ember-eui/core/components/eui-form-row';\nimport { argOrDefault } from '@ember-eui/core/helpers';\n\nimport optional from '@nullvoxpopuli/ember-composable-helpers/helpers/optional';\nimport queue from '@nullvoxpopuli/ember-composable-helpers/helpers/queue';\nimport { not } from 'ember-truth-helpers';\n\nimport randomId from '../../-private/random-id.ts';\nimport ValidatedFormFieldBase from './field-base.gts';\n\nimport type { FieldBaseSignature } from './field-base.gts';\nimport type { EuiComboBoxSignature } from '@ember-eui/core/components/eui-combo-box';\nimport type { EuiFormRowSignature } from '@ember-eui/core/components/eui-form-row';\n\nexport interface FieldComboBoxSignature {\n Element: EuiComboBoxSignature['Element'];\n Args: FieldBaseSignature['Args'] &\n EuiFormRowSignature['Args'] &\n EuiComboBoxSignature['Args'] & {\n rowClasses?: string;\n fieldClasses?: string;\n formId?: string;\n ariaLabel?: string;\n autofocus?: boolean;\n onChange?: (
|
|
1
|
+
{"version":3,"file":"field-combo-box.js","sources":["../../../src/components/validated-form/field-combo-box.gts"],"sourcesContent":["import { fn } from '@ember/helper';\nimport { action } from '@ember/object';\nimport didInsert from '@ember/render-modifiers/modifiers/did-insert';\nimport didUpdate from '@ember/render-modifiers/modifiers/did-update';\nimport EuiComboBox from '@ember-eui/core/components/eui-combo-box';\nimport EuiFormRow from '@ember-eui/core/components/eui-form-row';\nimport { argOrDefault } from '@ember-eui/core/helpers';\n\nimport optional from '@nullvoxpopuli/ember-composable-helpers/helpers/optional';\nimport queue from '@nullvoxpopuli/ember-composable-helpers/helpers/queue';\nimport { not } from 'ember-truth-helpers';\n\nimport randomId from '../../-private/random-id.ts';\nimport ValidatedFormFieldBase from './field-base.gts';\n\nimport type { FieldBaseSignature } from './field-base.gts';\nimport type { EuiComboBoxSignature } from '@ember-eui/core/components/eui-combo-box';\nimport type { EuiFormRowSignature } from '@ember-eui/core/components/eui-form-row';\n\n/**\n * A validated combo box in an EuiFormRow. Takes FieldBase's, EuiFormRow's and\n * the control's args.\n */\nexport interface FieldComboBoxSignature {\n Element: EuiComboBoxSignature['Element'];\n Args: FieldBaseSignature['Args'] &\n EuiFormRowSignature['Args'] &\n EuiComboBoxSignature['Args'] & {\n /** Classes for the EuiFormRow. */\n rowClasses?: string;\n /** Classes for the control. */\n fieldClasses?: string;\n /** @private Set by ValidatedForm. */\n formId?: string;\n /** Accessible label of the control. */\n ariaLabel?: string;\n /** Focuses the control on render. */\n autofocus?: boolean;\n /** Called with the selected options. */\n onChange?: (options: any[]) => void;\n /** Placeholder text. */\n placeholder?: string;\n /** The options, see the control. */\n options?: EuiComboBoxSignature['Args']['options'];\n /** The selected options. */\n selectedOptions?: EuiComboBoxSignature['Args']['selectedOptions'];\n };\n Blocks: {\n label: EuiFormRowSignature['Blocks']['label'];\n helpText: EuiFormRowSignature['Blocks']['helpText'];\n default: EuiComboBoxSignature['Blocks']['default'];\n };\n}\n\nexport default class ValidatedFormFieldComboBox extends ValidatedFormFieldBase<FieldComboBoxSignature> {\n validationProperty = 'args.selectedOptions';\n\n @action\n //@ts-expect-error\n handleChange(options: any[]) {\n this.args.onChange(options);\n this.notifyValidityChange();\n }\n\n <template>\n {{#let (argOrDefault @id (randomId)) as |theId|}}\n <EuiFormRow\n class={{this.rowClasses}}\n @labelType={{@labelType}}\n @display={{@display}}\n @hasEmptyLabelSpace={{@hasEmptyLabelSpace}}\n @fullWidth={{@fullWidth}}\n @hasChildLabel={{@hasChildLabel}}\n @label={{this.label}}\n @labelAppend={{@labelAppend}}\n @id={{theId}}\n @isInvalid={{this.isInvalidAndTouched}}\n @error={{this.validationErrorMessages}}\n @helpText={{@helpText}}\n @errorClasses={{@errorClasses}}\n @isFakeLabelBlock={{not (has-block \"label\")}}\n @isFakeHelpTextBlock={{not (has-block \"helpText\")}}\n {{didInsert this.setValidationMessages}}\n {{didUpdate this.didUpdateValue @validations}}\n {{didUpdate this.didUpdateValue @selectedOptions}}\n >\n <:label>\n {{yield to=\"label\"}}\n </:label>\n <:field>\n <EuiComboBox\n class={{@fieldClasses}}\n @onChange={{this.handleChange}}\n @dropdownClass={{@dropdownClass}}\n @placeholder={{@placeholder}}\n @options={{this.options}}\n @singleSelection={{@singleSelection}}\n @selectedOptions={{@selectedOptions}}\n @searchEnabled={{argOrDefault @searchEnabled true}}\n @placeholderComponent={{@placeholderComponent}}\n @searchMessageComponent={{@searchMessageComponent}}\n @loadingMessage={{@loadingMessage}}\n @beforeOptionsComponent={{@beforeOptionsComponent}}\n @afterOptionsComponent={{@afterOptionsComponent}}\n @searchField={{@searchField}}\n @searchMessage={{@searchMessage}}\n @search={{@search}}\n aria-label={{@ariaLabel}}\n form={{@formId}}\n @isInvalid={{this.isInvalidAndTouched}}\n @isClearable={{@isClearable}}\n @fullWidth={{@fullWidth}}\n @isLoading={{@isLoading}}\n @readOnly={{@readOnly}}\n @compressed={{@compressed}}\n @onCreateOption={{@onCreateOption}}\n @matchTriggerWidth={{@matchTriggerWidth}}\n @customOptionText={{@customOptionText}}\n @onBlur={{queue (fn this.setIsTouched true) (optional @onBlur)}}\n @onFocus={{@onFocus}}\n @onClose={{@onClose}}\n @onOpen={{@onOpen}}\n @isDisabled={{@isDisabled}}\n @renderInPlace={{@renderInPlace}}\n @extra={{@extra}}\n ...attributes\n as |opt index select|\n >\n {{yield opt index select}}\n </EuiComboBox>\n </:field>\n <:helpText as |helpText|>\n {{yield helpText to=\"helpText\"}}\n </:helpText>\n </EuiFormRow>\n {{/let}}\n </template>\n}\n"],"names":["ValidatedFormFieldComboBox","ValidatedFormFieldBase","validationProperty","handleChange","options","args","onChange","notifyValidityChange","n","prototype","action","setComponentTemplate","precompileTemplate","strictMode","scope","argOrDefault","randomId","EuiFormRow","not","didInsert","didUpdate","EuiComboBox","queue","fn","optional"],"mappings":";;;;;;;;;;;;;;;;AAsDe,MAAMA,mCAAmCC,sBAAA,CAAuB;AAC7EC,EAAAA,kBAAA,GAAqB,sBAAA;AAGrB;EACAC,YAAAA,CAAaC,OAAc,EAAE;AAC3B,IAAA,IAAI,CAACC,IAAI,CAACC,QAAQ,CAACF,OAAA,CAAA;IACnB,IAAI,CAACG,oBAAoB,EAAA;AAC3B,EAAA;AAAA,EAAA;IAAAC,CAAA,CAAA,IAAA,CAAAC,SAAA,EAAA,cAAA,EAAA,CALCC,MAAA,CAAA,CAAA;AAAA;AAOD,EAAA;IAAAC,oBAAA,CAAAC,kBAAA,CAAA,qmEAAA,EAwEA;MAAAC,UAAA,EAAA,IAAA;AAAAC,MAAAA,KAAA,EAAAA,OAAA;QAAAC,YAAA;QAAAC,QAAA;QAAAC,UAAA;QAAAC,GAAA;QAAAC,SAAA;QAAAC,SAAA;QAAAC,WAAA;QAAAC,KAAA;QAAAC,EAAA;AAAAC,QAAAA;AAAA,OAAA;KAAU,CAAA,EAAV,IAAW,CAAA;AAAD;AACZ;;"}
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import '@ember/helper';
|
|
2
|
-
import '@ember/modifier';
|
|
3
1
|
import { action } from '@ember/object';
|
|
4
2
|
import didInsert from '@ember/render-modifiers/modifiers/did-insert';
|
|
5
3
|
import didUpdate from '@ember/render-modifiers/modifiers/did-update';
|
|
@@ -11,7 +9,7 @@ import randomId from '../../-private/random-id.js';
|
|
|
11
9
|
import ValidatedFormFieldBase from './field-base.js';
|
|
12
10
|
import { precompileTemplate } from '@ember/template-compilation';
|
|
13
11
|
import { setComponentTemplate } from '@ember/component';
|
|
14
|
-
import { n } from 'decorator-transforms/runtime';
|
|
12
|
+
import { n } from 'decorator-transforms/runtime-esm';
|
|
15
13
|
|
|
16
14
|
class ValidatedFormFieldRangeSlider extends ValidatedFormFieldBase {
|
|
17
15
|
//@ts-expect-error
|
|
@@ -25,7 +23,7 @@ class ValidatedFormFieldRangeSlider extends ValidatedFormFieldBase {
|
|
|
25
23
|
n(this.prototype, "handleChange", [action]);
|
|
26
24
|
}
|
|
27
25
|
static {
|
|
28
|
-
setComponentTemplate(precompileTemplate("
|
|
26
|
+
setComponentTemplate(precompileTemplate("{{#let (argOrDefault @id (randomId)) as |theId|}}\n <EuiFormRow class={{this.rowClasses}} @labelType={{@labelType}} @display={{@display}} @hasEmptyLabelSpace={{@hasEmptyLabelSpace}} @fullWidth={{@fullWidth}} @hasChildLabel={{@hasChildLabel}} @label={{this.label}} @labelAppend={{@labelAppend}} @id={{theId}} @isInvalid={{this.isInvalidAndTouched}} @error={{this.validationErrorMessages}} @helpText={{@helpText}} @errorClasses={{@errorClasses}} @isFakeLabelBlock={{not (has-block \"label\")}} @isFakeHelpTextBlock={{not (has-block \"helpText\")}} {{didInsert this.setValidationMessages}} {{didUpdate this.didUpdateValue @validations}} {{didUpdate this.didUpdateValue @value}}>\n <:label>\n {{yield to=\"label\"}}\n </:label>\n\n <:field>\n <EuiDualRange class={{@fieldClasses}} form={{@formId}} @value={{@value}} @fullWidth={{@fullWidth}} @isInvalid={{this.isInvalidAndTouched}} @levels={{@levels}} @showLabels={{@showLabels}} @showInput={{@showInput}} @tickInterval={{@tickInterval}} @ticks={{@ticks}} aria-label={{@ariaLabel}} @disabled={{@disabled}} @compressed={{@compressed}} @showRange={{@showRange}} @showTicks={{@showTicks}} @readOnly={{@readOnly}} @id={{theId}} @step={{@step}} @onChange={{this.handleChange}} @max={{@max}} @min={{@min}} @isPrependProvided={{has-block \"prepend\"}} @isAppendProvided={{has-block \"append\"}} @isFakeMinBlock={{not (has-block \"min\")}} @isFakeMaxBlock={{not (has-block \"max\")}} autofocus={{@autofocus}} ...attributes>\n <:prepend as |classes|>\n {{yield classes to=\"prepend\"}}\n </:prepend>\n <:min>\n {{yield to=\"min\"}}\n </:min>\n <:max>\n {{yield to=\"max\"}}\n </:max>\n <:append as |classes|>\n {{yield classes to=\"append\"}}\n </:append>\n </EuiDualRange>\n </:field>\n\n <:helpText as |helpText|>\n {{yield helpText to=\"helpText\"}}\n </:helpText>\n </EuiFormRow>\n{{/let}}", {
|
|
29
27
|
strictMode: true,
|
|
30
28
|
scope: () => ({
|
|
31
29
|
argOrDefault,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"field-dual-range-slider.js","sources":["../../../src/components/validated-form/field-dual-range-slider.gts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"field-dual-range-slider.js","sources":["../../../src/components/validated-form/field-dual-range-slider.gts"],"sourcesContent":["import { action } from '@ember/object';\nimport didInsert from '@ember/render-modifiers/modifiers/did-insert';\nimport didUpdate from '@ember/render-modifiers/modifiers/did-update';\nimport EuiDualRange from '@ember-eui/core/components/eui-dual-range';\nimport EuiFormRow from '@ember-eui/core/components/eui-form-row';\nimport { argOrDefault } from '@ember-eui/core/helpers';\n\nimport { not } from 'ember-truth-helpers';\n\nimport randomId from '../../-private/random-id.ts';\nimport ValidatedFormFieldBase from './field-base.gts';\n\nimport type { FieldBaseSignature } from './field-base.gts';\nimport type {\n EuiDualRangeSignature,\n ValueMember\n} from '@ember-eui/core/components/eui-dual-range';\nimport type { EuiFormRowSignature } from '@ember-eui/core/components/eui-form-row';\n\n/**\n * A validated dual range slider in an EuiFormRow. Takes FieldBase's, EuiFormRow's and\n * the control's args.\n */\nexport interface FieldDualRangeSliderSignature {\n Element: EuiDualRangeSignature['Element'];\n Args: FieldBaseSignature['Args'] &\n EuiFormRowSignature['Args'] &\n EuiDualRangeSignature['Args'] & {\n /** Classes for the EuiFormRow. */\n rowClasses?: string;\n /** Classes for the control. */\n fieldClasses?: string;\n /** @private Set by ValidatedForm. */\n formId?: string;\n /** Accessible label of the control. */\n ariaLabel?: string;\n /** Focuses the control on render. */\n autofocus?: boolean;\n /** Disables the control. */\n disabled?: boolean;\n /** Compressed control. */\n compressed?: boolean;\n /** @deprecated Has no effect. */\n hasFocus?: boolean;\n /** Shows a spinner. */\n isLoading?: boolean;\n /** Read-only control. */\n readOnly?: boolean;\n /** Icon of the control. */\n icon?: string;\n\n /** Called with `[lower, upper]`. */\n onChange?: (value: [ValueMember, ValueMember]) => void;\n };\n Blocks: {\n label: [];\n helpText: [...EuiFormRowSignature['Blocks']['helpText']];\n prepend: [...EuiDualRangeSignature['Blocks']['prepend']];\n min: [...EuiDualRangeSignature['Blocks']['min']];\n append: [...EuiDualRangeSignature['Blocks']['append']];\n max: [...EuiDualRangeSignature['Blocks']['max']];\n };\n}\n\nexport default class ValidatedFormFieldRangeSlider extends ValidatedFormFieldBase<FieldDualRangeSliderSignature> {\n @action\n //@ts-expect-error\n handleChange(\n e: [ValueMember, ValueMember],\n _isValid: boolean,\n _event: Event\n ) {\n // The received event for the dual range is an array with [min, max] as strings\n const value = [Number(e[0]), Number(e[1])];\n\n this.args.onChange(value);\n this.notifyValidityChange();\n }\n\n <template>\n {{#let (argOrDefault @id (randomId)) as |theId|}}\n <EuiFormRow\n class={{this.rowClasses}}\n @labelType={{@labelType}}\n @display={{@display}}\n @hasEmptyLabelSpace={{@hasEmptyLabelSpace}}\n @fullWidth={{@fullWidth}}\n @hasChildLabel={{@hasChildLabel}}\n @label={{this.label}}\n @labelAppend={{@labelAppend}}\n @id={{theId}}\n @isInvalid={{this.isInvalidAndTouched}}\n @error={{this.validationErrorMessages}}\n @helpText={{@helpText}}\n @errorClasses={{@errorClasses}}\n @isFakeLabelBlock={{not (has-block \"label\")}}\n @isFakeHelpTextBlock={{not (has-block \"helpText\")}}\n {{didInsert this.setValidationMessages}}\n {{didUpdate this.didUpdateValue @validations}}\n {{didUpdate this.didUpdateValue @value}}\n >\n <:label>\n {{yield to=\"label\"}}\n </:label>\n\n <:field>\n <EuiDualRange\n class={{@fieldClasses}}\n form={{@formId}}\n @value={{@value}}\n @fullWidth={{@fullWidth}}\n @isInvalid={{this.isInvalidAndTouched}}\n @levels={{@levels}}\n @showLabels={{@showLabels}}\n @showInput={{@showInput}}\n @tickInterval={{@tickInterval}}\n @ticks={{@ticks}}\n aria-label={{@ariaLabel}}\n @disabled={{@disabled}}\n @compressed={{@compressed}}\n @showRange={{@showRange}}\n @showTicks={{@showTicks}}\n @readOnly={{@readOnly}}\n @id={{theId}}\n @step={{@step}}\n @onChange={{this.handleChange}}\n @max={{@max}}\n @min={{@min}}\n @isPrependProvided={{has-block \"prepend\"}}\n @isAppendProvided={{has-block \"append\"}}\n @isFakeMinBlock={{not (has-block \"min\")}}\n @isFakeMaxBlock={{not (has-block \"max\")}}\n autofocus={{@autofocus}}\n ...attributes\n >\n <:prepend as |classes|>\n {{yield classes to=\"prepend\"}}\n </:prepend>\n <:min>\n {{yield to=\"min\"}}\n </:min>\n <:max>\n {{yield to=\"max\"}}\n </:max>\n <:append as |classes|>\n {{yield classes to=\"append\"}}\n </:append>\n </EuiDualRange>\n </:field>\n\n <:helpText as |helpText|>\n {{yield helpText to=\"helpText\"}}\n </:helpText>\n </EuiFormRow>\n {{/let}}\n </template>\n}\n"],"names":["ValidatedFormFieldRangeSlider","ValidatedFormFieldBase","handleChange","e","_isValid","_event","value","Number","args","onChange","notifyValidityChange","n","prototype","action","setComponentTemplate","precompileTemplate","strictMode","scope","argOrDefault","randomId","EuiFormRow","not","didInsert","didUpdate","EuiDualRange"],"mappings":";;;;;;;;;;;;;AAgEe,MAAMA,sCAAsCC,sBAAA,CAAuB;AAEhF;AACAC,EAAAA,YAAAA,CACEC,CAA6B,EAC7BC,QAAiB,EACjBC,MAAa,EACb;AACA;AACA,IAAA,MAAMC,KAAA,GAAQ,CAACC,MAAA,CAAOJ,CAAC,CAAC,CAAA,CAAE,CAAA,EAAGI,MAAA,CAAOJ,CAAC,CAAC,CAAA,CAAE,CAAA,CAAE;AAE1C,IAAA,IAAI,CAACK,IAAI,CAACC,QAAQ,CAACH,KAAA,CAAA;IACnB,IAAI,CAACI,oBAAoB,EAAA;AAC3B,EAAA;AAAA,EAAA;IAAAC,CAAA,CAAA,IAAA,CAAAC,SAAA,EAAA,cAAA,EAAA,CAZCC,MAAA,CAAA,CAAA;AAAA;AAcD,EAAA;IAAAC,oBAAA,CAAAC,kBAAA,CAAA,46DAAA,EA4EA;MAAAC,UAAA,EAAA,IAAA;AAAAC,MAAAA,KAAA,EAAAA,OAAA;QAAAC,YAAA;QAAAC,QAAA;QAAAC,UAAA;QAAAC,GAAA;QAAAC,SAAA;QAAAC,SAAA;AAAAC,QAAAA;AAAA,OAAA;KAAU,CAAA,EAAV,IAAW,CAAA;AAAD;AACZ;;"}
|
|
@@ -1,18 +1,15 @@
|
|
|
1
|
-
import '@ember/helper';
|
|
2
|
-
import '@ember/modifier';
|
|
3
1
|
import { action } from '@ember/object';
|
|
4
2
|
import didInsert from '@ember/render-modifiers/modifiers/did-insert';
|
|
5
3
|
import didUpdate from '@ember/render-modifiers/modifiers/did-update';
|
|
6
4
|
import EuiFormRow from '@ember-eui/core/components/eui-form-row';
|
|
7
5
|
import EuiMarkdownEditor from '@ember-eui/core/components/eui-markdown-editor';
|
|
8
6
|
import { argOrDefault } from '@ember-eui/core/helpers';
|
|
9
|
-
import { EnsureSafeComponentHelper } from '@embroider/util';
|
|
10
7
|
import { not } from 'ember-truth-helpers';
|
|
11
8
|
import randomId from '../../-private/random-id.js';
|
|
12
9
|
import ValidatedFormFieldBase from './field-base.js';
|
|
13
10
|
import { precompileTemplate } from '@ember/template-compilation';
|
|
14
11
|
import { setComponentTemplate } from '@ember/component';
|
|
15
|
-
import { n } from 'decorator-transforms/runtime';
|
|
12
|
+
import { n } from 'decorator-transforms/runtime-esm';
|
|
16
13
|
|
|
17
14
|
class ValidatedFormFieldMarkdownEditor extends ValidatedFormFieldBase {
|
|
18
15
|
//@ts-expect-error
|
|
@@ -24,7 +21,7 @@ class ValidatedFormFieldMarkdownEditor extends ValidatedFormFieldBase {
|
|
|
24
21
|
n(this.prototype, "handleChange", [action]);
|
|
25
22
|
}
|
|
26
23
|
static {
|
|
27
|
-
setComponentTemplate(precompileTemplate("
|
|
24
|
+
setComponentTemplate(precompileTemplate("{{#let (argOrDefault @id (randomId)) as |theId|}}\n <EuiFormRow class={{this.rowClasses}} @labelType={{@labelType}} @display={{@display}} @hasEmptyLabelSpace={{@hasEmptyLabelSpace}} @fullWidth={{@fullWidth}} @hasChildLabel={{@hasChildLabel}} @label={{this.label}} @labelAppend={{@labelAppend}} @id={{theId}} @isInvalid={{this.isInvalidAndTouched}} @error={{this.validationErrorMessages}} @helpText={{@helpText}} @errorClasses={{@errorClasses}} @isFakeLabelBlock={{not (has-block \"label\")}} @isFakeHelpTextBlock={{not (has-block \"helpText\")}} {{didInsert this.setValidationMessages}} {{didUpdate this.didUpdateValue @validations}} {{didUpdate this.didUpdateValue @value}}>\n <:label as |label|>\n {{yield label to=\"label\"}}\n </:label>\n <:field>\n {{#let (if @editorComponent (component @editorComponent) (component EuiMarkdownEditor)) as |MarkdownEditor|}}\n {{!--@glint-expect-error--}}\n <MarkdownEditor class={{@fieldClasses}} form={{@formId}} aria-label={{@ariaLabel}} @value={{@value}} @isInvalid={{this.isInvalidAndTouched}} @disabled={{@disabled}} @editorId={{theId}} @onChange={{this.handleChange}} @ariaDescribedBy={{@ariaDescribedBy}} @ariaLabel={{@ariaLabel}} @ariaLabelledBy={{@ariaLabelledBy}} autofocus={{@autofocus}} placeholder={{@placeholder}} @onParse={{@onParse}} @parsingPluginList={{@parsingPluginList}} @uiPlugins={{@uiPlugins}} @height={{@height}} @maxHeight={{@maxHeight}} @autoExpandPreview={{@autoExpandPreview}} @initialViewMode={{@initialViewMode}} ...attributes />\n {{/let}}\n </:field>\n <:helpText as |helpText|>\n {{yield helpText to=\"helpText\"}}\n </:helpText>\n </EuiFormRow>\n{{/let}}", {
|
|
28
25
|
strictMode: true,
|
|
29
26
|
scope: () => ({
|
|
30
27
|
argOrDefault,
|
|
@@ -33,7 +30,6 @@ class ValidatedFormFieldMarkdownEditor extends ValidatedFormFieldBase {
|
|
|
33
30
|
not,
|
|
34
31
|
didInsert,
|
|
35
32
|
didUpdate,
|
|
36
|
-
EnsureSafeComponentHelper,
|
|
37
33
|
EuiMarkdownEditor
|
|
38
34
|
})
|
|
39
35
|
}), this);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"field-markdown-editor.js","sources":["../../../src/components/validated-form/field-markdown-editor.gts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"field-markdown-editor.js","sources":["../../../src/components/validated-form/field-markdown-editor.gts"],"sourcesContent":["import { action } from '@ember/object';\nimport didInsert from '@ember/render-modifiers/modifiers/did-insert';\nimport didUpdate from '@ember/render-modifiers/modifiers/did-update';\nimport EuiFormRow from '@ember-eui/core/components/eui-form-row';\nimport EuiMarkdownEditor from '@ember-eui/core/components/eui-markdown-editor';\nimport { argOrDefault } from '@ember-eui/core/helpers';\n\nimport { not } from 'ember-truth-helpers';\n\nimport randomId from '../../-private/random-id.ts';\nimport ValidatedFormFieldBase from './field-base.gts';\n\nimport type { FieldBaseSignature } from './field-base.gts';\nimport type { EuiFormRowSignature } from '@ember-eui/core/components/eui-form-row';\nimport type { EuiMarkdownEditorSignature } from '@ember-eui/core/components/eui-markdown-editor';\nimport type { ComponentLike } from '@glint/template';\n\n/**\n * A validated markdown editor in an EuiFormRow. Takes FieldBase's, EuiFormRow's and\n * the control's args.\n */\nexport interface FieldMarkdownEditorSignature {\n Element: EuiMarkdownEditorSignature['Element'];\n Args: FieldBaseSignature['Args'] &\n EuiFormRowSignature['Args'] &\n EuiMarkdownEditorSignature['Args'] & {\n /** Classes for the EuiFormRow. */\n rowClasses?: string;\n /** Classes for the control. */\n fieldClasses?: string;\n /** @private Set by ValidatedForm. */\n formId?: string;\n /** Accessible label of the control. */\n ariaLabel?: string;\n /** Focuses the control on render. */\n autofocus?: boolean;\n /** Called with the markdown text. */\n onChange?: (value: string) => void;\n /** Placeholder text. */\n placeholder?: string;\n /** @deprecated Has no effect. */\n editorComponent?: ComponentLike;\n };\n Blocks: {\n label: [...EuiFormRowSignature['Blocks']['label']];\n helpText: [...EuiFormRowSignature['Blocks']['helpText']];\n };\n}\n\nexport default class ValidatedFormFieldMarkdownEditor extends ValidatedFormFieldBase<FieldMarkdownEditorSignature> {\n @action\n //@ts-expect-error\n handleChange(str: string) {\n this.args.onChange(str);\n this.notifyValidityChange();\n }\n\n <template>\n {{#let (argOrDefault @id (randomId)) as |theId|}}\n <EuiFormRow\n class={{this.rowClasses}}\n @labelType={{@labelType}}\n @display={{@display}}\n @hasEmptyLabelSpace={{@hasEmptyLabelSpace}}\n @fullWidth={{@fullWidth}}\n @hasChildLabel={{@hasChildLabel}}\n @label={{this.label}}\n @labelAppend={{@labelAppend}}\n @id={{theId}}\n @isInvalid={{this.isInvalidAndTouched}}\n @error={{this.validationErrorMessages}}\n @helpText={{@helpText}}\n @errorClasses={{@errorClasses}}\n @isFakeLabelBlock={{not (has-block \"label\")}}\n @isFakeHelpTextBlock={{not (has-block \"helpText\")}}\n {{didInsert this.setValidationMessages}}\n {{didUpdate this.didUpdateValue @validations}}\n {{didUpdate this.didUpdateValue @value}}\n >\n <:label as |label|>\n {{yield label to=\"label\"}}\n </:label>\n <:field>\n {{#let\n (if\n @editorComponent\n (component @editorComponent)\n (component EuiMarkdownEditor)\n )\n as |MarkdownEditor|\n }}\n {{!@glint-expect-error}}\n <MarkdownEditor\n class={{@fieldClasses}}\n form={{@formId}}\n aria-label={{@ariaLabel}}\n @value={{@value}}\n @isInvalid={{this.isInvalidAndTouched}}\n @disabled={{@disabled}}\n @editorId={{theId}}\n @onChange={{this.handleChange}}\n @ariaDescribedBy={{@ariaDescribedBy}}\n @ariaLabel={{@ariaLabel}}\n @ariaLabelledBy={{@ariaLabelledBy}}\n autofocus={{@autofocus}}\n placeholder={{@placeholder}}\n @onParse={{@onParse}}\n @parsingPluginList={{@parsingPluginList}}\n @uiPlugins={{@uiPlugins}}\n @height={{@height}}\n @maxHeight={{@maxHeight}}\n @autoExpandPreview={{@autoExpandPreview}}\n @initialViewMode={{@initialViewMode}}\n ...attributes\n />\n {{/let}}\n </:field>\n <:helpText as |helpText|>\n {{yield helpText to=\"helpText\"}}\n </:helpText>\n </EuiFormRow>\n {{/let}}\n </template>\n}\n"],"names":["ValidatedFormFieldMarkdownEditor","ValidatedFormFieldBase","handleChange","str","args","onChange","notifyValidityChange","n","prototype","action","setComponentTemplate","precompileTemplate","strictMode","scope","argOrDefault","randomId","EuiFormRow","not","didInsert","didUpdate","EuiMarkdownEditor"],"mappings":";;;;;;;;;;;;;AAiDe,MAAMA,yCAAyCC,sBAAA,CAAuB;AAEnF;EACAC,YAAAA,CAAaC,GAAW,EAAE;AACxB,IAAA,IAAI,CAACC,IAAI,CAACC,QAAQ,CAACF,GAAA,CAAA;IACnB,IAAI,CAACG,oBAAoB,EAAA;AAC3B,EAAA;AAAA,EAAA;IAAAC,CAAA,CAAA,IAAA,CAAAC,SAAA,EAAA,cAAA,EAAA,CALCC,MAAA,CAAA,CAAA;AAAA;AAOD,EAAA;IAAAC,oBAAA,CAAAC,kBAAA,CAAA,qpDAAA,EAiEA;MAAAC,UAAA,EAAA,IAAA;AAAAC,MAAAA,KAAA,EAAAA,OAAA;QAAAC,YAAA;QAAAC,QAAA;QAAAC,UAAA;QAAAC,GAAA;QAAAC,SAAA;QAAAC,SAAA;AAAAC,QAAAA;AAAA,OAAA;KAAU,CAAA,EAAV,IAAW,CAAA;AAAD;AACZ;;"}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import '@ember/helper';
|
|
2
1
|
import { on } from '@ember/modifier';
|
|
3
2
|
import didInsert from '@ember/render-modifiers/modifiers/did-insert';
|
|
4
3
|
import didUpdate from '@ember/render-modifiers/modifiers/did-update';
|
|
@@ -13,7 +12,7 @@ import { setComponentTemplate } from '@ember/component';
|
|
|
13
12
|
|
|
14
13
|
class ValidatedFormFieldNumber extends ValidatedFormFieldBase {
|
|
15
14
|
static {
|
|
16
|
-
setComponentTemplate(precompileTemplate("
|
|
15
|
+
setComponentTemplate(precompileTemplate("{{#let (argOrDefault @id (randomId)) as |theId|}}\n <EuiFormRow class={{this.rowClasses}} @labelType={{@labelType}} @display={{@display}} @hasEmptyLabelSpace={{@hasEmptyLabelSpace}} @fullWidth={{@fullWidth}} @hasChildLabel={{@hasChildLabel}} @label={{this.label}} @labelAppend={{@labelAppend}} @id={{theId}} @isInvalid={{this.isInvalidAndTouched}} @error={{this.validationErrorMessages}} @helpText={{@helpText}} @errorClasses={{@errorClasses}} @isFakeLabelBlock={{not (has-block \"label\")}} @isFakeHelpTextBlock={{not (has-block \"helpText\")}} {{didInsert this.setValidationMessages}} {{didUpdate this.didUpdateValue @validations}} {{didUpdate this.didUpdateValue @value}}>\n <:label>\n {{yield to=\"label\"}}\n </:label>\n\n <:field>\n <EuiFieldNumber class={{@fieldClasses}} form={{@formId}} aria-label={{@ariaLabel}} @value={{@value}} @icon={{@icon}} @isInvalid={{this.isInvalidAndTouched}} @fullWidth={{@fullWidth}} @isLoading={{@isLoading}} @readOnly={{@readOnly}} @disabled={{@disabled}} @min={{@min}} @max={{@max}} @step={{@step}} @inputRef={{@inputRef}} @controlOnly={{@controlOnly}} @compressed={{@compressed}} @id={{theId}} @clear={{@clear}} @isPrependProvided={{has-block \"prepend\"}} @isAppendProvided={{has-block \"append\"}} autofocus={{@autofocus}} placeholder={{@placeholder}} ...attributes {{on \"input\" this.handleChange}}>\n <:prepend as |classes|>\n {{yield classes to=\"prepend\"}}\n </:prepend>\n <:append as |classes|>\n {{yield classes to=\"append\"}}\n </:append>\n </EuiFieldNumber>\n </:field>\n <:helpText as |helpText|>\n {{yield helpText to=\"helpText\"}}\n </:helpText>\n </EuiFormRow>\n{{/let}}", {
|
|
17
16
|
strictMode: true,
|
|
18
17
|
scope: () => ({
|
|
19
18
|
argOrDefault,
|