@flipdish/ui-library 0.49.0 → 0.50.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/dist/components/atoms/Button/components/ButtonIcon.cjs +17 -0
- package/dist/components/atoms/Button/components/ButtonIcon.cjs.map +1 -0
- package/dist/components/atoms/Button/components/ButtonIcon.d.ts +14 -0
- package/dist/components/atoms/Button/components/ButtonIcon.d.ts.map +1 -0
- package/dist/components/atoms/Button/components/ButtonIcon.js +15 -0
- package/dist/components/atoms/Button/components/ButtonIcon.js.map +1 -0
- package/dist/components/atoms/Button/components/ButtonSpinner.cjs +11 -0
- package/dist/components/atoms/Button/components/ButtonSpinner.cjs.map +1 -0
- package/dist/components/atoms/Button/components/ButtonSpinner.d.ts +8 -0
- package/dist/components/atoms/Button/components/ButtonSpinner.d.ts.map +1 -0
- package/dist/components/atoms/Button/components/ButtonSpinner.js +9 -0
- package/dist/components/atoms/Button/components/ButtonSpinner.js.map +1 -0
- package/dist/components/atoms/Button/index.cjs +6 -6
- package/dist/components/atoms/Button/index.cjs.map +1 -1
- package/dist/components/atoms/Button/index.d.ts +2 -0
- package/dist/components/atoms/Button/index.d.ts.map +1 -1
- package/dist/components/atoms/Button/index.js +6 -6
- package/dist/components/atoms/Button/index.js.map +1 -1
- package/dist/components/atoms/Checkbox/index.cjs +22 -2
- package/dist/components/atoms/Checkbox/index.cjs.map +1 -1
- package/dist/components/atoms/Checkbox/index.d.ts +23 -4
- package/dist/components/atoms/Checkbox/index.d.ts.map +1 -1
- package/dist/components/atoms/Checkbox/index.js +24 -5
- package/dist/components/atoms/Checkbox/index.js.map +1 -1
- package/dist/components/atoms/Input/index.cjs +0 -1
- package/dist/components/atoms/Input/index.cjs.map +1 -1
- package/dist/components/atoms/Input/index.d.ts.map +1 -1
- package/dist/components/atoms/Input/index.js +0 -1
- package/dist/components/atoms/Input/index.js.map +1 -1
- package/dist/components/atoms/RadioButton/index.cjs.map +1 -1
- package/dist/components/atoms/RadioButton/index.d.ts +1 -0
- package/dist/components/atoms/RadioButton/index.d.ts.map +1 -1
- package/dist/components/atoms/RadioButton/index.js.map +1 -1
- package/dist/components/atoms/Slider/index.cjs +9 -3
- package/dist/components/atoms/Slider/index.cjs.map +1 -1
- package/dist/components/atoms/Slider/index.d.ts +3 -1
- package/dist/components/atoms/Slider/index.d.ts.map +1 -1
- package/dist/components/atoms/Slider/index.js +10 -4
- package/dist/components/atoms/Slider/index.js.map +1 -1
- package/dist/components/atoms/Toggle/index.cjs +6 -2
- package/dist/components/atoms/Toggle/index.cjs.map +1 -1
- package/dist/components/atoms/Toggle/index.d.ts.map +1 -1
- package/dist/components/atoms/Toggle/index.js +6 -2
- package/dist/components/atoms/Toggle/index.js.map +1 -1
- package/dist/components/molecules/EmptyState/index.cjs +8 -0
- package/dist/components/molecules/EmptyState/index.cjs.map +1 -1
- package/dist/components/molecules/EmptyState/index.d.ts +19 -0
- package/dist/components/molecules/EmptyState/index.d.ts.map +1 -1
- package/dist/components/molecules/EmptyState/index.js +10 -3
- package/dist/components/molecules/EmptyState/index.js.map +1 -1
- package/dist/components/molecules/RadioGroup/components/RadioGroupAvatar.cjs +7 -1
- package/dist/components/molecules/RadioGroup/components/RadioGroupAvatar.cjs.map +1 -1
- package/dist/components/molecules/RadioGroup/components/RadioGroupAvatar.d.ts.map +1 -1
- package/dist/components/molecules/RadioGroup/components/RadioGroupAvatar.js +8 -2
- package/dist/components/molecules/RadioGroup/components/RadioGroupAvatar.js.map +1 -1
- package/dist/components/molecules/RadioGroup/components/RadioGroupCheckbox.cjs +7 -1
- package/dist/components/molecules/RadioGroup/components/RadioGroupCheckbox.cjs.map +1 -1
- package/dist/components/molecules/RadioGroup/components/RadioGroupCheckbox.d.ts.map +1 -1
- package/dist/components/molecules/RadioGroup/components/RadioGroupCheckbox.js +8 -2
- package/dist/components/molecules/RadioGroup/components/RadioGroupCheckbox.js.map +1 -1
- package/dist/components/molecules/RadioGroup/components/RadioGroupIconCard.cjs +13 -1
- package/dist/components/molecules/RadioGroup/components/RadioGroupIconCard.cjs.map +1 -1
- package/dist/components/molecules/RadioGroup/components/RadioGroupIconCard.d.ts.map +1 -1
- package/dist/components/molecules/RadioGroup/components/RadioGroupIconCard.js +13 -1
- package/dist/components/molecules/RadioGroup/components/RadioGroupIconCard.js.map +1 -1
- package/dist/components/molecules/RadioGroup/components/RadioGroupIconSimple.cjs +7 -1
- package/dist/components/molecules/RadioGroup/components/RadioGroupIconSimple.cjs.map +1 -1
- package/dist/components/molecules/RadioGroup/components/RadioGroupIconSimple.d.ts.map +1 -1
- package/dist/components/molecules/RadioGroup/components/RadioGroupIconSimple.js +8 -2
- package/dist/components/molecules/RadioGroup/components/RadioGroupIconSimple.js.map +1 -1
- package/dist/components/molecules/RadioGroup/components/RadioGroupPaymentIcon.cjs +6 -1
- package/dist/components/molecules/RadioGroup/components/RadioGroupPaymentIcon.cjs.map +1 -1
- package/dist/components/molecules/RadioGroup/components/RadioGroupPaymentIcon.d.ts.map +1 -1
- package/dist/components/molecules/RadioGroup/components/RadioGroupPaymentIcon.js +7 -2
- package/dist/components/molecules/RadioGroup/components/RadioGroupPaymentIcon.js.map +1 -1
- package/dist/components/molecules/RadioGroup/components/RadioGroupRadioButton.cjs +10 -3
- package/dist/components/molecules/RadioGroup/components/RadioGroupRadioButton.cjs.map +1 -1
- package/dist/components/molecules/RadioGroup/components/RadioGroupRadioButton.d.ts +6 -4
- package/dist/components/molecules/RadioGroup/components/RadioGroupRadioButton.d.ts.map +1 -1
- package/dist/components/molecules/RadioGroup/components/RadioGroupRadioButton.js +11 -4
- package/dist/components/molecules/RadioGroup/components/RadioGroupRadioButton.js.map +1 -1
- package/dist/components/molecules/RadioGroup/hooks/useOptionIds.cjs +24 -0
- package/dist/components/molecules/RadioGroup/hooks/useOptionIds.cjs.map +1 -0
- package/dist/components/molecules/RadioGroup/hooks/useOptionIds.d.ts +10 -0
- package/dist/components/molecules/RadioGroup/hooks/useOptionIds.d.ts.map +1 -0
- package/dist/components/molecules/RadioGroup/hooks/useOptionIds.js +22 -0
- package/dist/components/molecules/RadioGroup/hooks/useOptionIds.js.map +1 -0
- package/dist/components/molecules/RadioGroup/index.d.ts +1 -1
- package/dist/components/molecules/RadioGroup/index.d.ts.map +1 -1
- package/dist/components/molecules/RadioGroup/radioGroup.types.d.ts +14 -0
- package/dist/components/molecules/RadioGroup/radioGroup.types.d.ts.map +1 -1
- package/dist/components/molecules/Select/components/Combobox.cjs +2 -1
- package/dist/components/molecules/Select/components/Combobox.cjs.map +1 -1
- package/dist/components/molecules/Select/components/Combobox.d.ts +2 -1
- package/dist/components/molecules/Select/components/Combobox.d.ts.map +1 -1
- package/dist/components/molecules/Select/components/Combobox.js +2 -1
- package/dist/components/molecules/Select/components/Combobox.js.map +1 -1
- package/dist/components/molecules/Select/components/MultiSelect.cjs +3 -2
- package/dist/components/molecules/Select/components/MultiSelect.cjs.map +1 -1
- package/dist/components/molecules/Select/components/MultiSelect.d.ts +3 -3
- package/dist/components/molecules/Select/components/MultiSelect.d.ts.map +1 -1
- package/dist/components/molecules/Select/components/MultiSelect.js +5 -4
- package/dist/components/molecules/Select/components/MultiSelect.js.map +1 -1
- package/dist/components/molecules/Select/components/SelectItem.cjs +8 -0
- package/dist/components/molecules/Select/components/SelectItem.cjs.map +1 -1
- package/dist/components/molecules/Select/components/SelectItem.d.ts +7 -0
- package/dist/components/molecules/Select/components/SelectItem.d.ts.map +1 -1
- package/dist/components/molecules/Select/components/SelectItem.js +8 -1
- package/dist/components/molecules/Select/components/SelectItem.js.map +1 -1
- package/dist/components/molecules/Select/index.cjs +1 -1
- package/dist/components/molecules/Select/index.cjs.map +1 -1
- package/dist/components/molecules/Select/index.d.ts +3 -3
- package/dist/components/molecules/Select/index.d.ts.map +1 -1
- package/dist/components/molecules/Select/index.js +2 -2
- package/dist/components/molecules/Select/index.js.map +1 -1
- package/dist/components/organisms/ColorPicker/colorPicker.utils.cjs +26 -0
- package/dist/components/organisms/ColorPicker/colorPicker.utils.cjs.map +1 -1
- package/dist/components/organisms/ColorPicker/colorPicker.utils.d.ts +15 -0
- package/dist/components/organisms/ColorPicker/colorPicker.utils.d.ts.map +1 -1
- package/dist/components/organisms/ColorPicker/colorPicker.utils.js +25 -1
- package/dist/components/organisms/ColorPicker/colorPicker.utils.js.map +1 -1
- package/dist/components/organisms/ColorPicker/components/ColorPickerDialog.cjs +15 -0
- package/dist/components/organisms/ColorPicker/components/ColorPickerDialog.cjs.map +1 -0
- package/dist/components/organisms/ColorPicker/components/ColorPickerDialog.d.ts +12 -0
- package/dist/components/organisms/ColorPicker/components/ColorPickerDialog.d.ts.map +1 -0
- package/dist/components/organisms/ColorPicker/components/ColorPickerDialog.js +13 -0
- package/dist/components/organisms/ColorPicker/components/ColorPickerDialog.js.map +1 -0
- package/dist/components/organisms/ColorPicker/components/ColorPickerField.cjs +51 -0
- package/dist/components/organisms/ColorPicker/components/ColorPickerField.cjs.map +1 -0
- package/dist/components/organisms/ColorPicker/components/ColorPickerField.d.ts +48 -0
- package/dist/components/organisms/ColorPicker/components/ColorPickerField.d.ts.map +1 -0
- package/dist/components/organisms/ColorPicker/components/ColorPickerField.js +49 -0
- package/dist/components/organisms/ColorPicker/components/ColorPickerField.js.map +1 -0
- package/dist/components/organisms/ColorPicker/hooks/useColorFieldEdit.cjs +69 -0
- package/dist/components/organisms/ColorPicker/hooks/useColorFieldEdit.cjs.map +1 -0
- package/dist/components/organisms/ColorPicker/hooks/useColorFieldEdit.d.ts +29 -0
- package/dist/components/organisms/ColorPicker/hooks/useColorFieldEdit.d.ts.map +1 -0
- package/dist/components/organisms/ColorPicker/hooks/useColorFieldEdit.js +67 -0
- package/dist/components/organisms/ColorPicker/hooks/useColorFieldEdit.js.map +1 -0
- package/dist/components/organisms/ColorPicker/index.cjs +6 -7
- package/dist/components/organisms/ColorPicker/index.cjs.map +1 -1
- package/dist/components/organisms/ColorPicker/index.d.ts +4 -6
- package/dist/components/organisms/ColorPicker/index.d.ts.map +1 -1
- package/dist/components/organisms/ColorPicker/index.js +6 -7
- package/dist/components/organisms/ColorPicker/index.js.map +1 -1
- package/dist/components/organisms/DatePicker/components/DateRangePicker.cjs +17 -13
- package/dist/components/organisms/DatePicker/components/DateRangePicker.cjs.map +1 -1
- package/dist/components/organisms/DatePicker/components/DateRangePicker.d.ts +8 -1
- package/dist/components/organisms/DatePicker/components/DateRangePicker.d.ts.map +1 -1
- package/dist/components/organisms/DatePicker/components/DateRangePicker.js +17 -13
- package/dist/components/organisms/DatePicker/components/DateRangePicker.js.map +1 -1
- package/dist/components/organisms/DatePicker/index.cjs +14 -10
- package/dist/components/organisms/DatePicker/index.cjs.map +1 -1
- package/dist/components/organisms/DatePicker/index.d.ts +8 -1
- package/dist/components/organisms/DatePicker/index.d.ts.map +1 -1
- package/dist/components/organisms/DatePicker/index.js +14 -10
- package/dist/components/organisms/DatePicker/index.js.map +1 -1
- package/dist/hooks/useFocusAfterRetry/index.cjs +31 -0
- package/dist/hooks/useFocusAfterRetry/index.cjs.map +1 -0
- package/dist/hooks/useFocusAfterRetry/index.d.ts +13 -0
- package/dist/hooks/useFocusAfterRetry/index.d.ts.map +1 -0
- package/dist/hooks/useFocusAfterRetry/index.js +29 -0
- package/dist/hooks/useFocusAfterRetry/index.js.map +1 -0
- package/dist/native/components/atoms/Button/index.d.ts +2 -0
- package/dist/native/components/atoms/Button/index.d.ts.map +1 -1
- package/dist/native/components/atoms/Button/index.js +5 -3
- package/dist/native/components/atoms/Button/index.js.map +1 -1
- package/dist/native/components/atoms/Checkbox/index.d.ts +35 -3
- package/dist/native/components/atoms/Checkbox/index.d.ts.map +1 -1
- package/dist/native/components/atoms/Checkbox/index.js +47 -10
- package/dist/native/components/atoms/Checkbox/index.js.map +1 -1
- package/dist/native/hooks/useFocusAfterRetry/index.d.ts +12 -0
- package/dist/utilities/__internal__/ariaIdsUtils/ariaIds.utils.cjs +12 -0
- package/dist/utilities/__internal__/ariaIdsUtils/ariaIds.utils.cjs.map +1 -0
- package/dist/utilities/__internal__/ariaIdsUtils/ariaIds.utils.d.ts +8 -0
- package/dist/utilities/__internal__/ariaIdsUtils/ariaIds.utils.d.ts.map +1 -0
- package/dist/utilities/__internal__/ariaIdsUtils/ariaIds.utils.js +10 -0
- package/dist/utilities/__internal__/ariaIdsUtils/ariaIds.utils.js.map +1 -0
- package/dist/utilities/__internal__/refUtils/ref.utils.cjs +22 -0
- package/dist/utilities/__internal__/refUtils/ref.utils.cjs.map +1 -0
- package/dist/utilities/__internal__/refUtils/ref.utils.d.ts +15 -0
- package/dist/utilities/__internal__/refUtils/ref.utils.d.ts.map +1 -0
- package/dist/utilities/__internal__/refUtils/ref.utils.js +20 -0
- package/dist/utilities/__internal__/refUtils/ref.utils.js.map +1 -0
- package/package.json +2 -2
|
@@ -3,6 +3,8 @@
|
|
|
3
3
|
var jsxRuntime = require('react/jsx-runtime');
|
|
4
4
|
var uiIcons = require('@flipdish/ui-icons');
|
|
5
5
|
var Button = require('@flipdish/ui-library/components/atoms/Button');
|
|
6
|
+
var Input = require('@flipdish/ui-library/components/atoms/Input');
|
|
7
|
+
var cx = require('@flipdish/ui-library/utilities/cx');
|
|
6
8
|
var testIdUtils = require('@flipdish/ui-library/utilities/testIdUtils');
|
|
7
9
|
var date = require('@internationalized/date');
|
|
8
10
|
var i18n = require('@react-aria/i18n');
|
|
@@ -21,7 +23,7 @@ const highlightedDates = [date.today(date.getLocalTimeZone())];
|
|
|
21
23
|
*
|
|
22
24
|
* @summary popover calendar for selecting a single date
|
|
23
25
|
*/
|
|
24
|
-
const DatePicker = ({ value: valueProp, defaultValue, onChange, onApply, onCancel, onOpenChange, size = 'sm', placeholder = 'Select date', 'data-testid': dataTestId, ...props }) => {
|
|
26
|
+
const DatePicker = ({ value: valueProp, defaultValue, onChange, onApply, onCancel, onOpenChange, size = 'sm', placeholder = 'Select date', label, hint, className, ref, 'data-testid': dataTestId, ...props }) => {
|
|
25
27
|
const formatter = i18n.useDateFormatter({
|
|
26
28
|
month: 'short',
|
|
27
29
|
day: 'numeric',
|
|
@@ -35,7 +37,9 @@ const DatePicker = ({ value: valueProp, defaultValue, onChange, onApply, onCance
|
|
|
35
37
|
const [draftValue, setDraftValue] = React.useState(value);
|
|
36
38
|
const formattedDate = value ? formatter.format(value.toDate(date.getLocalTimeZone())) : placeholder;
|
|
37
39
|
const rootTestId = testIdUtils.useResolvedTestId({ testId: dataTestId, segment: 'date-picker', rootName: 'date-picker' });
|
|
38
|
-
return (jsxRuntime.jsx(testIdUtils.TestIdProvider, { value: rootTestId, children: jsxRuntime.
|
|
40
|
+
return (jsxRuntime.jsx(testIdUtils.TestIdProvider, { value: rootTestId, children: jsxRuntime.jsx(reactAriaComponents.DatePicker
|
|
41
|
+
// A visible label names the picker; without one this default does, unless `aria-label` is passed.
|
|
42
|
+
, { "aria-label": label ? undefined : 'Date picker', shouldCloseOnSelect: false, ...props, ref: ref, className: (state) => cx.cx('flex flex-col items-start gap-1.5', typeof className === 'function' ? className(state) : className), value: draftValue, onChange: setDraftValue, onOpenChange: (isOpen) => {
|
|
39
43
|
// Re-seed the draft from the latest committed value every time the popover opens, so
|
|
40
44
|
// a stale in-progress edit from a previous Cancel/dismiss never leaks in, and a
|
|
41
45
|
// controlled `value` that changed while closed is always the starting point.
|
|
@@ -43,14 +47,14 @@ const DatePicker = ({ value: valueProp, defaultValue, onChange, onApply, onCance
|
|
|
43
47
|
setDraftValue(value);
|
|
44
48
|
}
|
|
45
49
|
onOpenChange?.(isOpen);
|
|
46
|
-
}, "data-testid": rootTestId, children: [jsxRuntime.jsx(reactAriaComponents.Group, { children: jsxRuntime.jsx(Button.Button, { size: size, color: "secondary", iconLeading: uiIcons.Calendar, "data-testid": testIdUtils.joinTestId(rootTestId, 'trigger'), children: formattedDate }) }), jsxRuntime.jsx(CalendarOverlay.CalendarOverlay, { "aria-label": props['aria-label'] ?? 'Date picker', "data-testid": testIdUtils.joinTestId(rootTestId, 'popover'), children: ({ close }) => (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx("div", { className: "flex w-full max-w-78 px-4 py-5 sm:max-w-82 sm:px-6", children: jsxRuntime.jsx(Calendar.Calendar, { highlightedDates: highlightedDates }) }), jsxRuntime.jsxs("div", { className: "sticky bottom-0 grid w-full grid-cols-2 gap-3 border-t border-secondary bg-primary px-4 pt-4 pb-[calc(1rem+env(safe-area-inset-bottom))]", children: [jsxRuntime.jsx(Button.Button, { size: "md", color: "secondary", "data-testid": testIdUtils.joinTestId(rootTestId, 'cancel'), onClick: () => {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
50
|
+
}, "data-testid": rootTestId, children: ({ isInvalid, isRequired }) => (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [label && jsxRuntime.jsx(Input.Label, { isRequired: isRequired, children: label }), jsxRuntime.jsx(reactAriaComponents.Group, { children: jsxRuntime.jsx(Button.Button, { size: size, color: "secondary", iconLeading: uiIcons.Calendar, className: cx.cx(isInvalid && 'ring-error_subtle'), "aria-label": `Calendar, ${formattedDate}`, "data-testid": testIdUtils.joinTestId(rootTestId, 'trigger'), children: formattedDate }) }), hint && jsxRuntime.jsx(Input.HintText, { isInvalid: isInvalid, children: hint }), jsxRuntime.jsx(CalendarOverlay.CalendarOverlay, { "aria-label": props['aria-label'] ?? label ?? 'Date picker', "data-testid": testIdUtils.joinTestId(rootTestId, 'popover'), children: ({ close }) => (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx("div", { className: "flex w-full max-w-78 px-4 py-5 sm:max-w-82 sm:px-6", children: jsxRuntime.jsx(Calendar.Calendar, { highlightedDates: highlightedDates }) }), jsxRuntime.jsxs("div", { className: "sticky bottom-0 grid w-full grid-cols-2 gap-3 border-t border-secondary bg-primary px-4 pt-4 pb-[calc(1rem+env(safe-area-inset-bottom))]", children: [jsxRuntime.jsx(Button.Button, { size: "md", color: "secondary", "data-testid": testIdUtils.joinTestId(rootTestId, 'cancel'), onClick: () => {
|
|
51
|
+
onCancel?.();
|
|
52
|
+
close();
|
|
53
|
+
}, children: "Cancel" }), jsxRuntime.jsx(Button.Button, { size: "md", color: "primary", "data-testid": testIdUtils.joinTestId(rootTestId, 'apply'), onClick: () => {
|
|
54
|
+
setValue(draftValue);
|
|
55
|
+
onApply?.();
|
|
56
|
+
close();
|
|
57
|
+
}, children: "Apply" })] })] })) })] })) }) }));
|
|
54
58
|
};
|
|
55
59
|
|
|
56
60
|
exports.DateRangePicker = DateRangePicker.DateRangePicker;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sources":["../../../../src/components/organisms/DatePicker/index.tsx"],"sourcesContent":[null],"names":["today","getLocalTimeZone","useDateFormatter","useControlledState","useState","useResolvedTestId","_jsx","TestIdProvider","_jsxs","
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../../../../src/components/organisms/DatePicker/index.tsx"],"sourcesContent":[null],"names":["today","getLocalTimeZone","useDateFormatter","useControlledState","useState","useResolvedTestId","_jsx","TestIdProvider","AriaDatePicker","cx","_jsxs","_Fragment","Label","AriaGroup","Button","CalendarIcon","joinTestId","HintText","CalendarOverlay","Calendar"],"mappings":";;;;;;;;;;;;;;;;;;AAmBA,MAAM,gBAAgB,GAAG,CAACA,UAAK,CAACC,qBAAgB,EAAE,CAAC,CAAC;AAqBpD;;;;;AAKG;MACU,UAAU,GAAG,CAAC,EACzB,KAAK,EAAE,SAAS,EAChB,YAAY,EACZ,QAAQ,EACR,OAAO,EACP,QAAQ,EACR,YAAY,EACZ,IAAI,GAAG,IAAI,EACX,WAAW,GAAG,aAAa,EAC3B,KAAK,EACL,IAAI,EACJ,SAAS,EACT,GAAG,EACH,aAAa,EAAE,UAAU,EACzB,GAAG,KAAK,EACQ,KAAI;IACpB,MAAM,SAAS,GAAGC,qBAAgB,CAAC;AACjC,QAAA,KAAK,EAAE,OAAO;AACd,QAAA,GAAG,EAAE,S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AAA,CAACQ,aAAM,IACL,IAAI,EAAC,IAAI,EACT,KAAK,EAAC,SAAS,EAAA,aAAA,EACFE,sBAAU,CAAC,UAAU,EAAE,OAAO,CAAC,EAC5C,OAAO,EAAE,MAAK;gDACZ,QAAQ,CAAC,UAAU,CAAC;gDACpB,OAAO,IAAI;AACX,gDAAA,KAAK,EAAE;4CACT,CAAC,EAAA,QAAA,EAAA,OAAA,EAAA,CAGM,CAAA,EAAA,CACL,CAAA,EAAA,CACL,CACJ,EAAA,CACe,IACjB,CACJ,EAAA,CACc,EAAA,CACF;AAErB;;;;"}
|
|
@@ -1,8 +1,15 @@
|
|
|
1
1
|
import { type ButtonProps } from '@flipdish/ui-library/components/atoms/Button';
|
|
2
|
+
import { type ReactNode, type Ref } from 'react';
|
|
2
3
|
import type { DatePickerProps as AriaDatePickerProps, DateValue } from 'react-aria-components';
|
|
3
4
|
export { DateRangePicker, type DateRangePickerProps } from './components/DateRangePicker';
|
|
4
5
|
export { RangeCalendar, type RangeCalendarProps } from './components/RangeCalendar';
|
|
5
6
|
export interface DatePickerProps extends AriaDatePickerProps<DateValue> {
|
|
7
|
+
/** Visible label above the trigger; it names the trigger and the calendar. When omitted, pass `aria-label`. */
|
|
8
|
+
label?: string;
|
|
9
|
+
/** Helper text beneath the trigger, read out as its description; shown as an error while `isInvalid` is set. */
|
|
10
|
+
hint?: ReactNode;
|
|
11
|
+
/** Ref forwarded to the root element, which holds the label, trigger and hint. */
|
|
12
|
+
ref?: Ref<HTMLDivElement>;
|
|
6
13
|
/** The function to call when the apply button is clicked. */
|
|
7
14
|
onApply?: () => void;
|
|
8
15
|
/** The function to call when the cancel button is clicked. */
|
|
@@ -20,5 +27,5 @@ export interface DatePickerProps extends AriaDatePickerProps<DateValue> {
|
|
|
20
27
|
*
|
|
21
28
|
* @summary popover calendar for selecting a single date
|
|
22
29
|
*/
|
|
23
|
-
export declare const DatePicker: ({ value: valueProp, defaultValue, onChange, onApply, onCancel, onOpenChange, size, placeholder, "data-testid": dataTestId, ...props }: DatePickerProps) => import("react").JSX.Element;
|
|
30
|
+
export declare const DatePicker: ({ value: valueProp, defaultValue, onChange, onApply, onCancel, onOpenChange, size, placeholder, label, hint, className, ref, "data-testid": dataTestId, ...props }: DatePickerProps) => import("react").JSX.Element;
|
|
24
31
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/organisms/DatePicker/index.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAU,KAAK,WAAW,EAAE,MAAM,8CAA8C,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/organisms/DatePicker/index.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAU,KAAK,WAAW,EAAE,MAAM,8CAA8C,CAAC;AAOxF,OAAO,EAAE,KAAK,SAAS,EAAE,KAAK,GAAG,EAAY,MAAM,OAAO,CAAC;AAC3D,OAAO,KAAK,EAAE,eAAe,IAAI,mBAAmB,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAK/F,OAAO,EAAE,eAAe,EAAE,KAAK,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AAC1F,OAAO,EAAE,aAAa,EAAE,KAAK,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAIpF,MAAM,WAAW,eAAgB,SAAQ,mBAAmB,CAAC,SAAS,CAAC;IACrE,+GAA+G;IAC/G,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,gHAAgH;IAChH,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB,kFAAkF;IAClF,GAAG,CAAC,EAAE,GAAG,CAAC,cAAc,CAAC,CAAC;IAC1B,6DAA6D;IAC7D,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IACrB,8DAA8D;IAC9D,QAAQ,CAAC,EAAE,MAAM,IAAI,CAAC;IACtB,4EAA4E;IAC5E,IAAI,CAAC,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IAC3B,6CAA6C;IAC7C,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,sHAAsH;IACtH,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED;;;;;GAKG;AACH,eAAO,MAAM,UAAU,GAAI,oKAexB,eAAe,gCAiGjB,CAAC"}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
2
2
|
import { Calendar } from '@flipdish/ui-icons';
|
|
3
3
|
import { Button } from '@flipdish/ui-library/components/atoms/Button';
|
|
4
|
+
import { Label, HintText } from '@flipdish/ui-library/components/atoms/Input';
|
|
5
|
+
import { cx } from '@flipdish/ui-library/utilities/cx';
|
|
4
6
|
import { useResolvedTestId, TestIdProvider, joinTestId } from '@flipdish/ui-library/utilities/testIdUtils';
|
|
5
7
|
import { today, getLocalTimeZone } from '@internationalized/date';
|
|
6
8
|
import { useDateFormatter } from '@react-aria/i18n';
|
|
@@ -19,7 +21,7 @@ const highlightedDates = [today(getLocalTimeZone())];
|
|
|
19
21
|
*
|
|
20
22
|
* @summary popover calendar for selecting a single date
|
|
21
23
|
*/
|
|
22
|
-
const DatePicker = ({ value: valueProp, defaultValue, onChange, onApply, onCancel, onOpenChange, size = 'sm', placeholder = 'Select date', 'data-testid': dataTestId, ...props }) => {
|
|
24
|
+
const DatePicker = ({ value: valueProp, defaultValue, onChange, onApply, onCancel, onOpenChange, size = 'sm', placeholder = 'Select date', label, hint, className, ref, 'data-testid': dataTestId, ...props }) => {
|
|
23
25
|
const formatter = useDateFormatter({
|
|
24
26
|
month: 'short',
|
|
25
27
|
day: 'numeric',
|
|
@@ -33,7 +35,9 @@ const DatePicker = ({ value: valueProp, defaultValue, onChange, onApply, onCance
|
|
|
33
35
|
const [draftValue, setDraftValue] = useState(value);
|
|
34
36
|
const formattedDate = value ? formatter.format(value.toDate(getLocalTimeZone())) : placeholder;
|
|
35
37
|
const rootTestId = useResolvedTestId({ testId: dataTestId, segment: 'date-picker', rootName: 'date-picker' });
|
|
36
|
-
return (jsx(TestIdProvider, { value: rootTestId, children:
|
|
38
|
+
return (jsx(TestIdProvider, { value: rootTestId, children: jsx(DatePicker$1
|
|
39
|
+
// A visible label names the picker; without one this default does, unless `aria-label` is passed.
|
|
40
|
+
, { "aria-label": label ? undefined : 'Date picker', shouldCloseOnSelect: false, ...props, ref: ref, className: (state) => cx('flex flex-col items-start gap-1.5', typeof className === 'function' ? className(state) : className), value: draftValue, onChange: setDraftValue, onOpenChange: (isOpen) => {
|
|
37
41
|
// Re-seed the draft from the latest committed value every time the popover opens, so
|
|
38
42
|
// a stale in-progress edit from a previous Cancel/dismiss never leaks in, and a
|
|
39
43
|
// controlled `value` that changed while closed is always the starting point.
|
|
@@ -41,14 +45,14 @@ const DatePicker = ({ value: valueProp, defaultValue, onChange, onApply, onCance
|
|
|
41
45
|
setDraftValue(value);
|
|
42
46
|
}
|
|
43
47
|
onOpenChange?.(isOpen);
|
|
44
|
-
}, "data-testid": rootTestId, children: [jsx(Group, { children: jsx(Button, { size: size, color: "secondary", iconLeading: Calendar, "data-testid": joinTestId(rootTestId, 'trigger'), children: formattedDate }) }), jsx(CalendarOverlay, { "aria-label": props['aria-label'] ?? 'Date picker', "data-testid": joinTestId(rootTestId, 'popover'), children: ({ close }) => (jsxs(Fragment, { children: [jsx("div", { className: "flex w-full max-w-78 px-4 py-5 sm:max-w-82 sm:px-6", children: jsx(Calendar$1, { highlightedDates: highlightedDates }) }), jsxs("div", { className: "sticky bottom-0 grid w-full grid-cols-2 gap-3 border-t border-secondary bg-primary px-4 pt-4 pb-[calc(1rem+env(safe-area-inset-bottom))]", children: [jsx(Button, { size: "md", color: "secondary", "data-testid": joinTestId(rootTestId, 'cancel'), onClick: () => {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
48
|
+
}, "data-testid": rootTestId, children: ({ isInvalid, isRequired }) => (jsxs(Fragment, { children: [label && jsx(Label, { isRequired: isRequired, children: label }), jsx(Group, { children: jsx(Button, { size: size, color: "secondary", iconLeading: Calendar, className: cx(isInvalid && 'ring-error_subtle'), "aria-label": `Calendar, ${formattedDate}`, "data-testid": joinTestId(rootTestId, 'trigger'), children: formattedDate }) }), hint && jsx(HintText, { isInvalid: isInvalid, children: hint }), jsx(CalendarOverlay, { "aria-label": props['aria-label'] ?? label ?? 'Date picker', "data-testid": joinTestId(rootTestId, 'popover'), children: ({ close }) => (jsxs(Fragment, { children: [jsx("div", { className: "flex w-full max-w-78 px-4 py-5 sm:max-w-82 sm:px-6", children: jsx(Calendar$1, { highlightedDates: highlightedDates }) }), jsxs("div", { className: "sticky bottom-0 grid w-full grid-cols-2 gap-3 border-t border-secondary bg-primary px-4 pt-4 pb-[calc(1rem+env(safe-area-inset-bottom))]", children: [jsx(Button, { size: "md", color: "secondary", "data-testid": joinTestId(rootTestId, 'cancel'), onClick: () => {
|
|
49
|
+
onCancel?.();
|
|
50
|
+
close();
|
|
51
|
+
}, children: "Cancel" }), jsx(Button, { size: "md", color: "primary", "data-testid": joinTestId(rootTestId, 'apply'), onClick: () => {
|
|
52
|
+
setValue(draftValue);
|
|
53
|
+
onApply?.();
|
|
54
|
+
close();
|
|
55
|
+
}, children: "Apply" })] })] })) })] })) }) }));
|
|
52
56
|
};
|
|
53
57
|
|
|
54
58
|
export { DatePicker };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../../src/components/organisms/DatePicker/index.tsx"],"sourcesContent":[null],"names":["_jsx","_jsxs","
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../../src/components/organisms/DatePicker/index.tsx"],"sourcesContent":[null],"names":["_jsx","AriaDatePicker","_jsxs","_Fragment","AriaGroup","CalendarIcon","Calendar"],"mappings":";;;;;;;;;;;;;;;;AAmBA,MAAM,gBAAgB,GAAG,CAAC,KAAK,CAAC,gBAAgB,EAAE,CAAC,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EAAA,CAAI,EAAA,CAC5C,EACNJ,IAAA,CAAA,KAAA,EAAA,EAAK,SAAS,EAAC,0IAA0I,EAAA,QAAA,EAAA,CACvJF,GAAA,CAAC,MAAM,EAAA,EACL,IAAI,EAAC,IAAI,EACT,KAAK,EAAC,WAAW,iBACJ,UAAU,CAAC,UAAU,EAAE,QAAQ,CAAC,EAC7C,OAAO,EAAE,MAAK;gDACZ,QAAQ,IAAI;AACZ,gDAAA,KAAK,EAAE;4CACT,CAAC,EAAA,QAAA,EAAA,QAAA,EAAA,CAGM,EACTA,GAAA,CAAC,MAAM,IACL,IAAI,EAAC,IAAI,EACT,KAAK,EAAC,SAAS,EAAA,aAAA,EACF,UAAU,CAAC,UAAU,EAAE,OAAO,CAAC,EAC5C,OAAO,EAAE,MAAK;gDACZ,QAAQ,CAAC,UAAU,CAAC;gDACpB,OAAO,IAAI;AACX,gDAAA,KAAK,EAAE;4CACT,CAAC,EAAA,QAAA,EAAA,OAAA,EAAA,CAGM,CAAA,EAAA,CACL,CAAA,EAAA,CACL,CACJ,EAAA,CACe,IACjB,CACJ,EAAA,CACc,EAAA,CACF;AAErB;;"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var React = require('react');
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Keeps keyboard focus in place across a retry. A "Try again" button unmounts once the data arrives, and focus would
|
|
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.
|
|
8
|
+
*
|
|
9
|
+
* @param retry Starts the failed request again.
|
|
10
|
+
* @returns `retryLoad` for the retry button, and `contentRef` for the element that replaces the error. That element takes
|
|
11
|
+
* focus when it mounts after a retry, unless the user has moved focus elsewhere, and must be focusable (`tabIndex={-1}`).
|
|
12
|
+
*/
|
|
13
|
+
const useFocusAfterRetry = (retry) => {
|
|
14
|
+
const hasRetried = React.useRef(false);
|
|
15
|
+
const retryLoad = () => {
|
|
16
|
+
hasRetried.current = true;
|
|
17
|
+
retry();
|
|
18
|
+
};
|
|
19
|
+
const contentRef = (content) => {
|
|
20
|
+
if (!content || !hasRetried.current)
|
|
21
|
+
return;
|
|
22
|
+
hasRetried.current = false;
|
|
23
|
+
// Focus sits on `<body>` only when the button it was on is gone; anywhere else, the user chose it.
|
|
24
|
+
if (content.ownerDocument.activeElement === content.ownerDocument.body)
|
|
25
|
+
content.focus();
|
|
26
|
+
};
|
|
27
|
+
return { retryLoad, contentRef };
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
exports.useFocusAfterRetry = useFocusAfterRetry;
|
|
31
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../../../src/hooks/useFocusAfterRetry/index.ts"],"sourcesContent":[null],"names":["useRef"],"mappings":";;;;AAIA;;;;;;;AAOG;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,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE;AAClC;;"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Keeps keyboard focus in place across a retry. A "Try again" button unmounts once the data arrives, and focus would
|
|
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
|
+
*
|
|
5
|
+
* @param retry Starts the failed request again.
|
|
6
|
+
* @returns `retryLoad` for the retry button, and `contentRef` for the element that replaces the error. That element takes
|
|
7
|
+
* focus when it mounts after a retry, unless the user has moved focus elsewhere, and must be focusable (`tabIndex={-1}`).
|
|
8
|
+
*/
|
|
9
|
+
export declare const useFocusAfterRetry: (retry: () => unknown) => {
|
|
10
|
+
retryLoad: () => void;
|
|
11
|
+
contentRef: (content: HTMLElement | null) => void;
|
|
12
|
+
};
|
|
13
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/hooks/useFocusAfterRetry/index.ts"],"names":[],"mappings":"AAIA;;;;;;;GAOG;AACH,eAAO,MAAM,kBAAkB,GAAI,OAAO,MAAM,OAAO;;0BAQxB,WAAW,GAAG,IAAI;CAQhD,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { useRef } from 'react';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Keeps keyboard focus in place across a retry. A "Try again" button unmounts once the data arrives, and focus would
|
|
5
|
+
* 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
|
+
*
|
|
7
|
+
* @param retry Starts the failed request again.
|
|
8
|
+
* @returns `retryLoad` for the retry button, and `contentRef` for the element that replaces the error. That element takes
|
|
9
|
+
* focus when it mounts after a retry, unless the user has moved focus elsewhere, and must be focusable (`tabIndex={-1}`).
|
|
10
|
+
*/
|
|
11
|
+
const useFocusAfterRetry = (retry) => {
|
|
12
|
+
const hasRetried = useRef(false);
|
|
13
|
+
const retryLoad = () => {
|
|
14
|
+
hasRetried.current = true;
|
|
15
|
+
retry();
|
|
16
|
+
};
|
|
17
|
+
const contentRef = (content) => {
|
|
18
|
+
if (!content || !hasRetried.current)
|
|
19
|
+
return;
|
|
20
|
+
hasRetried.current = false;
|
|
21
|
+
// Focus sits on `<body>` only when the button it was on is gone; anywhere else, the user chose it.
|
|
22
|
+
if (content.ownerDocument.activeElement === content.ownerDocument.body)
|
|
23
|
+
content.focus();
|
|
24
|
+
};
|
|
25
|
+
return { retryLoad, contentRef };
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
export { useFocusAfterRetry };
|
|
29
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../src/hooks/useFocusAfterRetry/index.ts"],"sourcesContent":[null],"names":[],"mappings":";;AAIA;;;;;;;AAOG;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,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE;AAClC;;"}
|
|
@@ -13,6 +13,8 @@ interface CommonProps {
|
|
|
13
13
|
isDisabled?: boolean;
|
|
14
14
|
/** Shows a loading spinner and disables the button */
|
|
15
15
|
isLoading?: boolean;
|
|
16
|
+
/** Shows a check in place of the button's icons, to confirm the action finished; `isLoading` takes precedence. */
|
|
17
|
+
isSuccess?: boolean;
|
|
16
18
|
/** The size variant of the button */
|
|
17
19
|
size?: ButtonSize;
|
|
18
20
|
/** The color variant of the button */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/components/atoms/Button/index.native.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/components/atoms/Button/index.native.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,EAAE,EAAkB,KAAK,YAAY,EAAE,KAAK,SAAS,EAAY,MAAM,OAAO,CAAC;AAC7F,OAAO,EAAyC,KAAK,cAAc,EAAc,MAAM,cAAc,CAAC;AAEtG,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAEzC,KAAK,QAAQ,GAAG,EAAE,CAAC;IAAE,SAAS,CAAC,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC,GAAG,SAAS,CAAC;AAEtF,MAAM,MAAM,UAAU,GAAG,MAAM,OAAO,MAAM,CAAC,KAAK,CAAC;AACnD,MAAM,MAAM,WAAW,GAAG,MAAM,OAAO,MAAM,CAAC,MAAM,CAAC;AAErD,UAAU,WAAW;IACnB,qDAAqD;IACrD,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,sDAAsD;IACtD,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,kHAAkH;IAClH,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,qCAAqC;IACrC,IAAI,CAAC,EAAE,UAAU,CAAC;IAClB,sCAAsC;IACtC,KAAK,CAAC,EAAE,WAAW,CAAC;IACpB,wDAAwD;IACxD,WAAW,CAAC,EAAE,QAAQ,CAAC;IACvB,uDAAuD;IACvD,YAAY,CAAC,EAAE,QAAQ,CAAC;IACxB,uDAAuD;IACvD,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,6DAA6D;IAC7D,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B,kEAAkE;IAClE,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB;;;OAGG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,EAAE,SAAS,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,KAAK,SAAS,GAAG,IAAI,CAAC,cAAc,EAAE,SAAS,GAAG,SAAS,GAAG,oBAAoB,GAAG,mBAAmB,CAAC,CAAC;AAE1G,8CAA8C;AAC9C,MAAM,MAAM,WAAW,GAAG,WAAW,GAAG,SAAS,CAAC;AAElD,mFAAmF;AACnF,MAAM,MAAM,SAAS,GAAG,WAAW,GAAG,SAAS,GAAG;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC;AAEnE,MAAM,MAAM,KAAK,GAAG,WAAW,GAAG,SAAS,CAAC;AA4F5C;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,MAAM,EAAE;IACnB,CAAC,KAAK,EAAE,SAAS,GAAG,YAAY,CAAC;IACjC,CAAC,KAAK,EAAE,WAAW,GAAG,YAAY,CAAC;CAwGpC,CAAC"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
2
|
+
import { Check } from '@flipdish/ui-icons';
|
|
2
3
|
import { cx } from '../../../utilities/cx/index.js';
|
|
3
4
|
import { useResolvedTestId } from '../../../utilities/testIdUtils/index.js';
|
|
4
5
|
import { useState, isValidElement } from 'react';
|
|
@@ -102,7 +103,7 @@ const renderIcon = (icon, size, color, className) => {
|
|
|
102
103
|
*
|
|
103
104
|
* @summary action trigger or URL control (React Native)
|
|
104
105
|
*/
|
|
105
|
-
const Button = ({ size = 'sm', color = 'primary', children, className, noTextPadding: noTextPaddingProp, iconLeading: IconLeading, iconTrailing: IconTrailing, isDisabled, isLoading, showTextWhileLoading, 'data-testid': dataTestId, 'aria-label': ariaLabel, onPress, hitSlop, accessibilityLabel, accessibilityHint, ...props }) => {
|
|
106
|
+
const Button = ({ size = 'sm', color = 'primary', children, className, noTextPadding: noTextPaddingProp, iconLeading: IconLeading, iconTrailing: IconTrailing, isDisabled, isLoading, isSuccess, showTextWhileLoading, 'data-testid': dataTestId, 'aria-label': ariaLabel, onPress, hitSlop, accessibilityLabel, accessibilityHint, ...props }) => {
|
|
106
107
|
const href = 'href' in props ? props.href : undefined;
|
|
107
108
|
const resolvedAccessibilityLabel = accessibilityLabel ?? ariaLabel;
|
|
108
109
|
const buttonTestId = useResolvedTestId({ testId: dataTestId, segment: 'button', rootName: 'button' });
|
|
@@ -128,8 +129,9 @@ const Button = ({ size = 'sm', color = 'primary', children, className, noTextPad
|
|
|
128
129
|
Linking.openURL(href).catch(() => { });
|
|
129
130
|
}
|
|
130
131
|
};
|
|
131
|
-
const
|
|
132
|
-
const
|
|
132
|
+
const showSuccess = Boolean(isSuccess && !isLoading);
|
|
133
|
+
const leadingIcon = !omitIconsWhileLoading ? renderIcon(showSuccess ? Check : IconLeading, size, iconColor, styles.common.icon) : null;
|
|
134
|
+
const trailingIcon = !omitIconsWhileLoading && !showSuccess ? renderIcon(IconTrailing, size, iconColor, styles.common.icon) : null;
|
|
133
135
|
return (jsxs(Pressable, { testID: buttonTestId, disabled: disabled, onPress: handlePress, onPressIn: () => setPressed(true), onPressOut: () => setPressed(false), hitSlop: hitSlop, accessibilityRole: href ? 'link' : 'button', accessibilityLabel: resolvedAccessibilityLabel, accessibilityHint: accessibilityHint, accessibilityState: { disabled, busy: Boolean(isLoading) }, className: cx(styles.common.root, isLinkType ? styles.sizes[size].linkRoot : styles.sizes[size].root,
|
|
134
136
|
// Merged (not swapped) so icon-only keeps `rounded-lg`/`gap-*` from `root` —
|
|
135
137
|
// `cx` (tailwind-merge) resolves the padding conflict, keeping this override.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../../../../src/components/atoms/Button/index.native.tsx"],"sourcesContent":[null],"names":["_jsx","_jsxs"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../../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EA,QAAQ,EAAA,CACJ,CACR,EAEA,YAAY,GAAGA,GAAA,CAAC,IAAI,EAAA,EAAC,KAAK,EAAE,aAAa,GAAG,EAAE,OAAO,EAAE,CAAC,EAAE,GAAG,SAAS,EAAA,QAAA,EAAG,YAAY,EAAA,CAAQ,GAAG,IAAI,CAAA,EAAA,CAC3F;AAEhB;;"}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { type ReactNode } from 'react';
|
|
2
2
|
export interface CheckboxProps {
|
|
3
|
-
/**
|
|
3
|
+
/** Identifies this option within a `CheckboxGroup`: the group's `value` list holds it while the box is ticked. */
|
|
4
|
+
value?: string;
|
|
5
|
+
/** Sets the box size and the label and hint text size; a parent `CheckboxGroup`'s `size` overrides it. */
|
|
4
6
|
size?: 'sm' | 'md';
|
|
5
7
|
/** Text shown beside the box; pressing it toggles the checkbox. */
|
|
6
8
|
label?: ReactNode;
|
|
@@ -20,7 +22,7 @@ export interface CheckboxProps {
|
|
|
20
22
|
className?: string;
|
|
21
23
|
/** Web-style accessible name, used as `accessibilityLabel` so shared call sites work on both platforms. */
|
|
22
24
|
'aria-label'?: string;
|
|
23
|
-
/** Overrides the
|
|
25
|
+
/** Overrides the derived `testID` (defaults to `<group>--option-<value>` in a `CheckboxGroup`, or `fd-checkbox`). */
|
|
24
26
|
'data-testid'?: string;
|
|
25
27
|
}
|
|
26
28
|
/**
|
|
@@ -30,5 +32,35 @@ export interface CheckboxProps {
|
|
|
30
32
|
*
|
|
31
33
|
* @summary checkbox for selecting one or more options (React Native)
|
|
32
34
|
*/
|
|
33
|
-
export declare const Checkbox: ({ label, hint, size, className, isSelected: isSelectedProp, defaultSelected, isIndeterminate, isDisabled, onChange, "aria-label": ariaLabel, "data-testid": dataTestId, }: CheckboxProps) => import("react").JSX.Element;
|
|
35
|
+
export declare const Checkbox: ({ value, label, hint, size: sizeProp, className, isSelected: isSelectedProp, defaultSelected, isIndeterminate, isDisabled: isDisabledProp, onChange, "aria-label": ariaLabel, "data-testid": dataTestId, }: CheckboxProps) => import("react").JSX.Element;
|
|
36
|
+
export interface CheckboxGroupProps {
|
|
37
|
+
/** The `Checkbox` options; each one's `value` is what the group's `value` list holds while it is ticked. */
|
|
38
|
+
children: ReactNode;
|
|
39
|
+
/** Visible name of the group, shown above the boxes. When omitted, pass `aria-label`. */
|
|
40
|
+
label?: ReactNode;
|
|
41
|
+
/** Supporting text beneath the boxes, announced with every box; shown as the group's error while `isInvalid`. */
|
|
42
|
+
hint?: ReactNode;
|
|
43
|
+
/** Sets the size of every checkbox in the group. */
|
|
44
|
+
size?: 'sm' | 'md';
|
|
45
|
+
/** Controlled list of ticked values. */
|
|
46
|
+
value?: string[];
|
|
47
|
+
/** Initial ticked values for uncontrolled usage. */
|
|
48
|
+
defaultValue?: string[];
|
|
49
|
+
/** Called with the whole list of ticked values whenever a box is toggled. */
|
|
50
|
+
onChange?: (value: string[]) => void;
|
|
51
|
+
/** Disables every option in the group. */
|
|
52
|
+
isDisabled?: boolean;
|
|
53
|
+
/** Shows `hint` in the error colour. */
|
|
54
|
+
isInvalid?: boolean;
|
|
55
|
+
/** Marks the group as required: an asterisk after its label, and "required" after its name for screen readers. */
|
|
56
|
+
isRequired?: boolean;
|
|
57
|
+
/** Extra classes merged onto the root `View`. */
|
|
58
|
+
className?: string;
|
|
59
|
+
/** Web-style accessible name for the group; native has no `aria-labelledby`, so set this when `label` is not plain text. */
|
|
60
|
+
'aria-label'?: string;
|
|
61
|
+
/** Overrides the `testID` (defaults to `fd-checkbox-group`); each option derives `<group>--option-<value>` from it. */
|
|
62
|
+
'data-testid'?: string;
|
|
63
|
+
}
|
|
64
|
+
/** React Native `CheckboxGroup` that names a set of `Checkbox` children, owns which are ticked as a list, and shows one hint or error for the set. */
|
|
65
|
+
export declare const CheckboxGroup: ({ children, label, hint, className, size, value, defaultValue, onChange, isDisabled, isInvalid, isRequired, "aria-label": ariaLabel, "data-testid": dataTestId, }: CheckboxGroupProps) => import("react").JSX.Element;
|
|
34
66
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/components/atoms/Checkbox/index.native.tsx"],"names":[],"mappings":"AAGA,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/components/atoms/Checkbox/index.native.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAiB,KAAK,SAAS,EAAwB,MAAM,OAAO,CAAC;AAoB5E,MAAM,WAAW,aAAa;IAC5B,kHAAkH;IAClH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,0GAA0G;IAC1G,IAAI,CAAC,EAAE,IAAI,GAAG,IAAI,CAAC;IACnB,mEAAmE;IACnE,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB,6CAA6C;IAC7C,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB,oEAAoE;IACpE,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,oDAAoD;IACpD,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,uFAAuF;IACvF,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,8DAA8D;IAC9D,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,sEAAsE;IACtE,QAAQ,CAAC,EAAE,CAAC,UAAU,EAAE,OAAO,KAAK,IAAI,CAAC;IACzC,sDAAsD;IACtD,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,2GAA2G;IAC3G,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,qHAAqH;IACrH,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AASD;;;;;;GAMG;AACH,eAAO,MAAM,QAAQ,GAAI,4MAatB,aAAa,gCAqDf,CAAC;AAUF,MAAM,WAAW,kBAAkB;IACjC,4GAA4G;IAC5G,QAAQ,EAAE,SAAS,CAAC;IACpB,yFAAyF;IACzF,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB,iHAAiH;IACjH,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB,oDAAoD;IACpD,IAAI,CAAC,EAAE,IAAI,GAAG,IAAI,CAAC;IACnB,wCAAwC;IACxC,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;IACjB,oDAAoD;IACpD,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;IACxB,6EAA6E;IAC7E,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,IAAI,CAAC;IACrC,0CAA0C;IAC1C,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,wCAAwC;IACxC,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,kHAAkH;IAClH,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,iDAAiD;IACjD,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,4HAA4H;IAC5H,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,uHAAuH;IACvH,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED,sJAAsJ;AACtJ,eAAO,MAAM,aAAa,GAAI,mKAc3B,kBAAkB,gCAkCpB,CAAC"}
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
2
2
|
import { Minus, Check } from '@flipdish/ui-icons';
|
|
3
3
|
import { cx } from '../../../utilities/cx/index.js';
|
|
4
|
-
import { useResolvedTestId } from '../../../utilities/testIdUtils/index.js';
|
|
5
|
-
import { useState } from 'react';
|
|
6
|
-
import { Pressable, View } from 'react-native';
|
|
4
|
+
import { useResolvedTestId, joinTestId, slugifyTestId } from '../../../utilities/testIdUtils/index.js';
|
|
5
|
+
import { createContext, useContext, useState } from 'react';
|
|
6
|
+
import { Pressable, View, Text } from 'react-native';
|
|
7
7
|
import { SelectionControlText } from '../../__internal__/selectionControl/SelectionControlText.js';
|
|
8
8
|
import { selectionControlSizes } from '../../__internal__/selectionControl/selectionControl.styles.js';
|
|
9
|
-
import {
|
|
9
|
+
import { getAccessibleHint, SELECTION_CONTROL_HIT_SLOP, getAccessibleName } from '../../__internal__/selectionControl/selectionControl.utils.js';
|
|
10
10
|
|
|
11
|
+
const CheckboxGroupContext = createContext(null);
|
|
11
12
|
// Web draws both glyphs in a 14px viewBox with a 2px stroke; the ported 24px icons need 24/7 for the same weight.
|
|
12
13
|
const GLYPH_STROKE = 24 / 7;
|
|
13
14
|
const CHECK_SIZE = { sm: 12, md: 14 };
|
|
@@ -21,19 +22,55 @@ const GLYPH_COLOR = '#ffffff';
|
|
|
21
22
|
*
|
|
22
23
|
* @summary checkbox for selecting one or more options (React Native)
|
|
23
24
|
*/
|
|
24
|
-
const Checkbox = ({ label, hint, size = 'sm', className, isSelected: isSelectedProp, defaultSelected = false, isIndeterminate, isDisabled, onChange, 'aria-label': ariaLabel, 'data-testid': dataTestId, }) => {
|
|
25
|
-
const
|
|
25
|
+
const Checkbox = ({ value, label, hint, size: sizeProp = 'sm', className, isSelected: isSelectedProp, defaultSelected = false, isIndeterminate, isDisabled: isDisabledProp, onChange, 'aria-label': ariaLabel, 'data-testid': dataTestId, }) => {
|
|
26
|
+
const group = useContext(CheckboxGroupContext);
|
|
27
|
+
// A box with no `value` is not one of the group's options, so it keeps its own state.
|
|
28
|
+
const option = group && value !== undefined ? { group, value } : null;
|
|
29
|
+
const size = group?.size ?? sizeProp;
|
|
30
|
+
const isDisabled = Boolean(isDisabledProp || group?.isDisabled);
|
|
31
|
+
const fallbackTestId = useResolvedTestId({ testId: dataTestId, segment: 'checkbox', rootName: 'checkbox' });
|
|
32
|
+
const checkboxTestId = !dataTestId && option ? joinTestId(option.group.testIdPrefix, `option-${slugifyTestId(option.value)}`) : fallbackTestId;
|
|
26
33
|
const [uncontrolledSelected, setUncontrolledSelected] = useState(defaultSelected);
|
|
27
|
-
const isSelected = isSelectedProp ?? uncontrolledSelected;
|
|
34
|
+
const isSelected = option ? option.group.values.includes(option.value) : (isSelectedProp ?? uncontrolledSelected);
|
|
28
35
|
const isFilled = isSelected || isIndeterminate;
|
|
36
|
+
const accessibilityHint = [getAccessibleHint(hint), group?.description].filter(Boolean).join(' ') || undefined;
|
|
37
|
+
const ownName = getAccessibleName(ariaLabel, label);
|
|
38
|
+
const accessibleName = ownName && option?.group.name ? `${ownName}, ${option.group.name}` : ownName;
|
|
29
39
|
const handlePress = () => {
|
|
30
40
|
const next = !isSelected;
|
|
31
|
-
if (
|
|
41
|
+
if (option)
|
|
42
|
+
option.group.toggle(option.value);
|
|
43
|
+
else if (isSelectedProp === undefined)
|
|
32
44
|
setUncontrolledSelected(next);
|
|
33
45
|
onChange?.(next);
|
|
34
46
|
};
|
|
35
|
-
return (jsxs(Pressable, { testID: checkboxTestId, disabled: isDisabled, onPress: handlePress, accessibilityRole: "checkbox", hitSlop: SELECTION_CONTROL_HIT_SLOP, accessibilityLabel:
|
|
47
|
+
return (jsxs(Pressable, { testID: checkboxTestId, disabled: isDisabled, onPress: handlePress, accessibilityRole: "checkbox", hitSlop: SELECTION_CONTROL_HIT_SLOP, accessibilityLabel: accessibleName, accessibilityHint: accessibilityHint, accessibilityState: { checked: isIndeterminate ? 'mixed' : isSelected, disabled: isDisabled }, className: cx('relative flex flex-row items-start self-start', selectionControlSizes[size].root, className), children: [jsxs(View, { className: cx('size-4 shrink-0 items-center justify-center rounded border border-primary bg-primary', size === 'md' && 'size-5 rounded-md', isFilled && 'border-brand-solid bg-brand-solid', isDisabled && 'opacity-50', isDisabled && !isFilled && 'bg-tertiary', (label || hint) && 'mt-0.5'), children: [isIndeterminate && jsx(Minus, { size: DASH_SIZE[size], color: GLYPH_COLOR, strokeWidth: GLYPH_STROKE }), !isIndeterminate && isSelected && jsx(Check, { size: CHECK_SIZE[size], color: GLYPH_COLOR, strokeWidth: GLYPH_STROKE })] }), jsx(SelectionControlText, { size: size, label: label, hint: hint })] }));
|
|
48
|
+
};
|
|
49
|
+
// `Text` className is ignored by the current `react-native-css` preview (see Avatar), so the group's text goes through `style`.
|
|
50
|
+
const GROUP_TEXT = { fontSize: 14, lineHeight: 20 };
|
|
51
|
+
// Light-mode hex of `text-secondary` (neutral-700), `text-tertiary` (neutral-600), `text-error-primary` (red-600) and `text-brand-tertiary` (brand-600).
|
|
52
|
+
const GROUP_LABEL_COLOR = '#404040';
|
|
53
|
+
const GROUP_HINT_COLOR = '#525252';
|
|
54
|
+
const GROUP_ERROR_COLOR = '#dc2626';
|
|
55
|
+
const GROUP_REQUIRED_COLOR = '#0b75d7';
|
|
56
|
+
/** React Native `CheckboxGroup` that names a set of `Checkbox` children, owns which are ticked as a list, and shows one hint or error for the set. */
|
|
57
|
+
const CheckboxGroup = ({ children, label, hint, className, size = 'sm', value, defaultValue = [], onChange, isDisabled = false, isInvalid = false, isRequired = false, 'aria-label': ariaLabel, 'data-testid': dataTestId, }) => {
|
|
58
|
+
const rootTestId = useResolvedTestId({ testId: dataTestId, segment: 'checkbox-group', rootName: 'checkbox-group' });
|
|
59
|
+
const [uncontrolledValues, setUncontrolledValues] = useState(defaultValue);
|
|
60
|
+
const values = value ?? uncontrolledValues;
|
|
61
|
+
const toggle = (option) => {
|
|
62
|
+
const next = values.includes(option) ? values.filter((ticked) => ticked !== option) : [...values, option];
|
|
63
|
+
if (value === undefined)
|
|
64
|
+
setUncontrolledValues(next);
|
|
65
|
+
onChange?.(next);
|
|
66
|
+
};
|
|
67
|
+
const groupName = getAccessibleName(ariaLabel, label);
|
|
68
|
+
// React Native has no required state for a set of boxes, so the group's name says it in words.
|
|
69
|
+
const announcedName = groupName && isRequired ? `${groupName}, required` : groupName;
|
|
70
|
+
// A plain `View` is not a screen-reader stop, so with no visible label each box carries the group's name.
|
|
71
|
+
const optionGroupName = label ? undefined : announcedName;
|
|
72
|
+
return (jsx(CheckboxGroupContext.Provider, { value: { size, testIdPrefix: rootTestId, values, isDisabled, description: getAccessibleHint(hint), name: optionGroupName, toggle }, children: jsxs(View, { testID: rootTestId, accessibilityLabel: groupName, className: cx('flex flex-col gap-3', className), children: [label ? (jsxs(Text, { accessibilityLabel: isRequired ? announcedName : undefined, style: { ...GROUP_TEXT, fontWeight: '500', color: GROUP_LABEL_COLOR }, children: [label, isRequired ? jsx(Text, { style: { color: isInvalid ? GROUP_ERROR_COLOR : GROUP_REQUIRED_COLOR }, children: " *" }) : null] })) : null, children, hint ? jsx(Text, { style: { ...GROUP_TEXT, color: isInvalid ? GROUP_ERROR_COLOR : GROUP_HINT_COLOR }, children: hint }) : null] }) }));
|
|
36
73
|
};
|
|
37
74
|
|
|
38
|
-
export { Checkbox };
|
|
75
|
+
export { Checkbox, CheckboxGroup };
|
|
39
76
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../../../../src/components/atoms/Checkbox/index.native.tsx"],"sourcesContent":[null],"names":["_jsxs","_jsx"],"mappings":";;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../../../../src/components/atoms/Checkbox/index.native.tsx"],"sourcesContent":[null],"names":["_jsxs","_jsx"],"mappings":";;;;;;;;;;AAqBA,MAAM,oBAAoB,GAAG,aAAa,CAAmC,IAAI,CAAC;AA6BlF;AACA,MAAM,YAAY,GAAG,EAAE,GAAG,CAAC;AAC3B,MAAM,UAAU,GAAG,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAW;AAC9C,MAAM,SAAS,GAAG,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAW;AAC7C;AACA,MAAM,WAAW,GAAG,SAAS;AAE7B;;;;;;AAMG;MACU,QAAQ,GAAG,CAAC,EACvB,KAAK,EACL,KAAK,EACL,IAAI,EACJ,IAAI,EAAE,QAAQ,GAAG,IAAI,EACrB,SAAS,EACT,UAAU,EAAE,cAAc,EAC1B,eAAe,GAAG,KAAK,EACvB,eAAe,EACf,UAAU,EAAE,cAAc,EAC1B,QAAQ,EACR,YAAY,EAAE,SAAS,EACvB,aAAa,EAAE,UAAU,GACX,KAAI;AAClB,IAAA,MAAM,KAAK,GAAG,U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AA,EAAG,IAAI,EAAA,CAAQ,GAAG,IAAI,CAAA,EAAA,CAChH,EAAA,CACuB;AAEpC;;"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `useFocusAfterRetry` has no React Native implementation.
|
|
3
|
+
*
|
|
4
|
+
* This is a generated types-only stub (scripts/emit-native-stubs.mjs). It exists so
|
|
5
|
+
* that importing `@flipdish/ui-library/hooks/useFocusAfterRetry` from React Native fails at
|
|
6
|
+
* compile time rather than resolving to the web build's types. There is no
|
|
7
|
+
* matching `index.js`, so Metro cannot bundle this module either.
|
|
8
|
+
*
|
|
9
|
+
* To make `useFocusAfterRetry` available on React Native, add an `index.native.tsx` beside
|
|
10
|
+
* its `index.tsx` — the build picks it up automatically and this stub disappears.
|
|
11
|
+
*/
|
|
12
|
+
export declare const __NO_REACT_NATIVE_IMPLEMENTATION__: never;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Joins the ids that are present into one `aria-labelledby` or `aria-describedby` value.
|
|
5
|
+
*
|
|
6
|
+
* @param ids The ids of the elements that name or describe a control, in reading order; an absent part is `undefined` or `false`.
|
|
7
|
+
* @returns The ids separated by spaces, or `undefined` when none is present, so the attribute is left off.
|
|
8
|
+
*/
|
|
9
|
+
const joinIds = (...ids) => ids.filter(Boolean).join(' ') || undefined;
|
|
10
|
+
|
|
11
|
+
exports.joinIds = joinIds;
|
|
12
|
+
//# sourceMappingURL=ariaIds.utils.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ariaIds.utils.cjs","sources":["../../../../src/utilities/__internal__/ariaIdsUtils/ariaIds.utils.ts"],"sourcesContent":[null],"names":[],"mappings":";;AAAA;;;;;AAKG;MACU,OAAO,GAAG,CAAC,GAAG,GAAmC,KAAK,GAAG,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI;;"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Joins the ids that are present into one `aria-labelledby` or `aria-describedby` value.
|
|
3
|
+
*
|
|
4
|
+
* @param ids The ids of the elements that name or describe a control, in reading order; an absent part is `undefined` or `false`.
|
|
5
|
+
* @returns The ids separated by spaces, or `undefined` when none is present, so the attribute is left off.
|
|
6
|
+
*/
|
|
7
|
+
export declare const joinIds: (...ids: (string | false | undefined)[]) => string | undefined;
|
|
8
|
+
//# sourceMappingURL=ariaIds.utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ariaIds.utils.d.ts","sourceRoot":"","sources":["../../../../src/utilities/__internal__/ariaIdsUtils/ariaIds.utils.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,eAAO,MAAM,OAAO,GAAI,GAAG,KAAK,CAAC,MAAM,GAAG,KAAK,GAAG,SAAS,CAAC,EAAE,uBAA+C,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Joins the ids that are present into one `aria-labelledby` or `aria-describedby` value.
|
|
3
|
+
*
|
|
4
|
+
* @param ids The ids of the elements that name or describe a control, in reading order; an absent part is `undefined` or `false`.
|
|
5
|
+
* @returns The ids separated by spaces, or `undefined` when none is present, so the attribute is left off.
|
|
6
|
+
*/
|
|
7
|
+
const joinIds = (...ids) => ids.filter(Boolean).join(' ') || undefined;
|
|
8
|
+
|
|
9
|
+
export { joinIds };
|
|
10
|
+
//# sourceMappingURL=ariaIds.utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ariaIds.utils.js","sources":["../../../../src/utilities/__internal__/ariaIdsUtils/ariaIds.utils.ts"],"sourcesContent":[null],"names":[],"mappings":"AAAA;;;;;AAKG;MACU,OAAO,GAAG,CAAC,GAAG,GAAmC,KAAK,GAAG,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI;;"}
|