burne-ui 2.1.2 → 2.1.4
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/README.md +8 -4
- package/cli/burne-ui.js +4 -3
- package/cli/init.js +83 -19
- package/cli/skin-live-slots.json +1 -1
- package/cli/skin-slots.json +2 -0
- package/cli/skin-validate.mjs +83 -2
- package/cli/tailwind.css +20 -0
- package/cli/theme-bridge.css +6 -0
- package/dist/authoring.d.ts +2 -0
- package/dist/authoring.js +8 -0
- package/dist/components/composite/Accordion/accordionStyles.js +1 -1
- package/dist/components/composite/Accordion/useAccordionRootState.js +6 -2
- package/dist/components/composite/AlertDialog/AlertDialog.d.ts +1 -1
- package/dist/components/composite/AlertDialog/AlertDialog.js +1 -0
- package/dist/components/composite/AlertDialog/alertDialogAnimations.d.ts +1 -0
- package/dist/components/composite/AlertDialog/alertDialogAnimations.js +1 -0
- package/dist/components/composite/AlertDialog/alertDialogParts.d.ts +5 -7
- package/dist/components/composite/AlertDialog/alertDialogParts.js +92 -37
- package/dist/components/composite/AlertDialog/alertDialogStyles.d.ts +3 -2
- package/dist/components/composite/AlertDialog/alertDialogStyles.js +5 -3
- package/dist/components/composite/AlertDialog/alertDialogTypes.d.ts +8 -8
- package/dist/components/composite/AlertDialog/index.d.ts +4 -6
- package/dist/components/composite/AlertDialog/useAlertDialogRootState.d.ts +1 -1
- package/dist/components/composite/AlertDialog/useAlertDialogRootState.js +13 -1
- package/dist/components/composite/ButtonGroup/ButtonGroup.d.ts +1 -0
- package/dist/components/composite/ButtonGroup/ButtonGroup.js +59 -25
- package/dist/components/composite/ButtonGroup/buttonGroupAPI.d.ts +1 -0
- package/dist/components/composite/ButtonGroup/buttonGroupAPI.js +7 -1
- package/dist/components/composite/ButtonGroup/buttonGroupContext.d.ts +3 -2
- package/dist/components/composite/ButtonGroup/buttonGroupContext.js +4 -3
- package/dist/components/composite/ButtonGroup/buttonGroupStyles.js +1 -1
- package/dist/components/composite/ButtonGroup/buttonGroupTypes.d.ts +3 -1
- package/dist/components/composite/ButtonGroup/index.d.ts +1 -0
- package/dist/components/composite/CheckboxGroup/CheckboxGroup.js +25 -7
- package/dist/components/composite/CheckboxGroup/useCheckboxGroupRootState.d.ts +5 -1
- package/dist/components/composite/CheckboxGroup/useCheckboxGroupRootState.js +74 -23
- package/dist/components/composite/Form/Form.js +6 -0
- package/dist/components/composite/Form/formAPI.d.ts +2 -0
- package/dist/components/composite/Form/formAPI.js +29 -2
- package/dist/components/composite/Form/formContext.js +4 -0
- package/dist/components/composite/Form/formParts.js +20 -6
- package/dist/components/composite/Form/formStyles.js +4 -4
- package/dist/components/composite/Form/useFormControlProps.js +25 -15
- package/dist/components/composite/Form/useFormFieldBinding.js +22 -14
- package/dist/components/composite/Form/useFormRootState.d.ts +2 -1
- package/dist/components/composite/Form/useFormRootState.js +151 -89
- package/dist/components/composite/RadioGroup/RadioGroup.js +30 -10
- package/dist/components/composite/RadioGroup/radioGroupA11y.d.ts +10 -0
- package/dist/components/composite/RadioGroup/radioGroupA11y.js +75 -0
- package/dist/components/composite/RadioGroup/radioGroupTypes.d.ts +2 -2
- package/dist/components/composite/RadioGroup/useRadioGroupRootState.d.ts +7 -1
- package/dist/components/composite/RadioGroup/useRadioGroupRootState.js +105 -34
- package/dist/components/composite/ToggleButtonGroup/ToggleButtonGroup.js +3 -1
- package/dist/components/composite/ToggleButtonGroup/toggleButtonGroupA11y.d.ts +1 -1
- package/dist/components/composite/ToggleButtonGroup/toggleButtonGroupA11y.js +13 -7
- package/dist/components/composite/ToggleButtonGroup/toggleButtonGroupAPI.d.ts +2 -0
- package/dist/components/composite/ToggleButtonGroup/toggleButtonGroupAPI.js +19 -4
- package/dist/components/composite/ToggleButtonGroup/useToggleButtonGroupRootState.js +20 -7
- package/dist/components/composite/utils/optionGroupFieldset.d.ts +1 -1
- package/dist/components/core/Alert/Alert.js +3 -1
- package/dist/components/core/Alert/alertAnimations.js +14 -3
- package/dist/components/core/Alert/alertStyles.d.ts +1 -1
- package/dist/components/core/Alert/alertStyles.js +1 -1
- package/dist/components/core/AppShell/AppShell.js +16 -4
- package/dist/components/core/AppShell/appShellAnimations.js +1 -1
- package/dist/components/core/AppShell/appShellStyles.d.ts +3 -2
- package/dist/components/core/AppShell/appShellStyles.js +8 -2
- package/dist/components/core/AspectRatio/AspectRatio.js +6 -3
- package/dist/components/core/AspectRatio/aspectRatioAnimations.js +1 -1
- package/dist/components/core/AspectRatio/aspectRatioStyles.d.ts +5 -2
- package/dist/components/core/AspectRatio/aspectRatioStyles.js +27 -3
- package/dist/components/core/Avatar/avatarParts.js +26 -6
- package/dist/components/core/Avatar/avatarTypes.d.ts +1 -0
- package/dist/components/core/Avatar/useAvatarRootState.d.ts +1 -0
- package/dist/components/core/Avatar/useAvatarRootState.js +6 -2
- package/dist/components/core/Badge/Badge.js +9 -3
- package/dist/components/core/Badge/badgeA11y.js +6 -0
- package/dist/components/core/Badge/badgeAPI.js +4 -4
- package/dist/components/core/Badge/badgeAnimations.js +18 -3
- package/dist/components/core/Badge/badgeParts.d.ts +1 -1
- package/dist/components/core/Badge/badgeParts.js +6 -3
- package/dist/components/core/Badge/badgeStyles.d.ts +1 -0
- package/dist/components/core/Badge/badgeStyles.js +2 -0
- package/dist/components/core/Badge/badgeTypes.d.ts +2 -0
- package/dist/components/core/Badge/useBadgeRootState.d.ts +1 -0
- package/dist/components/core/Badge/useBadgeRootState.js +2 -1
- package/dist/components/core/Breadcrumbs/breadcrumbsAPI.js +11 -5
- package/dist/components/core/Breadcrumbs/breadcrumbsParts.js +21 -6
- package/dist/components/core/Breadcrumbs/breadcrumbsStyles.js +4 -4
- package/dist/components/core/Button/Button.js +34 -18
- package/dist/components/core/Button/buttonAnimations.d.ts +1 -1
- package/dist/components/core/Button/buttonAnimations.js +18 -7
- package/dist/components/core/Button/buttonParts.js +2 -2
- package/dist/components/core/Button/buttonStyles.d.ts +4 -3
- package/dist/components/core/Button/buttonStyles.js +11 -10
- package/dist/components/core/Button/buttonTypes.d.ts +2 -1
- package/dist/components/core/Button/useButtonRootState.d.ts +2 -1
- package/dist/components/core/Button/useButtonRootState.js +10 -4
- package/dist/components/core/Calendar/Calendar.js +15 -4
- package/dist/components/core/Calendar/calendarAPI.d.ts +10 -6
- package/dist/components/core/Calendar/calendarAPI.js +110 -30
- package/dist/components/core/Calendar/calendarParts.js +173 -72
- package/dist/components/core/Calendar/calendarStyles.d.ts +5 -5
- package/dist/components/core/Calendar/calendarStyles.js +8 -8
- package/dist/components/core/Calendar/calendarTypes.d.ts +8 -0
- package/dist/components/core/Calendar/useCalendarRootState.js +60 -19
- package/dist/components/core/Calendar/useCalendarViewModels.js +6 -6
- package/dist/components/core/Card/Card.d.ts +1 -0
- package/dist/components/core/Card/Card.js +17 -7
- package/dist/components/core/Card/cardAPI.d.ts +1 -0
- package/dist/components/core/Card/cardAPI.js +23 -1
- package/dist/components/core/Card/cardAnimations.d.ts +1 -1
- package/dist/components/core/Card/cardAnimations.js +41 -10
- package/dist/components/core/Card/cardParts.d.ts +1 -1
- package/dist/components/core/Card/cardParts.js +26 -6
- package/dist/components/core/Card/cardStyles.d.ts +5 -4
- package/dist/components/core/Card/cardStyles.js +9 -6
- package/dist/components/core/Card/cardTypes.d.ts +4 -0
- package/dist/components/core/Card/index.d.ts +1 -0
- package/dist/components/core/Checkbox/Checkbox.js +9 -1
- package/dist/components/core/Checkbox/checkboxAPI.d.ts +2 -0
- package/dist/components/core/Checkbox/checkboxAPI.js +36 -0
- package/dist/components/core/Checkbox/checkboxParts.d.ts +5 -4
- package/dist/components/core/Checkbox/checkboxParts.js +74 -48
- package/dist/components/core/Checkbox/checkboxStyles.d.ts +4 -3
- package/dist/components/core/Checkbox/checkboxStyles.js +5 -3
- package/dist/components/core/Checkbox/checkboxTypes.d.ts +2 -0
- package/dist/components/core/Checkbox/index.d.ts +1 -1
- package/dist/components/core/Checkbox/useCheckboxRootState.d.ts +4 -1
- package/dist/components/core/Checkbox/useCheckboxRootState.js +43 -30
- package/dist/components/core/CloseButton/CloseButton.js +2 -1
- package/dist/components/core/CloseButton/closeButtonAnimations.js +38 -9
- package/dist/components/core/CloseButton/closeButtonParts.js +3 -4
- package/dist/components/core/ColorPicker/ColorPicker.js +27 -8
- package/dist/components/core/ColorPicker/ColorSlider.d.ts +2 -0
- package/dist/components/core/ColorPicker/ColorSlider.js +131 -53
- package/dist/components/core/ColorPicker/ColorSwatch.js +22 -4
- package/dist/components/core/ColorPicker/colorPickerAnimations.d.ts +1 -1
- package/dist/components/core/ColorPicker/colorPickerAnimations.js +33 -8
- package/dist/components/core/ColorPicker/colorPickerParts.js +125 -32
- package/dist/components/core/ColorPicker/colorPickerStyles.d.ts +11 -3
- package/dist/components/core/ColorPicker/colorPickerStyles.js +13 -3
- package/dist/components/core/ColorPicker/colorPickerTypes.d.ts +4 -0
- package/dist/components/core/ColorPicker/colorSliderStyles.d.ts +2 -2
- package/dist/components/core/ColorPicker/colorSliderStyles.js +4 -4
- package/dist/components/core/ColorPicker/colorSliderTypes.d.ts +2 -0
- package/dist/components/core/ColorPicker/colorSwatchStyles.d.ts +1 -0
- package/dist/components/core/ColorPicker/colorSwatchStyles.js +4 -0
- package/dist/components/core/ColorPicker/colorUtils.d.ts +2 -1
- package/dist/components/core/ColorPicker/colorUtils.js +33 -10
- package/dist/components/core/ColorPicker/index.d.ts +2 -0
- package/dist/components/core/ColorPicker/useColorPickerRootState.d.ts +3 -1
- package/dist/components/core/ColorPicker/useColorPickerRootState.js +65 -30
- package/dist/components/core/ComboBox/ComboBox.js +13 -1
- package/dist/components/core/ComboBox/comboBoxAnimations.d.ts +3 -2
- package/dist/components/core/ComboBox/comboBoxAnimations.js +5 -2
- package/dist/components/core/ComboBox/comboBoxFieldParts.js +1 -1
- package/dist/components/core/ComboBox/comboBoxParts.d.ts +3 -1
- package/dist/components/core/ComboBox/comboBoxParts.js +114 -28
- package/dist/components/core/ComboBox/comboBoxStyles.d.ts +4 -4
- package/dist/components/core/ComboBox/comboBoxStyles.js +4 -4
- package/dist/components/core/ComboBox/comboBoxTypes.d.ts +5 -0
- package/dist/components/core/ComboBox/useComboBoxInputState.d.ts +3 -2
- package/dist/components/core/ComboBox/useComboBoxInputState.js +130 -62
- package/dist/components/core/ComboBox/useComboBoxRootState.js +44 -18
- package/dist/components/core/Container/Container.js +3 -0
- package/dist/components/core/Container/containerStyles.d.ts +2 -1
- package/dist/components/core/Container/containerStyles.js +2 -1
- package/dist/components/core/ContextMenu/ContextMenu.d.ts +3 -1
- package/dist/components/core/ContextMenu/ContextMenu.js +177 -19
- package/dist/components/core/ContextMenu/contextMenuStyles.d.ts +1 -1
- package/dist/components/core/ContextMenu/contextMenuStyles.js +1 -1
- package/dist/components/core/ContextMenu/index.d.ts +3 -1
- package/dist/components/core/DatePicker/DatePicker.js +8 -3
- package/dist/components/core/DatePicker/datePickerAPI.d.ts +2 -0
- package/dist/components/core/DatePicker/datePickerAPI.js +43 -0
- package/dist/components/core/DatePicker/datePickerAnimations.d.ts +2 -1
- package/dist/components/core/DatePicker/datePickerAnimations.js +9 -5
- package/dist/components/core/DatePicker/datePickerParts.js +29 -5
- package/dist/components/core/DatePicker/datePickerStyles.d.ts +2 -2
- package/dist/components/core/DatePicker/datePickerStyles.js +2 -2
- package/dist/components/core/DatePicker/datePickerTypes.d.ts +2 -0
- package/dist/components/core/DatePicker/useDatePickerRootState.d.ts +2 -0
- package/dist/components/core/DatePicker/useDatePickerRootState.js +63 -24
- package/dist/components/core/Dialog/Dialog.d.ts +1 -1
- package/dist/components/core/Dialog/Dialog.js +2 -0
- package/dist/components/core/Dialog/dialogAnimations.d.ts +1 -0
- package/dist/components/core/Dialog/dialogAnimations.js +1 -0
- package/dist/components/core/Dialog/dialogParts.d.ts +1 -1
- package/dist/components/core/Dialog/dialogParts.js +8 -3
- package/dist/components/core/Dialog/dialogStyles.d.ts +1 -1
- package/dist/components/core/Dialog/dialogStyles.js +2 -2
- package/dist/components/core/Dialog/dialogTypes.d.ts +4 -1
- package/dist/components/core/Dialog/useDialogRootState.d.ts +1 -1
- package/dist/components/core/Dialog/useDialogRootState.js +2 -0
- package/dist/components/core/Disclosure/Disclosure.js +10 -4
- package/dist/components/core/Disclosure/disclosureAnimations.js +7 -5
- package/dist/components/core/Disclosure/disclosureContentPart.js +3 -0
- package/dist/components/core/Disclosure/disclosureParts.js +29 -20
- package/dist/components/core/Disclosure/disclosureStyles.d.ts +1 -1
- package/dist/components/core/Disclosure/disclosureStyles.js +3 -3
- package/dist/components/core/Disclosure/useDisclosureContentDrag.js +3 -1
- package/dist/components/core/Disclosure/useDisclosureGroupRootState.js +17 -7
- package/dist/components/core/Disclosure/useDisclosureRootState.js +12 -12
- package/dist/components/core/Drawer/Drawer.d.ts +1 -1
- package/dist/components/core/Drawer/Drawer.js +2 -0
- package/dist/components/core/Drawer/drawerAnimations.d.ts +1 -0
- package/dist/components/core/Drawer/drawerAnimations.js +1 -0
- package/dist/components/core/Drawer/drawerParts.js +14 -9
- package/dist/components/core/Drawer/drawerStyles.d.ts +1 -1
- package/dist/components/core/Drawer/drawerStyles.js +2 -2
- package/dist/components/core/Drawer/drawerTypes.d.ts +4 -1
- package/dist/components/core/Drawer/useDrawerHandleDrag.d.ts +2 -0
- package/dist/components/core/Drawer/useDrawerHandleDrag.js +117 -35
- package/dist/components/core/Drawer/useDrawerRootState.d.ts +1 -1
- package/dist/components/core/Drawer/useDrawerRootState.js +3 -0
- package/dist/components/core/Dropdown/dropdownA11y.js +4 -1
- package/dist/components/core/Dropdown/dropdownAnimations.d.ts +3 -2
- package/dist/components/core/Dropdown/dropdownAnimations.js +79 -29
- package/dist/components/core/Dropdown/dropdownItemParts.d.ts +3 -1
- package/dist/components/core/Dropdown/dropdownItemParts.js +25 -5
- package/dist/components/core/Dropdown/dropdownParts.js +40 -11
- package/dist/components/core/Dropdown/dropdownStyles.d.ts +3 -3
- package/dist/components/core/Dropdown/dropdownStyles.js +3 -3
- package/dist/components/core/Dropdown/dropdownSubParts.js +47 -16
- package/dist/components/core/Dropdown/dropdownTypes.d.ts +13 -2
- package/dist/components/core/Dropdown/index.d.ts +3 -1
- package/dist/components/core/Dropdown/useDropdownItemState.d.ts +5 -1
- package/dist/components/core/Dropdown/useDropdownItemState.js +3 -1
- package/dist/components/core/Dropdown/useDropdownRootState.js +16 -5
- package/dist/components/core/Expandable/expandableA11y.d.ts +1 -0
- package/dist/components/core/Expandable/expandableA11y.js +5 -0
- package/dist/components/core/Expandable/expandableAPI.d.ts +1 -0
- package/dist/components/core/Expandable/expandableAPI.js +19 -11
- package/dist/components/core/Expandable/expandableAnimations.d.ts +1 -1
- package/dist/components/core/Expandable/expandableAnimations.js +9 -9
- package/dist/components/core/Expandable/expandableParts.js +31 -23
- package/dist/components/core/Expandable/expandableStyles.d.ts +1 -1
- package/dist/components/core/Expandable/expandableStyles.js +1 -1
- package/dist/components/core/Expandable/useExpandableRootState.js +5 -3
- package/dist/components/core/Field/fieldParts.d.ts +2 -2
- package/dist/components/core/Field/fieldParts.js +2 -1
- package/dist/components/core/Field/fieldStyles.js +1 -1
- package/dist/components/core/Grid/Grid.js +3 -0
- package/dist/components/core/Grid/gridStyles.d.ts +2 -1
- package/dist/components/core/Grid/gridStyles.js +2 -1
- package/dist/components/core/Header/Header.js +3 -1
- package/dist/components/core/Header/headerStyles.d.ts +3 -2
- package/dist/components/core/Header/headerStyles.js +9 -2
- package/dist/components/core/HoverCard/hoverCardParts.js +23 -11
- package/dist/components/core/Input/inputAffixParts.js +6 -0
- package/dist/components/core/Input/inputAnimations.js +3 -1
- package/dist/components/core/Input/inputControlParts.js +48 -14
- package/dist/components/core/Input/inputFieldParts.js +1 -1
- package/dist/components/core/Input/inputStyles.d.ts +5 -5
- package/dist/components/core/Input/inputStyles.js +5 -5
- package/dist/components/core/Input/inputTypes.d.ts +1 -0
- package/dist/components/core/Input/useInputRootState.js +2 -1
- package/dist/components/core/Kbd/Kbd.js +3 -1
- package/dist/components/core/Kbd/kbdAnimations.js +16 -4
- package/dist/components/core/Kbd/kbdParts.js +6 -4
- package/dist/components/core/Kbd/kbdStyles.d.ts +1 -1
- package/dist/components/core/Kbd/kbdStyles.js +1 -1
- package/dist/components/core/Kbd/kbdTextPart.js +5 -2
- package/dist/components/core/Kbd/useKbdRootState.js +6 -2
- package/dist/components/core/Label/Label.d.ts +2 -1
- package/dist/components/core/Label/Label.js +8 -1
- package/dist/components/core/Label/labelParts.d.ts +1 -0
- package/dist/components/core/Label/labelTypes.d.ts +3 -1
- package/dist/components/core/Label/useLabelRootState.d.ts +2 -1
- package/dist/components/core/Label/useLabelRootState.js +3 -1
- package/dist/components/core/Link/Link.d.ts +1 -1
- package/dist/components/core/Link/Link.js +38 -25
- package/dist/components/core/Link/linkAPI.d.ts +3 -1
- package/dist/components/core/Link/linkAPI.js +8 -4
- package/dist/components/core/Link/linkAnchorBodyPart.d.ts +2 -2
- package/dist/components/core/Link/linkAnchorBodyPart.js +48 -8
- package/dist/components/core/Link/linkAnimations.d.ts +1 -1
- package/dist/components/core/Link/linkAnimations.js +29 -14
- package/dist/components/core/Link/linkIconSlotPart.d.ts +1 -1
- package/dist/components/core/Link/linkIconSlotPart.js +3 -3
- package/dist/components/core/Link/linkStyles.d.ts +5 -3
- package/dist/components/core/Link/linkStyles.js +6 -3
- package/dist/components/core/Link/linkTypes.d.ts +14 -1
- package/dist/components/core/Link/useLinkRootState.d.ts +2 -0
- package/dist/components/core/ListBox/ListBox.d.ts +1 -0
- package/dist/components/core/ListBox/ListBox.js +2 -0
- package/dist/components/core/ListBox/index.d.ts +1 -0
- package/dist/components/core/ListBox/listBoxAnimations.d.ts +5 -2
- package/dist/components/core/ListBox/listBoxAnimations.js +15 -3
- package/dist/components/core/ListBox/listBoxParts.js +21 -5
- package/dist/components/core/ListBox/listBoxStyles.d.ts +3 -3
- package/dist/components/core/ListBox/listBoxStyles.js +3 -3
- package/dist/components/core/ListBox/listBoxTypes.d.ts +5 -1
- package/dist/components/core/ListBox/useListBoxItemState.d.ts +1 -1
- package/dist/components/core/ListBox/useListBoxRootState.d.ts +1 -1
- package/dist/components/core/ListBox/useListBoxRootState.js +31 -6
- package/dist/components/core/ListBox/useListBoxVirtualWindow.d.ts +1 -0
- package/dist/components/core/ListBox/useListBoxVirtualWindow.js +11 -4
- package/dist/components/core/Loading/Loading.js +1 -1
- package/dist/components/core/Loading/loadingAnimations.d.ts +2 -2
- package/dist/components/core/Loading/loadingAnimations.js +12 -5
- package/dist/components/core/Loading/loadingParts.js +1 -1
- package/dist/components/core/Loading/loadingStyles.js +1 -1
- package/dist/components/core/Meter/Meter.js +21 -3
- package/dist/components/core/Meter/meterAPI.d.ts +4 -0
- package/dist/components/core/Meter/meterAPI.js +13 -2
- package/dist/components/core/Meter/meterParts.js +6 -2
- package/dist/components/core/Meter/meterStyles.d.ts +1 -1
- package/dist/components/core/Meter/meterStyles.js +1 -1
- package/dist/components/core/Meter/meterTypes.d.ts +1 -0
- package/dist/components/core/Meter/useMeterRootState.js +3 -2
- package/dist/components/core/Meter/useMeterTrackState.d.ts +1 -1
- package/dist/components/core/Meter/useMeterTrackState.js +15 -10
- package/dist/components/core/NumberInput/NumberInput.js +13 -2
- package/dist/components/core/NumberInput/numberInputParts.d.ts +4 -1
- package/dist/components/core/NumberInput/numberInputParts.js +30 -4
- package/dist/components/core/NumberInput/numberInputStyles.js +2 -2
- package/dist/components/core/NumberInput/useNumberInputRootState.js +47 -33
- package/dist/components/core/Pagination/paginationAPI.d.ts +4 -1
- package/dist/components/core/Pagination/paginationAPI.js +60 -17
- package/dist/components/core/Pagination/paginationAnimations.js +6 -0
- package/dist/components/core/Pagination/paginationParts.d.ts +1 -1
- package/dist/components/core/Pagination/paginationParts.js +82 -22
- package/dist/components/core/Pagination/paginationStyles.d.ts +7 -6
- package/dist/components/core/Pagination/paginationStyles.js +7 -6
- package/dist/components/core/Pagination/paginationTypes.d.ts +1 -0
- package/dist/components/core/Pagination/usePaginationRootState.js +12 -6
- package/dist/components/core/PinInput/pinInputAnimations.d.ts +6 -1
- package/dist/components/core/PinInput/pinInputAnimations.js +13 -4
- package/dist/components/core/PinInput/pinInputParts.js +84 -20
- package/dist/components/core/PinInput/pinInputStyles.d.ts +1 -1
- package/dist/components/core/PinInput/pinInputStyles.js +2 -2
- package/dist/components/core/PinInput/pinInputTypes.d.ts +4 -0
- package/dist/components/core/PinInput/usePinInputRootState.js +71 -33
- package/dist/components/core/Popover/popoverAnimations.d.ts +1 -0
- package/dist/components/core/Popover/popoverAnimations.js +33 -7
- package/dist/components/core/Popover/popoverParts.js +62 -14
- package/dist/components/core/Popover/popoverStyles.d.ts +1 -1
- package/dist/components/core/Popover/popoverStyles.js +1 -1
- package/dist/components/core/Popover/popoverTypes.d.ts +1 -0
- package/dist/components/core/Popover/usePopoverRootState.js +46 -14
- package/dist/components/core/ProgressBar/ProgressBar.js +21 -3
- package/dist/components/core/ProgressBar/progressBarA11y.d.ts +1 -1
- package/dist/components/core/ProgressBar/progressBarA11y.js +4 -2
- package/dist/components/core/ProgressBar/progressBarAPI.d.ts +4 -0
- package/dist/components/core/ProgressBar/progressBarAPI.js +13 -2
- package/dist/components/core/ProgressBar/progressBarParts.js +6 -2
- package/dist/components/core/ProgressBar/progressBarStyles.d.ts +1 -1
- package/dist/components/core/ProgressBar/progressBarStyles.js +1 -1
- package/dist/components/core/ProgressBar/progressBarTypes.d.ts +3 -0
- package/dist/components/core/ProgressBar/useProgressBarRootState.js +6 -3
- package/dist/components/core/ProgressBar/useProgressBarTrackState.d.ts +1 -1
- package/dist/components/core/ProgressBar/useProgressBarTrackState.js +18 -11
- package/dist/components/core/Radio/Radio.js +6 -1
- package/dist/components/core/Radio/radioParts.js +6 -3
- package/dist/components/core/Radio/radioStyles.d.ts +3 -3
- package/dist/components/core/Radio/radioStyles.js +3 -3
- package/dist/components/core/Radio/radioTypes.d.ts +1 -0
- package/dist/components/core/Radio/useRadioRootState.d.ts +5 -2
- package/dist/components/core/Radio/useRadioRootState.js +80 -36
- package/dist/components/core/Resizable/Resizable.js +185 -20
- package/dist/components/core/Resizable/index.d.ts +1 -0
- package/dist/components/core/Resizable/resizableAnimations.js +1 -1
- package/dist/components/core/Resizable/resizableParts.d.ts +1 -0
- package/dist/components/core/Resizable/resizableParts.js +96 -42
- package/dist/components/core/Resizable/resizableStyles.d.ts +3 -2
- package/dist/components/core/Resizable/resizableStyles.js +3 -2
- package/dist/components/core/Resizable/resizableTypes.d.ts +10 -2
- package/dist/components/core/Ripple/Ripple.js +3 -2
- package/dist/components/core/Ripple/rippleAPI.d.ts +1 -0
- package/dist/components/core/Ripple/rippleAPI.js +7 -0
- package/dist/components/core/Ripple/rippleStyles.d.ts +1 -1
- package/dist/components/core/Ripple/rippleStyles.js +1 -1
- package/dist/components/core/ScrollArea/ScrollArea.js +1 -1
- package/dist/components/core/ScrollArea/scrollAreaAPI.d.ts +11 -2
- package/dist/components/core/ScrollArea/scrollAreaAPI.js +65 -9
- package/dist/components/core/ScrollArea/scrollAreaParts.js +31 -10
- package/dist/components/core/ScrollArea/scrollAreaStyles.d.ts +1 -1
- package/dist/components/core/ScrollArea/scrollAreaStyles.js +1 -1
- package/dist/components/core/ScrollArea/scrollAreaTypes.d.ts +4 -0
- package/dist/components/core/ScrollArea/useScrollAreaRootState.d.ts +1 -1
- package/dist/components/core/ScrollArea/useScrollAreaRootState.js +49 -10
- package/dist/components/core/SearchInput/SearchInput.js +24 -9
- package/dist/components/core/SearchInput/searchInputAnimations.d.ts +7 -6
- package/dist/components/core/SearchInput/searchInputAnimations.js +23 -18
- package/dist/components/core/SearchInput/searchInputParts.d.ts +2 -2
- package/dist/components/core/SearchInput/searchInputParts.js +22 -10
- package/dist/components/core/SearchInput/searchInputStyles.d.ts +5 -3
- package/dist/components/core/SearchInput/searchInputStyles.js +6 -5
- package/dist/components/core/SearchInput/searchInputTypes.d.ts +1 -0
- package/dist/components/core/SearchInput/useSearchInputRootState.d.ts +3 -3
- package/dist/components/core/SearchInput/useSearchInputRootState.js +52 -34
- package/dist/components/core/Select/Select.js +13 -1
- package/dist/components/core/Select/selectAnimations.d.ts +3 -2
- package/dist/components/core/Select/selectAnimations.js +5 -2
- package/dist/components/core/Select/selectParts.d.ts +3 -1
- package/dist/components/core/Select/selectParts.js +2 -1
- package/dist/components/core/Select/selectStyles.d.ts +3 -3
- package/dist/components/core/Select/selectStyles.js +3 -3
- package/dist/components/core/Select/selectTriggerParts.js +79 -28
- package/dist/components/core/Select/selectTypes.d.ts +1 -0
- package/dist/components/core/Select/useSelectRootState.js +33 -16
- package/dist/components/core/SelectionIndicator/selectionIndicatorAnimations.js +23 -3
- package/dist/components/core/SelectionThumb/SelectionThumb.js +1 -1
- package/dist/components/core/Separator/Separator.d.ts +2 -1
- package/dist/components/core/Separator/Separator.js +3 -1
- package/dist/components/core/Separator/index.d.ts +1 -1
- package/dist/components/core/Separator/separatorStyles.d.ts +2 -2
- package/dist/components/core/Separator/separatorStyles.js +2 -2
- package/dist/components/core/Separator/separatorTypes.d.ts +4 -0
- package/dist/components/core/Sidebar/Sidebar.js +15 -2
- package/dist/components/core/Sidebar/sidebarAnimations.d.ts +2 -2
- package/dist/components/core/Sidebar/sidebarAnimations.js +4 -3
- package/dist/components/core/Sidebar/sidebarStyles.d.ts +2 -1
- package/dist/components/core/Sidebar/sidebarStyles.js +2 -1
- package/dist/components/core/Skeleton/skeletonParts.js +8 -5
- package/dist/components/core/Skeleton/skeletonStyles.d.ts +10 -0
- package/dist/components/core/Skeleton/skeletonStyles.js +20 -0
- package/dist/components/core/Slider/Slider.js +9 -3
- package/dist/components/core/Slider/sliderAPI.d.ts +5 -4
- package/dist/components/core/Slider/sliderAPI.js +86 -42
- package/dist/components/core/Slider/sliderAnimations.d.ts +1 -1
- package/dist/components/core/Slider/sliderAnimations.js +2 -2
- package/dist/components/core/Slider/sliderParts.js +11 -2
- package/dist/components/core/Slider/sliderStyles.d.ts +4 -4
- package/dist/components/core/Slider/sliderStyles.js +18 -6
- package/dist/components/core/Slider/sliderThumbParts.d.ts +2 -0
- package/dist/components/core/Slider/sliderThumbParts.js +16 -4
- package/dist/components/core/Slider/sliderTrackParts.js +10 -4
- package/dist/components/core/Slider/sliderTypes.d.ts +9 -1
- package/dist/components/core/Slider/useSliderRootState.d.ts +3 -2
- package/dist/components/core/Slider/useSliderRootState.js +104 -49
- package/dist/components/core/Slider/useSliderTrackState.js +198 -39
- package/dist/components/core/Stack/Stack.js +3 -0
- package/dist/components/core/Stack/stackStyles.d.ts +2 -1
- package/dist/components/core/Stack/stackStyles.js +2 -1
- package/dist/components/core/Stepper/index.d.ts +10 -1
- package/dist/components/core/Stepper/stepperAPI.d.ts +2 -2
- package/dist/components/core/Stepper/stepperAPI.js +4 -3
- package/dist/components/core/Stepper/stepperAnimations.d.ts +1 -0
- package/dist/components/core/Stepper/stepperAnimations.js +28 -2
- package/dist/components/core/Stepper/stepperParts.d.ts +11 -2
- package/dist/components/core/Stepper/stepperParts.js +38 -9
- package/dist/components/core/Stepper/stepperStyles.js +3 -1
- package/dist/components/core/Stepper/stepperTypes.d.ts +3 -2
- package/dist/components/core/Stepper/useStepperRootState.js +10 -3
- package/dist/components/core/Surface/Surface.js +3 -1
- package/dist/components/core/Switch/Switch.js +12 -1
- package/dist/components/core/Switch/switchAPI.d.ts +2 -0
- package/dist/components/core/Switch/switchAPI.js +18 -1
- package/dist/components/core/Switch/switchAnimations.js +29 -9
- package/dist/components/core/Switch/switchControlParts.js +93 -30
- package/dist/components/core/Switch/switchGeometry.js +2 -2
- package/dist/components/core/Switch/switchSimpleParts.d.ts +2 -1
- package/dist/components/core/Switch/switchSimpleParts.js +3 -1
- package/dist/components/core/Switch/switchStyles.d.ts +3 -3
- package/dist/components/core/Switch/switchStyles.js +3 -3
- package/dist/components/core/Switch/switchTypes.d.ts +8 -0
- package/dist/components/core/Switch/useSwitchRootState.js +54 -17
- package/dist/components/core/Table/Table.d.ts +1 -0
- package/dist/components/core/Table/Table.js +2 -0
- package/dist/components/core/Table/index.d.ts +1 -0
- package/dist/components/core/Table/tableAPI.d.ts +6 -1
- package/dist/components/core/Table/tableAPI.js +73 -5
- package/dist/components/core/Table/tableContext.js +6 -1
- package/dist/components/core/Table/tableParts.js +77 -34
- package/dist/components/core/Table/tableStyles.d.ts +13 -2
- package/dist/components/core/Table/tableStyles.js +26 -3
- package/dist/components/core/Table/tableTypes.d.ts +4 -0
- package/dist/components/core/Table/tableVirtualRows.js +140 -27
- package/dist/components/core/Table/useTableContentState.d.ts +2 -1
- package/dist/components/core/Table/useTableContentState.js +32 -6
- package/dist/components/core/Tabs/tabsA11y.d.ts +4 -3
- package/dist/components/core/Tabs/tabsA11y.js +5 -4
- package/dist/components/core/Tabs/tabsContext.d.ts +5 -0
- package/dist/components/core/Tabs/tabsContext.js +12 -0
- package/dist/components/core/Tabs/tabsPanelPart.js +11 -1
- package/dist/components/core/Tabs/tabsParts.js +70 -32
- package/dist/components/core/Tabs/tabsStyles.d.ts +5 -2
- package/dist/components/core/Tabs/tabsStyles.js +13 -4
- package/dist/components/core/Tabs/tabsTabPart.js +55 -50
- package/dist/components/core/Tabs/tabsTypes.d.ts +2 -2
- package/dist/components/core/Tabs/useSlidingTabIndicator.d.ts +1 -1
- package/dist/components/core/Tabs/useSlidingTabIndicator.js +25 -10
- package/dist/components/core/Tabs/useTabsRootState.js +13 -5
- package/dist/components/core/TagsInput/TagsInput.js +13 -2
- package/dist/components/core/TagsInput/index.d.ts +2 -0
- package/dist/components/core/TagsInput/tagsInputParts.d.ts +6 -2
- package/dist/components/core/TagsInput/tagsInputParts.js +81 -14
- package/dist/components/core/TagsInput/tagsInputStyles.js +2 -2
- package/dist/components/core/TagsInput/tagsInputTypes.d.ts +3 -0
- package/dist/components/core/TagsInput/useTagsInputRootState.js +78 -33
- package/dist/components/core/Text/Text.d.ts +2 -1
- package/dist/components/core/Text/Text.js +3 -1
- package/dist/components/core/Text/index.d.ts +1 -1
- package/dist/components/core/Text/textTypes.d.ts +4 -0
- package/dist/components/core/TextArea/textAreaAnimations.js +5 -3
- package/dist/components/core/TextArea/textAreaParts.js +94 -12
- package/dist/components/core/TextArea/textAreaStyles.d.ts +3 -3
- package/dist/components/core/TextArea/textAreaStyles.js +2 -2
- package/dist/components/core/TextArea/textAreaTypes.d.ts +1 -0
- package/dist/components/core/TextArea/useTextAreaRootState.js +2 -1
- package/dist/components/core/TimeField/TimeField.js +6 -1
- package/dist/components/core/TimeField/timeFieldAnimations.d.ts +3 -2
- package/dist/components/core/TimeField/timeFieldAnimations.js +13 -4
- package/dist/components/core/TimeField/timeFieldParts.js +50 -30
- package/dist/components/core/TimeField/timeFieldStyles.d.ts +1 -1
- package/dist/components/core/TimeField/timeFieldStyles.js +1 -1
- package/dist/components/core/TimeField/timeFieldTypes.d.ts +2 -0
- package/dist/components/core/TimeField/useTimeFieldControlState.d.ts +4 -1
- package/dist/components/core/TimeField/useTimeFieldControlState.js +141 -39
- package/dist/components/core/TimeField/useTimeFieldRootState.js +3 -1
- package/dist/components/core/Toast/toastA11y.js +17 -7
- package/dist/components/core/Toast/toastAPI.d.ts +17 -1
- package/dist/components/core/Toast/toastAPI.js +82 -0
- package/dist/components/core/Toast/toastAnimations.d.ts +1 -1
- package/dist/components/core/Toast/toastAnimations.js +106 -98
- package/dist/components/core/Toast/toastProvider.js +25 -3
- package/dist/components/core/Toast/toastStyles.d.ts +5 -3
- package/dist/components/core/Toast/toastStyles.js +5 -3
- package/dist/components/core/Toast/toastTypes.d.ts +9 -0
- package/dist/components/core/Toast/useToastProviderState.js +61 -6
- package/dist/components/core/ToggleButton/ToggleButton.js +23 -7
- package/dist/components/core/ToggleButton/toggleButtonAnimations.d.ts +4 -2
- package/dist/components/core/ToggleButton/toggleButtonAnimations.js +64 -41
- package/dist/components/core/ToggleButton/toggleButtonStyles.d.ts +2 -1
- package/dist/components/core/ToggleButton/toggleButtonStyles.js +21 -2
- package/dist/components/core/ToggleButton/toggleButtonTypes.d.ts +3 -0
- package/dist/components/core/ToggleButton/useToggleButtonRootState.d.ts +1 -1
- package/dist/components/core/ToggleButton/useToggleButtonRootState.js +4 -7
- package/dist/components/core/Tooltip/tooltipAnimations.js +17 -1
- package/dist/components/core/Tooltip/tooltipParts.js +83 -26
- package/dist/components/core/Tooltip/tooltipPosition.js +57 -32
- package/dist/components/core/Tooltip/tooltipStyles.d.ts +2 -2
- package/dist/components/core/Tooltip/tooltipStyles.js +2 -2
- package/dist/components/core/Tooltip/tooltipTypes.d.ts +5 -0
- package/dist/components/core/Tooltip/useTooltipRootState.js +59 -10
- package/dist/components/core/utils/bodyScrollLock.js +12 -3
- package/dist/components/core/utils/clampNumber.d.ts +1 -1
- package/dist/components/core/utils/clampNumber.js +4 -1
- package/dist/components/core/utils/containedEscape.js +12 -0
- package/dist/components/core/utils/fieldFormDom.d.ts +24 -0
- package/dist/components/core/utils/fieldFormDom.js +37 -2
- package/dist/components/core/utils/focusElement.js +2 -2
- package/dist/components/core/utils/hoverInteractiveLift.d.ts +12 -0
- package/dist/components/core/utils/hoverInteractiveLift.js +43 -2
- package/dist/components/core/utils/inputAffixStyles.js +1 -1
- package/dist/components/core/utils/mergeAsChildProps.d.ts +7 -0
- package/dist/components/core/utils/mergeAsChildProps.js +23 -2
- package/dist/components/core/utils/optionListItemStyles.d.ts +2 -2
- package/dist/components/core/utils/optionListItemStyles.js +2 -2
- package/dist/components/core/utils/overlayLayer.d.ts +39 -0
- package/dist/components/core/utils/overlayLayer.js +164 -2
- package/dist/components/core/utils/overlayTriggerSqueeze.js +5 -4
- package/dist/components/core/utils/portalContainer.d.ts +27 -5
- package/dist/components/core/utils/portalContainer.js +38 -4
- package/dist/components/core/utils/pressRipple.js +2 -1
- package/dist/components/core/utils/readingDirection.js +8 -0
- package/dist/components/core/utils/runOpenAfterSqueeze.d.ts +7 -0
- package/dist/components/core/utils/runOpenAfterSqueeze.js +10 -3
- package/dist/components/core/utils/semanticStatusSurface.js +4 -4
- package/dist/components/core/utils/sizeLayout/panel.js +4 -4
- package/dist/components/core/utils/slotMotion/recipes/loadKitRecipe.js +2 -0
- package/dist/components/core/utils/slotMotion/recipes/switchThumb.js +3 -0
- package/dist/components/core/utils/slotMotion/resolveMotionValue.js +1 -1
- package/dist/components/core/utils/slotMotion/slotMount.js +1 -1
- package/dist/components/core/utils/slotMotion/useBarFillMotion.js +8 -3
- package/dist/components/core/utils/useCollapsibleHeight.js +2 -1
- package/dist/components/core/utils/useConvergeRipples.js +4 -1
- package/dist/components/core/utils/useModalMotion.d.ts +2 -0
- package/dist/components/core/utils/useModalMotion.js +19 -3
- package/dist/components/core/utils/usePressableElementTextMotion.js +4 -5
- package/dist/components/core/utils/useShadowMotion.js +28 -7
- package/dist/index.d.ts +3 -3
- package/dist/skins/resolveVariantVisual.d.ts +1 -1
- package/dist/skins/resolveVariantVisual.js +2 -2
- package/dist/skins/skinContext.js +6 -5
- package/dist/skins/skinLiveSlots.generated.d.ts +1 -1
- package/dist/skins/skinLiveSlots.generated.js +1 -1
- package/dist/skins/skinShell.js +9 -4
- package/dist/skins/skinSlots.generated.d.ts +1 -1
- package/dist/skins/skinSlots.generated.js +2 -0
- package/dist/studio/colorPresets.d.ts +1 -1
- package/dist/studio/colorPresets.js +8 -1
- package/dist/studio.d.ts +1 -1
- package/dist/studio.js +13 -1
- package/dist/theme/namedPalettes.d.ts +12 -0
- package/dist/theme/namedPalettes.js +697 -1
- package/dist/theme/themeDefaults.js +6 -3
- package/dist/tokens/config.d.ts +8 -2
- package/dist/tokens/config.js +15 -2
- package/dist/tokens/index.d.ts +1 -1
- package/dist/tokens/index.js +9 -0
- package/dist/ui.css +499 -55
- package/dist/utils/cn.js +89 -2
- package/package.json +1 -1
- package/dist/components/composite/utils/useOptionGroupRequiredAnchor.js +0 -17
- package/dist/components/composite/utils/useOptionGroupSingleValue.js +0 -24
|
@@ -1,18 +1,20 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsxs, jsx } from "react/jsx-runtime";
|
|
3
|
-
import { forwardRef, useMemo, useId, useState, useLayoutEffect, useCallback, isValidElement, cloneElement } from "react";
|
|
4
|
-
import {
|
|
3
|
+
import { forwardRef, useMemo, useId, useState, useRef, useLayoutEffect, useCallback, isValidElement, cloneElement } from "react";
|
|
4
|
+
import { useFormFieldBinding } from "../../composite/Form/useFormFieldBinding.js";
|
|
5
5
|
import { joinFieldDescribedBy } from "../Field/fieldA11y.js";
|
|
6
6
|
import { useBurneLabel } from "../../../theme/BurneLabelsProvider.js";
|
|
7
7
|
import { useSkinVariant } from "../../../skins/skinContext.js";
|
|
8
8
|
import { isInteractivePressKey } from "../utils/hoverInteractiveLift.js";
|
|
9
|
+
import { useNativeFormReset } from "../utils/fieldFormDom.js";
|
|
10
|
+
import { useResolvedFieldInvalid } from "../utils/fieldInvalid.js";
|
|
9
11
|
import { useControllableState } from "../utils/useControllableState.js";
|
|
10
12
|
import { partitionSwitchControlChildren, hasSwitchThumbChild } from "./switchAPI.js";
|
|
11
13
|
import { switchInputId, switchFallbackAriaLabel } from "./switchA11y.js";
|
|
12
14
|
import { useOptionalSwitchFieldContext, useSwitchClassNames } from "./switchContext.js";
|
|
13
15
|
import { SWITCH_INPUT_VISUALLY_HIDDEN_CLASS, switchControlCellClass, switchControlClass } from "./switchStyles.js";
|
|
14
16
|
import { SwitchTrack, SwitchFill } from "./switchTrackParts.js";
|
|
15
|
-
import { dataOnState, dataVariantProps } from "../utils/dataContract.js";
|
|
17
|
+
import { dataFlag, dataOnState, dataVariantProps } from "../utils/dataContract.js";
|
|
16
18
|
import { cn } from "../../../utils/cn.js";
|
|
17
19
|
const SwitchControl = forwardRef(
|
|
18
20
|
function SwitchControl2({
|
|
@@ -25,18 +27,19 @@ const SwitchControl = forwardRef(
|
|
|
25
27
|
thickness,
|
|
26
28
|
className,
|
|
27
29
|
classNames: controlClassNames,
|
|
28
|
-
disabled,
|
|
30
|
+
disabled: disabledProp,
|
|
29
31
|
checked,
|
|
30
32
|
defaultChecked,
|
|
31
33
|
onChange,
|
|
34
|
+
onClick,
|
|
32
35
|
id: idProp,
|
|
33
36
|
name,
|
|
34
37
|
value,
|
|
35
|
-
required,
|
|
38
|
+
required: requiredProp,
|
|
36
39
|
form,
|
|
37
40
|
autoFocus,
|
|
38
41
|
tabIndex,
|
|
39
|
-
readOnly,
|
|
42
|
+
readOnly: readOnlyProp,
|
|
40
43
|
onBlur,
|
|
41
44
|
onFocus,
|
|
42
45
|
onPointerDown,
|
|
@@ -64,37 +67,70 @@ const SwitchControl = forwardRef(
|
|
|
64
67
|
const hintId = fieldCtx?.hintId ?? `${inputId}-hint`;
|
|
65
68
|
const errorId = fieldCtx?.errorId ?? `${inputId}-error`;
|
|
66
69
|
const size = sizeProp ?? fieldCtx?.size ?? "base";
|
|
67
|
-
const
|
|
70
|
+
const resolvedDisabledInput = disabledProp ?? fieldCtx?.disabledProp;
|
|
71
|
+
const resolvedReadOnlyInput = readOnlyProp ?? fieldCtx?.readOnlyProp;
|
|
72
|
+
const resolvedRequired = Boolean(requiredProp ?? fieldCtx?.required);
|
|
73
|
+
const formBinding = useFormFieldBinding({
|
|
68
74
|
name: typeof name === "string" ? name : void 0,
|
|
69
75
|
value: checked,
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
disabled,
|
|
73
|
-
readOnly,
|
|
74
|
-
type: "checkbox"
|
|
76
|
+
disabled: resolvedDisabledInput,
|
|
77
|
+
readOnly: resolvedReadOnlyInput
|
|
75
78
|
});
|
|
76
|
-
const
|
|
77
|
-
const
|
|
78
|
-
const
|
|
79
|
+
const formBound = formBinding.bound;
|
|
80
|
+
const resolvedReadOnly = Boolean(resolvedReadOnlyInput ?? formBinding.readOnly);
|
|
81
|
+
const resolvedDisabled = Boolean(resolvedDisabledInput ?? formBinding.disabled);
|
|
82
|
+
const formChecked = formBound ? Boolean(formBinding.value) : void 0;
|
|
79
83
|
const [mergedChecked, setMergedChecked, isControlled] = useControllableState({
|
|
80
84
|
value: formChecked ?? checked,
|
|
81
85
|
defaultValue: Boolean(defaultChecked)
|
|
82
86
|
});
|
|
83
87
|
const [squeezeToken, setSqueezeToken] = useState(0);
|
|
88
|
+
const inputElementRef = useRef(null);
|
|
89
|
+
useNativeFormReset(
|
|
90
|
+
inputElementRef,
|
|
91
|
+
() => {
|
|
92
|
+
setMergedChecked(Boolean(defaultChecked));
|
|
93
|
+
},
|
|
94
|
+
!isControlled && !formBound
|
|
95
|
+
);
|
|
84
96
|
useLayoutEffect(() => {
|
|
85
97
|
fieldCtx?.setMergedChecked(mergedChecked);
|
|
86
98
|
}, [fieldCtx, mergedChecked]);
|
|
99
|
+
const isInvalid = useResolvedFieldInvalid({
|
|
100
|
+
invalid: fieldCtx?.invalidProp,
|
|
101
|
+
errorConnected: fieldCtx?.errorConnected ?? false,
|
|
102
|
+
formInvalid: Boolean(formBound && formBinding.error)
|
|
103
|
+
});
|
|
87
104
|
const handleChange = useCallback(
|
|
88
105
|
(e) => {
|
|
89
|
-
if (resolvedReadOnly) {
|
|
106
|
+
if (resolvedReadOnly || resolvedDisabled) {
|
|
90
107
|
e.preventDefault();
|
|
91
108
|
return;
|
|
92
109
|
}
|
|
93
110
|
const next = e.target.checked;
|
|
94
111
|
if (!isControlled) setMergedChecked(next);
|
|
95
|
-
|
|
112
|
+
onChange?.(e);
|
|
113
|
+
if (e.defaultPrevented) return;
|
|
114
|
+
if (formBound) formBinding.setValue(next);
|
|
115
|
+
},
|
|
116
|
+
[formBinding, formBound, isControlled, onChange, resolvedDisabled, resolvedReadOnly, setMergedChecked]
|
|
117
|
+
);
|
|
118
|
+
const handleClick = useCallback(
|
|
119
|
+
(event) => {
|
|
120
|
+
if (resolvedReadOnly) {
|
|
121
|
+
event.preventDefault();
|
|
122
|
+
return;
|
|
123
|
+
}
|
|
124
|
+
onClick?.(event);
|
|
125
|
+
},
|
|
126
|
+
[onClick, resolvedReadOnly]
|
|
127
|
+
);
|
|
128
|
+
const handleBlur = useCallback(
|
|
129
|
+
(event) => {
|
|
130
|
+
onBlur?.(event);
|
|
131
|
+
if (formBound) formBinding.onBlur();
|
|
96
132
|
},
|
|
97
|
-
[formBinding,
|
|
133
|
+
[formBinding, formBound, onBlur]
|
|
98
134
|
);
|
|
99
135
|
const handlePointerDown = useCallback(
|
|
100
136
|
(e) => {
|
|
@@ -144,7 +180,28 @@ const SwitchControl = forwardRef(
|
|
|
144
180
|
}, [children]);
|
|
145
181
|
let trackVisual;
|
|
146
182
|
if (compoundTrack != null) {
|
|
147
|
-
|
|
183
|
+
if (isValidElement(compoundTrack)) {
|
|
184
|
+
const childProps = compoundTrack.props;
|
|
185
|
+
trackVisual = cloneElement(compoundTrack, {
|
|
186
|
+
...trackDefaults,
|
|
187
|
+
...childProps,
|
|
188
|
+
size: childProps.size ?? trackDefaults.size,
|
|
189
|
+
checked: childProps.checked ?? trackDefaults.checked,
|
|
190
|
+
disabled: childProps.disabled ?? trackDefaults.disabled,
|
|
191
|
+
variant: childProps.variant ?? trackDefaults.variant,
|
|
192
|
+
squeezeToken: childProps.squeezeToken ?? trackDefaults.squeezeToken,
|
|
193
|
+
classNames: {
|
|
194
|
+
...trackDefaults.classNames,
|
|
195
|
+
...childProps.classNames
|
|
196
|
+
},
|
|
197
|
+
motionController: childProps.motionController ?? motionController,
|
|
198
|
+
motionState: childProps.motionState ?? motionState,
|
|
199
|
+
motionPayload: childProps.motionPayload ?? motionPayload,
|
|
200
|
+
playInitialState: childProps.playInitialState ?? playInitialState
|
|
201
|
+
});
|
|
202
|
+
} else {
|
|
203
|
+
trackVisual = compoundTrack;
|
|
204
|
+
}
|
|
148
205
|
} else if (hasThumbChild) {
|
|
149
206
|
trackVisual = /* @__PURE__ */ jsxs(
|
|
150
207
|
SwitchTrack,
|
|
@@ -184,11 +241,18 @@ const SwitchControl = forwardRef(
|
|
|
184
241
|
slotClassNames.control,
|
|
185
242
|
className
|
|
186
243
|
),
|
|
244
|
+
"data-state": dataOnState(mergedChecked),
|
|
245
|
+
"data-disabled": dataFlag(resolvedDisabled),
|
|
246
|
+
"data-readonly": dataFlag(resolvedReadOnly),
|
|
247
|
+
"data-invalid": dataFlag(isInvalid),
|
|
248
|
+
"data-required": dataFlag(resolvedRequired),
|
|
187
249
|
children: [
|
|
188
250
|
/* @__PURE__ */ jsx(
|
|
189
251
|
"input",
|
|
190
252
|
{
|
|
253
|
+
...inputRest,
|
|
191
254
|
ref: (node) => {
|
|
255
|
+
inputElementRef.current = node;
|
|
192
256
|
formBinding.ref(node);
|
|
193
257
|
if (typeof inputRef === "function") inputRef(node);
|
|
194
258
|
else if (inputRef) inputRef.current = node;
|
|
@@ -204,18 +268,16 @@ const SwitchControl = forwardRef(
|
|
|
204
268
|
disabled: resolvedDisabled,
|
|
205
269
|
name: formBinding.name ?? name,
|
|
206
270
|
...value != null ? { value } : null,
|
|
207
|
-
required,
|
|
208
|
-
"aria-required":
|
|
209
|
-
"aria-invalid":
|
|
271
|
+
required: resolvedRequired || void 0,
|
|
272
|
+
"aria-required": resolvedRequired || void 0,
|
|
273
|
+
"aria-invalid": isInvalid ? true : void 0,
|
|
210
274
|
"aria-readonly": resolvedReadOnly || void 0,
|
|
211
275
|
form,
|
|
212
276
|
autoFocus,
|
|
213
277
|
tabIndex,
|
|
214
|
-
readOnly: resolvedReadOnly || isControlled && onChange === void 0 && !
|
|
215
|
-
onClick:
|
|
216
|
-
|
|
217
|
-
},
|
|
218
|
-
onBlur: formBinding.onBlur,
|
|
278
|
+
readOnly: resolvedReadOnly || isControlled && onChange === void 0 && !formBound,
|
|
279
|
+
onClick: handleClick,
|
|
280
|
+
onBlur: handleBlur,
|
|
219
281
|
onFocus,
|
|
220
282
|
"aria-describedby": joinFieldDescribedBy(
|
|
221
283
|
fieldCtx?.hintConnected ? hintId : void 0,
|
|
@@ -225,11 +287,12 @@ const SwitchControl = forwardRef(
|
|
|
225
287
|
onPointerDown: handlePointerDown,
|
|
226
288
|
onKeyDown: handleKeyDown,
|
|
227
289
|
...isControlled ? { checked: mergedChecked, onChange: handleChange } : { defaultChecked, onChange: handleChange },
|
|
228
|
-
...inputRest,
|
|
229
290
|
...dataVariantProps({ size, variant }),
|
|
230
|
-
"data-invalid": fieldCtx?.isInvalid ? "" : void 0,
|
|
231
291
|
"data-state": dataOnState(mergedChecked),
|
|
232
|
-
"data-
|
|
292
|
+
"data-disabled": dataFlag(resolvedDisabled),
|
|
293
|
+
"data-readonly": dataFlag(resolvedReadOnly),
|
|
294
|
+
"data-invalid": dataFlag(isInvalid),
|
|
295
|
+
"data-required": dataFlag(resolvedRequired)
|
|
233
296
|
}
|
|
234
297
|
),
|
|
235
298
|
trackVisual
|
|
@@ -20,8 +20,8 @@ function resolveFallbackThumbPx(thickness, size) {
|
|
|
20
20
|
return THUMB_PX[size];
|
|
21
21
|
}
|
|
22
22
|
function measureSwitchTravel(trackEl, thumbEl) {
|
|
23
|
-
const trackW = trackEl.getBoundingClientRect().width;
|
|
24
|
-
const thumbW = thumbEl.getBoundingClientRect().width;
|
|
23
|
+
const trackW = trackEl.clientWidth || trackEl.getBoundingClientRect().width;
|
|
24
|
+
const thumbW = thumbEl.offsetWidth || thumbEl.getBoundingClientRect().width;
|
|
25
25
|
return Math.max(0, trackW - thumbW);
|
|
26
26
|
}
|
|
27
27
|
const SWITCH_TRACK = {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { SwitchControlProps, SwitchLabelPosition, SwitchSize } from './switchTypes.js';
|
|
2
|
-
export declare function SwitchSimpleBody({ label, hint, error, hasTextColumn, hasHint, hasError, secondaryLines, textColRef, size, disabled, labelPosition, hintId, errorId, controlProps, }: {
|
|
2
|
+
export declare function SwitchSimpleBody({ label, hint, error, hasTextColumn, hasHint, hasError, secondaryLines, textColRef, size, disabled, isInvalid, labelPosition, hintId, errorId, controlProps, }: {
|
|
3
3
|
label?: React.ReactNode;
|
|
4
4
|
hint?: React.ReactNode;
|
|
5
5
|
error?: React.ReactNode;
|
|
@@ -10,6 +10,7 @@ export declare function SwitchSimpleBody({ label, hint, error, hasTextColumn, ha
|
|
|
10
10
|
textColRef: React.RefObject<HTMLElement | null>;
|
|
11
11
|
size: SwitchSize;
|
|
12
12
|
disabled?: boolean;
|
|
13
|
+
isInvalid?: boolean;
|
|
13
14
|
labelPosition: SwitchLabelPosition;
|
|
14
15
|
hintId: string;
|
|
15
16
|
errorId: string;
|
|
@@ -5,7 +5,7 @@ import { mergeRefs } from "../utils/mergeRefs.js";
|
|
|
5
5
|
import { useSwitchChromeSlot } from "./switchAnimations.js";
|
|
6
6
|
import { SwitchControl } from "./switchControlParts.js";
|
|
7
7
|
import { useSwitchClassNames } from "./switchContext.js";
|
|
8
|
-
import { switchControlCellClass, SWITCH_LABEL_TEXT_DISABLED_CLASS, SWITCH_SIMPLE_LABEL_TEXT_CLASS, SWITCH_SIMPLE_LABEL_WRAP_CLASS, switchLabelCellClass, SWITCH_HINT_DISABLED_CLASS, switchSecondaryCellClass, SWITCH_ERROR_DISABLED_CLASS } from "./switchStyles.js";
|
|
8
|
+
import { switchControlCellClass, SWITCH_LABEL_TEXT_DISABLED_CLASS, SWITCH_LABEL_TEXT_DANGER_CLASS, SWITCH_SIMPLE_LABEL_TEXT_CLASS, SWITCH_SIMPLE_LABEL_WRAP_CLASS, switchLabelCellClass, SWITCH_HINT_DISABLED_CLASS, switchSecondaryCellClass, SWITCH_ERROR_DISABLED_CLASS } from "./switchStyles.js";
|
|
9
9
|
import { cn } from "../../../utils/cn.js";
|
|
10
10
|
import { Text } from "../Text/Text.js";
|
|
11
11
|
import { SWITCH_LAYOUT } from "./switchGeometry.js";
|
|
@@ -20,6 +20,7 @@ function SwitchSimpleBody({
|
|
|
20
20
|
textColRef,
|
|
21
21
|
size,
|
|
22
22
|
disabled,
|
|
23
|
+
isInvalid,
|
|
23
24
|
labelPosition,
|
|
24
25
|
hintId,
|
|
25
26
|
errorId,
|
|
@@ -59,6 +60,7 @@ function SwitchSimpleBody({
|
|
|
59
60
|
inheritColor: true,
|
|
60
61
|
className: cn(
|
|
61
62
|
SWITCH_SIMPLE_LABEL_TEXT_CLASS,
|
|
63
|
+
!disabled && isInvalid && SWITCH_LABEL_TEXT_DANGER_CLASS,
|
|
62
64
|
disabled && SWITCH_LABEL_TEXT_DISABLED_CLASS,
|
|
63
65
|
slotClassNames.simpleLabelText,
|
|
64
66
|
slotClassNames.labelText
|
|
@@ -14,9 +14,9 @@ export declare const SWITCH_LABEL_COMPOUND_SECONDARY_CLASS = "min-w-0";
|
|
|
14
14
|
export declare const SWITCH_LABEL_MOTION_CLASS = "origin-center";
|
|
15
15
|
export declare const SWITCH_LABEL_TEXT_CLASS = "font-w-mid";
|
|
16
16
|
export declare const SWITCH_LABEL_TEXT_DANGER_CLASS = "text-danger";
|
|
17
|
-
export declare const SWITCH_LABEL_TEXT_DISABLED_CLASS = "text-muted";
|
|
18
|
-
export declare const SWITCH_HINT_DISABLED_CLASS = "text-muted";
|
|
19
|
-
export declare const SWITCH_ERROR_DISABLED_CLASS = "text-muted";
|
|
17
|
+
export declare const SWITCH_LABEL_TEXT_DISABLED_CLASS = "text-muted-foreground";
|
|
18
|
+
export declare const SWITCH_HINT_DISABLED_CLASS = "text-muted-foreground";
|
|
19
|
+
export declare const SWITCH_ERROR_DISABLED_CLASS = "text-muted-foreground";
|
|
20
20
|
export declare const SWITCH_SIMPLE_LABEL_WRAP_CLASS = "origin-center";
|
|
21
21
|
export declare const SWITCH_SIMPLE_LABEL_TEXT_CLASS = "min-w-0 font-w-mid";
|
|
22
22
|
export declare const SWITCH_ROOT_BASE_CLASS = "relative cursor-pointer select-none rounded-small text-start";
|
|
@@ -19,9 +19,9 @@ const SWITCH_LABEL_COMPOUND_SECONDARY_CLASS = "min-w-0";
|
|
|
19
19
|
const SWITCH_LABEL_MOTION_CLASS = "origin-center";
|
|
20
20
|
const SWITCH_LABEL_TEXT_CLASS = "font-w-mid";
|
|
21
21
|
const SWITCH_LABEL_TEXT_DANGER_CLASS = "text-danger";
|
|
22
|
-
const SWITCH_LABEL_TEXT_DISABLED_CLASS = "text-muted";
|
|
23
|
-
const SWITCH_HINT_DISABLED_CLASS = "text-muted";
|
|
24
|
-
const SWITCH_ERROR_DISABLED_CLASS = "text-muted";
|
|
22
|
+
const SWITCH_LABEL_TEXT_DISABLED_CLASS = "text-muted-foreground";
|
|
23
|
+
const SWITCH_HINT_DISABLED_CLASS = "text-muted-foreground";
|
|
24
|
+
const SWITCH_ERROR_DISABLED_CLASS = "text-muted-foreground";
|
|
25
25
|
const SWITCH_SIMPLE_LABEL_WRAP_CLASS = "origin-center";
|
|
26
26
|
const SWITCH_SIMPLE_LABEL_TEXT_CLASS = "min-w-0 font-w-mid";
|
|
27
27
|
const SWITCH_ROOT_BASE_CLASS = "relative cursor-pointer select-none rounded-small text-start";
|
|
@@ -62,6 +62,11 @@ export type SwitchFieldContextValue = {
|
|
|
62
62
|
size: SwitchSize;
|
|
63
63
|
labelPosition: SwitchLabelPosition;
|
|
64
64
|
disabled?: boolean;
|
|
65
|
+
disabledProp?: boolean;
|
|
66
|
+
readOnly: boolean;
|
|
67
|
+
readOnlyProp?: boolean;
|
|
68
|
+
invalidProp?: boolean;
|
|
69
|
+
required: boolean;
|
|
65
70
|
isCompound: boolean;
|
|
66
71
|
hasCompoundHint: boolean;
|
|
67
72
|
hasCompoundError: boolean;
|
|
@@ -220,6 +225,9 @@ export type UseSwitchRootStateResult = {
|
|
|
220
225
|
hintId: string;
|
|
221
226
|
errorId: string;
|
|
222
227
|
disabled?: boolean;
|
|
228
|
+
readOnly: boolean;
|
|
229
|
+
required: boolean;
|
|
230
|
+
isChecked: boolean;
|
|
223
231
|
enableTextMotion: boolean;
|
|
224
232
|
textColRef: RefObject<HTMLElement | null>;
|
|
225
233
|
labelPosition: SwitchLabelPosition;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { useId, useState,
|
|
2
|
+
import { useMemo, useId, useState, useRef } from "react";
|
|
3
|
+
import { useFormFieldBinding } from "../../composite/Form/useFormFieldBinding.js";
|
|
3
4
|
import { hasCompoundChild } from "../utils/hasCompoundChild.js";
|
|
4
5
|
import { hasCompoundChildren } from "../utils/hasCompoundChildren.js";
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import { compoundHasLabel, compoundUsesInlineMotion, countSecondaryLines } from "./switchAPI.js";
|
|
6
|
+
import { useResolvedFieldInvalid } from "../utils/fieldInvalid.js";
|
|
7
|
+
import { readSwitchCompoundControlProps, compoundHasLabel, compoundUsesInlineMotion, countSecondaryLines } from "./switchAPI.js";
|
|
8
8
|
import { switchInputId, switchErrorId, switchHintId, switchLabelId } from "./switchA11y.js";
|
|
9
9
|
import { SWITCH_LAYOUT } from "./switchGeometry.js";
|
|
10
10
|
function useSwitchRootState({
|
|
@@ -19,9 +19,27 @@ function useSwitchRootState({
|
|
|
19
19
|
className,
|
|
20
20
|
...controlRest
|
|
21
21
|
}) {
|
|
22
|
+
const compoundControlProps = useMemo(
|
|
23
|
+
() => readSwitchCompoundControlProps(children),
|
|
24
|
+
[children]
|
|
25
|
+
);
|
|
26
|
+
const resolvedName = typeof controlRest.name === "string" ? controlRest.name : typeof compoundControlProps.name === "string" ? compoundControlProps.name : void 0;
|
|
27
|
+
const resolvedCheckedProp = controlRest.checked !== void 0 ? controlRest.checked : compoundControlProps.checked;
|
|
28
|
+
const resolvedDefaultCheckedProp = controlRest.defaultChecked !== void 0 ? controlRest.defaultChecked : compoundControlProps.defaultChecked;
|
|
29
|
+
const resolvedReadOnlyProp = controlRest.readOnly !== void 0 ? controlRest.readOnly : compoundControlProps.readOnly;
|
|
30
|
+
const resolvedDisabledProp = disabledRoot !== void 0 ? disabledRoot : compoundControlProps.disabled;
|
|
31
|
+
const resolvedRequiredProp = Boolean(
|
|
32
|
+
controlRest.required ?? compoundControlProps.required
|
|
33
|
+
);
|
|
34
|
+
const formBinding = useFormFieldBinding({
|
|
35
|
+
name: resolvedName,
|
|
36
|
+
value: resolvedCheckedProp,
|
|
37
|
+
disabled: resolvedDisabledProp,
|
|
38
|
+
readOnly: resolvedReadOnlyProp
|
|
39
|
+
});
|
|
22
40
|
const autoId = useId();
|
|
23
41
|
const switchId = switchInputId(
|
|
24
|
-
typeof controlRest.id === "string" ? controlRest.id : void 0,
|
|
42
|
+
typeof controlRest.id === "string" ? controlRest.id : typeof compoundControlProps.id === "string" ? compoundControlProps.id : void 0,
|
|
25
43
|
autoId
|
|
26
44
|
);
|
|
27
45
|
const labelId = switchLabelId(switchId);
|
|
@@ -29,26 +47,28 @@ function useSwitchRootState({
|
|
|
29
47
|
const errorId = switchErrorId(switchId);
|
|
30
48
|
const [, setSqueezeToken] = useState(0);
|
|
31
49
|
const [mergedChecked, setMergedChecked] = useState(() => {
|
|
32
|
-
if (typeof
|
|
33
|
-
if (
|
|
50
|
+
if (typeof resolvedCheckedProp === "boolean") return resolvedCheckedProp;
|
|
51
|
+
if (formBinding.bound) return Boolean(formBinding.value);
|
|
52
|
+
if (resolvedDefaultCheckedProp != null) return Boolean(resolvedDefaultCheckedProp);
|
|
34
53
|
return null;
|
|
35
54
|
});
|
|
36
55
|
const { isCompound, hasCompoundHint, hasCompoundError, hasCompoundLabel } = useMemo(() => {
|
|
37
56
|
const compound = hasCompoundChildren(children);
|
|
38
57
|
return {
|
|
39
58
|
isCompound: compound,
|
|
40
|
-
hasCompoundHint: compound ? hasCompoundChild(children, "Switch.Hint") : false,
|
|
41
|
-
hasCompoundError: compound ? hasCompoundChild(children, "Switch.Error") : false,
|
|
59
|
+
hasCompoundHint: compound ? hasCompoundChild(children, "Switch.Hint", "SwitchHint") : false,
|
|
60
|
+
hasCompoundError: compound ? hasCompoundChild(children, "Switch.Error", "SwitchError") : false,
|
|
42
61
|
hasCompoundLabel: compound ? compoundHasLabel(children) : false
|
|
43
62
|
};
|
|
44
63
|
}, [children]);
|
|
45
64
|
const useInlineCompoundMotion = isCompound && compoundUsesInlineMotion(className);
|
|
65
|
+
const resolvedError = error ?? (!hasCompoundError && formBinding.bound ? formBinding.error : void 0);
|
|
46
66
|
const hasHint = hint != null;
|
|
47
|
-
const hasError =
|
|
48
|
-
const isInvalid =
|
|
67
|
+
const hasError = resolvedError != null;
|
|
68
|
+
const isInvalid = useResolvedFieldInvalid({
|
|
49
69
|
invalid,
|
|
50
|
-
|
|
51
|
-
|
|
70
|
+
errorConnected: isCompound ? hasCompoundError : hasError,
|
|
71
|
+
formInvalid: Boolean(formBinding.bound && formBinding.error)
|
|
52
72
|
});
|
|
53
73
|
const secondaryLines = countSecondaryLines(
|
|
54
74
|
isCompound,
|
|
@@ -58,8 +78,12 @@ function useSwitchRootState({
|
|
|
58
78
|
hasCompoundError
|
|
59
79
|
);
|
|
60
80
|
const hasTextColumn = isCompound ? hasCompoundLabel : label != null;
|
|
61
|
-
const disabled =
|
|
81
|
+
const disabled = Boolean(resolvedDisabledProp ?? formBinding.disabled);
|
|
82
|
+
const readOnly = Boolean(resolvedReadOnlyProp ?? formBinding.readOnly);
|
|
62
83
|
const enableTextMotion = !disabled && hasTextColumn && (!isCompound || useInlineCompoundMotion);
|
|
84
|
+
const isChecked = mergedChecked ?? Boolean(
|
|
85
|
+
formBinding.bound ? formBinding.value : resolvedCheckedProp ?? resolvedDefaultCheckedProp
|
|
86
|
+
);
|
|
63
87
|
const textColRef = useRef(null);
|
|
64
88
|
const sz = SWITCH_LAYOUT[size];
|
|
65
89
|
const fieldCtx = useMemo(
|
|
@@ -72,6 +96,11 @@ function useSwitchRootState({
|
|
|
72
96
|
size,
|
|
73
97
|
labelPosition,
|
|
74
98
|
disabled,
|
|
99
|
+
disabledProp: resolvedDisabledProp,
|
|
100
|
+
readOnly,
|
|
101
|
+
readOnlyProp: resolvedReadOnlyProp,
|
|
102
|
+
invalidProp: invalid,
|
|
103
|
+
required: resolvedRequiredProp,
|
|
75
104
|
isCompound,
|
|
76
105
|
hasCompoundHint,
|
|
77
106
|
hasCompoundError,
|
|
@@ -87,6 +116,11 @@ function useSwitchRootState({
|
|
|
87
116
|
}),
|
|
88
117
|
[
|
|
89
118
|
disabled,
|
|
119
|
+
resolvedDisabledProp,
|
|
120
|
+
readOnly,
|
|
121
|
+
resolvedReadOnlyProp,
|
|
122
|
+
invalid,
|
|
123
|
+
resolvedRequiredProp,
|
|
90
124
|
hasCompoundHint,
|
|
91
125
|
hasCompoundError,
|
|
92
126
|
hasCompoundLabel,
|
|
@@ -109,9 +143,9 @@ function useSwitchRootState({
|
|
|
109
143
|
() => ({
|
|
110
144
|
controlId: switchId,
|
|
111
145
|
labelId,
|
|
112
|
-
required:
|
|
146
|
+
required: resolvedRequiredProp
|
|
113
147
|
}),
|
|
114
|
-
[labelId, switchId]
|
|
148
|
+
[labelId, resolvedRequiredProp, switchId]
|
|
115
149
|
);
|
|
116
150
|
return {
|
|
117
151
|
fieldCtx,
|
|
@@ -122,12 +156,15 @@ function useSwitchRootState({
|
|
|
122
156
|
sz,
|
|
123
157
|
label,
|
|
124
158
|
hint,
|
|
125
|
-
error,
|
|
159
|
+
error: resolvedError,
|
|
126
160
|
hasHint,
|
|
127
161
|
hasError,
|
|
128
162
|
hintId,
|
|
129
163
|
errorId,
|
|
130
164
|
disabled,
|
|
165
|
+
readOnly,
|
|
166
|
+
required: resolvedRequiredProp,
|
|
167
|
+
isChecked,
|
|
131
168
|
enableTextMotion,
|
|
132
169
|
textColRef,
|
|
133
170
|
labelPosition,
|
|
@@ -4,6 +4,7 @@ export declare const TableRoot: import('react').ForwardRefExoticComponent<import
|
|
|
4
4
|
variant?: import('./tableTypes.js').TableVariant;
|
|
5
5
|
size?: import('./tableTypes.js').TableSize;
|
|
6
6
|
selectionMode?: import('./tableTypes.js').SelectionMode;
|
|
7
|
+
disallowEmptySelection?: boolean;
|
|
7
8
|
selectedKeys?: import('./tableTypes.js').Selection;
|
|
8
9
|
defaultSelectedKeys?: import('./tableTypes.js').Selection;
|
|
9
10
|
onSelectionChange?: (keys: import('./tableTypes.js').Selection) => void;
|
|
@@ -20,6 +20,7 @@ const TableRoot = forwardRef(function TableRoot2({
|
|
|
20
20
|
motionPayload,
|
|
21
21
|
playInitialState,
|
|
22
22
|
selectionMode,
|
|
23
|
+
disallowEmptySelection,
|
|
23
24
|
selectedKeys,
|
|
24
25
|
defaultSelectedKeys,
|
|
25
26
|
onSelectionChange,
|
|
@@ -34,6 +35,7 @@ const TableRoot = forwardRef(function TableRoot2({
|
|
|
34
35
|
const { variant } = useTableRootState({ variant: variantProp });
|
|
35
36
|
const contentState = useTableContentState({
|
|
36
37
|
selectionMode,
|
|
38
|
+
disallowEmptySelection,
|
|
37
39
|
selectedKeys,
|
|
38
40
|
defaultSelectedKeys,
|
|
39
41
|
onSelectionChange,
|
|
@@ -2,6 +2,7 @@ export declare const Table: import('react').ForwardRefExoticComponent<import('re
|
|
|
2
2
|
variant?: import('./tableTypes.js').TableVariant;
|
|
3
3
|
size?: import('./tableTypes.js').TableSize;
|
|
4
4
|
selectionMode?: import('./tableTypes.js').SelectionMode;
|
|
5
|
+
disallowEmptySelection?: boolean;
|
|
5
6
|
selectedKeys?: import('./tableTypes.js').Selection;
|
|
6
7
|
defaultSelectedKeys?: import('./tableTypes.js').Selection;
|
|
7
8
|
onSelectionChange?: (keys: import('./tableTypes.js').Selection) => void;
|
|
@@ -8,11 +8,16 @@ export declare function hasTableLabel(children: ReactNode): boolean;
|
|
|
8
8
|
export declare function isTableEmptyElement(node: ReactNode): node is ReactElement;
|
|
9
9
|
export declare function isRowInSelection(selectedKeys: Selection, key: string | number): boolean;
|
|
10
10
|
export declare function selectionEquals(a: Selection, b: Selection): boolean;
|
|
11
|
-
export declare function toggleSelectionKey({ selectionMode, selectedKeys, key, }: {
|
|
11
|
+
export declare function toggleSelectionKey({ selectionMode, selectedKeys, key, allSelectableKeys, disallowEmptySelection, }: {
|
|
12
12
|
selectionMode: SelectionMode;
|
|
13
13
|
selectedKeys: Selection;
|
|
14
14
|
key: string | number;
|
|
15
|
+
allSelectableKeys?: readonly (string | number)[];
|
|
16
|
+
disallowEmptySelection?: boolean;
|
|
15
17
|
}): Selection | null;
|
|
18
|
+
export declare function isInteractiveRowDescendant(target: EventTarget | null, rowEl: HTMLElement): boolean;
|
|
19
|
+
export declare function extractTableRowKey(item: unknown, renderItem?: (item: unknown) => ReactNode): string | number | undefined;
|
|
20
|
+
export declare function clampTableColumnWidth(rawWidth: number, minWidth: number, maxWidth: number | undefined): number;
|
|
16
21
|
export declare function resolveColumnSortDirection(columnId: string | undefined, sortDescriptor: SortDescriptor | undefined): SortDescriptor["direction"] | undefined;
|
|
17
22
|
export declare function resolveNextSortDescriptor(columnId: string, sortDescriptor: SortDescriptor | undefined): SortDescriptor;
|
|
18
23
|
export declare const TABLE_ROW_KEY_ATTR = "data-table-row-key";
|
|
@@ -24,16 +24,81 @@ function selectionEquals(a, b) {
|
|
|
24
24
|
function toggleSelectionKey({
|
|
25
25
|
selectionMode,
|
|
26
26
|
selectedKeys,
|
|
27
|
-
key
|
|
27
|
+
key,
|
|
28
|
+
allSelectableKeys,
|
|
29
|
+
disallowEmptySelection = false
|
|
28
30
|
}) {
|
|
29
31
|
if (selectionMode === "none") return null;
|
|
30
|
-
if (selectionMode === "single")
|
|
31
|
-
|
|
32
|
+
if (selectionMode === "single") {
|
|
33
|
+
if (selectedKeys === "all") return /* @__PURE__ */ new Set([key]);
|
|
34
|
+
const alreadySelected = selectedKeys.has(key) || Array.from(selectedKeys).some((k) => String(k) === String(key));
|
|
35
|
+
if (alreadySelected) {
|
|
36
|
+
return disallowEmptySelection ? null : /* @__PURE__ */ new Set();
|
|
37
|
+
}
|
|
38
|
+
return /* @__PURE__ */ new Set([key]);
|
|
39
|
+
}
|
|
40
|
+
if (selectedKeys === "all") {
|
|
41
|
+
if (!allSelectableKeys) return /* @__PURE__ */ new Set();
|
|
42
|
+
const next2 = new Set(
|
|
43
|
+
allSelectableKeys.filter((k) => k !== key && String(k) !== String(key))
|
|
44
|
+
);
|
|
45
|
+
if (disallowEmptySelection && next2.size === 0) return null;
|
|
46
|
+
return next2;
|
|
47
|
+
}
|
|
32
48
|
const next = new Set(selectedKeys);
|
|
33
|
-
if (next.has(key))
|
|
34
|
-
|
|
49
|
+
if (next.has(key)) {
|
|
50
|
+
if (disallowEmptySelection && next.size <= 1) return null;
|
|
51
|
+
next.delete(key);
|
|
52
|
+
} else {
|
|
53
|
+
next.add(key);
|
|
54
|
+
}
|
|
35
55
|
return next;
|
|
36
56
|
}
|
|
57
|
+
const ROW_INTERACTIVE_DESCENDANT_SELECTOR = [
|
|
58
|
+
"button",
|
|
59
|
+
"a[href]",
|
|
60
|
+
"input",
|
|
61
|
+
"textarea",
|
|
62
|
+
"select",
|
|
63
|
+
"[role='button']",
|
|
64
|
+
"[role='checkbox']",
|
|
65
|
+
"[role='switch']",
|
|
66
|
+
"[role='menuitem']",
|
|
67
|
+
"[role='option']",
|
|
68
|
+
"[role='combobox']",
|
|
69
|
+
"[role='link']",
|
|
70
|
+
"[contenteditable='true']"
|
|
71
|
+
].join(",");
|
|
72
|
+
function isInteractiveRowDescendant(target, rowEl) {
|
|
73
|
+
if (!(target instanceof Element) || target === rowEl) return false;
|
|
74
|
+
const interactive = target.closest(ROW_INTERACTIVE_DESCENDANT_SELECTOR);
|
|
75
|
+
if (!interactive || interactive === rowEl) return false;
|
|
76
|
+
return rowEl.contains(interactive);
|
|
77
|
+
}
|
|
78
|
+
function extractTableRowKey(item, renderItem) {
|
|
79
|
+
if (renderItem) {
|
|
80
|
+
try {
|
|
81
|
+
const rendered = renderItem(item);
|
|
82
|
+
if (isValidElement(rendered) && rendered.props.id !== void 0) {
|
|
83
|
+
return rendered.props.id;
|
|
84
|
+
}
|
|
85
|
+
} catch {
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
if (typeof item === "object" && item !== null) {
|
|
89
|
+
const rec = item;
|
|
90
|
+
if (typeof rec.id === "string" || typeof rec.id === "number") return rec.id;
|
|
91
|
+
if (typeof rec.key === "string" || typeof rec.key === "number") return rec.key;
|
|
92
|
+
}
|
|
93
|
+
return void 0;
|
|
94
|
+
}
|
|
95
|
+
function clampTableColumnWidth(rawWidth, minWidth, maxWidth) {
|
|
96
|
+
const clampedMin = Math.max(minWidth, Math.round(rawWidth));
|
|
97
|
+
if (maxWidth != null && maxWidth >= minWidth) {
|
|
98
|
+
return Math.min(maxWidth, clampedMin);
|
|
99
|
+
}
|
|
100
|
+
return clampedMin;
|
|
101
|
+
}
|
|
37
102
|
function resolveColumnSortDirection(columnId, sortDescriptor) {
|
|
38
103
|
if (!columnId || sortDescriptor?.column !== columnId) return void 0;
|
|
39
104
|
return sortDescriptor.direction;
|
|
@@ -105,7 +170,10 @@ export {
|
|
|
105
170
|
TABLE_ROW_KEY_ATTR,
|
|
106
171
|
TABLE_VIRTUAL_INDEX_ATTR,
|
|
107
172
|
TONED_ROW_DEFAULT_TONE,
|
|
173
|
+
clampTableColumnWidth,
|
|
174
|
+
extractTableRowKey,
|
|
108
175
|
hasTableLabel,
|
|
176
|
+
isInteractiveRowDescendant,
|
|
109
177
|
isTableEmptyElement,
|
|
110
178
|
moveVirtualTableRow,
|
|
111
179
|
resolveColumnSortDirection,
|
|
@@ -18,7 +18,12 @@ const noopStore = {
|
|
|
18
18
|
setFocusedRowKey: () => {
|
|
19
19
|
},
|
|
20
20
|
claimFocusedRowKey: () => {
|
|
21
|
-
}
|
|
21
|
+
},
|
|
22
|
+
registerRowKey: () => () => {
|
|
23
|
+
},
|
|
24
|
+
setCatalogKeys: () => {
|
|
25
|
+
},
|
|
26
|
+
getAllRowKeys: () => []
|
|
22
27
|
};
|
|
23
28
|
const TableVariantContext = createContext("default");
|
|
24
29
|
const TableSizeContext = createContext("base");
|