@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,67 +1,13 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var Input = require('@flipdish/ui-library/components/atoms/Input');
|
|
5
|
-
var cx = require('@flipdish/ui-library/utilities/cx');
|
|
6
|
-
var testIdUtils = require('@flipdish/ui-library/utilities/testIdUtils');
|
|
7
|
-
var React = require('react');
|
|
8
|
-
var reactAriaComponents = require('react-aria-components');
|
|
9
|
-
var selectionControl_styles = require('../../__internal__/selectionControl/selectionControl.styles.cjs');
|
|
3
|
+
var Checkboxes = require('@flipdish/ui-library/components/atoms/Checkboxes');
|
|
10
4
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* Checkbox input for selecting one or more options in a form. Supports checked,
|
|
19
|
-
* unchecked, and indeterminate states with optional label and hint text.
|
|
20
|
-
*
|
|
21
|
-
* @summary checkbox input for selecting one or more options in a form
|
|
22
|
-
*/
|
|
23
|
-
const Checkbox = ({ label, hint, size = 'sm', className, 'data-testid': dataTestId, ...ariaCheckboxProps }) => {
|
|
24
|
-
const group = React.useContext(CheckboxGroupContext);
|
|
25
|
-
const groupState = React.useContext(reactAriaComponents.CheckboxGroupStateContext);
|
|
26
|
-
size = group?.size ?? size;
|
|
27
|
-
const fallbackTestId = testIdUtils.useResolvedTestId({ testId: dataTestId, segment: 'checkbox', rootName: 'checkbox' });
|
|
28
|
-
const { value } = ariaCheckboxProps;
|
|
29
|
-
// A box with no `value` leaves the group's state below, so what the group forbids is carried over by hand.
|
|
30
|
-
const isStandaloneInGroup = Boolean(group) && value === undefined;
|
|
31
|
-
// The group's restriction first, else the prop as given: an explicit `false` still overrides a `CheckboxContext`.
|
|
32
|
-
const isDisabled = (isStandaloneInGroup && groupState?.isDisabled) || ariaCheckboxProps.isDisabled;
|
|
33
|
-
const isReadOnly = (isStandaloneInGroup && groupState?.isReadOnly) || ariaCheckboxProps.isReadOnly;
|
|
34
|
-
const isGroupOption = !dataTestId && group && value !== undefined;
|
|
35
|
-
const checkboxTestId = isGroupOption ? testIdUtils.joinTestId(group.testIdPrefix, `option-${testIdUtils.slugifyTestId(value)}`) : fallbackTestId;
|
|
36
|
-
const checkbox = (jsxRuntime.jsx(reactAriaComponents.Checkbox, { ...ariaCheckboxProps,
|
|
37
|
-
// Each box resolves this by itself and would fall back to the browser's own check, whatever its group asked for (react-aria-components 1.19).
|
|
38
|
-
validationBehavior: ariaCheckboxProps.validationBehavior ?? group?.validationBehavior, isDisabled: isDisabled, isReadOnly: isReadOnly, "data-testid": checkboxTestId, className: (state) => cx.cx('relative flex items-start', state.isDisabled && 'cursor-not-allowed', selectionControl_styles.selectionControlSizes[size].root, typeof className === 'function' ? className(state) : className), children: ({ isSelected, isIndeterminate, isDisabled, isFocusVisible }) => (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(CheckboxBase, { size: size, isSelected: isSelected, isIndeterminate: isIndeterminate, isDisabled: isDisabled, isFocusVisible: isFocusVisible, className: label || hint ? 'mt-0.5' : '' }), (label || hint) && (jsxRuntime.jsxs("div", { className: cx.cx('inline-flex flex-col', selectionControl_styles.selectionControlSizes[size].textWrapper), children: [label && jsxRuntime.jsx("p", { className: cx.cx('text-secondary select-none', selectionControl_styles.selectionControlSizes[size].label), children: label }), hint && (
|
|
39
|
-
// biome-ignore lint/a11y/noStaticElementInteractions: not independently interactive — only stops the click reaching outer React handlers, see below
|
|
40
|
-
// biome-ignore lint/a11y/useKeyWithClickEvents: same as above, no keyboard equivalent needed
|
|
41
|
-
jsxRuntime.jsx("span", { className: cx.cx('text-tertiary', selectionControl_styles.selectionControlSizes[size].hint), onClick: (event) => {
|
|
42
|
-
// Deliberately stopPropagation only, no preventDefault (matches the
|
|
43
|
-
// Untitled UI reference). The native <label>->control click-forwarding
|
|
44
|
-
// that toggles the checkbox happens during the real DOM bubble phase,
|
|
45
|
-
// which completes before React's synthetic onClick (delegated at the
|
|
46
|
-
// root) ever runs — so this can't and doesn't block the toggle. It only
|
|
47
|
-
// stops the click reaching an OUTER React onClick a consumer might wrap
|
|
48
|
-
// around the checkbox (e.g. a clickable row/card), so clicking the hint
|
|
49
|
-
// toggles this checkbox without also firing the row's handler.
|
|
50
|
-
event.stopPropagation();
|
|
51
|
-
}, children: hint }))] }))] })) }));
|
|
52
|
-
// A box with no `value` is not one of the group's options: it keeps its own state, as it does on React Native,
|
|
53
|
-
// where react-aria would otherwise hand every box inside a group to that group.
|
|
54
|
-
if (isStandaloneInGroup)
|
|
55
|
-
return jsxRuntime.jsx(reactAriaComponents.CheckboxGroupStateContext.Provider, { value: null, children: checkbox });
|
|
56
|
-
return checkbox;
|
|
57
|
-
};
|
|
58
|
-
Checkbox.displayName = 'Checkbox';
|
|
59
|
-
/** Wrapper around react-aria-components' `CheckboxGroup` that names a set of `Checkbox` children, holds their ticked values as a list, and shows one hint or error for the set. */
|
|
60
|
-
const CheckboxGroup = ({ children, label, hint, size = 'sm', className, 'data-testid': dataTestId, ...props }) => {
|
|
61
|
-
const rootTestId = testIdUtils.useResolvedTestId({ testId: dataTestId, segment: 'checkbox-group', rootName: 'checkbox-group' });
|
|
62
|
-
return (jsxRuntime.jsx(CheckboxGroupContext.Provider, { value: { size, testIdPrefix: rootTestId, validationBehavior: props.validationBehavior }, children: jsxRuntime.jsx(reactAriaComponents.CheckboxGroup, { ...props, "data-testid": rootTestId, className: cx.cx('flex flex-col gap-3', className), children: ({ isInvalid, isRequired }) => (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [label && (jsxRuntime.jsx(Input.Label, { isRequired: isRequired, isInvalid: isInvalid, children: label })), children, hint && jsxRuntime.jsx(Input.HintText, { isInvalid: isInvalid, children: hint })] })) }) }));
|
|
63
|
-
};
|
|
64
|
-
CheckboxGroup.displayName = 'CheckboxGroup';
|
|
5
|
+
/** @deprecated Import from `@flipdish/ui-library/components/atoms/Checkboxes`. Removed in the next major. */
|
|
6
|
+
const Checkbox = Checkboxes.Checkbox;
|
|
7
|
+
/** @deprecated Import from `@flipdish/ui-library/components/atoms/Checkboxes`. Removed in the next major. */
|
|
8
|
+
const CheckboxBase = Checkboxes.CheckboxBase;
|
|
9
|
+
/** @deprecated Import from `@flipdish/ui-library/components/atoms/Checkboxes`. Removed in the next major. */
|
|
10
|
+
const CheckboxGroup = Checkboxes.CheckboxGroup;
|
|
65
11
|
|
|
66
12
|
exports.Checkbox = Checkbox;
|
|
67
13
|
exports.CheckboxBase = CheckboxBase;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sources":["../../../../src/components/atoms/Checkbox/index.tsx"],"sourcesContent":[null],"names":["
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../../../../src/components/atoms/Checkbox/index.tsx"],"sourcesContent":[null],"names":["CheckboxNext","CheckboxBaseNext","CheckboxGroupNext"],"mappings":";;;;AAaA;AACO,MAAM,QAAQ,GAAGA;AACxB;AACO,MAAM,YAAY,GAAGC;AAC5B;AACO,MAAM,aAAa,GAAGC;;;;"}
|
|
@@ -1,63 +1,23 @@
|
|
|
1
|
-
import { type
|
|
2
|
-
|
|
3
|
-
export
|
|
4
|
-
|
|
5
|
-
size?: 'sm' | 'md';
|
|
6
|
-
/** Extra classes merged onto the box element. */
|
|
7
|
-
className?: string;
|
|
8
|
-
/** Draws the keyboard focus ring around the box. */
|
|
9
|
-
isFocusVisible?: boolean;
|
|
10
|
-
/** Fills the box with the brand colour and shows the check mark. */
|
|
11
|
-
isSelected?: boolean;
|
|
12
|
-
/** Dims the box and shows a not-allowed cursor. */
|
|
13
|
-
isDisabled?: boolean;
|
|
14
|
-
/** Fills the box and shows a dash instead of the check mark, taking precedence over `isSelected`. */
|
|
15
|
-
isIndeterminate?: boolean;
|
|
16
|
-
}
|
|
17
|
-
/** Visual-only checkbox square with no input behaviour, for building custom selectable controls; `Checkbox` renders it inside a react-aria `Checkbox`. */
|
|
18
|
-
export declare const CheckboxBase: {
|
|
19
|
-
({ className, isSelected, isDisabled, isIndeterminate, size, isFocusVisible }: CheckboxBaseProps): import("react").JSX.Element;
|
|
1
|
+
import { type CheckboxBaseProps as CheckboxBasePropsNext, type CheckboxGroupProps as CheckboxGroupPropsNext, type CheckboxProps as CheckboxPropsNext } from '@flipdish/ui-library/components/atoms/Checkboxes';
|
|
2
|
+
/** @deprecated Import from `@flipdish/ui-library/components/atoms/Checkboxes`. Removed in the next major. */
|
|
3
|
+
export declare const Checkbox: {
|
|
4
|
+
({ label, hint, size, className, "data-testid": dataTestId, ...ariaCheckboxProps }: CheckboxPropsNext): import("react").JSX.Element;
|
|
20
5
|
displayName: string;
|
|
21
6
|
};
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
/** Sets the box size and the label and hint text size; a parent `CheckboxGroup`'s `size` overrides it. */
|
|
26
|
-
size?: 'sm' | 'md';
|
|
27
|
-
/** Text shown beside the box; clicking it toggles the checkbox. */
|
|
28
|
-
label?: ReactNode;
|
|
29
|
-
/** Supporting text shown below the label. */
|
|
30
|
-
hint?: ReactNode;
|
|
31
|
-
/** Overrides the derived `data-testid` (defaults to `<group>--option-<value>` in a `CheckboxGroup`, or `fd-checkbox`). */
|
|
32
|
-
'data-testid'?: string;
|
|
33
|
-
}
|
|
34
|
-
/**
|
|
35
|
-
* Checkbox input for selecting one or more options in a form. Supports checked,
|
|
36
|
-
* unchecked, and indeterminate states with optional label and hint text.
|
|
37
|
-
*
|
|
38
|
-
* @summary checkbox input for selecting one or more options in a form
|
|
39
|
-
*/
|
|
40
|
-
export declare const Checkbox: {
|
|
41
|
-
({ label, hint, size, className, "data-testid": dataTestId, ...ariaCheckboxProps }: CheckboxProps): import("react").JSX.Element;
|
|
7
|
+
/** @deprecated Import from `@flipdish/ui-library/components/atoms/Checkboxes`. Removed in the next major. */
|
|
8
|
+
export declare const CheckboxBase: {
|
|
9
|
+
({ className, isSelected, isDisabled, isIndeterminate, size, isFocusVisible }: CheckboxBasePropsNext): import("react").JSX.Element;
|
|
42
10
|
displayName: string;
|
|
43
11
|
};
|
|
44
|
-
|
|
45
|
-
/** The `Checkbox` options; each one's `value` is what the group's `value` list holds while it is ticked. */
|
|
46
|
-
children: ReactNode;
|
|
47
|
-
/** Visible name of the group, shown above the boxes. When omitted, pass `aria-label`. */
|
|
48
|
-
label?: ReactNode;
|
|
49
|
-
/** Supporting text beneath the boxes, read out with every box; shown as the group's error while `isInvalid`. */
|
|
50
|
-
hint?: ReactNode;
|
|
51
|
-
/** Sets the size of every checkbox in the group, and of each box's label and hint text. */
|
|
52
|
-
size?: 'sm' | 'md';
|
|
53
|
-
/** Extra classes merged onto the group element. */
|
|
54
|
-
className?: string;
|
|
55
|
-
/** Overrides the `data-testid` (defaults to `fd-checkbox-group`); each option derives `<group>--option-<value>` from it. */
|
|
56
|
-
'data-testid'?: string;
|
|
57
|
-
}
|
|
58
|
-
/** Wrapper around react-aria-components' `CheckboxGroup` that names a set of `Checkbox` children, holds their ticked values as a list, and shows one hint or error for the set. */
|
|
12
|
+
/** @deprecated Import from `@flipdish/ui-library/components/atoms/Checkboxes`. Removed in the next major. */
|
|
59
13
|
export declare const CheckboxGroup: {
|
|
60
|
-
({ children, label, hint, size, className, "data-testid": dataTestId, ...props }:
|
|
14
|
+
({ children, label, hint, size, className, "data-testid": dataTestId, ...props }: CheckboxGroupPropsNext): import("react").JSX.Element;
|
|
61
15
|
displayName: string;
|
|
62
16
|
};
|
|
17
|
+
/** @deprecated Import from `@flipdish/ui-library/components/atoms/Checkboxes`. Removed in the next major. */
|
|
18
|
+
export type CheckboxProps = CheckboxPropsNext;
|
|
19
|
+
/** @deprecated Import from `@flipdish/ui-library/components/atoms/Checkboxes`. Removed in the next major. */
|
|
20
|
+
export type CheckboxBaseProps = CheckboxBasePropsNext;
|
|
21
|
+
/** @deprecated Import from `@flipdish/ui-library/components/atoms/Checkboxes`. Removed in the next major. */
|
|
22
|
+
export type CheckboxGroupProps = CheckboxGroupPropsNext;
|
|
63
23
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/atoms/Checkbox/index.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/atoms/Checkbox/index.tsx"],"names":[],"mappings":"AAIA,OAAO,EAEL,KAAK,iBAAiB,IAAI,qBAAqB,EAE/C,KAAK,kBAAkB,IAAI,sBAAsB,EAEjD,KAAK,aAAa,IAAI,iBAAiB,EACxC,MAAM,kDAAkD,CAAC;AAE1D,6GAA6G;AAC7G,eAAO,MAAM,QAAQ;;;CAAe,CAAC;AACrC,6GAA6G;AAC7G,eAAO,MAAM,YAAY;;;CAAmB,CAAC;AAC7C,6GAA6G;AAC7G,eAAO,MAAM,aAAa;;;CAAoB,CAAC;AAC/C,6GAA6G;AAC7G,MAAM,MAAM,aAAa,GAAG,iBAAiB,CAAC;AAC9C,6GAA6G;AAC7G,MAAM,MAAM,iBAAiB,GAAG,qBAAqB,CAAC;AACtD,6GAA6G;AAC7G,MAAM,MAAM,kBAAkB,GAAG,sBAAsB,CAAC"}
|
|
@@ -1,65 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { Label, HintText } from '@flipdish/ui-library/components/atoms/Input';
|
|
3
|
-
import { cx } from '@flipdish/ui-library/utilities/cx';
|
|
4
|
-
import { useResolvedTestId, joinTestId, slugifyTestId } from '@flipdish/ui-library/utilities/testIdUtils';
|
|
5
|
-
import { createContext, useContext } from 'react';
|
|
6
|
-
import { CheckboxGroupStateContext, Checkbox as Checkbox$1, CheckboxGroup as CheckboxGroup$1 } from 'react-aria-components';
|
|
7
|
-
import { selectionControlSizes } from '../../__internal__/selectionControl/selectionControl.styles.js';
|
|
1
|
+
import { Checkbox as Checkbox$1, CheckboxBase as CheckboxBase$1, CheckboxGroup as CheckboxGroup$1 } from '@flipdish/ui-library/components/atoms/Checkboxes';
|
|
8
2
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* Checkbox input for selecting one or more options in a form. Supports checked,
|
|
17
|
-
* unchecked, and indeterminate states with optional label and hint text.
|
|
18
|
-
*
|
|
19
|
-
* @summary checkbox input for selecting one or more options in a form
|
|
20
|
-
*/
|
|
21
|
-
const Checkbox = ({ label, hint, size = 'sm', className, 'data-testid': dataTestId, ...ariaCheckboxProps }) => {
|
|
22
|
-
const group = useContext(CheckboxGroupContext);
|
|
23
|
-
const groupState = useContext(CheckboxGroupStateContext);
|
|
24
|
-
size = group?.size ?? size;
|
|
25
|
-
const fallbackTestId = useResolvedTestId({ testId: dataTestId, segment: 'checkbox', rootName: 'checkbox' });
|
|
26
|
-
const { value } = ariaCheckboxProps;
|
|
27
|
-
// A box with no `value` leaves the group's state below, so what the group forbids is carried over by hand.
|
|
28
|
-
const isStandaloneInGroup = Boolean(group) && value === undefined;
|
|
29
|
-
// The group's restriction first, else the prop as given: an explicit `false` still overrides a `CheckboxContext`.
|
|
30
|
-
const isDisabled = (isStandaloneInGroup && groupState?.isDisabled) || ariaCheckboxProps.isDisabled;
|
|
31
|
-
const isReadOnly = (isStandaloneInGroup && groupState?.isReadOnly) || ariaCheckboxProps.isReadOnly;
|
|
32
|
-
const isGroupOption = !dataTestId && group && value !== undefined;
|
|
33
|
-
const checkboxTestId = isGroupOption ? joinTestId(group.testIdPrefix, `option-${slugifyTestId(value)}`) : fallbackTestId;
|
|
34
|
-
const checkbox = (jsx(Checkbox$1, { ...ariaCheckboxProps,
|
|
35
|
-
// Each box resolves this by itself and would fall back to the browser's own check, whatever its group asked for (react-aria-components 1.19).
|
|
36
|
-
validationBehavior: ariaCheckboxProps.validationBehavior ?? group?.validationBehavior, isDisabled: isDisabled, isReadOnly: isReadOnly, "data-testid": checkboxTestId, className: (state) => cx('relative flex items-start', state.isDisabled && 'cursor-not-allowed', selectionControlSizes[size].root, typeof className === 'function' ? className(state) : className), children: ({ isSelected, isIndeterminate, isDisabled, isFocusVisible }) => (jsxs(Fragment, { children: [jsx(CheckboxBase, { size: size, isSelected: isSelected, isIndeterminate: isIndeterminate, isDisabled: isDisabled, isFocusVisible: isFocusVisible, className: label || hint ? 'mt-0.5' : '' }), (label || hint) && (jsxs("div", { className: cx('inline-flex flex-col', selectionControlSizes[size].textWrapper), children: [label && jsx("p", { className: cx('text-secondary select-none', selectionControlSizes[size].label), children: label }), hint && (
|
|
37
|
-
// biome-ignore lint/a11y/noStaticElementInteractions: not independently interactive — only stops the click reaching outer React handlers, see below
|
|
38
|
-
// biome-ignore lint/a11y/useKeyWithClickEvents: same as above, no keyboard equivalent needed
|
|
39
|
-
jsx("span", { className: cx('text-tertiary', selectionControlSizes[size].hint), onClick: (event) => {
|
|
40
|
-
// Deliberately stopPropagation only, no preventDefault (matches the
|
|
41
|
-
// Untitled UI reference). The native <label>->control click-forwarding
|
|
42
|
-
// that toggles the checkbox happens during the real DOM bubble phase,
|
|
43
|
-
// which completes before React's synthetic onClick (delegated at the
|
|
44
|
-
// root) ever runs — so this can't and doesn't block the toggle. It only
|
|
45
|
-
// stops the click reaching an OUTER React onClick a consumer might wrap
|
|
46
|
-
// around the checkbox (e.g. a clickable row/card), so clicking the hint
|
|
47
|
-
// toggles this checkbox without also firing the row's handler.
|
|
48
|
-
event.stopPropagation();
|
|
49
|
-
}, children: hint }))] }))] })) }));
|
|
50
|
-
// A box with no `value` is not one of the group's options: it keeps its own state, as it does on React Native,
|
|
51
|
-
// where react-aria would otherwise hand every box inside a group to that group.
|
|
52
|
-
if (isStandaloneInGroup)
|
|
53
|
-
return jsx(CheckboxGroupStateContext.Provider, { value: null, children: checkbox });
|
|
54
|
-
return checkbox;
|
|
55
|
-
};
|
|
56
|
-
Checkbox.displayName = 'Checkbox';
|
|
57
|
-
/** Wrapper around react-aria-components' `CheckboxGroup` that names a set of `Checkbox` children, holds their ticked values as a list, and shows one hint or error for the set. */
|
|
58
|
-
const CheckboxGroup = ({ children, label, hint, size = 'sm', className, 'data-testid': dataTestId, ...props }) => {
|
|
59
|
-
const rootTestId = useResolvedTestId({ testId: dataTestId, segment: 'checkbox-group', rootName: 'checkbox-group' });
|
|
60
|
-
return (jsx(CheckboxGroupContext.Provider, { value: { size, testIdPrefix: rootTestId, validationBehavior: props.validationBehavior }, children: jsx(CheckboxGroup$1, { ...props, "data-testid": rootTestId, className: cx('flex flex-col gap-3', className), children: ({ isInvalid, isRequired }) => (jsxs(Fragment, { children: [label && (jsx(Label, { isRequired: isRequired, isInvalid: isInvalid, children: label })), children, hint && jsx(HintText, { isInvalid: isInvalid, children: hint })] })) }) }));
|
|
61
|
-
};
|
|
62
|
-
CheckboxGroup.displayName = 'CheckboxGroup';
|
|
3
|
+
/** @deprecated Import from `@flipdish/ui-library/components/atoms/Checkboxes`. Removed in the next major. */
|
|
4
|
+
const Checkbox = Checkbox$1;
|
|
5
|
+
/** @deprecated Import from `@flipdish/ui-library/components/atoms/Checkboxes`. Removed in the next major. */
|
|
6
|
+
const CheckboxBase = CheckboxBase$1;
|
|
7
|
+
/** @deprecated Import from `@flipdish/ui-library/components/atoms/Checkboxes`. Removed in the next major. */
|
|
8
|
+
const CheckboxGroup = CheckboxGroup$1;
|
|
63
9
|
|
|
64
10
|
export { Checkbox, CheckboxBase, CheckboxGroup };
|
|
65
11
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../../src/components/atoms/Checkbox/index.tsx"],"sourcesContent":[null],"names":["
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../../src/components/atoms/Checkbox/index.tsx"],"sourcesContent":[null],"names":["CheckboxNext","CheckboxBaseNext","CheckboxGroupNext"],"mappings":";;AAaA;AACO,MAAM,QAAQ,GAAGA;AACxB;AACO,MAAM,YAAY,GAAGC;AAC5B;AACO,MAAM,aAAa,GAAGC;;"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
4
|
+
var cx = require('@flipdish/ui-library/utilities/cx');
|
|
5
|
+
var testIdUtils = require('@flipdish/ui-library/utilities/testIdUtils');
|
|
6
|
+
var React = require('react');
|
|
7
|
+
var reactAriaComponents = require('react-aria-components');
|
|
8
|
+
var selectionControl_styles = require('../../../__internal__/selectionControl/selectionControl.styles.cjs');
|
|
9
|
+
var CheckboxGroup_context = require('../providers/CheckboxGroup.context.cjs');
|
|
10
|
+
var CheckboxBase = require('./CheckboxBase.cjs');
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Checkbox input for selecting one or more options in a form. Supports checked,
|
|
14
|
+
* unchecked, and indeterminate states with optional label and hint text.
|
|
15
|
+
*
|
|
16
|
+
* @summary checkbox input for selecting one or more options in a form
|
|
17
|
+
*/
|
|
18
|
+
const Checkbox = ({ label, hint, size = 'sm', className, 'data-testid': dataTestId, ...ariaCheckboxProps }) => {
|
|
19
|
+
const group = React.useContext(CheckboxGroup_context.CheckboxGroupContext);
|
|
20
|
+
const groupState = React.useContext(reactAriaComponents.CheckboxGroupStateContext);
|
|
21
|
+
size = group?.size ?? size;
|
|
22
|
+
const fallbackTestId = testIdUtils.useResolvedTestId({ testId: dataTestId, segment: 'checkbox', rootName: 'checkbox' });
|
|
23
|
+
const { value } = ariaCheckboxProps;
|
|
24
|
+
// A box with no `value` leaves the group's state below, so what the group forbids is carried over by hand.
|
|
25
|
+
const isStandaloneInGroup = Boolean(group) && value === undefined;
|
|
26
|
+
// The group's restriction first, else the prop as given: an explicit `false` still overrides a `CheckboxContext`.
|
|
27
|
+
const isDisabled = (isStandaloneInGroup && groupState?.isDisabled) || ariaCheckboxProps.isDisabled;
|
|
28
|
+
const isReadOnly = (isStandaloneInGroup && groupState?.isReadOnly) || ariaCheckboxProps.isReadOnly;
|
|
29
|
+
const isGroupOption = !dataTestId && group && value !== undefined;
|
|
30
|
+
const checkboxTestId = isGroupOption ? testIdUtils.joinTestId(group.testIdPrefix, `option-${testIdUtils.slugifyTestId(value)}`) : fallbackTestId;
|
|
31
|
+
const checkbox = (jsxRuntime.jsx(reactAriaComponents.Checkbox, { ...ariaCheckboxProps,
|
|
32
|
+
// Each box resolves this by itself and would fall back to the browser's own check, whatever its group asked for (react-aria-components 1.19).
|
|
33
|
+
validationBehavior: ariaCheckboxProps.validationBehavior ?? group?.validationBehavior, isDisabled: isDisabled, isReadOnly: isReadOnly, "data-testid": checkboxTestId, className: (state) => cx.cx('relative flex items-start', state.isDisabled && 'cursor-not-allowed', selectionControl_styles.selectionControlSizes[size].root, typeof className === 'function' ? className(state) : className), children: ({ isSelected, isIndeterminate, isDisabled, isFocusVisible }) => (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(CheckboxBase.CheckboxBase, { size: size, isSelected: isSelected, isIndeterminate: isIndeterminate, isDisabled: isDisabled, isFocusVisible: isFocusVisible, className: label || hint ? 'mt-0.5' : '' }), (label || hint) && (jsxRuntime.jsxs("div", { className: cx.cx('inline-flex flex-col', selectionControl_styles.selectionControlSizes[size].textWrapper), children: [label && jsxRuntime.jsx("p", { className: cx.cx('text-secondary select-none', selectionControl_styles.selectionControlSizes[size].label), children: label }), hint && (
|
|
34
|
+
// biome-ignore lint/a11y/noStaticElementInteractions: not independently interactive — only stops the click reaching outer React handlers, see below
|
|
35
|
+
// biome-ignore lint/a11y/useKeyWithClickEvents: same as above, no keyboard equivalent needed
|
|
36
|
+
jsxRuntime.jsx("span", { className: cx.cx('text-tertiary', selectionControl_styles.selectionControlSizes[size].hint), onClick: (event) => {
|
|
37
|
+
// Deliberately stopPropagation only, no preventDefault (matches the
|
|
38
|
+
// Untitled UI reference). The native <label>->control click-forwarding
|
|
39
|
+
// that toggles the checkbox happens during the real DOM bubble phase,
|
|
40
|
+
// which completes before React's synthetic onClick (delegated at the
|
|
41
|
+
// root) ever runs — so this can't and doesn't block the toggle. It only
|
|
42
|
+
// stops the click reaching an OUTER React onClick a consumer might wrap
|
|
43
|
+
// around the checkbox (e.g. a clickable row/card), so clicking the hint
|
|
44
|
+
// toggles this checkbox without also firing the row's handler.
|
|
45
|
+
event.stopPropagation();
|
|
46
|
+
}, children: hint }))] }))] })) }));
|
|
47
|
+
// A box with no `value` is not one of the group's options: it keeps its own state, as it does on React Native,
|
|
48
|
+
// where react-aria would otherwise hand every box inside a group to that group.
|
|
49
|
+
if (isStandaloneInGroup)
|
|
50
|
+
return jsxRuntime.jsx(reactAriaComponents.CheckboxGroupStateContext.Provider, { value: null, children: checkbox });
|
|
51
|
+
return checkbox;
|
|
52
|
+
};
|
|
53
|
+
Checkbox.displayName = 'Checkbox';
|
|
54
|
+
|
|
55
|
+
exports.Checkbox = Checkbox;
|
|
56
|
+
//# sourceMappingURL=Checkbox.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Checkbox.cjs","sources":["../../../../../src/components/atoms/Checkboxes/Checkbox/Checkbox.tsx"],"sourcesContent":[null],"names":["useContext","CheckboxGroupContext","CheckboxGroupStateContext","useResolvedTestId","joinTestId","slugifyTestId","_jsx","AriaCheckbox","cx","selectionControlSizes","_jsxs","_Fragment","CheckboxBase"],"mappings":"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"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { type ReactNode, type Ref } from 'react';
|
|
2
|
+
import { type CheckboxProps as AriaCheckboxProps } from 'react-aria-components';
|
|
3
|
+
export interface CheckboxProps extends AriaCheckboxProps {
|
|
4
|
+
/** Ref forwarded to the underlying `<label>`. */
|
|
5
|
+
ref?: Ref<HTMLLabelElement>;
|
|
6
|
+
/** Sets the box size and the label and hint text size; a parent `CheckboxGroup`'s `size` overrides it. */
|
|
7
|
+
size?: 'sm' | 'md';
|
|
8
|
+
/** Text shown beside the box; clicking it toggles the checkbox. */
|
|
9
|
+
label?: ReactNode;
|
|
10
|
+
/** Supporting text shown below the label. */
|
|
11
|
+
hint?: ReactNode;
|
|
12
|
+
/** Overrides the derived `data-testid` (defaults to `<group>--option-<value>` in a `CheckboxGroup`, or `fd-checkbox`). */
|
|
13
|
+
'data-testid'?: string;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Checkbox input for selecting one or more options in a form. Supports checked,
|
|
17
|
+
* unchecked, and indeterminate states with optional label and hint text.
|
|
18
|
+
*
|
|
19
|
+
* @summary checkbox input for selecting one or more options in a form
|
|
20
|
+
*/
|
|
21
|
+
export declare const Checkbox: {
|
|
22
|
+
({ label, hint, size, className, "data-testid": dataTestId, ...ariaCheckboxProps }: CheckboxProps): import("react").JSX.Element;
|
|
23
|
+
displayName: string;
|
|
24
|
+
};
|
|
25
|
+
//# sourceMappingURL=Checkbox.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Checkbox.d.ts","sourceRoot":"","sources":["../../../../../src/components/atoms/Checkboxes/Checkbox/Checkbox.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,SAAS,EAAE,KAAK,GAAG,EAAc,MAAM,OAAO,CAAC;AAC7D,OAAO,EAA4B,KAAK,aAAa,IAAI,iBAAiB,EAA6B,MAAM,uBAAuB,CAAC;AAKrI,MAAM,WAAW,aAAc,SAAQ,iBAAiB;IACtD,iDAAiD;IACjD,GAAG,CAAC,EAAE,GAAG,CAAC,gBAAgB,CAAC,CAAC;IAC5B,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,0HAA0H;IAC1H,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED;;;;;GAKG;AACH,eAAO,MAAM,QAAQ;wFAA8F,aAAa;;CA6E/H,CAAC"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
2
|
+
import { cx } from '@flipdish/ui-library/utilities/cx';
|
|
3
|
+
import { useResolvedTestId, joinTestId, slugifyTestId } from '@flipdish/ui-library/utilities/testIdUtils';
|
|
4
|
+
import { useContext } from 'react';
|
|
5
|
+
import { CheckboxGroupStateContext, Checkbox as Checkbox$1 } from 'react-aria-components';
|
|
6
|
+
import { selectionControlSizes } from '../../../__internal__/selectionControl/selectionControl.styles.js';
|
|
7
|
+
import { CheckboxGroupContext } from '../providers/CheckboxGroup.context.js';
|
|
8
|
+
import { CheckboxBase } from './CheckboxBase.js';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Checkbox input for selecting one or more options in a form. Supports checked,
|
|
12
|
+
* unchecked, and indeterminate states with optional label and hint text.
|
|
13
|
+
*
|
|
14
|
+
* @summary checkbox input for selecting one or more options in a form
|
|
15
|
+
*/
|
|
16
|
+
const Checkbox = ({ label, hint, size = 'sm', className, 'data-testid': dataTestId, ...ariaCheckboxProps }) => {
|
|
17
|
+
const group = useContext(CheckboxGroupContext);
|
|
18
|
+
const groupState = useContext(CheckboxGroupStateContext);
|
|
19
|
+
size = group?.size ?? size;
|
|
20
|
+
const fallbackTestId = useResolvedTestId({ testId: dataTestId, segment: 'checkbox', rootName: 'checkbox' });
|
|
21
|
+
const { value } = ariaCheckboxProps;
|
|
22
|
+
// A box with no `value` leaves the group's state below, so what the group forbids is carried over by hand.
|
|
23
|
+
const isStandaloneInGroup = Boolean(group) && value === undefined;
|
|
24
|
+
// The group's restriction first, else the prop as given: an explicit `false` still overrides a `CheckboxContext`.
|
|
25
|
+
const isDisabled = (isStandaloneInGroup && groupState?.isDisabled) || ariaCheckboxProps.isDisabled;
|
|
26
|
+
const isReadOnly = (isStandaloneInGroup && groupState?.isReadOnly) || ariaCheckboxProps.isReadOnly;
|
|
27
|
+
const isGroupOption = !dataTestId && group && value !== undefined;
|
|
28
|
+
const checkboxTestId = isGroupOption ? joinTestId(group.testIdPrefix, `option-${slugifyTestId(value)}`) : fallbackTestId;
|
|
29
|
+
const checkbox = (jsx(Checkbox$1, { ...ariaCheckboxProps,
|
|
30
|
+
// Each box resolves this by itself and would fall back to the browser's own check, whatever its group asked for (react-aria-components 1.19).
|
|
31
|
+
validationBehavior: ariaCheckboxProps.validationBehavior ?? group?.validationBehavior, isDisabled: isDisabled, isReadOnly: isReadOnly, "data-testid": checkboxTestId, className: (state) => cx('relative flex items-start', state.isDisabled && 'cursor-not-allowed', selectionControlSizes[size].root, typeof className === 'function' ? className(state) : className), children: ({ isSelected, isIndeterminate, isDisabled, isFocusVisible }) => (jsxs(Fragment, { children: [jsx(CheckboxBase, { size: size, isSelected: isSelected, isIndeterminate: isIndeterminate, isDisabled: isDisabled, isFocusVisible: isFocusVisible, className: label || hint ? 'mt-0.5' : '' }), (label || hint) && (jsxs("div", { className: cx('inline-flex flex-col', selectionControlSizes[size].textWrapper), children: [label && jsx("p", { className: cx('text-secondary select-none', selectionControlSizes[size].label), children: label }), hint && (
|
|
32
|
+
// biome-ignore lint/a11y/noStaticElementInteractions: not independently interactive — only stops the click reaching outer React handlers, see below
|
|
33
|
+
// biome-ignore lint/a11y/useKeyWithClickEvents: same as above, no keyboard equivalent needed
|
|
34
|
+
jsx("span", { className: cx('text-tertiary', selectionControlSizes[size].hint), onClick: (event) => {
|
|
35
|
+
// Deliberately stopPropagation only, no preventDefault (matches the
|
|
36
|
+
// Untitled UI reference). The native <label>->control click-forwarding
|
|
37
|
+
// that toggles the checkbox happens during the real DOM bubble phase,
|
|
38
|
+
// which completes before React's synthetic onClick (delegated at the
|
|
39
|
+
// root) ever runs — so this can't and doesn't block the toggle. It only
|
|
40
|
+
// stops the click reaching an OUTER React onClick a consumer might wrap
|
|
41
|
+
// around the checkbox (e.g. a clickable row/card), so clicking the hint
|
|
42
|
+
// toggles this checkbox without also firing the row's handler.
|
|
43
|
+
event.stopPropagation();
|
|
44
|
+
}, children: hint }))] }))] })) }));
|
|
45
|
+
// A box with no `value` is not one of the group's options: it keeps its own state, as it does on React Native,
|
|
46
|
+
// where react-aria would otherwise hand every box inside a group to that group.
|
|
47
|
+
if (isStandaloneInGroup)
|
|
48
|
+
return jsx(CheckboxGroupStateContext.Provider, { value: null, children: checkbox });
|
|
49
|
+
return checkbox;
|
|
50
|
+
};
|
|
51
|
+
Checkbox.displayName = 'Checkbox';
|
|
52
|
+
|
|
53
|
+
export { Checkbox };
|
|
54
|
+
//# sourceMappingURL=Checkbox.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Checkbox.js","sources":["../../../../../src/components/atoms/Checkboxes/Checkbox/Checkbox.tsx"],"sourcesContent":[null],"names":["_jsx","AriaCheckbox","_jsxs","_Fragment"],"mappings":"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"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
4
|
+
var cx = require('@flipdish/ui-library/utilities/cx');
|
|
5
|
+
|
|
6
|
+
/** Visual-only checkbox square with no input behaviour, for building custom selectable controls; `Checkbox` renders it inside a react-aria `Checkbox`. */
|
|
7
|
+
const CheckboxBase = ({ className, isSelected, isDisabled, isIndeterminate, size = 'sm', isFocusVisible = false }) => {
|
|
8
|
+
return (jsxRuntime.jsxs("div", { className: cx.cx('relative flex size-4 shrink-0 cursor-pointer appearance-none items-center justify-center rounded bg-primary ring-1 ring-primary ring-inset', size === 'md' && 'size-5 rounded-md', (isSelected || isIndeterminate) && 'bg-brand-solid ring-brand-solid', isDisabled && 'cursor-not-allowed opacity-50', isDisabled && !(isSelected || isIndeterminate) && 'bg-tertiary', isFocusVisible && 'outline-2 outline-offset-2 outline-focus-ring', className), children: [jsxRuntime.jsx("svg", { "aria-hidden": "true", viewBox: "0 0 14 14", fill: "none", className: cx.cx('pointer-events-none absolute h-3 w-2.5 text-fg-white opacity-0 transition-inherit-all', size === 'md' && 'size-3.5', isIndeterminate && 'opacity-100'), children: jsxRuntime.jsx("path", { d: "M2.91675 7H11.0834", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" }) }), jsxRuntime.jsx("svg", { "aria-hidden": "true", viewBox: "0 0 14 14", fill: "none", className: cx.cx('pointer-events-none absolute size-3 text-fg-white opacity-0 transition-inherit-all', size === 'md' && 'size-3.5', isSelected && !isIndeterminate && 'opacity-100'), children: jsxRuntime.jsx("path", { d: "M11.6666 3.5L5.24992 9.91667L2.33325 7", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" }) })] }));
|
|
9
|
+
};
|
|
10
|
+
CheckboxBase.displayName = 'CheckboxBase';
|
|
11
|
+
|
|
12
|
+
exports.CheckboxBase = CheckboxBase;
|
|
13
|
+
//# sourceMappingURL=CheckboxBase.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CheckboxBase.cjs","sources":["../../../../../src/components/atoms/Checkboxes/Checkbox/CheckboxBase.tsx"],"sourcesContent":[null],"names":["_jsxs","cx","_jsx"],"mappings":";;;;;AAmBA;MACa,YAAY,GAAG,CAAC,EAAE,SAAS,EAAE,UAAU,EAAE,UAAU,EAAE,eAAe,EAAE,IAAI,GAAG,IAAI,EAAE,cAAc,GAAG,KAAK,EAAqB,KAAI;AAC7I,IAAA,QACEA,eAAA,CAAA,KAAA,EAAA,EACE,SAAS,EAAEC,KAAE,CACX,4IAA4I,EAC5I,IAAI,KAAK,IAAI,IAAI,mBAAmB,EACpC,CAAC,UAAU,IAAI,eAAe,KAAK,iCAAiC,EACpE,UAAU,IAAI,+BAA+B,EAC7C,UAAU,IAAI,EAAE,UAAU,IAAI,eAAe,CAAC,IAAI,aAAa,EAC/D,cAAc,IAAI,+CAA+C,EACjE,SAAS,CACV,EAAA,QAAA,EAAA,CAEDC,cAAA,CAAA,KAAA,EAAA,EAAA,aAAA,EACc,MAAM,EAClB,OAAO,EAAC,WAAW,EACnB,IAAI,EAAC,MAAM,EACX,SAAS,EAAED,KAAE,CACX,uFAAuF,EACvF,IAAI,KAAK,IAAI,IAAI,UAAU,EAC3B,eAAe,IAAI,aAAa,CACjC,EAAA,QAAA,EAEDC,yBAAM,CAAC,EAAC,oBAAoB,EAAC,MAAM,EAAC,cAAc,EAAC,WAAW,EAAC,GAAG,EAAC,aAAa,EAAC,OAAO,EAAC,cAAc,EAAC,OAAO,EAAA,CAAG,EAAA,CAC9G,EAENA,cAAA,CAAA,KAAA,EAAA,EAAA,aAAA,EACc,MAAM,EAClB,OAAO,EAAC,WAAW,EACnB,IAAI,EAAC,MAAM,EACX,SAAS,EAAED,KAAE,CACX,oFAAoF,EACpF,IAAI,KAAK,IAAI,IAAI,UAAU,EAC3B,UAAU,IAAI,CAAC,eAAe,IAAI,aAAa,CAChD,EAAA,QAAA,EAEDC,cAAA,CAAA,MAAA,EAAA,EAAM,CAAC,EAAC,wCAAwC,EAAC,MAAM,EAAC,cAAc,EAAC,WAAW,EAAC,GAAG,EAAC,aAAa,EAAC,OAAO,EAAC,cAAc,EAAC,OAAO,EAAA,CAAG,EAAA,CAClI,CAAA,EAAA,CACF;AAEV;AACA,YAAY,CAAC,WAAW,GAAG,cAAc;;"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export interface CheckboxBaseProps {
|
|
2
|
+
/** Sets the box size: 16px at `sm`, 20px at `md`. */
|
|
3
|
+
size?: 'sm' | 'md';
|
|
4
|
+
/** Extra classes merged onto the box element. */
|
|
5
|
+
className?: string;
|
|
6
|
+
/** Draws the keyboard focus ring around the box. */
|
|
7
|
+
isFocusVisible?: boolean;
|
|
8
|
+
/** Fills the box with the brand colour and shows the check mark. */
|
|
9
|
+
isSelected?: boolean;
|
|
10
|
+
/** Dims the box and shows a not-allowed cursor. */
|
|
11
|
+
isDisabled?: boolean;
|
|
12
|
+
/** Fills the box and shows a dash instead of the check mark, taking precedence over `isSelected`. */
|
|
13
|
+
isIndeterminate?: boolean;
|
|
14
|
+
}
|
|
15
|
+
/** Visual-only checkbox square with no input behaviour, for building custom selectable controls; `Checkbox` renders it inside a react-aria `Checkbox`. */
|
|
16
|
+
export declare const CheckboxBase: {
|
|
17
|
+
({ className, isSelected, isDisabled, isIndeterminate, size, isFocusVisible }: CheckboxBaseProps): import("react").JSX.Element;
|
|
18
|
+
displayName: string;
|
|
19
|
+
};
|
|
20
|
+
//# sourceMappingURL=CheckboxBase.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CheckboxBase.d.ts","sourceRoot":"","sources":["../../../../../src/components/atoms/Checkboxes/Checkbox/CheckboxBase.tsx"],"names":[],"mappings":"AAIA,MAAM,WAAW,iBAAiB;IAChC,qDAAqD;IACrD,IAAI,CAAC,EAAE,IAAI,GAAG,IAAI,CAAC;IACnB,iDAAiD;IACjD,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,oDAAoD;IACpD,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,oEAAoE;IACpE,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,mDAAmD;IACnD,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,qGAAqG;IACrG,eAAe,CAAC,EAAE,OAAO,CAAC;CAC3B;AAED,0JAA0J;AAC1J,eAAO,MAAM,YAAY;mFAAiG,iBAAiB;;CAwC1I,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
2
|
+
import { cx } from '@flipdish/ui-library/utilities/cx';
|
|
3
|
+
|
|
4
|
+
/** Visual-only checkbox square with no input behaviour, for building custom selectable controls; `Checkbox` renders it inside a react-aria `Checkbox`. */
|
|
5
|
+
const CheckboxBase = ({ className, isSelected, isDisabled, isIndeterminate, size = 'sm', isFocusVisible = false }) => {
|
|
6
|
+
return (jsxs("div", { className: cx('relative flex size-4 shrink-0 cursor-pointer appearance-none items-center justify-center rounded bg-primary ring-1 ring-primary ring-inset', size === 'md' && 'size-5 rounded-md', (isSelected || isIndeterminate) && 'bg-brand-solid ring-brand-solid', isDisabled && 'cursor-not-allowed opacity-50', isDisabled && !(isSelected || isIndeterminate) && 'bg-tertiary', isFocusVisible && 'outline-2 outline-offset-2 outline-focus-ring', className), children: [jsx("svg", { "aria-hidden": "true", viewBox: "0 0 14 14", fill: "none", className: cx('pointer-events-none absolute h-3 w-2.5 text-fg-white opacity-0 transition-inherit-all', size === 'md' && 'size-3.5', isIndeterminate && 'opacity-100'), children: jsx("path", { d: "M2.91675 7H11.0834", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" }) }), jsx("svg", { "aria-hidden": "true", viewBox: "0 0 14 14", fill: "none", className: cx('pointer-events-none absolute size-3 text-fg-white opacity-0 transition-inherit-all', size === 'md' && 'size-3.5', isSelected && !isIndeterminate && 'opacity-100'), children: jsx("path", { d: "M11.6666 3.5L5.24992 9.91667L2.33325 7", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" }) })] }));
|
|
7
|
+
};
|
|
8
|
+
CheckboxBase.displayName = 'CheckboxBase';
|
|
9
|
+
|
|
10
|
+
export { CheckboxBase };
|
|
11
|
+
//# sourceMappingURL=CheckboxBase.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CheckboxBase.js","sources":["../../../../../src/components/atoms/Checkboxes/Checkbox/CheckboxBase.tsx"],"sourcesContent":[null],"names":["_jsxs","_jsx"],"mappings":";;;AAmBA;MACa,YAAY,GAAG,CAAC,EAAE,SAAS,EAAE,UAAU,EAAE,UAAU,EAAE,eAAe,EAAE,IAAI,GAAG,IAAI,EAAE,cAAc,GAAG,KAAK,EAAqB,KAAI;AAC7I,IAAA,QACEA,IAAA,CAAA,KAAA,EAAA,EACE,SAAS,EAAE,EAAE,CACX,4IAA4I,EAC5I,IAAI,KAAK,IAAI,IAAI,mBAAmB,EACpC,CAAC,UAAU,IAAI,eAAe,KAAK,iCAAiC,EACpE,UAAU,IAAI,+BAA+B,EAC7C,UAAU,IAAI,EAAE,UAAU,IAAI,eAAe,CAAC,IAAI,aAAa,EAC/D,cAAc,IAAI,+CAA+C,EACjE,SAAS,CACV,EAAA,QAAA,EAAA,CAEDC,GAAA,CAAA,KAAA,EAAA,EAAA,aAAA,EACc,MAAM,EAClB,OAAO,EAAC,WAAW,EACnB,IAAI,EAAC,MAAM,EACX,SAAS,EAAE,EAAE,CACX,uFAAuF,EACvF,IAAI,KAAK,IAAI,IAAI,UAAU,EAC3B,eAAe,IAAI,aAAa,CACjC,EAAA,QAAA,EAEDA,cAAM,CAAC,EAAC,oBAAoB,EAAC,MAAM,EAAC,cAAc,EAAC,WAAW,EAAC,GAAG,EAAC,aAAa,EAAC,OAAO,EAAC,cAAc,EAAC,OAAO,EAAA,CAAG,EAAA,CAC9G,EAENA,GAAA,CAAA,KAAA,EAAA,EAAA,aAAA,EACc,MAAM,EAClB,OAAO,EAAC,WAAW,EACnB,IAAI,EAAC,MAAM,EACX,SAAS,EAAE,EAAE,CACX,oFAAoF,EACpF,IAAI,KAAK,IAAI,IAAI,UAAU,EAC3B,UAAU,IAAI,CAAC,eAAe,IAAI,aAAa,CAChD,EAAA,QAAA,EAEDA,GAAA,CAAA,MAAA,EAAA,EAAM,CAAC,EAAC,wCAAwC,EAAC,MAAM,EAAC,cAAc,EAAC,WAAW,EAAC,GAAG,EAAC,aAAa,EAAC,OAAO,EAAC,cAAc,EAAC,OAAO,EAAA,CAAG,EAAA,CAClI,CAAA,EAAA,CACF;AAEV;AACA,YAAY,CAAC,WAAW,GAAG,cAAc;;"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
4
|
+
var Input = require('@flipdish/ui-library/components/atoms/Input');
|
|
5
|
+
var cx = require('@flipdish/ui-library/utilities/cx');
|
|
6
|
+
var testIdUtils = require('@flipdish/ui-library/utilities/testIdUtils');
|
|
7
|
+
var reactAriaComponents = require('react-aria-components');
|
|
8
|
+
var CheckboxGroup_context = require('../providers/CheckboxGroup.context.cjs');
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* A named set of `Checkbox` options, built on react-aria-components' `CheckboxGroup`: it holds the ticked values as a
|
|
12
|
+
* list and shows one hint or error for the set. Use it whenever the user ticks any number of related options.
|
|
13
|
+
*
|
|
14
|
+
* @summary named set of checkboxes whose ticked values form a list
|
|
15
|
+
*/
|
|
16
|
+
const CheckboxGroup = ({ children, label, hint, size = 'sm', className, 'data-testid': dataTestId, ...props }) => {
|
|
17
|
+
const rootTestId = testIdUtils.useResolvedTestId({ testId: dataTestId, segment: 'checkbox-group', rootName: 'checkbox-group' });
|
|
18
|
+
return (jsxRuntime.jsx(CheckboxGroup_context.CheckboxGroupContext.Provider, { value: { size, testIdPrefix: rootTestId, validationBehavior: props.validationBehavior }, children: jsxRuntime.jsx(reactAriaComponents.CheckboxGroup, { ...props, "data-testid": rootTestId, className: cx.cx('flex flex-col gap-3', className), children: ({ isInvalid, isRequired }) => (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [label && (jsxRuntime.jsx(Input.Label, { isRequired: isRequired, isInvalid: isInvalid, children: label })), children, hint && jsxRuntime.jsx(Input.HintText, { isInvalid: isInvalid, children: hint })] })) }) }));
|
|
19
|
+
};
|
|
20
|
+
CheckboxGroup.displayName = 'CheckboxGroup';
|
|
21
|
+
|
|
22
|
+
exports.CheckboxGroup = CheckboxGroup;
|
|
23
|
+
//# sourceMappingURL=CheckboxGroup.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CheckboxGroup.cjs","sources":["../../../../../src/components/atoms/Checkboxes/CheckboxGroup/CheckboxGroup.tsx"],"sourcesContent":[null],"names":["useResolvedTestId","_jsx","CheckboxGroupContext","AriaCheckboxGroup","cx","_jsxs","_Fragment","Label","HintText"],"mappings":";;;;;;;;;AAwBA;;;;;AAKG;AACI,MAAM,aAAa,GAAG,CAAC,EAAE,QAAQ,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,GAAG,IAAI,EAAE,SAAS,EAAE,aAAa,EAAE,UAAU,EAAE,GAAG,KAAK,EAAsB,KAAI;AAC1I,IAAA,MAAM,UAAU,GAAGA,6BAAiB,CAAC,EAAE,MAAM,EAAE,UAAU,EAAE,OAAO,EAAE,gBAAgB,EAAE,QAAQ,EAAE,gBAAgB,EAAE,CAAC;AAEnH,IAAA,QACEC,cAAA,CAACC,0CAAoB,CAAC,QAAQ,EAAA,EAAC,KAAK,EAAE,EAAE,IAAI,EAAE,YAAY,EAAE,UAAU,EAAE,kBAAkB,EAAE,KAAK,CAAC,kBAAkB,EAAE,EAAA,QAAA,EACpHD,eAACE,iCAAiB,EAAA,EAAA,GAAK,KAAK,EAAA,aAAA,EAAe,UAAU,EAAE,SAAS,EAAEC,KAAE,CAAC,qBAAqB,EAAE,SAAS,CAAC,EAAA,QAAA,EACnG,CAAC,EAAE,SAAS,EAAE,UAAU,EAAE,MACzBC,eAAA,CAAAC,mBAAA,EAAA,EAAA,QAAA,EAAA,CACG,KAAK,KACJL,cAAA,CAACM,WAAK,EAAA,EAAC,UAAU,EAAE,UAAU,EAAE,SAAS,EAAE,SAAS,EAAA,QAAA,EAChD,KAAK,EAAA,CACA,CACT,EACA,QAAQ,EAER,IAAI,IAAIN,cAAA,CAACO,cAAQ,EAAA,EAAC,SAAS,EAAE,SAAS,EAAA,QAAA,EAAG,IAAI,EAAA,CAAY,CAAA,EAAA,CACzD,CACJ,EAAA,CACiB,EAAA,CACU;AAEpC;AACA,aAAa,CAAC,WAAW,GAAG,eAAe;;"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
import { type CheckboxGroupProps as AriaCheckboxGroupProps } from 'react-aria-components';
|
|
3
|
+
export interface CheckboxGroupProps extends Omit<AriaCheckboxGroupProps, 'children' | 'className'> {
|
|
4
|
+
/** The `Checkbox` options; each one's `value` is what the group's `value` list holds while it is ticked. */
|
|
5
|
+
children: ReactNode;
|
|
6
|
+
/** Visible name of the group, shown above the boxes. When omitted, pass `aria-label`. */
|
|
7
|
+
label?: ReactNode;
|
|
8
|
+
/** Supporting text beneath the boxes, read out with every box; shown as the group's error while `isInvalid`. */
|
|
9
|
+
hint?: ReactNode;
|
|
10
|
+
/** Sets the size of every checkbox in the group, and of each box's label and hint text. */
|
|
11
|
+
size?: 'sm' | 'md';
|
|
12
|
+
/** Extra classes merged onto the group element. */
|
|
13
|
+
className?: string;
|
|
14
|
+
/** Overrides the `data-testid` (defaults to `fd-checkbox-group`); each option derives `<group>--option-<value>` from it. */
|
|
15
|
+
'data-testid'?: string;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* A named set of `Checkbox` options, built on react-aria-components' `CheckboxGroup`: it holds the ticked values as a
|
|
19
|
+
* list and shows one hint or error for the set. Use it whenever the user ticks any number of related options.
|
|
20
|
+
*
|
|
21
|
+
* @summary named set of checkboxes whose ticked values form a list
|
|
22
|
+
*/
|
|
23
|
+
export declare const CheckboxGroup: {
|
|
24
|
+
({ children, label, hint, size, className, "data-testid": dataTestId, ...props }: CheckboxGroupProps): import("react").JSX.Element;
|
|
25
|
+
displayName: string;
|
|
26
|
+
};
|
|
27
|
+
//# sourceMappingURL=CheckboxGroup.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CheckboxGroup.d.ts","sourceRoot":"","sources":["../../../../../src/components/atoms/Checkboxes/CheckboxGroup/CheckboxGroup.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACvC,OAAO,EAAsC,KAAK,kBAAkB,IAAI,sBAAsB,EAAE,MAAM,uBAAuB,CAAC;AAG9H,MAAM,WAAW,kBAAmB,SAAQ,IAAI,CAAC,sBAAsB,EAAE,UAAU,GAAG,WAAW,CAAC;IAChG,4GAA4G;IAC5G,QAAQ,EAAE,SAAS,CAAC;IACpB,yFAAyF;IACzF,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB,gHAAgH;IAChH,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB,2FAA2F;IAC3F,IAAI,CAAC,EAAE,IAAI,GAAG,IAAI,CAAC;IACnB,mDAAmD;IACnD,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,4HAA4H;IAC5H,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED;;;;;GAKG;AACH,eAAO,MAAM,aAAa;sFAA4F,kBAAkB;;CAqBvI,CAAC"}
|