@funstack/ui 0.1.0-alpha.11 → 0.1.0-alpha.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/accordion/accordion-context.mjs.map +1 -1
- package/dist/accordion/accordion-item.d.mts +3 -4
- package/dist/accordion/accordion-item.d.mts.map +1 -1
- package/dist/accordion/accordion-item.mjs +10 -4
- package/dist/accordion/accordion-item.mjs.map +1 -1
- package/dist/accordion/accordion-panel.d.mts +3 -4
- package/dist/accordion/accordion-panel.d.mts.map +1 -1
- package/dist/accordion/accordion-panel.mjs +2 -1
- package/dist/accordion/accordion-panel.mjs.map +1 -1
- package/dist/accordion/accordion-root.d.mts +3 -3
- package/dist/accordion/accordion-root.d.mts.map +1 -1
- package/dist/accordion/accordion-root.mjs +8 -19
- package/dist/accordion/accordion-root.mjs.map +1 -1
- package/dist/accordion/accordion-trigger.d.mts +3 -4
- package/dist/accordion/accordion-trigger.d.mts.map +1 -1
- package/dist/accordion/accordion-trigger.mjs +5 -3
- package/dist/accordion/accordion-trigger.mjs.map +1 -1
- package/dist/button/button.d.mts +4 -2
- package/dist/button/button.d.mts.map +1 -1
- package/dist/button/button.mjs +3 -2
- package/dist/button/button.mjs.map +1 -1
- package/dist/checkbox/checkbox.d.mts +4 -5
- package/dist/checkbox/checkbox.d.mts.map +1 -1
- package/dist/checkbox/checkbox.mjs +16 -59
- package/dist/checkbox/checkbox.mjs.map +1 -1
- package/dist/checkbox-group/checkbox-group-context.mjs.map +1 -1
- package/dist/checkbox-group/checkbox-group-item.d.mts +3 -4
- package/dist/checkbox-group/checkbox-group-item.d.mts.map +1 -1
- package/dist/checkbox-group/checkbox-group-item.mjs +21 -27
- package/dist/checkbox-group/checkbox-group-item.mjs.map +1 -1
- package/dist/checkbox-group/checkbox-group-label.mjs +1 -6
- package/dist/checkbox-group/checkbox-group-label.mjs.map +1 -1
- package/dist/checkbox-group/checkbox-group-parent.d.mts +3 -4
- package/dist/checkbox-group/checkbox-group-parent.d.mts.map +1 -1
- package/dist/checkbox-group/checkbox-group-parent.mjs +12 -10
- package/dist/checkbox-group/checkbox-group-parent.mjs.map +1 -1
- package/dist/checkbox-group/checkbox-group-root.d.mts +1 -1
- package/dist/checkbox-group/checkbox-group-root.d.mts.map +1 -1
- package/dist/checkbox-group/checkbox-group-root.mjs +74 -101
- package/dist/checkbox-group/checkbox-group-root.mjs.map +1 -1
- package/dist/combobox/combobox-clear.d.mts.map +1 -1
- package/dist/combobox/combobox-clear.mjs +5 -6
- package/dist/combobox/combobox-clear.mjs.map +1 -1
- package/dist/combobox/combobox-context.mjs.map +1 -1
- package/dist/combobox/combobox-group.d.mts.map +1 -1
- package/dist/combobox/combobox-group.mjs +2 -1
- package/dist/combobox/combobox-group.mjs.map +1 -1
- package/dist/combobox/combobox-input.d.mts.map +1 -1
- package/dist/combobox/combobox-input.mjs +14 -7
- package/dist/combobox/combobox-input.mjs.map +1 -1
- package/dist/combobox/combobox-list.d.mts.map +1 -1
- package/dist/combobox/combobox-list.mjs +6 -10
- package/dist/combobox/combobox-list.mjs.map +1 -1
- package/dist/combobox/combobox-option.d.mts.map +1 -1
- package/dist/combobox/combobox-option.mjs +2 -1
- package/dist/combobox/combobox-option.mjs.map +1 -1
- package/dist/combobox/combobox-popup.d.mts.map +1 -1
- package/dist/combobox/combobox-popup.mjs +9 -25
- package/dist/combobox/combobox-popup.mjs.map +1 -1
- package/dist/combobox/combobox-root.d.mts.map +1 -1
- package/dist/combobox/combobox-root.mjs +30 -102
- package/dist/combobox/combobox-root.mjs.map +1 -1
- package/dist/combobox/combobox-trigger.d.mts.map +1 -1
- package/dist/combobox/combobox-trigger.mjs +6 -25
- package/dist/combobox/combobox-trigger.mjs.map +1 -1
- package/dist/combobox/index.mjs +1 -1
- package/dist/combobox/use-combobox-form.mjs +56 -0
- package/dist/combobox/use-combobox-form.mjs.map +1 -0
- package/dist/combobox/use-option-registry.mjs +62 -0
- package/dist/combobox/use-option-registry.mjs.map +1 -0
- package/dist/dialog/dialog-close.d.mts.map +1 -1
- package/dist/dialog/dialog-close.mjs +29 -62
- package/dist/dialog/dialog-close.mjs.map +1 -1
- package/dist/dialog/dialog-context.mjs.map +1 -1
- package/dist/dialog/dialog-form.d.mts.map +1 -1
- package/dist/dialog/dialog-form.mjs +5 -4
- package/dist/dialog/dialog-form.mjs.map +1 -1
- package/dist/dialog/dialog-popup.d.mts +3 -4
- package/dist/dialog/dialog-popup.d.mts.map +1 -1
- package/dist/dialog/dialog-popup.mjs +37 -98
- package/dist/dialog/dialog-popup.mjs.map +1 -1
- package/dist/dialog/dialog-root.d.mts.map +1 -1
- package/dist/dialog/dialog-root.mjs +30 -118
- package/dist/dialog/dialog-root.mjs.map +1 -1
- package/dist/dialog/dialog-trigger.d.mts.map +1 -1
- package/dist/dialog/dialog-trigger.mjs +13 -16
- package/dist/dialog/dialog-trigger.mjs.map +1 -1
- package/dist/field/field-control.mjs +6 -13
- package/dist/field/field-control.mjs.map +1 -1
- package/dist/field/field-description.d.mts.map +1 -1
- package/dist/field/field-description.mjs +1 -2
- package/dist/field/field-description.mjs.map +1 -1
- package/dist/field/field-error.d.mts.map +1 -1
- package/dist/field/field-error.mjs +1 -2
- package/dist/field/field-error.mjs.map +1 -1
- package/dist/field/field-label.d.mts.map +1 -1
- package/dist/field/field-label.mjs +3 -11
- package/dist/field/field-label.mjs.map +1 -1
- package/dist/field/field-root.mjs +21 -41
- package/dist/field/field-root.mjs.map +1 -1
- package/dist/field/index.mjs +1 -1
- package/dist/field/use-server-error-visibility.mjs +44 -0
- package/dist/field/use-server-error-visibility.mjs.map +1 -0
- package/dist/form/form-root.d.mts.map +1 -1
- package/dist/form/form-root.mjs +6 -7
- package/dist/form/form-root.mjs.map +1 -1
- package/dist/form/form-submit.d.mts +1 -1
- package/dist/form/form-submit.mjs +4 -10
- package/dist/form/form-submit.mjs.map +1 -1
- package/dist/index.d.mts +2 -2
- package/dist/internal/anchor-position.mjs +1 -59
- package/dist/internal/anchor-position.mjs.map +1 -1
- package/dist/internal/announce.mjs.map +1 -1
- package/dist/internal/arrow-keys.mjs +21 -0
- package/dist/internal/arrow-keys.mjs.map +1 -0
- package/dist/internal/decimal.mjs +7 -1
- package/dist/internal/decimal.mjs.map +1 -1
- package/dist/internal/dom-order.mjs +17 -0
- package/dist/internal/dom-order.mjs.map +1 -0
- package/dist/internal/field-context.d.mts.map +1 -1
- package/dist/internal/field-context.mjs +11 -1
- package/dist/internal/field-context.mjs.map +1 -1
- package/dist/internal/focus-first-invalid.mjs +1 -1
- package/dist/internal/focus-first-invalid.mjs.map +1 -1
- package/dist/internal/group-member.mjs +37 -0
- package/dist/internal/group-member.mjs.map +1 -0
- package/dist/internal/overlay-popup.mjs +103 -0
- package/dist/internal/overlay-popup.mjs.map +1 -0
- package/dist/internal/popover-open.mjs +18 -0
- package/dist/internal/popover-open.mjs.map +1 -0
- package/dist/internal/render-element.d.mts +2 -0
- package/dist/internal/render-element.mjs +20 -2
- package/dist/internal/render-element.mjs.map +1 -1
- package/dist/internal/shipped-styles.mjs +14 -0
- package/dist/internal/shipped-styles.mjs.map +1 -0
- package/dist/internal/sync-presence.mjs +5 -1
- package/dist/internal/sync-presence.mjs.map +1 -1
- package/dist/internal/toolbar-context.mjs.map +1 -1
- package/dist/internal/tooltip-warm.mjs +1 -1
- package/dist/internal/tooltip-warm.mjs.map +1 -1
- package/dist/internal/transition-boundary.mjs +1 -1
- package/dist/internal/transition-boundary.mjs.map +1 -1
- package/dist/internal/types.d.mts +2 -0
- package/dist/internal/types.d.mts.map +1 -1
- package/dist/internal/use-action-trigger.mjs +5 -23
- package/dist/internal/use-action-trigger.mjs.map +1 -1
- package/dist/internal/use-checkable-input.mjs +79 -0
- package/dist/internal/use-checkable-input.mjs.map +1 -0
- package/dist/internal/use-controllable-action.mjs +16 -24
- package/dist/internal/use-controllable-action.mjs.map +1 -1
- package/dist/internal/use-dev-warning.mjs +8 -4
- package/dist/internal/use-dev-warning.mjs.map +1 -1
- package/dist/internal/use-element-check.mjs +39 -0
- package/dist/internal/use-element-check.mjs.map +1 -0
- package/dist/internal/use-exit-animation.mjs +1 -1
- package/dist/internal/use-exit-animation.mjs.map +1 -1
- package/dist/internal/use-field-control.mjs +28 -12
- package/dist/internal/use-field-control.mjs.map +1 -1
- package/dist/internal/use-fieldset-group.mjs +46 -0
- package/dist/internal/use-fieldset-group.mjs.map +1 -0
- package/dist/internal/use-form-reset.mjs +1 -5
- package/dist/internal/use-form-reset.mjs.map +1 -1
- package/dist/internal/use-item-order.mjs +42 -0
- package/dist/internal/use-item-order.mjs.map +1 -0
- package/dist/internal/use-latest.mjs +4 -8
- package/dist/internal/use-latest.mjs.map +1 -1
- package/dist/internal/use-merged-refs.mjs +19 -0
- package/dist/internal/use-merged-refs.mjs.map +1 -0
- package/dist/internal/use-name-warning.mjs +84 -0
- package/dist/internal/use-name-warning.mjs.map +1 -0
- package/dist/internal/use-native-checked.mjs +4 -6
- package/dist/internal/use-native-checked.mjs.map +1 -1
- package/dist/internal/use-native-focusgroup.mjs +19 -0
- package/dist/internal/use-native-focusgroup.mjs.map +1 -0
- package/dist/internal/use-native-group-reconciliation.mjs.map +1 -1
- package/dist/internal/use-overlay-close.mjs +63 -0
- package/dist/internal/use-overlay-close.mjs.map +1 -0
- package/dist/internal/{use-popover-root.mjs → use-overlay-root.mjs} +28 -39
- package/dist/internal/use-overlay-root.mjs.map +1 -0
- package/dist/internal/use-popover-popup.mjs +32 -78
- package/dist/internal/use-popover-popup.mjs.map +1 -1
- package/dist/internal/use-popover-trigger.d.mts +15 -0
- package/dist/internal/use-popover-trigger.d.mts.map +1 -0
- package/dist/internal/use-popover-trigger.mjs +13 -17
- package/dist/internal/use-popover-trigger.mjs.map +1 -1
- package/dist/internal/use-register-count.mjs +24 -0
- package/dist/internal/use-register-count.mjs.map +1 -0
- package/dist/internal/use-render.d.mts +2 -0
- package/dist/internal/use-render.mjs +2 -2
- package/dist/internal/use-render.mjs.map +1 -1
- package/dist/internal/use-resolved-placement.mjs +38 -22
- package/dist/internal/use-resolved-placement.mjs.map +1 -1
- package/dist/internal/use-roving-focus.mjs +5 -18
- package/dist/internal/use-roving-focus.mjs.map +1 -1
- package/dist/internal/use-superseded-rejection.mjs +47 -0
- package/dist/internal/use-superseded-rejection.mjs.map +1 -0
- package/dist/internal/validity.mjs +1 -13
- package/dist/internal/validity.mjs.map +1 -1
- package/dist/internal/value-set.mjs +41 -0
- package/dist/internal/value-set.mjs.map +1 -0
- package/dist/menu/index.d.mts +1 -1
- package/dist/menu/menu-checkbox-item.mjs.map +1 -1
- package/dist/menu/menu-context-trigger.d.mts +2 -7
- package/dist/menu/menu-context-trigger.d.mts.map +1 -1
- package/dist/menu/menu-context-trigger.mjs +10 -187
- package/dist/menu/menu-context-trigger.mjs.map +1 -1
- package/dist/menu/menu-context.d.mts +1 -1
- package/dist/menu/menu-context.mjs +1 -1
- package/dist/menu/menu-context.mjs.map +1 -1
- package/dist/menu/menu-dom.mjs +1 -2
- package/dist/menu/menu-dom.mjs.map +1 -1
- package/dist/menu/menu-gestures.mjs +167 -0
- package/dist/menu/menu-gestures.mjs.map +1 -0
- package/dist/menu/menu-group.d.mts.map +1 -1
- package/dist/menu/menu-group.mjs +2 -1
- package/dist/menu/menu-group.mjs.map +1 -1
- package/dist/menu/menu-hover.mjs +0 -1
- package/dist/menu/menu-hover.mjs.map +1 -1
- package/dist/menu/menu-item.mjs.map +1 -1
- package/dist/menu/menu-outside.mjs +101 -0
- package/dist/menu/menu-outside.mjs.map +1 -0
- package/dist/menu/menu-point.mjs +85 -0
- package/dist/menu/menu-point.mjs.map +1 -0
- package/dist/menu/menu-popup.d.mts +6 -7
- package/dist/menu/menu-popup.d.mts.map +1 -1
- package/dist/menu/menu-popup.mjs +37 -248
- package/dist/menu/menu-popup.mjs.map +1 -1
- package/dist/menu/menu-radio-group.mjs.map +1 -1
- package/dist/menu/menu-root.d.mts +10 -0
- package/dist/menu/menu-root.d.mts.map +1 -1
- package/dist/menu/menu-root.mjs +10 -8
- package/dist/menu/menu-root.mjs.map +1 -1
- package/dist/menu/menu-submenu-trigger.d.mts.map +1 -1
- package/dist/menu/menu-submenu-trigger.mjs +6 -6
- package/dist/menu/menu-submenu-trigger.mjs.map +1 -1
- package/dist/menu/menu-trigger.d.mts +4 -9
- package/dist/menu/menu-trigger.d.mts.map +1 -1
- package/dist/menu/menu-trigger.mjs +8 -6
- package/dist/menu/menu-trigger.mjs.map +1 -1
- package/dist/menu/use-menu-item.mjs +14 -16
- package/dist/menu/use-menu-item.mjs.map +1 -1
- package/dist/menu/use-menu-keyboard.mjs +88 -0
- package/dist/menu/use-menu-keyboard.mjs.map +1 -0
- package/dist/meter/meter-root.mjs +1 -1
- package/dist/number-field/index.d.mts +2 -1
- package/dist/number-field/index.d.mts.map +1 -1
- package/dist/number-field/index.mjs +2 -2
- package/dist/number-field/index.mjs.map +1 -1
- package/dist/number-field/number-field-arithmetic.mjs +30 -11
- package/dist/number-field/number-field-arithmetic.mjs.map +1 -1
- package/dist/number-field/number-field-context.d.mts +6 -1
- package/dist/number-field/number-field-context.d.mts.map +1 -0
- package/dist/number-field/number-field-context.mjs.map +1 -1
- package/dist/number-field/number-field-decrement.d.mts +1 -1
- package/dist/number-field/number-field-decrement.mjs +1 -1
- package/dist/number-field/number-field-decrement.mjs.map +1 -1
- package/dist/number-field/number-field-increment.d.mts +2 -22
- package/dist/number-field/number-field-increment.d.mts.map +1 -1
- package/dist/number-field/number-field-increment.mjs +2 -53
- package/dist/number-field/number-field-increment.mjs.map +1 -1
- package/dist/number-field/number-field-input.d.mts.map +1 -1
- package/dist/number-field/number-field-input.mjs +18 -22
- package/dist/number-field/number-field-input.mjs.map +1 -1
- package/dist/number-field/number-field-label.d.mts.map +1 -1
- package/dist/number-field/number-field-label.mjs +3 -9
- package/dist/number-field/number-field-label.mjs.map +1 -1
- package/dist/number-field/number-field-root.d.mts +2 -1
- package/dist/number-field/number-field-root.d.mts.map +1 -1
- package/dist/number-field/number-field-root.mjs +81 -91
- package/dist/number-field/number-field-root.mjs.map +1 -1
- package/dist/number-field/use-number-field-dev-warnings.mjs +28 -0
- package/dist/number-field/use-number-field-dev-warnings.mjs.map +1 -0
- package/dist/number-field/use-step-button.d.mts +24 -0
- package/dist/number-field/use-step-button.d.mts.map +1 -0
- package/dist/number-field/use-step-button.mjs +57 -3
- package/dist/number-field/use-step-button.mjs.map +1 -1
- package/dist/popover/popover-close.d.mts.map +1 -1
- package/dist/popover/popover-close.mjs +28 -67
- package/dist/popover/popover-close.mjs.map +1 -1
- package/dist/popover/popover-context.mjs.map +1 -1
- package/dist/popover/popover-popup.d.mts +9 -6
- package/dist/popover/popover-popup.d.mts.map +1 -1
- package/dist/popover/popover-popup.mjs +13 -36
- package/dist/popover/popover-popup.mjs.map +1 -1
- package/dist/popover/popover-root.mjs +4 -3
- package/dist/popover/popover-root.mjs.map +1 -1
- package/dist/popover/popover-trigger.d.mts +4 -8
- package/dist/popover/popover-trigger.d.mts.map +1 -1
- package/dist/popover/popover-trigger.mjs +2 -1
- package/dist/popover/popover-trigger.mjs.map +1 -1
- package/dist/progress/progress-root.mjs +1 -1
- package/dist/radio-group/radio-group-context.mjs.map +1 -1
- package/dist/radio-group/radio-group-item.d.mts +3 -4
- package/dist/radio-group/radio-group-item.d.mts.map +1 -1
- package/dist/radio-group/radio-group-item.mjs +20 -25
- package/dist/radio-group/radio-group-item.mjs.map +1 -1
- package/dist/radio-group/radio-group-label.mjs +1 -6
- package/dist/radio-group/radio-group-label.mjs.map +1 -1
- package/dist/radio-group/radio-group-root.d.mts +1 -1
- package/dist/radio-group/radio-group-root.d.mts.map +1 -1
- package/dist/radio-group/radio-group-root.mjs +21 -40
- package/dist/radio-group/radio-group-root.mjs.map +1 -1
- package/dist/select/select-dom.mjs +9 -18
- package/dist/select/select-dom.mjs.map +1 -1
- package/dist/select/select-option.mjs +1 -1
- package/dist/select/select-root.mjs +3 -2
- package/dist/select/select-root.mjs.map +1 -1
- package/dist/slider/slider-arithmetic.mjs +74 -13
- package/dist/slider/slider-arithmetic.mjs.map +1 -1
- package/dist/slider/slider-context.mjs.map +1 -1
- package/dist/slider/slider-label.d.mts.map +1 -1
- package/dist/slider/slider-label.mjs +3 -9
- package/dist/slider/slider-label.mjs.map +1 -1
- package/dist/slider/slider-root.d.mts +2 -2
- package/dist/slider/slider-root.d.mts.map +1 -1
- package/dist/slider/slider-root.mjs +36 -116
- package/dist/slider/slider-root.mjs.map +1 -1
- package/dist/slider/slider-thumb.d.mts.map +1 -1
- package/dist/slider/slider-thumb.mjs +8 -6
- package/dist/slider/slider-thumb.mjs.map +1 -1
- package/dist/slider/slider-value.d.mts.map +1 -1
- package/dist/slider/slider-value.mjs +2 -1
- package/dist/slider/slider-value.mjs.map +1 -1
- package/dist/slider/use-slider-dev-warnings.mjs +29 -0
- package/dist/slider/use-slider-dev-warnings.mjs.map +1 -0
- package/dist/slider/use-thumb-registry.mjs +51 -0
- package/dist/slider/use-thumb-registry.mjs.map +1 -0
- package/dist/switch/switch.d.mts +4 -5
- package/dist/switch/switch.d.mts.map +1 -1
- package/dist/switch/switch.mjs +15 -55
- package/dist/switch/switch.mjs.map +1 -1
- package/dist/tabs/tabs-context.d.mts +2 -3
- package/dist/tabs/tabs-context.d.mts.map +1 -1
- package/dist/tabs/tabs-context.mjs.map +1 -1
- package/dist/tabs/tabs-list.d.mts.map +1 -1
- package/dist/tabs/tabs-list.mjs +9 -22
- package/dist/tabs/tabs-list.mjs.map +1 -1
- package/dist/tabs/tabs-panel.d.mts +3 -4
- package/dist/tabs/tabs-panel.d.mts.map +1 -1
- package/dist/tabs/tabs-panel.mjs.map +1 -1
- package/dist/tabs/tabs-root.d.mts +4 -3
- package/dist/tabs/tabs-root.d.mts.map +1 -1
- package/dist/tabs/tabs-root.mjs +2 -1
- package/dist/tabs/tabs-root.mjs.map +1 -1
- package/dist/tabs/tabs-tab.d.mts +3 -4
- package/dist/tabs/tabs-tab.d.mts.map +1 -1
- package/dist/tabs/tabs-tab.mjs.map +1 -1
- package/dist/toast/toast-action.mjs.map +1 -1
- package/dist/toast/toast-close.d.mts.map +1 -1
- package/dist/toast/toast-close.mjs +2 -8
- package/dist/toast/toast-close.mjs.map +1 -1
- package/dist/toast/toast-context.mjs.map +1 -1
- package/dist/toast/toast-hotkey.mjs +27 -0
- package/dist/toast/toast-hotkey.mjs.map +1 -0
- package/dist/toast/toast-queue.mjs +137 -0
- package/dist/toast/toast-queue.mjs.map +1 -0
- package/dist/toast/toast-timers.mjs +65 -0
- package/dist/toast/toast-timers.mjs.map +1 -0
- package/dist/toast/toast-viewport.d.mts.map +1 -1
- package/dist/toast/toast-viewport.mjs +30 -235
- package/dist/toast/toast-viewport.mjs.map +1 -1
- package/dist/toast/toast.mjs +1 -1
- package/dist/toast/toast.mjs.map +1 -1
- package/dist/toast/use-modal-portal-host.mjs +52 -0
- package/dist/toast/use-modal-portal-host.mjs.map +1 -0
- package/dist/toggle/toggle.d.mts +3 -4
- package/dist/toggle/toggle.d.mts.map +1 -1
- package/dist/toggle/toggle.mjs +7 -10
- package/dist/toggle/toggle.mjs.map +1 -1
- package/dist/toggle-group/toggle-group-context.d.mts +2 -1
- package/dist/toggle-group/toggle-group-context.d.mts.map +1 -1
- package/dist/toggle-group/toggle-group-context.mjs.map +1 -1
- package/dist/toggle-group/toggle-group-item.d.mts +5 -3
- package/dist/toggle-group/toggle-group-item.d.mts.map +1 -1
- package/dist/toggle-group/toggle-group-item.mjs +5 -7
- package/dist/toggle-group/toggle-group-item.mjs.map +1 -1
- package/dist/toggle-group/toggle-group-root.d.mts.map +1 -1
- package/dist/toggle-group/toggle-group-root.mjs +29 -64
- package/dist/toggle-group/toggle-group-root.mjs.map +1 -1
- package/dist/toolbar/toolbar-root.d.mts +2 -2
- package/dist/toolbar/toolbar-root.d.mts.map +1 -1
- package/dist/toolbar/toolbar-root.mjs +3 -4
- package/dist/toolbar/toolbar-root.mjs.map +1 -1
- package/dist/tooltip/tooltip-context.d.mts +1 -1
- package/dist/tooltip/tooltip-context.mjs.map +1 -1
- package/dist/tooltip/tooltip-popup.d.mts.map +1 -1
- package/dist/tooltip/tooltip-popup.mjs +6 -15
- package/dist/tooltip/tooltip-popup.mjs.map +1 -1
- package/dist/tooltip/tooltip-root.mjs +2 -2
- package/dist/tooltip/tooltip-root.mjs.map +1 -1
- package/dist/tooltip/tooltip-trigger.d.mts +2 -1
- package/dist/tooltip/tooltip-trigger.d.mts.map +1 -1
- package/dist/tooltip/tooltip-trigger.mjs +3 -2
- package/dist/tooltip/tooltip-trigger.mjs.map +1 -1
- package/dist/tooltip/use-tooltip-interaction.mjs +4 -3
- package/dist/tooltip/use-tooltip-interaction.mjs.map +1 -1
- package/package.json +3 -2
- package/dist/accordion/accordion-context.d.mts +0 -5
- package/dist/accordion/accordion-context.d.mts.map +0 -1
- package/dist/internal/use-popover-root.mjs.map +0 -1
- /package/dist/internal/{use-popover-root.d.mts → use-overlay-root.d.mts} +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"slider-value.mjs","names":[],"sources":["../../src/slider/slider-value.tsx"],"sourcesContent":["\"use client\";\nimport type { ComponentPropsWithRef, CSSProperties, ReactNode } from \"react\";\nimport type { RenderProp, StateValue } from \"../internal/types.js\";\nimport { useDevWarning } from \"../internal/use-dev-warning.js\";\nimport { useRender } from \"../internal/use-render.js\";\nimport { useSliderContext } from \"./slider-context.js\";\nimport type { SliderRootState, SliderValue } from \"./slider-root.js\";\n\n/**\n * `T` defaults to `SliderValue` (a number or an array): a part is not connected to its Root's\n * value type. Pass it to narrow, `<Slider.Value<number>>`, or read `values`.\n */\nexport interface SliderValueState<T extends SliderValue = SliderValue> extends SliderRootState<T> {\n /** The `index` prop, or `null`. */\n readonly index: number | null;\n}\n\nexport interface SliderValueProps<T extends SliderValue = SliderValue> extends Omit<\n ComponentPropsWithRef<\"span\">,\n \"className\" | \"style\" | \"children\"\n> {\n /**\n * Show one thumb's value. Without it a single-thumb slider shows its value; a multi-thumb\n * slider needs `children` (dev warning otherwise, renders nothing).\n */\n index?: number;\n className?: StateValue<string | undefined, SliderValueState<T>>;\n style?: StateValue<CSSProperties | undefined, SliderValueState<T>>;\n children?: StateValue<ReactNode, SliderValueState<T>>;\n render?: RenderProp<ComponentPropsWithRef<\"span\">, SliderValueState<T>>;\n}\n\n/**\n * Displays the shown value: `children(state)`, or the thumb at `index`, or the single value as\n * text. A plain `span`, not `<output>`: a `status` live region updating on every step would\n * chatter (the slider itself exposes its value). No owned keys.\n */\nexport function SliderValuePart<T extends SliderValue = SliderValue>({\n index,\n className,\n style,\n children,\n render,\n ...rest\n}: SliderValueProps<T>) {\n const ctx = useSliderContext(\"Slider.Value\");\n const state: SliderValueState<T> = {\n ...(ctx.state as SliderRootState<T>),\n index: index ?? null,\n };\n\n const missing = children === undefined && index === undefined && ctx.shown.length > 1;\n useDevWarning(\n missing,\n \"Slider.Value: a multi-thumb slider has no single value to show. Pass `index` to show one \" +\n
|
|
1
|
+
{"version":3,"file":"slider-value.mjs","names":[],"sources":["../../src/slider/slider-value.tsx"],"sourcesContent":["\"use client\";\nimport type { ComponentPropsWithRef, CSSProperties, ReactNode } from \"react\";\nimport type { RenderProp, StateValue } from \"../internal/types.js\";\nimport { useDevWarning } from \"../internal/use-dev-warning.js\";\nimport { useRender } from \"../internal/use-render.js\";\nimport { useSliderContext } from \"./slider-context.js\";\nimport type { SliderRootState, SliderValue } from \"./slider-root.js\";\n\nconst isDev = process.env.NODE_ENV !== \"production\";\n\n/**\n * `T` defaults to `SliderValue` (a number or an array): a part is not connected to its Root's\n * value type. Pass it to narrow, `<Slider.Value<number>>`, or read `values`.\n */\nexport interface SliderValueState<T extends SliderValue = SliderValue> extends SliderRootState<T> {\n /** The `index` prop, or `null`. */\n readonly index: number | null;\n}\n\nexport interface SliderValueProps<T extends SliderValue = SliderValue> extends Omit<\n ComponentPropsWithRef<\"span\">,\n \"className\" | \"style\" | \"children\"\n> {\n /**\n * Show one thumb's value. Without it a single-thumb slider shows its value; a multi-thumb\n * slider needs `children` (dev warning otherwise, renders nothing).\n */\n index?: number;\n className?: StateValue<string | undefined, SliderValueState<T>>;\n style?: StateValue<CSSProperties | undefined, SliderValueState<T>>;\n children?: StateValue<ReactNode, SliderValueState<T>>;\n render?: RenderProp<ComponentPropsWithRef<\"span\">, SliderValueState<T>>;\n}\n\n/**\n * Displays the shown value: `children(state)`, or the thumb at `index`, or the single value as\n * text. A plain `span`, not `<output>`: a `status` live region updating on every step would\n * chatter (the slider itself exposes its value). No owned keys.\n */\nexport function SliderValuePart<T extends SliderValue = SliderValue>({\n index,\n className,\n style,\n children,\n render,\n ...rest\n}: SliderValueProps<T>) {\n const ctx = useSliderContext(\"Slider.Value\");\n const state: SliderValueState<T> = {\n ...(ctx.state as SliderRootState<T>),\n index: index ?? null,\n };\n\n const missing = children === undefined && index === undefined && ctx.shown.length > 1;\n useDevWarning(\n missing,\n isDev &&\n \"Slider.Value: a multi-thumb slider has no single value to show. Pass `index` to show one \" +\n \"thumb's value, or `children` (a function of the state) to format them all.\",\n );\n\n let fallback: ReactNode = null;\n if (index !== undefined) {\n const value = ctx.shown[index];\n fallback = value === undefined ? null : String(value);\n } else if (ctx.shown.length === 1) {\n fallback = String(ctx.shown[0]);\n }\n\n return useRender<ComponentPropsWithRef<\"span\">, SliderValueState<T>>({\n defaultElement: \"span\",\n render,\n state,\n className,\n style,\n children: children ?? fallback,\n props: rest,\n });\n}\n\nSliderValuePart.displayName = \"SliderValue\";\n"],"mappings":";;;;;AAQA,MAAM,QAAQ,QAAQ,IAAI,aAAa;;;;;;AA+BvC,SAAgB,gBAAqD,EACnE,OACA,WACA,OACA,UACA,QACA,GAAG,QACmB;CACtB,MAAM,MAAM,iBAAiB,cAAc;CAC3C,MAAM,QAA6B;EACjC,GAAI,IAAI;EACR,OAAO,SAAS;CAClB;CAEA,MAAM,UAAU,aAAa,KAAA,KAAa,UAAU,KAAA,KAAa,IAAI,MAAM,SAAS;CACpF,cACE,SACA,SACE,qKAEJ;CAEA,IAAI,WAAsB;CAC1B,IAAI,UAAU,KAAA,GAAW;EACvB,MAAM,QAAQ,IAAI,MAAM;EACxB,WAAW,UAAU,KAAA,IAAY,OAAO,OAAO,KAAK;CACtD,OAAO,IAAI,IAAI,MAAM,WAAW,GAC9B,WAAW,OAAO,IAAI,MAAM,EAAE;CAGhC,OAAO,UAA8D;EACnE,gBAAgB;EAChB;EACA;EACA;EACA;EACA,UAAU,YAAY;EACtB,OAAO;CACT,CAAC;AACH;AAEA,gBAAgB,cAAc"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useDevWarning } from "../internal/use-dev-warning.mjs";
|
|
3
|
+
import { isMaxReachable, isOnGrid, shapeOf, toArray } from "./slider-arithmetic.mjs";
|
|
4
|
+
import { useEffect, useRef } from "react";
|
|
5
|
+
//#region src/slider/use-slider-dev-warnings.ts
|
|
6
|
+
const isDev = process.env.NODE_ENV !== "production";
|
|
7
|
+
/** `Slider.Root`'s development warnings about its props (design 3.1, 5, 9.1). */
|
|
8
|
+
function useSliderDevWarnings(options) {
|
|
9
|
+
const { stepProp, stepValid, min, max, step, value, defaultValue, shape } = options;
|
|
10
|
+
const { unnamedGroup, labelCountRef } = options;
|
|
11
|
+
useDevWarning(!stepValid, isDev && `Slider.Root: \`step\` must be a positive number (got ${String(stepProp)}); using 1.`);
|
|
12
|
+
useDevWarning(stepValid && !isMaxReachable(min, max, step), isDev && `Slider.Root: \`max\` (${max}) is not on the step grid from \`min\` (${min}) with \`step\` ${step}: it is unreachable, as on a native range. The last reachable value is the last step below \`max\`.`);
|
|
13
|
+
const given = value ?? defaultValue;
|
|
14
|
+
const givenValues = given === void 0 ? [] : toArray(given);
|
|
15
|
+
useDevWarning(givenValues.some((v) => !isOnGrid(v, min, max, step)), isDev && `Slider.Root: the ${value !== void 0 ? "`value`" : "`defaultValue`"} (${givenValues.join(", ")}) is off the step grid or outside \`min\` / \`max\`. It is rendered as given and the browser sanitises it; the first user step snaps it.`);
|
|
16
|
+
useDevWarning(givenValues.some((v, i) => i > 0 && v < givenValues[i - 1]), isDev && `Slider.Root: the values (${givenValues.join(", ")}) must be in ascending order; the thumbs would be rendered crossed.`);
|
|
17
|
+
const currentShape = shapeOf(given);
|
|
18
|
+
useDevWarning(currentShape !== void 0 && currentShape !== shape, isDev && "Slider.Root: the value changed shape between a number and an array after mount. The shape is fixed at mount; remount the Slider (a `key`) to change the number of thumbs.");
|
|
19
|
+
const warnedGroupName = useRef(false);
|
|
20
|
+
useEffect(() => {
|
|
21
|
+
if (!isDev || warnedGroupName.current || !unnamedGroup || labelCountRef.current > 0) return;
|
|
22
|
+
warnedGroupName.current = true;
|
|
23
|
+
console.error("Slider.Root: a slider with several thumbs is a `group` and needs a name: render a Slider.Label, or pass `aria-label` / `aria-labelledby` to the Root.");
|
|
24
|
+
}, [unnamedGroup, labelCountRef]);
|
|
25
|
+
}
|
|
26
|
+
//#endregion
|
|
27
|
+
export { useSliderDevWarnings };
|
|
28
|
+
|
|
29
|
+
//# sourceMappingURL=use-slider-dev-warnings.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-slider-dev-warnings.mjs","names":[],"sources":["../../src/slider/use-slider-dev-warnings.ts"],"sourcesContent":["\"use client\";\nimport { useEffect, useRef } from \"react\";\nimport type { RefObject } from \"react\";\nimport { useDevWarning } from \"../internal/use-dev-warning.js\";\nimport { isMaxReachable, isOnGrid, shapeOf, toArray } from \"./slider-arithmetic.js\";\n\nconst isDev = process.env.NODE_ENV !== \"production\";\n\n/** The Root's props (as given) and derived values the warnings read. */\nexport interface SliderDevWarningsOptions {\n readonly stepProp: number;\n readonly stepValid: boolean;\n readonly min: number;\n readonly max: number;\n readonly step: number;\n readonly value: number | readonly number[] | undefined;\n readonly defaultValue: number | readonly number[] | undefined;\n readonly shape: \"number\" | \"array\";\n readonly unnamedGroup: boolean;\n readonly labelCountRef: RefObject<number>;\n}\n\n/** `Slider.Root`'s development warnings about its props (design 3.1, 5, 9.1). */\nexport function useSliderDevWarnings(options: SliderDevWarningsOptions): void {\n const { stepProp, stepValid, min, max, step, value, defaultValue, shape } = options;\n const { unnamedGroup, labelCountRef } = options;\n useDevWarning(\n !stepValid,\n isDev && `Slider.Root: \\`step\\` must be a positive number (got ${String(stepProp)}); using 1.`,\n );\n useDevWarning(\n stepValid && !isMaxReachable(min, max, step),\n isDev &&\n `Slider.Root: \\`max\\` (${max}) is not on the step grid from \\`min\\` (${min}) with \\`step\\` ` +\n `${step}: it is unreachable, as on a native range. The last reachable value is the last ` +\n `step below \\`max\\`.`,\n );\n const given = value ?? defaultValue;\n const givenValues = given === undefined ? [] : toArray(given);\n useDevWarning(\n givenValues.some((v) => !isOnGrid(v, min, max, step)),\n isDev &&\n `Slider.Root: the ${value !== undefined ? \"`value`\" : \"`defaultValue`\"} ` +\n `(${givenValues.join(\", \")}) is off the step grid or outside \\`min\\` / \\`max\\`. It is ` +\n `rendered as given and the browser sanitises it; the first user step snaps it.`,\n );\n useDevWarning(\n givenValues.some((v, i) => i > 0 && v < (givenValues[i - 1] as number)),\n isDev &&\n `Slider.Root: the values (${givenValues.join(\", \")}) must be in ascending order; the thumbs ` +\n `would be rendered crossed.`,\n );\n const currentShape = shapeOf(given);\n useDevWarning(\n currentShape !== undefined && currentShape !== shape,\n isDev &&\n `Slider.Root: the value changed shape between a number and an array after mount. The shape ` +\n `is fixed at mount; remount the Slider (a \\`key\\`) to change the number of thumbs.`,\n );\n const warnedGroupName = useRef(false);\n useEffect(() => {\n if (!isDev || warnedGroupName.current || !unnamedGroup || labelCountRef.current > 0) return;\n warnedGroupName.current = true;\n console.error(\n \"Slider.Root: a slider with several thumbs is a `group` and needs a name: render a \" +\n \"Slider.Label, or pass `aria-label` / `aria-labelledby` to the Root.\",\n );\n }, [unnamedGroup, labelCountRef]);\n}\n"],"mappings":";;;;;AAMA,MAAM,QAAQ,QAAQ,IAAI,aAAa;;AAiBvC,SAAgB,qBAAqB,SAAyC;CAC5E,MAAM,EAAE,UAAU,WAAW,KAAK,KAAK,MAAM,OAAO,cAAc,UAAU;CAC5E,MAAM,EAAE,cAAc,kBAAkB;CACxC,cACE,CAAC,WACD,SAAS,wDAAwD,OAAO,QAAQ,EAAE,YACpF;CACA,cACE,aAAa,CAAC,eAAe,KAAK,KAAK,IAAI,GAC3C,SACE,yBAAyB,IAAI,0CAA0C,IAAI,kBACtE,KAAK,oGAEd;CACA,MAAM,QAAQ,SAAS;CACvB,MAAM,cAAc,UAAU,KAAA,IAAY,CAAC,IAAI,QAAQ,KAAK;CAC5D,cACE,YAAY,MAAM,MAAM,CAAC,SAAS,GAAG,KAAK,KAAK,IAAI,CAAC,GACpD,SACE,oBAAoB,UAAU,KAAA,IAAY,YAAY,iBAAiB,IACjE,YAAY,KAAK,IAAI,EAAE,yIAEjC;CACA,cACE,YAAY,MAAM,GAAG,MAAM,IAAI,KAAK,IAAK,YAAY,IAAI,EAAa,GACtE,SACE,4BAA4B,YAAY,KAAK,IAAI,EAAE,oEAEvD;CACA,MAAM,eAAe,QAAQ,KAAK;CAClC,cACE,iBAAiB,KAAA,KAAa,iBAAiB,OAC/C,SACE,2KAEJ;CACA,MAAM,kBAAkB,OAAO,KAAK;CACpC,gBAAgB;EACd,IAAI,CAAC,SAAS,gBAAgB,WAAW,CAAC,gBAAgB,cAAc,UAAU,GAAG;EACrF,gBAAgB,UAAU;EAC1B,QAAQ,MACN,uJAEF;CACF,GAAG,CAAC,cAAc,aAAa,CAAC;AAClC"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useCallback, useMemo, useRef, useState } from "react";
|
|
3
|
+
//#region src/slider/use-thumb-registry.ts
|
|
4
|
+
const isDev = process.env.NODE_ENV !== "production";
|
|
5
|
+
/**
|
|
6
|
+
* `Slider.Root`'s Thumb registry (design 9.2): the inputs by index, read by the residual browser
|
|
7
|
+
* paths and the pointer gesture's focus. Development warns once about two Thumbs with one index
|
|
8
|
+
* and once about Thumbs in different forms.
|
|
9
|
+
*/
|
|
10
|
+
function useThumbRegistry() {
|
|
11
|
+
const [registry] = useState(() => /* @__PURE__ */ new Map());
|
|
12
|
+
const warnedDuplicate = useRef(false);
|
|
13
|
+
const warnedForm = useRef(false);
|
|
14
|
+
return {
|
|
15
|
+
registry,
|
|
16
|
+
registerThumb: useCallback((index, input) => {
|
|
17
|
+
const existing = registry.get(index);
|
|
18
|
+
if (isDev && existing !== void 0 && existing !== input && !warnedDuplicate.current) {
|
|
19
|
+
warnedDuplicate.current = true;
|
|
20
|
+
console.error(`Slider.Thumb: two Thumbs have \`index={${index}}\`. Each value needs exactly one Thumb; give every Thumb a distinct index.`);
|
|
21
|
+
}
|
|
22
|
+
if (isDev && !warnedForm.current) {
|
|
23
|
+
for (const other of registry.values()) if (other !== input && other.form !== input.form) {
|
|
24
|
+
warnedForm.current = true;
|
|
25
|
+
console.error("Slider.Thumb: the thumbs of one Slider belong to different forms (a Thumb's `form` prop). A form reset is followed through the first thumb's form only; keep every thumb in one form.");
|
|
26
|
+
break;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
registry.set(index, input);
|
|
30
|
+
return () => {
|
|
31
|
+
if (registry.get(index) === input) registry.delete(index);
|
|
32
|
+
};
|
|
33
|
+
}, [registry]),
|
|
34
|
+
formElement: useMemo(() => ({
|
|
35
|
+
get current() {
|
|
36
|
+
let first = null;
|
|
37
|
+
let firstIndex = Number.POSITIVE_INFINITY;
|
|
38
|
+
for (const [index, input] of registry) if (index < firstIndex) {
|
|
39
|
+
firstIndex = index;
|
|
40
|
+
first = input;
|
|
41
|
+
}
|
|
42
|
+
return first;
|
|
43
|
+
},
|
|
44
|
+
set current(_ignored) {}
|
|
45
|
+
}), [registry])
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
//#endregion
|
|
49
|
+
export { useThumbRegistry };
|
|
50
|
+
|
|
51
|
+
//# sourceMappingURL=use-thumb-registry.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-thumb-registry.mjs","names":[],"sources":["../../src/slider/use-thumb-registry.ts"],"sourcesContent":["\"use client\";\nimport { useCallback, useMemo, useRef, useState } from \"react\";\nimport type { RefObject } from \"react\";\nimport type { FormAssociatedElement } from \"../internal/use-form-owner-event.js\";\n\nconst isDev = process.env.NODE_ENV !== \"production\";\n\nexport interface ThumbRegistry {\n /** Thumb index → its input. Mutated in place; one identity for the Root's lifetime. */\n readonly registry: ReadonlyMap<number, HTMLInputElement>;\n /** Stable. Each Thumb registers its input from its ref; returns the unregistration. */\n readonly registerThumb: (index: number, input: HTMLInputElement) => () => void;\n /** The first registered input: the form-associated element the reset subscription follows. */\n readonly formElement: RefObject<FormAssociatedElement | null>;\n}\n\n/**\n * `Slider.Root`'s Thumb registry (design 9.2): the inputs by index, read by the residual browser\n * paths and the pointer gesture's focus. Development warns once about two Thumbs with one index\n * and once about Thumbs in different forms.\n */\nexport function useThumbRegistry(): ThumbRegistry {\n const [registry] = useState(() => new Map<number, HTMLInputElement>());\n const warnedDuplicate = useRef(false);\n const warnedForm = useRef(false);\n const registerThumb = useCallback(\n (index: number, input: HTMLInputElement) => {\n const existing = registry.get(index);\n if (isDev && existing !== undefined && existing !== input && !warnedDuplicate.current) {\n warnedDuplicate.current = true;\n console.error(\n `Slider.Thumb: two Thumbs have \\`index={${index}}\\`. Each value needs exactly one ` +\n `Thumb; give every Thumb a distinct index.`,\n );\n }\n if (isDev && !warnedForm.current) {\n for (const other of registry.values()) {\n if (other !== input && other.form !== input.form) {\n warnedForm.current = true;\n console.error(\n \"Slider.Thumb: the thumbs of one Slider belong to different forms (a Thumb's \" +\n \"`form` prop). A form reset is followed through the first thumb's form only; \" +\n \"keep every thumb in one form.\",\n );\n break;\n }\n }\n }\n registry.set(index, input);\n return () => {\n if (registry.get(index) === input) registry.delete(index);\n };\n },\n [registry],\n );\n\n const formElement = useMemo<RefObject<FormAssociatedElement | null>>(\n () => ({\n get current() {\n let first: HTMLInputElement | null = null;\n let firstIndex = Number.POSITIVE_INFINITY;\n for (const [index, input] of registry) {\n if (index < firstIndex) {\n firstIndex = index;\n first = input;\n }\n }\n return first;\n },\n set current(_ignored) {},\n }),\n [registry],\n );\n\n return { registry, registerThumb, formElement };\n}\n"],"mappings":";;;AAKA,MAAM,QAAQ,QAAQ,IAAI,aAAa;;;;;;AAgBvC,SAAgB,mBAAkC;CAChD,MAAM,CAAC,YAAY,+BAAe,IAAI,IAA8B,CAAC;CACrE,MAAM,kBAAkB,OAAO,KAAK;CACpC,MAAM,aAAa,OAAO,KAAK;CAkD/B,OAAO;EAAE;EAAU,eAjDG,aACnB,OAAe,UAA4B;GAC1C,MAAM,WAAW,SAAS,IAAI,KAAK;GACnC,IAAI,SAAS,aAAa,KAAA,KAAa,aAAa,SAAS,CAAC,gBAAgB,SAAS;IACrF,gBAAgB,UAAU;IAC1B,QAAQ,MACN,0CAA0C,MAAM,4EAElD;GACF;GACA,IAAI,SAAS,CAAC,WAAW,SAClB;SAAA,MAAM,SAAS,SAAS,OAAO,GAClC,IAAI,UAAU,SAAS,MAAM,SAAS,MAAM,MAAM;KAChD,WAAW,UAAU;KACrB,QAAQ,MACN,uLAGF;KACA;IACF;;GAGJ,SAAS,IAAI,OAAO,KAAK;GACzB,aAAa;IACX,IAAI,SAAS,IAAI,KAAK,MAAM,OAAO,SAAS,OAAO,KAAK;GAC1D;EACF,GACA,CAAC,QAAQ,CAqBoB;EAAG,aAlBd,eACX;GACL,IAAI,UAAU;IACZ,IAAI,QAAiC;IACrC,IAAI,aAAa,OAAO;IACxB,KAAK,MAAM,CAAC,OAAO,UAAU,UAC3B,IAAI,QAAQ,YAAY;KACtB,aAAa;KACb,QAAQ;IACV;IAEF,OAAO;GACT;GACA,IAAI,QAAQ,UAAU,CAAC;EACzB,IACA,CAAC,QAAQ,CAGiC;CAAE;AAChD"}
|
package/dist/switch/switch.d.mts
CHANGED
|
@@ -45,10 +45,9 @@ export interface SwitchProps extends Omit<ComponentPropsWithRef<"input">, "type"
|
|
|
45
45
|
* Forwarded as `default` to the Switch's `<ViewTransition>`. Default: no boundary. Animates the
|
|
46
46
|
* commit that ends an action, not the optimistic flip; animate the flip with CSS on `:checked`.
|
|
47
47
|
*
|
|
48
|
-
* Static:
|
|
49
|
-
*
|
|
50
|
-
*
|
|
51
|
-
* page cross-fades for about 250 ms and the next transition commit waits for it (issue #35).
|
|
48
|
+
* Static: setting or unsetting it remounts the element. Any value, `"none"` included, makes a
|
|
49
|
+
* mount or `<Activity>` reveal inside a transition start a document view transition (a ~250 ms
|
|
50
|
+
* page cross-fade that the next transition waits for).
|
|
52
51
|
*/
|
|
53
52
|
transition?: ViewTransitionClass;
|
|
54
53
|
className?: StateValue<string | undefined, SwitchState>;
|
|
@@ -72,7 +71,7 @@ export interface SwitchProps extends Omit<ComponentPropsWithRef<"input">, "type"
|
|
|
72
71
|
* `onChange` (or `onClick`) runs first, then the library's; an `onClick` that calls
|
|
73
72
|
* `preventDefault()` cancels the change (nothing is dispatched).
|
|
74
73
|
*/
|
|
75
|
-
export declare function Switch({ checked, defaultChecked, checkedChangeAction, disabled
|
|
74
|
+
export declare function Switch({ checked, defaultChecked, checkedChangeAction, disabled, transition, className, style, render, ...rest }: SwitchProps): import("react").ReactNode;
|
|
76
75
|
export declare namespace Switch {
|
|
77
76
|
var displayName: string;
|
|
78
77
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"switch.d.mts","names":[],"sources":["../../src/switch/switch.tsx"],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"switch.d.mts","names":[],"sources":["../../src/switch/switch.tsx"],"mappings":";;;iBAciB;;WAEN;;WAEA;;WAEA;;;iBAIM,mCAAmC;;;;;;;WAOzC,QAAQ;;iBAGF,oBAAoB,KACnC;;EAYA;;;;;EAKA;;;;;;;;;;EAUA,sBAAsB,sBAAsB;;EAE5C;;EAEA;;;;;;;;;EASA,aAAa;EACb,YAAY,+BAA+B;EAC3C,QAAQ,WAAW,2BAA2B;;;;;EAK9C,SAAS,WAAW,gCAAgC;;;;;;;;;;;;;;;wBAgBtC,SACd,SACA,gBACA,qBACA,UACA,YACA,WACA,OACA,WACG,QACF,8BAAW;yBAVE"}
|
package/dist/switch/switch.mjs
CHANGED
|
@@ -1,12 +1,8 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { createActionDetails } from "../internal/action-details.mjs";
|
|
3
|
-
import { dataAttr } from "../internal/data-attr.mjs";
|
|
4
2
|
import { useTransitionBoundary } from "../internal/transition-boundary.mjs";
|
|
5
3
|
import { useRender } from "../internal/use-render.mjs";
|
|
6
4
|
import { transitionTypes } from "../internal/transition-types.mjs";
|
|
7
|
-
import {
|
|
8
|
-
import { fieldInputProps, useFieldControl, useFieldValueChange, useMergedRef } from "../internal/use-field-control.mjs";
|
|
9
|
-
import { guardCheckableChange, useNativeChecked } from "../internal/use-native-checked.mjs";
|
|
5
|
+
import { useCheckableInput } from "../internal/use-checkable-input.mjs";
|
|
10
6
|
//#region src/switch/switch.tsx
|
|
11
7
|
/**
|
|
12
8
|
* An on/off switch (WAI-ARIA "Switch" pattern, HTML checkbox input variant). Renders
|
|
@@ -21,42 +17,22 @@ import { guardCheckableChange, useNativeChecked } from "../internal/use-native-c
|
|
|
21
17
|
* `onChange` (or `onClick`) runs first, then the library's; an `onClick` that calls
|
|
22
18
|
* `preventDefault()` cancels the change (nothing is dispatched).
|
|
23
19
|
*/
|
|
24
|
-
function Switch({ checked, defaultChecked, checkedChangeAction, disabled
|
|
25
|
-
const
|
|
26
|
-
labelable: true,
|
|
27
|
-
name: rest.name,
|
|
28
|
-
disabled: disabledProp,
|
|
29
|
-
required: rest.required,
|
|
30
|
-
id: rest.id,
|
|
31
|
-
component: "Switch"
|
|
32
|
-
});
|
|
33
|
-
const disabled = field.disabled;
|
|
34
|
-
const { optimistic, pending, dispatch, latestInFlight } = useControllableAction({
|
|
35
|
-
controlled: checked,
|
|
36
|
-
defaultValue: defaultChecked,
|
|
37
|
-
initialValue: false,
|
|
38
|
-
action: checkedChangeAction,
|
|
39
|
-
transitionTypes: (next) => transitionTypes("switch", next ? "on" : "off"),
|
|
40
|
-
warn: {
|
|
41
|
-
component: "Switch",
|
|
42
|
-
prop: "checked"
|
|
43
|
-
}
|
|
44
|
-
});
|
|
45
|
-
useFieldValueChange(optimistic);
|
|
46
|
-
const inputRef = useNativeChecked({
|
|
47
|
-
type: "checkbox",
|
|
20
|
+
function Switch({ checked, defaultChecked, checkedChangeAction, disabled, transition, className, style, render, ...rest }) {
|
|
21
|
+
const input = useCheckableInput({
|
|
48
22
|
component: "Switch",
|
|
49
|
-
checked
|
|
50
|
-
defaultChecked
|
|
51
|
-
|
|
52
|
-
|
|
23
|
+
checked,
|
|
24
|
+
defaultChecked,
|
|
25
|
+
checkedChangeAction,
|
|
26
|
+
disabled,
|
|
27
|
+
own: rest,
|
|
28
|
+
transitionTypes: (next) => transitionTypes("switch", next ? "on" : "off"),
|
|
29
|
+
role: "switch"
|
|
53
30
|
});
|
|
54
31
|
const state = {
|
|
55
|
-
checked: optimistic,
|
|
56
|
-
pending,
|
|
57
|
-
disabled
|
|
32
|
+
checked: input.optimistic,
|
|
33
|
+
pending: input.pending,
|
|
34
|
+
disabled: input.disabled
|
|
58
35
|
};
|
|
59
|
-
const ref = useMergedRef(inputRef, field.ref);
|
|
60
36
|
const element = useRender({
|
|
61
37
|
defaultElement: "input",
|
|
62
38
|
render,
|
|
@@ -64,25 +40,9 @@ function Switch({ checked, defaultChecked, checkedChangeAction, disabled: disabl
|
|
|
64
40
|
className,
|
|
65
41
|
style,
|
|
66
42
|
children: void 0,
|
|
67
|
-
ref,
|
|
43
|
+
ref: input.ref,
|
|
68
44
|
props: rest,
|
|
69
|
-
libraryProps:
|
|
70
|
-
...fieldInputProps(field),
|
|
71
|
-
type: "checkbox",
|
|
72
|
-
role: "switch",
|
|
73
|
-
checked: optimistic,
|
|
74
|
-
defaultChecked: void 0,
|
|
75
|
-
"aria-checked": void 0,
|
|
76
|
-
disabled,
|
|
77
|
-
"data-checked": dataAttr(optimistic),
|
|
78
|
-
"data-pending": dataAttr(pending),
|
|
79
|
-
"data-disabled": dataAttr(disabled),
|
|
80
|
-
onChange: (event) => {
|
|
81
|
-
if (disabled) return;
|
|
82
|
-
const nativeEvent = event.nativeEvent;
|
|
83
|
-
guardCheckableChange(nativeEvent, () => dispatch(!optimistic, createActionDetails(nativeEvent, { reason: "activate" })), "Switch");
|
|
84
|
-
}
|
|
85
|
-
}
|
|
45
|
+
libraryProps: input.libraryProps
|
|
86
46
|
});
|
|
87
47
|
return useTransitionBoundary("Switch", transition, element);
|
|
88
48
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"switch.mjs","names":[],"sources":["../../src/switch/switch.tsx"],"sourcesContent":["\"use client\";\nimport type {
|
|
1
|
+
{"version":3,"file":"switch.mjs","names":[],"sources":["../../src/switch/switch.tsx"],"sourcesContent":["\"use client\";\nimport type { ComponentPropsWithRef, CSSProperties, ViewTransitionClass } from \"react\";\nimport { useTransitionBoundary } from \"../internal/transition-boundary.js\";\nimport { transitionTypes } from \"../internal/transition-types.js\";\nimport type {\n ActionDetails,\n ChangeAction,\n ChangeReason,\n RenderProp,\n StateValue,\n} from \"../internal/types.js\";\nimport { useCheckableInput } from \"../internal/use-checkable-input.js\";\nimport { useRender } from \"../internal/use-render.js\";\n\nexport interface SwitchState {\n /** Optimistic checked state: what the user sees, including an in-flight change. */\n readonly checked: boolean;\n /** An action dispatched by this Switch is in flight (including the resulting render). */\n readonly pending: boolean;\n /** The `disabled` prop (or the enclosing `Field.Root`'s). */\n readonly disabled: boolean;\n}\n\n/** Details passed as the second argument of `checkedChangeAction`. */\nexport interface SwitchCheckedChangeDetails extends ActionDetails {\n /**\n * `\"activate\"`: the user toggled the switch (click, Space, label click); `event` is the native\n * `click` event. `\"platform\"`: the browser changed the value itself: a form reset (`event` is\n * the `reset` event) or a click before hydration / Firefox form-state restoration found on\n * mount (`event` is `undefined`).\n */\n readonly reason: ChangeReason;\n}\n\nexport interface SwitchProps extends Omit<\n ComponentPropsWithRef<\"input\">,\n | \"type\"\n | \"role\"\n | \"checked\"\n | \"defaultChecked\"\n | \"onChange\"\n | \"aria-checked\"\n | \"className\"\n | \"style\"\n | \"children\"\n> {\n /** Controlled checked state. `undefined` means uncontrolled. */\n checked?: boolean;\n /**\n * Initial checked state in uncontrolled mode (default `false`). Also the value a form reset\n * returns to: the latest prop value is mirrored into the input's `defaultChecked`.\n */\n defaultChecked?: boolean;\n /**\n * Called with the next checked state on every change. Runs inside the Switch's transition; may\n * be sync or async (also a Server Function). Rejections reach the nearest Error Boundary.\n * Also called with `details.reason === \"platform\"` for a form reset or a pre-hydration click.\n *\n * A `setState` placed after your own `await` is not a Transition update; wrap it in\n * `startTransition` (React limitation). `details.event.preventDefault()` is not a veto and is\n * unsupported here; use controlled mode to veto a change.\n */\n checkedChangeAction?: ChangeAction<boolean, SwitchCheckedChangeDetails>;\n /** Renders a natively disabled input; never dispatches. Default `false`. */\n disabled?: boolean;\n /** Submitted as the input's value when checked. Default `\"on\"` (platform). */\n value?: string;\n /**\n * Forwarded as `default` to the Switch's `<ViewTransition>`. Default: no boundary. Animates the\n * commit that ends an action, not the optimistic flip; animate the flip with CSS on `:checked`.\n *\n * Static: setting or unsetting it remounts the element. Any value, `\"none\"` included, makes a\n * mount or `<Activity>` reveal inside a transition start a document view transition (a ~250 ms\n * page cross-fade that the next transition waits for).\n */\n transition?: ViewTransitionClass;\n className?: StateValue<string | undefined, SwitchState>;\n style?: StateValue<CSSProperties | undefined, SwitchState>;\n /**\n * Replace the rendered element (element form) or take over rendering (function form). Must keep\n * an `<input type=\"checkbox\">`.\n */\n render?: RenderProp<ComponentPropsWithRef<\"input\">, SwitchState>;\n}\n\n/**\n * An on/off switch (WAI-ARIA \"Switch\" pattern, HTML checkbox input variant). Renders\n * `<input type=\"checkbox\" role=\"switch\">` whose DOM `checked` is the optimistic state; the input\n * carries `data-pending` while `checkedChangeAction` is in flight and takes part in forms natively.\n *\n * Owned keys (a `render` element's value is overridden): `type`, `role`, `checked`,\n * `defaultChecked`, `aria-checked` (always removed), `disabled`, `data-checked`, `data-pending`,\n * `data-disabled`; inside a `Field.Root` also `id`, `name`, `required`, `aria-invalid`,\n * `aria-describedby` (token-merged) and `data-invalid`, and `disabled` / `name` / `required`\n * default from the Field. Event handlers are merged rather than owned: a `render` element's own\n * `onChange` (or `onClick`) runs first, then the library's; an `onClick` that calls\n * `preventDefault()` cancels the change (nothing is dispatched).\n */\nexport function Switch({\n checked,\n defaultChecked,\n checkedChangeAction,\n disabled,\n transition,\n className,\n style,\n render,\n ...rest\n}: SwitchProps) {\n const input = useCheckableInput({\n component: \"Switch\",\n checked,\n defaultChecked,\n checkedChangeAction,\n disabled,\n own: rest,\n transitionTypes: (next) => transitionTypes(\"switch\", next ? \"on\" : \"off\"),\n role: \"switch\",\n });\n\n const state: SwitchState = {\n checked: input.optimistic,\n pending: input.pending,\n disabled: input.disabled,\n };\n\n const element = useRender<ComponentPropsWithRef<\"input\">, SwitchState>({\n defaultElement: \"input\",\n render,\n state,\n className,\n style,\n children: undefined,\n ref: input.ref,\n // Pass-through layer: a `render` element's own props win over these.\n props: rest,\n libraryProps: input.libraryProps,\n });\n\n return useTransitionBoundary(\"Switch\", transition, element);\n}\n\nSwitch.displayName = \"Switch\";\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAkGA,SAAgB,OAAO,EACrB,SACA,gBACA,qBACA,UACA,YACA,WACA,OACA,QACA,GAAG,QACW;CACd,MAAM,QAAQ,kBAAkB;EAC9B,WAAW;EACX;EACA;EACA;EACA;EACA,KAAK;EACL,kBAAkB,SAAS,gBAAgB,UAAU,OAAO,OAAO,KAAK;EACxE,MAAM;CACR,CAAC;CAED,MAAM,QAAqB;EACzB,SAAS,MAAM;EACf,SAAS,MAAM;EACf,UAAU,MAAM;CAClB;CAEA,MAAM,UAAU,UAAuD;EACrE,gBAAgB;EAChB;EACA;EACA;EACA;EACA,UAAU,KAAA;EACV,KAAK,MAAM;EAEX,OAAO;EACP,cAAc,MAAM;CACtB,CAAC;CAED,OAAO,sBAAsB,UAAU,YAAY,OAAO;AAC5D;AAEA,OAAO,cAAc"}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
+
import { Orientation } from "../internal/types.mjs";
|
|
1
2
|
//#region src/tabs/tabs-context.d.ts
|
|
2
|
-
export type TabsOrientation =
|
|
3
|
+
export type TabsOrientation = Orientation;
|
|
3
4
|
export type TabsActivationMode = "automatic" | "manual";
|
|
4
|
-
/** Why a Tabs change was dispatched (design section 3.1). */
|
|
5
|
-
export type TabsChangeReason = "activate" | "platform";
|
|
6
5
|
//#endregion
|
|
7
6
|
//# sourceMappingURL=tabs-context.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tabs-context.d.mts","names":[],"sources":["../../src/tabs/tabs-context.ts"],"mappings":";
|
|
1
|
+
{"version":3,"file":"tabs-context.d.mts","names":[],"sources":["../../src/tabs/tabs-context.ts"],"mappings":";;YAIY,kBAAkB;YAClB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tabs-context.mjs","names":[],"sources":["../../src/tabs/tabs-context.ts"],"sourcesContent":["\"use client\";\nimport { createContext, use } from \"react\";\
|
|
1
|
+
{"version":3,"file":"tabs-context.mjs","names":[],"sources":["../../src/tabs/tabs-context.ts"],"sourcesContent":["\"use client\";\nimport { createContext, use } from \"react\";\nimport type { ChangeReason, Orientation } from \"../internal/types.js\";\n\nexport type TabsOrientation = Orientation;\nexport type TabsActivationMode = \"automatic\" | \"manual\";\n\nexport interface TabsContextValue {\n readonly rootId: string;\n /** Committed value: Panels render this. */\n readonly committed: string | null;\n /** Optimistic value: Tabs and the Indicator render this. */\n readonly optimistic: string | null;\n readonly pending: boolean;\n readonly orientation: TabsOrientation;\n readonly activationMode: TabsActivationMode;\n readonly loop: boolean;\n readonly disabled: boolean;\n /** Dispatches a change. No-op if `value` is the optimistic value. Never checks `disabled`. */\n readonly select: (value: string, event: Event | undefined, reason: ChangeReason) => void;\n}\n\nexport const TabsContext = createContext<TabsContextValue | null>(null);\n\n/** What a Tabs.List tells its Tabs about `experimental_focusgroup`. */\nexport interface TabsListContextValue {\n /** `experimental_focusgroup` is on: the selected Tab carries `focusgroupstart`. */\n readonly focusgroup: boolean;\n /**\n * The flag is on and the engine implements `focusgroup` (`useNativeFocusgroup`: false during\n * SSR and hydration). Unselected Tabs then drop `tabindex=\"-1\"`: Chromium leaves an element with\n * a negative tabindex out of the focusgroup, so roving tabindex would disable the native arrows.\n */\n readonly nativeFocusgroup: boolean;\n}\n\nexport const TabsListContext = createContext<TabsListContextValue | null>(null);\n\nexport function useTabsContext(part: string): TabsContextValue {\n const context = use(TabsContext);\n if (context === null) {\n throw new Error(`${part} must be rendered inside a Tabs.Root.`);\n }\n return context;\n}\n"],"mappings":";;;AAsBA,MAAa,cAAc,cAAuC,IAAI;AActE,MAAa,kBAAkB,cAA2C,IAAI;AAE9E,SAAgB,eAAe,MAAgC;CAC7D,MAAM,UAAU,IAAI,WAAW;CAC/B,IAAI,YAAY,MACd,MAAM,IAAI,MAAM,GAAG,KAAK,sCAAsC;CAEhE,OAAO;AACT"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tabs-list.d.mts","names":[],"sources":["../../src/tabs/tabs-list.tsx"],"mappings":";;;;
|
|
1
|
+
{"version":3,"file":"tabs-list.d.mts","names":[],"sources":["../../src/tabs/tabs-list.tsx"],"mappings":";;;;iBAoBiB;WACN,aAAa;WACb;;iBAGM,sBAAsB,KACrC;;;;;;EAQA;EACA,YAAY,+BAA+B;EAC3C,QAAQ,WAAW,2BAA2B;EAC9C,WAAW,WAAW,WAAW;EACjC,SAAS,WAAW,8BAA8B;;;;;;;;;;wBAkBpC,WACd,yBACA,WACA,OACA,UACA,WACG,QACF,gCAAa,IAAA;yBAPA"}
|
package/dist/tabs/tabs-list.mjs
CHANGED
|
@@ -2,30 +2,17 @@
|
|
|
2
2
|
import { dataAttr } from "../internal/data-attr.mjs";
|
|
3
3
|
import { useDevWarning } from "../internal/use-dev-warning.mjs";
|
|
4
4
|
import { useRender } from "../internal/use-render.mjs";
|
|
5
|
+
import { useNativeFocusgroup } from "../internal/use-native-focusgroup.mjs";
|
|
6
|
+
import { focusWithRing, resolveArrowKey } from "../internal/arrow-keys.mjs";
|
|
5
7
|
import { TabsListContext, useTabsContext } from "./tabs-context.mjs";
|
|
6
|
-
import { useLayoutEffect, useMemo, useRef, useState
|
|
8
|
+
import { useLayoutEffect, useMemo, useRef, useState } from "react";
|
|
7
9
|
import { jsx } from "react/jsx-runtime";
|
|
8
10
|
//#region src/tabs/tabs-list.tsx
|
|
9
|
-
|
|
10
|
-
switch (key) {
|
|
11
|
-
case "Home": return "first";
|
|
12
|
-
case "End": return "last";
|
|
13
|
-
case "ArrowRight": return orientation === "horizontal" ? rtl ? "prev" : "next" : null;
|
|
14
|
-
case "ArrowLeft": return orientation === "horizontal" ? rtl ? "next" : "prev" : null;
|
|
15
|
-
case "ArrowDown": return orientation === "vertical" ? "next" : null;
|
|
16
|
-
case "ArrowUp": return orientation === "vertical" ? "prev" : null;
|
|
17
|
-
default: return null;
|
|
18
|
-
}
|
|
19
|
-
}
|
|
11
|
+
const isDev = process.env.NODE_ENV !== "production";
|
|
20
12
|
/** The tabs that belong to `list` (not to a nested tablist), in DOM order. Disabled included. */
|
|
21
13
|
function tabsOf(list) {
|
|
22
14
|
return Array.from(list.querySelectorAll("[role=\"tab\"]")).filter((tab) => tab.closest("[role=\"tablist\"]") === list);
|
|
23
15
|
}
|
|
24
|
-
function focusTab(tab) {
|
|
25
|
-
tab.focus({ focusVisible: true });
|
|
26
|
-
}
|
|
27
|
-
/** Engine capabilities never change while the page lives. */
|
|
28
|
-
const subscribeNever = () => () => {};
|
|
29
16
|
/**
|
|
30
17
|
* The `role="tablist"` container. Owns arrow-key / Home / End navigation between Tabs: it only
|
|
31
18
|
* moves focus; automatic activation happens in the Tab's focus handler.
|
|
@@ -36,7 +23,7 @@ const subscribeNever = () => () => {};
|
|
|
36
23
|
*/
|
|
37
24
|
function TabsList({ experimental_focusgroup = false, className, style, children, render, ...rest }) {
|
|
38
25
|
const { orientation, loop, disabled, optimistic } = useTabsContext("Tabs.List");
|
|
39
|
-
const nativeFocusgroup =
|
|
26
|
+
const nativeFocusgroup = useNativeFocusgroup(experimental_focusgroup);
|
|
40
27
|
const listContext = useMemo(() => ({
|
|
41
28
|
focusgroup: experimental_focusgroup,
|
|
42
29
|
nativeFocusgroup
|
|
@@ -52,7 +39,7 @@ function TabsList({ experimental_focusgroup = false, className, style, children,
|
|
|
52
39
|
children,
|
|
53
40
|
unmatched
|
|
54
41
|
]);
|
|
55
|
-
useDevWarning(unmatched, `Tabs: the value ${JSON.stringify(optimistic)} matches no Tabs.Tab. No tab is selected; the tablist itself is the tab stop. Pass null to select nothing on purpose.`);
|
|
42
|
+
useDevWarning(unmatched, isDev && `Tabs: the value ${JSON.stringify(optimistic)} matches no Tabs.Tab. No tab is selected; the tablist itself is the tab stop. Pass null to select nothing on purpose.`);
|
|
56
43
|
const listIsTabStop = optimistic === null || unmatched;
|
|
57
44
|
const state = {
|
|
58
45
|
orientation,
|
|
@@ -64,7 +51,7 @@ function TabsList({ experimental_focusgroup = false, className, style, children,
|
|
|
64
51
|
const target = event.target;
|
|
65
52
|
if (target.getAttribute("role") !== "tab" || target.closest("[role=\"tablist\"]") !== list) return;
|
|
66
53
|
const rtl = orientation === "horizontal" && getComputedStyle(list).direction === "rtl";
|
|
67
|
-
const move =
|
|
54
|
+
const move = resolveArrowKey(event.key, orientation, rtl);
|
|
68
55
|
if (move === null) return;
|
|
69
56
|
if (nativeFocusgroup) return;
|
|
70
57
|
event.preventDefault();
|
|
@@ -86,7 +73,7 @@ function TabsList({ experimental_focusgroup = false, className, style, children,
|
|
|
86
73
|
case "prev": nextIndex = index <= 0 ? loop ? last : 0 : index - 1;
|
|
87
74
|
}
|
|
88
75
|
const next = tabs[nextIndex];
|
|
89
|
-
if (next !== void 0 && next !== target)
|
|
76
|
+
if (next !== void 0 && next !== target) focusWithRing(next);
|
|
90
77
|
};
|
|
91
78
|
const onFocus = (event) => {
|
|
92
79
|
const list = event.currentTarget;
|
|
@@ -95,7 +82,7 @@ function TabsList({ experimental_focusgroup = false, className, style, children,
|
|
|
95
82
|
if (from instanceof Node && list.contains(from)) return;
|
|
96
83
|
const tabs = tabsOf(list);
|
|
97
84
|
const first = tabs.find((tab) => tab.getAttribute("aria-disabled") !== "true") ?? tabs[0];
|
|
98
|
-
if (first !== void 0)
|
|
85
|
+
if (first !== void 0) focusWithRing(first);
|
|
99
86
|
};
|
|
100
87
|
const focusgroup = experimental_focusgroup ? `tablist ${orientation === "vertical" ? "block" : "inline"} ${loop ? "wrap" : "nowrap"} nomemory` : void 0;
|
|
101
88
|
const element = useRender({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tabs-list.mjs","names":[],"sources":["../../src/tabs/tabs-list.tsx"],"sourcesContent":["\"use client\";\nimport { useLayoutEffect, useMemo, useRef, useState, useSyncExternalStore } from \"react\";\nimport type {\n ComponentPropsWithRef,\n CSSProperties,\n FocusEvent,\n KeyboardEvent,\n ReactNode,\n} from \"react\";\nimport { dataAttr } from \"../internal/data-attr.js\";\nimport type { RenderProp, StateValue } from \"../internal/types.js\";\nimport { useDevWarning } from \"../internal/use-dev-warning.js\";\nimport { useRender } from \"../internal/use-render.js\";\nimport { TabsListContext, useTabsContext } from \"./tabs-context.js\";\nimport type { TabsListContextValue, TabsOrientation } from \"./tabs-context.js\";\n\nexport interface TabsListState {\n readonly orientation: TabsOrientation;\n readonly disabled: boolean;\n}\n\nexport interface TabsListProps extends Omit<\n ComponentPropsWithRef<\"div\">,\n \"onKeyDown\" | \"onFocus\" | \"className\" | \"style\" | \"children\"\n> {\n /**\n * Render `focusgroup=\"tablist …\"` and, where the browser implements it, let the browser handle\n * arrow keys, Home and End. Chromium 150+ only; elsewhere the JS path stays active.\n * Default `false`.\n */\n experimental_focusgroup?: boolean;\n className?: StateValue<string | undefined, TabsListState>;\n style?: StateValue<CSSProperties | undefined, TabsListState>;\n children?: StateValue<ReactNode, TabsListState>;\n render?: RenderProp<ComponentPropsWithRef<\"div\">, TabsListState>;\n}\n\ntype Move = \"next\" | \"prev\" | \"first\" | \"last\";\n\nfunction resolveKey(key: string, orientation: TabsOrientation, rtl: boolean): Move | null {\n switch (key) {\n case \"Home\":\n return \"first\";\n case \"End\":\n return \"last\";\n case \"ArrowRight\":\n return orientation === \"horizontal\" ? (rtl ? \"prev\" : \"next\") : null;\n case \"ArrowLeft\":\n return orientation === \"horizontal\" ? (rtl ? \"next\" : \"prev\") : null;\n case \"ArrowDown\":\n return orientation === \"vertical\" ? \"next\" : null;\n case \"ArrowUp\":\n return orientation === \"vertical\" ? \"prev\" : null;\n default:\n return null;\n }\n}\n\n/** The tabs that belong to `list` (not to a nested tablist), in DOM order. Disabled included. */\nfunction tabsOf(list: Element): HTMLElement[] {\n return Array.from(list.querySelectorAll<HTMLElement>('[role=\"tab\"]')).filter(\n (tab) => tab.closest('[role=\"tablist\"]') === list,\n );\n}\n\nfunction focusTab(tab: HTMLElement): void {\n // `focusVisible` shows the ring even where the engine's heuristic would not (survey: adopt).\n tab.focus({ focusVisible: true } as FocusOptions);\n}\n\n/** Engine capabilities never change while the page lives. */\nconst subscribeNever = () => () => {};\n\n/**\n * The `role=\"tablist\"` container. Owns arrow-key / Home / End navigation between Tabs: it only\n * moves focus; automatic activation happens in the Tab's focus handler.\n *\n * Owned keys (a `render` element cannot override them, conventions 1.2): `role`,\n * `aria-orientation`, `data-orientation`, `data-disabled`, `tabIndex`, `onKeyDown`, `onFocus`,\n * and `focusgroup` when `experimental_focusgroup` is on.\n */\nexport function TabsList({\n experimental_focusgroup = false,\n className,\n style,\n children,\n render,\n ...rest\n}: TabsListProps) {\n const ctx = useTabsContext(\"Tabs.List\");\n const { orientation, loop, disabled, optimistic } = ctx;\n\n // Feature detection only when the flag is on, and never during SSR or hydration (conventions\n // 8): the server snapshot is `false`, so hydration markup matches the server and React re-renders\n // with the client answer afterwards. The IDL attribute is camel-cased `focusGroup`\n // (`\"focusgroup\" in HTMLElement.prototype` is always false, issue #43). The Tabs read it too:\n // they drop `tabindex=\"-1\"` on the native path (TabsListContextValue).\n const nativeFocusgroup = useSyncExternalStore(\n subscribeNever,\n () => experimental_focusgroup && \"focusGroup\" in HTMLElement.prototype,\n () => false,\n );\n const listContext = useMemo<TabsListContextValue>(\n () => ({ focusgroup: experimental_focusgroup, nativeFocusgroup }),\n [experimental_focusgroup, nativeFocusgroup],\n );\n\n // A value that matches no Tab (a controlled `value` for a route without a tab, design 11.5)\n // leaves no tab with tabindex=0, so the List takes over as the tab stop exactly as for `null`.\n // Read from the DOM (Tabs register nowhere) whenever the value or the List's children change; a\n // Tab added or removed by a component below that re-renders on its own is picked up on the\n // List's next render. The state only changes when the answer does.\n const listRef = useRef<HTMLElement | null>(null);\n const [unmatched, setUnmatched] = useState(false);\n useLayoutEffect(() => {\n const list = listRef.current;\n const next =\n optimistic !== null &&\n list !== null &&\n !tabsOf(list).some((tab) => tab.getAttribute(\"tabindex\") === \"0\");\n if (next !== unmatched) setUnmatched(next);\n }, [optimistic, children, unmatched]);\n useDevWarning(\n unmatched,\n `Tabs: the value ${JSON.stringify(optimistic)} matches no Tabs.Tab. No tab is selected; the ` +\n \"tablist itself is the tab stop. Pass null to select nothing on purpose.\",\n );\n const listIsTabStop = optimistic === null || unmatched;\n\n const state: TabsListState = { orientation, disabled };\n\n const onKeyDown = (event: KeyboardEvent<HTMLElement>) => {\n if (event.defaultPrevented || event.altKey || event.ctrlKey || event.metaKey) return;\n const list = event.currentTarget;\n const target = event.target as Element;\n if (target.getAttribute(\"role\") !== \"tab\" || target.closest('[role=\"tablist\"]') !== list) {\n return;\n }\n const rtl = orientation === \"horizontal\" && getComputedStyle(list).direction === \"rtl\";\n const move = resolveKey(event.key, orientation, rtl);\n if (move === null) return;\n // The browser moves focus itself where `focusgroup` is implemented.\n if (nativeFocusgroup) return;\n\n event.preventDefault();\n const tabs = tabsOf(list);\n if (tabs.length === 0) return;\n const index = tabs.indexOf(target as HTMLElement);\n const last = tabs.length - 1;\n let nextIndex: number;\n switch (move) {\n case \"first\":\n nextIndex = 0;\n break;\n case \"last\":\n nextIndex = last;\n break;\n case \"next\":\n nextIndex = index >= last ? (loop ? 0 : last) : index + 1;\n break;\n case \"prev\":\n nextIndex = index <= 0 ? (loop ? last : 0) : index - 1;\n break;\n }\n const next = tabs[nextIndex];\n if (next !== undefined && next !== target) focusTab(next);\n };\n\n // With no selected tab (value null or matching no Tab) no Tab has tabindex=0, so the list\n // itself is the tab stop and hands focus to the first enabled tab (design section 8). Only when\n // focus arrives from outside the list: Shift+Tab from a tab inside would otherwise bounce\n // straight back. The redirect never selects: the Tab only dispatches on focus that moves\n // between tabs.\n const onFocus = (event: FocusEvent<HTMLElement>) => {\n const list = event.currentTarget;\n if (event.target !== list || !listIsTabStop) return;\n const from = event.relatedTarget;\n if (from instanceof Node && list.contains(from)) return;\n const tabs = tabsOf(list);\n const first = tabs.find((tab) => tab.getAttribute(\"aria-disabled\") !== \"true\") ?? tabs[0];\n if (first !== undefined) focusTab(first);\n };\n\n const focusgroup = experimental_focusgroup\n ? // `nomemory` + `focusgroupstart` on the selected Tab: Tab always enters on the selected tab\n // (APG), not on the last focused one, which differs in manual activation.\n `tablist ${orientation === \"vertical\" ? \"block\" : \"inline\"} ${loop ? \"wrap\" : \"nowrap\"} nomemory`\n : undefined;\n\n const element = useRender<ComponentPropsWithRef<\"div\">, TabsListState>({\n defaultElement: \"div\",\n render,\n state,\n className,\n style,\n children,\n props: rest,\n libraryProps: {\n role: \"tablist\",\n \"aria-orientation\": orientation,\n \"data-orientation\": orientation,\n \"data-disabled\": dataAttr(disabled),\n tabIndex: listIsTabStop ? 0 : undefined,\n // Owned only while the flag is on; otherwise the key is omitted, not `undefined`, so it is not\n // owned (conventions 1.2).\n ...(focusgroup !== undefined && { focusgroup }),\n onKeyDown,\n onFocus,\n },\n ref: listRef,\n });\n\n return <TabsListContext value={listContext}>{element}</TabsListContext>;\n}\n\nTabsList.displayName = \"TabsList\";\n"],"mappings":"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"}
|
|
1
|
+
{"version":3,"file":"tabs-list.mjs","names":[],"sources":["../../src/tabs/tabs-list.tsx"],"sourcesContent":["\"use client\";\nimport { useLayoutEffect, useMemo, useRef, useState } from \"react\";\nimport type {\n ComponentPropsWithRef,\n CSSProperties,\n FocusEvent,\n KeyboardEvent,\n ReactNode,\n} from \"react\";\nimport { focusWithRing, resolveArrowKey } from \"../internal/arrow-keys.js\";\nimport { dataAttr } from \"../internal/data-attr.js\";\nimport type { RenderProp, StateValue } from \"../internal/types.js\";\nimport { useDevWarning } from \"../internal/use-dev-warning.js\";\nimport { useNativeFocusgroup } from \"../internal/use-native-focusgroup.js\";\nimport { useRender } from \"../internal/use-render.js\";\nimport { TabsListContext, useTabsContext } from \"./tabs-context.js\";\nimport type { TabsListContextValue, TabsOrientation } from \"./tabs-context.js\";\n\nconst isDev = process.env.NODE_ENV !== \"production\";\n\nexport interface TabsListState {\n readonly orientation: TabsOrientation;\n readonly disabled: boolean;\n}\n\nexport interface TabsListProps extends Omit<\n ComponentPropsWithRef<\"div\">,\n \"onKeyDown\" | \"onFocus\" | \"className\" | \"style\" | \"children\"\n> {\n /**\n * Render `focusgroup=\"tablist …\"` and, where the browser implements it, let the browser handle\n * arrow keys, Home and End. Chromium 150+ only; elsewhere the JS path stays active.\n * Default `false`.\n */\n experimental_focusgroup?: boolean;\n className?: StateValue<string | undefined, TabsListState>;\n style?: StateValue<CSSProperties | undefined, TabsListState>;\n children?: StateValue<ReactNode, TabsListState>;\n render?: RenderProp<ComponentPropsWithRef<\"div\">, TabsListState>;\n}\n\n/** The tabs that belong to `list` (not to a nested tablist), in DOM order. Disabled included. */\nfunction tabsOf(list: Element): HTMLElement[] {\n return Array.from(list.querySelectorAll<HTMLElement>('[role=\"tab\"]')).filter(\n (tab) => tab.closest('[role=\"tablist\"]') === list,\n );\n}\n\n/**\n * The `role=\"tablist\"` container. Owns arrow-key / Home / End navigation between Tabs: it only\n * moves focus; automatic activation happens in the Tab's focus handler.\n *\n * Owned keys (a `render` element cannot override them, conventions 1.2): `role`,\n * `aria-orientation`, `data-orientation`, `data-disabled`, `tabIndex`, `onKeyDown`, `onFocus`,\n * and `focusgroup` when `experimental_focusgroup` is on.\n */\nexport function TabsList({\n experimental_focusgroup = false,\n className,\n style,\n children,\n render,\n ...rest\n}: TabsListProps) {\n const ctx = useTabsContext(\"Tabs.List\");\n const { orientation, loop, disabled, optimistic } = ctx;\n\n // The Tabs read it too: they drop `tabindex=\"-1\"` on the native path (TabsListContextValue).\n const nativeFocusgroup = useNativeFocusgroup(experimental_focusgroup);\n const listContext = useMemo<TabsListContextValue>(\n () => ({ focusgroup: experimental_focusgroup, nativeFocusgroup }),\n [experimental_focusgroup, nativeFocusgroup],\n );\n\n // A value that matches no Tab (a controlled `value` for a route without a tab, design 11.5)\n // leaves no tab with tabindex=0, so the List takes over as the tab stop exactly as for `null`.\n // Read from the DOM (Tabs register nowhere) whenever the value or the List's children change; a\n // Tab added or removed by a component below that re-renders on its own is picked up on the\n // List's next render. The state only changes when the answer does.\n const listRef = useRef<HTMLElement | null>(null);\n const [unmatched, setUnmatched] = useState(false);\n useLayoutEffect(() => {\n const list = listRef.current;\n const next =\n optimistic !== null &&\n list !== null &&\n !tabsOf(list).some((tab) => tab.getAttribute(\"tabindex\") === \"0\");\n if (next !== unmatched) setUnmatched(next);\n }, [optimistic, children, unmatched]);\n useDevWarning(\n unmatched,\n isDev &&\n `Tabs: the value ${JSON.stringify(optimistic)} matches no Tabs.Tab. No tab is selected; the ` +\n \"tablist itself is the tab stop. Pass null to select nothing on purpose.\",\n );\n const listIsTabStop = optimistic === null || unmatched;\n\n const state: TabsListState = { orientation, disabled };\n\n const onKeyDown = (event: KeyboardEvent<HTMLElement>) => {\n if (event.defaultPrevented || event.altKey || event.ctrlKey || event.metaKey) return;\n const list = event.currentTarget;\n const target = event.target as Element;\n if (target.getAttribute(\"role\") !== \"tab\" || target.closest('[role=\"tablist\"]') !== list) {\n return;\n }\n const rtl = orientation === \"horizontal\" && getComputedStyle(list).direction === \"rtl\";\n const move = resolveArrowKey(event.key, orientation, rtl);\n if (move === null) return;\n // The browser moves focus itself where `focusgroup` is implemented.\n if (nativeFocusgroup) return;\n\n event.preventDefault();\n const tabs = tabsOf(list);\n if (tabs.length === 0) return;\n const index = tabs.indexOf(target as HTMLElement);\n const last = tabs.length - 1;\n let nextIndex: number;\n switch (move) {\n case \"first\":\n nextIndex = 0;\n break;\n case \"last\":\n nextIndex = last;\n break;\n case \"next\":\n nextIndex = index >= last ? (loop ? 0 : last) : index + 1;\n break;\n case \"prev\":\n nextIndex = index <= 0 ? (loop ? last : 0) : index - 1;\n break;\n }\n const next = tabs[nextIndex];\n if (next !== undefined && next !== target) focusWithRing(next);\n };\n\n // With no selected tab (value null or matching no Tab) no Tab has tabindex=0, so the list\n // itself is the tab stop and hands focus to the first enabled tab (design section 8). Only when\n // focus arrives from outside the list: Shift+Tab from a tab inside would otherwise bounce\n // straight back. The redirect never selects: the Tab only dispatches on focus that moves\n // between tabs.\n const onFocus = (event: FocusEvent<HTMLElement>) => {\n const list = event.currentTarget;\n if (event.target !== list || !listIsTabStop) return;\n const from = event.relatedTarget;\n if (from instanceof Node && list.contains(from)) return;\n const tabs = tabsOf(list);\n const first = tabs.find((tab) => tab.getAttribute(\"aria-disabled\") !== \"true\") ?? tabs[0];\n if (first !== undefined) focusWithRing(first);\n };\n\n const focusgroup = experimental_focusgroup\n ? // `nomemory` + `focusgroupstart` on the selected Tab: Tab always enters on the selected tab\n // (APG), not on the last focused one, which differs in manual activation.\n `tablist ${orientation === \"vertical\" ? \"block\" : \"inline\"} ${loop ? \"wrap\" : \"nowrap\"} nomemory`\n : undefined;\n\n const element = useRender<ComponentPropsWithRef<\"div\">, TabsListState>({\n defaultElement: \"div\",\n render,\n state,\n className,\n style,\n children,\n props: rest,\n libraryProps: {\n role: \"tablist\",\n \"aria-orientation\": orientation,\n \"data-orientation\": orientation,\n \"data-disabled\": dataAttr(disabled),\n tabIndex: listIsTabStop ? 0 : undefined,\n // Owned only while the flag is on; otherwise the key is omitted, not `undefined`, so it is not\n // owned (conventions 1.2).\n ...(focusgroup !== undefined && { focusgroup }),\n onKeyDown,\n onFocus,\n },\n ref: listRef,\n });\n\n return <TabsListContext value={listContext}>{element}</TabsListContext>;\n}\n\nTabsList.displayName = \"TabsList\";\n"],"mappings":";;;;;;;;;;AAkBA,MAAM,QAAQ,QAAQ,IAAI,aAAa;;AAwBvC,SAAS,OAAO,MAA8B;CAC5C,OAAO,MAAM,KAAK,KAAK,iBAA8B,gBAAc,CAAC,CAAC,CAAC,QACnE,QAAQ,IAAI,QAAQ,oBAAkB,MAAM,IAC/C;AACF;;;;;;;;;AAUA,SAAgB,SAAS,EACvB,0BAA0B,OAC1B,WACA,OACA,UACA,QACA,GAAG,QACa;CAEhB,MAAM,EAAE,aAAa,MAAM,UAAU,eADzB,eAAe,WAC2B;CAGtD,MAAM,mBAAmB,oBAAoB,uBAAuB;CACpE,MAAM,cAAc,eACX;EAAE,YAAY;EAAyB;CAAiB,IAC/D,CAAC,yBAAyB,gBAAgB,CAC5C;CAOA,MAAM,UAAU,OAA2B,IAAI;CAC/C,MAAM,CAAC,WAAW,gBAAgB,SAAS,KAAK;CAChD,sBAAsB;EACpB,MAAM,OAAO,QAAQ;EACrB,MAAM,OACJ,eAAe,QACf,SAAS,QACT,CAAC,OAAO,IAAI,CAAC,CAAC,MAAM,QAAQ,IAAI,aAAa,UAAU,MAAM,GAAG;EAClE,IAAI,SAAS,WAAW,aAAa,IAAI;CAC3C,GAAG;EAAC;EAAY;EAAU;CAAS,CAAC;CACpC,cACE,WACA,SACE,mBAAmB,KAAK,UAAU,UAAU,EAAE,sHAElD;CACA,MAAM,gBAAgB,eAAe,QAAQ;CAE7C,MAAM,QAAuB;EAAE;EAAa;CAAS;CAErD,MAAM,aAAa,UAAsC;EACvD,IAAI,MAAM,oBAAoB,MAAM,UAAU,MAAM,WAAW,MAAM,SAAS;EAC9E,MAAM,OAAO,MAAM;EACnB,MAAM,SAAS,MAAM;EACrB,IAAI,OAAO,aAAa,MAAM,MAAM,SAAS,OAAO,QAAQ,oBAAkB,MAAM,MAClF;EAEF,MAAM,MAAM,gBAAgB,gBAAgB,iBAAiB,IAAI,CAAC,CAAC,cAAc;EACjF,MAAM,OAAO,gBAAgB,MAAM,KAAK,aAAa,GAAG;EACxD,IAAI,SAAS,MAAM;EAEnB,IAAI,kBAAkB;EAEtB,MAAM,eAAe;EACrB,MAAM,OAAO,OAAO,IAAI;EACxB,IAAI,KAAK,WAAW,GAAG;EACvB,MAAM,QAAQ,KAAK,QAAQ,MAAqB;EAChD,MAAM,OAAO,KAAK,SAAS;EAC3B,IAAI;EACJ,QAAQ,MAAR;GACE,KAAK;IACH,YAAY;IACZ;GACF,KAAK;IACH,YAAY;IACZ;GACF,KAAK;IACH,YAAY,SAAS,OAAQ,OAAO,IAAI,OAAQ,QAAQ;IACxD;GACF,KAAK,QACH,YAAY,SAAS,IAAK,OAAO,OAAO,IAAK,QAAQ;EAEzD;EACA,MAAM,OAAO,KAAK;EAClB,IAAI,SAAS,KAAA,KAAa,SAAS,QAAQ,cAAc,IAAI;CAC/D;CAOA,MAAM,WAAW,UAAmC;EAClD,MAAM,OAAO,MAAM;EACnB,IAAI,MAAM,WAAW,QAAQ,CAAC,eAAe;EAC7C,MAAM,OAAO,MAAM;EACnB,IAAI,gBAAgB,QAAQ,KAAK,SAAS,IAAI,GAAG;EACjD,MAAM,OAAO,OAAO,IAAI;EACxB,MAAM,QAAQ,KAAK,MAAM,QAAQ,IAAI,aAAa,eAAe,MAAM,MAAM,KAAK,KAAK;EACvF,IAAI,UAAU,KAAA,GAAW,cAAc,KAAK;CAC9C;CAEA,MAAM,aAAa,0BAGf,WAAW,gBAAgB,aAAa,UAAU,SAAS,GAAG,OAAO,SAAS,SAAS,aACvF,KAAA;CAEJ,MAAM,UAAU,UAAuD;EACrE,gBAAgB;EAChB;EACA;EACA;EACA;EACA;EACA,OAAO;EACP,cAAc;GACZ,MAAM;GACN,oBAAoB;GACpB,oBAAoB;GACpB,iBAAiB,SAAS,QAAQ;GAClC,UAAU,gBAAgB,IAAI,KAAA;GAG9B,GAAI,eAAe,KAAA,KAAa,EAAE,WAAW;GAC7C;GACA;EACF;EACA,KAAK;CACP,CAAC;CAED,OAAO,oBAAC,iBAAD;EAAiB,OAAO;EAAc,UAAA;CAAyB,CAAA;AACxE;AAEA,SAAS,cAAc"}
|
|
@@ -24,10 +24,9 @@ export interface TabsPanelProps extends Omit<ComponentPropsWithRef<"div">, "id"
|
|
|
24
24
|
/**
|
|
25
25
|
* Forwarded to the Panel's `<ViewTransition default>`. Default: no boundary.
|
|
26
26
|
*
|
|
27
|
-
* Static:
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
* page cross-fades for about 250 ms and the next transition commit waits for it (issue #35).
|
|
27
|
+
* Static: setting or unsetting it remounts the element. Any value, `"none"` included, makes a
|
|
28
|
+
* mount or `<Activity>` reveal inside a transition start a document view transition (a ~250 ms
|
|
29
|
+
* page cross-fade that the next transition waits for).
|
|
31
30
|
*/
|
|
32
31
|
transition?: ViewTransitionClass;
|
|
33
32
|
className?: StateValue<string | undefined, TabsPanelState>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tabs-panel.d.mts","names":[],"sources":["../../src/tabs/tabs-panel.tsx"],"mappings":";;;;iBAYiB;WACN;;WAEA;WACA,aAAa;;iBAGP,uBAAuB,KACtC;;EAIA;;;;;;;;;;EAUA
|
|
1
|
+
{"version":3,"file":"tabs-panel.d.mts","names":[],"sources":["../../src/tabs/tabs-panel.tsx"],"mappings":";;;;iBAYiB;WACN;;WAEA;WACA,aAAa;;iBAGP,uBAAuB,KACtC;;EAIA;;;;;;;;;;EAUA;;;;;;;;EAQA,aAAa;EACb,YAAY,+BAA+B;EAC3C,QAAQ,WAAW,2BAA2B;EAC9C,WAAW,WAAW,WAAW;EACjC,SAAS,WAAW,8BAA8B;;;;;;;;;wBAUpC,UAAU,OAAO,iCAAc,IAAA;yBAA/B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tabs-panel.mjs","names":[],"sources":["../../src/tabs/tabs-panel.tsx"],"sourcesContent":["\"use client\";\nimport { Activity } from \"react\";\nimport type { ComponentPropsWithRef, CSSProperties, ReactNode, ViewTransitionClass } from \"react\";\nimport { useTransitionBoundary } from \"../internal/transition-boundary.js\";\nimport { dataAttr } from \"../internal/data-attr.js\";\nimport type { RenderProp, StateValue } from \"../internal/types.js\";\nimport { useRender } from \"../internal/use-render.js\";\nimport { useUntilFound } from \"../internal/use-until-found.js\";\nimport { useTabsContext } from \"./tabs-context.js\";\nimport type { TabsContextValue, TabsOrientation } from \"./tabs-context.js\";\nimport { panelId, tabId } from \"./tabs-ids.js\";\n\nexport interface TabsPanelState {\n readonly value: string;\n /** Committed: true only once the action has resolved and the render has committed. */\n readonly selected: boolean;\n readonly orientation: TabsOrientation;\n}\n\nexport interface TabsPanelProps extends Omit<\n ComponentPropsWithRef<\"div\">,\n \"id\" | \"hidden\" | \"className\" | \"style\" | \"children\"\n> {\n /** The tab value this panel belongs to. */\n value: string;\n /**\n * What happens while this panel is not the committed selection.\n * - `false` (default): the panel is not rendered.\n * - `true`: rendered inside `<Activity mode=\"hidden\">`: DOM and state are preserved, effects\n * are stopped, content is pre-rendered at low priority. Not part of server-rendered HTML.\n * - `\"until-found\"`: rendered with `hidden=\"until-found\"`: DOM, state and effects stay live,\n * the content is in server-rendered HTML, and find-in-page or a text fragment selects the\n * tab (`details.reason === \"platform\"`).\n */\n keepMounted?: boolean | \"until-found\";\n /**\n * Forwarded to the Panel's `<ViewTransition default>`. Default: no boundary.\n *\n * Static:
|
|
1
|
+
{"version":3,"file":"tabs-panel.mjs","names":[],"sources":["../../src/tabs/tabs-panel.tsx"],"sourcesContent":["\"use client\";\nimport { Activity } from \"react\";\nimport type { ComponentPropsWithRef, CSSProperties, ReactNode, ViewTransitionClass } from \"react\";\nimport { useTransitionBoundary } from \"../internal/transition-boundary.js\";\nimport { dataAttr } from \"../internal/data-attr.js\";\nimport type { RenderProp, StateValue } from \"../internal/types.js\";\nimport { useRender } from \"../internal/use-render.js\";\nimport { useUntilFound } from \"../internal/use-until-found.js\";\nimport { useTabsContext } from \"./tabs-context.js\";\nimport type { TabsContextValue, TabsOrientation } from \"./tabs-context.js\";\nimport { panelId, tabId } from \"./tabs-ids.js\";\n\nexport interface TabsPanelState {\n readonly value: string;\n /** Committed: true only once the action has resolved and the render has committed. */\n readonly selected: boolean;\n readonly orientation: TabsOrientation;\n}\n\nexport interface TabsPanelProps extends Omit<\n ComponentPropsWithRef<\"div\">,\n \"id\" | \"hidden\" | \"className\" | \"style\" | \"children\"\n> {\n /** The tab value this panel belongs to. */\n value: string;\n /**\n * What happens while this panel is not the committed selection.\n * - `false` (default): the panel is not rendered.\n * - `true`: rendered inside `<Activity mode=\"hidden\">`: DOM and state are preserved, effects\n * are stopped, content is pre-rendered at low priority. Not part of server-rendered HTML.\n * - `\"until-found\"`: rendered with `hidden=\"until-found\"`: DOM, state and effects stay live,\n * the content is in server-rendered HTML, and find-in-page or a text fragment selects the\n * tab (`details.reason === \"platform\"`).\n */\n keepMounted?: boolean | \"until-found\";\n /**\n * Forwarded to the Panel's `<ViewTransition default>`. Default: no boundary.\n *\n * Static: setting or unsetting it remounts the element. Any value, `\"none\"` included, makes a\n * mount or `<Activity>` reveal inside a transition start a document view transition (a ~250 ms\n * page cross-fade that the next transition waits for).\n */\n transition?: ViewTransitionClass;\n className?: StateValue<string | undefined, TabsPanelState>;\n style?: StateValue<CSSProperties | undefined, TabsPanelState>;\n children?: StateValue<ReactNode, TabsPanelState>;\n render?: RenderProp<ComponentPropsWithRef<\"div\">, TabsPanelState>;\n}\n\n/**\n * A `div[role=tabpanel]`. Renders the **committed** selection, so a newly selected panel that\n * suspends keeps the current panel on screen while the Root shows `data-pending`.\n *\n * Owned keys (conventions 1.2): `role`, `id`, `aria-labelledby` (token-merged), `data-selected`,\n * `hidden`.\n */\nexport function TabsPanel(props: TabsPanelProps) {\n const ctx = useTabsContext(\"Tabs.Panel\");\n const { value, keepMounted = false } = props;\n const selected = ctx.committed === value;\n\n if (keepMounted === false) {\n return selected ? <PanelElement {...props} ctx={ctx} selected untilFound={false} /> : null;\n }\n if (keepMounted === true) {\n // The mode only changes when `committed` does, i.e. inside the Root's transition, so the\n // nested `<ViewTransition>` gets enter / exit (conventions 5.5).\n return (\n <Activity mode={selected ? \"visible\" : \"hidden\"}>\n <PanelElement {...props} ctx={ctx} selected={selected} untilFound={false} />\n </Activity>\n );\n }\n return <PanelElement {...props} ctx={ctx} selected={selected} untilFound />;\n}\n\nTabsPanel.displayName = \"TabsPanel\";\n\ninterface PanelElementProps extends TabsPanelProps {\n ctx: TabsContextValue;\n selected: boolean;\n untilFound: boolean;\n}\n\n/** Split out so that an unrendered panel resolves none of its function props. */\nfunction PanelElement({\n ctx,\n selected,\n untilFound,\n value,\n keepMounted: _keepMounted,\n transition,\n className,\n style,\n children,\n render,\n ...rest\n}: PanelElementProps) {\n const untilFoundRef = useUntilFound<HTMLDivElement>({\n // Not while this panel is the optimistic target: the browser has revealed it (or the user\n // selected its tab) and the action is pending; re-hiding it would undo the reveal. A\n // rejection or veto reverts the optimistic value, which re-activates the hook.\n active: untilFound && !selected && ctx.optimistic !== value,\n onMatch: (event) => ctx.select(value, event, \"platform\"),\n });\n\n const state: TabsPanelState = { value, selected, orientation: ctx.orientation };\n\n const element = useRender<ComponentPropsWithRef<\"div\">, TabsPanelState>({\n defaultElement: \"div\",\n render,\n state,\n className,\n style,\n children,\n // `tabIndex` defaults to 0 (APG: the panel is a tab stop) and passes through.\n props: { tabIndex: 0, ...rest },\n libraryProps: {\n role: \"tabpanel\",\n id: panelId(ctx.rootId, value),\n \"aria-labelledby\": tabId(ctx.rootId, value),\n \"data-selected\": dataAttr(selected),\n // Boolean form for SSR; `useUntilFound` upgrades it to \"until-found\" (conventions 7.4).\n hidden: untilFound ? !selected : undefined,\n },\n ref: untilFound ? untilFoundRef : undefined,\n });\n\n return useTransitionBoundary(\"Tabs.Panel\", transition, element);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAwDA,SAAgB,UAAU,OAAuB;CAC/C,MAAM,MAAM,eAAe,YAAY;CACvC,MAAM,EAAE,OAAO,cAAc,UAAU;CACvC,MAAM,WAAW,IAAI,cAAc;CAEnC,IAAI,gBAAgB,OAClB,OAAO,WAAW,oBAAC,cAAD;EAAc,GAAI;EAAY;EAAK,UAAA;EAAS,YAAY;CAAQ,CAAA,IAAI;CAExF,IAAI,gBAAgB,MAGlB,OACE,oBAAC,UAAD;EAAU,MAAM,WAAW,YAAY;EACrC,UAAA,oBAAC,cAAD;GAAc,GAAI;GAAY;GAAe;GAAU,YAAY;EAAQ,CAAA;CACnE,CAAA;CAGd,OAAO,oBAAC,cAAD;EAAc,GAAI;EAAY;EAAe;EAAU,YAAA;CAAY,CAAA;AAC5E;AAEA,UAAU,cAAc;;AASxB,SAAS,aAAa,EACpB,KACA,UACA,YACA,OACA,aAAa,cACb,YACA,WACA,OACA,UACA,QACA,GAAG,QACiB;CACpB,MAAM,gBAAgB,cAA8B;EAIlD,QAAQ,cAAc,CAAC,YAAY,IAAI,eAAe;EACtD,UAAU,UAAU,IAAI,OAAO,OAAO,OAAO,UAAU;CACzD,CAAC;CAED,MAAM,QAAwB;EAAE;EAAO;EAAU,aAAa,IAAI;CAAY;CAE9E,MAAM,UAAU,UAAwD;EACtE,gBAAgB;EAChB;EACA;EACA;EACA;EACA;EAEA,OAAO;GAAE,UAAU;GAAG,GAAG;EAAK;EAC9B,cAAc;GACZ,MAAM;GACN,IAAI,QAAQ,IAAI,QAAQ,KAAK;GAC7B,mBAAmB,MAAM,IAAI,QAAQ,KAAK;GAC1C,iBAAiB,SAAS,QAAQ;GAElC,QAAQ,aAAa,CAAC,WAAW,KAAA;EACnC;EACA,KAAK,aAAa,gBAAgB,KAAA;CACpC,CAAC;CAED,OAAO,sBAAsB,cAAc,YAAY,OAAO;AAChE"}
|
|
@@ -1,15 +1,16 @@
|
|
|
1
|
-
import { ActionDetails, ChangeAction, RenderProp, StateValue } from "../internal/types.mjs";
|
|
2
|
-
import { TabsActivationMode,
|
|
1
|
+
import { ActionDetails, ChangeAction, ChangeReason, RenderProp, StateValue } from "../internal/types.mjs";
|
|
2
|
+
import { TabsActivationMode, TabsOrientation } from "./tabs-context.mjs";
|
|
3
3
|
import { CSSProperties, ComponentPropsWithRef, ReactNode } from "react";
|
|
4
4
|
//#region src/tabs/tabs-root.d.ts
|
|
5
5
|
/** Details passed as the second argument of `valueChangeAction`. */
|
|
6
6
|
export interface TabsValueChangeDetails extends ActionDetails {
|
|
7
7
|
/**
|
|
8
|
+
* The shared vocabulary (conventions 2.2); Tabs dispatches two of its values.
|
|
8
9
|
* `"activate"`: the user selected the tab (click, Enter/Space, or focus in automatic mode).
|
|
9
10
|
* `"platform"`: the browser revealed a `keepMounted="until-found"` panel through find-in-page or a
|
|
10
11
|
* text fragment (`details.event` is the `beforematch` event).
|
|
11
12
|
*/
|
|
12
|
-
readonly reason:
|
|
13
|
+
readonly reason: ChangeReason;
|
|
13
14
|
}
|
|
14
15
|
export interface TabsRootState {
|
|
15
16
|
/** Optimistic selected value, or `null`. Content rendered from it must not suspend. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tabs-root.d.mts","names":[],"sources":["../../src/tabs/tabs-root.tsx"],"mappings":";;;;;
|
|
1
|
+
{"version":3,"file":"tabs-root.d.mts","names":[],"sources":["../../src/tabs/tabs-root.tsx"],"mappings":";;;;;iBAyBiB,+BAA+B;;;;;;;WAOrC,QAAQ;;iBAGF;;WAEN;;WAEA;WACA,aAAa;WACb;;iBAGM,sBAAsB,KACrC;;EAIA;;EAEA;;;;;;;;;EASA,oBAAoB,qBAAqB;;EAEzC,cAAc;;;;;EAKd,iBAAiB;;EAEjB;;EAEA;EACA,YAAY,+BAA+B;EAC3C,QAAQ,WAAW,2BAA2B;EAC9C,WAAW,WAAW,WAAW;EACjC,SAAS,WAAW,8BAA8B;;;;;;;;wBAkBpC,WACd,OACA,cACA,mBACA,aACA,gBACA,MACA,UACA,WACA,OACA,UACA,WACG,QACF,gCAAa,IAAA;yBAbA"}
|
package/dist/tabs/tabs-root.mjs
CHANGED
|
@@ -10,6 +10,7 @@ import { tabId } from "./tabs-ids.mjs";
|
|
|
10
10
|
import { useId, useMemo, useRef } from "react";
|
|
11
11
|
import { jsx } from "react/jsx-runtime";
|
|
12
12
|
//#region src/tabs/tabs-root.tsx
|
|
13
|
+
const isDev = process.env.NODE_ENV !== "production";
|
|
13
14
|
/** Looks up an element by id in the tree that contains `node` (document or shadow root). */
|
|
14
15
|
function findById(node, id) {
|
|
15
16
|
const root = node?.getRootNode() ?? (typeof document === "undefined" ? null : document);
|
|
@@ -43,7 +44,7 @@ function TabsRoot({ value, defaultValue, valueChangeAction, orientation = "horiz
|
|
|
43
44
|
prop: "value"
|
|
44
45
|
}
|
|
45
46
|
});
|
|
46
|
-
useDevWarning(value === void 0 && defaultValue === void 0, "Tabs.Root: neither `value` nor `defaultValue` was passed, so no tab is selected and no panel is shown. Pass `defaultValue`, or `defaultValue={null}` to start with no selection.");
|
|
47
|
+
useDevWarning(value === void 0 && defaultValue === void 0, isDev && "Tabs.Root: neither `value` nor `defaultValue` was passed, so no tab is selected and no panel is shown. Pass `defaultValue`, or `defaultValue={null}` to start with no selection.");
|
|
47
48
|
const context = useMemo(() => ({
|
|
48
49
|
rootId,
|
|
49
50
|
committed,
|