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
|
@@ -14,40 +14,48 @@ function useFormFieldBinding({
|
|
|
14
14
|
const form = useOptionalFormBindingContext();
|
|
15
15
|
const explicitValue = valueProp !== void 0;
|
|
16
16
|
const bound = form != null && name != null && !explicitValue;
|
|
17
|
+
const registerRef = form?.registerRef;
|
|
18
|
+
const setFormValue = form?.setValue;
|
|
19
|
+
const setTouched = form?.setTouched;
|
|
20
|
+
const validateField = form?.validateField;
|
|
21
|
+
const getFieldRules = form?.getFieldRules;
|
|
22
|
+
const validateMode = form?.validateMode;
|
|
23
|
+
const onChangeRef = useRef(onChangeProp);
|
|
24
|
+
onChangeRef.current = onChangeProp;
|
|
17
25
|
const ref = useRef(null);
|
|
18
26
|
const setRef = useCallback(
|
|
19
27
|
(node) => {
|
|
20
28
|
ref.current = node;
|
|
21
|
-
if (bound && name)
|
|
29
|
+
if (bound && name) registerRef?.(name, node);
|
|
22
30
|
},
|
|
23
|
-
[bound,
|
|
31
|
+
[bound, name, registerRef]
|
|
24
32
|
);
|
|
25
33
|
const disabled = disabledProp ?? form?.disabled ?? false;
|
|
26
34
|
const readOnly = readOnlyProp ?? form?.readOnly ?? false;
|
|
27
35
|
const formError = bound && name ? form.getError(name) : void 0;
|
|
28
36
|
const rules = useMemo(
|
|
29
|
-
() => mergeFormFieldRules(name ?
|
|
30
|
-
[
|
|
37
|
+
() => mergeFormFieldRules(name ? getFieldRules?.(name) : void 0, rulesProp),
|
|
38
|
+
[getFieldRules, name, rulesProp]
|
|
31
39
|
);
|
|
32
40
|
const rawValue = bound && name ? form.getValue(name) : valueProp;
|
|
33
41
|
const value = bound ? rawValue ?? "" : rawValue;
|
|
34
42
|
const setValue = useCallback(
|
|
35
43
|
(next) => {
|
|
36
|
-
|
|
37
|
-
if (!bound || !name || !
|
|
38
|
-
|
|
39
|
-
shouldValidate:
|
|
44
|
+
onChangeRef.current?.(next);
|
|
45
|
+
if (!bound || !name || !setFormValue) return;
|
|
46
|
+
setFormValue(name, next, {
|
|
47
|
+
shouldValidate: validateMode === "onChange"
|
|
40
48
|
});
|
|
41
49
|
},
|
|
42
|
-
[bound,
|
|
50
|
+
[bound, name, setFormValue, validateMode]
|
|
43
51
|
);
|
|
44
52
|
const onBlur = useCallback(() => {
|
|
45
|
-
if (!bound || !name
|
|
46
|
-
|
|
47
|
-
if (
|
|
48
|
-
|
|
53
|
+
if (!bound || !name) return;
|
|
54
|
+
setTouched?.(name, true);
|
|
55
|
+
if (validateMode === "onBlur") {
|
|
56
|
+
validateField?.(name);
|
|
49
57
|
}
|
|
50
|
-
}, [bound,
|
|
58
|
+
}, [bound, name, setTouched, validateField, validateMode]);
|
|
51
59
|
return {
|
|
52
60
|
bound,
|
|
53
61
|
name,
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { FormEvent } from 'react';
|
|
2
2
|
import { FormBindingContextValue, FormShellIds, UseFormRootStateProps } from './formTypes.js';
|
|
3
|
-
export declare function useFormRootState({ defaultValues, values: valuesProp, onValuesChange, rules: rulesProp, resolver, validateMode, disabled, readOnly, onSubmit, onSubmitError, }: UseFormRootStateProps): {
|
|
3
|
+
export declare function useFormRootState({ defaultValues, values: valuesProp, onValuesChange, rules: rulesProp, resolver, validateMode, disabled, readOnly, onSubmit, onSubmitError, onReset, }: UseFormRootStateProps): {
|
|
4
4
|
shellIds: FormShellIds;
|
|
5
5
|
bindingValue: FormBindingContextValue;
|
|
6
6
|
handleSubmit: (event: FormEvent<HTMLFormElement>) => Promise<void>;
|
|
7
|
+
handleReset: (event: FormEvent<HTMLFormElement>) => void;
|
|
7
8
|
errors: Record<string, string>;
|
|
8
9
|
hasErrors: boolean;
|
|
9
10
|
isSubmitting: boolean;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { useId, useState, useRef, useCallback
|
|
2
|
+
import { useId, useMemo, useState, useRef, useCallback } from "react";
|
|
3
3
|
import { useBurneLabels } from "../../../theme/BurneLabelsProvider.js";
|
|
4
|
-
import { focusFirstFormInvalidField,
|
|
5
|
-
import { setFormValueAtPath, validateFormFieldRules, countFormErrors } from "./formAPI.js";
|
|
4
|
+
import { focusFirstFormInvalidField, buildFormSuccessAnnounceMessage, buildFormErrorSummaryMessage } from "./formA11y.js";
|
|
5
|
+
import { mergeFormFieldRules, getFormValueAtPath, setFormValueAtPath, validateFormFieldRules, cleanFormResolverErrors, countFormErrors } from "./formAPI.js";
|
|
6
6
|
function useFormRootState({
|
|
7
7
|
defaultValues,
|
|
8
8
|
values: valuesProp,
|
|
@@ -13,21 +13,25 @@ function useFormRootState({
|
|
|
13
13
|
disabled = false,
|
|
14
14
|
readOnly = false,
|
|
15
15
|
onSubmit,
|
|
16
|
-
onSubmitError
|
|
16
|
+
onSubmitError,
|
|
17
|
+
onReset
|
|
17
18
|
}) {
|
|
18
19
|
const labels = useBurneLabels();
|
|
19
20
|
const titleId = useId();
|
|
20
21
|
const descriptionId = useId();
|
|
21
22
|
const errorSummaryId = useId();
|
|
22
23
|
const announceId = useId();
|
|
23
|
-
const shellIds =
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
24
|
+
const shellIds = useMemo(
|
|
25
|
+
() => ({
|
|
26
|
+
titleId,
|
|
27
|
+
descriptionId,
|
|
28
|
+
errorSummaryId,
|
|
29
|
+
announceId
|
|
30
|
+
}),
|
|
31
|
+
[announceId, descriptionId, errorSummaryId, titleId]
|
|
32
|
+
);
|
|
29
33
|
const controlled = valuesProp !== void 0;
|
|
30
|
-
const [internalValues, setInternalValues] = useState(defaultValues ?? {});
|
|
34
|
+
const [internalValues, setInternalValues] = useState(() => defaultValues ?? {});
|
|
31
35
|
const values = controlled ? valuesProp : internalValues;
|
|
32
36
|
const [errors, setErrors] = useState({});
|
|
33
37
|
const [touched, setTouchedState] = useState({});
|
|
@@ -35,94 +39,126 @@ function useFormRootState({
|
|
|
35
39
|
const [isSubmitting, setIsSubmitting] = useState(false);
|
|
36
40
|
const [announce, setAnnounce] = useState(null);
|
|
37
41
|
const fieldRefs = useRef(/* @__PURE__ */ new Map());
|
|
38
|
-
const
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
42
|
+
const registeredRulesRef = useRef({});
|
|
43
|
+
const rulesPropRef = useRef(rulesProp);
|
|
44
|
+
rulesPropRef.current = rulesProp;
|
|
45
|
+
const valuesRef = useRef(values);
|
|
46
|
+
valuesRef.current = values;
|
|
47
|
+
const errorsRef = useRef(errors);
|
|
48
|
+
errorsRef.current = errors;
|
|
49
|
+
const touchedRef = useRef(touched);
|
|
50
|
+
touchedRef.current = touched;
|
|
51
|
+
const controlledRef = useRef(controlled);
|
|
52
|
+
controlledRef.current = controlled;
|
|
53
|
+
const defaultValuesRef = useRef(defaultValues);
|
|
54
|
+
defaultValuesRef.current = defaultValues;
|
|
55
|
+
const onValuesChangeRef = useRef(onValuesChange);
|
|
56
|
+
onValuesChangeRef.current = onValuesChange;
|
|
57
|
+
const onResetRef = useRef(onReset);
|
|
58
|
+
onResetRef.current = onReset;
|
|
59
|
+
const resolveRulesForField = useCallback((name) => {
|
|
60
|
+
return mergeFormFieldRules(registeredRulesRef.current[name], rulesPropRef.current?.[name]);
|
|
61
|
+
}, []);
|
|
62
|
+
const setValues = useCallback((next) => {
|
|
63
|
+
if (!controlledRef.current) {
|
|
64
|
+
valuesRef.current = next;
|
|
65
|
+
setInternalValues(next);
|
|
66
|
+
}
|
|
67
|
+
onValuesChangeRef.current?.(next);
|
|
68
|
+
}, []);
|
|
47
69
|
const getValue = useCallback((name) => {
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
if (acc == null || typeof acc !== "object") return void 0;
|
|
51
|
-
return acc[key];
|
|
52
|
-
}, values);
|
|
53
|
-
}, [values]);
|
|
70
|
+
return getFormValueAtPath(valuesRef.current, name);
|
|
71
|
+
}, []);
|
|
54
72
|
const setValue = useCallback(
|
|
55
73
|
(name, value, options) => {
|
|
56
|
-
const nextValues = setFormValueAtPath(
|
|
74
|
+
const nextValues = setFormValueAtPath(valuesRef.current, name, value);
|
|
57
75
|
setValues(nextValues);
|
|
58
|
-
if (options?.shouldValidate) {
|
|
59
|
-
const message = validateFormFieldRules(value, nextValues,
|
|
60
|
-
|
|
61
|
-
|
|
76
|
+
if (options?.shouldValidate || Boolean(errorsRef.current[name])) {
|
|
77
|
+
const message = validateFormFieldRules(value, nextValues, resolveRulesForField(name));
|
|
78
|
+
const prevErrors = errorsRef.current;
|
|
79
|
+
if ((message ?? void 0) !== prevErrors[name]) {
|
|
80
|
+
const next = { ...prevErrors };
|
|
62
81
|
if (message) next[name] = message;
|
|
63
82
|
else delete next[name];
|
|
64
|
-
|
|
65
|
-
|
|
83
|
+
errorsRef.current = next;
|
|
84
|
+
setErrors(next);
|
|
85
|
+
}
|
|
66
86
|
}
|
|
67
87
|
},
|
|
68
|
-
[
|
|
88
|
+
[resolveRulesForField, setValues]
|
|
89
|
+
);
|
|
90
|
+
const getError = useCallback((name) => errorsRef.current[name], []);
|
|
91
|
+
const getErrors = useCallback(() => errorsRef.current, []);
|
|
92
|
+
const getFieldRules = useCallback(
|
|
93
|
+
(name) => resolveRulesForField(name),
|
|
94
|
+
[resolveRulesForField]
|
|
69
95
|
);
|
|
70
|
-
const getError = useCallback((name) => errors[name], [errors]);
|
|
71
|
-
const getErrors = useCallback(() => errors, [errors]);
|
|
72
|
-
const getFieldRules = useCallback((name) => fieldRulesRef.current[name], []);
|
|
73
96
|
const setTouched = useCallback((name, nextTouched) => {
|
|
74
|
-
|
|
97
|
+
const prevTouched = touchedRef.current;
|
|
98
|
+
if (Boolean(prevTouched[name]) === nextTouched) return;
|
|
99
|
+
const next = { ...prevTouched, [name]: nextTouched };
|
|
100
|
+
touchedRef.current = next;
|
|
101
|
+
setTouchedState(next);
|
|
75
102
|
}, []);
|
|
76
|
-
const isTouched = useCallback((name) => Boolean(
|
|
103
|
+
const isTouched = useCallback((name) => Boolean(touchedRef.current[name]), []);
|
|
77
104
|
const registerRef = useCallback((name, node) => {
|
|
78
105
|
if (node) fieldRefs.current.set(name, node);
|
|
79
106
|
else fieldRefs.current.delete(name);
|
|
80
107
|
}, []);
|
|
81
108
|
const registerFieldRules = useCallback((name, rules) => {
|
|
82
109
|
if (rules == null) return;
|
|
83
|
-
|
|
110
|
+
registeredRulesRef.current = { ...registeredRulesRef.current, [name]: rules };
|
|
84
111
|
}, []);
|
|
85
112
|
const unregisterFieldRules = useCallback((name) => {
|
|
86
|
-
const next = { ...
|
|
113
|
+
const next = { ...registeredRulesRef.current };
|
|
87
114
|
delete next[name];
|
|
88
|
-
|
|
115
|
+
registeredRulesRef.current = next;
|
|
89
116
|
}, []);
|
|
90
117
|
const validateField = useCallback(
|
|
91
118
|
(name) => {
|
|
119
|
+
const currentValues = valuesRef.current;
|
|
92
120
|
const message = validateFormFieldRules(
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
121
|
+
getFormValueAtPath(currentValues, name),
|
|
122
|
+
currentValues,
|
|
123
|
+
resolveRulesForField(name)
|
|
96
124
|
);
|
|
97
|
-
|
|
98
|
-
|
|
125
|
+
const prevErrors = errorsRef.current;
|
|
126
|
+
if ((message ?? void 0) !== prevErrors[name]) {
|
|
127
|
+
const next = { ...prevErrors };
|
|
99
128
|
if (message) next[name] = message;
|
|
100
129
|
else delete next[name];
|
|
101
|
-
|
|
102
|
-
|
|
130
|
+
errorsRef.current = next;
|
|
131
|
+
setErrors(next);
|
|
132
|
+
}
|
|
103
133
|
return message;
|
|
104
134
|
},
|
|
105
|
-
[
|
|
135
|
+
[resolveRulesForField]
|
|
106
136
|
);
|
|
107
137
|
const validateForm = useCallback(() => {
|
|
138
|
+
const currentValues = valuesRef.current;
|
|
139
|
+
const ruleNames = /* @__PURE__ */ new Set([
|
|
140
|
+
...Object.keys(registeredRulesRef.current),
|
|
141
|
+
...Object.keys(rulesPropRef.current ?? {})
|
|
142
|
+
]);
|
|
108
143
|
const nextErrors = {};
|
|
109
|
-
for (const name of
|
|
144
|
+
for (const name of ruleNames) {
|
|
110
145
|
const message = validateFormFieldRules(
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
146
|
+
getFormValueAtPath(currentValues, name),
|
|
147
|
+
currentValues,
|
|
148
|
+
resolveRulesForField(name)
|
|
114
149
|
);
|
|
115
150
|
if (message) nextErrors[name] = message;
|
|
116
151
|
}
|
|
152
|
+
errorsRef.current = nextErrors;
|
|
117
153
|
setErrors(nextErrors);
|
|
118
154
|
return nextErrors;
|
|
119
|
-
}, [
|
|
155
|
+
}, [resolveRulesForField]);
|
|
120
156
|
const focusFirstInvalid = useCallback(() => {
|
|
121
|
-
focusFirstFormInvalidField(fieldRefs.current,
|
|
122
|
-
}, [
|
|
157
|
+
focusFirstFormInvalidField(fieldRefs.current, errorsRef.current);
|
|
158
|
+
}, []);
|
|
123
159
|
const clearAnnounce = useCallback(() => setAnnounce(null), []);
|
|
124
|
-
const bindingValue = useMemo(
|
|
125
|
-
|
|
160
|
+
const bindingValue = useMemo(() => {
|
|
161
|
+
return {
|
|
126
162
|
disabled,
|
|
127
163
|
readOnly,
|
|
128
164
|
validateMode,
|
|
@@ -143,45 +179,54 @@ function useFormRootState({
|
|
|
143
179
|
focusFirstInvalid,
|
|
144
180
|
announce,
|
|
145
181
|
clearAnnounce
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
182
|
+
};
|
|
183
|
+
}, [
|
|
184
|
+
announce,
|
|
185
|
+
clearAnnounce,
|
|
186
|
+
disabled,
|
|
187
|
+
errors,
|
|
188
|
+
focusFirstInvalid,
|
|
189
|
+
getError,
|
|
190
|
+
getErrors,
|
|
191
|
+
getFieldRules,
|
|
192
|
+
getValue,
|
|
193
|
+
isSubmitting,
|
|
194
|
+
isTouched,
|
|
195
|
+
readOnly,
|
|
196
|
+
registerFieldRules,
|
|
197
|
+
registerRef,
|
|
198
|
+
setTouched,
|
|
199
|
+
setValue,
|
|
200
|
+
submitCount,
|
|
201
|
+
touched,
|
|
202
|
+
unregisterFieldRules,
|
|
203
|
+
validateField,
|
|
204
|
+
validateForm,
|
|
205
|
+
validateMode,
|
|
206
|
+
values
|
|
207
|
+
]);
|
|
170
208
|
const handleSubmit = useCallback(
|
|
171
209
|
async (event) => {
|
|
172
210
|
event.preventDefault();
|
|
173
211
|
setSubmitCount((n) => n + 1);
|
|
174
212
|
setAnnounce(null);
|
|
213
|
+
let submitValues = valuesRef.current;
|
|
175
214
|
let nextErrors = validateForm();
|
|
176
215
|
if (resolver) {
|
|
177
|
-
const result = await resolver(
|
|
216
|
+
const result = await resolver(submitValues);
|
|
217
|
+
if (result.values !== void 0) {
|
|
218
|
+
submitValues = result.values;
|
|
219
|
+
}
|
|
178
220
|
if (result.errors) {
|
|
179
|
-
|
|
221
|
+
const cleaned = cleanFormResolverErrors(result.errors);
|
|
222
|
+
nextErrors = { ...nextErrors, ...cleaned };
|
|
223
|
+
errorsRef.current = nextErrors;
|
|
180
224
|
setErrors(nextErrors);
|
|
181
225
|
}
|
|
182
226
|
}
|
|
183
|
-
|
|
184
|
-
|
|
227
|
+
const errorTotal = countFormErrors(nextErrors);
|
|
228
|
+
if (errorTotal > 0) {
|
|
229
|
+
setAnnounce(buildFormErrorSummaryMessage(errorTotal, labels));
|
|
185
230
|
focusFirstFormInvalidField(fieldRefs.current, nextErrors);
|
|
186
231
|
onSubmitError?.(nextErrors);
|
|
187
232
|
return;
|
|
@@ -189,19 +234,36 @@ function useFormRootState({
|
|
|
189
234
|
if (!onSubmit) return;
|
|
190
235
|
try {
|
|
191
236
|
setIsSubmitting(true);
|
|
192
|
-
await onSubmit(
|
|
237
|
+
await onSubmit(submitValues);
|
|
193
238
|
setAnnounce(buildFormSuccessAnnounceMessage(labels));
|
|
194
239
|
} finally {
|
|
195
240
|
setIsSubmitting(false);
|
|
196
241
|
}
|
|
197
242
|
},
|
|
198
|
-
[labels, onSubmit, onSubmitError, resolver, validateForm
|
|
243
|
+
[labels, onSubmit, onSubmitError, resolver, validateForm]
|
|
199
244
|
);
|
|
245
|
+
const handleReset = useCallback((event) => {
|
|
246
|
+
onResetRef.current?.(event);
|
|
247
|
+
if (event.defaultPrevented) return;
|
|
248
|
+
const initial = defaultValuesRef.current ?? {};
|
|
249
|
+
if (!controlledRef.current) {
|
|
250
|
+
valuesRef.current = initial;
|
|
251
|
+
setInternalValues(initial);
|
|
252
|
+
}
|
|
253
|
+
onValuesChangeRef.current?.(initial);
|
|
254
|
+
errorsRef.current = {};
|
|
255
|
+
touchedRef.current = {};
|
|
256
|
+
setErrors({});
|
|
257
|
+
setTouchedState({});
|
|
258
|
+
setSubmitCount(0);
|
|
259
|
+
setAnnounce(null);
|
|
260
|
+
}, []);
|
|
200
261
|
const hasErrors = countFormErrors(errors) > 0;
|
|
201
262
|
return {
|
|
202
263
|
shellIds,
|
|
203
264
|
bindingValue,
|
|
204
265
|
handleSubmit,
|
|
266
|
+
handleReset,
|
|
205
267
|
errors,
|
|
206
268
|
hasErrors,
|
|
207
269
|
isSubmitting,
|
|
@@ -2,8 +2,9 @@
|
|
|
2
2
|
import { jsxs, jsx } from "react/jsx-runtime";
|
|
3
3
|
import { forwardRef, useMemo, Children, isValidElement } from "react";
|
|
4
4
|
import { Radio } from "../../core/Radio/index.js";
|
|
5
|
+
import { dataFlag } from "../../core/utils/dataContract.js";
|
|
6
|
+
import { mergeRefs } from "../../core/utils/mergeRefs.js";
|
|
5
7
|
import { OptionGroupFieldset } from "../utils/optionGroupFieldset.js";
|
|
6
|
-
import { itemsPartTaken } from "../../core/utils/itemsBesideChildren.js";
|
|
7
8
|
import { resolveRadioGroupMotionDefaults, useRadioGroupRootMotion } from "./radioGroupAnimations.js";
|
|
8
9
|
import { RadioGroupProvider, RadioGroupClassNamesProvider, RadioGroupMotionProvider, useRadioGroupClassNames, useRadioGroupContext } from "./radioGroupContext.js";
|
|
9
10
|
import { RadioGroupLegend, RadioGroupList, RadioGroupHint, RadioGroupError } from "./radioGroupParts.js";
|
|
@@ -28,7 +29,7 @@ const RadioGroupFieldsetShell = forwardRef(
|
|
|
28
29
|
...props
|
|
29
30
|
}, ref) {
|
|
30
31
|
const slotClassNames = useRadioGroupClassNames();
|
|
31
|
-
const { selectedValue, required, readOnly, legendId } = useRadioGroupContext();
|
|
32
|
+
const { selectedValue, required, readOnly, disabled, legendId } = useRadioGroupContext();
|
|
32
33
|
const part = useRadioGroupRootMotion({
|
|
33
34
|
forwardedRef: ref,
|
|
34
35
|
selectionIdentity: selectedValue ?? "",
|
|
@@ -50,7 +51,9 @@ const RadioGroupFieldsetShell = forwardRef(
|
|
|
50
51
|
"aria-labelledby": labelledBy,
|
|
51
52
|
"aria-required": required || void 0,
|
|
52
53
|
"aria-readonly": readOnly || void 0,
|
|
53
|
-
"data-
|
|
54
|
+
"data-disabled": dataFlag(disabled),
|
|
55
|
+
"data-readonly": dataFlag(readOnly),
|
|
56
|
+
"data-required": dataFlag(required),
|
|
54
57
|
children
|
|
55
58
|
}
|
|
56
59
|
);
|
|
@@ -65,9 +68,12 @@ const RadioGroupRoot = forwardRef(
|
|
|
65
68
|
size,
|
|
66
69
|
label,
|
|
67
70
|
hint,
|
|
68
|
-
error,
|
|
69
|
-
items,
|
|
70
|
-
disabled
|
|
71
|
+
error: _error,
|
|
72
|
+
items: _items,
|
|
73
|
+
disabled: _disabled,
|
|
74
|
+
invalid: invalidProp,
|
|
75
|
+
onKeyDown: _onKeyDown,
|
|
76
|
+
onBlur: _onBlur,
|
|
71
77
|
readOnly: _readOnly,
|
|
72
78
|
name: _name,
|
|
73
79
|
required: _required,
|
|
@@ -83,14 +89,28 @@ const RadioGroupRoot = forwardRef(
|
|
|
83
89
|
playInitialState,
|
|
84
90
|
...fieldsetProps
|
|
85
91
|
} = props;
|
|
86
|
-
const {
|
|
92
|
+
const {
|
|
93
|
+
contextValue,
|
|
94
|
+
fieldLabelCtx,
|
|
95
|
+
hintId,
|
|
96
|
+
errorId,
|
|
97
|
+
disabled,
|
|
98
|
+
optionList,
|
|
99
|
+
formInvalid,
|
|
100
|
+
resolvedError,
|
|
101
|
+
bindFieldsetRef,
|
|
102
|
+
handleKeyDown,
|
|
103
|
+
handleBlur
|
|
104
|
+
} = useRadioGroupRootState(props);
|
|
87
105
|
const motionDefaults = useMemo(() => resolveRadioGroupMotionDefaults(), []);
|
|
88
|
-
const optionList = items && !itemsPartTaken("RadioGroup", children, "RadioRoot", "RadioGroup.List") ? items : void 0;
|
|
89
106
|
const fieldset = /* @__PURE__ */ jsxs(
|
|
90
107
|
RadioGroupFieldsetShell,
|
|
91
108
|
{
|
|
92
|
-
ref,
|
|
109
|
+
ref: mergeRefs(ref, bindFieldsetRef),
|
|
93
110
|
disabled,
|
|
111
|
+
invalid: formInvalid ? true : invalidProp,
|
|
112
|
+
onKeyDown: handleKeyDown,
|
|
113
|
+
onBlur: handleBlur,
|
|
94
114
|
hintId,
|
|
95
115
|
errorId,
|
|
96
116
|
size,
|
|
@@ -109,7 +129,7 @@ const RadioGroupRoot = forwardRef(
|
|
|
109
129
|
option.value
|
|
110
130
|
)) }) : null,
|
|
111
131
|
hint != null ? /* @__PURE__ */ jsx(RadioGroupHint, { children: hint }) : null,
|
|
112
|
-
|
|
132
|
+
resolvedError != null ? /* @__PURE__ */ jsx(RadioGroupError, { children: resolvedError }) : null,
|
|
113
133
|
children
|
|
114
134
|
]
|
|
115
135
|
}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { KeyboardEvent, ReactNode } from 'react';
|
|
2
|
+
import { RadioGroupItem } from './radioGroupTypes.js';
|
|
1
3
|
/**
|
|
2
4
|
* RadioGroup uses native `<fieldset role="radiogroup">` + `<legend>`.
|
|
3
5
|
* `aria-readonly` lives on the group: ARIA 1.2 does not allow it on `radio`.
|
|
@@ -5,3 +7,11 @@
|
|
|
5
7
|
*/
|
|
6
8
|
export declare const RADIO_GROUP_USES_NATIVE_FIELDSET: true;
|
|
7
9
|
export declare function radioGroupName(nameProp: string | undefined, autoId: string): string;
|
|
10
|
+
export declare function findFirstEnabledRadioValue(items: readonly RadioGroupItem[] | undefined, children: ReactNode): string | null;
|
|
11
|
+
export declare function createRadioGroupKeyDownHandler({ disabled, readOnly, groupName, selectValue, onKeyDown, }: {
|
|
12
|
+
disabled: boolean;
|
|
13
|
+
readOnly: boolean;
|
|
14
|
+
groupName: string;
|
|
15
|
+
selectValue: (value: string | undefined) => void;
|
|
16
|
+
onKeyDown?: (event: KeyboardEvent<HTMLFieldSetElement>) => void;
|
|
17
|
+
}): (event: KeyboardEvent<HTMLFieldSetElement>) => void;
|
|
@@ -1,6 +1,81 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { Children, isValidElement } from "react";
|
|
3
|
+
import { focusKeyboard } from "../../core/utils/focusElement.js";
|
|
4
|
+
import { isRtlElement } from "../../core/utils/readingDirection.js";
|
|
1
5
|
function radioGroupName(nameProp, autoId) {
|
|
2
6
|
return nameProp ?? `radio-group-${autoId}`;
|
|
3
7
|
}
|
|
8
|
+
function findFirstEnabledRadioValue(items, children) {
|
|
9
|
+
if (items && items.length > 0) {
|
|
10
|
+
const first = items.find((item) => !item.disabled);
|
|
11
|
+
return first ? String(first.value) : "";
|
|
12
|
+
}
|
|
13
|
+
let foundAnyRadio = false;
|
|
14
|
+
let firstEnabled = null;
|
|
15
|
+
const walk = (node) => {
|
|
16
|
+
if (firstEnabled !== null) return;
|
|
17
|
+
for (const child of Children.toArray(node)) {
|
|
18
|
+
if (!isValidElement(child)) continue;
|
|
19
|
+
const displayName = child.type.displayName;
|
|
20
|
+
const props = child.props;
|
|
21
|
+
if (displayName === "RadioRoot") {
|
|
22
|
+
foundAnyRadio = true;
|
|
23
|
+
if (!props.disabled && props.value !== void 0 && props.value !== null) {
|
|
24
|
+
firstEnabled = String(props.value);
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
continue;
|
|
28
|
+
}
|
|
29
|
+
if (props.children != null) {
|
|
30
|
+
walk(props.children);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
walk(children);
|
|
35
|
+
if (firstEnabled !== null) return firstEnabled;
|
|
36
|
+
return foundAnyRadio ? "" : null;
|
|
37
|
+
}
|
|
38
|
+
function createRadioGroupKeyDownHandler({
|
|
39
|
+
disabled,
|
|
40
|
+
readOnly,
|
|
41
|
+
groupName,
|
|
42
|
+
selectValue,
|
|
43
|
+
onKeyDown
|
|
44
|
+
}) {
|
|
45
|
+
return (event) => {
|
|
46
|
+
onKeyDown?.(event);
|
|
47
|
+
if (event.defaultPrevented) return;
|
|
48
|
+
const { key } = event;
|
|
49
|
+
const isArrow = key === "ArrowRight" || key === "ArrowLeft" || key === "ArrowDown" || key === "ArrowUp";
|
|
50
|
+
if (!isArrow) return;
|
|
51
|
+
if (disabled || readOnly) {
|
|
52
|
+
event.preventDefault();
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
const groupEl = event.currentTarget;
|
|
56
|
+
const radios = Array.from(
|
|
57
|
+
groupEl.querySelectorAll('input[type="radio"]:not(:disabled)')
|
|
58
|
+
).filter((input) => !input.name || input.name === groupName);
|
|
59
|
+
if (radios.length === 0) return;
|
|
60
|
+
const rtl = isRtlElement(groupEl);
|
|
61
|
+
const step = key === "ArrowDown" ? 1 : key === "ArrowUp" ? -1 : key === "ArrowRight" ? rtl ? -1 : 1 : rtl ? 1 : -1;
|
|
62
|
+
let currentIndex = radios.findIndex((el) => el === document.activeElement);
|
|
63
|
+
if (currentIndex < 0) {
|
|
64
|
+
currentIndex = radios.findIndex((el) => el.checked);
|
|
65
|
+
}
|
|
66
|
+
const nextIndex = currentIndex < 0 ? step > 0 ? 0 : radios.length - 1 : (currentIndex + step + radios.length) % radios.length;
|
|
67
|
+
const nextRadio = radios[nextIndex];
|
|
68
|
+
event.preventDefault();
|
|
69
|
+
focusKeyboard(nextRadio);
|
|
70
|
+
if (nextRadio.hasAttribute("value")) {
|
|
71
|
+
selectValue(nextRadio.value);
|
|
72
|
+
} else {
|
|
73
|
+
nextRadio.click();
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
}
|
|
4
77
|
export {
|
|
78
|
+
createRadioGroupKeyDownHandler,
|
|
79
|
+
findFirstEnabledRadioValue,
|
|
5
80
|
radioGroupName
|
|
6
81
|
};
|
|
@@ -26,8 +26,8 @@ export type RadioGroupContextValue = {
|
|
|
26
26
|
errorId: string;
|
|
27
27
|
selectedValue: string | null;
|
|
28
28
|
selectValue: (value: string | undefined) => void;
|
|
29
|
-
/**
|
|
30
|
-
|
|
29
|
+
/** Deterministic check for whether an option carries native `required`. */
|
|
30
|
+
isOptionRequired: (optionValue: string | undefined, optionDisabled: boolean) => boolean;
|
|
31
31
|
};
|
|
32
32
|
export type RadioGroupPartMotion = {
|
|
33
33
|
hoverIn?: MotionValue;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { RadioGroupContextValue, UseRadioGroupRootStateProps } from './radioGroupTypes.js';
|
|
2
|
-
export declare function useRadioGroupRootState({ required, value: valueProp, defaultValue, onValueChange, disabled, readOnly, name: nameProp, hintId: hintIdProp, errorId: errorIdProp, }: UseRadioGroupRootStateProps): {
|
|
2
|
+
export declare function useRadioGroupRootState({ required, value: valueProp, defaultValue, onValueChange, disabled: disabledProp, readOnly: readOnlyProp, name: nameProp, error, items, children, onKeyDown, onBlur: onBlurProp, hintId: hintIdProp, errorId: errorIdProp, }: UseRadioGroupRootStateProps): {
|
|
3
3
|
contextValue: RadioGroupContextValue;
|
|
4
4
|
fieldLabelCtx: {
|
|
5
5
|
required: boolean;
|
|
@@ -7,4 +7,10 @@ export declare function useRadioGroupRootState({ required, value: valueProp, def
|
|
|
7
7
|
hintId: string;
|
|
8
8
|
errorId: string;
|
|
9
9
|
disabled: boolean;
|
|
10
|
+
optionList: import('./radioGroupTypes.js').RadioGroupItem[] | undefined;
|
|
11
|
+
formInvalid: boolean;
|
|
12
|
+
resolvedError: string | number | bigint | boolean | import('react').ReactElement<unknown, string | import('react').JSXElementConstructor<any>> | Iterable<import('react').ReactNode> | Promise<string | number | bigint | boolean | import('react').ReactPortal | import('react').ReactElement<unknown, string | import('react').JSXElementConstructor<any>> | Iterable<import('react').ReactNode> | null | undefined> | undefined;
|
|
13
|
+
bindFieldsetRef: (node: HTMLFieldSetElement | null) => void;
|
|
14
|
+
handleKeyDown: (event: import('react').KeyboardEvent<HTMLFieldSetElement>) => void;
|
|
15
|
+
handleBlur: (event: React.FocusEvent<HTMLFieldSetElement>) => void;
|
|
10
16
|
};
|