@flipdish/ui-library 0.52.0 → 0.53.1
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/dist/components/atoms/CloseButton/index.cjs +1 -0
- package/dist/components/atoms/CloseButton/index.cjs.map +1 -1
- package/dist/components/atoms/CloseButton/index.d.ts.map +1 -1
- package/dist/components/atoms/CloseButton/index.js +1 -0
- package/dist/components/atoms/CloseButton/index.js.map +1 -1
- package/dist/components/forms/Form/hooks/useSaveForm/useSaveForm.cjs +93 -0
- package/dist/components/forms/Form/hooks/useSaveForm/useSaveForm.cjs.map +1 -0
- package/dist/components/forms/Form/hooks/useSaveForm/useSaveForm.d.ts +54 -0
- package/dist/components/forms/Form/hooks/useSaveForm/useSaveForm.d.ts.map +1 -0
- package/dist/components/forms/Form/hooks/useSaveForm/useSaveForm.js +91 -0
- package/dist/components/forms/Form/hooks/useSaveForm/useSaveForm.js.map +1 -0
- package/dist/components/forms/Form/index.cjs +26 -6
- package/dist/components/forms/Form/index.cjs.map +1 -1
- package/dist/components/forms/Form/index.d.ts +9 -2
- package/dist/components/forms/Form/index.d.ts.map +1 -1
- package/dist/components/forms/Form/index.js +27 -8
- package/dist/components/forms/Form/index.js.map +1 -1
- package/dist/components/forms/FormFooter/index.cjs +1 -1
- package/dist/components/forms/FormFooter/index.cjs.map +1 -1
- package/dist/components/forms/FormFooter/index.d.ts +4 -0
- package/dist/components/forms/FormFooter/index.d.ts.map +1 -1
- package/dist/components/forms/FormFooter/index.js +1 -1
- package/dist/components/forms/FormFooter/index.js.map +1 -1
- package/dist/components/forms/FormSaveErrorAlert/index.cjs +28 -0
- package/dist/components/forms/FormSaveErrorAlert/index.cjs.map +1 -0
- package/dist/components/forms/FormSaveErrorAlert/index.d.ts +18 -0
- package/dist/components/forms/FormSaveErrorAlert/index.d.ts.map +1 -0
- package/dist/components/forms/FormSaveErrorAlert/index.js +26 -0
- package/dist/components/forms/FormSaveErrorAlert/index.js.map +1 -0
- package/dist/components/forms/FormUnsavedChangesModal/index.cjs +24 -0
- package/dist/components/forms/FormUnsavedChangesModal/index.cjs.map +1 -0
- package/dist/components/forms/FormUnsavedChangesModal/index.d.ts +14 -0
- package/dist/components/forms/FormUnsavedChangesModal/index.d.ts.map +1 -0
- package/dist/components/forms/FormUnsavedChangesModal/index.js +22 -0
- package/dist/components/forms/FormUnsavedChangesModal/index.js.map +1 -0
- package/dist/components/forms/__internal__/formField/hooks/useFormField.cjs +8 -3
- package/dist/components/forms/__internal__/formField/hooks/useFormField.cjs.map +1 -1
- package/dist/components/forms/__internal__/formField/hooks/useFormField.d.ts +1 -1
- package/dist/components/forms/__internal__/formField/hooks/useFormField.d.ts.map +1 -1
- package/dist/components/forms/__internal__/formField/hooks/useFormField.js +8 -3
- package/dist/components/forms/__internal__/formField/hooks/useFormField.js.map +1 -1
- package/dist/components/forms/__internal__/formField/utilities/fieldDependents.utils.cjs +47 -0
- package/dist/components/forms/__internal__/formField/utilities/fieldDependents.utils.cjs.map +1 -0
- package/dist/components/forms/__internal__/formField/utilities/fieldDependents.utils.d.ts +26 -0
- package/dist/components/forms/__internal__/formField/utilities/fieldDependents.utils.d.ts.map +1 -0
- package/dist/components/forms/__internal__/formField/utilities/fieldDependents.utils.js +43 -0
- package/dist/components/forms/__internal__/formField/utilities/fieldDependents.utils.js.map +1 -0
- package/dist/components/forms/__internal__/formSubmit/providers/FormSubmit.context.cjs +12 -0
- package/dist/components/forms/__internal__/formSubmit/providers/FormSubmit.context.cjs.map +1 -0
- package/dist/components/forms/__internal__/formSubmit/providers/FormSubmit.context.d.ts +6 -0
- package/dist/components/forms/__internal__/formSubmit/providers/FormSubmit.context.d.ts.map +1 -0
- package/dist/components/forms/__internal__/formSubmit/providers/FormSubmit.context.js +10 -0
- package/dist/components/forms/__internal__/formSubmit/providers/FormSubmit.context.js.map +1 -0
- package/dist/components/forms/fields/FormCheckbox/index.cjs.map +1 -1
- package/dist/components/forms/fields/FormCheckbox/index.d.ts +4 -1
- package/dist/components/forms/fields/FormCheckbox/index.d.ts.map +1 -1
- package/dist/components/forms/fields/FormCheckbox/index.js.map +1 -1
- package/dist/components/forms/fields/FormCheckboxGroup/index.cjs.map +1 -1
- package/dist/components/forms/fields/FormCheckboxGroup/index.d.ts +4 -1
- package/dist/components/forms/fields/FormCheckboxGroup/index.d.ts.map +1 -1
- package/dist/components/forms/fields/FormCheckboxGroup/index.js.map +1 -1
- package/dist/components/forms/fields/FormColorPicker/index.cjs.map +1 -1
- package/dist/components/forms/fields/FormColorPicker/index.d.ts +4 -1
- package/dist/components/forms/fields/FormColorPicker/index.d.ts.map +1 -1
- package/dist/components/forms/fields/FormColorPicker/index.js.map +1 -1
- package/dist/components/forms/fields/FormDatePicker/index.cjs.map +1 -1
- package/dist/components/forms/fields/FormDatePicker/index.d.ts +4 -1
- package/dist/components/forms/fields/FormDatePicker/index.d.ts.map +1 -1
- package/dist/components/forms/fields/FormDatePicker/index.js.map +1 -1
- package/dist/components/forms/fields/FormInput/index.cjs.map +1 -1
- package/dist/components/forms/fields/FormInput/index.d.ts +4 -1
- package/dist/components/forms/fields/FormInput/index.d.ts.map +1 -1
- package/dist/components/forms/fields/FormInput/index.js.map +1 -1
- package/dist/components/forms/fields/FormMultiSelect/index.cjs.map +1 -1
- package/dist/components/forms/fields/FormMultiSelect/index.d.ts +4 -1
- package/dist/components/forms/fields/FormMultiSelect/index.d.ts.map +1 -1
- package/dist/components/forms/fields/FormMultiSelect/index.js.map +1 -1
- package/dist/components/forms/fields/FormRadioCardGroup/index.cjs.map +1 -1
- package/dist/components/forms/fields/FormRadioCardGroup/index.d.ts +4 -1
- package/dist/components/forms/fields/FormRadioCardGroup/index.d.ts.map +1 -1
- package/dist/components/forms/fields/FormRadioCardGroup/index.js.map +1 -1
- package/dist/components/forms/fields/FormRadioGroup/index.cjs.map +1 -1
- package/dist/components/forms/fields/FormRadioGroup/index.d.ts +4 -1
- package/dist/components/forms/fields/FormRadioGroup/index.d.ts.map +1 -1
- package/dist/components/forms/fields/FormRadioGroup/index.js.map +1 -1
- package/dist/components/forms/fields/FormSelect/index.cjs.map +1 -1
- package/dist/components/forms/fields/FormSelect/index.d.ts +4 -1
- package/dist/components/forms/fields/FormSelect/index.d.ts.map +1 -1
- package/dist/components/forms/fields/FormSelect/index.js.map +1 -1
- package/dist/components/forms/fields/FormSlider/index.cjs.map +1 -1
- package/dist/components/forms/fields/FormSlider/index.d.ts +4 -1
- package/dist/components/forms/fields/FormSlider/index.d.ts.map +1 -1
- package/dist/components/forms/fields/FormSlider/index.js.map +1 -1
- package/dist/components/forms/fields/FormTextArea/index.cjs.map +1 -1
- package/dist/components/forms/fields/FormTextArea/index.d.ts +4 -1
- package/dist/components/forms/fields/FormTextArea/index.d.ts.map +1 -1
- package/dist/components/forms/fields/FormTextArea/index.js.map +1 -1
- package/dist/components/forms/fields/FormToggle/index.cjs.map +1 -1
- package/dist/components/forms/fields/FormToggle/index.d.ts +4 -1
- package/dist/components/forms/fields/FormToggle/index.d.ts.map +1 -1
- package/dist/components/forms/fields/FormToggle/index.js.map +1 -1
- package/dist/components/forms/validation/hooks/useSchemaResolver.cjs +7 -2
- package/dist/components/forms/validation/hooks/useSchemaResolver.cjs.map +1 -1
- package/dist/components/forms/validation/hooks/useSchemaResolver.d.ts +2 -1
- package/dist/components/forms/validation/hooks/useSchemaResolver.d.ts.map +1 -1
- package/dist/components/forms/validation/hooks/useSchemaResolver.js +8 -3
- package/dist/components/forms/validation/hooks/useSchemaResolver.js.map +1 -1
- package/dist/components/forms/validation/index.cjs +112 -8
- package/dist/components/forms/validation/index.cjs.map +1 -1
- package/dist/components/forms/validation/index.d.ts +71 -7
- package/dist/components/forms/validation/index.d.ts.map +1 -1
- package/dist/components/forms/validation/index.js +110 -9
- package/dist/components/forms/validation/index.js.map +1 -1
- package/dist/components/forms/validation/utilities/validation.utils.cjs +30 -0
- package/dist/components/forms/validation/utilities/validation.utils.cjs.map +1 -1
- package/dist/components/forms/validation/utilities/validation.utils.d.ts +18 -0
- package/dist/components/forms/validation/utilities/validation.utils.d.ts.map +1 -1
- package/dist/components/forms/validation/utilities/validation.utils.js +29 -1
- package/dist/components/forms/validation/utilities/validation.utils.js.map +1 -1
- package/dist/components/molecules/Dropdown/components/DropdownSelectionIndicator.cjs +29 -0
- package/dist/components/molecules/Dropdown/components/DropdownSelectionIndicator.cjs.map +1 -0
- package/dist/components/molecules/Dropdown/components/DropdownSelectionIndicator.d.ts +9 -0
- package/dist/components/molecules/Dropdown/components/DropdownSelectionIndicator.d.ts.map +1 -0
- package/dist/components/molecules/Dropdown/components/DropdownSelectionIndicator.js +27 -0
- package/dist/components/molecules/Dropdown/components/DropdownSelectionIndicator.js.map +1 -0
- package/dist/components/molecules/Dropdown/index.cjs +4 -30
- package/dist/components/molecules/Dropdown/index.cjs.map +1 -1
- package/dist/components/molecules/Dropdown/index.d.ts +1 -1
- package/dist/components/molecules/Dropdown/index.d.ts.map +1 -1
- package/dist/components/molecules/Dropdown/index.js +6 -32
- package/dist/components/molecules/Dropdown/index.js.map +1 -1
- package/dist/components/molecules/Dropdown/utilities/dropdown.utils.cjs +24 -0
- package/dist/components/molecules/Dropdown/utilities/dropdown.utils.cjs.map +1 -0
- package/dist/components/molecules/Dropdown/utilities/dropdown.utils.d.ts +10 -0
- package/dist/components/molecules/Dropdown/utilities/dropdown.utils.d.ts.map +1 -0
- package/dist/components/molecules/Dropdown/utilities/dropdown.utils.js +22 -0
- package/dist/components/molecules/Dropdown/utilities/dropdown.utils.js.map +1 -0
- package/dist/hooks/useFocusAfterRetry/index.cjs +7 -3
- package/dist/hooks/useFocusAfterRetry/index.cjs.map +1 -1
- package/dist/hooks/useFocusAfterRetry/index.d.ts +8 -2
- package/dist/hooks/useFocusAfterRetry/index.d.ts.map +1 -1
- package/dist/hooks/useFocusAfterRetry/index.js +7 -3
- package/dist/hooks/useFocusAfterRetry/index.js.map +1 -1
- package/dist/localization/en.json.cjs +19 -0
- package/dist/localization/en.json.cjs.map +1 -1
- package/dist/localization/en.json.js +18 -1
- package/dist/localization/en.json.js.map +1 -1
- package/dist/native/components/forms/FormSaveErrorAlert/index.d.ts +12 -0
- package/dist/native/components/forms/FormUnsavedChangesModal/index.d.ts +12 -0
- package/dist/native/utilities/colorUtils/index.d.ts +12 -0
- package/dist/utilities/__internal__/builtInTextUtils/builtInText.utils.d.ts +1 -1
- package/dist/utilities/__internal__/builtInTextUtils/builtInText.utils.d.ts.map +1 -1
- package/dist/utilities/colorUtils/index.cjs +24 -0
- package/dist/utilities/colorUtils/index.cjs.map +1 -0
- package/dist/utilities/colorUtils/index.d.ts +8 -0
- package/dist/utilities/colorUtils/index.d.ts.map +1 -0
- package/dist/utilities/colorUtils/index.js +22 -0
- package/dist/utilities/colorUtils/index.js.map +1 -0
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validation.utils.cjs","sources":["../../../../../src/components/forms/validation/utilities/validation.utils.ts"],"sourcesContent":[null],"names":["builtInTextIdOf","builtInText","fillPlaceholders"],"mappings":"
|
|
1
|
+
{"version":3,"file":"validation.utils.cjs","sources":["../../../../../src/components/forms/validation/utilities/validation.utils.ts"],"sourcesContent":[null],"names":["withRule","builtInTextIdOf","builtInText","fillPlaceholders"],"mappings":";;;;;AAMA;AACA,MAAM,YAAY,GAAG,IAAI,OAAO,EAA2D;AAE3F;;;;;;AAMG;AACI,MAAM,kBAAkB,GAAG,CAAC,OAAkB,EAAE,KAAwB,EAAE,SAAiB,KAAU;;IAE1G,MAAM,MAAM,GAAG,OAAO,CAAC,IAAI,EAAE,GAAG,CAAC,MAAM,IAAI,EAAE;IAC7C,MAAM,KAAK,GAAG,MAAM,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC;AACvC,IAAA,IAAI,KAAK;QAAE,YAAY,CAAC,GAAG,CAAC,KAAK,EAAE,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC;AAC1D;AAEA;;;;;;AAMG;AACI,MAAM,sBAAsB,GAA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;;;"}
|
|
@@ -1,4 +1,22 @@
|
|
|
1
|
+
import type { z } from 'zod';
|
|
2
|
+
import type { FieldDependents } from '../../__internal__/formField/utilities/fieldDependents.utils';
|
|
1
3
|
import type { MessageValues, Translate } from '../validation.types';
|
|
4
|
+
/**
|
|
5
|
+
* Notes which fields a cross-field rule ties together, for the form's fields to re-validate one as another changes.
|
|
6
|
+
*
|
|
7
|
+
* @param refined The schema as the rule's refinement returned it, whose last check is the rule's.
|
|
8
|
+
* @param reads The fields the rule reads.
|
|
9
|
+
* @param reportsOn The field the rule's error is shown on.
|
|
10
|
+
*/
|
|
11
|
+
export declare const noteCrossFieldRule: (refined: z.ZodType, reads: readonly string[], reportsOn: string) => void;
|
|
12
|
+
/**
|
|
13
|
+
* Collects, for each field a schema's cross-field rules read, the fields those rules report on.
|
|
14
|
+
*
|
|
15
|
+
* @param schema The form's schema. One that wraps the schema the rules were added to, as `.transform()` and
|
|
16
|
+
* `.optional()` give, carries none of its checks, and so names nothing.
|
|
17
|
+
* @returns The dependents of each field; empty for a schema with no such rule.
|
|
18
|
+
*/
|
|
19
|
+
export declare const crossFieldDependentsOf: (schema: z.ZodType) => FieldDependents;
|
|
2
20
|
/**
|
|
3
21
|
* Collects the values a failed rule offers its message: the limit of a length or size rule as `min` or `max`, and
|
|
4
22
|
* whatever the rule passed as `params`.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validation.utils.d.ts","sourceRoot":"","sources":["../../../../../src/components/forms/validation/utilities/validation.utils.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"validation.utils.d.ts","sourceRoot":"","sources":["../../../../../src/components/forms/validation/utilities/validation.utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAG7B,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,8DAA8D,CAAC;AACpG,OAAO,KAAK,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAKpE;;;;;;GAMG;AACH,eAAO,MAAM,kBAAkB,GAAI,SAAS,CAAC,CAAC,OAAO,EAAE,OAAO,SAAS,MAAM,EAAE,EAAE,WAAW,MAAM,KAAG,IAKpG,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,sBAAsB,GAAI,QAAQ,CAAC,CAAC,OAAO,KAAG,eAI5C,CAAC;AAEhB;;;;;;GAMG;AACH,eAAO,MAAM,QAAQ,GAAI,OAAO,MAAM,KAAG,aAGxC,CAAC;AAEF;;;;;;;;GAQG;AACH,eAAO,MAAM,WAAW,GACrB,WAAW,SAAS,GAAG,SAAS,MAChC,SAAS,MAAM,EAAE,QAAQ,aAAa,KAAG,MAUzC,CAAC"}
|
|
@@ -1,5 +1,33 @@
|
|
|
1
|
+
import { withRule } from '../../__internal__/formField/utilities/fieldDependents.utils.js';
|
|
1
2
|
import { builtInTextIdOf, builtInText, fillPlaceholders } from '../../../../utilities/__internal__/builtInTextUtils/builtInText.utils.js';
|
|
2
3
|
|
|
4
|
+
// Kept by the check zod makes for a rule, never by the schema: zod copies a schema on each call, such as `.refine()`, and carries its checks over.
|
|
5
|
+
const rulesByCheck = new WeakMap();
|
|
6
|
+
/**
|
|
7
|
+
* Notes which fields a cross-field rule ties together, for the form's fields to re-validate one as another changes.
|
|
8
|
+
*
|
|
9
|
+
* @param refined The schema as the rule's refinement returned it, whose last check is the rule's.
|
|
10
|
+
* @param reads The fields the rule reads.
|
|
11
|
+
* @param reportsOn The field the rule's error is shown on.
|
|
12
|
+
*/
|
|
13
|
+
const noteCrossFieldRule = (refined, reads, reportsOn) => {
|
|
14
|
+
// `_zod` is read with `?.` here and below: a schema that keeps its checks elsewhere then names nothing, where it would throw as the form mounts.
|
|
15
|
+
const checks = refined._zod?.def.checks ?? [];
|
|
16
|
+
const check = checks[checks.length - 1];
|
|
17
|
+
if (check)
|
|
18
|
+
rulesByCheck.set(check, { reads, reportsOn });
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* Collects, for each field a schema's cross-field rules read, the fields those rules report on.
|
|
22
|
+
*
|
|
23
|
+
* @param schema The form's schema. One that wraps the schema the rules were added to, as `.transform()` and
|
|
24
|
+
* `.optional()` give, carries none of its checks, and so names nothing.
|
|
25
|
+
* @returns The dependents of each field; empty for a schema with no such rule.
|
|
26
|
+
*/
|
|
27
|
+
const crossFieldDependentsOf = (schema) => (schema._zod?.def.checks ?? []).reduce((dependents, check) => {
|
|
28
|
+
const rule = rulesByCheck.get(check);
|
|
29
|
+
return rule ? withRule(dependents, rule.reads, rule.reportsOn) : dependents;
|
|
30
|
+
}, new Map());
|
|
3
31
|
/**
|
|
4
32
|
* Collects the values a failed rule offers its message: the limit of a length or size rule as `min` or `max`, and
|
|
5
33
|
* whatever the rule passed as `params`.
|
|
@@ -35,5 +63,5 @@ const messageText = (translate) => (message, values) => {
|
|
|
35
63
|
}
|
|
36
64
|
};
|
|
37
65
|
|
|
38
|
-
export { messageText, valuesOf };
|
|
66
|
+
export { crossFieldDependentsOf, messageText, noteCrossFieldRule, valuesOf };
|
|
39
67
|
//# sourceMappingURL=validation.utils.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validation.utils.js","sources":["../../../../../src/components/forms/validation/utilities/validation.utils.ts"],"sourcesContent":[null],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"validation.utils.js","sources":["../../../../../src/components/forms/validation/utilities/validation.utils.ts"],"sourcesContent":[null],"names":[],"mappings":";;;AAMA;AACA,MAAM,YAAY,GAAG,IAAI,OAAO,EAA2D;AAE3F;;;;;;AAMG;AACI,MAAM,kBAAkB,GAAG,CAAC,OAAkB,EAAE,KAAwB,EAAE,SAAiB,KAAU;;IAE1G,MAAM,MAAM,GAAG,OAAO,CAAC,IAAI,EAAE,GAAG,CAAC,MAAM,IAAI,EAAE;IAC7C,MAAM,KAAK,GAAG,MAAM,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC;AACvC,IAAA,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AI,KAAK,QAAQ,IAAI,IAAI,CAAC,IAAI,EAAE,GAAG,IAAI,GAAG,OAAO;IACjE;AAAE,IAAA,MAAM;AACN,QAAA,OAAO,OAAO;IAChB;AACF;;"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
4
|
+
var uiIcons = require('@flipdish/ui-icons');
|
|
5
|
+
var Checkbox = require('@flipdish/ui-library/components/atoms/Checkbox');
|
|
6
|
+
var RadioButton = require('@flipdish/ui-library/components/atoms/RadioButton');
|
|
7
|
+
var Toggle = require('@flipdish/ui-library/components/atoms/Toggle');
|
|
8
|
+
var cx = require('@flipdish/ui-library/utilities/cx');
|
|
9
|
+
|
|
10
|
+
const DropdownSelectionIndicator = ({ selectionIndicator, isSelected, hasSubmenu, className }) => {
|
|
11
|
+
if (selectionIndicator === 'checkmark') {
|
|
12
|
+
return (jsxRuntime.jsx(uiIcons.Check, { "aria-hidden": "true", className: cx.cx('size-4 shrink-0 stroke-[2.25px] text-fg-brand-primary', !isSelected && 'invisible', className) }));
|
|
13
|
+
}
|
|
14
|
+
if (selectionIndicator === 'checkbox') {
|
|
15
|
+
return (jsxRuntime.jsx(Checkbox.CheckboxBase, { isSelected: isSelected && !hasSubmenu,
|
|
16
|
+
// A selected item that opens a submenu is only partly chosen, so the box is mixed rather than checked.
|
|
17
|
+
isIndeterminate: isSelected && hasSubmenu, size: "sm", className: cx.cx('shrink-0', className) }));
|
|
18
|
+
}
|
|
19
|
+
if (selectionIndicator === 'radio') {
|
|
20
|
+
return jsxRuntime.jsx(RadioButton.RadioButtonBase, { isSelected: isSelected, className: cx.cx('shrink-0', className) });
|
|
21
|
+
}
|
|
22
|
+
if (selectionIndicator === 'toggle') {
|
|
23
|
+
return jsxRuntime.jsx(Toggle.ToggleBase, { slim: true, size: "sm", isSelected: isSelected, className: cx.cx('shrink-0', className) });
|
|
24
|
+
}
|
|
25
|
+
return null;
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
exports.DropdownSelectionIndicator = DropdownSelectionIndicator;
|
|
29
|
+
//# sourceMappingURL=DropdownSelectionIndicator.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DropdownSelectionIndicator.cjs","sources":["../../../../../src/components/molecules/Dropdown/components/DropdownSelectionIndicator.tsx"],"sourcesContent":[null],"names":["_jsx","Check","cx","CheckboxBase","RadioButtonBase","ToggleBase"],"mappings":";;;;;;;;;AAeO,MAAM,0BAA0B,GAAG,CAAC,EAAE,kBAAkB,EAAE,UAAU,EAAE,UAAU,EAAE,SAAS,EAAmC,KAAI;AACvI,IAAA,IAAI,kBAAkB,KAAK,WAAW,EAAE;QACtC,QACEA,eAACC,aAAK,EAAA,EAAA,aAAA,EAAa,MAAM,EAAC,SAAS,EAAEC,KAAE,CAAC,uDAAuD,EAAE,CAAC,UAAU,IAAI,WAAW,EAAE,SAAS,CAAC,EAAA,CAAI;IAE/I;AACA,IAAA,IAAI,kBAAkB,KAAK,UAAU,EAAE;QACrC,QACEF,eAACG,qBAAY,EAAA,EACX,UAAU,EAAE,UAAU,IAAI,CAAC,UAAU;;AAErC,YAAA,eAAe,EAAE,UAAU,IAAI,UAAU,EACzC,IAAI,EAAC,IAAI,EACT,SAAS,EAAED,KAAE,CAAC,UAAU,EAAE,SAAS,CAAC,EAAA,CACpC;IAEN;AACA,IAAA,IAAI,kBAAkB,KAAK,OAAO,EAAE;AAClC,QAAA,OAAOF,eAACI,2BAAe,EAAA,EAAC,UAAU,EAAE,UAAU,EAAE,SAAS,EAAEF,KAAE,CAAC,UAAU,EAAE,SAAS,CAAC,GAAI;IAC1F;AACA,IAAA,IAAI,kBAAkB,KAAK,QAAQ,EAAE;QACnC,OAAOF,cAAA,CAACK,iBAAU,EAAA,EAAC,IAAI,QAAC,IAAI,EAAC,IAAI,EAAC,UAAU,EAAE,UAAU,EAAE,SAAS,EAAEH,KAAE,CAAC,UAAU,EAAE,SAAS,CAAC,EAAA,CAAI;IACpG;AACA,IAAA,OAAO,IAAI;AACb;;"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
interface DropdownSelectionIndicatorProps {
|
|
2
|
+
selectionIndicator: 'checkmark' | 'checkbox' | 'radio' | 'toggle' | 'none';
|
|
3
|
+
isSelected: boolean;
|
|
4
|
+
hasSubmenu?: boolean;
|
|
5
|
+
className?: string;
|
|
6
|
+
}
|
|
7
|
+
export declare const DropdownSelectionIndicator: ({ selectionIndicator, isSelected, hasSubmenu, className }: DropdownSelectionIndicatorProps) => import("react").JSX.Element | null;
|
|
8
|
+
export {};
|
|
9
|
+
//# sourceMappingURL=DropdownSelectionIndicator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DropdownSelectionIndicator.d.ts","sourceRoot":"","sources":["../../../../../src/components/molecules/Dropdown/components/DropdownSelectionIndicator.tsx"],"names":[],"mappings":"AAQA,UAAU,+BAA+B;IACvC,kBAAkB,EAAE,WAAW,GAAG,UAAU,GAAG,OAAO,GAAG,QAAQ,GAAG,MAAM,CAAC;IAC3E,UAAU,EAAE,OAAO,CAAC;IACpB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,eAAO,MAAM,0BAA0B,GAAI,2DAA2D,+BAA+B,uCAwBpI,CAAC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { jsx } from 'react/jsx-runtime';
|
|
2
|
+
import { Check } from '@flipdish/ui-icons';
|
|
3
|
+
import { CheckboxBase } from '@flipdish/ui-library/components/atoms/Checkbox';
|
|
4
|
+
import { RadioButtonBase } from '@flipdish/ui-library/components/atoms/RadioButton';
|
|
5
|
+
import { ToggleBase } from '@flipdish/ui-library/components/atoms/Toggle';
|
|
6
|
+
import { cx } from '@flipdish/ui-library/utilities/cx';
|
|
7
|
+
|
|
8
|
+
const DropdownSelectionIndicator = ({ selectionIndicator, isSelected, hasSubmenu, className }) => {
|
|
9
|
+
if (selectionIndicator === 'checkmark') {
|
|
10
|
+
return (jsx(Check, { "aria-hidden": "true", className: cx('size-4 shrink-0 stroke-[2.25px] text-fg-brand-primary', !isSelected && 'invisible', className) }));
|
|
11
|
+
}
|
|
12
|
+
if (selectionIndicator === 'checkbox') {
|
|
13
|
+
return (jsx(CheckboxBase, { isSelected: isSelected && !hasSubmenu,
|
|
14
|
+
// A selected item that opens a submenu is only partly chosen, so the box is mixed rather than checked.
|
|
15
|
+
isIndeterminate: isSelected && hasSubmenu, size: "sm", className: cx('shrink-0', className) }));
|
|
16
|
+
}
|
|
17
|
+
if (selectionIndicator === 'radio') {
|
|
18
|
+
return jsx(RadioButtonBase, { isSelected: isSelected, className: cx('shrink-0', className) });
|
|
19
|
+
}
|
|
20
|
+
if (selectionIndicator === 'toggle') {
|
|
21
|
+
return jsx(ToggleBase, { slim: true, size: "sm", isSelected: isSelected, className: cx('shrink-0', className) });
|
|
22
|
+
}
|
|
23
|
+
return null;
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
export { DropdownSelectionIndicator };
|
|
27
|
+
//# sourceMappingURL=DropdownSelectionIndicator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DropdownSelectionIndicator.js","sources":["../../../../../src/components/molecules/Dropdown/components/DropdownSelectionIndicator.tsx"],"sourcesContent":[null],"names":["_jsx"],"mappings":";;;;;;;AAeO,MAAM,0BAA0B,GAAG,CAAC,EAAE,kBAAkB,EAAE,UAAU,EAAE,UAAU,EAAE,SAAS,EAAmC,KAAI;AACvI,IAAA,IAAI,kBAAkB,KAAK,WAAW,EAAE;QACtC,QACEA,IAAC,KAAK,EAAA,EAAA,aAAA,EAAa,MAAM,EAAC,SAAS,EAAE,EAAE,CAAC,uDAAuD,EAAE,CAAC,UAAU,IAAI,WAAW,EAAE,SAAS,CAAC,EAAA,CAAI;IAE/I;AACA,IAAA,IAAI,kBAAkB,KAAK,UAAU,EAAE;QACrC,QACEA,IAAC,YAAY,EAAA,EACX,UAAU,EAAE,UAAU,IAAI,CAAC,UAAU;;AAErC,YAAA,eAAe,EAAE,UAAU,IAAI,UAAU,EACzC,IAAI,EAAC,IAAI,EACT,SAAS,EAAE,EAAE,CAAC,UAAU,EAAE,SAAS,CAAC,EAAA,CACpC;IAEN;AACA,IAAA,IAAI,kBAAkB,KAAK,OAAO,EAAE;AAClC,QAAA,OAAOA,IAAC,eAAe,EAAA,EAAC,UAAU,EAAE,UAAU,EAAE,SAAS,EAAE,EAAE,CAAC,UAAU,EAAE,SAAS,CAAC,GAAI;IAC1F;AACA,IAAA,IAAI,kBAAkB,KAAK,QAAQ,EAAE;QACnC,OAAOA,GAAA,CAAC,UAAU,EAAA,EAAC,IAAI,QAAC,IAAI,EAAC,IAAI,EAAC,UAAU,EAAE,UAAU,EAAE,SAAS,EAAE,EAAE,CAAC,UAAU,EAAE,SAAS,CAAC,EAAA,CAAI;IACpG;AACA,IAAA,OAAO,IAAI;AACb;;"}
|
|
@@ -4,47 +4,21 @@ var jsxRuntime = require('react/jsx-runtime');
|
|
|
4
4
|
var uiIcons = require('@flipdish/ui-icons');
|
|
5
5
|
var Avatar = require('@flipdish/ui-library/components/atoms/Avatar');
|
|
6
6
|
var Button = require('@flipdish/ui-library/components/atoms/Button');
|
|
7
|
-
var Checkbox = require('@flipdish/ui-library/components/atoms/Checkbox');
|
|
8
|
-
var RadioButton = require('@flipdish/ui-library/components/atoms/RadioButton');
|
|
9
|
-
var Toggle = require('@flipdish/ui-library/components/atoms/Toggle');
|
|
10
7
|
var cx = require('@flipdish/ui-library/utilities/cx');
|
|
11
8
|
var testIdUtils = require('@flipdish/ui-library/utilities/testIdUtils');
|
|
12
|
-
var React = require('react');
|
|
13
9
|
var reactAriaComponents = require('react-aria-components');
|
|
14
10
|
var ScrollClosingPopover = require('../../__internal__/popover/ScrollClosingPopover.cjs');
|
|
11
|
+
var DropdownSelectionIndicator = require('./components/DropdownSelectionIndicator.cjs');
|
|
12
|
+
var dropdown_utils = require('./utilities/dropdown.utils.cjs');
|
|
15
13
|
|
|
16
14
|
const DropdownItem = ({ label, children, addon, icon: Icon, avatarUrl, unstyled, selectionIndicator = 'checkmark', 'data-testid': dataTestId, ...props }) => {
|
|
17
15
|
const prefix = testIdUtils.useTestIdPrefix();
|
|
18
|
-
const
|
|
19
|
-
if (props.id !== undefined)
|
|
20
|
-
return testIdUtils.slugifyTestId(String(props.id));
|
|
21
|
-
if (typeof label === 'string')
|
|
22
|
-
return testIdUtils.slugifyTestId(label);
|
|
23
|
-
if (typeof children === 'string')
|
|
24
|
-
return testIdUtils.slugifyTestId(children);
|
|
25
|
-
return 'item';
|
|
26
|
-
};
|
|
27
|
-
const idPart = resolveIdPart();
|
|
16
|
+
const idPart = dropdown_utils.dropdownItemSegment(props.id, label, children);
|
|
28
17
|
const itemTestId = dataTestId ?? (prefix ? testIdUtils.joinTestId(prefix, `item-${idPart}`) : undefined);
|
|
29
|
-
const SelectionIndicator = React.useCallback((state) => {
|
|
30
|
-
if (selectionIndicator === 'checkmark') {
|
|
31
|
-
return (jsxRuntime.jsx(uiIcons.Check, { "aria-hidden": "true", className: cx.cx('size-4 shrink-0 stroke-[2.25px] text-fg-brand-primary', !state.isSelected && 'invisible', state.className) }));
|
|
32
|
-
}
|
|
33
|
-
if (selectionIndicator === 'checkbox') {
|
|
34
|
-
return (jsxRuntime.jsx(Checkbox.CheckboxBase, { isSelected: state.isSelected && !state.hasSubmenu, isIndeterminate: state.isSelected && state.hasSubmenu, size: "sm", className: cx.cx('shrink-0', state.className) }));
|
|
35
|
-
}
|
|
36
|
-
if (selectionIndicator === 'radio') {
|
|
37
|
-
return jsxRuntime.jsx(RadioButton.RadioButtonBase, { isSelected: state.isSelected, className: cx.cx('shrink-0', state.className) });
|
|
38
|
-
}
|
|
39
|
-
if (selectionIndicator === 'toggle') {
|
|
40
|
-
return jsxRuntime.jsx(Toggle.ToggleBase, { slim: true, size: "sm", isSelected: state.isSelected, className: cx.cx('shrink-0', state.className) });
|
|
41
|
-
}
|
|
42
|
-
return null;
|
|
43
|
-
}, [selectionIndicator]);
|
|
44
18
|
if (unstyled) {
|
|
45
19
|
return jsxRuntime.jsx(reactAriaComponents.MenuItem, { id: label, textValue: label, "data-testid": itemTestId, ...props });
|
|
46
20
|
}
|
|
47
|
-
return (jsxRuntime.jsx(reactAriaComponents.MenuItem, { ...props, "data-testid": itemTestId, className: (state) => cx.cx('group block cursor-pointer px-1.5 py-px outline-hidden', state.isDisabled && 'cursor-not-allowed opacity-50', typeof props.className === 'function' ? props.className(state) : props.className), children: (state) => (jsxRuntime.jsxs("div", { className: cx.cx('relative flex items-center rounded-md px-2.5 py-2 outline-focus-ring transition duration-100 ease-linear', !state.isDisabled && 'group-hover:bg-primary_hover', state.isFocused && 'bg-primary_hover', state.isFocusVisible && 'outline-2 -outline-offset-2', state.hasSubmenu && 'pr-1.5'), children: [state.selectionMode !== 'none' && !avatarUrl && !Icon && jsxRuntime.jsx(
|
|
21
|
+
return (jsxRuntime.jsx(reactAriaComponents.MenuItem, { ...props, "data-testid": itemTestId, className: (state) => cx.cx('group block cursor-pointer px-1.5 py-px outline-hidden', state.isDisabled && 'cursor-not-allowed opacity-50', typeof props.className === 'function' ? props.className(state) : props.className), children: (state) => (jsxRuntime.jsxs("div", { className: cx.cx('relative flex items-center rounded-md px-2.5 py-2 outline-focus-ring transition duration-100 ease-linear', !state.isDisabled && 'group-hover:bg-primary_hover', state.isFocused && 'bg-primary_hover', state.isFocusVisible && 'outline-2 -outline-offset-2', state.hasSubmenu && 'pr-1.5'), children: [state.selectionMode !== 'none' && !avatarUrl && !Icon && (jsxRuntime.jsx(DropdownSelectionIndicator.DropdownSelectionIndicator, { selectionIndicator: selectionIndicator, isSelected: state.isSelected, hasSubmenu: state.hasSubmenu, className: "mr-2" })), avatarUrl && (jsxRuntime.jsx("div", { className: "mr-2 flex size-4 items-center justify-center", children: jsxRuntime.jsx(Avatar.Avatar, { "aria-hidden": "true", size: "xs", src: avatarUrl, alt: label, className: "size-5" }) })), Icon && jsxRuntime.jsx(Icon, { "aria-hidden": "true", className: "mr-2 size-4 shrink-0 stroke-[2.25px] text-fg-quaternary" }), jsxRuntime.jsx("span", { className: cx.cx('grow truncate text-sm font-semibold text-secondary', state.isFocused && 'text-secondary_hover'), children: label || (typeof children === 'function' ? children(state) : children) }), addon && jsxRuntime.jsx("span", { className: "ml-1 shrink-0 pr-1 text-xs font-medium text-quaternary", children: addon }), state.selectionMode !== 'none' && (avatarUrl || Icon) && (jsxRuntime.jsx(DropdownSelectionIndicator.DropdownSelectionIndicator, { selectionIndicator: selectionIndicator, isSelected: state.isSelected, hasSubmenu: state.hasSubmenu, className: "ml-1" })), state.hasSubmenu && jsxRuntime.jsx(uiIcons.ChevronRight, { "aria-hidden": "true", className: "ml-auto size-4 shrink-0 stroke-[2.25px] text-fg-quaternary" })] })) }));
|
|
48
22
|
};
|
|
49
23
|
const DropdownMenu = ({ 'data-testid': dataTestId, ...props }) => {
|
|
50
24
|
const prefix = testIdUtils.useTestIdPrefix();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sources":["../../../../src/components/molecules/Dropdown/index.tsx"],"sourcesContent":[null],"names":["useTestIdPrefix","
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../../../../src/components/molecules/Dropdown/index.tsx"],"sourcesContent":[null],"names":["useTestIdPrefix","dropdownItemSegment","joinTestId","_jsx","AriaMenuItem","cx","_jsxs","DropdownSelectionIndicator","Avatar","ChevronRight","AriaMenu","ScrollClosingPopover","AriaSeparator","useResolvedTestId","Button","DotsVertical","TestIdProvider","AriaMenuTrigger","AriaMenuSection","AriaHeader"],"mappings":";;;;;;;;;;;;;AA4CA,MAAM,YAAY,GAAG,CAAC,EACpB,KAAK,EACL,QAAQ,EACR,KAAK,EACL,IAAI,EAAE,IAAI,EACV,SAAS,EACT,QAAQ,EACR,kBAAkB,GAAG,WAAW,EAChC,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M,EAAE,UAAU,EAAE,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,sBAAsB,EAAE,CAAC;IAE5H,OAAOV,cAAA,CAACW,aAAM,EAAA,EAAA,YAAA,EAAY,WAAW,KAAK,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,WAAW,EAAEC,oBAAY,EAAA,aAAA,EAAe,gBAAgB,EAAA,CAAI;AACzI,CAAC;AAUD,MAAM,YAAY,GAAG,CAAC,EAAE,QAAQ,EAAE,aAAa,EAAE,UAAU,EAAE,GAAG,KAAK,EAAqB,KAAI;AAC5F,IAAA,MAAM,UAAU,GAAGF,6BAAiB,CAAC,EAAE,MAAM,EAAE,UAAU,EAAE,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,UAAU,EAAE,CAAC;AAEvG,IAAA,QACEV,cAAA,CAACa,0BAAc,EAAA,EAAC,KAAK,EAAE,UAAU,EAAA,QAAA,EAC/Bb,cAAA,CAACc,+BAAe,OAAK,KAAK,EAAA,QAAA,EAAG,QAAQ,EAAA,CAAmB,EAAA,CACzC;AAErB,CAAC;AAED;;;;;;;;AAQG;AACI,MAAM,QAAQ,GAAG;AACtB,IAAA,IAAI,EAAE,YAAY;AAClB,IAAA,OAAO,EAAE,eAAe;AACxB,IAAA,IAAI,EAAE,YAAY;AAClB,IAAA,OAAO,EAAEC,+BAAe;AACxB,IAAA,aAAa,EAAEC,0BAAU;AACzB,IAAA,IAAI,EAAE,YAAY;AAClB,IAAA,SAAS,EAAE,iBAAiB;AAC5B,IAAA,UAAU,EAAE,kBAAkB;;;"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type ButtonProps } from '@flipdish/ui-library/components/atoms/Button';
|
|
2
|
-
import {
|
|
2
|
+
import type { FC, SVGProps } from 'react';
|
|
3
3
|
import type { MenuItemProps as AriaMenuItemProps, MenuProps as AriaMenuProps, MenuTriggerProps as AriaMenuTriggerProps, PopoverProps as AriaPopoverProps, SeparatorProps as AriaSeparatorProps } from 'react-aria-components';
|
|
4
4
|
interface DropdownItemProps extends AriaMenuItemProps {
|
|
5
5
|
/** The label of the item to be displayed. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/molecules/Dropdown/index.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAU,KAAK,WAAW,EAAE,MAAM,8CAA8C,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/molecules/Dropdown/index.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAU,KAAK,WAAW,EAAE,MAAM,8CAA8C,CAAC;AAGxF,OAAO,KAAK,EAAE,EAAE,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC1C,OAAO,KAAK,EACV,aAAa,IAAI,iBAAiB,EAClC,SAAS,IAAI,aAAa,EAC1B,gBAAgB,IAAI,oBAAoB,EACxC,YAAY,IAAI,gBAAgB,EAChC,cAAc,IAAI,kBAAkB,EACrC,MAAM,uBAAuB,CAAC;AAa/B,UAAU,iBAAkB,SAAQ,iBAAiB;IACnD,6CAA6C;IAC7C,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,8DAA8D;IAC9D,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,kDAAkD;IAClD,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,4DAA4D;IAC5D,IAAI,CAAC,EAAE,EAAE,CAAC,QAAQ,CAAC,aAAa,CAAC,CAAC,CAAC;IACnC,+DAA+D;IAC/D,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,2DAA2D;IAC3D,kBAAkB,CAAC,EAAE,WAAW,GAAG,UAAU,GAAG,OAAO,GAAG,QAAQ,GAAG,MAAM,CAAC;IAC5E,0FAA0F;IAC1F,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAkFD,MAAM,WAAW,iBAAiB,CAAC,CAAC,SAAS,MAAM,CAAE,SAAQ,aAAa,CAAC,CAAC,CAAC;IAC3E,0HAA0H;IAC1H,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAiBD,UAAU,oBAAqB,SAAQ,gBAAgB;CAAG;AA2B1D,MAAM,WAAW,uBAAwB,SAAQ,IAAI,CAAC,WAAW,EAAE,UAAU,GAAG,aAAa,GAAG,cAAc,GAAG,MAAM,GAAG,OAAO,CAAC;IAChI,8HAA8H;IAC9H,KAAK,CAAC,EAAE,WAAW,GAAG,UAAU,CAAC;IACjC,4EAA4E;IAC5E,IAAI,CAAC,EAAE,IAAI,GAAG,IAAI,CAAC;IACnB;;;OAGG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAQD,MAAM,WAAW,iBAAkB,SAAQ,oBAAoB;IAC7D;;;OAGG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAYD;;;;;;;;GAQG;AACH,eAAO,MAAM,QAAQ;8DAnBoD,iBAAiB;qBAnD1D,oBAAoB;WAjB9B,CAAC,SAAS,MAAM,2CAA2C,iBAAiB,CAAC,CAAC,CAAC;;;iIA3ElG,iBAAiB;uBAiHc,kBAAkB;uEAgBmD,uBAAuB;CA0C7H,CAAC"}
|
|
@@ -1,48 +1,22 @@
|
|
|
1
1
|
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
2
|
-
import { DotsVertical,
|
|
2
|
+
import { DotsVertical, ChevronRight } from '@flipdish/ui-icons';
|
|
3
3
|
import { Avatar } from '@flipdish/ui-library/components/atoms/Avatar';
|
|
4
4
|
import { Button } from '@flipdish/ui-library/components/atoms/Button';
|
|
5
|
-
import { CheckboxBase } from '@flipdish/ui-library/components/atoms/Checkbox';
|
|
6
|
-
import { RadioButtonBase } from '@flipdish/ui-library/components/atoms/RadioButton';
|
|
7
|
-
import { ToggleBase } from '@flipdish/ui-library/components/atoms/Toggle';
|
|
8
5
|
import { cx } from '@flipdish/ui-library/utilities/cx';
|
|
9
|
-
import { useResolvedTestId, useTestIdPrefix, joinTestId, TestIdProvider
|
|
10
|
-
import { useCallback } from 'react';
|
|
6
|
+
import { useResolvedTestId, useTestIdPrefix, joinTestId, TestIdProvider } from '@flipdish/ui-library/utilities/testIdUtils';
|
|
11
7
|
import { Header, MenuSection, Separator, MenuItem, Menu, MenuTrigger } from 'react-aria-components';
|
|
12
8
|
import { ScrollClosingPopover } from '../../__internal__/popover/ScrollClosingPopover.js';
|
|
9
|
+
import { DropdownSelectionIndicator } from './components/DropdownSelectionIndicator.js';
|
|
10
|
+
import { dropdownItemSegment } from './utilities/dropdown.utils.js';
|
|
13
11
|
|
|
14
12
|
const DropdownItem = ({ label, children, addon, icon: Icon, avatarUrl, unstyled, selectionIndicator = 'checkmark', 'data-testid': dataTestId, ...props }) => {
|
|
15
13
|
const prefix = useTestIdPrefix();
|
|
16
|
-
const
|
|
17
|
-
if (props.id !== undefined)
|
|
18
|
-
return slugifyTestId(String(props.id));
|
|
19
|
-
if (typeof label === 'string')
|
|
20
|
-
return slugifyTestId(label);
|
|
21
|
-
if (typeof children === 'string')
|
|
22
|
-
return slugifyTestId(children);
|
|
23
|
-
return 'item';
|
|
24
|
-
};
|
|
25
|
-
const idPart = resolveIdPart();
|
|
14
|
+
const idPart = dropdownItemSegment(props.id, label, children);
|
|
26
15
|
const itemTestId = dataTestId ?? (prefix ? joinTestId(prefix, `item-${idPart}`) : undefined);
|
|
27
|
-
const SelectionIndicator = useCallback((state) => {
|
|
28
|
-
if (selectionIndicator === 'checkmark') {
|
|
29
|
-
return (jsx(Check, { "aria-hidden": "true", className: cx('size-4 shrink-0 stroke-[2.25px] text-fg-brand-primary', !state.isSelected && 'invisible', state.className) }));
|
|
30
|
-
}
|
|
31
|
-
if (selectionIndicator === 'checkbox') {
|
|
32
|
-
return (jsx(CheckboxBase, { isSelected: state.isSelected && !state.hasSubmenu, isIndeterminate: state.isSelected && state.hasSubmenu, size: "sm", className: cx('shrink-0', state.className) }));
|
|
33
|
-
}
|
|
34
|
-
if (selectionIndicator === 'radio') {
|
|
35
|
-
return jsx(RadioButtonBase, { isSelected: state.isSelected, className: cx('shrink-0', state.className) });
|
|
36
|
-
}
|
|
37
|
-
if (selectionIndicator === 'toggle') {
|
|
38
|
-
return jsx(ToggleBase, { slim: true, size: "sm", isSelected: state.isSelected, className: cx('shrink-0', state.className) });
|
|
39
|
-
}
|
|
40
|
-
return null;
|
|
41
|
-
}, [selectionIndicator]);
|
|
42
16
|
if (unstyled) {
|
|
43
17
|
return jsx(MenuItem, { id: label, textValue: label, "data-testid": itemTestId, ...props });
|
|
44
18
|
}
|
|
45
|
-
return (jsx(MenuItem, { ...props, "data-testid": itemTestId, className: (state) => cx('group block cursor-pointer px-1.5 py-px outline-hidden', state.isDisabled && 'cursor-not-allowed opacity-50', typeof props.className === 'function' ? props.className(state) : props.className), children: (state) => (jsxs("div", { className: cx('relative flex items-center rounded-md px-2.5 py-2 outline-focus-ring transition duration-100 ease-linear', !state.isDisabled && 'group-hover:bg-primary_hover', state.isFocused && 'bg-primary_hover', state.isFocusVisible && 'outline-2 -outline-offset-2', state.hasSubmenu && 'pr-1.5'), children: [state.selectionMode !== 'none' && !avatarUrl && !Icon && jsx(
|
|
19
|
+
return (jsx(MenuItem, { ...props, "data-testid": itemTestId, className: (state) => cx('group block cursor-pointer px-1.5 py-px outline-hidden', state.isDisabled && 'cursor-not-allowed opacity-50', typeof props.className === 'function' ? props.className(state) : props.className), children: (state) => (jsxs("div", { className: cx('relative flex items-center rounded-md px-2.5 py-2 outline-focus-ring transition duration-100 ease-linear', !state.isDisabled && 'group-hover:bg-primary_hover', state.isFocused && 'bg-primary_hover', state.isFocusVisible && 'outline-2 -outline-offset-2', state.hasSubmenu && 'pr-1.5'), children: [state.selectionMode !== 'none' && !avatarUrl && !Icon && (jsx(DropdownSelectionIndicator, { selectionIndicator: selectionIndicator, isSelected: state.isSelected, hasSubmenu: state.hasSubmenu, className: "mr-2" })), avatarUrl && (jsx("div", { className: "mr-2 flex size-4 items-center justify-center", children: jsx(Avatar, { "aria-hidden": "true", size: "xs", src: avatarUrl, alt: label, className: "size-5" }) })), Icon && jsx(Icon, { "aria-hidden": "true", className: "mr-2 size-4 shrink-0 stroke-[2.25px] text-fg-quaternary" }), jsx("span", { className: cx('grow truncate text-sm font-semibold text-secondary', state.isFocused && 'text-secondary_hover'), children: label || (typeof children === 'function' ? children(state) : children) }), addon && jsx("span", { className: "ml-1 shrink-0 pr-1 text-xs font-medium text-quaternary", children: addon }), state.selectionMode !== 'none' && (avatarUrl || Icon) && (jsx(DropdownSelectionIndicator, { selectionIndicator: selectionIndicator, isSelected: state.isSelected, hasSubmenu: state.hasSubmenu, className: "ml-1" })), state.hasSubmenu && jsx(ChevronRight, { "aria-hidden": "true", className: "ml-auto size-4 shrink-0 stroke-[2.25px] text-fg-quaternary" })] })) }));
|
|
46
20
|
};
|
|
47
21
|
const DropdownMenu = ({ 'data-testid': dataTestId, ...props }) => {
|
|
48
22
|
const prefix = useTestIdPrefix();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../../src/components/molecules/Dropdown/index.tsx"],"sourcesContent":[null],"names":["_jsx","AriaMenuItem","_jsxs","AriaMenu","AriaSeparator","AriaMenuTrigger","AriaMenuSection","AriaHeader"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../../src/components/molecules/Dropdown/index.tsx"],"sourcesContent":[null],"names":["_jsx","AriaMenuItem","_jsxs","AriaMenu","AriaSeparator","AriaMenuTrigger","AriaMenuSection","AriaHeader"],"mappings":";;;;;;;;;;;AA4CA,MAAM,YAAY,GAAG,CAAC,EACpB,KAAK,EACL,QAAQ,EACR,KAAK,EACL,IAAI,EAAE,IAAI,EACV,SAAS,EACT,QAAQ,EACR,kBAAkB,GAAG,WAAW,EAChC,aAAa,EAAE,UAAU,EACzB,GAAG,KAAK,EACU,KAAI;AACtB,IAAA,MAAM,MAAM,GAAG,eAAe,EAAE;AAChC,IAAA,MAAM,MAAM,GAAG,mBAAmB,CAAC,KAAK,C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AAE,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,WAAW,EAAE,YAAY,EAAA,aAAA,EAAe,gBAAgB,EAAA,CAAI;AACzI,CAAC;AAUD,MAAM,YAAY,GAAG,CAAC,EAAE,QAAQ,EAAE,aAAa,EAAE,UAAU,EAAE,GAAG,KAAK,EAAqB,KAAI;AAC5F,IAAA,MAAM,UAAU,GAAG,iBAAiB,CAAC,EAAE,MAAM,EAAE,UAAU,EAAE,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,UAAU,EAAE,CAAC;AAEvG,IAAA,QACEA,GAAA,CAAC,cAAc,EAAA,EAAC,KAAK,EAAE,UAAU,EAAA,QAAA,EAC/BA,GAAA,CAACK,WAAe,OAAK,KAAK,EAAA,QAAA,EAAG,QAAQ,EAAA,CAAmB,EAAA,CACzC;AAErB,CAAC;AAED;;;;;;;;AAQG;AACI,MAAM,QAAQ,GAAG;AACtB,IAAA,IAAI,EAAE,YAAY;AAClB,IAAA,OAAO,EAAE,eAAe;AACxB,IAAA,IAAI,EAAE,YAAY;AAClB,IAAA,OAAO,EAAEC,WAAe;AACxB,IAAA,aAAa,EAAEC,MAAU;AACzB,IAAA,IAAI,EAAE,YAAY;AAClB,IAAA,SAAS,EAAE,iBAAiB;AAC5B,IAAA,UAAU,EAAE,kBAAkB;;;"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var testIdUtils = require('@flipdish/ui-library/utilities/testIdUtils');
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Chooses the test-id segment for a dropdown item.
|
|
7
|
+
*
|
|
8
|
+
* @param id The item's `id`, when one was set. `0` counts; only a missing id is skipped.
|
|
9
|
+
* @param label The visible label. Used when `id` is missing and the label is text.
|
|
10
|
+
* @param children The item's children. Used when they are a string and neither `id` nor a text label is set.
|
|
11
|
+
* @returns A slug of the first of those that is set, or `item` when none is.
|
|
12
|
+
*/
|
|
13
|
+
const dropdownItemSegment = (id, label, children) => {
|
|
14
|
+
if (id !== undefined)
|
|
15
|
+
return testIdUtils.slugifyTestId(String(id));
|
|
16
|
+
if (typeof label === 'string')
|
|
17
|
+
return testIdUtils.slugifyTestId(label);
|
|
18
|
+
if (typeof children === 'string')
|
|
19
|
+
return testIdUtils.slugifyTestId(children);
|
|
20
|
+
return 'item';
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
exports.dropdownItemSegment = dropdownItemSegment;
|
|
24
|
+
//# sourceMappingURL=dropdown.utils.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dropdown.utils.cjs","sources":["../../../../../src/components/molecules/Dropdown/utilities/dropdown.utils.ts"],"sourcesContent":[null],"names":["slugifyTestId"],"mappings":";;;;AAEA;;;;;;;AAOG;AACI,MAAM,mBAAmB,GAAG,CAAC,EAA+B,EAAE,KAAyB,EAAE,QAAiB,KAAY;IAC3H,IAAI,EAAE,KAAK,SAAS;AAAE,QAAA,OAAOA,yBAAa,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;IACtD,IAAI,OAAO,KAAK,KAAK,QAAQ;AAAE,QAAA,OAAOA,yBAAa,CAAC,KAAK,CAAC;IAC1D,IAAI,OAAO,QAAQ,KAAK,QAAQ;AAAE,QAAA,OAAOA,yBAAa,CAAC,QAAQ,CAAC;AAChE,IAAA,OAAO,MAAM;AACf;;"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Chooses the test-id segment for a dropdown item.
|
|
3
|
+
*
|
|
4
|
+
* @param id The item's `id`, when one was set. `0` counts; only a missing id is skipped.
|
|
5
|
+
* @param label The visible label. Used when `id` is missing and the label is text.
|
|
6
|
+
* @param children The item's children. Used when they are a string and neither `id` nor a text label is set.
|
|
7
|
+
* @returns A slug of the first of those that is set, or `item` when none is.
|
|
8
|
+
*/
|
|
9
|
+
export declare const dropdownItemSegment: (id: string | number | undefined, label: string | undefined, children: unknown) => string;
|
|
10
|
+
//# sourceMappingURL=dropdown.utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dropdown.utils.d.ts","sourceRoot":"","sources":["../../../../../src/components/molecules/Dropdown/utilities/dropdown.utils.ts"],"names":[],"mappings":"AAEA;;;;;;;GAOG;AACH,eAAO,MAAM,mBAAmB,GAAI,IAAI,MAAM,GAAG,MAAM,GAAG,SAAS,EAAE,OAAO,MAAM,GAAG,SAAS,EAAE,UAAU,OAAO,KAAG,MAKnH,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { slugifyTestId } from '@flipdish/ui-library/utilities/testIdUtils';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Chooses the test-id segment for a dropdown item.
|
|
5
|
+
*
|
|
6
|
+
* @param id The item's `id`, when one was set. `0` counts; only a missing id is skipped.
|
|
7
|
+
* @param label The visible label. Used when `id` is missing and the label is text.
|
|
8
|
+
* @param children The item's children. Used when they are a string and neither `id` nor a text label is set.
|
|
9
|
+
* @returns A slug of the first of those that is set, or `item` when none is.
|
|
10
|
+
*/
|
|
11
|
+
const dropdownItemSegment = (id, label, children) => {
|
|
12
|
+
if (id !== undefined)
|
|
13
|
+
return slugifyTestId(String(id));
|
|
14
|
+
if (typeof label === 'string')
|
|
15
|
+
return slugifyTestId(label);
|
|
16
|
+
if (typeof children === 'string')
|
|
17
|
+
return slugifyTestId(children);
|
|
18
|
+
return 'item';
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export { dropdownItemSegment };
|
|
22
|
+
//# sourceMappingURL=dropdown.utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dropdown.utils.js","sources":["../../../../../src/components/molecules/Dropdown/utilities/dropdown.utils.ts"],"sourcesContent":[null],"names":[],"mappings":";;AAEA;;;;;;;AAOG;AACI,MAAM,mBAAmB,GAAG,CAAC,EAA+B,EAAE,KAAyB,EAAE,QAAiB,KAAY;IAC3H,IAAI,EAAE,KAAK,SAAS;AAAE,QAAA,OAAO,aAAa,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;IACtD,IAAI,OAAO,KAAK,KAAK,QAAQ;AAAE,QAAA,OAAO,aAAa,CAAC,KAAK,CAAC;IAC1D,IAAI,OAAO,QAAQ,KAAK,QAAQ;AAAE,QAAA,OAAO,aAAa,CAAC,QAAQ,CAAC;AAChE,IAAA,OAAO,MAAM;AACf;;"}
|
|
@@ -2,13 +2,16 @@
|
|
|
2
2
|
|
|
3
3
|
var React = require('react');
|
|
4
4
|
|
|
5
|
+
// The ring shows for keyboard focus only, as on every other focus target in the library.
|
|
6
|
+
const FOCUS_TARGET_CLASSES = 'outline-focus-ring focus-visible:outline-2 focus-visible:outline-offset-2';
|
|
5
7
|
/**
|
|
6
8
|
* Keeps keyboard focus in place across a retry. A "Try again" button unmounts once the data arrives, and focus would
|
|
7
9
|
* otherwise fall back to the top of the page; use it wherever a load error is replaced by the content it failed to load.
|
|
8
10
|
*
|
|
9
11
|
* @param retry Starts the failed request again.
|
|
10
|
-
* @returns `retryLoad` for the retry button, and
|
|
11
|
-
*
|
|
12
|
+
* @returns `retryLoad` for the retry button, and for the element that replaces the error either `contentProps` to spread
|
|
13
|
+
* onto it (the ref, `tabIndex={-1}` and a focus ring) or `contentRef` alone when it is already focusable, as `Form` is.
|
|
14
|
+
* That element takes focus when it mounts after a retry, unless the user has moved focus elsewhere.
|
|
12
15
|
*/
|
|
13
16
|
const useFocusAfterRetry = (retry) => {
|
|
14
17
|
const hasRetried = React.useRef(false);
|
|
@@ -24,7 +27,8 @@ const useFocusAfterRetry = (retry) => {
|
|
|
24
27
|
if (content.ownerDocument.activeElement === content.ownerDocument.body)
|
|
25
28
|
content.focus();
|
|
26
29
|
};
|
|
27
|
-
|
|
30
|
+
const contentProps = { ref: contentRef, tabIndex: -1, className: FOCUS_TARGET_CLASSES };
|
|
31
|
+
return { retryLoad, contentRef, contentProps };
|
|
28
32
|
};
|
|
29
33
|
|
|
30
34
|
exports.useFocusAfterRetry = useFocusAfterRetry;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sources":["../../../src/hooks/useFocusAfterRetry/index.ts"],"sourcesContent":[null],"names":["useRef"],"mappings":";;;;AAIA
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../../../src/hooks/useFocusAfterRetry/index.ts"],"sourcesContent":[null],"names":["useRef"],"mappings":";;;;AAIA;AACA,MAAM,oBAAoB,GAAG,2EAA2E;AAExG;;;;;;;;AAQG;AACI,MAAM,kBAAkB,GAAG,CAAC,KAAoB,KAAI;AACzD,IAAA,MAAM,UAAU,GAAGA,YAAM,CAAC,KAAK,CAAC;IAEhC,MAAM,SAAS,GAAG,MAAK;AACrB,QAAA,UAAU,CAAC,OAAO,GAAG,IAAI;AACzB,QAAA,KAAK,EAAE;AACT,IAAA,CAAC;AAED,IAAA,MAAM,UAAU,GAAG,CAAC,OAA2B,KAAI;AACjD,QAAA,IAAI,CAAC,OAAO,IAAI,CAAC,UAAU,CAAC,OAAO;YAAE;AACrC,QAAA,UAAU,CAAC,OAAO,GAAG,KAAK;;QAE1B,IAAI,OAAO,CAAC,aAAa,CAAC,aAAa,KAAK,OAAO,CAAC,aAAa,CAAC,IAAI;YAAE,OAAO,CAAC,KAAK,EAAE;AACzF,IAAA,CAAC;AAED,IAAA,MAAM,YAAY,GAAG,EAAE,GAAG,EAAE,UAAU,EAAE,QAAQ,EAAE,EAAE,EAAE,SAAS,EAAE,oBAAoB,EAAW;AAEhG,IAAA,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,YAAY,EAAE;AAChD;;"}
|
|
@@ -3,11 +3,17 @@
|
|
|
3
3
|
* otherwise fall back to the top of the page; use it wherever a load error is replaced by the content it failed to load.
|
|
4
4
|
*
|
|
5
5
|
* @param retry Starts the failed request again.
|
|
6
|
-
* @returns `retryLoad` for the retry button, and
|
|
7
|
-
*
|
|
6
|
+
* @returns `retryLoad` for the retry button, and for the element that replaces the error either `contentProps` to spread
|
|
7
|
+
* onto it (the ref, `tabIndex={-1}` and a focus ring) or `contentRef` alone when it is already focusable, as `Form` is.
|
|
8
|
+
* That element takes focus when it mounts after a retry, unless the user has moved focus elsewhere.
|
|
8
9
|
*/
|
|
9
10
|
export declare const useFocusAfterRetry: (retry: () => unknown) => {
|
|
10
11
|
retryLoad: () => void;
|
|
11
12
|
contentRef: (content: HTMLElement | null) => void;
|
|
13
|
+
contentProps: {
|
|
14
|
+
readonly ref: (content: HTMLElement | null) => void;
|
|
15
|
+
readonly tabIndex: -1;
|
|
16
|
+
readonly className: "outline-focus-ring focus-visible:outline-2 focus-visible:outline-offset-2";
|
|
17
|
+
};
|
|
12
18
|
};
|
|
13
19
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/hooks/useFocusAfterRetry/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/hooks/useFocusAfterRetry/index.ts"],"names":[],"mappings":"AAOA;;;;;;;;GAQG;AACH,eAAO,MAAM,kBAAkB,GAAI,OAAO,MAAM,OAAO;;0BAQxB,WAAW,GAAG,IAAI;;gCAAlB,WAAW,GAAG,IAAI;;;;CAUhD,CAAC"}
|
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
import { useRef } from 'react';
|
|
2
2
|
|
|
3
|
+
// The ring shows for keyboard focus only, as on every other focus target in the library.
|
|
4
|
+
const FOCUS_TARGET_CLASSES = 'outline-focus-ring focus-visible:outline-2 focus-visible:outline-offset-2';
|
|
3
5
|
/**
|
|
4
6
|
* Keeps keyboard focus in place across a retry. A "Try again" button unmounts once the data arrives, and focus would
|
|
5
7
|
* otherwise fall back to the top of the page; use it wherever a load error is replaced by the content it failed to load.
|
|
6
8
|
*
|
|
7
9
|
* @param retry Starts the failed request again.
|
|
8
|
-
* @returns `retryLoad` for the retry button, and
|
|
9
|
-
*
|
|
10
|
+
* @returns `retryLoad` for the retry button, and for the element that replaces the error either `contentProps` to spread
|
|
11
|
+
* onto it (the ref, `tabIndex={-1}` and a focus ring) or `contentRef` alone when it is already focusable, as `Form` is.
|
|
12
|
+
* That element takes focus when it mounts after a retry, unless the user has moved focus elsewhere.
|
|
10
13
|
*/
|
|
11
14
|
const useFocusAfterRetry = (retry) => {
|
|
12
15
|
const hasRetried = useRef(false);
|
|
@@ -22,7 +25,8 @@ const useFocusAfterRetry = (retry) => {
|
|
|
22
25
|
if (content.ownerDocument.activeElement === content.ownerDocument.body)
|
|
23
26
|
content.focus();
|
|
24
27
|
};
|
|
25
|
-
|
|
28
|
+
const contentProps = { ref: contentRef, tabIndex: -1, className: FOCUS_TARGET_CLASSES };
|
|
29
|
+
return { retryLoad, contentRef, contentProps };
|
|
26
30
|
};
|
|
27
31
|
|
|
28
32
|
export { useFocusAfterRetry };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../src/hooks/useFocusAfterRetry/index.ts"],"sourcesContent":[null],"names":[],"mappings":";;AAIA
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../src/hooks/useFocusAfterRetry/index.ts"],"sourcesContent":[null],"names":[],"mappings":";;AAIA;AACA,MAAM,oBAAoB,GAAG,2EAA2E;AAExG;;;;;;;;AAQG;AACI,MAAM,kBAAkB,GAAG,CAAC,KAAoB,KAAI;AACzD,IAAA,MAAM,UAAU,GAAG,MAAM,CAAC,KAAK,CAAC;IAEhC,MAAM,SAAS,GAAG,MAAK;AACrB,QAAA,UAAU,CAAC,OAAO,GAAG,IAAI;AACzB,QAAA,KAAK,EAAE;AACT,IAAA,CAAC;AAED,IAAA,MAAM,UAAU,GAAG,CAAC,OAA2B,KAAI;AACjD,QAAA,IAAI,CAAC,OAAO,IAAI,CAAC,UAAU,CAAC,OAAO;YAAE;AACrC,QAAA,UAAU,CAAC,OAAO,GAAG,KAAK;;QAE1B,IAAI,OAAO,CAAC,aAAa,CAAC,aAAa,KAAK,OAAO,CAAC,aAAa,CAAC,IAAI;YAAE,OAAO,CAAC,KAAK,EAAE;AACzF,IAAA,CAAC;AAED,IAAA,MAAM,YAAY,GAAG,EAAE,GAAG,EAAE,UAAU,EAAE,QAAQ,EAAE,EAAE,EAAE,SAAS,EAAE,oBAAoB,EAAW;AAEhG,IAAA,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,YAAY,EAAE;AAChD;;"}
|
|
@@ -41,6 +41,12 @@ var Enter_digits_only = {
|
|
|
41
41
|
var Select_this_box_to_continue = {
|
|
42
42
|
value: "Select this box to continue"
|
|
43
43
|
};
|
|
44
|
+
var Enter_an_Eircode_such_as_D02_X285 = {
|
|
45
|
+
value: "Enter an Eircode, such as D02 X285"
|
|
46
|
+
};
|
|
47
|
+
var Enter_a_UK_postcode_such_as_SW1A_1AA = {
|
|
48
|
+
value: "Enter a UK postcode, such as SW1A 1AA"
|
|
49
|
+
};
|
|
44
50
|
var en = {
|
|
45
51
|
This_field_is_required: This_field_is_required,
|
|
46
52
|
"Enter_{min}_or_more_characters": {
|
|
@@ -78,11 +84,23 @@ var en = {
|
|
|
78
84
|
Select_this_box_to_continue: Select_this_box_to_continue,
|
|
79
85
|
"Choose_{max}_or_fewer": {
|
|
80
86
|
value: "Choose {max} or fewer"
|
|
87
|
+
},
|
|
88
|
+
Enter_an_Eircode_such_as_D02_X285: Enter_an_Eircode_such_as_D02_X285,
|
|
89
|
+
Enter_a_UK_postcode_such_as_SW1A_1AA: Enter_a_UK_postcode_such_as_SW1A_1AA,
|
|
90
|
+
"Enter_a_postcode_such_as_{example}": {
|
|
91
|
+
value: "Enter a postcode, such as {example}"
|
|
92
|
+
},
|
|
93
|
+
"Enter_a_postal_code_such_as_{example}": {
|
|
94
|
+
value: "Enter a postal code, such as {example}"
|
|
95
|
+
},
|
|
96
|
+
"Enter_a_ZIP_code_such_as_{example}": {
|
|
97
|
+
value: "Enter a ZIP code, such as {example}"
|
|
81
98
|
}
|
|
82
99
|
};
|
|
83
100
|
|
|
84
101
|
exports.Choose_an_option = Choose_an_option;
|
|
85
102
|
exports.Choose_at_least_one_option = Choose_at_least_one_option;
|
|
103
|
+
exports.Enter_a_UK_postcode_such_as_SW1A_1AA = Enter_a_UK_postcode_such_as_SW1A_1AA;
|
|
86
104
|
exports.Enter_a_number = Enter_a_number;
|
|
87
105
|
exports.Enter_a_valid_amount = Enter_a_valid_amount;
|
|
88
106
|
exports.Enter_a_valid_colour = Enter_a_valid_colour;
|
|
@@ -91,6 +109,7 @@ exports.Enter_a_valid_phone_number = Enter_a_valid_phone_number;
|
|
|
91
109
|
exports.Enter_a_valid_value = Enter_a_valid_value;
|
|
92
110
|
exports.Enter_a_valid_web_address = Enter_a_valid_web_address;
|
|
93
111
|
exports.Enter_a_whole_number = Enter_a_whole_number;
|
|
112
|
+
exports.Enter_an_Eircode_such_as_D02_X285 = Enter_an_Eircode_such_as_D02_X285;
|
|
94
113
|
exports.Enter_digits_only = Enter_digits_only;
|
|
95
114
|
exports.Select_this_box_to_continue = Select_this_box_to_continue;
|
|
96
115
|
exports.This_field_is_required = This_field_is_required;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"en.json.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"en.json.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|