@funstack/ui 0.1.0-alpha.11 → 0.1.0-alpha.13
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 +6 -5
- package/dist/combobox/combobox-input.d.mts.map +1 -1
- package/dist/combobox/combobox-input.mjs +29 -14
- 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 +101 -106
- package/dist/combobox/combobox-root.mjs.map +1 -1
- package/dist/combobox/combobox-trigger.d.mts +9 -6
- package/dist/combobox/combobox-trigger.d.mts.map +1 -1
- package/dist/combobox/combobox-trigger.mjs +36 -43
- 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 +5 -5
- package/dist/dialog/dialog-popup.d.mts.map +1 -1
- package/dist/dialog/dialog-popup.mjs +39 -103
- 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 +2 -1
- package/dist/dialog/dialog-trigger.d.mts.map +1 -1
- package/dist/dialog/dialog-trigger.mjs +27 -23
- 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 +22 -42
- 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 +4 -42
- 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 +16 -7
- 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/pointer-capture.mjs +20 -0
- package/dist/internal/pointer-capture.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/trigger-ref.mjs +26 -0
- package/dist/internal/trigger-ref.mjs.map +1 -0
- 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} +32 -39
- package/dist/internal/use-overlay-root.mjs.map +1 -0
- package/dist/internal/use-popover-popup.mjs +38 -80
- 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 +28 -24
- 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 +11 -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 +2 -17
- package/dist/menu/menu-dom.mjs.map +1 -1
- package/dist/menu/menu-gestures.mjs +166 -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 +38 -248
- package/dist/menu/menu-popup.mjs.map +1 -1
- package/dist/menu/menu-radio-group.mjs.map +1 -1
- package/dist/menu/menu-radio-item.d.mts +2 -0
- package/dist/menu/menu-radio-item.d.mts.map +1 -1
- package/dist/menu/menu-radio-item.mjs +1 -0
- package/dist/menu/menu-radio-item.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 +12 -9
- package/dist/menu/menu-submenu-trigger.mjs.map +1 -1
- package/dist/menu/menu-trigger.d.mts +10 -11
- package/dist/menu/menu-trigger.d.mts.map +1 -1
- package/dist/menu/menu-trigger.mjs +14 -7
- 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 +3 -2
- 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 +10 -10
- package/dist/popover/popover-trigger.d.mts.map +1 -1
- package/dist/popover/popover-trigger.mjs +4 -2
- 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-root.d.mts.map +1 -1
- package/dist/toast/toast-root.mjs +2 -0
- package/dist/toast/toast-root.mjs.map +1 -1
- 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 +7 -3
- package/dist/toggle-group/toggle-group-item.d.mts.map +1 -1
- package/dist/toggle-group/toggle-group-item.mjs +6 -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,19 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useSyncExternalStore } from "react";
|
|
3
|
+
//#region src/internal/use-native-focusgroup.ts
|
|
4
|
+
/** Engine capabilities never change while the page lives. */
|
|
5
|
+
const subscribeNever = () => () => {};
|
|
6
|
+
/**
|
|
7
|
+
* Whether the native `focusgroup` path is on: the `experimental_focusgroup` flag is set and the
|
|
8
|
+
* engine implements it. Detected only with the flag, and never during SSR or hydration
|
|
9
|
+
* (conventions 8): the server snapshot is `false`, so hydration markup matches the server and
|
|
10
|
+
* React re-renders with the client answer afterwards. The IDL attribute is camel-cased
|
|
11
|
+
* `focusGroup` (`"focusgroup" in HTMLElement.prototype` is always false).
|
|
12
|
+
*/
|
|
13
|
+
function useNativeFocusgroup(flag) {
|
|
14
|
+
return useSyncExternalStore(subscribeNever, () => flag && "focusGroup" in HTMLElement.prototype, () => false);
|
|
15
|
+
}
|
|
16
|
+
//#endregion
|
|
17
|
+
export { useNativeFocusgroup };
|
|
18
|
+
|
|
19
|
+
//# sourceMappingURL=use-native-focusgroup.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-native-focusgroup.mjs","names":[],"sources":["../../src/internal/use-native-focusgroup.ts"],"sourcesContent":["\"use client\";\nimport { useSyncExternalStore } from \"react\";\n\n/** Engine capabilities never change while the page lives. */\nconst subscribeNever = () => () => {};\n\n/**\n * Whether the native `focusgroup` path is on: the `experimental_focusgroup` flag is set and the\n * engine implements it. Detected only with the flag, and never during SSR or hydration\n * (conventions 8): the server snapshot is `false`, so hydration markup matches the server and\n * React re-renders with the client answer afterwards. The IDL attribute is camel-cased\n * `focusGroup` (`\"focusgroup\" in HTMLElement.prototype` is always false).\n */\nexport function useNativeFocusgroup(flag: boolean): boolean {\n return useSyncExternalStore(\n subscribeNever,\n () => flag && \"focusGroup\" in HTMLElement.prototype,\n () => false,\n );\n}\n"],"mappings":";;;;AAIA,MAAM,6BAA6B,CAAC;;;;;;;;AASpC,SAAgB,oBAAoB,MAAwB;CAC1D,OAAO,qBACL,sBACM,QAAQ,gBAAgB,YAAY,iBACpC,KACR;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-native-group-reconciliation.mjs","names":[],"sources":["../../src/internal/use-native-group-reconciliation.ts"],"sourcesContent":["\"use client\";\nimport { useCallback, useEffectEvent, useLayoutEffect, useRef } from \"react\";\nimport type { RefObject } from \"react\";\nimport { useFormReset } from \"./use-form-reset.js\";\nimport type { FormAssociatedElement } from \"./use-form-
|
|
1
|
+
{"version":3,"file":"use-native-group-reconciliation.mjs","names":[],"sources":["../../src/internal/use-native-group-reconciliation.ts"],"sourcesContent":["\"use client\";\nimport { useCallback, useEffectEvent, useLayoutEffect, useRef } from \"react\";\nimport type { RefObject } from \"react\";\nimport { useFormReset } from \"./use-form-reset.js\";\nimport type { FormAssociatedElement } from \"./use-form-owner-event.js\";\nimport { useLatest } from \"./use-latest.js\";\n\nexport interface UseNativeGroupReconciliationOptions<T> {\n /**\n * The group's form-associated element: `RadioGroup.Root`'s / `CheckboxGroup.Root`'s\n * `<fieldset>`, `Select.Root`'s `<select>` (whose options are the members), or any member\n * input when the Root renders no form-associated element (`Slider.Root` subscribes through its\n * first Thumb's `<input type=\"range\">`).\n */\n readonly element: RefObject<FormAssociatedElement | null>;\n /** The group's value as the DOM shows it now (`checked` of the members). */\n readonly readCurrent: () => T;\n /** The value the browser resets the group to (`defaultChecked` of the members, rule 5). */\n readonly readDefault: () => T;\n /**\n * What the user intends (rule 1): the latest in-flight dispatch's `next`, else the optimistic\n * value. `intendedValue` (use-controllable-action.ts) keeps an in-flight dispatch of a nullish\n * value (a pending reset to \"nothing checked\"), which `?.next ?? optimistic` would drop.\n */\n readonly base: () => T;\n /**\n * The browser changed the group's value on a residual path and it differs from `base()`.\n * `event` is the `reset` event, or `undefined` for mount reconciliation (the Root's mount, or a\n * member mounting later). The Root dispatches once for the whole group with\n * `reason: \"platform\"`.\n */\n readonly onPlatformChange: (next: T, event: Event | undefined) => void;\n /**\n * Equality between a read value and `base()`. Default `Object.is`, right for a primitive value\n * (RadioGroup's `string | null`); a group with a collection value (CheckboxGroup's\n * `ReadonlySet<string>`) passes structural equality, since every read builds a new object.\n */\n readonly equals?: ((a: T, b: T) => boolean) | undefined;\n /**\n * Passed through to `useFormReset`: called synchronously from the `reset` event, before the\n * reset algorithm runs. A group of controlled **value** inputs (Slider) writes each input's\n * `defaultValue` to the reset target here, because react-dom keeps that attribute equal to the\n * current value after every update (conventions 3.8 rule 6).\n */\n readonly onResetEvent?: ((event: Event) => void) | undefined;\n}\n\nexport interface UseNativeGroupReconciliationResult {\n /**\n * Stable. Pass it to every member, which hands it to\n * `useNativeChecked({ group: true, onItemMounted })`; the hook calls it from the member's mount\n * layout effect. A member that mounts after the Root's own mount reconciliation (inside a\n * Suspense boundary that hydrates later, selective hydration, or a member added on the client)\n * makes the adapter reconcile the group again: `readCurrent()` vs `base()`, in a microtask, once\n * for all members mounted in the same commit. Members mounting in the Root's own commit are\n * covered by the Root's mount reconciliation (their effects run before the Root's) and are\n * ignored. The member's element argument is not used here; the Root may use it (dev warnings).\n */\n readonly onItemMounted: (element?: Element | null) => void;\n}\n\n/**\n * Group adapter of the native-input machinery (conventions 3.8): one dispatch per group for the\n * residual browser paths, from the Root rather than once per member.\n *\n * - Mount reconciliation, once, in a layout effect: `readCurrent()` vs `base()`. The members'\n * `useNativeChecked({ group: true })` leaves `checked` alone in their mount commit, so this\n * effect, which runs after the members' (children first), still reads the hydrated DOM.\n * - Late members: a member mounting in a later commit (a Suspense boundary that hydrates after the\n * Root, where a click before hydration changed the DOM) reports through `onItemMounted`, and the\n * group is reconciled again the same way (see `UseNativeGroupReconciliationResult`).\n * - Form reset through `useFormReset` on the container: in a microtask after the reset,\n * `readDefault()` vs `base()`.\n *\n * Values are compared with `equals` (default `Object.is`).\n */\nexport function useNativeGroupReconciliation<T>(\n options: UseNativeGroupReconciliationOptions<T>,\n): UseNativeGroupReconciliationResult {\n const { element } = options;\n\n // The latest committed options, for the late reconciliation, which runs in a microtask outside\n // any effect (so it cannot go through an Effect Event).\n const latest = useLatest(options);\n\n /** The Root's own mount reconciliation has run (reset by its cleanup, StrictMode included). */\n const rootReconciled = useRef(false);\n /** A late reconciliation is queued; members mounting in the same commit share it. */\n const lateQueued = useRef(false);\n\n const reconcileMount = useEffectEvent(() => {\n if (element.current === null) return;\n reconcile(options, options.readCurrent());\n });\n useLayoutEffect(() => {\n reconcileMount();\n rootReconciled.current = true;\n return () => {\n rootReconciled.current = false;\n };\n }, []);\n\n const onItemMounted = useCallback(() => {\n if (!rootReconciled.current || lateQueued.current) return;\n lateQueued.current = true;\n queueMicrotask(() => {\n lateQueued.current = false;\n if (!rootReconciled.current) return;\n const current = latest.current;\n if (current.element.current === null) return;\n reconcile(current, current.readCurrent());\n });\n }, [latest]);\n\n useFormReset(\n element,\n (event) => {\n if (element.current === null) return;\n reconcile(options, options.readDefault(), event);\n },\n (event) => {\n if (element.current === null) return;\n options.onResetEvent?.(event);\n },\n );\n\n return { onItemMounted };\n}\n\nfunction reconcile<T>(options: UseNativeGroupReconciliationOptions<T>, next: T, event?: Event) {\n const equals = options.equals ?? Object.is;\n if (!equals(next, options.base())) options.onPlatformChange(next, event);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AA4EA,SAAgB,6BACd,SACoC;CACpC,MAAM,EAAE,YAAY;CAIpB,MAAM,SAAS,UAAU,OAAO;;CAGhC,MAAM,iBAAiB,OAAO,KAAK;;CAEnC,MAAM,aAAa,OAAO,KAAK;CAE/B,MAAM,iBAAiB,qBAAqB;EAC1C,IAAI,QAAQ,YAAY,MAAM;EAC9B,UAAU,SAAS,QAAQ,YAAY,CAAC;CAC1C,CAAC;CACD,sBAAsB;EACpB,eAAe;EACf,eAAe,UAAU;EACzB,aAAa;GACX,eAAe,UAAU;EAC3B;CACF,GAAG,CAAC,CAAC;CAEL,MAAM,gBAAgB,kBAAkB;EACtC,IAAI,CAAC,eAAe,WAAW,WAAW,SAAS;EACnD,WAAW,UAAU;EACrB,qBAAqB;GACnB,WAAW,UAAU;GACrB,IAAI,CAAC,eAAe,SAAS;GAC7B,MAAM,UAAU,OAAO;GACvB,IAAI,QAAQ,QAAQ,YAAY,MAAM;GACtC,UAAU,SAAS,QAAQ,YAAY,CAAC;EAC1C,CAAC;CACH,GAAG,CAAC,MAAM,CAAC;CAEX,aACE,UACC,UAAU;EACT,IAAI,QAAQ,YAAY,MAAM;EAC9B,UAAU,SAAS,QAAQ,YAAY,GAAG,KAAK;CACjD,IACC,UAAU;EACT,IAAI,QAAQ,YAAY,MAAM;EAC9B,QAAQ,eAAe,KAAK;CAC9B,CACF;CAEA,OAAO,EAAE,cAAc;AACzB;AAEA,SAAS,UAAa,SAAiD,MAAS,OAAe;CAE7F,IAAI,EADW,QAAQ,UAAU,OAAO,GAAA,CAC5B,MAAM,QAAQ,KAAK,CAAC,GAAG,QAAQ,iBAAiB,MAAM,KAAK;AACzE"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { dataAttr } from "./data-attr.mjs";
|
|
3
|
+
import { useActionTrigger } from "./use-action-trigger.mjs";
|
|
4
|
+
import { disabledButton, rendersButton } from "./render-element.mjs";
|
|
5
|
+
import { useRender } from "./use-render.mjs";
|
|
6
|
+
import { useElementCheck } from "./use-element-check.mjs";
|
|
7
|
+
//#region src/internal/use-overlay-close.ts
|
|
8
|
+
const isDev = process.env.NODE_ENV !== "production";
|
|
9
|
+
/**
|
|
10
|
+
* The Close part of a popover-like or dialog overlay (design/components/popover.md 3.4,
|
|
11
|
+
* dialog.md 3.4): `<button type="button" commandfor command>`. In JS-free mode without `action`
|
|
12
|
+
* the browser runs the command. Otherwise the click is cancelled, refused while disabled, and
|
|
13
|
+
* `close` runs, after the `action` when there is one, inside this part's own transition; a
|
|
14
|
+
* second click meanwhile starts nothing, and a close whose open was superseded by a newer one
|
|
15
|
+
* (dismissed and re-opened meanwhile) is dropped (the open-generation guard).
|
|
16
|
+
*/
|
|
17
|
+
function useOverlayClose(options) {
|
|
18
|
+
const { part, noun, isLibrary, popupId, command, action, disabled, render } = options;
|
|
19
|
+
const { pending, run } = useActionTrigger({ openGeneration: options.openGeneration });
|
|
20
|
+
const installClick = isLibrary || action !== void 0;
|
|
21
|
+
const disabledProps = disabledButton(render, disabled, { handlesClick: installClick });
|
|
22
|
+
const ref = useElementCheck(isDev && ((element) => !installClick && element.tagName !== "BUTTON" ? `${part}: rendered a <${element.tagName.toLowerCase()}> in JS-free mode without \`action\`. Only a <button> runs \`command="${command}"\`; this element will not close the ${noun}.` : null), [installClick]);
|
|
23
|
+
const onClick = (event) => {
|
|
24
|
+
event.preventDefault();
|
|
25
|
+
if (disabled) return;
|
|
26
|
+
const native = event.nativeEvent;
|
|
27
|
+
if (action === void 0) {
|
|
28
|
+
options.close(native);
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
const details = options.details(native);
|
|
32
|
+
run(() => action(details), () => options.close(native));
|
|
33
|
+
};
|
|
34
|
+
const libraryProps = {
|
|
35
|
+
...rendersButton(render) && { type: "button" },
|
|
36
|
+
disabled: disabledProps.props.disabled,
|
|
37
|
+
commandfor: disabledProps.invoker && rendersButton(render) ? popupId : void 0,
|
|
38
|
+
command: disabledProps.invoker && rendersButton(render) ? command : void 0,
|
|
39
|
+
...options.ownProps,
|
|
40
|
+
...installClick && { onClick },
|
|
41
|
+
"aria-disabled": pending || !disabledProps.invoker ? true : void 0,
|
|
42
|
+
"data-pending": dataAttr(pending),
|
|
43
|
+
"data-disabled": dataAttr(disabled)
|
|
44
|
+
};
|
|
45
|
+
return useRender({
|
|
46
|
+
defaultElement: "button",
|
|
47
|
+
render,
|
|
48
|
+
state: {
|
|
49
|
+
pending,
|
|
50
|
+
disabled
|
|
51
|
+
},
|
|
52
|
+
className: options.className,
|
|
53
|
+
style: options.style,
|
|
54
|
+
children: options.children,
|
|
55
|
+
props: options.rest,
|
|
56
|
+
libraryProps,
|
|
57
|
+
ref
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
//#endregion
|
|
61
|
+
export { useOverlayClose };
|
|
62
|
+
|
|
63
|
+
//# sourceMappingURL=use-overlay-close.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-overlay-close.mjs","names":[],"sources":["../../src/internal/use-overlay-close.ts"],"sourcesContent":["\"use client\";\nimport type { ComponentPropsWithRef, CSSProperties, MouseEvent, ReactNode } from \"react\";\nimport { dataAttr } from \"./data-attr.js\";\nimport type { Action, ActionDetails, RenderProp, StateValue } from \"./types.js\";\nimport { useActionTrigger } from \"./use-action-trigger.js\";\nimport { useElementCheck } from \"./use-element-check.js\";\nimport { disabledButton, rendersButton, useRender } from \"./use-render.js\";\nimport type { DataAttributes } from \"./use-render.js\";\n\nconst isDev = process.env.NODE_ENV !== \"production\";\n\n/** The state of Popover.Close and Dialog.Close. */\nexport interface OverlayCloseState {\n /** The `action` is in flight. */\n readonly pending: boolean;\n readonly disabled: boolean;\n}\n\nexport interface OverlayCloseOptions<Details extends ActionDetails> {\n /** Public name of the part (`\"Popover.Close\"`). */\n readonly part: string;\n /** What the part closes, for the development warning (`\"popover\"`). */\n readonly noun: string;\n readonly isLibrary: boolean;\n /** The popup's id (`commandfor`) and the native command. */\n readonly popupId: string;\n readonly command: \"hide-popover\" | \"request-close\";\n readonly openGeneration: () => number;\n readonly action: Action<[details: Details]> | undefined;\n /** The `action`'s details, built at the click. */\n readonly details: (event: Event) => Details;\n /** The close after the action (or at once without one): through the Root, or natively. */\n readonly close: (event: Event) => void;\n /** Owned keys after `command` (Dialog.Close's `value`). */\n readonly ownProps?: ComponentPropsWithRef<\"button\">;\n readonly disabled: boolean;\n readonly className: StateValue<string | undefined, OverlayCloseState> | undefined;\n readonly style: StateValue<CSSProperties | undefined, OverlayCloseState> | undefined;\n readonly children: StateValue<ReactNode, OverlayCloseState> | undefined;\n readonly render: RenderProp<ComponentPropsWithRef<\"button\">, OverlayCloseState> | undefined;\n readonly rest: Omit<ComponentPropsWithRef<\"button\">, \"className\" | \"style\" | \"children\">;\n}\n\n/**\n * The Close part of a popover-like or dialog overlay (design/components/popover.md 3.4,\n * dialog.md 3.4): `<button type=\"button\" commandfor command>`. In JS-free mode without `action`\n * the browser runs the command. Otherwise the click is cancelled, refused while disabled, and\n * `close` runs, after the `action` when there is one, inside this part's own transition; a\n * second click meanwhile starts nothing, and a close whose open was superseded by a newer one\n * (dismissed and re-opened meanwhile) is dropped (the open-generation guard).\n */\nexport function useOverlayClose<Details extends ActionDetails>(\n options: OverlayCloseOptions<Details>,\n): ReactNode {\n const { part, noun, isLibrary, popupId, command, action, disabled, render } = options;\n const { pending, run } = useActionTrigger({ openGeneration: options.openGeneration });\n const installClick = isLibrary || action !== undefined;\n // JS-free mode without `action` is the browser's command, which only native `disabled` stops.\n const disabledProps = disabledButton(render, disabled, { handlesClick: installClick });\n\n const ref = useElementCheck(\n isDev &&\n ((element) =>\n !installClick && element.tagName !== \"BUTTON\"\n ? `${part}: rendered a <${element.tagName.toLowerCase()}> in JS-free mode without ` +\n `\\`action\\`. Only a <button> runs \\`command=\"${command}\"\\`; this element will not ` +\n `close the ${noun}.`\n : null),\n [installClick],\n );\n\n const onClick = (event: MouseEvent<HTMLElement>) => {\n // Cancelling the click cancels the command.\n event.preventDefault();\n if (disabled) return;\n const native = event.nativeEvent;\n if (action === undefined) {\n options.close(native);\n return;\n }\n const details = options.details(native);\n run(\n () => action(details),\n () => options.close(native),\n );\n };\n\n const libraryProps: ComponentPropsWithRef<\"button\"> & DataAttributes = {\n ...(rendersButton(render) && { type: \"button\" as const }),\n // Owned: a render element must not re-enable a disabled Close.\n disabled: disabledProps.props.disabled,\n // Only on a button (or a component, assumed to render one): another element is no invoker.\n // `disabledProps.invoker` itself stays the availability below.\n commandfor: disabledProps.invoker && rendersButton(render) ? popupId : undefined,\n command: disabledProps.invoker && rendersButton(render) ? command : undefined,\n ...options.ownProps,\n ...(installClick && { onClick }),\n // Exactly while `data-pending`: a Close that will not act is unavailable to AT. Owned,\n // so an idle Close removes a render element's own `aria-disabled`.\n \"aria-disabled\": pending || !disabledProps.invoker ? true : undefined,\n \"data-pending\": dataAttr(pending),\n \"data-disabled\": dataAttr(disabled),\n };\n\n return useRender<ComponentPropsWithRef<\"button\">, OverlayCloseState>({\n defaultElement: \"button\",\n render,\n state: { pending, disabled },\n className: options.className,\n style: options.style,\n children: options.children,\n props: options.rest,\n libraryProps,\n ref,\n });\n}\n"],"mappings":";;;;;;;AASA,MAAM,QAAQ,QAAQ,IAAI,aAAa;;;;;;;;;AA0CvC,SAAgB,gBACd,SACW;CACX,MAAM,EAAE,MAAM,MAAM,WAAW,SAAS,SAAS,QAAQ,UAAU,WAAW;CAC9E,MAAM,EAAE,SAAS,QAAQ,iBAAiB,EAAE,gBAAgB,QAAQ,eAAe,CAAC;CACpF,MAAM,eAAe,aAAa,WAAW,KAAA;CAE7C,MAAM,gBAAgB,eAAe,QAAQ,UAAU,EAAE,cAAc,aAAa,CAAC;CAErF,MAAM,MAAM,gBACV,WACI,YACA,CAAC,gBAAgB,QAAQ,YAAY,WACjC,GAAG,KAAK,gBAAgB,QAAQ,QAAQ,YAAY,EAAE,wEACP,QAAQ,uCAC1C,KAAK,KAClB,OACR,CAAC,YAAY,CACf;CAEA,MAAM,WAAW,UAAmC;EAElD,MAAM,eAAe;EACrB,IAAI,UAAU;EACd,MAAM,SAAS,MAAM;EACrB,IAAI,WAAW,KAAA,GAAW;GACxB,QAAQ,MAAM,MAAM;GACpB;EACF;EACA,MAAM,UAAU,QAAQ,QAAQ,MAAM;EACtC,UACQ,OAAO,OAAO,SACd,QAAQ,MAAM,MAAM,CAC5B;CACF;CAEA,MAAM,eAAiE;EACrE,GAAI,cAAc,MAAM,KAAK,EAAE,MAAM,SAAkB;EAEvD,UAAU,cAAc,MAAM;EAG9B,YAAY,cAAc,WAAW,cAAc,MAAM,IAAI,UAAU,KAAA;EACvE,SAAS,cAAc,WAAW,cAAc,MAAM,IAAI,UAAU,KAAA;EACpE,GAAG,QAAQ;EACX,GAAI,gBAAgB,EAAE,QAAQ;EAG9B,iBAAiB,WAAW,CAAC,cAAc,UAAU,OAAO,KAAA;EAC5D,gBAAgB,SAAS,OAAO;EAChC,iBAAiB,SAAS,QAAQ;CACpC;CAEA,OAAO,UAA8D;EACnE,gBAAgB;EAChB;EACA,OAAO;GAAE;GAAS;EAAS;EAC3B,WAAW,QAAQ;EACnB,OAAO,QAAQ;EACf,UAAU,QAAQ;EAClB,OAAO,QAAQ;EACf;EACA;CACF,CAAC;AACH"}
|
|
@@ -4,33 +4,30 @@ import { useDevWarning } from "./use-dev-warning.mjs";
|
|
|
4
4
|
import { transitionTypes } from "./transition-types.mjs";
|
|
5
5
|
import { useLatest } from "./use-latest.mjs";
|
|
6
6
|
import { useControllableAction } from "./use-controllable-action.mjs";
|
|
7
|
+
import { isPopoverOpen } from "./popover-open.mjs";
|
|
7
8
|
import { useCallback, useId, useMemo, useRef, useState } from "react";
|
|
8
|
-
//#region src/internal/use-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
return element.matches(":popover-open");
|
|
13
|
-
} catch {
|
|
14
|
-
return false;
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
/** How long a recorded close intent survives when the popover did not close (design 2.3). */
|
|
18
|
-
function clearLater(intentRef, intent, popupRef) {
|
|
9
|
+
//#region src/internal/use-overlay-root.ts
|
|
10
|
+
const isDev = process.env.NODE_ENV !== "production";
|
|
11
|
+
/** How long a recorded close intent survives when the popup did not close (design 2.3). */
|
|
12
|
+
function clearLater(intentRef, intent, popupRef, isShown) {
|
|
19
13
|
setTimeout(() => {
|
|
20
|
-
|
|
14
|
+
const popup = popupRef.current;
|
|
15
|
+
if (intentRef.current === intent && popup !== null && isShown(popup)) intentRef.current = void 0;
|
|
21
16
|
}, 0);
|
|
22
17
|
}
|
|
18
|
+
/** The `details` of a popover-like component: `{ reason }` (and `event`). */
|
|
19
|
+
const popoverDetails = (event, reason) => createActionDetails(event, { reason });
|
|
23
20
|
/**
|
|
24
|
-
* The Root of
|
|
25
|
-
*
|
|
21
|
+
* The Root of an overlay without its public props: mode detection (once, from the first
|
|
22
|
+
* render), `useControllableAction<boolean>`, ids, refs, close intents, the open generation and
|
|
26
23
|
* the intent-aware `requestOpen` / `requestClose` / `notifyClosed`.
|
|
27
24
|
*/
|
|
28
|
-
function
|
|
25
|
+
function useOverlayRoot(options) {
|
|
29
26
|
const { component, part, open, defaultOpen, openChangeAction, details, onDispatch } = options;
|
|
30
27
|
const isLibraryNow = options.mode === "library" || open !== void 0 || defaultOpen !== void 0 || openChangeAction !== void 0;
|
|
31
28
|
const [mode] = useState(isLibraryNow ? "library" : "static");
|
|
32
29
|
const isLibrary = mode === "library";
|
|
33
|
-
useDevWarning(isLibrary !== isLibraryNow, `${part}: the mode changed after mount (\`open\`, \`defaultOpen\` and \`openChangeAction\` were all absent on one render and present on another). Switching between JS-free and library mode is not supported.`);
|
|
30
|
+
useDevWarning(isLibrary !== isLibraryNow, isDev && `${part}: the mode changed after mount (\`open\`, \`defaultOpen\` and \`openChangeAction\` were all absent on one render and present on another). Switching between JS-free and library mode is not supported.`);
|
|
34
31
|
const { committed, optimistic, pending, dispatch, latestInFlight } = useControllableAction({
|
|
35
32
|
controlled: isLibrary ? open : void 0,
|
|
36
33
|
defaultValue: isLibrary ? defaultOpen : void 0,
|
|
@@ -47,6 +44,11 @@ function usePopoverRoot(options) {
|
|
|
47
44
|
const popupRef = useRef(null);
|
|
48
45
|
const closeIntent = useRef(void 0);
|
|
49
46
|
const committedOptimistic = useLatest(optimistic);
|
|
47
|
+
const callbacks = useLatest({
|
|
48
|
+
details,
|
|
49
|
+
onDispatch,
|
|
50
|
+
isShown: options.isShown
|
|
51
|
+
});
|
|
50
52
|
const generation = useRef(0);
|
|
51
53
|
const openGeneration = useCallback(() => generation.current, []);
|
|
52
54
|
const nextOpenGeneration = useCallback(() => {
|
|
@@ -54,21 +56,17 @@ function usePopoverRoot(options) {
|
|
|
54
56
|
}, []);
|
|
55
57
|
const recordCloseIntent = useCallback((intent) => {
|
|
56
58
|
closeIntent.current = intent;
|
|
57
|
-
if (intent !== void 0) clearLater(closeIntent, intent, popupRef);
|
|
58
|
-
}, []);
|
|
59
|
+
if (intent !== void 0) clearLater(closeIntent, intent, popupRef, callbacks.current.isShown ?? isPopoverOpen);
|
|
60
|
+
}, [callbacks]);
|
|
59
61
|
const takeCloseIntent = useCallback(() => {
|
|
60
62
|
const intent = closeIntent.current;
|
|
61
63
|
closeIntent.current = void 0;
|
|
62
64
|
return intent;
|
|
63
65
|
}, []);
|
|
64
66
|
const intended = useCallback(() => latestInFlight()?.next ?? committedOptimistic.current, [latestInFlight, committedOptimistic]);
|
|
65
|
-
const
|
|
66
|
-
details,
|
|
67
|
-
onDispatch
|
|
68
|
-
});
|
|
69
|
-
const send = useCallback((next, event, reason) => {
|
|
67
|
+
const send = useCallback((next, event, reason, args) => {
|
|
70
68
|
const { details, onDispatch } = callbacks.current;
|
|
71
|
-
const built = details
|
|
69
|
+
const built = details(event, reason, ...args);
|
|
72
70
|
if (next) nextOpenGeneration();
|
|
73
71
|
onDispatch?.(next, built);
|
|
74
72
|
dispatch(next, built);
|
|
@@ -79,28 +77,21 @@ function usePopoverRoot(options) {
|
|
|
79
77
|
]);
|
|
80
78
|
const requestOpen = useCallback((event, reason) => {
|
|
81
79
|
if (!isLibrary || intended()) return;
|
|
82
|
-
send(true, event, reason);
|
|
83
|
-
}, [
|
|
84
|
-
isLibrary,
|
|
85
|
-
intended,
|
|
86
|
-
send
|
|
87
|
-
]);
|
|
88
|
-
const requestClose = useCallback((event, reason) => {
|
|
89
|
-
if (!isLibrary || !intended()) return;
|
|
90
|
-
send(false, event, reason);
|
|
80
|
+
send(true, event, reason, []);
|
|
91
81
|
}, [
|
|
92
82
|
isLibrary,
|
|
93
83
|
intended,
|
|
94
84
|
send
|
|
95
85
|
]);
|
|
96
|
-
const
|
|
86
|
+
const requestClose = useCallback((event, reason, ...args) => {
|
|
97
87
|
if (!isLibrary || !intended()) return;
|
|
98
|
-
send(false, event, reason);
|
|
88
|
+
send(false, event, reason, args);
|
|
99
89
|
}, [
|
|
100
90
|
isLibrary,
|
|
101
91
|
intended,
|
|
102
92
|
send
|
|
103
93
|
]);
|
|
94
|
+
const [shown, setShown] = useState(false);
|
|
104
95
|
const ids = useMemo(() => ({
|
|
105
96
|
popup: id,
|
|
106
97
|
title: `${id}-title`,
|
|
@@ -111,13 +102,15 @@ function usePopoverRoot(options) {
|
|
|
111
102
|
ids,
|
|
112
103
|
committed: isLibrary && committed,
|
|
113
104
|
optimistic: isLibrary && optimistic,
|
|
105
|
+
shown,
|
|
106
|
+
setShown,
|
|
114
107
|
pending: isLibrary && pending,
|
|
115
108
|
intended,
|
|
116
109
|
openGeneration,
|
|
117
110
|
nextOpenGeneration,
|
|
118
111
|
requestOpen,
|
|
119
112
|
requestClose,
|
|
120
|
-
notifyClosed,
|
|
113
|
+
notifyClosed: requestClose,
|
|
121
114
|
latestInFlight,
|
|
122
115
|
triggerRef,
|
|
123
116
|
popupRef,
|
|
@@ -129,19 +122,19 @@ function usePopoverRoot(options) {
|
|
|
129
122
|
isLibrary,
|
|
130
123
|
committed,
|
|
131
124
|
optimistic,
|
|
125
|
+
shown,
|
|
132
126
|
pending,
|
|
133
127
|
intended,
|
|
134
128
|
openGeneration,
|
|
135
129
|
nextOpenGeneration,
|
|
136
130
|
requestOpen,
|
|
137
131
|
requestClose,
|
|
138
|
-
notifyClosed,
|
|
139
132
|
latestInFlight,
|
|
140
133
|
recordCloseIntent,
|
|
141
134
|
takeCloseIntent
|
|
142
135
|
]);
|
|
143
136
|
}
|
|
144
137
|
//#endregion
|
|
145
|
-
export {
|
|
138
|
+
export { popoverDetails, useOverlayRoot };
|
|
146
139
|
|
|
147
|
-
//# sourceMappingURL=use-
|
|
140
|
+
//# sourceMappingURL=use-overlay-root.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-overlay-root.mjs","names":[],"sources":["../../src/internal/use-overlay-root.ts"],"sourcesContent":["\"use client\";\nimport { useCallback, useId, useMemo, useRef, useState } from \"react\";\nimport type { RefObject } from \"react\";\nimport { createActionDetails } from \"./action-details.js\";\nimport { isPopoverOpen } from \"./popover-open.js\";\nimport { transitionTypes } from \"./transition-types.js\";\nimport type { ActionDetails, ChangeAction, ChangeReason } from \"./types.js\";\nimport { useControllableAction } from \"./use-controllable-action.js\";\nimport { useDevWarning } from \"./use-dev-warning.js\";\nimport { useLatest } from \"./use-latest.js\";\n\nconst isDev = process.env.NODE_ENV !== \"production\";\n\n/**\n * \"static\": JS-free mode, the browser owns open and close through Invoker Commands. \"library\":\n * opening and part-initiated closing are library-owned (transitions keyed on committed state);\n * dismissals are the browser's and notified (design/components/popover.md section 2).\n */\nexport type OverlayMode = \"static\" | \"library\";\n\n/**\n * What caused the next close, recorded just before it happens (design 2.3). The `toggle` event\n * carries no source; without an intent a close is a `\"dismiss\"`.\n */\nexport interface OverlayCloseIntent {\n readonly reason: ChangeReason;\n readonly event: Event | undefined;\n}\n\n/** The `details` every overlay `openChangeAction` receives (Dialog's adds `returnValue`). */\nexport interface OverlayDetails extends ActionDetails {\n readonly reason: ChangeReason;\n}\n\n/**\n * The Root's state and machinery, shared by Popover, Menu, Combobox (design 14) and Dialog. The\n * component puts it in its own context; `usePopoverTrigger` and `usePopoverPopup` take it as their\n * first argument. `Popup` is the popup element's type; `CloseArgs` are the extra arguments of a\n * close (Dialog's `returnValue`), passed on to the `details` builder.\n */\nexport interface OverlayRootValue<Popup extends HTMLElement, CloseArgs extends unknown[]> {\n readonly mode: OverlayMode;\n /** `useId`-based ids: the popup, its Title and its Description. */\n readonly ids: { readonly popup: string; readonly title: string; readonly description: string };\n /** Committed open state (library mode); `false` in JS-free mode. */\n readonly committed: boolean;\n /** Optimistic open state (library mode); `false` in JS-free mode. */\n readonly optimistic: boolean;\n /**\n * The popup is in the top layer, mirrored from its `toggle` (urgent, conventions 3.5): what\n * `aria-expanded` renders (#118). Written by a popover Popup in library mode; Dialog does not\n * maintain it.\n */\n readonly shown: boolean;\n /** Writes `shown` from the DOM (`:popover-open`); the Popup's `toggle`, ref attach and detach. */\n readonly setShown: (shown: boolean) => void;\n /** The Root's transition is pending (library mode). */\n readonly pending: boolean;\n /**\n * What the user already intends: the latest in-flight dispatch's `next`, else the optimistic\n * value of the last commit. Safe to call from handlers and effects (layout effects included,\n * also in the commit that changed it), and after an `await`. Not during render.\n */\n readonly intended: () => boolean;\n /**\n * A counter that grows with every open (a requested open, or the popup being shown). A part\n * whose close runs after an `await` records it first and drops the close when it changed: the\n * user dismissed and re-opened meanwhile (Popover.Close, design 3.4). Handlers only.\n */\n readonly openGeneration: () => number;\n /** Advance `openGeneration` (the Popup's `beforetoggle` for an open). */\n readonly nextOpenGeneration: () => void;\n /**\n * Open through the Root's transition (library mode): a Trigger click, a foreign open caught at\n * `beforetoggle`, or mount reconciliation. A no-op when `true` is already intended.\n */\n readonly requestOpen: (event: Event | undefined, reason: ChangeReason) => void;\n /**\n * A library-owned close (library mode): a Trigger click while open, a Close part, Menu's item\n * activation. `openChangeAction(false)` is awaited and the popup hides in the commit. A no-op\n * when `false` is already intended.\n */\n readonly requestClose: (\n event: Event | undefined,\n reason: ChangeReason,\n ...args: CloseArgs\n ) => void;\n /**\n * The browser hid the popup (a dismissal or a foreign invoker): dispatch the `false`\n * notification unless `false` is already intended (the library's own echo, or a dismissal\n * during a pending part-initiated close).\n */\n readonly notifyClosed: (\n event: Event | undefined,\n reason: ChangeReason,\n ...args: CloseArgs\n ) => void;\n /** From `useControllableAction`: the latest in-flight intent, or `null`. */\n readonly latestInFlight: () => { readonly next: boolean } | null;\n /** The registered Trigger: `showPopover({ source })` and the focus-return fallback. */\n readonly triggerRef: RefObject<HTMLElement | null>;\n /** The popup element, set by the Popup's ref; how Close reaches `hidePopover()` / `close()`. */\n readonly popupRef: RefObject<Popup | null>;\n /** Record what causes the next close. Cleared after a task if the popover did not close. */\n readonly recordCloseIntent: (intent: OverlayCloseIntent | undefined) => void;\n /** Read and clear the recorded intent (the Popup's `toggle` listener). */\n readonly takeCloseIntent: () => OverlayCloseIntent | undefined;\n}\n\n/** The root value of the popover-like components (Popover, Menu, Combobox). */\nexport type PopoverRootValue = OverlayRootValue<HTMLElement, []>;\n\nexport interface UseOverlayRootOptions<\n Details extends ActionDetails,\n Popup extends HTMLElement = HTMLElement,\n CloseArgs extends unknown[] = [],\n> {\n /** Transition types and messages: `\"popover\"` gives `fsui-popover`, `fsui-popover-open`, … */\n readonly component: string;\n /** Public name of the Root part for development warnings (`\"Popover.Root\"`). */\n readonly part: string;\n readonly open: boolean | undefined;\n readonly defaultOpen: boolean | undefined;\n readonly openChangeAction: ChangeAction<boolean, Details> | undefined;\n /**\n * `\"library\"` forces library mode whatever the props (Menu, which has no JS-free mode). Default:\n * detected from `open` / `defaultOpen` / `openChangeAction` on the first render.\n */\n readonly mode?: \"library\";\n /**\n * Called synchronously for every dispatch, before the action runs (Menu: cancel hover timers,\n * read the open cause).\n */\n readonly onDispatch?: (next: boolean, details: Details) => void;\n /** Builds the `details` of a dispatch (`popoverDetails`: `{ reason }`); an open passes no args. */\n readonly details: (\n event: Event | undefined,\n reason: ChangeReason,\n ...args: CloseArgs | []\n ) => Details;\n /** Whether the popup is shown, for a stale close intent. Default: `:popover-open`. */\n readonly isShown?: (popup: Popup) => boolean;\n}\n\n/** How long a recorded close intent survives when the popup did not close (design 2.3). */\nfunction clearLater<Popup extends HTMLElement>(\n intentRef: { current: OverlayCloseIntent | undefined },\n intent: OverlayCloseIntent,\n popupRef: { current: Popup | null },\n isShown: (popup: Popup) => boolean,\n): void {\n setTimeout(() => {\n // Closed: its `toggle` / `close` event (queued as a task) consumes the intent. Still open: the\n // close was cancelled or invalid, so the intent is stale.\n const popup = popupRef.current;\n if (intentRef.current === intent && popup !== null && isShown(popup)) {\n intentRef.current = undefined;\n }\n }, 0);\n}\n\n/** The `details` of a popover-like component: `{ reason }` (and `event`). */\nexport const popoverDetails = (event: Event | undefined, reason: ChangeReason): OverlayDetails =>\n createActionDetails(event, { reason });\n\n/**\n * The Root of an overlay without its public props: mode detection (once, from the first\n * render), `useControllableAction<boolean>`, ids, refs, close intents, the open generation and\n * the intent-aware `requestOpen` / `requestClose` / `notifyClosed`.\n */\nexport function useOverlayRoot<\n Details extends ActionDetails,\n Popup extends HTMLElement = HTMLElement,\n CloseArgs extends unknown[] = [],\n>(options: UseOverlayRootOptions<Details, Popup, CloseArgs>): OverlayRootValue<Popup, CloseArgs> {\n const { component, part, open, defaultOpen, openChangeAction, details, onDispatch } = options;\n\n // Mode is decided once, from the first render's props (design 2).\n const isLibraryNow =\n options.mode === \"library\" ||\n open !== undefined ||\n defaultOpen !== undefined ||\n openChangeAction !== undefined;\n const [mode] = useState<OverlayMode>(isLibraryNow ? \"library\" : \"static\");\n const isLibrary = mode === \"library\";\n useDevWarning(\n isLibrary !== isLibraryNow,\n isDev &&\n `${part}: the mode changed after mount (\\`open\\`, \\`defaultOpen\\` and \\`openChangeAction\\` ` +\n \"were all absent on one render and present on another). Switching between JS-free and \" +\n \"library mode is not supported.\",\n );\n\n // Hooks cannot be conditional: JS-free mode calls the hook too and never dispatches.\n const { committed, optimistic, pending, dispatch, latestInFlight } = useControllableAction<\n boolean,\n Details\n >({\n controlled: isLibrary ? open : undefined,\n defaultValue: isLibrary ? defaultOpen : undefined,\n initialValue: false,\n action: isLibrary ? openChangeAction : undefined,\n transitionTypes: (next) => transitionTypes(component, next ? \"open\" : \"close\"),\n warn: { component: part, prop: \"open\" },\n });\n\n const id = useId();\n const triggerRef = useRef<HTMLElement | null>(null);\n const popupRef = useRef<Popup | null>(null);\n const closeIntent = useRef<OverlayCloseIntent | undefined>(undefined);\n\n // The optimistic value of the last commit, for callers that run after an `await` (a Close\n // action's continuation) and would otherwise read the value of the render they were created in.\n // An insertion effect runs in the mutation phase, before any layout effect of the same commit\n // (a child's included), so `intended()` is current there too.\n const committedOptimistic = useLatest(optimistic);\n // `details`, `onDispatch` and `isShown` are usually inline functions: read the committed render's\n // through a ref so that the functions below, and with them the returned value, stay stable.\n const callbacks = useLatest({ details, onDispatch, isShown: options.isShown });\n const generation = useRef(0);\n const openGeneration = useCallback(() => generation.current, []);\n const nextOpenGeneration = useCallback(() => {\n generation.current++;\n }, []);\n\n const recordCloseIntent = useCallback(\n (intent: OverlayCloseIntent | undefined) => {\n closeIntent.current = intent;\n if (intent !== undefined) {\n clearLater(closeIntent, intent, popupRef, callbacks.current.isShown ?? isPopoverOpen);\n }\n },\n [callbacks],\n );\n const takeCloseIntent = useCallback(() => {\n const intent = closeIntent.current;\n closeIntent.current = undefined;\n return intent;\n }, []);\n\n // Conventions 3.8 rule 1: judge no-ops against what the user already intends. That also\n // deduplicates the StrictMode re-run of the mount reconciliation and recognises the library's\n // own `hidePopover()` echoing back through `toggle`.\n const intended = useCallback(\n (): boolean => latestInFlight()?.next ?? committedOptimistic.current,\n [latestInFlight, committedOptimistic],\n );\n\n const send = useCallback(\n (next: boolean, event: Event | undefined, reason: ChangeReason, args: CloseArgs | []): void => {\n const { details, onDispatch } = callbacks.current;\n const built = details(event, reason, ...args);\n if (next) nextOpenGeneration();\n onDispatch?.(next, built);\n dispatch(next, built);\n },\n [callbacks, nextOpenGeneration, dispatch],\n );\n\n const requestOpen = useCallback(\n (event: Event | undefined, reason: ChangeReason): void => {\n if (!isLibrary || intended()) return;\n send(true, event, reason, []);\n },\n [isLibrary, intended, send],\n );\n\n const requestClose = useCallback(\n (event: Event | undefined, reason: ChangeReason, ...args: CloseArgs): void => {\n if (!isLibrary || !intended()) return;\n send(false, event, reason, args);\n },\n [isLibrary, intended, send],\n );\n\n const [shown, setShown] = useState(false);\n\n const ids = useMemo(\n () => ({ popup: id, title: `${id}-title`, description: `${id}-description` }),\n [id],\n );\n\n // Memoised: every function above is stable, so the value changes only with the open state and\n // pending, and the components' context values built on it are reused otherwise.\n return useMemo(\n () => ({\n mode,\n ids,\n committed: isLibrary && committed,\n optimistic: isLibrary && optimistic,\n shown,\n setShown,\n pending: isLibrary && pending,\n intended,\n openGeneration,\n nextOpenGeneration,\n requestOpen,\n requestClose,\n // The same function as `requestClose`; a separate name because the callers mean different\n // things (a part asks to close; the platform already closed).\n notifyClosed: requestClose,\n latestInFlight,\n triggerRef,\n popupRef,\n recordCloseIntent,\n takeCloseIntent,\n }),\n [\n mode,\n ids,\n isLibrary,\n committed,\n optimistic,\n shown,\n pending,\n intended,\n openGeneration,\n nextOpenGeneration,\n requestOpen,\n requestClose,\n latestInFlight,\n recordCloseIntent,\n takeCloseIntent,\n ],\n );\n}\n"],"mappings":";;;;;;;;;AAWA,MAAM,QAAQ,QAAQ,IAAI,aAAa;;AAsIvC,SAAS,WACP,WACA,QACA,UACA,SACM;CACN,iBAAiB;EAGf,MAAM,QAAQ,SAAS;EACvB,IAAI,UAAU,YAAY,UAAU,UAAU,QAAQ,QAAQ,KAAK,GACjE,UAAU,UAAU,KAAA;CAExB,GAAG,CAAC;AACN;;AAGA,MAAa,kBAAkB,OAA0B,WACvD,oBAAoB,OAAO,EAAE,OAAO,CAAC;;;;;;AAOvC,SAAgB,eAId,SAA+F;CAC/F,MAAM,EAAE,WAAW,MAAM,MAAM,aAAa,kBAAkB,SAAS,eAAe;CAGtF,MAAM,eACJ,QAAQ,SAAS,aACjB,SAAS,KAAA,KACT,gBAAgB,KAAA,KAChB,qBAAqB,KAAA;CACvB,MAAM,CAAC,QAAQ,SAAsB,eAAe,YAAY,QAAQ;CACxE,MAAM,YAAY,SAAS;CAC3B,cACE,cAAc,cACd,SACE,GAAG,KAAK,uMAGZ;CAGA,MAAM,EAAE,WAAW,YAAY,SAAS,UAAU,mBAAmB,sBAGnE;EACA,YAAY,YAAY,OAAO,KAAA;EAC/B,cAAc,YAAY,cAAc,KAAA;EACxC,cAAc;EACd,QAAQ,YAAY,mBAAmB,KAAA;EACvC,kBAAkB,SAAS,gBAAgB,WAAW,OAAO,SAAS,OAAO;EAC7E,MAAM;GAAE,WAAW;GAAM,MAAM;EAAO;CACxC,CAAC;CAED,MAAM,KAAK,MAAM;CACjB,MAAM,aAAa,OAA2B,IAAI;CAClD,MAAM,WAAW,OAAqB,IAAI;CAC1C,MAAM,cAAc,OAAuC,KAAA,CAAS;CAMpE,MAAM,sBAAsB,UAAU,UAAU;CAGhD,MAAM,YAAY,UAAU;EAAE;EAAS;EAAY,SAAS,QAAQ;CAAQ,CAAC;CAC7E,MAAM,aAAa,OAAO,CAAC;CAC3B,MAAM,iBAAiB,kBAAkB,WAAW,SAAS,CAAC,CAAC;CAC/D,MAAM,qBAAqB,kBAAkB;EAC3C,WAAW;CACb,GAAG,CAAC,CAAC;CAEL,MAAM,oBAAoB,aACvB,WAA2C;EAC1C,YAAY,UAAU;EACtB,IAAI,WAAW,KAAA,GACb,WAAW,aAAa,QAAQ,UAAU,UAAU,QAAQ,WAAW,aAAa;CAExF,GACA,CAAC,SAAS,CACZ;CACA,MAAM,kBAAkB,kBAAkB;EACxC,MAAM,SAAS,YAAY;EAC3B,YAAY,UAAU,KAAA;EACtB,OAAO;CACT,GAAG,CAAC,CAAC;CAKL,MAAM,WAAW,kBACA,eAAe,CAAC,EAAE,QAAQ,oBAAoB,SAC7D,CAAC,gBAAgB,mBAAmB,CACtC;CAEA,MAAM,OAAO,aACV,MAAe,OAA0B,QAAsB,SAA+B;EAC7F,MAAM,EAAE,SAAS,eAAe,UAAU;EAC1C,MAAM,QAAQ,QAAQ,OAAO,QAAQ,GAAG,IAAI;EAC5C,IAAI,MAAM,mBAAmB;EAC7B,aAAa,MAAM,KAAK;EACxB,SAAS,MAAM,KAAK;CACtB,GACA;EAAC;EAAW;EAAoB;CAAQ,CAC1C;CAEA,MAAM,cAAc,aACjB,OAA0B,WAA+B;EACxD,IAAI,CAAC,aAAa,SAAS,GAAG;EAC9B,KAAK,MAAM,OAAO,QAAQ,CAAC,CAAC;CAC9B,GACA;EAAC;EAAW;EAAU;CAAI,CAC5B;CAEA,MAAM,eAAe,aAClB,OAA0B,QAAsB,GAAG,SAA0B;EAC5E,IAAI,CAAC,aAAa,CAAC,SAAS,GAAG;EAC/B,KAAK,OAAO,OAAO,QAAQ,IAAI;CACjC,GACA;EAAC;EAAW;EAAU;CAAI,CAC5B;CAEA,MAAM,CAAC,OAAO,YAAY,SAAS,KAAK;CAExC,MAAM,MAAM,eACH;EAAE,OAAO;EAAI,OAAO,GAAG,GAAG;EAAS,aAAa,GAAG,GAAG;CAAc,IAC3E,CAAC,EAAE,CACL;CAIA,OAAO,eACE;EACL;EACA;EACA,WAAW,aAAa;EACxB,YAAY,aAAa;EACzB;EACA;EACA,SAAS,aAAa;EACtB;EACA;EACA;EACA;EACA;EAGA,cAAc;EACd;EACA;EACA;EACA;EACA;CACF,IACA;EACE;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACF,CACF;AACF"}
|
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
"use client";
|
|
2
|
+
import { useLatest } from "./use-latest.mjs";
|
|
3
|
+
import { useElementCheck } from "./use-element-check.mjs";
|
|
4
|
+
import { isPopoverOpen } from "./popover-open.mjs";
|
|
2
5
|
import { useContentFocusProbe } from "./content-focus-probe.mjs";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
6
|
+
import { commandOf, renderOverlayContent, resolveInitialFocus, returnFocusToTrigger, useCloseHold, useInitialFocusTarget } from "./overlay-popup.mjs";
|
|
7
|
+
import { useShownNameWarning } from "./use-name-warning.mjs";
|
|
8
|
+
import { useCallback, useEffectEvent, useLayoutEffect, useRef } from "react";
|
|
5
9
|
//#region src/internal/use-popover-popup.ts
|
|
6
10
|
const isDev = process.env.NODE_ENV !== "production";
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
return false;
|
|
12
|
-
}
|
|
11
|
+
/** The popup roles that require a name (a listbox's name is checked on the List). */
|
|
12
|
+
function needsName(element) {
|
|
13
|
+
const role = element.getAttribute("role");
|
|
14
|
+
return role === "dialog" || role === "alertdialog" || role === "menu";
|
|
13
15
|
}
|
|
14
16
|
let focusVisibleOption;
|
|
15
17
|
/**
|
|
@@ -32,11 +34,6 @@ function supportsFocusVisibleOption(doc) {
|
|
|
32
34
|
}
|
|
33
35
|
return focusVisibleOption;
|
|
34
36
|
}
|
|
35
|
-
/** Resolves `initialFocus` against the popup (a ref, or a selector inside the popup). */
|
|
36
|
-
function resolveInitialFocus(popup, initialFocus) {
|
|
37
|
-
if (typeof initialFocus === "string") return popup.querySelector(initialFocus);
|
|
38
|
-
return initialFocus.current;
|
|
39
|
-
}
|
|
40
37
|
/** Whether `element` sits inside a popover that is not shown (an outer popup that closed). */
|
|
41
38
|
function insideHiddenPopover(element) {
|
|
42
39
|
for (let node = element.parentElement; node !== null; node = node.parentElement) if (node.hasAttribute("popover") && !isPopoverOpen(node)) return true;
|
|
@@ -52,36 +49,19 @@ function usePopoverPopup(ctx, options) {
|
|
|
52
49
|
const { part, initialFocus, transition, onBeforeToggle: onBeforeToggleOption } = options;
|
|
53
50
|
const onToggleOption = options.onToggle;
|
|
54
51
|
const isLibrary = ctx.mode === "library";
|
|
55
|
-
const { popupRef, triggerRef } = ctx;
|
|
52
|
+
const { popupRef, triggerRef, setShown } = ctx;
|
|
56
53
|
const opening = useRef(false);
|
|
57
54
|
const reshowing = useRef(false);
|
|
58
55
|
const awaitingClose = useRef(false);
|
|
59
56
|
const focusWasInside = useRef(false);
|
|
60
|
-
const
|
|
61
|
-
const exit =
|
|
62
|
-
const [prevCommitted, setPrevCommitted] = useState(ctx.committed);
|
|
63
|
-
if (prevCommitted !== ctx.committed) {
|
|
64
|
-
setPrevCommitted(ctx.committed);
|
|
65
|
-
if (isLibrary && prevCommitted && transition === void 0) exit.holdDuringRender();
|
|
66
|
-
}
|
|
57
|
+
const initialFocusTarget = useInitialFocusTarget(part, "popup");
|
|
58
|
+
const exit = useCloseHold(ctx.committed, isLibrary, transition);
|
|
67
59
|
const contentProbe = useContentFocusProbe(popupRef);
|
|
68
60
|
const { wrapContent } = contentProbe;
|
|
69
61
|
const syncExpanded = (element) => {
|
|
70
62
|
triggerRef.current?.setAttribute("aria-expanded", String(isPopoverOpen(element)));
|
|
71
63
|
};
|
|
72
|
-
|
|
73
|
-
* Design 6.2 rule 2, for a close that began with focus inside: when focus is now on `<body>`
|
|
74
|
-
* or still inside the hidden popup, focus the Trigger (connected, not inside a hidden
|
|
75
|
-
* popover), else blur what holds focus.
|
|
76
|
-
*/
|
|
77
|
-
const returnFocus = (element) => {
|
|
78
|
-
const doc = element.ownerDocument;
|
|
79
|
-
const active = doc.activeElement;
|
|
80
|
-
if (active !== null && active !== doc.body && !element.contains(active)) return;
|
|
81
|
-
const trigger = triggerRef.current;
|
|
82
|
-
if (trigger !== null && trigger.isConnected && !insideHiddenPopover(trigger)) trigger.focus();
|
|
83
|
-
else if (active instanceof HTMLElement && active !== doc.body) active.blur();
|
|
84
|
-
};
|
|
64
|
+
const returnFocus = (element) => returnFocusToTrigger(element, triggerRef.current, (trigger) => !insideHiddenPopover(trigger));
|
|
85
65
|
const resolveFocusTarget = (element) => {
|
|
86
66
|
if (options.resolveInitialFocus !== void 0) {
|
|
87
67
|
const resolved = options.resolveInitialFocus(element);
|
|
@@ -89,14 +69,7 @@ function usePopoverPopup(ctx, options) {
|
|
|
89
69
|
const target = resolved instanceof HTMLElement ? resolved : resolved.element;
|
|
90
70
|
return element.contains(target) ? resolved : null;
|
|
91
71
|
}
|
|
92
|
-
|
|
93
|
-
const target = resolveInitialFocus(element, initialFocus);
|
|
94
|
-
if (target !== null && element.contains(target)) return target;
|
|
95
|
-
if (isDev && !warnedFocus.current) {
|
|
96
|
-
warnedFocus.current = true;
|
|
97
|
-
console.error(target === null ? `${part}: \`initialFocus\` resolved to no element; the platform picks the focus target.` : `${part}: \`initialFocus\` is outside the popup; the platform picks the focus target.`);
|
|
98
|
-
}
|
|
99
|
-
return null;
|
|
72
|
+
return initialFocusTarget(element, initialFocus);
|
|
100
73
|
};
|
|
101
74
|
const showPopup = (element) => {
|
|
102
75
|
const resolved = resolveFocusTarget(element);
|
|
@@ -157,7 +130,7 @@ function usePopoverPopup(ctx, options) {
|
|
|
157
130
|
}
|
|
158
131
|
}
|
|
159
132
|
if (ctx.committed && isPopoverOpen(element)) contentProbe.forget();
|
|
160
|
-
|
|
133
|
+
exit.releaseIfIdle(ctx.committed, awaitingClose.current, isPopoverOpen(element));
|
|
161
134
|
});
|
|
162
135
|
const onBeforeToggle = (event) => {
|
|
163
136
|
const element = popupRef.current;
|
|
@@ -182,18 +155,15 @@ function usePopoverPopup(ctx, options) {
|
|
|
182
155
|
const element = popupRef.current;
|
|
183
156
|
if (element === null || event.target !== element) return;
|
|
184
157
|
awaitingClose.current = false;
|
|
185
|
-
if (
|
|
158
|
+
if (isLibrary) setShown(isPopoverOpen(element));
|
|
159
|
+
else syncExpanded(element);
|
|
186
160
|
if (!isPopoverOpen(element)) {
|
|
187
161
|
const wasInside = focusWasInside.current;
|
|
188
162
|
focusWasInside.current = false;
|
|
189
163
|
if (wasInside) returnFocus(element);
|
|
190
164
|
const intent = ctx.takeCloseIntent();
|
|
191
165
|
if (isLibrary) {
|
|
192
|
-
|
|
193
|
-
const animations = exit.exitAnimations(element);
|
|
194
|
-
if (animations.length > 0) exit.holdUntil(animations);
|
|
195
|
-
else exit.release();
|
|
196
|
-
}
|
|
166
|
+
exit.afterClose(element, !ctx.intended());
|
|
197
167
|
ctx.notifyClosed(intent?.event ?? event, intent?.reason ?? "dismiss");
|
|
198
168
|
}
|
|
199
169
|
}
|
|
@@ -202,26 +172,20 @@ function usePopoverPopup(ctx, options) {
|
|
|
202
172
|
const onCommand = (event) => {
|
|
203
173
|
const element = popupRef.current;
|
|
204
174
|
if (element === null || event.target !== element || event.defaultPrevented) return;
|
|
205
|
-
const command =
|
|
175
|
+
const command = commandOf(event);
|
|
206
176
|
if (command === "hide-popover" || command === "toggle-popover" && isPopoverOpen(element)) ctx.recordCloseIntent({
|
|
207
177
|
reason: "activate",
|
|
208
178
|
event
|
|
209
179
|
});
|
|
210
180
|
};
|
|
211
|
-
const handlers =
|
|
181
|
+
const handlers = useLatest({
|
|
212
182
|
onBeforeToggle,
|
|
213
183
|
onToggle,
|
|
214
184
|
onCommand
|
|
215
185
|
});
|
|
216
|
-
|
|
217
|
-
handlers.current = {
|
|
218
|
-
onBeforeToggle,
|
|
219
|
-
onToggle,
|
|
220
|
-
onCommand
|
|
221
|
-
};
|
|
222
|
-
});
|
|
186
|
+
const checkElement = useElementCheck(isDev && ((element) => element.tagName !== "DIALOG" && element.tagName !== "DIV" ? `${part}: expected to render a <dialog> or a <div> but got <${element.tagName.toLowerCase()}>.` : null));
|
|
223
187
|
const setElement = useCallback((element) => {
|
|
224
|
-
|
|
188
|
+
checkElement?.(element);
|
|
225
189
|
popupRef.current = element;
|
|
226
190
|
const listeners = [
|
|
227
191
|
["beforetoggle", (event) => handlers.current.onBeforeToggle(event)],
|
|
@@ -229,6 +193,7 @@ function usePopoverPopup(ctx, options) {
|
|
|
229
193
|
["command", (event) => handlers.current.onCommand(event)]
|
|
230
194
|
];
|
|
231
195
|
for (const [type, listener] of listeners) element.addEventListener(type, listener);
|
|
196
|
+
if (isLibrary) setShown(isPopoverOpen(element));
|
|
232
197
|
let autofocused = null;
|
|
233
198
|
if (!isLibrary && initialFocus !== void 0) {
|
|
234
199
|
const target = resolveInitialFocus(element, initialFocus);
|
|
@@ -239,37 +204,30 @@ function usePopoverPopup(ctx, options) {
|
|
|
239
204
|
}
|
|
240
205
|
return () => {
|
|
241
206
|
for (const [type, listener] of listeners) element.removeEventListener(type, listener);
|
|
207
|
+
if (isLibrary) setShown(false);
|
|
242
208
|
autofocused?.removeAttribute("autofocus");
|
|
243
209
|
if (popupRef.current === element) popupRef.current = null;
|
|
244
210
|
};
|
|
245
211
|
}, [
|
|
246
|
-
|
|
212
|
+
checkElement,
|
|
247
213
|
popupRef,
|
|
214
|
+
setShown,
|
|
215
|
+
handlers,
|
|
248
216
|
isLibrary,
|
|
249
217
|
initialFocus
|
|
250
218
|
]);
|
|
251
|
-
|
|
252
|
-
const
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
if (labelledBy.some((id) => id !== "" && doc.getElementById(id) !== null)) return;
|
|
260
|
-
const role = element.getAttribute("role");
|
|
261
|
-
if (role !== "dialog" && role !== "alertdialog" && role !== "menu") return;
|
|
262
|
-
warnedName.current = true;
|
|
263
|
-
console.error(`${part}: the popup has no accessible name. Render a Title, or give the Popup an \`aria-label\`.`);
|
|
264
|
-
}, [
|
|
265
|
-
popupRef,
|
|
266
|
-
shown,
|
|
267
|
-
part
|
|
268
|
-
]);
|
|
219
|
+
useShownNameWarning(popupRef, !isLibrary || ctx.committed, isDev && `${part}: the popup has no accessible name. Render a Title, or give the Popup an \`aria-label\`.`, needsName);
|
|
220
|
+
const visible = ctx.committed || exit.held;
|
|
221
|
+
const renderContent = (children) => renderOverlayContent({
|
|
222
|
+
isLibrary,
|
|
223
|
+
keepMounted: options.keepMounted,
|
|
224
|
+
visible,
|
|
225
|
+
wrapContent
|
|
226
|
+
}, children);
|
|
269
227
|
return {
|
|
270
228
|
setElement,
|
|
271
|
-
visible
|
|
272
|
-
|
|
229
|
+
visible,
|
|
230
|
+
renderContent,
|
|
273
231
|
reshow
|
|
274
232
|
};
|
|
275
233
|
}
|