@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
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
//#region src/internal/popover-open.ts
|
|
2
|
+
/**
|
|
3
|
+
* Whether `element` is a showing popover (`:popover-open`). `false` for `null` and where the
|
|
4
|
+
* selector is unsupported (it throws there, for example on a `render` element in an engine
|
|
5
|
+
* without the Popover API).
|
|
6
|
+
*/
|
|
7
|
+
function isPopoverOpen(element) {
|
|
8
|
+
if (element === null) return false;
|
|
9
|
+
try {
|
|
10
|
+
return element.matches(":popover-open");
|
|
11
|
+
} catch {
|
|
12
|
+
return false;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
//#endregion
|
|
16
|
+
export { isPopoverOpen };
|
|
17
|
+
|
|
18
|
+
//# sourceMappingURL=popover-open.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"popover-open.mjs","names":[],"sources":["../../src/internal/popover-open.ts"],"sourcesContent":["// No directive: a pure DOM read (conventions 7.1).\n\n/**\n * Whether `element` is a showing popover (`:popover-open`). `false` for `null` and where the\n * selector is unsupported (it throws there, for example on a `render` element in an engine\n * without the Popover API).\n */\nexport function isPopoverOpen(element: Element | null): boolean {\n if (element === null) return false;\n try {\n return element.matches(\":popover-open\");\n } catch {\n return false;\n }\n}\n"],"mappings":";;;;;;AAOA,SAAgB,cAAc,SAAkC;CAC9D,IAAI,YAAY,MAAM,OAAO;CAC7B,IAAI;EACF,OAAO,QAAQ,QAAQ,eAAe;CACxC,QAAQ;EACN,OAAO;CACT;AACF"}
|
|
@@ -21,13 +21,31 @@ function rendersButton(render) {
|
|
|
21
21
|
* Whether the rendered element is certainly a host `<button>`: no `render`, the function form, or
|
|
22
22
|
* a host `"button"` element. The strict predicate for native `disabled`, which means nothing on a
|
|
23
23
|
* link and would expose it as enabled to assistive technology; anything else (a link, a
|
|
24
|
-
* component) takes the `aria-disabled` branch (design/components/button.md
|
|
24
|
+
* component) takes the `aria-disabled` branch (design/components/button.md).
|
|
25
25
|
*/
|
|
26
26
|
function isHostButton(render) {
|
|
27
27
|
if (render === void 0 || typeof render === "function") return true;
|
|
28
28
|
return isValidElement(render) && render.type === "button";
|
|
29
29
|
}
|
|
30
30
|
/**
|
|
31
|
+
* The disabled rule of a button-like part that accepts an arbitrary `render`
|
|
32
|
+
* (conventions 1.2, design/components/button.md 17): native `disabled` on a host `<button>`, or
|
|
33
|
+
* where the browser handles the click (`handlesClick: false`: a JS-free command, which only
|
|
34
|
+
* native `disabled` stops); `aria-disabled` otherwise. `alwaysFocusable` always takes the
|
|
35
|
+
* `aria-disabled` branch (a menu item stays focusable).
|
|
36
|
+
*/
|
|
37
|
+
function disabledButton(render, disabled, options = {}) {
|
|
38
|
+
const { handlesClick = true, alwaysFocusable = false } = options;
|
|
39
|
+
const focusable = alwaysFocusable || handlesClick && !isHostButton(render);
|
|
40
|
+
return {
|
|
41
|
+
props: {
|
|
42
|
+
disabled: focusable ? void 0 : disabled,
|
|
43
|
+
...focusable && { "aria-disabled": disabled ? true : void 0 }
|
|
44
|
+
},
|
|
45
|
+
invoker: !(focusable && disabled)
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
31
49
|
* The ref of a part with no library ref, merged from the consumer's `ref` and a `render`
|
|
32
50
|
* element's ref without memoisation (a directive-free part cannot `useMemo`, design
|
|
33
51
|
* progress.md 14.1). A fresh callback ref per render is correct because every merged callback
|
|
@@ -62,6 +80,6 @@ function renderElement(options) {
|
|
|
62
80
|
return createElement(defaultElement, resolved);
|
|
63
81
|
}
|
|
64
82
|
//#endregion
|
|
65
|
-
export { isHostButton, mergeRenderRef, renderElement, rendersButton, resolveStateValue };
|
|
83
|
+
export { disabledButton, isHostButton, mergeRenderRef, renderElement, rendersButton, resolveStateValue };
|
|
66
84
|
|
|
67
85
|
//# sourceMappingURL=render-element.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"render-element.mjs","names":[],"sources":["../../src/internal/render-element.ts"],"sourcesContent":["// No \"use client\": the pure half of `useRender`, usable from a directive-free part (a Root that\n// may run as a Server Component, design/components/progress.md 8.1 and implementation note 14.1).\nimport { cloneElement, createElement, isValidElement } from \"react\";\nimport type { CSSProperties, ReactNode, Ref } from \"react\";\nimport { mergeProps, mergeRefs } from \"./merge-props.js\";\nimport type { RenderProp, StateValue } from \"./types.js\";\n\nexport interface ElementLikeProps {\n className?: string | undefined;\n style?: CSSProperties | undefined;\n children?: ReactNode;\n ref?: Ref<unknown> | undefined;\n}\n\n/** `data-*` attributes are valid JSX but absent from the element prop types. */\nexport type DataAttributes = { [key: `data-${string}`]: string | undefined };\n\nexport interface RenderElementOptions<Props extends ElementLikeProps, State> {\n /** Intrinsic element rendered when `render` is not given. */\n defaultElement: string;\n render: RenderProp<Props, State> | undefined;\n state: State;\n className: StateValue<string | undefined, State> | undefined;\n style: StateValue<CSSProperties | undefined, State> | undefined;\n children: StateValue<ReactNode, State> | undefined;\n /**\n * The part's pass-through props for the element. A `render` element's own props win over\n * these. Their `ref` is replaced by `ref` below.\n */\n props: Omit<Props, \"className\" | \"style\" | \"children\"> & DataAttributes;\n /**\n * Library-controlled attributes the part computes (`role`, `aria-*` state, id wiring, `data-*`\n * state, the library's own event handlers). These win over a `render` element's props\n * (conventions 1.2).\n */\n libraryProps?: Partial<Omit<Props, \"className\" | \"style\" | \"children\">> & DataAttributes;\n /**\n * The element's ref, already merged from the library's ref, the consumer's `ref` and the\n * `render` element's ref. The `render` element's own ref is not attached separately.\n */\n ref: Ref<unknown> | undefined;\n}\n\nexport function resolveStateValue<T, State>(value: StateValue<T, State>, state: State): T {\n return typeof value === \"function\" ? (value as (state: State) => T)(state) : value;\n}\n\n/**\n * Whether a part whose default element is a `<button>` should add `type=\"button\"` (conventions\n * 1.2): no `render`, the function form (it receives button props and decides itself what to\n * spread), a host `<button>` element, or a **component** element (assumed to render a\n * `<button>`; if it renders a link, `type` is a harmless ignored attribute, while a missing\n * `type` on a `<button>` in a form is a silent submit). Only a host element of another tag (an\n * `<a>`) does not get it.\n */\nexport function rendersButton<Props, State>(render: RenderProp<Props, State> | undefined): boolean {\n if (render === undefined || typeof render === \"function\") return true;\n if (!isValidElement(render)) return false;\n return typeof render.type !== \"string\" || render.type === \"button\";\n}\n\n/**\n * Whether the rendered element is certainly a host `<button>`: no `render`, the function form, or\n * a host `\"button\"` element. The strict predicate for native `disabled`, which means nothing on a\n * link and would expose it as enabled to assistive technology; anything else (a link, a\n * component) takes the `aria-disabled` branch (design/components/button.md
|
|
1
|
+
{"version":3,"file":"render-element.mjs","names":[],"sources":["../../src/internal/render-element.ts"],"sourcesContent":["// No \"use client\": the pure half of `useRender`, usable from a directive-free part (a Root that\n// may run as a Server Component, design/components/progress.md 8.1 and implementation note 14.1).\nimport { cloneElement, createElement, isValidElement } from \"react\";\nimport type { CSSProperties, ReactNode, Ref } from \"react\";\nimport { mergeProps, mergeRefs } from \"./merge-props.js\";\nimport type { RenderProp, StateValue } from \"./types.js\";\n\nexport interface ElementLikeProps {\n className?: string | undefined;\n style?: CSSProperties | undefined;\n children?: ReactNode;\n ref?: Ref<unknown> | undefined;\n}\n\n/** `data-*` attributes are valid JSX but absent from the element prop types. */\nexport type DataAttributes = { [key: `data-${string}`]: string | undefined };\n\nexport interface RenderElementOptions<Props extends ElementLikeProps, State> {\n /** Intrinsic element rendered when `render` is not given. */\n defaultElement: string;\n render: RenderProp<Props, State> | undefined;\n state: State;\n className: StateValue<string | undefined, State> | undefined;\n style: StateValue<CSSProperties | undefined, State> | undefined;\n children: StateValue<ReactNode, State> | undefined;\n /**\n * The part's pass-through props for the element. A `render` element's own props win over\n * these. Their `ref` is replaced by `ref` below.\n */\n props: Omit<Props, \"className\" | \"style\" | \"children\"> & DataAttributes;\n /**\n * Library-controlled attributes the part computes (`role`, `aria-*` state, id wiring, `data-*`\n * state, the library's own event handlers). These win over a `render` element's props\n * (conventions 1.2).\n */\n libraryProps?: Partial<Omit<Props, \"className\" | \"style\" | \"children\">> & DataAttributes;\n /**\n * The element's ref, already merged from the library's ref, the consumer's `ref` and the\n * `render` element's ref. The `render` element's own ref is not attached separately.\n */\n ref: Ref<unknown> | undefined;\n}\n\nexport function resolveStateValue<T, State>(value: StateValue<T, State>, state: State): T {\n return typeof value === \"function\" ? (value as (state: State) => T)(state) : value;\n}\n\n/**\n * Whether a part whose default element is a `<button>` should add `type=\"button\"` (conventions\n * 1.2): no `render`, the function form (it receives button props and decides itself what to\n * spread), a host `<button>` element, or a **component** element (assumed to render a\n * `<button>`; if it renders a link, `type` is a harmless ignored attribute, while a missing\n * `type` on a `<button>` in a form is a silent submit). Only a host element of another tag (an\n * `<a>`) does not get it.\n */\nexport function rendersButton<Props, State>(render: RenderProp<Props, State> | undefined): boolean {\n if (render === undefined || typeof render === \"function\") return true;\n if (!isValidElement(render)) return false;\n return typeof render.type !== \"string\" || render.type === \"button\";\n}\n\n/**\n * Whether the rendered element is certainly a host `<button>`: no `render`, the function form, or\n * a host `\"button\"` element. The strict predicate for native `disabled`, which means nothing on a\n * link and would expose it as enabled to assistive technology; anything else (a link, a\n * component) takes the `aria-disabled` branch (design/components/button.md).\n */\nexport function isHostButton<Props, State>(render: RenderProp<Props, State> | undefined): boolean {\n if (render === undefined || typeof render === \"function\") return true;\n return isValidElement(render) && render.type === \"button\";\n}\n\nexport interface DisabledButton {\n /**\n * Owned keys, spread where `disabled` goes: `disabled` (owned as absent in the focusable\n * branch, where the element may not be a host `<button>` and the part's click handler refuses,\n * so a render element's own is removed), and in that branch only `aria-disabled` (a host\n * button keeps a consumer's own).\n */\n readonly props: {\n readonly disabled: boolean | undefined;\n readonly \"aria-disabled\"?: true | undefined;\n };\n /**\n * Whether an invoker part may render `commandfor` / `command`: not when disabled in the\n * focusable branch, where nothing native stops the command (a component render spreading onto\n * a real `<button>` would be a live invoker before hydration).\n */\n readonly invoker: boolean;\n}\n\n/**\n * The disabled rule of a button-like part that accepts an arbitrary `render`\n * (conventions 1.2, design/components/button.md 17): native `disabled` on a host `<button>`, or\n * where the browser handles the click (`handlesClick: false`: a JS-free command, which only\n * native `disabled` stops); `aria-disabled` otherwise. `alwaysFocusable` always takes the\n * `aria-disabled` branch (a menu item stays focusable).\n */\nexport function disabledButton<Props, State>(\n render: RenderProp<Props, State> | undefined,\n disabled: boolean,\n options: { readonly handlesClick?: boolean; readonly alwaysFocusable?: boolean } = {},\n): DisabledButton {\n const { handlesClick = true, alwaysFocusable = false } = options;\n const focusable = alwaysFocusable || (handlesClick && !isHostButton(render));\n return {\n props: {\n disabled: focusable ? undefined : disabled,\n ...(focusable && { \"aria-disabled\": disabled ? true : undefined }),\n },\n invoker: !(focusable && disabled),\n };\n}\n\n/**\n * The ref of a part with no library ref, merged from the consumer's `ref` and a `render`\n * element's ref without memoisation (a directive-free part cannot `useMemo`, design\n * progress.md 14.1). A fresh callback ref per render is correct because every merged callback\n * returns a cleanup; a single ref is passed through untouched.\n */\nexport function mergeRenderRef(\n consumerRef: Ref<unknown> | undefined,\n render: unknown,\n): Ref<unknown> | undefined {\n const elementRef = isValidElement<ElementLikeProps>(render) ? render.props.ref : undefined;\n if (consumerRef != null && elementRef != null) return mergeRefs(consumerRef, elementRef);\n return consumerRef ?? elementRef;\n}\n\n/**\n * Resolves `render` and the function-form `className` / `style` / `children` of a part against\n * its state and produces the element (conventions 1.2, 1.3, 1.4). Pure: the caller merges the\n * refs (`useRender` memoises the merge; a directive-free part merges unmemoised).\n */\nexport function renderElement<Props extends ElementLikeProps, State>(\n options: RenderElementOptions<Props, State>,\n): ReactNode {\n const { defaultElement, render, state, className, style, children, props, libraryProps, ref } =\n options;\n\n const partProps = {\n ...props,\n ref,\n className: resolveStateValue(className, state),\n style: resolveStateValue(style, state),\n children: resolveStateValue(children, state),\n } as Record<string, unknown>;\n const controlled = (libraryProps ?? {}) as Record<string, unknown>;\n\n if (isValidElement<ElementLikeProps>(render)) {\n // The element's ref is already part of `ref`.\n const { ref: _ignored, ...elementProps } = render.props as Record<string, unknown>;\n return cloneElement(render, mergeProps(partProps, elementProps, controlled) as Partial<Props>);\n }\n const resolved = mergeProps(partProps, {}, controlled) as unknown as Props;\n if (typeof render === \"function\") {\n return render(resolved, state);\n }\n return createElement(defaultElement, resolved);\n}\n"],"mappings":";;;AA2CA,SAAgB,kBAA4B,OAA6B,OAAiB;CACxF,OAAO,OAAO,UAAU,aAAc,MAA8B,KAAK,IAAI;AAC/E;;;;;;;;;AAUA,SAAgB,cAA4B,QAAuD;CACjG,IAAI,WAAW,KAAA,KAAa,OAAO,WAAW,YAAY,OAAO;CACjE,IAAI,CAAC,eAAe,MAAM,GAAG,OAAO;CACpC,OAAO,OAAO,OAAO,SAAS,YAAY,OAAO,SAAS;AAC5D;;;;;;;AAQA,SAAgB,aAA2B,QAAuD;CAChG,IAAI,WAAW,KAAA,KAAa,OAAO,WAAW,YAAY,OAAO;CACjE,OAAO,eAAe,MAAM,KAAK,OAAO,SAAS;AACnD;;;;;;;;AA4BA,SAAgB,eACd,QACA,UACA,UAAmF,CAAC,GACpE;CAChB,MAAM,EAAE,eAAe,MAAM,kBAAkB,UAAU;CACzD,MAAM,YAAY,mBAAoB,gBAAgB,CAAC,aAAa,MAAM;CAC1E,OAAO;EACL,OAAO;GACL,UAAU,YAAY,KAAA,IAAY;GAClC,GAAI,aAAa,EAAE,iBAAiB,WAAW,OAAO,KAAA,EAAU;EAClE;EACA,SAAS,EAAE,aAAa;CAC1B;AACF;;;;;;;AAQA,SAAgB,eACd,aACA,QAC0B;CAC1B,MAAM,aAAa,eAAiC,MAAM,IAAI,OAAO,MAAM,MAAM,KAAA;CACjF,IAAI,eAAe,QAAQ,cAAc,MAAM,OAAO,UAAU,aAAa,UAAU;CACvF,OAAO,eAAe;AACxB;;;;;;AAOA,SAAgB,cACd,SACW;CACX,MAAM,EAAE,gBAAgB,QAAQ,OAAO,WAAW,OAAO,UAAU,OAAO,cAAc,QACtF;CAEF,MAAM,YAAY;EAChB,GAAG;EACH;EACA,WAAW,kBAAkB,WAAW,KAAK;EAC7C,OAAO,kBAAkB,OAAO,KAAK;EACrC,UAAU,kBAAkB,UAAU,KAAK;CAC7C;CACA,MAAM,aAAc,gBAAgB,CAAC;CAErC,IAAI,eAAiC,MAAM,GAAG;EAE5C,MAAM,EAAE,KAAK,UAAU,GAAG,iBAAiB,OAAO;EAClD,OAAO,aAAa,QAAQ,WAAW,WAAW,cAAc,UAAU,CAAmB;CAC/F;CACA,MAAM,WAAW,WAAW,WAAW,CAAC,GAAG,UAAU;CACrD,IAAI,OAAO,WAAW,YACpB,OAAO,OAAO,UAAU,KAAK;CAE/B,OAAO,cAAc,gBAAgB,QAAQ;AAC/C"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
//#region src/internal/shipped-styles.ts
|
|
2
|
+
/**
|
|
3
|
+
* The React stylesheet precedence bucket of the library's functional CSS. Fizz writes every
|
|
4
|
+
* same-precedence `<style>` of one server flush as a single element with the texts concatenated,
|
|
5
|
+
* which would match none of the per-href hashes in `STYLE_SHA256`: at most one shipped stylesheet
|
|
6
|
+
* in this bucket may render during server rendering (today the tooltip skip-delay rule; the menu
|
|
7
|
+
* point rules are client-only). A second one needs a precedence of its own (guard row in
|
|
8
|
+
* `csp/csp.test.tsx`).
|
|
9
|
+
*/
|
|
10
|
+
const FSUI_PRECEDENCE = "fsui";
|
|
11
|
+
//#endregion
|
|
12
|
+
export { FSUI_PRECEDENCE };
|
|
13
|
+
|
|
14
|
+
//# sourceMappingURL=shipped-styles.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shipped-styles.mjs","names":[],"sources":["../../src/internal/shipped-styles.ts"],"sourcesContent":["// Shared by the library's shipped functional stylesheets (conventions 12). No \"use client\"\n// directive: constants only (conventions 7.1).\n\n/**\n * The React stylesheet precedence bucket of the library's functional CSS. Fizz writes every\n * same-precedence `<style>` of one server flush as a single element with the texts concatenated,\n * which would match none of the per-href hashes in `STYLE_SHA256`: at most one shipped stylesheet\n * in this bucket may render during server rendering (today the tooltip skip-delay rule; the menu\n * point rules are client-only). A second one needs a precedence of its own (guard row in\n * `csp/csp.test.tsx`).\n */\nexport const FSUI_PRECEDENCE = \"fsui\";\n"],"mappings":";;;;;;;;;AAWA,MAAa,kBAAkB"}
|
|
@@ -13,7 +13,11 @@ function syncPresence(el, name, present) {
|
|
|
13
13
|
else el.removeAttribute(name);
|
|
14
14
|
}
|
|
15
15
|
}
|
|
16
|
+
/** `syncPresence` for each entry of `attributes`, in order. */
|
|
17
|
+
function syncPresences(el, attributes) {
|
|
18
|
+
for (const [name, present] of Object.entries(attributes)) syncPresence(el, name, present);
|
|
19
|
+
}
|
|
16
20
|
//#endregion
|
|
17
|
-
export { syncPresence };
|
|
21
|
+
export { syncPresence, syncPresences };
|
|
18
22
|
|
|
19
23
|
//# sourceMappingURL=sync-presence.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sync-presence.mjs","names":[],"sources":["../../src/internal/sync-presence.ts"],"sourcesContent":["/**\n * Makes a boolean attribute's presence match `present`. For group members that may hydrate after\n * their Root (`RadioGroup.Item`, `CheckboxGroup.Item` / `Parent`): hydration keeps server\n * attributes that differ from the client render (React only warns), and a member hydrating late\n * can render a different state than the server did.\n *\n * No `\"use client\"` directive: no client-only API (conventions 7.1).\n */\nexport function syncPresence(el: Element, name: string, present: boolean): void {\n if (el.hasAttribute(name) !== present) {\n if (present) el.setAttribute(name, \"\");\n else el.removeAttribute(name);\n }\n}\n"],"mappings":";;;;;;;;;AAQA,SAAgB,aAAa,IAAa,MAAc,SAAwB;CAC9E,IAAI,GAAG,aAAa,IAAI,MAAM,SAAS;EACrC,IAAI,SAAS,GAAG,aAAa,MAAM,EAAE;OAChC,GAAG,gBAAgB,IAAI;CAC9B;AACF"}
|
|
1
|
+
{"version":3,"file":"sync-presence.mjs","names":[],"sources":["../../src/internal/sync-presence.ts"],"sourcesContent":["/**\n * Makes a boolean attribute's presence match `present`. For group members that may hydrate after\n * their Root (`RadioGroup.Item`, `CheckboxGroup.Item` / `Parent`): hydration keeps server\n * attributes that differ from the client render (React only warns), and a member hydrating late\n * can render a different state than the server did.\n *\n * No `\"use client\"` directive: no client-only API (conventions 7.1).\n */\nexport function syncPresence(el: Element, name: string, present: boolean): void {\n if (el.hasAttribute(name) !== present) {\n if (present) el.setAttribute(name, \"\");\n else el.removeAttribute(name);\n }\n}\n\n/** `syncPresence` for each entry of `attributes`, in order. */\nexport function syncPresences(el: Element, attributes: Readonly<Record<string, boolean>>): void {\n for (const [name, present] of Object.entries(attributes)) syncPresence(el, name, present);\n}\n"],"mappings":";;;;;;;;;AAQA,SAAgB,aAAa,IAAa,MAAc,SAAwB;CAC9E,IAAI,GAAG,aAAa,IAAI,MAAM,SAAS;EACrC,IAAI,SAAS,GAAG,aAAa,MAAM,EAAE;OAChC,GAAG,gBAAgB,IAAI;CAC9B;AACF;;AAGA,SAAgB,cAAc,IAAa,YAAqD;CAC9F,KAAK,MAAM,CAAC,MAAM,YAAY,OAAO,QAAQ,UAAU,GAAG,aAAa,IAAI,MAAM,OAAO;AAC1F"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"toolbar-context.mjs","names":[],"sources":["../../src/internal/toolbar-context.ts"],"sourcesContent":["\"use client\";\nimport { createContext, use } from \"react\";\n\n/** What a part inside a `Toolbar.Root` learns about it (design/components/toggle-group.md 7.3, 7.4). */\nexport interface ToolbarContextValue {\n /** The Toolbar's arrow-key axis. */\n readonly orientation:
|
|
1
|
+
{"version":3,"file":"toolbar-context.mjs","names":[],"sources":["../../src/internal/toolbar-context.ts"],"sourcesContent":["\"use client\";\nimport { createContext, use } from \"react\";\nimport type { Orientation } from \"./types.js\";\n\n/** What a part inside a `Toolbar.Root` learns about it (design/components/toggle-group.md 7.3, 7.4). */\nexport interface ToolbarContextValue {\n /** The Toolbar's arrow-key axis. */\n readonly orientation: Orientation;\n}\n\n/**\n * Provided by `Toolbar.Root`; read across folders by `ToggleGroup.Root` (joins the Toolbar's\n * sequence instead of running its own engine), `Toolbar.Separator` (perpendicular orientation)\n * and `Menu.Trigger` (opening arrows in a vertical Toolbar). Conventions 7.1.\n */\nexport const ToolbarContext = createContext<ToolbarContextValue | null>(null);\n\n/** The enclosing Toolbar, or `null` outside one. Works during SSR (context, not DOM). */\nexport function useToolbarContext(): ToolbarContextValue | null {\n return use(ToolbarContext);\n}\n"],"mappings":";;;;;;;;AAeA,MAAa,iBAAiB,cAA0C,IAAI;;AAG5E,SAAgB,oBAAgD;CAC9D,OAAO,IAAI,cAAc;AAC3B"}
|
|
@@ -24,6 +24,6 @@ function warmDelay(delay) {
|
|
|
24
24
|
return `calc(${delay}ms * (1 - var(${TOOLTIP_WARM_PROPERTY}, 0)))`;
|
|
25
25
|
}
|
|
26
26
|
//#endregion
|
|
27
|
-
export { TOOLTIP_TRIGGER_MARKER, TOOLTIP_WARM_HREF,
|
|
27
|
+
export { TOOLTIP_TRIGGER_MARKER, TOOLTIP_WARM_HREF, TOOLTIP_WARM_RULES, warmDelay };
|
|
28
28
|
|
|
29
29
|
//# sourceMappingURL=tooltip-warm.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tooltip-warm.mjs","names":[],"sources":["../../src/internal/tooltip-warm.ts"],"sourcesContent":["// Tooltip's skip-delay rule on the native `interestfor` path (design/components/tooltip.md 6,\n// conventions 12): while any tooltip is showing, the inline `interest-delay-start` of a flagged\n// Trigger computes to 0. No \"use client\" directive: constants only (conventions 7.1).\n\n/** Registered, non-inherited: `1` on the marked triggers while a tooltip is showing, else `0`. */\
|
|
1
|
+
{"version":3,"file":"tooltip-warm.mjs","names":[],"sources":["../../src/internal/tooltip-warm.ts"],"sourcesContent":["// Tooltip's skip-delay rule on the native `interestfor` path (design/components/tooltip.md 6,\n// conventions 12): while any tooltip is showing, the inline `interest-delay-start` of a flagged\n// Trigger computes to 0. No \"use client\" directive: constants only (conventions 7.1).\n\n/** Registered, non-inherited: `1` on the marked triggers while a tooltip is showing, else `0`. */\nconst TOOLTIP_WARM_PROPERTY = \"--fsui-tooltip-warm\";\n/** The marker a flagged Trigger renders; the shipped rule matches nothing else. */\nexport const TOOLTIP_TRIGGER_MARKER = \"data-fsui-tooltip-trigger\";\n/** The dedupe key of the shipped rule (`<style href precedence>`). */\nexport const TOOLTIP_WARM_HREF = \"@funstack/ui/tooltip-warm\";\n\n/**\n * The library's second shipped stylesheet: interaction timing, nothing visual (conventions 12's\n * selector exception: it matches only the library's marker and sets only a `--fsui-` registered\n * property the Trigger's inline style consumes). Its SHA-256 is `STYLE_SHA256` in\n * `@funstack/ui/csp` (a jsdom row recomputes it). When the stylesheet is missing (blocked by a\n * CSP, or never rendered) the property is unregistered and unset: `warmDelay`'s `var()` carries\n * its own `0` fallback, so the Trigger keeps its own `delay` (without it the declaration would be\n * invalid at computed-value time and the browser's `normal` delay would apply).\n */\nexport const TOOLTIP_WARM_RULES =\n \"/* @funstack/ui: tooltip skip-delay. Functional only: while a tooltip is showing, the next \" +\n \"one opens without its delay. */\\n\" +\n `@property ${TOOLTIP_WARM_PROPERTY} { syntax: \"<number>\"; inherits: false; initial-value: 0; }\\n` +\n `:root:has([role=\"tooltip\"]:popover-open) [${TOOLTIP_TRIGGER_MARKER}] { ${TOOLTIP_WARM_PROPERTY}: 1; }\\n`;\n\n/**\n * The inline `interest-delay-start` of a flagged Trigger: `delay` when cold, `0` when warm, and\n * `delay` when the stylesheet is missing (the explicit `0` fallback).\n */\nexport function warmDelay(delay: number): string {\n return `calc(${delay}ms * (1 - var(${TOOLTIP_WARM_PROPERTY}, 0)))`;\n}\n"],"mappings":";;AAKA,MAAM,wBAAwB;;AAE9B,MAAa,yBAAyB;;AAEtC,MAAa,oBAAoB;;;;;;;;;;AAWjC,MAAa,qBACX;YAEa,sBAAsB,yGACU,uBAAuB,MAAM,sBAAsB;;;;;AAMlG,SAAgB,UAAU,OAAuB;CAC/C,OAAO,QAAQ,MAAM,gBAAgB,sBAAsB;AAC7D"}
|
|
@@ -8,7 +8,7 @@ const isDev = process.env.NODE_ENV !== "production";
|
|
|
8
8
|
* passed `transition`** (conventions 5.1). With `transition === undefined` the node is returned
|
|
9
9
|
* unwrapped and the part renders no boundary at all.
|
|
10
10
|
*
|
|
11
|
-
* Reason (docs/research/view-transition-mount-cost.md
|
|
11
|
+
* Reason (docs/research/view-transition-mount-cost.md): react-dom 19.3 starts a
|
|
12
12
|
* document view transition whenever a `<ViewTransition>` mounts or is revealed by `<Activity>` in
|
|
13
13
|
* a transition-lane commit, whatever its class resolves to (`"none"` included). The browser's
|
|
14
14
|
* 250 ms root cross-fade then runs and every later transition commit waits for it. Exits and
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transition-boundary.mjs","names":[],"sources":["../../src/internal/transition-boundary.tsx"],"sourcesContent":["\"use client\";\nimport { useEffect, useRef, ViewTransition } from \"react\";\nimport type { ReactNode, ViewTransitionClass } from \"react\";\n\nconst isDev = process.env.NODE_ENV !== \"production\";\n\n/**\n * Wraps a part's output in `<ViewTransition default={transition}>` **only when the consumer\n * passed `transition`** (conventions 5.1). With `transition === undefined` the node is returned\n * unwrapped and the part renders no boundary at all.\n *\n * Reason (docs/research/view-transition-mount-cost.md
|
|
1
|
+
{"version":3,"file":"transition-boundary.mjs","names":[],"sources":["../../src/internal/transition-boundary.tsx"],"sourcesContent":["\"use client\";\nimport { useEffect, useRef, ViewTransition } from \"react\";\nimport type { ReactNode, ViewTransitionClass } from \"react\";\n\nconst isDev = process.env.NODE_ENV !== \"production\";\n\n/**\n * Wraps a part's output in `<ViewTransition default={transition}>` **only when the consumer\n * passed `transition`** (conventions 5.1). With `transition === undefined` the node is returned\n * unwrapped and the part renders no boundary at all.\n *\n * Reason (docs/research/view-transition-mount-cost.md): react-dom 19.3 starts a\n * document view transition whenever a `<ViewTransition>` mounts or is revealed by `<Activity>` in\n * a transition-lane commit, whatever its class resolves to (`\"none\"` included). The browser's\n * 250 ms root cross-fade then runs and every later transition commit waits for it. Exits and\n * updates of a `\"none\"` boundary are free, so an explicit `transition=\"none\"` keeps the boundary\n * and lets a consumer switch between `\"none\"` and a class without remounting.\n *\n * The boundary stays the outermost node of the part's output, so a part that is the top of an\n * inserted subtree gets enter / exit. A plain function (not a component), so it adds no fiber\n * between the boundary and the element.\n */\nexport function transitionBoundary(\n transition: ViewTransitionClass | undefined,\n node: ReactNode,\n): ReactNode {\n if (transition === undefined) return node;\n return <ViewTransition default={transition}>{node}</ViewTransition>;\n}\n\n/**\n * {@link transitionBoundary} plus the development warning for a non-static `transition`\n * (conventions 5.1): changing it between `undefined` and a value changes the element type at the\n * part's root, so React remounts the part's subtree (DOM and state lost). Warns once per\n * instance, from an effect. `part` is the public name used in the message (`\"Tabs.Panel\"`).\n *\n * Pass the *effective* value: a part that ignores `transition` in some mode (Accordion, Dialog\n * JS-free mode) passes `undefined` there.\n */\nexport function useTransitionBoundary(\n part: string,\n transition: ViewTransitionClass | undefined,\n node: ReactNode,\n): ReactNode {\n const hasBoundary = transition !== undefined;\n const initial = useRef(hasBoundary);\n const warned = useRef(false);\n useEffect(() => {\n if (!isDev || warned.current || hasBoundary === initial.current) return;\n warned.current = true;\n console.error(\n `${part}: \\`transition\\` changed between undefined and a value after mount. The part ` +\n \"renders a <ViewTransition> only when `transition` is given, so this remounts its \" +\n 'subtree (DOM and state are lost). Keep `transition` static; use `transition=\"none\"` ' +\n \"to switch animation off without removing the boundary.\",\n );\n }, [hasBoundary, part]);\n return transitionBoundary(transition, node);\n}\n"],"mappings":";;;;AAIA,MAAM,QAAQ,QAAQ,IAAI,aAAa;;;;;;;;;;;;;;;;;AAkBvC,SAAgB,mBACd,YACA,MACW;CACX,IAAI,eAAe,KAAA,GAAW,OAAO;CACrC,OAAO,oBAAC,gBAAD;EAAgB,SAAS;EAAa,UAAA;CAAqB,CAAA;AACpE;;;;;;;;;;AAWA,SAAgB,sBACd,MACA,YACA,MACW;CACX,MAAM,cAAc,eAAe,KAAA;CACnC,MAAM,UAAU,OAAO,WAAW;CAClC,MAAM,SAAS,OAAO,KAAK;CAC3B,gBAAgB;EACd,IAAI,CAAC,SAAS,OAAO,WAAW,gBAAgB,QAAQ,SAAS;EACjE,OAAO,UAAU;EACjB,QAAQ,MACN,GAAG,KAAK,+SAIV;CACF,GAAG,CAAC,aAAa,IAAI,CAAC;CACtB,OAAO,mBAAmB,YAAY,IAAI;AAC5C"}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { ReactElement, ReactNode } from "react";
|
|
2
2
|
//#region src/internal/types.d.ts
|
|
3
|
+
/** The arrow-key axis of a composite widget (Toolbar, Tabs, ToggleGroup, Slider). */
|
|
4
|
+
export type Orientation = "horizontal" | "vertical";
|
|
3
5
|
/**
|
|
4
6
|
* A callback the library runs inside a Transition. May be sync or async: the library awaits
|
|
5
7
|
* whatever it returns (a thenable is awaited, anything else is ignored). The return type is
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.mts","names":[],"sources":["../../src/internal/types.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"types.d.mts","names":[],"sources":["../../src/internal/types.ts"],"mappings":";;;YAGY;;;;;;;YAQA,OAAO,4CAA4C,MAAM;iBAEpD;;WAEN,OAAO;;;YAIN,aAAa,GAAG,gBAAgB,gBAAgB,iBAAiB,QAC1E,MAAM,GAAG,SAAS;;;;;;;;YAUT,oBAAoB,GAAG,gBAAgB,gBAAgB,kBACjE,MAAM,GACN,SAAS;;;;;;;;;;;;;;;YAiBC;;YAGA,WAAW,GAAG,SAAS,MAAM,OAAO,UAAU;;;;;;YAO9C,WAAW,OAAO,SAC1B,aAAa,QAAQ,YACnB,OAAO,OAAO,OAAO,UAAU"}
|
|
@@ -1,11 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import {
|
|
2
|
+
import { useSupersededRejection } from "./use-superseded-rejection.mjs";
|
|
3
|
+
import { useRef, useTransition } from "react";
|
|
3
4
|
//#region src/internal/use-action-trigger.ts
|
|
4
|
-
/** Reports an error that cannot reach a boundary (conventions 2.4: never swallow). */
|
|
5
|
-
function report(error) {
|
|
6
|
-
if (typeof reportError === "function") reportError(error);
|
|
7
|
-
else console.error(error);
|
|
8
|
-
}
|
|
9
5
|
/**
|
|
10
6
|
* The transition of a pure-trigger part: an `action` with no state of its own (`Button`,
|
|
11
7
|
* `Dialog.Close`, `Popover.Close`, `Menu.Item`, `Toast.Action`; conventions 3.4). A second `run`
|
|
@@ -19,19 +15,11 @@ function report(error) {
|
|
|
19
15
|
*/
|
|
20
16
|
function useActionTrigger(options = {}) {
|
|
21
17
|
const { openGeneration, ignoreWhilePending = true } = options;
|
|
22
|
-
const
|
|
23
|
-
const
|
|
24
|
-
if (supersededError !== null) throw supersededError.error;
|
|
18
|
+
const ownCapture = useSupersededRejection();
|
|
19
|
+
const captureSuperseded = options.captureSuperseded ?? ownCapture;
|
|
25
20
|
const [pending, startOwnTransition] = useTransition();
|
|
26
21
|
const latest = useRef(0);
|
|
27
|
-
const mounted = useRef(false);
|
|
28
22
|
const inFlight = useRef(0);
|
|
29
|
-
useEffect(() => {
|
|
30
|
-
mounted.current = true;
|
|
31
|
-
return () => {
|
|
32
|
-
mounted.current = false;
|
|
33
|
-
};
|
|
34
|
-
}, []);
|
|
35
23
|
const run = (work, then) => {
|
|
36
24
|
if (ignoreWhilePending && inFlight.current > 0) return false;
|
|
37
25
|
inFlight.current++;
|
|
@@ -43,13 +31,7 @@ function useActionTrigger(options = {}) {
|
|
|
43
31
|
} catch (error) {
|
|
44
32
|
inFlight.current--;
|
|
45
33
|
if (id === latest.current) throw error;
|
|
46
|
-
|
|
47
|
-
if (hasSupersededError.current) {
|
|
48
|
-
report(error);
|
|
49
|
-
return;
|
|
50
|
-
}
|
|
51
|
-
hasSupersededError.current = true;
|
|
52
|
-
setSupersededError({ error });
|
|
34
|
+
captureSuperseded(error);
|
|
53
35
|
return;
|
|
54
36
|
}
|
|
55
37
|
inFlight.current--;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-action-trigger.mjs","names":[],"sources":["../../src/internal/use-action-trigger.ts"],"sourcesContent":["\"use client\";\nimport {
|
|
1
|
+
{"version":3,"file":"use-action-trigger.mjs","names":[],"sources":["../../src/internal/use-action-trigger.ts"],"sourcesContent":["\"use client\";\nimport { useRef, useTransition } from \"react\";\nimport { useSupersededRejection } from \"./use-superseded-rejection.js\";\n\nexport interface ActionTriggerOptions {\n /**\n * Open generation of the overlay a `then` belongs to: `then` is skipped when a newer open of\n * the overlay started after the run began.\n */\n readonly openGeneration?: (() => number) | undefined;\n /**\n * Ignore `run` while a run is in flight (conventions 2.5): `run` returns `false` and starts\n * nothing. In flight means the hook's synchronous in-flight counter is non-zero (it also sees\n * two activations in one task, before React re-rendered); the last render's `pending` is not\n * consulted, so a click in a settled-but-held commit window runs. Default `true`: every pure\n * trigger ignores re-entry. Only the continuous controls (`Slider`, `NumberField`)\n * pass `false`, because a step is not a re-entry: every step must run.\n */\n readonly ignoreWhilePending?: boolean | undefined;\n /**\n * A component with two transition channels (Slider, NumberField) passes one\n * `useSupersededRejection()` called before both hooks, so a superseded rejection of either\n * channel is thrown before both `useTransition`s and never waits for the other channel's\n * pending action. Stable. Default: the hook's own.\n */\n readonly captureSuperseded?: ((error: unknown) => void) | undefined;\n}\n\nexport interface ActionTrigger {\n /** A run started through this hook is in flight (the part's own transition). */\n readonly pending: boolean;\n /**\n * Runs `work` inside the part's own transition and, once it resolves, `then` (still inside the\n * transition: a Close part's close, a menu item's close). A rejection skips `then` and reaches\n * the nearest Error Boundary above the part, also when a later run superseded this one. With\n * `openGeneration`, `then` is skipped when a newer open of the overlay started after the run\n * began. Returns `false` when the run was ignored (a run is in flight and `ignoreWhilePending`\n * is on, the default), so the part can\n * `preventDefault()` the activation, and `true` otherwise.\n */\n readonly run: (work: () => unknown, then?: () => void) => boolean;\n}\n\n/**\n * The transition of a pure-trigger part: an `action` with no state of its own (`Button`,\n * `Dialog.Close`, `Popover.Close`, `Menu.Item`, `Toast.Action`; conventions 3.4). A second `run`\n * while one is in flight is ignored by default (conventions 2.5, design/components/button.md 16).\n *\n * With `ignoreWhilePending: false` (the continuous controls' steps) runs overlap, and the hook\n * surfaces superseded rejections as `useControllableAction` does: React keeps only the newest\n * thenable per `useTransition`, so the rejection of a run that a later run superseded would be\n * dropped. The hook catches it and throws it from render, so it reaches the same boundary as the\n * latest run's rejection does.\n */\nexport function useActionTrigger(options: ActionTriggerOptions = {}): ActionTrigger {\n const { openGeneration, ignoreWhilePending = true } = options;\n\n // Before `useTransition` on purpose (see the hook). Unused (never throws) with an external one.\n const ownCapture = useSupersededRejection();\n const captureSuperseded = options.captureSuperseded ?? ownCapture;\n\n const [pending, startOwnTransition] = useTransition();\n const latest = useRef(0);\n // Runs whose work has not settled yet. Updated synchronously, so a second activation in the\n // same task (React's `pending` is still the stale render value) is seen (conventions 2.5).\n const inFlight = useRef(0);\n\n const run = (work: () => unknown, then?: () => void): boolean => {\n // The own counter only, not the rendered `pending` (design/components/button.md 5.2): after\n // the work settled, a commit held by entanglement must not drop a new activation.\n if (ignoreWhilePending && inFlight.current > 0) return false;\n inFlight.current++;\n const id = ++latest.current;\n // The open this run belongs to (design/components/popover.md 3.4): if the\n // user dismisses and re-opens while the action runs, its close must not close the new open.\n const generation = openGeneration?.();\n startOwnTransition(async () => {\n try {\n await work();\n } catch (error) {\n inFlight.current--;\n // The latest run's rejection takes React's own route to the boundary.\n if (id === latest.current) throw error;\n captureSuperseded(error);\n return;\n }\n inFlight.current--;\n if (openGeneration !== undefined && openGeneration() !== generation) return;\n then?.();\n });\n return true;\n };\n\n return { pending, run };\n}\n"],"mappings":";;;;;;;;;;;;;;;AAsDA,SAAgB,iBAAiB,UAAgC,CAAC,GAAkB;CAClF,MAAM,EAAE,gBAAgB,qBAAqB,SAAS;CAGtD,MAAM,aAAa,uBAAuB;CAC1C,MAAM,oBAAoB,QAAQ,qBAAqB;CAEvD,MAAM,CAAC,SAAS,sBAAsB,cAAc;CACpD,MAAM,SAAS,OAAO,CAAC;CAGvB,MAAM,WAAW,OAAO,CAAC;CAEzB,MAAM,OAAO,MAAqB,SAA+B;EAG/D,IAAI,sBAAsB,SAAS,UAAU,GAAG,OAAO;EACvD,SAAS;EACT,MAAM,KAAK,EAAE,OAAO;EAGpB,MAAM,aAAa,iBAAiB;EACpC,mBAAmB,YAAY;GAC7B,IAAI;IACF,MAAM,KAAK;GACb,SAAS,OAAO;IACd,SAAS;IAET,IAAI,OAAO,OAAO,SAAS,MAAM;IACjC,kBAAkB,KAAK;IACvB;GACF;GACA,SAAS;GACT,IAAI,mBAAmB,KAAA,KAAa,eAAe,MAAM,YAAY;GACrE,OAAO;EACT,CAAC;EACD,OAAO;CACT;CAEA,OAAO;EAAE;EAAS;CAAI;AACxB"}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { createActionDetails } from "./action-details.mjs";
|
|
3
|
+
import { dataAttr } from "./data-attr.mjs";
|
|
4
|
+
import { useControllableAction } from "./use-controllable-action.mjs";
|
|
5
|
+
import { useMergedRefs } from "./use-merged-refs.mjs";
|
|
6
|
+
import { fieldInputProps, useFieldControl, useFieldValueChange } from "./use-field-control.mjs";
|
|
7
|
+
import { guardCheckableChange, useNativeChecked } from "./use-native-checked.mjs";
|
|
8
|
+
//#region src/internal/use-checkable-input.ts
|
|
9
|
+
/**
|
|
10
|
+
* The single-checkbox machinery `Checkbox` and `Switch` share: the Field wiring, the
|
|
11
|
+
* controllable action, the native `checked` re-apply and reconciliation (`useNativeChecked`),
|
|
12
|
+
* and the input's owned layer. The components keep their props, state, `useRender` call and
|
|
13
|
+
* transition boundary.
|
|
14
|
+
*/
|
|
15
|
+
function useCheckableInput(options) {
|
|
16
|
+
const { component, checked, defaultChecked, checkedChangeAction, disabled: disabledProp, own, transitionTypes, role, indeterminate } = options;
|
|
17
|
+
const field = useFieldControl({
|
|
18
|
+
labelable: true,
|
|
19
|
+
name: own.name,
|
|
20
|
+
disabled: disabledProp,
|
|
21
|
+
required: own.required,
|
|
22
|
+
id: own.id,
|
|
23
|
+
component
|
|
24
|
+
});
|
|
25
|
+
const disabled = field.disabled;
|
|
26
|
+
const { optimistic, pending, dispatch, latestInFlight } = useControllableAction({
|
|
27
|
+
controlled: checked,
|
|
28
|
+
defaultValue: defaultChecked,
|
|
29
|
+
initialValue: false,
|
|
30
|
+
action: checkedChangeAction,
|
|
31
|
+
transitionTypes,
|
|
32
|
+
warn: {
|
|
33
|
+
component,
|
|
34
|
+
prop: "checked"
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
useFieldValueChange(optimistic);
|
|
38
|
+
const mixed = indeterminate !== void 0;
|
|
39
|
+
const shownIndeterminate = indeterminate === true && !pending;
|
|
40
|
+
const inputRef = useNativeChecked({
|
|
41
|
+
type: "checkbox",
|
|
42
|
+
component,
|
|
43
|
+
checked: optimistic,
|
|
44
|
+
defaultChecked: checked === void 0 ? defaultChecked ?? false : void 0,
|
|
45
|
+
indeterminate: mixed ? shownIndeterminate : void 0,
|
|
46
|
+
latestInFlight,
|
|
47
|
+
onPlatformChange: (next, event) => dispatch(next, createActionDetails(event, { reason: "platform" }))
|
|
48
|
+
});
|
|
49
|
+
return {
|
|
50
|
+
optimistic,
|
|
51
|
+
pending,
|
|
52
|
+
disabled,
|
|
53
|
+
shownIndeterminate,
|
|
54
|
+
ref: useMergedRefs(inputRef, field.ref),
|
|
55
|
+
libraryProps: {
|
|
56
|
+
...fieldInputProps(field),
|
|
57
|
+
type: "checkbox",
|
|
58
|
+
...role !== void 0 && { role },
|
|
59
|
+
checked: optimistic,
|
|
60
|
+
defaultChecked: void 0,
|
|
61
|
+
...mixed && { indeterminate: void 0 },
|
|
62
|
+
"aria-checked": void 0,
|
|
63
|
+
disabled,
|
|
64
|
+
"data-checked": dataAttr(optimistic),
|
|
65
|
+
...mixed && { "data-indeterminate": dataAttr(shownIndeterminate) },
|
|
66
|
+
"data-pending": dataAttr(pending),
|
|
67
|
+
"data-disabled": dataAttr(disabled),
|
|
68
|
+
onChange: (event) => {
|
|
69
|
+
if (disabled) return;
|
|
70
|
+
const nativeEvent = event.nativeEvent;
|
|
71
|
+
guardCheckableChange(nativeEvent, () => dispatch(!optimistic, createActionDetails(nativeEvent, { reason: "activate" })), component);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
//#endregion
|
|
77
|
+
export { useCheckableInput };
|
|
78
|
+
|
|
79
|
+
//# sourceMappingURL=use-checkable-input.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-checkable-input.mjs","names":[],"sources":["../../src/internal/use-checkable-input.ts"],"sourcesContent":["\"use client\";\nimport type { ChangeEvent, ComponentPropsWithRef, Ref } from \"react\";\nimport { createActionDetails } from \"./action-details.js\";\nimport { dataAttr } from \"./data-attr.js\";\nimport type { DataAttributes } from \"./render-element.js\";\nimport type { ActionDetails, ChangeAction, ChangeReason } from \"./types.js\";\nimport { useControllableAction } from \"./use-controllable-action.js\";\nimport { fieldInputProps, useFieldControl, useFieldValueChange } from \"./use-field-control.js\";\nimport { useMergedRefs } from \"./use-merged-refs.js\";\nimport { guardCheckableChange, useNativeChecked } from \"./use-native-checked.js\";\n\n/** The details shape `Checkbox` and `Switch` share (each declares its own public name). */\nexport interface CheckableChangeDetails extends ActionDetails {\n readonly reason: ChangeReason;\n}\n\nexport interface UseCheckableInputOptions {\n /** Warning tag and dispatch-guard name. */\n readonly component: \"Checkbox\" | \"Switch\";\n readonly checked: boolean | undefined;\n readonly defaultChecked: boolean | undefined;\n readonly checkedChangeAction: ChangeAction<boolean, CheckableChangeDetails> | undefined;\n /** The `disabled` prop. */\n readonly disabled: boolean | undefined;\n /** The control's own `name` / `required` / `id` (the Field's \"own or the Field's\"). */\n readonly own: Pick<ComponentPropsWithRef<\"input\">, \"name\" | \"required\" | \"id\">;\n /** View Transition types of a dispatch of `next`. */\n readonly transitionTypes: (next: boolean) => readonly string[];\n /** Switch only: the owned `role`. */\n readonly role?: \"switch\" | undefined;\n /** Checkbox only: the `indeterminate` prop. `undefined` for a control with no mixed state. */\n readonly indeterminate?: boolean | undefined;\n}\n\nexport interface CheckableInput {\n readonly optimistic: boolean;\n readonly pending: boolean;\n /** Own `disabled` or the Field's. */\n readonly disabled: boolean;\n /** `indeterminate && !pending`. */\n readonly shownIndeterminate: boolean;\n readonly ref: Ref<HTMLInputElement> | undefined;\n /** The owned layer (conventions 1.2) of the input. */\n readonly libraryProps: Partial<ComponentPropsWithRef<\"input\">> & DataAttributes;\n}\n\n/**\n * The single-checkbox machinery `Checkbox` and `Switch` share: the Field wiring, the\n * controllable action, the native `checked` re-apply and reconciliation (`useNativeChecked`),\n * and the input's owned layer. The components keep their props, state, `useRender` call and\n * transition boundary.\n */\nexport function useCheckableInput(options: UseCheckableInputOptions): CheckableInput {\n const {\n component,\n checked,\n defaultChecked,\n checkedChangeAction,\n disabled: disabledProp,\n own,\n transitionTypes,\n role,\n indeterminate,\n } = options;\n // Inside a Field.Root (design/components/field-form.md 7.2) the Field owns the id and the ARIA\n // wiring, and `name` / `required` / `disabled` default from it.\n const field = useFieldControl({\n labelable: true,\n name: own.name,\n disabled: disabledProp,\n required: own.required,\n id: own.id,\n component,\n });\n const disabled = field.disabled;\n\n const { optimistic, pending, dispatch, latestInFlight } = useControllableAction<\n boolean,\n CheckableChangeDetails\n >({\n controlled: checked,\n defaultValue: defaultChecked,\n initialValue: false,\n action: checkedChangeAction,\n transitionTypes,\n warn: { component, prop: \"checked\" },\n });\n // Inside a Field: a value React writes with no event (a rejected action rolling back, a\n // controlled change) re-reads validity and `validate` after the commit.\n useFieldValueChange(optimistic);\n\n // Suspended while pending (conventions 4.1): the browser clears the property on the click, and\n // the parent may not have recomputed yet. Restored on settle if the parent still says mixed.\n const mixed = indeterminate !== undefined;\n const shownIndeterminate = indeterminate === true && !pending;\n\n const inputRef = useNativeChecked({\n type: \"checkbox\",\n component,\n checked: optimistic,\n // Uncontrolled: the latest prop is the reset target. Controlled: React's mount-time value.\n defaultChecked: checked === undefined ? (defaultChecked ?? false) : undefined,\n indeterminate: mixed ? shownIndeterminate : undefined,\n latestInFlight,\n onPlatformChange: (next, event) =>\n dispatch(next, createActionDetails(event, { reason: \"platform\" })),\n });\n\n const ref = useMergedRefs<HTMLInputElement>(inputRef, field.ref);\n\n const libraryProps = {\n ...fieldInputProps(field),\n type: \"checkbox\",\n ...(role !== undefined && { role }),\n // The DOM state is the optimistic state (conventions 3.2): react-dom restores a controlled\n // input to its props after every event, and only the sync-lane optimistic value survives.\n checked: optimistic,\n defaultChecked: undefined,\n // Not a DOM attribute; `useNativeChecked` sets the property. Owned so a `render` element's\n // own `indeterminate` prop (which react-dom would warn about) is stripped.\n ...(mixed && { indeterminate: undefined }),\n \"aria-checked\": undefined,\n // Owned so that native disabledness, `data-disabled` and the click guard always agree: a\n // `render` element cannot re-enable (`disabled={false}`) or disable the input on its own.\n disabled,\n \"data-checked\": dataAttr(optimistic),\n ...(mixed && { \"data-indeterminate\": dataAttr(shownIndeterminate) }),\n \"data-pending\": dataAttr(pending),\n \"data-disabled\": dataAttr(disabled),\n onChange: (event: ChangeEvent<HTMLInputElement>) => {\n // A natively disabled input fires no click; this covers `render` elements that do not\n // honour `disabled`.\n if (disabled) return;\n const nativeEvent = event.nativeEvent;\n // `indeterminate` plays no part: the platform's rule is \"flip checked, clear mixed\".\n guardCheckableChange(\n nativeEvent,\n () => dispatch(!optimistic, createActionDetails(nativeEvent, { reason: \"activate\" })),\n component,\n );\n },\n };\n\n return { optimistic, pending, disabled, shownIndeterminate, ref, libraryProps };\n}\n"],"mappings":";;;;;;;;;;;;;;AAoDA,SAAgB,kBAAkB,SAAmD;CACnF,MAAM,EACJ,WACA,SACA,gBACA,qBACA,UAAU,cACV,KACA,iBACA,MACA,kBACE;CAGJ,MAAM,QAAQ,gBAAgB;EAC5B,WAAW;EACX,MAAM,IAAI;EACV,UAAU;EACV,UAAU,IAAI;EACd,IAAI,IAAI;EACR;CACF,CAAC;CACD,MAAM,WAAW,MAAM;CAEvB,MAAM,EAAE,YAAY,SAAS,UAAU,mBAAmB,sBAGxD;EACA,YAAY;EACZ,cAAc;EACd,cAAc;EACd,QAAQ;EACR;EACA,MAAM;GAAE;GAAW,MAAM;EAAU;CACrC,CAAC;CAGD,oBAAoB,UAAU;CAI9B,MAAM,QAAQ,kBAAkB,KAAA;CAChC,MAAM,qBAAqB,kBAAkB,QAAQ,CAAC;CAEtD,MAAM,WAAW,iBAAiB;EAChC,MAAM;EACN;EACA,SAAS;EAET,gBAAgB,YAAY,KAAA,IAAa,kBAAkB,QAAS,KAAA;EACpE,eAAe,QAAQ,qBAAqB,KAAA;EAC5C;EACA,mBAAmB,MAAM,UACvB,SAAS,MAAM,oBAAoB,OAAO,EAAE,QAAQ,WAAW,CAAC,CAAC;CACrE,CAAC;CAqCD,OAAO;EAAE;EAAY;EAAS;EAAU;EAAoB,KAnChD,cAAgC,UAAU,MAAM,GAmCE;EAAG,cAAA;GAhC/D,GAAG,gBAAgB,KAAK;GACxB,MAAM;GACN,GAAI,SAAS,KAAA,KAAa,EAAE,KAAK;GAGjC,SAAS;GACT,gBAAgB,KAAA;GAGhB,GAAI,SAAS,EAAE,eAAe,KAAA,EAAU;GACxC,gBAAgB,KAAA;GAGhB;GACA,gBAAgB,SAAS,UAAU;GACnC,GAAI,SAAS,EAAE,sBAAsB,SAAS,kBAAkB,EAAE;GAClE,gBAAgB,SAAS,OAAO;GAChC,iBAAiB,SAAS,QAAQ;GAClC,WAAW,UAAyC;IAGlD,IAAI,UAAU;IACd,MAAM,cAAc,MAAM;IAE1B,qBACE,mBACM,SAAS,CAAC,YAAY,oBAAoB,aAAa,EAAE,QAAQ,WAAW,CAAC,CAAC,GACpF,SACF;GACF;EAG0E;CAAE;AAChF"}
|
|
@@ -1,16 +1,21 @@
|
|
|
1
1
|
"use client";
|
|
2
|
+
import { useSupersededRejection } from "./use-superseded-rejection.mjs";
|
|
2
3
|
import { useLatest } from "./use-latest.mjs";
|
|
3
4
|
import { addTransitionType, startTransition, useCallback, useEffect, useMemo, useOptimistic, useRef, useState, useTransition } from "react";
|
|
4
5
|
//#region src/internal/use-controllable-action.ts
|
|
5
6
|
const isDev = process.env.NODE_ENV !== "production";
|
|
7
|
+
/**
|
|
8
|
+
* What the user intends (conventions 3.8 rule 1): the latest in-flight dispatch's `next`, else
|
|
9
|
+
* `optimistic`. An explicit null check, not `?.next ?? optimistic`, which would drop an in-flight
|
|
10
|
+
* dispatch of a nullish value (a pending reset to "nothing checked"). Handlers and effects only.
|
|
11
|
+
*/
|
|
12
|
+
function intendedValue(latestInFlight, optimistic) {
|
|
13
|
+
const inFlight = latestInFlight();
|
|
14
|
+
return inFlight === null ? optimistic : inFlight.next;
|
|
15
|
+
}
|
|
6
16
|
function capitalize(s) {
|
|
7
17
|
return s.charAt(0).toUpperCase() + s.slice(1);
|
|
8
18
|
}
|
|
9
|
-
/** Reports an error that cannot reach a boundary (conventions 2.4: never swallow). */
|
|
10
|
-
function report(error) {
|
|
11
|
-
if (typeof reportError === "function") reportError(error);
|
|
12
|
-
else console.error(error);
|
|
13
|
-
}
|
|
14
19
|
/**
|
|
15
20
|
* The one place the state model of conventions section 3 is implemented: committed state,
|
|
16
21
|
* optimistic state (`useOptimistic`, reducer form), the component's own transition, the
|
|
@@ -19,9 +24,8 @@ function report(error) {
|
|
|
19
24
|
*/
|
|
20
25
|
function useControllableAction(options) {
|
|
21
26
|
const { controlled, defaultValue, initialValue, action, transitionTypes, reducer, warn } = options;
|
|
22
|
-
const
|
|
23
|
-
const
|
|
24
|
-
if (supersededError !== null) throw supersededError.error;
|
|
27
|
+
const ownCapture = useSupersededRejection();
|
|
28
|
+
const captureSuperseded = options.captureSuperseded ?? ownCapture;
|
|
25
29
|
const [internal, setInternal] = useState(defaultValue === void 0 ? initialValue : defaultValue);
|
|
26
30
|
const isControlled = controlled !== void 0;
|
|
27
31
|
const committed = isControlled ? controlled : internal;
|
|
@@ -32,14 +36,7 @@ function useControllableAction(options) {
|
|
|
32
36
|
count: 0,
|
|
33
37
|
next: void 0
|
|
34
38
|
});
|
|
35
|
-
const mounted = useRef(false);
|
|
36
39
|
useDevWarnings(isControlled, defaultValue !== void 0, warn);
|
|
37
|
-
useEffect(() => {
|
|
38
|
-
mounted.current = true;
|
|
39
|
-
return () => {
|
|
40
|
-
mounted.current = false;
|
|
41
|
-
};
|
|
42
|
-
}, []);
|
|
43
40
|
const props = useLatest({
|
|
44
41
|
committed,
|
|
45
42
|
isControlled,
|
|
@@ -66,13 +63,7 @@ function useControllableAction(options) {
|
|
|
66
63
|
} catch (error) {
|
|
67
64
|
settle();
|
|
68
65
|
if (id === latest.current) throw error;
|
|
69
|
-
|
|
70
|
-
if (hasSupersededError.current) {
|
|
71
|
-
report(error);
|
|
72
|
-
return;
|
|
73
|
-
}
|
|
74
|
-
hasSupersededError.current = true;
|
|
75
|
-
setSupersededError({ error });
|
|
66
|
+
captureSuperseded(error);
|
|
76
67
|
return;
|
|
77
68
|
}
|
|
78
69
|
settle();
|
|
@@ -81,7 +72,8 @@ function useControllableAction(options) {
|
|
|
81
72
|
}, [
|
|
82
73
|
props,
|
|
83
74
|
settle,
|
|
84
|
-
setOptimistic
|
|
75
|
+
setOptimistic,
|
|
76
|
+
captureSuperseded
|
|
85
77
|
]);
|
|
86
78
|
const latestInFlight = useCallback(() => {
|
|
87
79
|
const { count, next } = inFlight.current;
|
|
@@ -132,6 +124,6 @@ function useDevWarnings(isControlled, hasDefault, warn) {
|
|
|
132
124
|
]);
|
|
133
125
|
}
|
|
134
126
|
//#endregion
|
|
135
|
-
export { useControllableAction };
|
|
127
|
+
export { intendedValue, useControllableAction };
|
|
136
128
|
|
|
137
129
|
//# sourceMappingURL=use-controllable-action.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-controllable-action.mjs","names":[],"sources":["../../src/internal/use-controllable-action.ts"],"sourcesContent":["\"use client\";\nimport {\n addTransitionType,\n startTransition,\n useCallback,\n useEffect,\n useMemo,\n useOptimistic,\n useRef,\n useState,\n useTransition,\n} from \"react\";\nimport type { ActionDetails, ChangeAction } from \"./types.js\";\nimport { useLatest } from \"./use-latest.js\";\n\nexport interface UseControllableActionOptions<T, Details extends ActionDetails> {\n /** The controlled prop (`x`). `undefined` means uncontrolled. */\n controlled: T | undefined;\n /** The `defaultX` prop as the consumer passed it; `undefined` when omitted. */\n defaultValue: T | undefined;\n /** Initial uncontrolled value when neither `x` nor `defaultX` is given. */\n initialValue: T;\n /** The `xChangeAction` prop. Awaited inside this hook's transition. */\n action: ChangeAction<T, Details> | undefined;\n /**\n * View Transition types to attach to the commit that ends a dispatch. Receives the previous\n * committed value and the details object (Tabs derives next/prev direction from them).\n */\n transitionTypes?: (next: T, prev: T, details: Details) => readonly string[];\n /**\n * Optimistic reducer (conventions 3.4). Default: replace the value with `next`. Multi-item\n * states (Accordion's open set) pass a reducer keyed by item, reading the item from `details`,\n * so stacked optimistic patches re-base onto a changed committed value.\n */\n reducer?: (prev: T, next: T, details: Details) => T;\n /** Names used in development warnings. */\n warn?: { readonly component: string; readonly prop: string };\n}\n\nexport interface ControllableAction<T, Details extends ActionDetails> {\n /** Committed value (`x ?? internal`). Content regions render this. */\n readonly committed: T;\n /** Optimistic value; trigger parts render this. */\n readonly optimistic: T;\n /** An action dispatched through this hook is in flight. */\n readonly pending: boolean;\n /** Runs the action inside the hook's transition with optimistic feedback. */\n readonly dispatch: (next: T, details: Details) => void;\n /**\n * The `next` of the most recent dispatch while any dispatch's action is still unsettled, else\n * `null`. Lets a component with a browser-owned path (Accordion's find-in-page reveal) build on\n * what the user already intends instead of on the DOM. Read it from handlers and effects only.\n */\n readonly latestInFlight: () => { readonly next: T } | null;\n /**\n * Uncontrolled mode only (a no-op when controlled): writes the committed value without calling\n * the action, without an optimistic step and without a transition. For a component that adopts\n * a default the browser chose (Select with neither `value` nor `defaultValue` takes the first\n * enabled option, design/components/select.md 5). Call it from a layout effect so the write is\n * flushed before paint.\n */\n readonly adopt: (next: T) => void;\n}\n\nconst isDev = process.env.NODE_ENV !== \"production\";\n\nfunction capitalize(s: string): string {\n return s.charAt(0).toUpperCase() + s.slice(1);\n}\n\n/** Reports an error that cannot reach a boundary (conventions 2.4: never swallow). */\nfunction report(error: unknown): void {\n if (typeof reportError === \"function\") reportError(error);\n else console.error(error);\n}\n\n/**\n * The one place the state model of conventions section 3 is implemented: committed state,\n * optimistic state (`useOptimistic`, reducer form), the component's own transition, the\n * post-`await` write of uncontrolled state, the latest-dispatch guard, and the surfacing of\n * superseded rejections (conventions 2.4).\n */\nexport function useControllableAction<T, Details extends ActionDetails = ActionDetails>(\n options: UseControllableActionOptions<T, Details>,\n): ControllableAction<T, Details> {\n const { controlled, defaultValue, initialValue, action, transitionTypes, reducer, warn } =\n options;\n\n // React keeps only the newest thenable per `useTransition`, so a rejection from a dispatch that\n // was superseded by a later one would be dropped entirely (no boundary, no `reportError`). The\n // hook catches those itself, keeps the first, and throws it from render so it reaches the same\n // nearest Error Boundary as the latest dispatch's rejection does through React.\n //\n // The throw sits before `useTransition` on purpose: React retries an errored render with every\n // pending lane, and in that retry `useTransition` unwraps the still-pending action thenable and\n // suspends, which would hold the boundary commit until the newer action settles.\n const [supersededError, setSupersededError] = useState<{ readonly error: unknown } | null>(null);\n const hasSupersededError = useRef(false);\n if (supersededError !== null) throw supersededError.error;\n\n const [internal, setInternal] = useState<T>(\n defaultValue === undefined ? initialValue : defaultValue,\n );\n const isControlled = controlled !== undefined;\n const committed = isControlled ? controlled : internal;\n const [optimistic, setOptimistic] = useOptimistic(\n committed,\n (prev: T, patch: { next: T; details: Details }) =>\n reducer ? reducer(prev, patch.next, patch.details) : patch.next,\n );\n const [pending, startOwnTransition] = useTransition();\n const latest = useRef(0);\n const inFlight = useRef<{ count: number; next: T | undefined }>({ count: 0, next: undefined });\n const mounted = useRef(false);\n\n useDevWarnings(isControlled, defaultValue !== undefined, warn);\n\n useEffect(() => {\n mounted.current = true;\n return () => {\n mounted.current = false;\n };\n }, []);\n\n // The functions below keep one identity for the hook's lifetime, so the returned object changes\n // only with `committed`, `optimistic` and `pending`, and the components' memoised context values\n // are reused across renders that change none of them (#48). They read the props of the last\n // committed render through `props`; they run from handlers, actions and effects, never render.\n const props = useLatest({ committed, isControlled, action, transitionTypes });\n\n const settle = useCallback((): void => {\n inFlight.current.count -= 1;\n if (inFlight.current.count === 0) inFlight.current.next = undefined;\n }, []);\n\n const dispatch = useCallback(\n (next: T, details: Details): void => {\n // Read once, at the call, as the per-render closure did: the action, the mode and the\n // previous value belong to the UI the user acted on, even after the `await`.\n const { committed: prev, isControlled, action, transitionTypes } = props.current;\n const id = ++latest.current;\n inFlight.current.count += 1;\n inFlight.current.next = next;\n startOwnTransition(async () => {\n for (const type of transitionTypes?.(next, prev, details) ?? []) addTransitionType(type);\n setOptimistic({ next, details });\n try {\n await action?.(next, details);\n } catch (error) {\n settle();\n // The latest dispatch's rejection takes React's own route to the boundary.\n if (id === latest.current) throw error;\n // Nothing to throw to once unmounted (React drops its own thenables the same way).\n if (!mounted.current) return;\n if (hasSupersededError.current) {\n // One boundary reset per burst is enough; later errors are still reported.\n report(error);\n return;\n }\n hasSupersededError.current = true;\n // Outside the transition by now (after an await), so this is an urgent update: the\n // owner re-renders promptly and throws.\n setSupersededError({ error });\n return;\n }\n settle();\n if (!isControlled && id === latest.current) {\n startTransition(() => setInternal(next));\n }\n });\n },\n [props, settle, setOptimistic],\n );\n\n const latestInFlight = useCallback((): { readonly next: T } | null => {\n const { count, next } = inFlight.current;\n return count > 0 ? { next: next as T } : null;\n }, []);\n\n const adopt = useCallback(\n (next: T): void => {\n if (!props.current.isControlled) setInternal(next);\n },\n [props],\n );\n\n return useMemo(\n () => ({ committed, optimistic, pending, dispatch, latestInFlight, adopt }),\n [committed, optimistic, pending, dispatch, latestInFlight, adopt],\n );\n}\n\nfunction useDevWarnings(\n isControlled: boolean,\n hasDefault: boolean,\n warn: { readonly component: string; readonly prop: string } | undefined,\n): void {\n const initialMode = useRef(isControlled);\n const warnedBoth = useRef(false);\n const warnedSwitch = useRef(false);\n const component = warn?.component ?? \"A component\";\n const prop = warn?.prop ?? \"value\";\n\n useEffect(() => {\n if (!isDev) return;\n const defaultProp = `default${capitalize(prop)}`;\n\n if (isControlled && hasDefault && !warnedBoth.current) {\n warnedBoth.current = true;\n console.error(\n `${component}: both \\`${prop}\\` and \\`${defaultProp}\\` are set. ` +\n `Use \\`${prop}\\` for controlled mode or \\`${defaultProp}\\` for uncontrolled mode, not both.`,\n );\n }\n\n if (initialMode.current !== isControlled && !warnedSwitch.current) {\n warnedSwitch.current = true;\n const from = initialMode.current ? \"controlled\" : \"uncontrolled\";\n const to = isControlled ? \"controlled\" : \"uncontrolled\";\n console.error(\n `${component}: \\`${prop}\\` changed from ${from} to ${to}. Switching modes after mount ` +\n `is not supported; keep \\`${prop}\\` either always defined or always undefined.`,\n );\n }\n }, [component, prop, isControlled, hasDefault]);\n}\n"],"mappings":"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"}
|
|
1
|
+
{"version":3,"file":"use-controllable-action.mjs","names":[],"sources":["../../src/internal/use-controllable-action.ts"],"sourcesContent":["\"use client\";\nimport {\n addTransitionType,\n startTransition,\n useCallback,\n useEffect,\n useMemo,\n useOptimistic,\n useRef,\n useState,\n useTransition,\n} from \"react\";\nimport type { ActionDetails, ChangeAction } from \"./types.js\";\nimport { useLatest } from \"./use-latest.js\";\nimport { useSupersededRejection } from \"./use-superseded-rejection.js\";\n\nexport interface UseControllableActionOptions<T, Details extends ActionDetails> {\n /** The controlled prop (`x`). `undefined` means uncontrolled. */\n controlled: T | undefined;\n /** The `defaultX` prop as the consumer passed it; `undefined` when omitted. */\n defaultValue: T | undefined;\n /** Initial uncontrolled value when neither `x` nor `defaultX` is given. */\n initialValue: T;\n /** The `xChangeAction` prop. Awaited inside this hook's transition. */\n action: ChangeAction<T, Details> | undefined;\n /**\n * View Transition types to attach to the commit that ends a dispatch. Receives the previous\n * committed value and the details object (Tabs derives next/prev direction from them).\n */\n transitionTypes?: (next: T, prev: T, details: Details) => readonly string[];\n /**\n * Optimistic reducer (conventions 3.4). Default: replace the value with `next`. Multi-item\n * states (Accordion's open set) pass a reducer keyed by item, reading the item from `details`,\n * so stacked optimistic patches re-base onto a changed committed value.\n */\n reducer?: (prev: T, next: T, details: Details) => T;\n /** Names used in development warnings. */\n warn?: { readonly component: string; readonly prop: string };\n /**\n * A component with two transition channels (Slider, NumberField) passes one\n * `useSupersededRejection()` called before both hooks, so a superseded rejection of either\n * channel is thrown before both `useTransition`s and never waits for the other channel's\n * pending action. Stable. Default: the hook's own.\n */\n readonly captureSuperseded?: ((error: unknown) => void) | undefined;\n}\n\nexport interface ControllableAction<T, Details extends ActionDetails> {\n /** Committed value (`x ?? internal`). Content regions render this. */\n readonly committed: T;\n /** Optimistic value; trigger parts render this. */\n readonly optimistic: T;\n /** An action dispatched through this hook is in flight. */\n readonly pending: boolean;\n /** Runs the action inside the hook's transition with optimistic feedback. */\n readonly dispatch: (next: T, details: Details) => void;\n /**\n * The `next` of the most recent dispatch while any dispatch's action is still unsettled, else\n * `null`. Lets a component with a browser-owned path (Accordion's find-in-page reveal) build on\n * what the user already intends instead of on the DOM. Read it from handlers and effects only.\n */\n readonly latestInFlight: () => { readonly next: T } | null;\n /**\n * Uncontrolled mode only (a no-op when controlled): writes the committed value without calling\n * the action, without an optimistic step and without a transition. For a component that adopts\n * a default the browser chose (Select with neither `value` nor `defaultValue` takes the first\n * enabled option, design/components/select.md 5). Call it from a layout effect so the write is\n * flushed before paint.\n */\n readonly adopt: (next: T) => void;\n}\n\nconst isDev = process.env.NODE_ENV !== \"production\";\n\n/**\n * What the user intends (conventions 3.8 rule 1): the latest in-flight dispatch's `next`, else\n * `optimistic`. An explicit null check, not `?.next ?? optimistic`, which would drop an in-flight\n * dispatch of a nullish value (a pending reset to \"nothing checked\"). Handlers and effects only.\n */\nexport function intendedValue<T>(\n latestInFlight: () => { readonly next: T } | null,\n optimistic: T,\n): T {\n const inFlight = latestInFlight();\n return inFlight === null ? optimistic : inFlight.next;\n}\n\nfunction capitalize(s: string): string {\n return s.charAt(0).toUpperCase() + s.slice(1);\n}\n\n/**\n * The one place the state model of conventions section 3 is implemented: committed state,\n * optimistic state (`useOptimistic`, reducer form), the component's own transition, the\n * post-`await` write of uncontrolled state, the latest-dispatch guard, and the surfacing of\n * superseded rejections (conventions 2.4).\n */\nexport function useControllableAction<T, Details extends ActionDetails = ActionDetails>(\n options: UseControllableActionOptions<T, Details>,\n): ControllableAction<T, Details> {\n const { controlled, defaultValue, initialValue, action, transitionTypes, reducer, warn } =\n options;\n\n // Before `useTransition` on purpose (see the hook). Unused (never throws) with an external one.\n const ownCapture = useSupersededRejection();\n const captureSuperseded = options.captureSuperseded ?? ownCapture;\n\n const [internal, setInternal] = useState<T>(\n defaultValue === undefined ? initialValue : defaultValue,\n );\n const isControlled = controlled !== undefined;\n const committed = isControlled ? controlled : internal;\n const [optimistic, setOptimistic] = useOptimistic(\n committed,\n (prev: T, patch: { next: T; details: Details }) =>\n reducer ? reducer(prev, patch.next, patch.details) : patch.next,\n );\n const [pending, startOwnTransition] = useTransition();\n const latest = useRef(0);\n const inFlight = useRef<{ count: number; next: T | undefined }>({ count: 0, next: undefined });\n\n useDevWarnings(isControlled, defaultValue !== undefined, warn);\n\n // The functions below keep one identity for the hook's lifetime, so the returned object changes\n // only with `committed`, `optimistic` and `pending`, and the components' memoised context values\n // are reused across renders that change none of them. They read the props of the last\n // committed render through `props`; they run from handlers, actions and effects, never render.\n const props = useLatest({ committed, isControlled, action, transitionTypes });\n\n const settle = useCallback((): void => {\n inFlight.current.count -= 1;\n if (inFlight.current.count === 0) inFlight.current.next = undefined;\n }, []);\n\n const dispatch = useCallback(\n (next: T, details: Details): void => {\n // Read once, at the call, as the per-render closure did: the action, the mode and the\n // previous value belong to the UI the user acted on, even after the `await`.\n const { committed: prev, isControlled, action, transitionTypes } = props.current;\n const id = ++latest.current;\n inFlight.current.count += 1;\n inFlight.current.next = next;\n startOwnTransition(async () => {\n for (const type of transitionTypes?.(next, prev, details) ?? []) addTransitionType(type);\n setOptimistic({ next, details });\n try {\n await action?.(next, details);\n } catch (error) {\n settle();\n // The latest dispatch's rejection takes React's own route to the boundary.\n if (id === latest.current) throw error;\n captureSuperseded(error);\n return;\n }\n settle();\n if (!isControlled && id === latest.current) {\n startTransition(() => setInternal(next));\n }\n });\n },\n [props, settle, setOptimistic, captureSuperseded],\n );\n\n const latestInFlight = useCallback((): { readonly next: T } | null => {\n const { count, next } = inFlight.current;\n return count > 0 ? { next: next as T } : null;\n }, []);\n\n const adopt = useCallback(\n (next: T): void => {\n if (!props.current.isControlled) setInternal(next);\n },\n [props],\n );\n\n return useMemo(\n () => ({ committed, optimistic, pending, dispatch, latestInFlight, adopt }),\n [committed, optimistic, pending, dispatch, latestInFlight, adopt],\n );\n}\n\nfunction useDevWarnings(\n isControlled: boolean,\n hasDefault: boolean,\n warn: { readonly component: string; readonly prop: string } | undefined,\n): void {\n const initialMode = useRef(isControlled);\n const warnedBoth = useRef(false);\n const warnedSwitch = useRef(false);\n const component = warn?.component ?? \"A component\";\n const prop = warn?.prop ?? \"value\";\n\n useEffect(() => {\n if (!isDev) return;\n const defaultProp = `default${capitalize(prop)}`;\n\n if (isControlled && hasDefault && !warnedBoth.current) {\n warnedBoth.current = true;\n console.error(\n `${component}: both \\`${prop}\\` and \\`${defaultProp}\\` are set. ` +\n `Use \\`${prop}\\` for controlled mode or \\`${defaultProp}\\` for uncontrolled mode, not both.`,\n );\n }\n\n if (initialMode.current !== isControlled && !warnedSwitch.current) {\n warnedSwitch.current = true;\n const from = initialMode.current ? \"controlled\" : \"uncontrolled\";\n const to = isControlled ? \"controlled\" : \"uncontrolled\";\n console.error(\n `${component}: \\`${prop}\\` changed from ${from} to ${to}. Switching modes after mount ` +\n `is not supported; keep \\`${prop}\\` either always defined or always undefined.`,\n );\n }\n }, [component, prop, isControlled, hasDefault]);\n}\n"],"mappings":"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"}
|
|
@@ -1,20 +1,24 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { useEffect, useRef } from "react";
|
|
3
|
-
//#region src/internal/use-dev-warning.ts
|
|
4
|
-
const isDev = process.env.NODE_ENV !== "production";
|
|
5
3
|
/**
|
|
6
4
|
* Logs `message` through `console.error` once per component instance, the first time
|
|
7
5
|
* `condition` is true. Runs in an effect (never during render) so the warning cannot fire for a
|
|
8
6
|
* render that is discarded.
|
|
7
|
+
*
|
|
8
|
+
* Pass the message as `isDev && "..."` with the calling module's own `isDev` constant: the text
|
|
9
|
+
* then folds away in a production build (`src/__tests__/production-bundle.test.ts` checks it).
|
|
10
|
+
* In production the hook is a no-op.
|
|
9
11
|
*/
|
|
10
|
-
|
|
12
|
+
const useDevWarning = process.env.NODE_ENV !== "production" ? useDevWarningDev : noop;
|
|
13
|
+
function useDevWarningDev(condition, message) {
|
|
11
14
|
const warned = useRef(false);
|
|
12
15
|
useEffect(() => {
|
|
13
|
-
if (!
|
|
16
|
+
if (!condition || message === false || warned.current) return;
|
|
14
17
|
warned.current = true;
|
|
15
18
|
console.error(message);
|
|
16
19
|
}, [condition, message]);
|
|
17
20
|
}
|
|
21
|
+
function noop() {}
|
|
18
22
|
//#endregion
|
|
19
23
|
export { useDevWarning };
|
|
20
24
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-dev-warning.mjs","names":[],"sources":["../../src/internal/use-dev-warning.ts"],"sourcesContent":["\"use client\";\nimport { useEffect, useRef } from \"react\";\n\nconst isDev = process.env.NODE_ENV !== \"production\";\n\n/**\n * Logs `message` through `console.error` once per component instance, the first time\n * `condition` is true. Runs in an effect (never during render) so the warning cannot fire for a\n * render that is discarded.\n */\nexport
|
|
1
|
+
{"version":3,"file":"use-dev-warning.mjs","names":[],"sources":["../../src/internal/use-dev-warning.ts"],"sourcesContent":["\"use client\";\nimport { useEffect, useRef } from \"react\";\n\nconst isDev = process.env.NODE_ENV !== \"production\";\n\n/**\n * Logs `message` through `console.error` once per component instance, the first time\n * `condition` is true. Runs in an effect (never during render) so the warning cannot fire for a\n * render that is discarded.\n *\n * Pass the message as `isDev && \"...\"` with the calling module's own `isDev` constant: the text\n * then folds away in a production build (`src/__tests__/production-bundle.test.ts` checks it).\n * In production the hook is a no-op.\n */\nexport const useDevWarning: (condition: boolean, message: string | false) => void = isDev\n ? useDevWarningDev\n : noop;\n\nfunction useDevWarningDev(condition: boolean, message: string | false): void {\n const warned = useRef(false);\n useEffect(() => {\n if (!condition || message === false || warned.current) return;\n warned.current = true;\n console.error(message);\n }, [condition, message]);\n}\n\nfunction noop(): void {}\n"],"mappings":";;;;;;;;;;;AAcA,MAAa,gBAXC,QAAQ,IAAI,aAAa,eAYnC,mBACA;AAEJ,SAAS,iBAAiB,WAAoB,SAA+B;CAC3E,MAAM,SAAS,OAAO,KAAK;CAC3B,gBAAgB;EACd,IAAI,CAAC,aAAa,YAAY,SAAS,OAAO,SAAS;EACvD,OAAO,UAAU;EACjB,QAAQ,MAAM,OAAO;CACvB,GAAG,CAAC,WAAW,OAAO,CAAC;AACzB;AAEA,SAAS,OAAa,CAAC"}
|