@flipdish/ui-library 0.57.0 → 0.58.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/Checkbox/index.cjs +7 -61
- package/dist/components/atoms/Checkbox/index.cjs.map +1 -1
- package/dist/components/atoms/Checkbox/index.d.ts +15 -55
- package/dist/components/atoms/Checkbox/index.d.ts.map +1 -1
- package/dist/components/atoms/Checkbox/index.js +7 -61
- package/dist/components/atoms/Checkbox/index.js.map +1 -1
- package/dist/components/atoms/Checkboxes/Checkbox/Checkbox.cjs +56 -0
- package/dist/components/atoms/Checkboxes/Checkbox/Checkbox.cjs.map +1 -0
- package/dist/components/atoms/Checkboxes/Checkbox/Checkbox.d.ts +25 -0
- package/dist/components/atoms/Checkboxes/Checkbox/Checkbox.d.ts.map +1 -0
- package/dist/components/atoms/Checkboxes/Checkbox/Checkbox.js +54 -0
- package/dist/components/atoms/Checkboxes/Checkbox/Checkbox.js.map +1 -0
- package/dist/components/atoms/Checkboxes/Checkbox/CheckboxBase.cjs +13 -0
- package/dist/components/atoms/Checkboxes/Checkbox/CheckboxBase.cjs.map +1 -0
- package/dist/components/atoms/Checkboxes/Checkbox/CheckboxBase.d.ts +20 -0
- package/dist/components/atoms/Checkboxes/Checkbox/CheckboxBase.d.ts.map +1 -0
- package/dist/components/atoms/Checkboxes/Checkbox/CheckboxBase.js +11 -0
- package/dist/components/atoms/Checkboxes/Checkbox/CheckboxBase.js.map +1 -0
- package/dist/components/atoms/Checkboxes/CheckboxGroup/CheckboxGroup.cjs +23 -0
- package/dist/components/atoms/Checkboxes/CheckboxGroup/CheckboxGroup.cjs.map +1 -0
- package/dist/components/atoms/Checkboxes/CheckboxGroup/CheckboxGroup.d.ts +27 -0
- package/dist/components/atoms/Checkboxes/CheckboxGroup/CheckboxGroup.d.ts.map +1 -0
- package/dist/components/atoms/Checkboxes/CheckboxGroup/CheckboxGroup.js +21 -0
- package/dist/components/atoms/Checkboxes/CheckboxGroup/CheckboxGroup.js.map +1 -0
- package/dist/components/atoms/Checkboxes/index.cjs +12 -0
- package/dist/components/atoms/Checkboxes/index.cjs.map +1 -0
- package/dist/components/atoms/Checkboxes/index.d.ts +16 -0
- package/dist/components/atoms/Checkboxes/index.d.ts.map +1 -0
- package/dist/components/atoms/Checkboxes/index.js +4 -0
- package/dist/components/atoms/Checkboxes/index.js.map +1 -0
- package/dist/components/atoms/Checkboxes/providers/CheckboxGroup.context.cjs +9 -0
- package/dist/components/atoms/Checkboxes/providers/CheckboxGroup.context.cjs.map +1 -0
- package/dist/components/atoms/Checkboxes/providers/CheckboxGroup.context.d.ts +10 -0
- package/dist/components/atoms/Checkboxes/providers/CheckboxGroup.context.d.ts.map +1 -0
- package/dist/components/atoms/Checkboxes/providers/CheckboxGroup.context.js +7 -0
- package/dist/components/atoms/Checkboxes/providers/CheckboxGroup.context.js.map +1 -0
- package/dist/components/atoms/Divider/index.cjs +3 -15
- package/dist/components/atoms/Divider/index.cjs.map +1 -1
- package/dist/components/atoms/Divider/index.d.ts +7 -20
- package/dist/components/atoms/Divider/index.d.ts.map +1 -1
- package/dist/components/atoms/Divider/index.js +3 -15
- package/dist/components/atoms/Divider/index.js.map +1 -1
- package/dist/components/atoms/Dividers/ContentDivider/ContentDivider.cjs +24 -0
- package/dist/components/atoms/Dividers/ContentDivider/ContentDivider.cjs.map +1 -0
- package/dist/components/atoms/Dividers/ContentDivider/ContentDivider.d.ts +19 -0
- package/dist/components/atoms/Dividers/ContentDivider/ContentDivider.d.ts.map +1 -0
- package/dist/components/atoms/Dividers/ContentDivider/ContentDivider.js +22 -0
- package/dist/components/atoms/Dividers/ContentDivider/ContentDivider.js.map +1 -0
- package/dist/components/atoms/Dividers/Divider/Divider.cjs +21 -0
- package/dist/components/atoms/Dividers/Divider/Divider.cjs.map +1 -0
- package/dist/components/atoms/Dividers/Divider/Divider.d.ts +20 -0
- package/dist/components/atoms/Dividers/Divider/Divider.d.ts.map +1 -0
- package/dist/components/atoms/Dividers/Divider/Divider.js +19 -0
- package/dist/components/atoms/Dividers/Divider/Divider.js.map +1 -0
- package/dist/components/atoms/{Divider → Dividers/Divider}/Divider.styles.cjs +1 -1
- package/dist/components/atoms/Dividers/Divider/Divider.styles.cjs.map +1 -0
- package/dist/components/atoms/{Divider → Dividers/Divider}/Divider.styles.d.ts +1 -1
- package/dist/components/atoms/Dividers/Divider/Divider.styles.d.ts.map +1 -0
- package/dist/components/atoms/{Divider → Dividers/Divider}/Divider.styles.js +1 -1
- package/dist/components/atoms/Dividers/Divider/Divider.styles.js.map +1 -0
- package/dist/components/atoms/Dividers/index.cjs +10 -0
- package/dist/components/atoms/Dividers/index.cjs.map +1 -0
- package/dist/components/atoms/Dividers/index.d.ts +14 -0
- package/dist/components/atoms/Dividers/index.d.ts.map +1 -0
- package/dist/components/atoms/Dividers/index.js +3 -0
- package/dist/components/atoms/Dividers/index.js.map +1 -0
- package/dist/components/atoms/RadioButton/index.cjs +7 -34
- package/dist/components/atoms/RadioButton/index.cjs.map +1 -1
- package/dist/components/atoms/RadioButton/index.d.ts +16 -51
- package/dist/components/atoms/RadioButton/index.d.ts.map +1 -1
- package/dist/components/atoms/RadioButton/index.js +7 -34
- package/dist/components/atoms/RadioButton/index.js.map +1 -1
- package/dist/components/atoms/Radios/RadioButton/RadioButton.cjs +31 -0
- package/dist/components/atoms/Radios/RadioButton/RadioButton.cjs.map +1 -0
- package/dist/components/atoms/Radios/RadioButton/RadioButton.d.ts +25 -0
- package/dist/components/atoms/Radios/RadioButton/RadioButton.d.ts.map +1 -0
- package/dist/components/atoms/Radios/RadioButton/RadioButton.js +29 -0
- package/dist/components/atoms/Radios/RadioButton/RadioButton.js.map +1 -0
- package/dist/components/atoms/Radios/RadioButton/RadioButtonBase.cjs +13 -0
- package/dist/components/atoms/Radios/RadioButton/RadioButtonBase.cjs.map +1 -0
- package/dist/components/atoms/Radios/RadioButton/RadioButtonBase.d.ts +18 -0
- package/dist/components/atoms/Radios/RadioButton/RadioButtonBase.d.ts.map +1 -0
- package/dist/components/atoms/Radios/RadioButton/RadioButtonBase.js +11 -0
- package/dist/components/atoms/Radios/RadioButton/RadioButtonBase.js.map +1 -0
- package/dist/components/atoms/Radios/RadioGroup/RadioGroup.cjs +22 -0
- package/dist/components/atoms/Radios/RadioGroup/RadioGroup.cjs.map +1 -0
- package/dist/components/atoms/Radios/RadioGroup/RadioGroup.d.ts +20 -0
- package/dist/components/atoms/Radios/RadioGroup/RadioGroup.d.ts.map +1 -0
- package/dist/components/atoms/Radios/RadioGroup/RadioGroup.js +20 -0
- package/dist/components/atoms/Radios/RadioGroup/RadioGroup.js.map +1 -0
- package/dist/components/atoms/Radios/index.cjs +12 -0
- package/dist/components/atoms/Radios/index.cjs.map +1 -0
- package/dist/components/atoms/Radios/index.d.ts +16 -0
- package/dist/components/atoms/Radios/index.d.ts.map +1 -0
- package/dist/components/atoms/Radios/index.js +4 -0
- package/dist/components/atoms/Radios/index.js.map +1 -0
- package/dist/components/atoms/Radios/providers/RadioGroup.context.cjs +9 -0
- package/dist/components/atoms/Radios/providers/RadioGroup.context.cjs.map +1 -0
- package/dist/components/atoms/Radios/providers/RadioGroup.context.d.ts +8 -0
- package/dist/components/atoms/Radios/providers/RadioGroup.context.d.ts.map +1 -0
- package/dist/components/atoms/Radios/providers/RadioGroup.context.js +7 -0
- package/dist/components/atoms/Radios/providers/RadioGroup.context.js.map +1 -0
- package/dist/components/forms/FormSection/index.cjs +2 -2
- package/dist/components/forms/FormSection/index.cjs.map +1 -1
- package/dist/components/forms/FormSection/index.js +1 -1
- package/dist/components/forms/fields/FormCheckbox/index.cjs +2 -2
- package/dist/components/forms/fields/FormCheckbox/index.d.ts +1 -1
- package/dist/components/forms/fields/FormCheckbox/index.d.ts.map +1 -1
- package/dist/components/forms/fields/FormCheckbox/index.js +1 -1
- package/dist/components/forms/fields/FormCheckboxGroup/index.cjs +2 -2
- package/dist/components/forms/fields/FormCheckboxGroup/index.d.ts +1 -1
- package/dist/components/forms/fields/FormCheckboxGroup/index.d.ts.map +1 -1
- package/dist/components/forms/fields/FormCheckboxGroup/index.js +1 -1
- package/dist/components/forms/fields/FormRadioGroup/index.cjs +2 -2
- package/dist/components/forms/fields/FormRadioGroup/index.d.ts +1 -1
- package/dist/components/forms/fields/FormRadioGroup/index.d.ts.map +1 -1
- package/dist/components/forms/fields/FormRadioGroup/index.js +1 -1
- package/dist/components/molecules/Breadcrumbs/components/BreadcrumbAccountItem.cjs +2 -2
- package/dist/components/molecules/Breadcrumbs/components/BreadcrumbAccountItem.cjs.map +1 -1
- package/dist/components/molecules/Breadcrumbs/components/BreadcrumbAccountItem.js +1 -1
- package/dist/components/molecules/ContentDivider/index.cjs +5 -18
- package/dist/components/molecules/ContentDivider/index.cjs.map +1 -1
- package/dist/components/molecules/ContentDivider/index.d.ts +5 -18
- package/dist/components/molecules/ContentDivider/index.d.ts.map +1 -1
- package/dist/components/molecules/ContentDivider/index.js +5 -18
- package/dist/components/molecules/ContentDivider/index.js.map +1 -1
- package/dist/components/molecules/Dropdown/components/DropdownSelectionIndicator.cjs +4 -4
- package/dist/components/molecules/Dropdown/components/DropdownSelectionIndicator.cjs.map +1 -1
- package/dist/components/molecules/Dropdown/components/DropdownSelectionIndicator.js +2 -2
- package/dist/components/molecules/RadioGroup/components/RadioGroupAvatar.cjs +2 -2
- package/dist/components/molecules/RadioGroup/components/RadioGroupAvatar.cjs.map +1 -1
- package/dist/components/molecules/RadioGroup/components/RadioGroupAvatar.js +1 -1
- package/dist/components/molecules/RadioGroup/components/RadioGroupAvatarCard.cjs +3 -3
- package/dist/components/molecules/RadioGroup/components/RadioGroupAvatarCard.cjs.map +1 -1
- package/dist/components/molecules/RadioGroup/components/RadioGroupAvatarCard.js +2 -2
- package/dist/components/molecules/RadioGroup/components/RadioGroupCheckbox.cjs +2 -2
- package/dist/components/molecules/RadioGroup/components/RadioGroupCheckbox.cjs.map +1 -1
- package/dist/components/molecules/RadioGroup/components/RadioGroupCheckbox.js +1 -1
- package/dist/components/molecules/RadioGroup/components/RadioGroupIconCard.cjs +2 -2
- package/dist/components/molecules/RadioGroup/components/RadioGroupIconCard.cjs.map +1 -1
- package/dist/components/molecules/RadioGroup/components/RadioGroupIconCard.js +1 -1
- package/dist/components/molecules/RadioGroup/components/RadioGroupIconSimple.cjs +2 -2
- package/dist/components/molecules/RadioGroup/components/RadioGroupIconSimple.cjs.map +1 -1
- package/dist/components/molecules/RadioGroup/components/RadioGroupIconSimple.js +1 -1
- package/dist/components/molecules/RadioGroup/components/RadioGroupPaymentIcon.cjs +2 -2
- package/dist/components/molecules/RadioGroup/components/RadioGroupPaymentIcon.cjs.map +1 -1
- package/dist/components/molecules/RadioGroup/components/RadioGroupPaymentIcon.js +1 -1
- package/dist/components/molecules/Selects/components/SelectItem.cjs +2 -2
- package/dist/components/molecules/Selects/components/SelectItem.cjs.map +1 -1
- package/dist/components/molecules/Selects/components/SelectItem.js +1 -1
- package/dist/components/organisms/HeaderNavigation/components/NavAccountCard.cjs +2 -2
- package/dist/components/organisms/HeaderNavigation/components/NavAccountCard.cjs.map +1 -1
- package/dist/components/organisms/HeaderNavigation/components/NavAccountCard.js +1 -1
- package/dist/components/organisms/PageHeader/index.cjs +2 -2
- package/dist/components/organisms/PageHeader/index.cjs.map +1 -1
- package/dist/components/organisms/PageHeader/index.js +1 -1
- package/dist/components/organisms/Table/index.cjs +3 -3
- package/dist/components/organisms/Table/index.cjs.map +1 -1
- package/dist/components/organisms/Table/index.js +1 -1
- package/dist/components/organisms/TreeView/index.cjs +2 -2
- package/dist/components/organisms/TreeView/index.cjs.map +1 -1
- package/dist/components/organisms/TreeView/index.js +1 -1
- package/dist/native/components/atoms/Checkbox/index.d.ts +9 -65
- package/dist/native/components/atoms/Checkbox/index.d.ts.map +1 -1
- package/dist/native/components/atoms/Checkbox/index.js +9 -72
- package/dist/native/components/atoms/Checkbox/index.js.map +1 -1
- package/dist/native/components/atoms/Checkboxes/Checkbox/Checkbox.d.ts +36 -0
- package/dist/native/components/atoms/Checkboxes/Checkbox/Checkbox.d.ts.map +1 -0
- package/dist/native/components/atoms/Checkboxes/Checkbox/Checkbox.js +51 -0
- package/dist/native/components/atoms/Checkboxes/Checkbox/Checkbox.js.map +1 -0
- package/dist/native/components/atoms/Checkboxes/CheckboxGroup/CheckboxGroup.d.ts +37 -0
- package/dist/native/components/atoms/Checkboxes/CheckboxGroup/CheckboxGroup.d.ts.map +1 -0
- package/dist/native/components/atoms/Checkboxes/CheckboxGroup/CheckboxGroup.js +41 -0
- package/dist/native/components/atoms/Checkboxes/CheckboxGroup/CheckboxGroup.js.map +1 -0
- package/dist/native/components/atoms/Checkboxes/index.d.ts +6 -0
- package/dist/native/components/atoms/Checkboxes/index.d.ts.map +1 -0
- package/dist/native/components/atoms/Checkboxes/index.js +3 -0
- package/dist/native/components/atoms/Checkboxes/index.js.map +1 -0
- package/dist/native/components/atoms/Checkboxes/providers/CheckboxGroup.context.d.ts +15 -0
- package/dist/native/components/atoms/Checkboxes/providers/CheckboxGroup.context.d.ts.map +1 -0
- package/dist/native/components/atoms/Checkboxes/providers/CheckboxGroup.context.js +7 -0
- package/dist/native/components/atoms/Checkboxes/providers/CheckboxGroup.context.js.map +1 -0
- package/dist/native/components/atoms/Divider/index.d.ts +7 -33
- package/dist/native/components/atoms/Divider/index.d.ts.map +1 -1
- package/dist/native/components/atoms/Divider/index.js +6 -21
- package/dist/native/components/atoms/Divider/index.js.map +1 -1
- package/dist/native/components/atoms/Dividers/Divider/Divider.d.ts +33 -0
- package/dist/native/components/atoms/Dividers/Divider/Divider.d.ts.map +1 -0
- package/dist/native/components/atoms/Dividers/Divider/Divider.js +25 -0
- package/dist/native/components/atoms/Dividers/Divider/Divider.js.map +1 -0
- package/dist/native/components/atoms/{Divider → Dividers/Divider}/Divider.styles.d.ts +1 -1
- package/dist/native/components/atoms/Dividers/Divider/Divider.styles.d.ts.map +1 -0
- package/dist/native/components/atoms/{Divider → Dividers/Divider}/Divider.styles.js +1 -1
- package/dist/native/components/atoms/Dividers/Divider/Divider.styles.js.map +1 -0
- package/dist/native/components/atoms/Dividers/index.d.ts +5 -0
- package/dist/native/components/atoms/Dividers/index.d.ts.map +1 -0
- package/dist/native/components/atoms/Dividers/index.js +2 -0
- package/dist/native/components/atoms/Dividers/index.js.map +1 -0
- package/dist/native/components/atoms/RadioButton/index.d.ts +9 -49
- package/dist/native/components/atoms/RadioButton/index.d.ts.map +1 -1
- package/dist/native/components/atoms/RadioButton/index.js +9 -39
- package/dist/native/components/atoms/RadioButton/index.js.map +1 -1
- package/dist/native/components/atoms/Radios/RadioButton/RadioButton.d.ts +28 -0
- package/dist/native/components/atoms/Radios/RadioButton/RadioButton.d.ts.map +1 -0
- package/dist/native/components/atoms/Radios/RadioButton/RadioButton.js +29 -0
- package/dist/native/components/atoms/Radios/RadioButton/RadioButton.js.map +1 -0
- package/dist/native/components/atoms/Radios/RadioGroup/RadioGroup.d.ts +29 -0
- package/dist/native/components/atoms/Radios/RadioGroup/RadioGroup.d.ts.map +1 -0
- package/dist/native/components/atoms/Radios/RadioGroup/RadioGroup.js +29 -0
- package/dist/native/components/atoms/Radios/RadioGroup/RadioGroup.js.map +1 -0
- package/dist/native/components/atoms/Radios/index.d.ts +6 -0
- package/dist/native/components/atoms/Radios/index.d.ts.map +1 -0
- package/dist/native/components/atoms/Radios/index.js +3 -0
- package/dist/native/components/atoms/Radios/index.js.map +1 -0
- package/dist/native/components/atoms/Radios/providers/RadioGroup.context.d.ts +11 -0
- package/dist/native/components/atoms/Radios/providers/RadioGroup.context.d.ts.map +1 -0
- package/dist/native/components/atoms/Radios/providers/RadioGroup.context.js +7 -0
- package/dist/native/components/atoms/Radios/providers/RadioGroup.context.js.map +1 -0
- package/dist/providers/UnsavedChangesGuardProvider/hooks/useHostApproval.cjs +43 -0
- package/dist/providers/UnsavedChangesGuardProvider/hooks/useHostApproval.cjs.map +1 -0
- package/dist/providers/UnsavedChangesGuardProvider/hooks/useHostApproval.d.ts +14 -0
- package/dist/providers/UnsavedChangesGuardProvider/hooks/useHostApproval.d.ts.map +1 -0
- package/dist/providers/UnsavedChangesGuardProvider/hooks/useHostApproval.js +41 -0
- package/dist/providers/UnsavedChangesGuardProvider/hooks/useHostApproval.js.map +1 -0
- package/dist/providers/UnsavedChangesGuardProvider/hooks/useHostGuardRegistration.cjs +57 -0
- package/dist/providers/UnsavedChangesGuardProvider/hooks/useHostGuardRegistration.cjs.map +1 -0
- package/dist/providers/UnsavedChangesGuardProvider/hooks/useHostGuardRegistration.d.ts +16 -0
- package/dist/providers/UnsavedChangesGuardProvider/hooks/useHostGuardRegistration.d.ts.map +1 -0
- package/dist/providers/UnsavedChangesGuardProvider/hooks/useHostGuardRegistration.js +55 -0
- package/dist/providers/UnsavedChangesGuardProvider/hooks/useHostGuardRegistration.js.map +1 -0
- package/dist/providers/UnsavedChangesGuardProvider/index.cjs +7 -61
- package/dist/providers/UnsavedChangesGuardProvider/index.cjs.map +1 -1
- package/dist/providers/UnsavedChangesGuardProvider/index.d.ts.map +1 -1
- package/dist/providers/UnsavedChangesGuardProvider/index.js +8 -62
- package/dist/providers/UnsavedChangesGuardProvider/index.js.map +1 -1
- package/package.json +1 -1
- package/dist/components/atoms/Divider/Divider.styles.cjs.map +0 -1
- package/dist/components/atoms/Divider/Divider.styles.d.ts.map +0 -1
- package/dist/components/atoms/Divider/Divider.styles.js.map +0 -1
- package/dist/native/components/atoms/Divider/Divider.styles.d.ts.map +0 -1
- package/dist/native/components/atoms/Divider/Divider.styles.js.map +0 -1
|
@@ -1,50 +1,10 @@
|
|
|
1
|
-
import { type
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
hint?: ReactNode;
|
|
11
|
-
/** Disables this option and shows a reduced-opacity state. */
|
|
12
|
-
isDisabled?: boolean;
|
|
13
|
-
/** Extra classes merged onto the root `Pressable`. */
|
|
14
|
-
className?: string;
|
|
15
|
-
/** Web-style accessible name, used as `accessibilityLabel` so shared call sites work on both platforms. */
|
|
16
|
-
'aria-label'?: string;
|
|
17
|
-
/** Overrides the derived `testID` (defaults to `<group>--option-<value>` or `fd-radio-button`). */
|
|
18
|
-
'data-testid'?: string;
|
|
19
|
-
}
|
|
20
|
-
/**
|
|
21
|
-
* React Native `RadioButton` — the same circle, dot, label and hint as web, built from
|
|
22
|
-
* `Pressable` and `View` instead of a react-aria `Radio`. Selection lives in the parent
|
|
23
|
-
* `RadioGroup`; there is no arrow-key navigation between options on touch devices.
|
|
24
|
-
*
|
|
25
|
-
* @summary one option in a mutually exclusive group (React Native)
|
|
26
|
-
*/
|
|
27
|
-
export declare const RadioButton: ({ value, label, hint, className, size: sizeProp, isDisabled: isDisabledProp, "aria-label": ariaLabel, "data-testid": dataTestId, }: RadioButtonProps) => import("react").JSX.Element;
|
|
28
|
-
export interface RadioGroupProps {
|
|
29
|
-
/** The `RadioButton` options. */
|
|
30
|
-
children: ReactNode;
|
|
31
|
-
/** Sets the size of every option in the group. */
|
|
32
|
-
size?: 'sm' | 'md';
|
|
33
|
-
/** Controlled selected value. */
|
|
34
|
-
value?: string | null;
|
|
35
|
-
/** Initial selected value for uncontrolled usage. */
|
|
36
|
-
defaultValue?: string | null;
|
|
37
|
-
/** Called with the newly selected option's `value`. */
|
|
38
|
-
onChange?: (value: string) => void;
|
|
39
|
-
/** Disables every option in the group. */
|
|
40
|
-
isDisabled?: boolean;
|
|
41
|
-
/** Extra classes merged onto the root `View`. */
|
|
42
|
-
className?: string;
|
|
43
|
-
/** Web-style accessible name for the group; native has no `aria-labelledby`, so set this whenever the group needs a name. */
|
|
44
|
-
'aria-label'?: string;
|
|
45
|
-
/** Overrides the `testID` (defaults to `fd-radio-group`). */
|
|
46
|
-
'data-testid'?: string;
|
|
47
|
-
}
|
|
48
|
-
/** React Native `RadioGroup` that stacks its `RadioButton` children, owns which one is selected, and passes them `size` and a derived `testID`. */
|
|
49
|
-
export declare const RadioGroup: ({ children, className, size, value, defaultValue, onChange, isDisabled, "aria-label": ariaLabel, "data-testid": dataTestId, }: RadioGroupProps) => import("react").JSX.Element;
|
|
1
|
+
import { type RadioButtonProps as RadioButtonPropsNext, type RadioGroupProps as RadioGroupPropsNext } from '@flipdish/ui-library/components/atoms/Radios';
|
|
2
|
+
/** @deprecated Import from `@flipdish/ui-library/components/atoms/Radios`. Removed in the next major. */
|
|
3
|
+
export declare const RadioButton: ({ value, label, hint, className, size: sizeProp, isDisabled: isDisabledProp, "aria-label": ariaLabel, "data-testid": dataTestId, }: RadioButtonPropsNext) => import("react").JSX.Element;
|
|
4
|
+
/** @deprecated Import from `@flipdish/ui-library/components/atoms/Radios`. Removed in the next major. */
|
|
5
|
+
export declare const RadioGroup: ({ children, className, size, value, defaultValue, onChange, isDisabled, "aria-label": ariaLabel, "data-testid": dataTestId, }: RadioGroupPropsNext) => import("react").JSX.Element;
|
|
6
|
+
/** @deprecated Import from `@flipdish/ui-library/components/atoms/Radios`. Removed in the next major. */
|
|
7
|
+
export type RadioButtonProps = RadioButtonPropsNext;
|
|
8
|
+
/** @deprecated Import from `@flipdish/ui-library/components/atoms/Radios`. Removed in the next major. */
|
|
9
|
+
export type RadioGroupProps = RadioGroupPropsNext;
|
|
50
10
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/components/atoms/RadioButton/index.native.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/components/atoms/RadioButton/index.native.tsx"],"names":[],"mappings":"AAGA,OAAO,EAEL,KAAK,gBAAgB,IAAI,oBAAoB,EAE7C,KAAK,eAAe,IAAI,mBAAmB,EAC5C,MAAM,8CAA8C,CAAC;AAEtD,yGAAyG;AACzG,eAAO,MAAM,WAAW,2LAAkB,CAAC;AAC3C,yGAAyG;AACzG,eAAO,MAAM,UAAU,qLAAiB,CAAC;AACzC,yGAAyG;AACzG,MAAM,MAAM,gBAAgB,GAAG,oBAAoB,CAAC;AACpD,yGAAyG;AACzG,MAAM,MAAM,eAAe,GAAG,mBAAmB,CAAC"}
|
|
@@ -1,43 +1,13 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { useResolvedTestId, joinTestId, slugifyTestId } from '../../../utilities/testIdUtils/index.js';
|
|
4
|
-
import { createContext, useContext, useState } from 'react';
|
|
5
|
-
import { Pressable, View } from 'react-native';
|
|
6
|
-
import { SelectionControlText } from '../../__internal__/selectionControl/SelectionControlText.js';
|
|
7
|
-
import { selectionControlSizes } from '../../__internal__/selectionControl/selectionControl.styles.js';
|
|
8
|
-
import { SELECTION_CONTROL_HIT_SLOP, getAccessibleHint, getAccessibleName } from '../../__internal__/selectionControl/selectionControl.utils.js';
|
|
1
|
+
import { RadioButton as RadioButton$1 } from '../Radios/RadioButton/RadioButton.js';
|
|
2
|
+
import { RadioGroup as RadioGroup$1 } from '../Radios/RadioGroup/RadioGroup.js';
|
|
9
3
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
*/
|
|
18
|
-
const RadioButton = ({ value, label, hint, className, size: sizeProp = 'sm', isDisabled: isDisabledProp, 'aria-label': ariaLabel, 'data-testid': dataTestId, }) => {
|
|
19
|
-
const group = useContext(RadioGroupContext);
|
|
20
|
-
const size = group?.size ?? sizeProp;
|
|
21
|
-
const isDisabled = Boolean(isDisabledProp || group?.isDisabled);
|
|
22
|
-
const isSelected = group?.selectedValue === value;
|
|
23
|
-
const fallbackTestId = useResolvedTestId({ testId: dataTestId, segment: 'radio-button', rootName: 'radio-button' });
|
|
24
|
-
const radioTestId = !dataTestId && group ? joinTestId(group.testIdPrefix, `option-${slugifyTestId(value)}`) : fallbackTestId;
|
|
25
|
-
return (jsxs(Pressable, { testID: radioTestId, disabled: isDisabled, onPress: () => group?.select(value), accessibilityRole: "radio", hitSlop: SELECTION_CONTROL_HIT_SLOP, accessibilityLabel: getAccessibleName(ariaLabel, label), accessibilityHint: getAccessibleHint(hint), accessibilityState: { checked: isSelected, disabled: isDisabled }, className: cx('relative flex flex-row items-start self-start', selectionControlSizes[size].root, className), children: [jsx(View, { className: cx('size-4 shrink-0 items-center justify-center rounded-full border border-primary bg-primary', size === 'md' && 'size-5', isSelected && 'border-brand-solid bg-brand-solid', isDisabled && 'opacity-50', isDisabled && !isSelected && 'bg-tertiary', (label || hint) && 'mt-0.5'), children: isSelected ? jsx(View, { className: cx('size-1.5 rounded-full bg-fg-white', size === 'md' && 'size-2') }) : null }), jsx(SelectionControlText, { size: size, label: label, hint: hint })] }));
|
|
26
|
-
};
|
|
27
|
-
/** React Native `RadioGroup` that stacks its `RadioButton` children, owns which one is selected, and passes them `size` and a derived `testID`. */
|
|
28
|
-
const RadioGroup = ({ children, className, size = 'sm', value, defaultValue = null, onChange, isDisabled = false, 'aria-label': ariaLabel, 'data-testid': dataTestId, }) => {
|
|
29
|
-
const rootTestId = useResolvedTestId({ testId: dataTestId, segment: 'radio-group', rootName: 'radio-group' });
|
|
30
|
-
const [uncontrolledValue, setUncontrolledValue] = useState(defaultValue);
|
|
31
|
-
const selectedValue = value !== undefined ? value : uncontrolledValue;
|
|
32
|
-
const select = (next) => {
|
|
33
|
-
if (next === selectedValue)
|
|
34
|
-
return;
|
|
35
|
-
if (value === undefined)
|
|
36
|
-
setUncontrolledValue(next);
|
|
37
|
-
onChange?.(next);
|
|
38
|
-
};
|
|
39
|
-
return (jsx(RadioGroupContext.Provider, { value: { size, testIdPrefix: rootTestId, selectedValue, isDisabled, select }, children: jsx(View, { testID: rootTestId, accessibilityRole: "radiogroup", accessibilityLabel: ariaLabel, className: cx('flex flex-col gap-4', className), children: children }) }));
|
|
40
|
-
};
|
|
4
|
+
// Deprecated path, kept so existing imports keep working until the next major: `RadioButton` and `RadioGroup` now live in
|
|
5
|
+
// `atoms/Radios`. A re-export file is banned elsewhere; this one is a temporary deprecation path, and without it this
|
|
6
|
+
// path would resolve to the "not available on React Native" stub.
|
|
7
|
+
/** @deprecated Import from `@flipdish/ui-library/components/atoms/Radios`. Removed in the next major. */
|
|
8
|
+
const RadioButton = RadioButton$1;
|
|
9
|
+
/** @deprecated Import from `@flipdish/ui-library/components/atoms/Radios`. Removed in the next major. */
|
|
10
|
+
const RadioGroup = RadioGroup$1;
|
|
41
11
|
|
|
42
12
|
export { RadioButton, RadioGroup };
|
|
43
13
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../../../../src/components/atoms/RadioButton/index.native.tsx"],"sourcesContent":[null],"names":["
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../../../../src/components/atoms/RadioButton/index.native.tsx"],"sourcesContent":[null],"names":["RadioButtonNext","RadioGroupNext"],"mappings":";;;AAAA;AACA;AACA;AAQA;AACO,MAAM,WAAW,GAAGA;AAC3B;AACO,MAAM,UAAU,GAAGC;;"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { type ReactNode } from 'react';
|
|
2
|
+
export interface RadioButtonProps {
|
|
3
|
+
/** Identifies this option within its `RadioGroup`; selecting it sets the group's value to this. */
|
|
4
|
+
value: string;
|
|
5
|
+
/** Sets the circle size and the label and hint text size; a parent `RadioGroup`'s `size` overrides it. */
|
|
6
|
+
size?: 'sm' | 'md';
|
|
7
|
+
/** Text shown beside the circle; pressing it selects the option. */
|
|
8
|
+
label?: ReactNode;
|
|
9
|
+
/** Supporting text shown below the label. */
|
|
10
|
+
hint?: ReactNode;
|
|
11
|
+
/** Disables this option and shows a reduced-opacity state. */
|
|
12
|
+
isDisabled?: boolean;
|
|
13
|
+
/** Extra classes merged onto the root `Pressable`. */
|
|
14
|
+
className?: string;
|
|
15
|
+
/** Web-style accessible name, used as `accessibilityLabel` so shared call sites work on both platforms. */
|
|
16
|
+
'aria-label'?: string;
|
|
17
|
+
/** Overrides the derived `testID` (defaults to `<group>--option-<value>`, or `fd-radio-button` without a group). */
|
|
18
|
+
'data-testid'?: string;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* React Native `RadioButton` — the same circle, dot, label and hint as web, built from
|
|
22
|
+
* `Pressable` and `View` instead of a react-aria `Radio`. Selection lives in the parent
|
|
23
|
+
* `RadioGroup`; there is no arrow-key navigation between options on touch devices.
|
|
24
|
+
*
|
|
25
|
+
* @summary one option in a mutually exclusive group (React Native)
|
|
26
|
+
*/
|
|
27
|
+
export declare const RadioButton: ({ value, label, hint, className, size: sizeProp, isDisabled: isDisabledProp, "aria-label": ariaLabel, "data-testid": dataTestId, }: RadioButtonProps) => import("react").JSX.Element;
|
|
28
|
+
//# sourceMappingURL=RadioButton.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RadioButton.d.ts","sourceRoot":"","sources":["../../../../../../src/components/atoms/Radios/RadioButton/RadioButton.native.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,SAAS,EAAc,MAAM,OAAO,CAAC;AAOnD,MAAM,WAAW,gBAAgB;IAC/B,mGAAmG;IACnG,KAAK,EAAE,MAAM,CAAC;IACd,0GAA0G;IAC1G,IAAI,CAAC,EAAE,IAAI,GAAG,IAAI,CAAC;IACnB,oEAAoE;IACpE,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB,6CAA6C;IAC7C,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB,8DAA8D;IAC9D,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,sDAAsD;IACtD,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,2GAA2G;IAC3G,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,oHAAoH;IACpH,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED;;;;;;GAMG;AACH,eAAO,MAAM,WAAW,GAAI,oIASzB,gBAAgB,gCAqClB,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
2
|
+
import { cx } from '../../../../utilities/cx/index.js';
|
|
3
|
+
import { useResolvedTestId, joinTestId, slugifyTestId } from '../../../../utilities/testIdUtils/index.js';
|
|
4
|
+
import { useContext } from 'react';
|
|
5
|
+
import { Pressable, View } from 'react-native';
|
|
6
|
+
import { SelectionControlText } from '../../../__internal__/selectionControl/SelectionControlText.js';
|
|
7
|
+
import { selectionControlSizes } from '../../../__internal__/selectionControl/selectionControl.styles.js';
|
|
8
|
+
import { SELECTION_CONTROL_HIT_SLOP, getAccessibleHint, getAccessibleName } from '../../../__internal__/selectionControl/selectionControl.utils.js';
|
|
9
|
+
import { RadioGroupContext } from '../providers/RadioGroup.context.js';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* React Native `RadioButton` — the same circle, dot, label and hint as web, built from
|
|
13
|
+
* `Pressable` and `View` instead of a react-aria `Radio`. Selection lives in the parent
|
|
14
|
+
* `RadioGroup`; there is no arrow-key navigation between options on touch devices.
|
|
15
|
+
*
|
|
16
|
+
* @summary one option in a mutually exclusive group (React Native)
|
|
17
|
+
*/
|
|
18
|
+
const RadioButton = ({ value, label, hint, className, size: sizeProp = 'sm', isDisabled: isDisabledProp, 'aria-label': ariaLabel, 'data-testid': dataTestId, }) => {
|
|
19
|
+
const group = useContext(RadioGroupContext);
|
|
20
|
+
const size = group?.size ?? sizeProp;
|
|
21
|
+
const isDisabled = Boolean(isDisabledProp || group?.isDisabled);
|
|
22
|
+
const isSelected = group?.selectedValue === value;
|
|
23
|
+
const fallbackTestId = useResolvedTestId({ testId: dataTestId, segment: 'radio-button', rootName: 'radio-button' });
|
|
24
|
+
const radioTestId = !dataTestId && group ? joinTestId(group.testIdPrefix, `option-${slugifyTestId(value)}`) : fallbackTestId;
|
|
25
|
+
return (jsxs(Pressable, { testID: radioTestId, disabled: isDisabled, onPress: () => group?.select(value), accessibilityRole: "radio", hitSlop: SELECTION_CONTROL_HIT_SLOP, accessibilityLabel: getAccessibleName(ariaLabel, label), accessibilityHint: getAccessibleHint(hint), accessibilityState: { checked: isSelected, disabled: isDisabled }, className: cx('relative flex flex-row items-start self-start', selectionControlSizes[size].root, className), children: [jsx(View, { className: cx('size-4 shrink-0 items-center justify-center rounded-full border border-primary bg-primary', size === 'md' && 'size-5', isSelected && 'border-brand-solid bg-brand-solid', isDisabled && 'opacity-50', isDisabled && !isSelected && 'bg-tertiary', (label || hint) && 'mt-0.5'), children: isSelected ? jsx(View, { className: cx('size-1.5 rounded-full bg-fg-white', size === 'md' && 'size-2') }) : null }), jsx(SelectionControlText, { size: size, label: label, hint: hint })] }));
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
export { RadioButton };
|
|
29
|
+
//# sourceMappingURL=RadioButton.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RadioButton.js","sources":["../../../../../../../src/components/atoms/Radios/RadioButton/RadioButton.native.tsx"],"sourcesContent":[null],"names":["_jsxs","_jsx"],"mappings":";;;;;;;;;;AA4BA;;;;;;AAMG;AACI,MAAM,WAAW,GAAG,CAAC,EAC1B,KAAK,EACL,KAAK,EACL,IAAI,EACJ,SAAS,EACT,IAAI,EAAE,QAAQ,GAAG,IAAI,EACrB,UAAU,EAAE,cAAc,EAC1B,YAAY,EAAE,SAAS,EACvB,aAAa,EAAE,UAAU,GACR,KAAI;AACrB,IAAA,MAAM,KAAK,GAAG,UAAU,CAAC,iBAAiB,CAAC;AAC3C,IAAA,MAAM,IAAI,GAAG,KAAK,EAAE,IAAI,IAAI,QAAQ;IACpC,MAAM,UAAU,GAAG,OAAO,CAAC,cAAc,IAAI,KAAK,EAAE,UAAU,CAAC;AAC/D,IAAA,MAAM,UAAU,GAAG,KAAK,EAAE,aAAa,KAAK,KAAK;AAEjD,IAAA,MAAM,cAAc,GAAG,iBAAiB,CAAC,EAAE,MAAM,EAAE,UAAU,EAAE,OAAO,EAAE,cAAc,EAAE,QAAQ,EAAE,cAAc,EAAE,CAAC;IACnH,MAAM,WAAW,GAAG,CAAC,UAAU,IAAI,KAAK,GAAG,UAAU,CAAC,KAAK,CAAC,YAAY,EAAE,CAAA,OAAA,EAAU,aAAa,CAAC,KAAK,CAAC,CAAA,CAAE,CAAC,GAAG,cAAc;AAE5H,IAAA,QACEA,IAAA,CAAC,SAAS,EAAA,EACR,MAAM,EAAE,WAAW,EACnB,QAAQ,EAAE,UAAU,EACpB,OAAO,EAAE,MAAM,KAAK,EAAE,MAAM,CAAC,KAAK,CAAC,EACnC,iBAAiB,EAAC,OAAO,EACzB,OAAO,EAAE,0BAA0B,EACnC,kBAAkB,EAAE,iBAAiB,CAAC,SAAS,EAAE,KAAK,CAAC,EACvD,iBAAiB,EAAE,iBAAiB,CAAC,IAAI,CAAC,EAC1C,kBAAkB,EAAE,EAAE,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,UAAU,EAAE,EACjE,SAAS,EAAE,EAAE,CAAC,+CAA+C,EAAE,qBAAqB,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,SAAS,CAAC,EAAA,QAAA,EAAA,CAE3GC,IAAC,IAAI,EAAA,EACH,SAAS,EAAE,EAAE,CACX,2FAA2F,EAC3F,IAAI,KAAK,IAAI,IAAI,QAAQ,EACzB,UAAU,IAAI,mCAAmC,EACjD,UAAU,IAAI,YAAY,EAC1B,UAAU,IAAI,CAAC,UAAU,IAAI,aAAa,EAC1C,CAAC,KAAK,IAAI,IAAI,KAAK,QAAQ,CAC5B,EAAA,QAAA,EAEA,UAAU,GAAGA,GAAA,CAAC,IAAI,IAAC,SAAS,EAAE,EAAE,CAAC,mCAAmC,EAAE,IAAI,KAAK,IAAI,IAAI,QAAQ,CAAC,EAAA,CAAI,GAAG,IAAI,EAAA,CACvG,EAEPA,IAAC,oBAAoB,EAAA,EAAC,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,EAAA,CAAI,CAAA,EAAA,CACpD;AAEhB;;"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { type ReactNode } from 'react';
|
|
2
|
+
export interface RadioGroupProps {
|
|
3
|
+
/** The `RadioButton` options. */
|
|
4
|
+
children: ReactNode;
|
|
5
|
+
/** Sets the size of every option in the group. */
|
|
6
|
+
size?: 'sm' | 'md';
|
|
7
|
+
/** Controlled selected value. */
|
|
8
|
+
value?: string | null;
|
|
9
|
+
/** Initial selected value for uncontrolled usage. */
|
|
10
|
+
defaultValue?: string | null;
|
|
11
|
+
/** Called with the newly selected option's `value`. */
|
|
12
|
+
onChange?: (value: string) => void;
|
|
13
|
+
/** Disables every option in the group. */
|
|
14
|
+
isDisabled?: boolean;
|
|
15
|
+
/** Extra classes merged onto the root `View`. */
|
|
16
|
+
className?: string;
|
|
17
|
+
/** Web-style accessible name for the group; native has no `aria-labelledby`, so set this whenever the group needs a name. */
|
|
18
|
+
'aria-label'?: string;
|
|
19
|
+
/** Overrides the `testID` (defaults to `fd-radio-group`). */
|
|
20
|
+
'data-testid'?: string;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* React Native `RadioGroup` — stacks its `RadioButton` children, owns which one is selected, and passes them `size`
|
|
24
|
+
* and a derived `testID`. There is no arrow-key navigation between options on touch devices.
|
|
25
|
+
*
|
|
26
|
+
* @summary mutually exclusive group of radio options (React Native)
|
|
27
|
+
*/
|
|
28
|
+
export declare const RadioGroup: ({ children, className, size, value, defaultValue, onChange, isDisabled, "aria-label": ariaLabel, "data-testid": dataTestId, }: RadioGroupProps) => import("react").JSX.Element;
|
|
29
|
+
//# sourceMappingURL=RadioGroup.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RadioGroup.d.ts","sourceRoot":"","sources":["../../../../../../src/components/atoms/Radios/RadioGroup/RadioGroup.native.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,SAAS,EAAY,MAAM,OAAO,CAAC;AAIjD,MAAM,WAAW,eAAe;IAC9B,iCAAiC;IACjC,QAAQ,EAAE,SAAS,CAAC;IACpB,kDAAkD;IAClD,IAAI,CAAC,EAAE,IAAI,GAAG,IAAI,CAAC;IACnB,iCAAiC;IACjC,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,qDAAqD;IACrD,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,uDAAuD;IACvD,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACnC,0CAA0C;IAC1C,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,iDAAiD;IACjD,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,6HAA6H;IAC7H,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,6DAA6D;IAC7D,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED;;;;;GAKG;AACH,eAAO,MAAM,UAAU,GAAI,+HAUxB,eAAe,gCAkBjB,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { jsx } from 'react/jsx-runtime';
|
|
2
|
+
import { cx } from '../../../../utilities/cx/index.js';
|
|
3
|
+
import { useResolvedTestId } from '../../../../utilities/testIdUtils/index.js';
|
|
4
|
+
import { useState } from 'react';
|
|
5
|
+
import { View } from 'react-native';
|
|
6
|
+
import { RadioGroupContext } from '../providers/RadioGroup.context.js';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* React Native `RadioGroup` — stacks its `RadioButton` children, owns which one is selected, and passes them `size`
|
|
10
|
+
* and a derived `testID`. There is no arrow-key navigation between options on touch devices.
|
|
11
|
+
*
|
|
12
|
+
* @summary mutually exclusive group of radio options (React Native)
|
|
13
|
+
*/
|
|
14
|
+
const RadioGroup = ({ children, className, size = 'sm', value, defaultValue = null, onChange, isDisabled = false, 'aria-label': ariaLabel, 'data-testid': dataTestId, }) => {
|
|
15
|
+
const rootTestId = useResolvedTestId({ testId: dataTestId, segment: 'radio-group', rootName: 'radio-group' });
|
|
16
|
+
const [uncontrolledValue, setUncontrolledValue] = useState(defaultValue);
|
|
17
|
+
const selectedValue = value !== undefined ? value : uncontrolledValue;
|
|
18
|
+
const select = (next) => {
|
|
19
|
+
if (next === selectedValue)
|
|
20
|
+
return;
|
|
21
|
+
if (value === undefined)
|
|
22
|
+
setUncontrolledValue(next);
|
|
23
|
+
onChange?.(next);
|
|
24
|
+
};
|
|
25
|
+
return (jsx(RadioGroupContext.Provider, { value: { size, testIdPrefix: rootTestId, selectedValue, isDisabled, select }, children: jsx(View, { testID: rootTestId, accessibilityRole: "radiogroup", accessibilityLabel: ariaLabel, className: cx('flex flex-col gap-4', className), children: children }) }));
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
export { RadioGroup };
|
|
29
|
+
//# sourceMappingURL=RadioGroup.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RadioGroup.js","sources":["../../../../../../../src/components/atoms/Radios/RadioGroup/RadioGroup.native.tsx"],"sourcesContent":[null],"names":["_jsx"],"mappings":";;;;;;;AA2BA;;;;;AAKG;AACI,MAAM,UAAU,GAAG,CAAC,EACzB,QAAQ,EACR,SAAS,EACT,IAAI,GAAG,IAAI,EACX,KAAK,EACL,YAAY,GAAG,IAAI,EACnB,QAAQ,EACR,UAAU,GAAG,KAAK,EAClB,YAAY,EAAE,SAAS,EACvB,aAAa,EAAE,UAAU,GACT,KAAI;AACpB,IAAA,MAAM,UAAU,GAAG,iBAAiB,CAAC,EAAE,MAAM,EAAE,UAAU,EAAE,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,aAAa,EAAE,CAAC;IAC7G,MAAM,CAAC,iBAAiB,EAAE,oBAAoB,CAAC,GAAG,QAAQ,CAAgB,YAAY,CAAC;AACvF,IAAA,MAAM,aAAa,GAAG,KAAK,KAAK,SAAS,GAAG,KAAK,GAAG,iBAAiB;AAErE,IAAA,MAAM,MAAM,GAAG,CAAC,IAAY,KAAI;QAC9B,IAAI,IAAI,KAAK,aAAa;YAAE;QAC5B,IAAI,KAAK,KAAK,SAAS;YAAE,oBAAoB,CAAC,IAAI,CAAC;AACnD,QAAA,QAAQ,GAAG,IAAI,CAAC;AAClB,IAAA,CAAC;IAED,QACEA,IAAC,iBAAiB,CAAC,QAAQ,EAAA,EAAC,KAAK,EAAE,EAAE,IAAI,EAAE,YAAY,EAAE,UAAU,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,EAAE,EAAA,QAAA,EACtGA,GAAA,CAAC,IAAI,EAAA,EAAC,MAAM,EAAE,UAAU,EAAE,iBAAiB,EAAC,YAAY,EAAC,kBAAkB,EAAE,SAAS,EAAE,SAAS,EAAE,EAAE,CAAC,qBAAqB,EAAE,SAAS,CAAC,YACpI,QAAQ,EAAA,CACJ,EAAA,CACoB;AAEjC;;"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/** The React Native entry for Radios: explicit named re-exports on purpose, as in `index.tsx`. `RadioButtonBase` is web-only. */
|
|
2
|
+
export type { RadioButtonProps } from './RadioButton/RadioButton';
|
|
3
|
+
export { RadioButton } from './RadioButton/RadioButton';
|
|
4
|
+
export type { RadioGroupProps } from './RadioGroup/RadioGroup';
|
|
5
|
+
export { RadioGroup } from './RadioGroup/RadioGroup';
|
|
6
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/components/atoms/Radios/index.native.tsx"],"names":[],"mappings":"AAAA,iIAAiI;AAKjI,YAAY,EAAE,gBAAgB,EAAE,MAAM,kCAAkC,CAAC;AACzE,OAAO,EAAE,WAAW,EAAE,MAAM,kCAAkC,CAAC;AAC/D,YAAY,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AACtE,OAAO,EAAE,UAAU,EAAE,MAAM,gCAAgC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
interface RadioGroupContextValue {
|
|
2
|
+
size: 'sm' | 'md';
|
|
3
|
+
testIdPrefix: string;
|
|
4
|
+
selectedValue: string | null;
|
|
5
|
+
isDisabled: boolean;
|
|
6
|
+
select: (value: string) => void;
|
|
7
|
+
}
|
|
8
|
+
/** What a native `RadioGroup` shares with the `RadioButton`s beneath it: it owns the selection, where react-aria does on web. */
|
|
9
|
+
export declare const RadioGroupContext: import("react").Context<RadioGroupContextValue | null>;
|
|
10
|
+
export {};
|
|
11
|
+
//# sourceMappingURL=RadioGroup.context.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RadioGroup.context.d.ts","sourceRoot":"","sources":["../../../../../../src/components/atoms/Radios/providers/RadioGroup.context.native.ts"],"names":[],"mappings":"AAEA,UAAU,sBAAsB;IAC9B,IAAI,EAAE,IAAI,GAAG,IAAI,CAAC;IAClB,YAAY,EAAE,MAAM,CAAC;IACrB,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,UAAU,EAAE,OAAO,CAAC;IACpB,MAAM,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;CACjC;AAED,iIAAiI;AACjI,eAAO,MAAM,iBAAiB,wDAAqD,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { createContext } from 'react';
|
|
2
|
+
|
|
3
|
+
/** What a native `RadioGroup` shares with the `RadioButton`s beneath it: it owns the selection, where react-aria does on web. */
|
|
4
|
+
const RadioGroupContext = createContext(null);
|
|
5
|
+
|
|
6
|
+
export { RadioGroupContext };
|
|
7
|
+
//# sourceMappingURL=RadioGroup.context.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RadioGroup.context.js","sources":["../../../../../../../src/components/atoms/Radios/providers/RadioGroup.context.native.ts"],"sourcesContent":[null],"names":[],"mappings":";;AAUA;MACa,iBAAiB,GAAG,aAAa,CAAgC,IAAI;;"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var React = require('react');
|
|
4
|
+
var unsavedChangesGuard_constants = require('../unsavedChangesGuard.constants.cjs');
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Covers the one navigation a host makes after the user agrees to leave, so that move is not held or prompted again.
|
|
8
|
+
* The cover ends when it is taken, when the path or the set of unsaved forms changes, or after a second if the host never moves.
|
|
9
|
+
*
|
|
10
|
+
* @param pathname The current path. A change of it ends the cover; a change of search or hash does not.
|
|
11
|
+
* @param dirtyIds The ids of the forms that are still unsaved. A new set ends the cover.
|
|
12
|
+
* @returns `takeHostApproval`, which reports whether this move is the approved one and ends the cover, and
|
|
13
|
+
* `noteHostAnswer`, which starts the cover when the user agrees to leave.
|
|
14
|
+
*/
|
|
15
|
+
const useHostApproval = (pathname, dirtyIds) => {
|
|
16
|
+
// Set when the user lets a host navigate, so the navigation they just approved is not held or prompted a second time.
|
|
17
|
+
const isHostApproved = React.useRef(false);
|
|
18
|
+
const hostApprovalTimer = React.useRef(undefined);
|
|
19
|
+
const endHostApproval = React.useCallback(() => {
|
|
20
|
+
isHostApproved.current = false;
|
|
21
|
+
clearTimeout(hostApprovalTimer.current);
|
|
22
|
+
}, []);
|
|
23
|
+
/** Whether the host's approved navigation is the one happening now; the approval covers one navigation only. */
|
|
24
|
+
const takeHostApproval = React.useCallback(() => {
|
|
25
|
+
const isApproved = isHostApproved.current;
|
|
26
|
+
endHostApproval();
|
|
27
|
+
return isApproved;
|
|
28
|
+
}, [endHostApproval]);
|
|
29
|
+
// biome-ignore lint/correctness/useExhaustiveDependencies: a new path or a new set of unsaved forms ends the host's approval
|
|
30
|
+
React.useEffect(() => endHostApproval, [pathname, dirtyIds, endHostApproval]);
|
|
31
|
+
const noteHostAnswer = React.useCallback((leave) => {
|
|
32
|
+
endHostApproval();
|
|
33
|
+
if (leave) {
|
|
34
|
+
isHostApproved.current = true;
|
|
35
|
+
// A host that then does not navigate (another app said stay) must not leave the form unguarded.
|
|
36
|
+
hostApprovalTimer.current = setTimeout(endHostApproval, unsavedChangesGuard_constants.HOST_APPROVAL_MS);
|
|
37
|
+
}
|
|
38
|
+
}, [endHostApproval]);
|
|
39
|
+
return { takeHostApproval, noteHostAnswer };
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
exports.useHostApproval = useHostApproval;
|
|
43
|
+
//# sourceMappingURL=useHostApproval.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useHostApproval.cjs","sources":["../../../../src/providers/UnsavedChangesGuardProvider/hooks/useHostApproval.ts"],"sourcesContent":[null],"names":["useRef","useCallback","useEffect","HOST_APPROVAL_MS"],"mappings":";;;;;AAKA;;;;;;;;AAQG;MACU,eAAe,GAAG,CAAC,QAAgB,EAAE,QAA2B,KAAI;;AAE/E,IAAA,MAAM,cAAc,GAAGA,YAAM,CAAC,KAAK,CAAC;AACpC,IAAA,MAAM,iBAAiB,GAAGA,YAAM,CAAgC,SAAS,CAAC;AAE1E,IAAA,MAAM,eAAe,GAAGC,iBAAW,CAAC,MAAK;AACvC,QAAA,cAAc,CAAC,OAAO,GAAG,KAAK;AAC9B,QAAA,YAAY,CAAC,iBAAiB,CAAC,OAAO,CAAC;IACzC,CAAC,EAAE,EAAE,CAAC;;AAEN,IAAA,MAAM,gBAAgB,GAAGA,iBAAW,CAAC,MAAK;AACxC,QAAA,MAAM,UAAU,GAAG,cAAc,CAAC,OAAO;AACzC,QAAA,eAAe,EAAE;AACjB,QAAA,OAAO,UAAU;AACnB,IAAA,CAAC,EAAE,CAAC,eAAe,CAAC,CAAC;;AAGrB,IAAAC,eAAS,CAAC,MAAM,eAAe,EAAE,CAAC,QAAQ,EAAE,QAAQ,EAAE,eAAe,CAAC,CAAC;AAEvE,IAAA,MAAM,cAAc,GAAGD,iBAAW,CAChC,CAAC,KAAc,KAAI;AACjB,QAAA,eAAe,EAAE;QACjB,IAAI,KAAK,EAAE;AACT,YAAA,cAAc,CAAC,OAAO,GAAG,IAAI;;YAE7B,iBAAiB,CAAC,OAAO,GAAG,UAAU,CAAC,eAAe,EAAEE,8CAAgB,CAAC;QAC3E;AACF,IAAA,CAAC,EACD,CAAC,eAAe,CAAC,CAClB;AAED,IAAA,OAAO,EAAE,gBAAgB,EAAE,cAAc,EAAE;AAC7C;;"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Covers the one navigation a host makes after the user agrees to leave, so that move is not held or prompted again.
|
|
3
|
+
* The cover ends when it is taken, when the path or the set of unsaved forms changes, or after a second if the host never moves.
|
|
4
|
+
*
|
|
5
|
+
* @param pathname The current path. A change of it ends the cover; a change of search or hash does not.
|
|
6
|
+
* @param dirtyIds The ids of the forms that are still unsaved. A new set ends the cover.
|
|
7
|
+
* @returns `takeHostApproval`, which reports whether this move is the approved one and ends the cover, and
|
|
8
|
+
* `noteHostAnswer`, which starts the cover when the user agrees to leave.
|
|
9
|
+
*/
|
|
10
|
+
export declare const useHostApproval: (pathname: string, dirtyIds: readonly string[]) => {
|
|
11
|
+
takeHostApproval: () => boolean;
|
|
12
|
+
noteHostAnswer: (leave: boolean) => void;
|
|
13
|
+
};
|
|
14
|
+
//# sourceMappingURL=useHostApproval.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useHostApproval.d.ts","sourceRoot":"","sources":["../../../../src/providers/UnsavedChangesGuardProvider/hooks/useHostApproval.ts"],"names":[],"mappings":"AAKA;;;;;;;;GAQG;AACH,eAAO,MAAM,eAAe,GAAI,UAAU,MAAM,EAAE,UAAU,SAAS,MAAM,EAAE;;4BAoBjE,OAAO;CAYlB,CAAC"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { useRef, useCallback, useEffect } from 'react';
|
|
2
|
+
import { HOST_APPROVAL_MS } from '../unsavedChangesGuard.constants.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Covers the one navigation a host makes after the user agrees to leave, so that move is not held or prompted again.
|
|
6
|
+
* The cover ends when it is taken, when the path or the set of unsaved forms changes, or after a second if the host never moves.
|
|
7
|
+
*
|
|
8
|
+
* @param pathname The current path. A change of it ends the cover; a change of search or hash does not.
|
|
9
|
+
* @param dirtyIds The ids of the forms that are still unsaved. A new set ends the cover.
|
|
10
|
+
* @returns `takeHostApproval`, which reports whether this move is the approved one and ends the cover, and
|
|
11
|
+
* `noteHostAnswer`, which starts the cover when the user agrees to leave.
|
|
12
|
+
*/
|
|
13
|
+
const useHostApproval = (pathname, dirtyIds) => {
|
|
14
|
+
// Set when the user lets a host navigate, so the navigation they just approved is not held or prompted a second time.
|
|
15
|
+
const isHostApproved = useRef(false);
|
|
16
|
+
const hostApprovalTimer = useRef(undefined);
|
|
17
|
+
const endHostApproval = useCallback(() => {
|
|
18
|
+
isHostApproved.current = false;
|
|
19
|
+
clearTimeout(hostApprovalTimer.current);
|
|
20
|
+
}, []);
|
|
21
|
+
/** Whether the host's approved navigation is the one happening now; the approval covers one navigation only. */
|
|
22
|
+
const takeHostApproval = useCallback(() => {
|
|
23
|
+
const isApproved = isHostApproved.current;
|
|
24
|
+
endHostApproval();
|
|
25
|
+
return isApproved;
|
|
26
|
+
}, [endHostApproval]);
|
|
27
|
+
// biome-ignore lint/correctness/useExhaustiveDependencies: a new path or a new set of unsaved forms ends the host's approval
|
|
28
|
+
useEffect(() => endHostApproval, [pathname, dirtyIds, endHostApproval]);
|
|
29
|
+
const noteHostAnswer = useCallback((leave) => {
|
|
30
|
+
endHostApproval();
|
|
31
|
+
if (leave) {
|
|
32
|
+
isHostApproved.current = true;
|
|
33
|
+
// A host that then does not navigate (another app said stay) must not leave the form unguarded.
|
|
34
|
+
hostApprovalTimer.current = setTimeout(endHostApproval, HOST_APPROVAL_MS);
|
|
35
|
+
}
|
|
36
|
+
}, [endHostApproval]);
|
|
37
|
+
return { takeHostApproval, noteHostAnswer };
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
export { useHostApproval };
|
|
41
|
+
//# sourceMappingURL=useHostApproval.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useHostApproval.js","sources":["../../../../src/providers/UnsavedChangesGuardProvider/hooks/useHostApproval.ts"],"sourcesContent":[null],"names":[],"mappings":";;;AAKA;;;;;;;;AAQG;MACU,eAAe,GAAG,CAAC,QAAgB,EAAE,QAA2B,KAAI;;AAE/E,IAAA,MAAM,cAAc,GAAG,MAAM,CAAC,KAAK,CAAC;AACpC,IAAA,MAAM,iBAAiB,GAAG,MAAM,CAAgC,SAAS,CAAC;AAE1E,IAAA,MAAM,eAAe,GAAG,WAAW,CAAC,MAAK;AACvC,QAAA,cAAc,CAAC,OAAO,GAAG,KAAK;AAC9B,QAAA,YAAY,CAAC,iBAAiB,CAAC,OAAO,CAAC;IACzC,CAAC,EAAE,EAAE,CAAC;;AAEN,IAAA,MAAM,gBAAgB,GAAG,WAAW,CAAC,MAAK;AACxC,QAAA,MAAM,UAAU,GAAG,cAAc,CAAC,OAAO;AACzC,QAAA,eAAe,EAAE;AACjB,QAAA,OAAO,UAAU;AACnB,IAAA,CAAC,EAAE,CAAC,eAAe,CAAC,CAAC;;AAGrB,IAAA,SAAS,CAAC,MAAM,eAAe,EAAE,CAAC,QAAQ,EAAE,QAAQ,EAAE,eAAe,CAAC,CAAC;AAEvE,IAAA,MAAM,cAAc,GAAG,WAAW,CAChC,CAAC,KAAc,KAAI;AACjB,QAAA,eAAe,EAAE;QACjB,IAAI,KAAK,EAAE;AACT,YAAA,cAAc,CAAC,OAAO,GAAG,IAAI;;YAE7B,iBAAiB,CAAC,OAAO,GAAG,UAAU,CAAC,eAAe,EAAE,gBAAgB,CAAC;QAC3E;AACF,IAAA,CAAC,EACD,CAAC,eAAe,CAAC,CAClB;AAED,IAAA,OAAO,EAAE,gBAAgB,EAAE,cAAc,EAAE;AAC7C;;"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var React = require('react');
|
|
4
|
+
var unsavedChangesGuard_utils = require('../utilities/unsavedChangesGuard.utils.cjs');
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Registers with the host's navigation bridge while there are unsaved changes, and keeps the answer the host is waiting on.
|
|
8
|
+
* A second ask replaces the first, which is told to stay so the host is never left waiting.
|
|
9
|
+
*
|
|
10
|
+
* @param hasUnsavedChanges Whether any form beneath the provider is still dirty. The bridge is registered only while it is.
|
|
11
|
+
* @param basePath The app's router base path, handed to the host with the registration.
|
|
12
|
+
* @returns The host's current ask, and a way to drop it once the provider has answered.
|
|
13
|
+
*/
|
|
14
|
+
const useHostGuardRegistration = (hasUnsavedChanges, basePath) => {
|
|
15
|
+
const [answerHost, setAnswerHost] = React.useState(null);
|
|
16
|
+
const clearAnswerHost = React.useCallback(() => setAnswerHost(null), []);
|
|
17
|
+
React.useEffect(() => {
|
|
18
|
+
const guard = hasUnsavedChanges ? unsavedChangesGuard_utils.hostGuard() : undefined;
|
|
19
|
+
if (!guard)
|
|
20
|
+
return;
|
|
21
|
+
let pending = null;
|
|
22
|
+
let isRegistered = true;
|
|
23
|
+
const canLeave = () => new Promise((resolve) => {
|
|
24
|
+
// A host holding a registration that has since gone has nothing left to wait for.
|
|
25
|
+
if (!isRegistered)
|
|
26
|
+
return resolve(true);
|
|
27
|
+
// A second request replaces the first, which is answered "stay" so the host is never left waiting.
|
|
28
|
+
pending?.(false);
|
|
29
|
+
pending = resolve;
|
|
30
|
+
setAnswerHost(() => resolve);
|
|
31
|
+
});
|
|
32
|
+
let unregister;
|
|
33
|
+
try {
|
|
34
|
+
unregister = guard.register({ basePath, canLeave });
|
|
35
|
+
}
|
|
36
|
+
catch {
|
|
37
|
+
// A bridge that throws is treated as no bridge: this runs outside the app's error boundary, so it would take the page down.
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
return () => {
|
|
41
|
+
isRegistered = false;
|
|
42
|
+
try {
|
|
43
|
+
unregister();
|
|
44
|
+
}
|
|
45
|
+
catch {
|
|
46
|
+
// Ignored, as a `register` that throws is: this cleanup runs outside the app's error boundary too.
|
|
47
|
+
}
|
|
48
|
+
// Nothing is left to lose once the changes are saved or the form is gone, so a waiting host may go.
|
|
49
|
+
pending?.(true);
|
|
50
|
+
setAnswerHost(null);
|
|
51
|
+
};
|
|
52
|
+
}, [hasUnsavedChanges, basePath]);
|
|
53
|
+
return { answerHost, clearAnswerHost };
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
exports.useHostGuardRegistration = useHostGuardRegistration;
|
|
57
|
+
//# sourceMappingURL=useHostGuardRegistration.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useHostGuardRegistration.cjs","sources":["../../../../src/providers/UnsavedChangesGuardProvider/hooks/useHostGuardRegistration.ts"],"sourcesContent":[null],"names":["useState","useCallback","useEffect","hostGuard"],"mappings":";;;;;AAQA;;;;;;;AAOG;MACU,wBAAwB,GAAG,CAAC,iBAA0B,EAAE,QAAgB,KAAI;IACvF,MAAM,CAAC,UAAU,EAAE,aAAa,CAAC,GAAGA,cAAQ,CAAoB,IAAI,CAAC;AACrE,IAAA,MAAM,eAAe,GAAGC,iBAAW,CAAC,MAAM,aAAa,CAAC,IAAI,CAAC,EAAE,EAAE,CAAC;IAElEC,eAAS,CAAC,MAAK;AACb,QAAA,MAAM,KAAK,GAAG,iBAAiB,GAAGC,mCAAS,EAAE,GAAG,SAAS;AACzD,QAAA,IAAI,CAAC,KAAK;YAAE;QACZ,IAAI,OAAO,GAAsB,IAAI;QACrC,IAAI,YAAY,GAAG,IAAI;QACvB,MAAM,QAAQ,GAAG,MACf,IAAI,OAAO,CAAU,CAAC,OAAO,KAAI;;AAE/B,YAAA,IAAI,CAAC,YAAY;AAAE,gBAAA,OAAO,OAAO,CAAC,IAAI,CAAC;;AAEvC,YAAA,OAAO,GAAG,KAAK,CAAC;YAChB,OAAO,GAAG,OAAO;AACjB,YAAA,aAAa,CAAC,MAAM,OAAO,CAAC;AAC9B,QAAA,CAAC,CAAC;AACJ,QAAA,IAAI,UAAsB;AAC1B,QAAA,IAAI;YACF,UAAU,GAAG,KAAK,CAAC,QAAQ,CAAC,EAAE,QAAQ,EAAE,QAAQ,EAAE,CAAC;QACrD;AAAE,QAAA,MAAM;;YAEN;QACF;AACA,QAAA,OAAO,MAAK;YACV,YAAY,GAAG,KAAK;AACpB,YAAA,IAAI;AACF,gBAAA,UAAU,EAAE;YACd;AAAE,YAAA,MAAM;;YAER;;AAEA,YAAA,OAAO,GAAG,IAAI,CAAC;YACf,aAAa,CAAC,IAAI,CAAC;AACrB,QAAA,CAAC;AACH,IAAA,CAAC,EAAE,CAAC,iBAAiB,EAAE,QAAQ,CAAC,CAAC;AAEjC,IAAA,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE;AACxC;;"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/** Resolves a host's `canLeave`: `true` lets the host navigate. */
|
|
2
|
+
type HostAnswer = (leave: boolean) => void;
|
|
3
|
+
/**
|
|
4
|
+
* Registers with the host's navigation bridge while there are unsaved changes, and keeps the answer the host is waiting on.
|
|
5
|
+
* A second ask replaces the first, which is told to stay so the host is never left waiting.
|
|
6
|
+
*
|
|
7
|
+
* @param hasUnsavedChanges Whether any form beneath the provider is still dirty. The bridge is registered only while it is.
|
|
8
|
+
* @param basePath The app's router base path, handed to the host with the registration.
|
|
9
|
+
* @returns The host's current ask, and a way to drop it once the provider has answered.
|
|
10
|
+
*/
|
|
11
|
+
export declare const useHostGuardRegistration: (hasUnsavedChanges: boolean, basePath: string) => {
|
|
12
|
+
answerHost: HostAnswer | null;
|
|
13
|
+
clearAnswerHost: () => void;
|
|
14
|
+
};
|
|
15
|
+
export {};
|
|
16
|
+
//# sourceMappingURL=useHostGuardRegistration.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useHostGuardRegistration.d.ts","sourceRoot":"","sources":["../../../../src/providers/UnsavedChangesGuardProvider/hooks/useHostGuardRegistration.ts"],"names":[],"mappings":"AAKA,mEAAmE;AACnE,KAAK,UAAU,GAAG,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,CAAC;AAE3C;;;;;;;GAOG;AACH,eAAO,MAAM,wBAAwB,GAAI,mBAAmB,OAAO,EAAE,UAAU,MAAM;;;CAuCpF,CAAC"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { useState, useCallback, useEffect } from 'react';
|
|
2
|
+
import { hostGuard } from '../utilities/unsavedChangesGuard.utils.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Registers with the host's navigation bridge while there are unsaved changes, and keeps the answer the host is waiting on.
|
|
6
|
+
* A second ask replaces the first, which is told to stay so the host is never left waiting.
|
|
7
|
+
*
|
|
8
|
+
* @param hasUnsavedChanges Whether any form beneath the provider is still dirty. The bridge is registered only while it is.
|
|
9
|
+
* @param basePath The app's router base path, handed to the host with the registration.
|
|
10
|
+
* @returns The host's current ask, and a way to drop it once the provider has answered.
|
|
11
|
+
*/
|
|
12
|
+
const useHostGuardRegistration = (hasUnsavedChanges, basePath) => {
|
|
13
|
+
const [answerHost, setAnswerHost] = useState(null);
|
|
14
|
+
const clearAnswerHost = useCallback(() => setAnswerHost(null), []);
|
|
15
|
+
useEffect(() => {
|
|
16
|
+
const guard = hasUnsavedChanges ? hostGuard() : undefined;
|
|
17
|
+
if (!guard)
|
|
18
|
+
return;
|
|
19
|
+
let pending = null;
|
|
20
|
+
let isRegistered = true;
|
|
21
|
+
const canLeave = () => new Promise((resolve) => {
|
|
22
|
+
// A host holding a registration that has since gone has nothing left to wait for.
|
|
23
|
+
if (!isRegistered)
|
|
24
|
+
return resolve(true);
|
|
25
|
+
// A second request replaces the first, which is answered "stay" so the host is never left waiting.
|
|
26
|
+
pending?.(false);
|
|
27
|
+
pending = resolve;
|
|
28
|
+
setAnswerHost(() => resolve);
|
|
29
|
+
});
|
|
30
|
+
let unregister;
|
|
31
|
+
try {
|
|
32
|
+
unregister = guard.register({ basePath, canLeave });
|
|
33
|
+
}
|
|
34
|
+
catch {
|
|
35
|
+
// A bridge that throws is treated as no bridge: this runs outside the app's error boundary, so it would take the page down.
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
return () => {
|
|
39
|
+
isRegistered = false;
|
|
40
|
+
try {
|
|
41
|
+
unregister();
|
|
42
|
+
}
|
|
43
|
+
catch {
|
|
44
|
+
// Ignored, as a `register` that throws is: this cleanup runs outside the app's error boundary too.
|
|
45
|
+
}
|
|
46
|
+
// Nothing is left to lose once the changes are saved or the form is gone, so a waiting host may go.
|
|
47
|
+
pending?.(true);
|
|
48
|
+
setAnswerHost(null);
|
|
49
|
+
};
|
|
50
|
+
}, [hasUnsavedChanges, basePath]);
|
|
51
|
+
return { answerHost, clearAnswerHost };
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
export { useHostGuardRegistration };
|
|
55
|
+
//# sourceMappingURL=useHostGuardRegistration.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useHostGuardRegistration.js","sources":["../../../../src/providers/UnsavedChangesGuardProvider/hooks/useHostGuardRegistration.ts"],"sourcesContent":[null],"names":[],"mappings":";;;AAQA;;;;;;;AAOG;MACU,wBAAwB,GAAG,CAAC,iBAA0B,EAAE,QAAgB,KAAI;IACvF,MAAM,CAAC,UAAU,EAAE,aAAa,CAAC,GAAG,QAAQ,CAAoB,IAAI,CAAC;AACrE,IAAA,MAAM,eAAe,GAAG,WAAW,CAAC,MAAM,aAAa,CAAC,IAAI,CAAC,EAAE,EAAE,CAAC;IAElE,SAAS,CAAC,MAAK;AACb,QAAA,MAAM,KAAK,GAAG,iBAAiB,GAAG,SAAS,EAAE,GAAG,SAAS;AACzD,QAAA,IAAI,CAAC,KAAK;YAAE;QACZ,IAAI,OAAO,GAAsB,IAAI;QACrC,IAAI,YAAY,GAAG,IAAI;QACvB,MAAM,QAAQ,GAAG,MACf,IAAI,OAAO,CAAU,CAAC,OAAO,KAAI;;AAE/B,YAAA,IAAI,CAAC,YAAY;AAAE,gBAAA,OAAO,OAAO,CAAC,IAAI,CAAC;;AAEvC,YAAA,OAAO,GAAG,KAAK,CAAC;YAChB,OAAO,GAAG,OAAO;AACjB,YAAA,aAAa,CAAC,MAAM,OAAO,CAAC;AAC9B,QAAA,CAAC,CAAC;AACJ,QAAA,IAAI,UAAsB;AAC1B,QAAA,IAAI;YACF,UAAU,GAAG,KAAK,CAAC,QAAQ,CAAC,EAAE,QAAQ,EAAE,QAAQ,EAAE,CAAC;QACrD;AAAE,QAAA,MAAM;;YAEN;QACF;AACA,QAAA,OAAO,MAAK;YACV,YAAY,GAAG,KAAK;AACpB,YAAA,IAAI;AACF,gBAAA,UAAU,EAAE;YACd;AAAE,YAAA,MAAM;;YAER;;AAEA,YAAA,OAAO,GAAG,IAAI,CAAC;YACf,aAAa,CAAC,IAAI,CAAC;AACrB,QAAA,CAAC;AACH,IAAA,CAAC,EAAE,CAAC,iBAAiB,EAAE,QAAQ,CAAC,CAAC;AAEjC,IAAA,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE;AACxC;;"}
|