@funstack/ui 0.1.0-alpha.14 → 0.1.0-alpha.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +22 -1
- package/dist/accordion/accordion-item.d.mts +19 -0
- package/dist/accordion/accordion-item.d.mts.map +1 -1
- package/dist/accordion/accordion-item.mjs +2 -0
- package/dist/accordion/accordion-item.mjs.map +1 -1
- package/dist/accordion/accordion-panel.d.mts +16 -0
- package/dist/accordion/accordion-panel.d.mts.map +1 -1
- package/dist/accordion/accordion-panel.mjs +2 -0
- package/dist/accordion/accordion-panel.mjs.map +1 -1
- package/dist/accordion/accordion-root.d.mts +36 -2
- package/dist/accordion/accordion-root.d.mts.map +1 -1
- package/dist/accordion/accordion-root.mjs +7 -4
- package/dist/accordion/accordion-root.mjs.map +1 -1
- package/dist/accordion/accordion-trigger.d.mts +9 -0
- package/dist/accordion/accordion-trigger.d.mts.map +1 -1
- package/dist/accordion/accordion-trigger.mjs +2 -0
- package/dist/accordion/accordion-trigger.mjs.map +1 -1
- package/dist/accordion/index.d.mts +2 -0
- package/dist/accordion/index.d.mts.map +1 -1
- package/dist/accordion/index.mjs +2 -0
- package/dist/accordion/index.mjs.map +1 -1
- package/dist/bin/skill-installer.d.mts +1 -0
- package/dist/bin/skill-installer.mjs +12 -0
- package/dist/bin/skill-installer.mjs.map +1 -0
- package/dist/button/button.d.mts +25 -7
- package/dist/button/button.d.mts.map +1 -1
- package/dist/button/button.mjs +2 -0
- package/dist/button/button.mjs.map +1 -1
- package/dist/checkbox/checkbox.d.mts +25 -3
- package/dist/checkbox/checkbox.d.mts.map +1 -1
- package/dist/checkbox/checkbox.mjs +2 -0
- package/dist/checkbox/checkbox.mjs.map +1 -1
- package/dist/checkbox-group/checkbox-group-item.d.mts +15 -0
- package/dist/checkbox-group/checkbox-group-item.d.mts.map +1 -1
- package/dist/checkbox-group/checkbox-group-item.mjs +2 -0
- package/dist/checkbox-group/checkbox-group-item.mjs.map +1 -1
- package/dist/checkbox-group/checkbox-group-label.d.mts +10 -0
- package/dist/checkbox-group/checkbox-group-label.d.mts.map +1 -1
- package/dist/checkbox-group/checkbox-group-label.mjs +2 -0
- package/dist/checkbox-group/checkbox-group-label.mjs.map +1 -1
- package/dist/checkbox-group/checkbox-group-parent.d.mts +19 -1
- package/dist/checkbox-group/checkbox-group-parent.d.mts.map +1 -1
- package/dist/checkbox-group/checkbox-group-parent.mjs +2 -0
- package/dist/checkbox-group/checkbox-group-parent.mjs.map +1 -1
- package/dist/checkbox-group/checkbox-group-root.d.mts +31 -4
- package/dist/checkbox-group/checkbox-group-root.d.mts.map +1 -1
- package/dist/checkbox-group/checkbox-group-root.mjs +6 -5
- package/dist/checkbox-group/checkbox-group-root.mjs.map +1 -1
- package/dist/checkbox-group/index.d.mts +2 -0
- package/dist/checkbox-group/index.d.mts.map +1 -1
- package/dist/checkbox-group/index.mjs +2 -0
- package/dist/checkbox-group/index.mjs.map +1 -1
- package/dist/combobox/combobox-clear.d.mts +18 -0
- package/dist/combobox/combobox-clear.d.mts.map +1 -1
- package/dist/combobox/combobox-clear.mjs +2 -0
- 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 +49 -1
- package/dist/combobox/combobox-group.d.mts.map +1 -1
- package/dist/combobox/combobox-group.mjs +11 -1
- package/dist/combobox/combobox-group.mjs.map +1 -1
- package/dist/combobox/combobox-input.d.mts +18 -6
- package/dist/combobox/combobox-input.d.mts.map +1 -1
- package/dist/combobox/combobox-input.mjs +8 -5
- package/dist/combobox/combobox-input.mjs.map +1 -1
- package/dist/combobox/combobox-label.d.mts +18 -1
- package/dist/combobox/combobox-label.d.mts.map +1 -1
- package/dist/combobox/combobox-label.mjs +4 -1
- package/dist/combobox/combobox-label.mjs.map +1 -1
- package/dist/combobox/combobox-list.d.mts +14 -0
- package/dist/combobox/combobox-list.d.mts.map +1 -1
- package/dist/combobox/combobox-list.mjs +2 -0
- package/dist/combobox/combobox-list.mjs.map +1 -1
- package/dist/combobox/combobox-option.d.mts +25 -3
- package/dist/combobox/combobox-option.d.mts.map +1 -1
- package/dist/combobox/combobox-option.mjs +2 -0
- package/dist/combobox/combobox-option.mjs.map +1 -1
- package/dist/combobox/combobox-popup.d.mts +17 -1
- package/dist/combobox/combobox-popup.d.mts.map +1 -1
- package/dist/combobox/combobox-popup.mjs +5 -15
- package/dist/combobox/combobox-popup.mjs.map +1 -1
- package/dist/combobox/combobox-root.d.mts +49 -12
- package/dist/combobox/combobox-root.d.mts.map +1 -1
- package/dist/combobox/combobox-root.mjs +11 -80
- package/dist/combobox/combobox-root.mjs.map +1 -1
- package/dist/combobox/combobox-trigger.d.mts +26 -8
- package/dist/combobox/combobox-trigger.d.mts.map +1 -1
- package/dist/combobox/combobox-trigger.mjs +23 -17
- package/dist/combobox/combobox-trigger.mjs.map +1 -1
- package/dist/combobox/index.d.mts +4 -2
- package/dist/combobox/index.d.mts.map +1 -1
- package/dist/combobox/index.mjs +4 -2
- package/dist/combobox/index.mjs.map +1 -1
- package/dist/combobox/use-deferred-leave.mjs +105 -0
- package/dist/combobox/use-deferred-leave.mjs.map +1 -0
- package/dist/csp/csp-provider.d.mts +8 -0
- package/dist/csp/csp-provider.d.mts.map +1 -1
- package/dist/csp/csp-provider.mjs +2 -0
- package/dist/csp/csp-provider.mjs.map +1 -1
- package/dist/csp/style-hashes.d.mts +2 -0
- package/dist/csp/style-hashes.d.mts.map +1 -1
- package/dist/csp/style-hashes.mjs +2 -0
- package/dist/csp/style-hashes.mjs.map +1 -1
- package/dist/dialog/dialog-close.d.mts +18 -0
- package/dist/dialog/dialog-close.d.mts.map +1 -1
- package/dist/dialog/dialog-close.mjs +2 -0
- package/dist/dialog/dialog-close.mjs.map +1 -1
- package/dist/dialog/dialog-context.mjs.map +1 -1
- package/dist/dialog/dialog-description.d.mts +12 -0
- package/dist/dialog/dialog-description.d.mts.map +1 -1
- package/dist/dialog/dialog-description.mjs +2 -0
- package/dist/dialog/dialog-description.mjs.map +1 -1
- package/dist/dialog/dialog-form.d.mts +18 -1
- package/dist/dialog/dialog-form.d.mts.map +1 -1
- package/dist/dialog/dialog-form.mjs +2 -0
- package/dist/dialog/dialog-form.mjs.map +1 -1
- package/dist/dialog/dialog-popup.d.mts +25 -4
- package/dist/dialog/dialog-popup.d.mts.map +1 -1
- package/dist/dialog/dialog-popup.mjs +4 -2
- package/dist/dialog/dialog-popup.mjs.map +1 -1
- package/dist/dialog/dialog-root.d.mts +15 -1
- package/dist/dialog/dialog-root.d.mts.map +1 -1
- package/dist/dialog/dialog-root.mjs +2 -0
- package/dist/dialog/dialog-root.mjs.map +1 -1
- package/dist/dialog/dialog-title.d.mts +11 -0
- package/dist/dialog/dialog-title.d.mts.map +1 -1
- package/dist/dialog/dialog-title.mjs +2 -0
- package/dist/dialog/dialog-title.mjs.map +1 -1
- package/dist/dialog/dialog-trigger.d.mts +16 -0
- package/dist/dialog/dialog-trigger.d.mts.map +1 -1
- package/dist/dialog/dialog-trigger.mjs +2 -0
- package/dist/dialog/dialog-trigger.mjs.map +1 -1
- package/dist/dialog/index.d.mts +2 -0
- package/dist/dialog/index.d.mts.map +1 -1
- package/dist/dialog/index.mjs +2 -0
- package/dist/dialog/index.mjs.map +1 -1
- package/dist/docs/components/accordion.md +426 -0
- package/dist/docs/components/button.md +464 -0
- package/dist/docs/components/checkbox-group.md +474 -0
- package/dist/docs/components/checkbox.md +373 -0
- package/dist/docs/components/combobox.md +635 -0
- package/dist/docs/components/context-menu.md +524 -0
- package/dist/docs/components/dialog.md +686 -0
- package/dist/docs/components/field.md +587 -0
- package/dist/docs/components/menu.md +589 -0
- package/dist/docs/components/meter.md +313 -0
- package/dist/docs/components/number-field.md +528 -0
- package/dist/docs/components/popover.md +591 -0
- package/dist/docs/components/progress.md +450 -0
- package/dist/docs/components/radio-group.md +457 -0
- package/dist/docs/components/select.md +662 -0
- package/dist/docs/components/slider.md +558 -0
- package/dist/docs/components/switch.md +311 -0
- package/dist/docs/components/tabs.md +473 -0
- package/dist/docs/components/toast.md +576 -0
- package/dist/docs/components/toggle-group.md +341 -0
- package/dist/docs/components/toggle.md +245 -0
- package/dist/docs/components/toolbar.md +389 -0
- package/dist/docs/components/tooltip.md +494 -0
- package/dist/docs/concepts/action-props.md +251 -0
- package/dist/docs/concepts/ai-agents.md +56 -0
- package/dist/docs/concepts/browser-owned-state.md +118 -0
- package/dist/docs/concepts/content-security-policy.md +69 -0
- package/dist/docs/concepts/experimental.md +36 -0
- package/dist/docs/concepts/pending-and-optimistic.md +250 -0
- package/dist/docs/concepts/server-components.md +118 -0
- package/dist/docs/concepts/suspense.md +124 -0
- package/dist/docs/concepts/transitions.md +118 -0
- package/dist/docs/getting-started.md +115 -0
- package/dist/docs/index.md +181 -0
- package/dist/docs/roadmap.md +74 -0
- package/dist/docs/why.md +100 -0
- package/dist/field/field-control.d.mts +26 -3
- package/dist/field/field-control.d.mts.map +1 -1
- package/dist/field/field-control.mjs +2 -0
- package/dist/field/field-control.mjs.map +1 -1
- package/dist/field/field-description.d.mts +11 -0
- package/dist/field/field-description.d.mts.map +1 -1
- package/dist/field/field-description.mjs +2 -0
- package/dist/field/field-description.mjs.map +1 -1
- package/dist/field/field-error.d.mts +14 -2
- package/dist/field/field-error.d.mts.map +1 -1
- package/dist/field/field-error.mjs +2 -0
- package/dist/field/field-error.mjs.map +1 -1
- package/dist/field/field-label.d.mts +10 -0
- package/dist/field/field-label.d.mts.map +1 -1
- package/dist/field/field-label.mjs +2 -0
- package/dist/field/field-label.mjs.map +1 -1
- package/dist/field/field-root.d.mts +21 -2
- package/dist/field/field-root.d.mts.map +1 -1
- package/dist/field/field-root.mjs +2 -0
- package/dist/field/field-root.mjs.map +1 -1
- package/dist/field/index.d.mts +9 -0
- package/dist/field/index.d.mts.map +1 -1
- package/dist/field/index.mjs +9 -0
- package/dist/field/index.mjs.map +1 -1
- package/dist/form/form-root.d.mts +17 -1
- package/dist/form/form-root.d.mts.map +1 -1
- package/dist/form/form-root.mjs +3 -1
- package/dist/form/form-root.mjs.map +1 -1
- package/dist/form/form-submit.d.mts +18 -0
- package/dist/form/form-submit.d.mts.map +1 -1
- package/dist/form/form-submit.mjs +2 -0
- package/dist/form/form-submit.mjs.map +1 -1
- package/dist/form/index.d.mts +7 -0
- package/dist/form/index.d.mts.map +1 -1
- package/dist/form/index.mjs +7 -0
- package/dist/form/index.mjs.map +1 -1
- package/dist/index.d.mts +2 -1
- package/dist/internal/announce.mjs +12 -7
- package/dist/internal/announce.mjs.map +1 -1
- package/dist/internal/focus-first-invalid.mjs +2 -11
- package/dist/internal/focus-first-invalid.mjs.map +1 -1
- package/dist/internal/focus-visible.mjs +26 -0
- package/dist/internal/focus-visible.mjs.map +1 -0
- package/dist/internal/{invoker-press.mjs → invokers.mjs} +22 -5
- package/dist/internal/invokers.mjs.map +1 -0
- package/dist/internal/platform-attributes.d.mts +1 -1
- package/dist/internal/pointer-capture.mjs +1 -1
- package/dist/internal/pointer-capture.mjs.map +1 -1
- package/dist/internal/trigger-ref.mjs +1 -1
- package/dist/internal/trigger-ref.mjs.map +1 -1
- package/dist/internal/types.d.mts +3 -0
- package/dist/internal/types.d.mts.map +1 -1
- package/dist/internal/use-interest-dismiss.mjs +84 -0
- package/dist/internal/use-interest-dismiss.mjs.map +1 -0
- package/dist/internal/use-overlay-root.mjs.map +1 -1
- package/dist/internal/use-popover-popup.mjs +43 -108
- package/dist/internal/use-popover-popup.mjs.map +1 -1
- package/dist/internal/use-popover-trigger.d.mts +1 -0
- package/dist/internal/use-popover-trigger.d.mts.map +1 -1
- package/dist/internal/use-popover-trigger.mjs +29 -10
- package/dist/internal/use-popover-trigger.mjs.map +1 -1
- package/dist/internal/use-value-set.mjs +20 -0
- package/dist/internal/use-value-set.mjs.map +1 -0
- package/dist/internal/validity.d.mts +11 -0
- package/dist/internal/validity.d.mts.map +1 -1
- package/dist/internal/validity.mjs.map +1 -1
- package/dist/menu/index.d.mts +2 -0
- package/dist/menu/index.d.mts.map +1 -1
- package/dist/menu/index.mjs +2 -0
- package/dist/menu/index.mjs.map +1 -1
- package/dist/menu/menu-checkbox-item.d.mts +26 -2
- package/dist/menu/menu-checkbox-item.d.mts.map +1 -1
- package/dist/menu/menu-checkbox-item.mjs +2 -0
- package/dist/menu/menu-checkbox-item.mjs.map +1 -1
- package/dist/menu/menu-context-trigger.d.mts +24 -2
- package/dist/menu/menu-context-trigger.d.mts.map +1 -1
- package/dist/menu/menu-context-trigger.mjs +2 -0
- package/dist/menu/menu-context-trigger.mjs.map +1 -1
- package/dist/menu/menu-group.d.mts +36 -1
- package/dist/menu/menu-group.d.mts.map +1 -1
- package/dist/menu/menu-group.mjs +9 -1
- package/dist/menu/menu-group.mjs.map +1 -1
- package/dist/menu/menu-item.d.mts +23 -1
- package/dist/menu/menu-item.d.mts.map +1 -1
- package/dist/menu/menu-item.mjs +2 -0
- package/dist/menu/menu-item.mjs.map +1 -1
- package/dist/menu/menu-popup.d.mts +34 -9
- package/dist/menu/menu-popup.d.mts.map +1 -1
- package/dist/menu/menu-popup.mjs +15 -27
- package/dist/menu/menu-popup.mjs.map +1 -1
- package/dist/menu/menu-radio-group.d.mts +20 -1
- package/dist/menu/menu-radio-group.d.mts.map +1 -1
- package/dist/menu/menu-radio-group.mjs +2 -0
- package/dist/menu/menu-radio-group.mjs.map +1 -1
- package/dist/menu/menu-radio-item.d.mts +16 -0
- package/dist/menu/menu-radio-item.d.mts.map +1 -1
- package/dist/menu/menu-radio-item.mjs +2 -0
- package/dist/menu/menu-radio-item.mjs.map +1 -1
- package/dist/menu/menu-root.d.mts +22 -3
- package/dist/menu/menu-root.d.mts.map +1 -1
- package/dist/menu/menu-root.mjs +2 -0
- package/dist/menu/menu-root.mjs.map +1 -1
- package/dist/menu/menu-submenu-trigger.d.mts +21 -8
- package/dist/menu/menu-submenu-trigger.d.mts.map +1 -1
- package/dist/menu/menu-submenu-trigger.mjs +11 -10
- package/dist/menu/menu-submenu-trigger.mjs.map +1 -1
- package/dist/menu/menu-trigger.d.mts +23 -7
- package/dist/menu/menu-trigger.d.mts.map +1 -1
- package/dist/menu/menu-trigger.mjs +8 -12
- package/dist/menu/menu-trigger.mjs.map +1 -1
- package/dist/meter/index.d.mts +2 -0
- package/dist/meter/index.d.mts.map +1 -1
- package/dist/meter/index.mjs +2 -0
- package/dist/meter/index.mjs.map +1 -1
- package/dist/meter/meter-indicator.d.mts +11 -0
- package/dist/meter/meter-indicator.d.mts.map +1 -1
- package/dist/meter/meter-indicator.mjs +2 -0
- package/dist/meter/meter-indicator.mjs.map +1 -1
- package/dist/meter/meter-label.d.mts +11 -0
- package/dist/meter/meter-label.d.mts.map +1 -1
- package/dist/meter/meter-label.mjs +2 -0
- package/dist/meter/meter-label.mjs.map +1 -1
- package/dist/meter/meter-region.d.mts +5 -0
- package/dist/meter/meter-region.d.mts.map +1 -1
- package/dist/meter/meter-region.mjs.map +1 -1
- package/dist/meter/meter-root.d.mts +52 -10
- package/dist/meter/meter-root.d.mts.map +1 -1
- package/dist/meter/meter-root.mjs +2 -0
- package/dist/meter/meter-root.mjs.map +1 -1
- package/dist/meter/meter-track.d.mts +11 -0
- package/dist/meter/meter-track.d.mts.map +1 -1
- package/dist/meter/meter-track.mjs +2 -0
- package/dist/meter/meter-track.mjs.map +1 -1
- package/dist/meter/meter-value.d.mts +15 -1
- package/dist/meter/meter-value.d.mts.map +1 -1
- package/dist/meter/meter-value.mjs +2 -0
- package/dist/meter/meter-value.mjs.map +1 -1
- package/dist/number-field/index.d.mts +2 -0
- package/dist/number-field/index.d.mts.map +1 -1
- package/dist/number-field/index.mjs +2 -0
- package/dist/number-field/index.mjs.map +1 -1
- package/dist/number-field/number-field-decrement.d.mts +2 -0
- package/dist/number-field/number-field-decrement.d.mts.map +1 -1
- package/dist/number-field/number-field-decrement.mjs +2 -0
- package/dist/number-field/number-field-decrement.mjs.map +1 -1
- package/dist/number-field/number-field-increment.d.mts +2 -0
- package/dist/number-field/number-field-increment.d.mts.map +1 -1
- package/dist/number-field/number-field-increment.mjs +2 -0
- package/dist/number-field/number-field-increment.mjs.map +1 -1
- package/dist/number-field/number-field-input.d.mts +9 -0
- package/dist/number-field/number-field-input.d.mts.map +1 -1
- package/dist/number-field/number-field-input.mjs +2 -0
- package/dist/number-field/number-field-input.mjs.map +1 -1
- package/dist/number-field/number-field-label.d.mts +10 -0
- package/dist/number-field/number-field-label.d.mts.map +1 -1
- package/dist/number-field/number-field-label.mjs +2 -0
- package/dist/number-field/number-field-label.mjs.map +1 -1
- package/dist/number-field/number-field-root.d.mts +62 -14
- package/dist/number-field/number-field-root.d.mts.map +1 -1
- package/dist/number-field/number-field-root.mjs +3 -1
- package/dist/number-field/number-field-root.mjs.map +1 -1
- package/dist/number-field/use-step-button.d.mts +20 -0
- package/dist/number-field/use-step-button.d.mts.map +1 -1
- package/dist/number-field/use-step-button.mjs.map +1 -1
- package/dist/popover/index.d.mts +2 -0
- package/dist/popover/index.d.mts.map +1 -1
- package/dist/popover/index.mjs +2 -0
- package/dist/popover/index.mjs.map +1 -1
- package/dist/popover/popover-close.d.mts +21 -3
- package/dist/popover/popover-close.d.mts.map +1 -1
- package/dist/popover/popover-close.mjs +3 -1
- package/dist/popover/popover-close.mjs.map +1 -1
- package/dist/popover/popover-description.d.mts +12 -0
- package/dist/popover/popover-description.d.mts.map +1 -1
- package/dist/popover/popover-description.mjs +2 -0
- package/dist/popover/popover-description.mjs.map +1 -1
- package/dist/popover/popover-popup.d.mts +30 -4
- package/dist/popover/popover-popup.d.mts.map +1 -1
- package/dist/popover/popover-popup.mjs +2 -0
- package/dist/popover/popover-popup.mjs.map +1 -1
- package/dist/popover/popover-root.d.mts +9 -0
- package/dist/popover/popover-root.d.mts.map +1 -1
- package/dist/popover/popover-root.mjs +2 -0
- package/dist/popover/popover-root.mjs.map +1 -1
- package/dist/popover/popover-title.d.mts +11 -0
- package/dist/popover/popover-title.d.mts.map +1 -1
- package/dist/popover/popover-title.mjs +2 -0
- package/dist/popover/popover-title.mjs.map +1 -1
- package/dist/popover/popover-trigger.d.mts +24 -9
- package/dist/popover/popover-trigger.d.mts.map +1 -1
- package/dist/popover/popover-trigger.mjs +11 -9
- package/dist/popover/popover-trigger.mjs.map +1 -1
- package/dist/progress/index.d.mts +2 -0
- package/dist/progress/index.d.mts.map +1 -1
- package/dist/progress/index.mjs +2 -0
- package/dist/progress/index.mjs.map +1 -1
- package/dist/progress/progress-indicator.d.mts +11 -0
- package/dist/progress/progress-indicator.d.mts.map +1 -1
- package/dist/progress/progress-indicator.mjs +2 -0
- package/dist/progress/progress-indicator.mjs.map +1 -1
- package/dist/progress/progress-label.d.mts +11 -0
- package/dist/progress/progress-label.d.mts.map +1 -1
- package/dist/progress/progress-label.mjs +2 -0
- package/dist/progress/progress-label.mjs.map +1 -1
- package/dist/progress/progress-root.d.mts +36 -8
- package/dist/progress/progress-root.d.mts.map +1 -1
- package/dist/progress/progress-root.mjs +2 -0
- package/dist/progress/progress-root.mjs.map +1 -1
- package/dist/progress/progress-track.d.mts +11 -0
- package/dist/progress/progress-track.d.mts.map +1 -1
- package/dist/progress/progress-track.mjs +2 -0
- package/dist/progress/progress-track.mjs.map +1 -1
- package/dist/progress/progress-value.d.mts +15 -1
- package/dist/progress/progress-value.d.mts.map +1 -1
- package/dist/progress/progress-value.mjs +2 -0
- package/dist/progress/progress-value.mjs.map +1 -1
- package/dist/radio-group/index.d.mts +2 -0
- package/dist/radio-group/index.d.mts.map +1 -1
- package/dist/radio-group/index.mjs +2 -0
- package/dist/radio-group/index.mjs.map +1 -1
- package/dist/radio-group/radio-group-item.d.mts +18 -1
- package/dist/radio-group/radio-group-item.d.mts.map +1 -1
- package/dist/radio-group/radio-group-item.mjs +2 -0
- package/dist/radio-group/radio-group-item.mjs.map +1 -1
- package/dist/radio-group/radio-group-label.d.mts +10 -0
- package/dist/radio-group/radio-group-label.d.mts.map +1 -1
- package/dist/radio-group/radio-group-label.mjs +2 -0
- package/dist/radio-group/radio-group-label.mjs.map +1 -1
- package/dist/radio-group/radio-group-root.d.mts +29 -5
- package/dist/radio-group/radio-group-root.d.mts.map +1 -1
- package/dist/radio-group/radio-group-root.mjs +2 -0
- package/dist/radio-group/radio-group-root.mjs.map +1 -1
- package/dist/select/index.d.mts +2 -0
- package/dist/select/index.d.mts.map +1 -1
- package/dist/select/index.mjs +2 -0
- package/dist/select/index.mjs.map +1 -1
- package/dist/select/select-group-label.d.mts +10 -0
- package/dist/select/select-group-label.d.mts.map +1 -1
- package/dist/select/select-group-label.mjs +2 -0
- package/dist/select/select-group-label.mjs.map +1 -1
- package/dist/select/select-group.d.mts +15 -1
- package/dist/select/select-group.d.mts.map +1 -1
- package/dist/select/select-group.mjs +2 -0
- package/dist/select/select-group.mjs.map +1 -1
- package/dist/select/select-option.d.mts +19 -1
- package/dist/select/select-option.d.mts.map +1 -1
- package/dist/select/select-option.mjs +2 -0
- package/dist/select/select-option.mjs.map +1 -1
- package/dist/select/select-root.d.mts +24 -1
- package/dist/select/select-root.d.mts.map +1 -1
- package/dist/select/select-root.mjs +2 -0
- package/dist/select/select-root.mjs.map +1 -1
- package/dist/select/select-separator.d.mts +9 -0
- package/dist/select/select-separator.d.mts.map +1 -1
- package/dist/select/select-separator.mjs +2 -0
- package/dist/select/select-separator.mjs.map +1 -1
- package/dist/select/select-trigger.d.mts +9 -0
- package/dist/select/select-trigger.d.mts.map +1 -1
- package/dist/select/select-trigger.mjs +2 -0
- package/dist/select/select-trigger.mjs.map +1 -1
- package/dist/select/select-value.d.mts +9 -0
- package/dist/select/select-value.d.mts.map +1 -1
- package/dist/select/select-value.mjs +2 -0
- package/dist/select/select-value.mjs.map +1 -1
- package/dist/slider/index.d.mts +2 -0
- package/dist/slider/index.d.mts.map +1 -1
- package/dist/slider/index.mjs +2 -0
- package/dist/slider/index.mjs.map +1 -1
- package/dist/slider/slider-indicator.d.mts +12 -0
- package/dist/slider/slider-indicator.d.mts.map +1 -1
- package/dist/slider/slider-indicator.mjs +2 -0
- package/dist/slider/slider-indicator.mjs.map +1 -1
- package/dist/slider/slider-label.d.mts +11 -1
- package/dist/slider/slider-label.d.mts.map +1 -1
- package/dist/slider/slider-label.mjs +2 -0
- package/dist/slider/slider-label.mjs.map +1 -1
- package/dist/slider/slider-root.d.mts +53 -9
- package/dist/slider/slider-root.d.mts.map +1 -1
- package/dist/slider/slider-root.mjs +2 -0
- package/dist/slider/slider-root.mjs.map +1 -1
- package/dist/slider/slider-thumb.d.mts +32 -3
- package/dist/slider/slider-thumb.d.mts.map +1 -1
- package/dist/slider/slider-thumb.mjs +2 -0
- package/dist/slider/slider-thumb.mjs.map +1 -1
- package/dist/slider/slider-track.d.mts +17 -0
- package/dist/slider/slider-track.d.mts.map +1 -1
- package/dist/slider/slider-track.mjs +2 -0
- package/dist/slider/slider-track.mjs.map +1 -1
- package/dist/slider/slider-value.d.mts +11 -0
- package/dist/slider/slider-value.d.mts.map +1 -1
- package/dist/slider/slider-value.mjs +2 -0
- package/dist/slider/slider-value.mjs.map +1 -1
- package/dist/switch/switch.d.mts +23 -3
- package/dist/switch/switch.d.mts.map +1 -1
- package/dist/switch/switch.mjs +2 -0
- package/dist/switch/switch.mjs.map +1 -1
- package/dist/tabs/index.d.mts +2 -0
- package/dist/tabs/index.d.mts.map +1 -1
- package/dist/tabs/index.mjs +2 -0
- package/dist/tabs/index.mjs.map +1 -1
- package/dist/tabs/tabs-context.d.mts +5 -0
- package/dist/tabs/tabs-context.d.mts.map +1 -1
- package/dist/tabs/tabs-context.mjs.map +1 -1
- package/dist/tabs/tabs-indicator.d.mts +17 -0
- package/dist/tabs/tabs-indicator.d.mts.map +1 -1
- package/dist/tabs/tabs-indicator.mjs +2 -0
- package/dist/tabs/tabs-indicator.mjs.map +1 -1
- package/dist/tabs/tabs-list.d.mts +19 -1
- package/dist/tabs/tabs-list.d.mts.map +1 -1
- package/dist/tabs/tabs-list.mjs +2 -0
- package/dist/tabs/tabs-list.mjs.map +1 -1
- package/dist/tabs/tabs-panel.d.mts +19 -0
- package/dist/tabs/tabs-panel.d.mts.map +1 -1
- package/dist/tabs/tabs-panel.mjs +2 -0
- package/dist/tabs/tabs-panel.mjs.map +1 -1
- package/dist/tabs/tabs-root.d.mts +39 -5
- package/dist/tabs/tabs-root.d.mts.map +1 -1
- package/dist/tabs/tabs-root.mjs +2 -0
- package/dist/tabs/tabs-root.mjs.map +1 -1
- package/dist/tabs/tabs-tab.d.mts +22 -1
- package/dist/tabs/tabs-tab.d.mts.map +1 -1
- package/dist/tabs/tabs-tab.mjs +2 -0
- package/dist/tabs/tabs-tab.mjs.map +1 -1
- package/dist/toast/index.d.mts +2 -0
- package/dist/toast/index.d.mts.map +1 -1
- package/dist/toast/index.mjs +2 -0
- package/dist/toast/index.mjs.map +1 -1
- package/dist/toast/toast-action.d.mts +28 -3
- package/dist/toast/toast-action.d.mts.map +1 -1
- package/dist/toast/toast-action.mjs +2 -0
- package/dist/toast/toast-action.mjs.map +1 -1
- package/dist/toast/toast-close.d.mts +16 -0
- package/dist/toast/toast-close.d.mts.map +1 -1
- package/dist/toast/toast-close.mjs +2 -0
- package/dist/toast/toast-close.mjs.map +1 -1
- package/dist/toast/toast-description.d.mts +16 -1
- package/dist/toast/toast-description.d.mts.map +1 -1
- package/dist/toast/toast-description.mjs +2 -0
- package/dist/toast/toast-description.mjs.map +1 -1
- package/dist/toast/toast-root.d.mts +20 -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-title.d.mts +15 -1
- package/dist/toast/toast-title.d.mts.map +1 -1
- package/dist/toast/toast-title.mjs +2 -0
- package/dist/toast/toast-title.mjs.map +1 -1
- package/dist/toast/toast-viewport.d.mts +34 -5
- package/dist/toast/toast-viewport.d.mts.map +1 -1
- package/dist/toast/toast-viewport.mjs +6 -5
- package/dist/toast/toast-viewport.mjs.map +1 -1
- package/dist/toast/toast.d.mts +46 -6
- package/dist/toast/toast.d.mts.map +1 -1
- package/dist/toast/toast.mjs +4 -0
- package/dist/toast/toast.mjs.map +1 -1
- package/dist/toggle/toggle.d.mts +20 -2
- package/dist/toggle/toggle.d.mts.map +1 -1
- package/dist/toggle/toggle.mjs +2 -0
- package/dist/toggle/toggle.mjs.map +1 -1
- package/dist/toggle-group/index.d.mts +2 -0
- package/dist/toggle-group/index.d.mts.map +1 -1
- package/dist/toggle-group/index.mjs +2 -0
- package/dist/toggle-group/index.mjs.map +1 -1
- package/dist/toggle-group/toggle-group-context.d.mts +1 -0
- 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 +16 -0
- package/dist/toggle-group/toggle-group-item.d.mts.map +1 -1
- package/dist/toggle-group/toggle-group-item.mjs +2 -0
- package/dist/toggle-group/toggle-group-item.mjs.map +1 -1
- package/dist/toggle-group/toggle-group-root.d.mts +73 -12
- package/dist/toggle-group/toggle-group-root.d.mts.map +1 -1
- package/dist/toggle-group/toggle-group-root.mjs +6 -5
- package/dist/toggle-group/toggle-group-root.mjs.map +1 -1
- package/dist/toolbar/index.d.mts +2 -0
- package/dist/toolbar/index.d.mts.map +1 -1
- package/dist/toolbar/index.mjs +2 -0
- package/dist/toolbar/index.mjs.map +1 -1
- package/dist/toolbar/toolbar-root.d.mts +30 -3
- package/dist/toolbar/toolbar-root.d.mts.map +1 -1
- package/dist/toolbar/toolbar-root.mjs +2 -0
- package/dist/toolbar/toolbar-root.mjs.map +1 -1
- package/dist/toolbar/toolbar-separator.d.mts +13 -0
- package/dist/toolbar/toolbar-separator.d.mts.map +1 -1
- package/dist/toolbar/toolbar-separator.mjs +2 -0
- package/dist/toolbar/toolbar-separator.mjs.map +1 -1
- package/dist/tooltip/index.d.mts +2 -0
- package/dist/tooltip/index.d.mts.map +1 -1
- package/dist/tooltip/index.mjs +2 -0
- package/dist/tooltip/index.mjs.map +1 -1
- package/dist/tooltip/tooltip-arrow.d.mts +16 -0
- package/dist/tooltip/tooltip-arrow.d.mts.map +1 -1
- package/dist/tooltip/tooltip-arrow.mjs +2 -0
- package/dist/tooltip/tooltip-arrow.mjs.map +1 -1
- package/dist/tooltip/tooltip-context.d.mts +4 -0
- package/dist/tooltip/tooltip-context.d.mts.map +1 -1
- package/dist/tooltip/tooltip-context.mjs.map +1 -1
- package/dist/tooltip/tooltip-popup.d.mts +24 -3
- package/dist/tooltip/tooltip-popup.d.mts.map +1 -1
- package/dist/tooltip/tooltip-popup.mjs +2 -0
- package/dist/tooltip/tooltip-popup.mjs.map +1 -1
- package/dist/tooltip/tooltip-root.d.mts +24 -2
- package/dist/tooltip/tooltip-root.d.mts.map +1 -1
- package/dist/tooltip/tooltip-root.mjs +2 -0
- package/dist/tooltip/tooltip-root.mjs.map +1 -1
- package/dist/tooltip/tooltip-trigger.d.mts +18 -1
- package/dist/tooltip/tooltip-trigger.d.mts.map +1 -1
- package/dist/tooltip/tooltip-trigger.mjs +2 -0
- package/dist/tooltip/tooltip-trigger.mjs.map +1 -1
- package/package.json +9 -1
- package/skills/funstack-ui-knowledge/SKILL.md +75 -0
- package/dist/internal/invoker-press.mjs.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"form-submit.mjs","names":[],"sources":["../../src/form/form-submit.tsx"],"sourcesContent":["\"use client\";\nimport type { ComponentPropsWithRef, CSSProperties, ReactNode } from \"react\";\nimport { useFormStatus } from \"react-dom\";\nimport { dataAttr } from \"../internal/data-attr.js\";\nimport type { RenderProp, StateValue } from \"../internal/types.js\";\nimport { useElementCheck } from \"../internal/use-element-check.js\";\nimport { rendersButton, useRender } from \"../internal/use-render.js\";\n\nconst isDev = process.env.NODE_ENV !== \"production\";\n\nexport interface FormSubmitState {\n /** The enclosing form's submission is in flight (`useFormStatus().pending`). */\n readonly pending: boolean;\n readonly disabled: boolean;\n}\n\nexport interface FormSubmitProps extends Omit<\n ComponentPropsWithRef<\"button\">,\n \"type\" | \"className\" | \"style\" | \"children\"\n> {\n /**\n * Native `disabled`; owned. Never set by the library (conventions 3.6). Always native, also\n * with a component `render`: a submitter has no handler to honour `aria-disabled`.\n */\n disabled?: boolean;\n className?: StateValue<string | undefined, FormSubmitState>;\n style?: StateValue<CSSProperties | undefined, FormSubmitState>;\n children?: StateValue<ReactNode, FormSubmitState>;\n render?: RenderProp<ComponentPropsWithRef<\"button\">, FormSubmitState>;\n}\n\n/**\n * The form's submit button: `<button type=\"submit\">` with `data-pending` while the enclosing\n * form's submission is in flight (`useFormStatus`). Works in any React-rendered form\n * (`Form.Root`, `Dialog.Form`, a plain `<form action>`). Never disabled while pending: block\n * repeat clicks with CSS on `[data-pending]` if you need to.\n *\n * Owned keys (conventions 1.2): `type` (on a `<button>`), `disabled`, `data-pending`,\n * `data-disabled`.\n */\nexport function FormSubmit({\n disabled = false,\n className,\n style,\n children,\n render,\n ...rest\n}: FormSubmitProps) {\n const { pending } = useFormStatus();\n const ref = useElementCheck(\n isDev &&\n ((el) => {\n const submitter =\n el.tagName === \"BUTTON\" ||\n (el.tagName === \"INPUT\" && [\"submit\", \"image\"].includes((el as HTMLInputElement).type));\n return submitter\n ? null\n : `Form.Submit: expected to render a <button> (or <input type=\"submit\">) but got ` +\n `<${el.tagName.toLowerCase()}>. Only a submit button submits the form natively.`;\n }),\n );\n const state: FormSubmitState = { pending, disabled };\n return useRender<ComponentPropsWithRef<\"button\">, FormSubmitState>({\n defaultElement: \"button\",\n render,\n state,\n className,\n style,\n children,\n props: rest,\n libraryProps: {\n ...(rendersButton(render) && { type: \"submit\" as const }),\n disabled,\n \"data-pending\": dataAttr(pending),\n \"data-disabled\": dataAttr(disabled),\n },\n ref,\n });\n}\n\nFormSubmit.displayName = \"FormSubmit\";\n"],"mappings":";;;;;;;AAQA,MAAM,QAAQ,QAAQ,IAAI,aAAa
|
|
1
|
+
{"version":3,"file":"form-submit.mjs","names":[],"sources":["../../src/form/form-submit.tsx"],"sourcesContent":["\"use client\";\nimport type { ComponentPropsWithRef, CSSProperties, ReactNode } from \"react\";\nimport { useFormStatus } from \"react-dom\";\nimport { dataAttr } from \"../internal/data-attr.js\";\nimport type { RenderProp, StateValue } from \"../internal/types.js\";\nimport { useElementCheck } from \"../internal/use-element-check.js\";\nimport { rendersButton, useRender } from \"../internal/use-render.js\";\n\nconst isDev = process.env.NODE_ENV !== \"production\";\n\n/**\n * State of `Form.Submit`, passed to the function forms of `className`, `style`, `children` and\n * `render`.\n */\nexport interface FormSubmitState {\n /** The enclosing form's submission is in flight (`useFormStatus().pending`). */\n readonly pending: boolean;\n /** The `disabled` prop (never set by the library while pending). */\n readonly disabled: boolean;\n}\n\n/**\n * Props of `Form.Submit`.\n *\n * @see https://ui.funstack.work/components/field\n */\nexport interface FormSubmitProps extends Omit<\n ComponentPropsWithRef<\"button\">,\n \"type\" | \"className\" | \"style\" | \"children\"\n> {\n /**\n * Native `disabled`; owned. Never set by the library (conventions 3.6). Always native, also\n * with a component `render`: a submitter has no handler to honour `aria-disabled`.\n *\n * @defaultValue `false`\n */\n disabled?: boolean;\n /** Class name, or a function of the part's state that returns one. */\n className?: StateValue<string | undefined, FormSubmitState>;\n /** Inline style, or a function of the part's state that returns one. */\n style?: StateValue<CSSProperties | undefined, FormSubmitState>;\n /** Content, or a function of the part's state. */\n children?: StateValue<ReactNode, FormSubmitState>;\n /** Replace the default `<button>` (element form) or take over rendering (function form). */\n render?: RenderProp<ComponentPropsWithRef<\"button\">, FormSubmitState>;\n}\n\n/**\n * The form's submit button: `<button type=\"submit\">` with `data-pending` while the enclosing\n * form's submission is in flight (`useFormStatus`). Works in any React-rendered form\n * (`Form.Root`, `Dialog.Form`, a plain `<form action>`). Never disabled while pending: block\n * repeat clicks with CSS on `[data-pending]` if you need to.\n *\n * Owned keys (conventions 1.2): `type` (on a `<button>`), `disabled`, `data-pending`,\n * `data-disabled`.\n *\n * @see https://ui.funstack.work/components/field\n */\nexport function FormSubmit({\n disabled = false,\n className,\n style,\n children,\n render,\n ...rest\n}: FormSubmitProps) {\n const { pending } = useFormStatus();\n const ref = useElementCheck(\n isDev &&\n ((el) => {\n const submitter =\n el.tagName === \"BUTTON\" ||\n (el.tagName === \"INPUT\" && [\"submit\", \"image\"].includes((el as HTMLInputElement).type));\n return submitter\n ? null\n : `Form.Submit: expected to render a <button> (or <input type=\"submit\">) but got ` +\n `<${el.tagName.toLowerCase()}>. Only a submit button submits the form natively.`;\n }),\n );\n const state: FormSubmitState = { pending, disabled };\n return useRender<ComponentPropsWithRef<\"button\">, FormSubmitState>({\n defaultElement: \"button\",\n render,\n state,\n className,\n style,\n children,\n props: rest,\n libraryProps: {\n ...(rendersButton(render) && { type: \"submit\" as const }),\n disabled,\n \"data-pending\": dataAttr(pending),\n \"data-disabled\": dataAttr(disabled),\n },\n ref,\n });\n}\n\nFormSubmit.displayName = \"FormSubmit\";\n"],"mappings":";;;;;;;AAQA,MAAM,QAAQ,QAAQ,IAAI,aAAa;;;;;;;;;;;;AAkDvC,SAAgB,WAAW,EACzB,WAAW,OACX,WACA,OACA,UACA,QACA,GAAG,QACe;CAClB,MAAM,EAAE,YAAY,cAAc;CAClC,MAAM,MAAM,gBACV,WACI,OAAO;EAIP,OAFE,GAAG,YAAY,YACd,GAAG,YAAY,WAAW,CAAC,UAAU,OAAO,CAAC,CAAC,SAAU,GAAwB,IAAI,IAEnF,OACA,kFACM,GAAG,QAAQ,YAAY,EAAE;CACrC,EACJ;CAEA,OAAO,UAA4D;EACjE,gBAAgB;EAChB;EACA,OAAA;GAJ+B;GAAS;EAIpC;EACJ;EACA;EACA;EACA,OAAO;EACP,cAAc;GACZ,GAAI,cAAc,MAAM,KAAK,EAAE,MAAM,SAAkB;GACvD;GACA,gBAAgB,SAAS,OAAO;GAChC,iBAAiB,SAAS,QAAQ;EACpC;EACA;CACF,CAAC;AACH;AAEA,WAAW,cAAc"}
|
package/dist/form/index.d.mts
CHANGED
|
@@ -2,6 +2,13 @@ import { FieldErrorValue, FormErrors } from "../internal/validity.mjs";
|
|
|
2
2
|
import { FormRoot, FormRootProps, FormRootState } from "./form-root.mjs";
|
|
3
3
|
import { FormSubmit, FormSubmitProps, FormSubmitState } from "./form-submit.mjs";
|
|
4
4
|
//#region src/form/index.d.ts
|
|
5
|
+
/**
|
|
6
|
+
* Form: `Root` (`form`) runs its `action` in a transition with `data-pending`, routes server
|
|
7
|
+
* `errors` to the matching `Field.Root`s, focuses the first invalid field and resets only when the
|
|
8
|
+
* action reported no errors; `Submit` (`button[type=submit]`) shows the form's pending state.
|
|
9
|
+
*
|
|
10
|
+
* @see https://ui.funstack.work/components/field
|
|
11
|
+
*/
|
|
5
12
|
export declare const Form: {
|
|
6
13
|
readonly Root: typeof FormRoot;
|
|
7
14
|
readonly Submit: typeof FormSubmit;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","names":[],"sources":["../../src/form/index.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../../src/form/index.ts"],"mappings":";;;;;;;;;;;qBAUa;WAAS,aAAI;WAAY,eAAM"}
|
package/dist/form/index.mjs
CHANGED
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
import { FormRoot } from "./form-root.mjs";
|
|
2
2
|
import { FormSubmit } from "./form-submit.mjs";
|
|
3
3
|
//#region src/form/index.ts
|
|
4
|
+
/**
|
|
5
|
+
* Form: `Root` (`form`) runs its `action` in a transition with `data-pending`, routes server
|
|
6
|
+
* `errors` to the matching `Field.Root`s, focuses the first invalid field and resets only when the
|
|
7
|
+
* action reported no errors; `Submit` (`button[type=submit]`) shows the form's pending state.
|
|
8
|
+
*
|
|
9
|
+
* @see https://ui.funstack.work/components/field
|
|
10
|
+
*/
|
|
4
11
|
const Form = {
|
|
5
12
|
Root: FormRoot,
|
|
6
13
|
Submit: FormSubmit
|
package/dist/form/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":[],"sources":["../../src/form/index.ts"],"sourcesContent":["import { FormRoot } from \"./form-root.js\";\nimport { FormSubmit } from \"./form-submit.js\";\n\nexport const Form = { Root: FormRoot, Submit: FormSubmit } as const;\n\nexport type { FormRootProps, FormRootState, FormErrors, FieldErrorValue } from \"./form-root.js\";\nexport type { FormSubmitProps, FormSubmitState } from \"./form-submit.js\";\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../../src/form/index.ts"],"sourcesContent":["import { FormRoot } from \"./form-root.js\";\nimport { FormSubmit } from \"./form-submit.js\";\n\n/**\n * Form: `Root` (`form`) runs its `action` in a transition with `data-pending`, routes server\n * `errors` to the matching `Field.Root`s, focuses the first invalid field and resets only when the\n * action reported no errors; `Submit` (`button[type=submit]`) shows the form's pending state.\n *\n * @see https://ui.funstack.work/components/field\n */\nexport const Form = { Root: FormRoot, Submit: FormSubmit } as const;\n\nexport type { FormRootProps, FormRootState, FormErrors, FieldErrorValue } from \"./form-root.js\";\nexport type { FormSubmitProps, FormSubmitState } from \"./form-submit.js\";\n"],"mappings":";;;;;;;;;;AAUA,MAAa,OAAO;CAAE,MAAM;CAAU,QAAQ;AAAW"}
|
package/dist/index.d.mts
CHANGED
|
@@ -80,6 +80,7 @@ import { Popover } from "./popover/index.mjs";
|
|
|
80
80
|
import { MenuItemDetails, MenuItemProps, MenuItemState } from "./menu/menu-item.mjs";
|
|
81
81
|
import { MenuCheckboxItemProps, MenuCheckboxItemState } from "./menu/menu-checkbox-item.mjs";
|
|
82
82
|
import { MenuTriggerProps, MenuTriggerState } from "./menu/menu-trigger.mjs";
|
|
83
|
+
import { MenuContextTriggerProps, MenuContextTriggerState } from "./menu/menu-context-trigger.mjs";
|
|
83
84
|
import { MenuGroupLabelProps, MenuGroupLabelState, MenuGroupProps, MenuGroupState, MenuSeparatorProps, MenuSeparatorState } from "./menu/menu-group.mjs";
|
|
84
85
|
import { MenuAlign, MenuPopupProps, MenuPopupState, MenuSide } from "./menu/menu-popup.mjs";
|
|
85
86
|
import { MenuRadioGroupProps, MenuRadioGroupState } from "./menu/menu-radio-group.mjs";
|
|
@@ -132,4 +133,4 @@ import { MeterLabelProps } from "./meter/meter-label.mjs";
|
|
|
132
133
|
import { MeterTrackProps } from "./meter/meter-track.mjs";
|
|
133
134
|
import { MeterValueProps } from "./meter/meter-value.mjs";
|
|
134
135
|
import { Meter } from "./meter/index.mjs";
|
|
135
|
-
export { Accordion, type AccordionItemProps, type AccordionItemState, type AccordionPanelProps, type AccordionPanelState, type AccordionRootExclusiveProps, type AccordionRootMultipleProps, type AccordionRootProps, type AccordionRootState, type AccordionTriggerProps, type AccordionTriggerState, type AccordionValueChangeDetails, type Action, type ActionDetails, Button, type ButtonActionDetails, type ButtonProps, type ButtonState, CSPProvider, type CSPProviderProps, type ChangeAction, type ChangeReason, Checkbox, type CheckboxCheckedChangeDetails, CheckboxGroup, type CheckboxGroupItemProps, type CheckboxGroupItemState, type CheckboxGroupLabelProps, type CheckboxGroupParentProps, type CheckboxGroupParentState, type CheckboxGroupRootProps, type CheckboxGroupRootState, type CheckboxGroupValueChangeDetails, type CheckboxProps, type CheckboxState, Combobox, type ComboboxClearProps, type ComboboxClearState, type ComboboxEmptyProps, type ComboboxEmptyState, type ComboboxGroupLabelProps, type ComboboxGroupLabelState, type ComboboxGroupProps, type ComboboxGroupState, type ComboboxInputProps, type ComboboxInputState, type ComboboxInputValueChangeDetails, type ComboboxLabelProps, type ComboboxLabelState, type ComboboxListProps, type ComboboxListState, type ComboboxOpenChangeDetails, type ComboboxOptionProps, type ComboboxOptionState, type ComboboxPopupProps, type ComboboxPopupState, type ComboboxRootProps, type ComboboxRootState, type ComboboxStatusProps, type ComboboxStatusState, type ComboboxTriggerProps, type ComboboxTriggerState, type ComboboxValueChangeDetails, Dialog, type DialogCloseDetails, type DialogCloseProps, type DialogCloseState, type DialogDescriptionProps, type DialogDescriptionState, type DialogFormProps, type DialogFormState, type DialogOpenChangeDetails, type DialogPopupProps, type DialogPopupState, type DialogRootProps, type DialogRootState, type DialogTitleProps, type DialogTitleState, type DialogTriggerProps, type DialogTriggerState, Field, type FieldControlProps, type FieldDescriptionProps, type FieldErrorProps, type FieldErrorValue, type FieldLabelProps, type FieldRootProps, type FieldState, type FieldValidate, type FieldValidity, Form, type FormErrors, type FormRootProps, type FormRootState, type FormSubmitProps, type FormSubmitState, Menu, type MenuAlign, type MenuCheckboxItemProps, type MenuCheckboxItemState, type MenuGroupLabelProps, type MenuGroupLabelState, type MenuGroupProps, type MenuGroupState, type MenuItemDetails, type MenuItemProps, type MenuItemState, type MenuOpenChangeDetails, type MenuPopupProps, type MenuPopupState, type MenuRadioGroupProps, type MenuRadioGroupState, type MenuRadioItemProps, type MenuRadioItemState, type MenuRootProps, type MenuRootState, type MenuSeparatorProps, type MenuSeparatorState, type MenuSide, type MenuSubmenuTriggerProps, type MenuSubmenuTriggerState, type MenuTriggerProps, type MenuTriggerState, Meter, type MeterIndicatorProps, type MeterLabelProps, type MeterRegion, type MeterRootProps, type MeterState, type MeterTrackProps, type MeterValueProps, NumberField, type NumberFieldButtonState, type NumberFieldDecrementProps, type NumberFieldIncrementProps, type NumberFieldInputProps, type NumberFieldLabelProps, type NumberFieldRootProps, type NumberFieldState, type NumberFieldValueChangeDetails, Popover, type PopoverAlign, type PopoverCloseProps, type PopoverCloseState, type PopoverDescriptionProps, type PopoverDescriptionState, type PopoverOpenChangeDetails, type PopoverPopupProps, type PopoverPopupState, type PopoverRootProps, type PopoverRootState, type PopoverSide, type PopoverTitleProps, type PopoverTitleState, type PopoverTriggerProps, type PopoverTriggerState, Progress, type ProgressIndicatorProps, type ProgressLabelProps, type ProgressRootProps, type ProgressState, type ProgressTrackProps, type ProgressValueProps, RadioGroup, type RadioGroupItemProps, type RadioGroupItemState, type RadioGroupLabelProps, type RadioGroupRootProps, type RadioGroupRootState, type RadioGroupValueChangeDetails, type RenderProp, STYLE_SHA256, Select, type SelectGroupLabelProps, type SelectGroupProps, type SelectOptionProps, type SelectOptionState, type SelectRootProps, type SelectRootState, type SelectSeparatorProps, type SelectTriggerProps, type SelectValueChangeDetails, type SelectValueProps, Slider, type SliderIndicatorProps, type SliderIndicatorState, type SliderLabelProps, type SliderOrientation, type SliderRootProps, type SliderRootState, type SliderThumbProps, type SliderThumbState, type SliderTrackProps, type SliderTrackState, type SliderValue, type SliderValueChangeDetails, type SliderValueCommitDetails, type SliderValueProps, type SliderValueState, type StateValue, Switch, type SwitchCheckedChangeDetails, type SwitchProps, type SwitchState, Tabs, type TabsActivationMode, type TabsIndicatorProps, type TabsIndicatorState, type TabsListProps, type TabsListState, type TabsOrientation, type TabsPanelProps, type TabsPanelState, type TabsRootProps, type TabsRootState, type TabsTabProps, type TabsTabState, type TabsValueChangeDetails, Toast, type ToastActionDetails, type ToastActionOptions, type ToastActionProps, type ToastActionState, type ToastCloseDetails, type ToastCloseProps, type ToastCloseState, type ToastDescriptionProps, type ToastItem, type ToastManager, type ToastOptions, type ToastPriority, type ToastPromiseOptions, type ToastRootProps, type ToastRootState, type ToastTitleProps, type ToastViewportProps, type ToastViewportState, Toggle, ToggleGroup, type ToggleGroupExclusiveProps, type ToggleGroupItemProps, type ToggleGroupItemState, type ToggleGroupMultipleProps, type ToggleGroupOrientation, type ToggleGroupRootProps, type ToggleGroupRootState, type ToggleGroupValueChangeDetails, type TogglePressedChangeDetails, type ToggleProps, type ToggleState, Toolbar, type ToolbarOrientation, type ToolbarRootProps, type ToolbarRootState, type ToolbarSeparatorProps, type ToolbarSeparatorState, Tooltip, type TooltipAlign, type TooltipArrowProps, type TooltipArrowState, type TooltipPopupProps, type TooltipPopupState, type TooltipProvides, type TooltipRootProps, type TooltipRootState, type TooltipSide, type TooltipTriggerProps, type TooltipTriggerState, type UrgentChangeHandler, createToastManager, toast };
|
|
136
|
+
export { Accordion, type AccordionItemProps, type AccordionItemState, type AccordionPanelProps, type AccordionPanelState, type AccordionRootExclusiveProps, type AccordionRootMultipleProps, type AccordionRootProps, type AccordionRootState, type AccordionTriggerProps, type AccordionTriggerState, type AccordionValueChangeDetails, type Action, type ActionDetails, Button, type ButtonActionDetails, type ButtonProps, type ButtonState, CSPProvider, type CSPProviderProps, type ChangeAction, type ChangeReason, Checkbox, type CheckboxCheckedChangeDetails, CheckboxGroup, type CheckboxGroupItemProps, type CheckboxGroupItemState, type CheckboxGroupLabelProps, type CheckboxGroupParentProps, type CheckboxGroupParentState, type CheckboxGroupRootProps, type CheckboxGroupRootState, type CheckboxGroupValueChangeDetails, type CheckboxProps, type CheckboxState, Combobox, type ComboboxClearProps, type ComboboxClearState, type ComboboxEmptyProps, type ComboboxEmptyState, type ComboboxGroupLabelProps, type ComboboxGroupLabelState, type ComboboxGroupProps, type ComboboxGroupState, type ComboboxInputProps, type ComboboxInputState, type ComboboxInputValueChangeDetails, type ComboboxLabelProps, type ComboboxLabelState, type ComboboxListProps, type ComboboxListState, type ComboboxOpenChangeDetails, type ComboboxOptionProps, type ComboboxOptionState, type ComboboxPopupProps, type ComboboxPopupState, type ComboboxRootProps, type ComboboxRootState, type ComboboxStatusProps, type ComboboxStatusState, type ComboboxTriggerProps, type ComboboxTriggerState, type ComboboxValueChangeDetails, Dialog, type DialogCloseDetails, type DialogCloseProps, type DialogCloseState, type DialogDescriptionProps, type DialogDescriptionState, type DialogFormProps, type DialogFormState, type DialogOpenChangeDetails, type DialogPopupProps, type DialogPopupState, type DialogRootProps, type DialogRootState, type DialogTitleProps, type DialogTitleState, type DialogTriggerProps, type DialogTriggerState, Field, type FieldControlProps, type FieldDescriptionProps, type FieldErrorProps, type FieldErrorValue, type FieldLabelProps, type FieldRootProps, type FieldState, type FieldValidate, type FieldValidity, Form, type FormErrors, type FormRootProps, type FormRootState, type FormSubmitProps, type FormSubmitState, Menu, type MenuAlign, type MenuCheckboxItemProps, type MenuCheckboxItemState, type MenuContextTriggerProps, type MenuContextTriggerState, type MenuGroupLabelProps, type MenuGroupLabelState, type MenuGroupProps, type MenuGroupState, type MenuItemDetails, type MenuItemProps, type MenuItemState, type MenuOpenChangeDetails, type MenuPopupProps, type MenuPopupState, type MenuRadioGroupProps, type MenuRadioGroupState, type MenuRadioItemProps, type MenuRadioItemState, type MenuRootProps, type MenuRootState, type MenuSeparatorProps, type MenuSeparatorState, type MenuSide, type MenuSubmenuTriggerProps, type MenuSubmenuTriggerState, type MenuTriggerProps, type MenuTriggerState, Meter, type MeterIndicatorProps, type MeterLabelProps, type MeterRegion, type MeterRootProps, type MeterState, type MeterTrackProps, type MeterValueProps, NumberField, type NumberFieldButtonState, type NumberFieldDecrementProps, type NumberFieldIncrementProps, type NumberFieldInputProps, type NumberFieldLabelProps, type NumberFieldRootProps, type NumberFieldState, type NumberFieldValueChangeDetails, Popover, type PopoverAlign, type PopoverCloseProps, type PopoverCloseState, type PopoverDescriptionProps, type PopoverDescriptionState, type PopoverOpenChangeDetails, type PopoverPopupProps, type PopoverPopupState, type PopoverRootProps, type PopoverRootState, type PopoverSide, type PopoverTitleProps, type PopoverTitleState, type PopoverTriggerProps, type PopoverTriggerState, Progress, type ProgressIndicatorProps, type ProgressLabelProps, type ProgressRootProps, type ProgressState, type ProgressTrackProps, type ProgressValueProps, RadioGroup, type RadioGroupItemProps, type RadioGroupItemState, type RadioGroupLabelProps, type RadioGroupRootProps, type RadioGroupRootState, type RadioGroupValueChangeDetails, type RenderProp, STYLE_SHA256, Select, type SelectGroupLabelProps, type SelectGroupProps, type SelectOptionProps, type SelectOptionState, type SelectRootProps, type SelectRootState, type SelectSeparatorProps, type SelectTriggerProps, type SelectValueChangeDetails, type SelectValueProps, Slider, type SliderIndicatorProps, type SliderIndicatorState, type SliderLabelProps, type SliderOrientation, type SliderRootProps, type SliderRootState, type SliderThumbProps, type SliderThumbState, type SliderTrackProps, type SliderTrackState, type SliderValue, type SliderValueChangeDetails, type SliderValueCommitDetails, type SliderValueProps, type SliderValueState, type StateValue, Switch, type SwitchCheckedChangeDetails, type SwitchProps, type SwitchState, Tabs, type TabsActivationMode, type TabsIndicatorProps, type TabsIndicatorState, type TabsListProps, type TabsListState, type TabsOrientation, type TabsPanelProps, type TabsPanelState, type TabsRootProps, type TabsRootState, type TabsTabProps, type TabsTabState, type TabsValueChangeDetails, Toast, type ToastActionDetails, type ToastActionOptions, type ToastActionProps, type ToastActionState, type ToastCloseDetails, type ToastCloseProps, type ToastCloseState, type ToastDescriptionProps, type ToastItem, type ToastManager, type ToastOptions, type ToastPriority, type ToastPromiseOptions, type ToastRootProps, type ToastRootState, type ToastTitleProps, type ToastViewportProps, type ToastViewportState, Toggle, ToggleGroup, type ToggleGroupExclusiveProps, type ToggleGroupItemProps, type ToggleGroupItemState, type ToggleGroupMultipleProps, type ToggleGroupOrientation, type ToggleGroupRootProps, type ToggleGroupRootState, type ToggleGroupValueChangeDetails, type TogglePressedChangeDetails, type ToggleProps, type ToggleState, Toolbar, type ToolbarOrientation, type ToolbarRootProps, type ToolbarRootState, type ToolbarSeparatorProps, type ToolbarSeparatorState, Tooltip, type TooltipAlign, type TooltipArrowProps, type TooltipArrowState, type TooltipPopupProps, type TooltipPopupState, type TooltipProvides, type TooltipRootProps, type TooltipRootState, type TooltipSide, type TooltipTriggerProps, type TooltipTriggerState, type UrgentChangeHandler, createToastManager, toast };
|
|
@@ -1,15 +1,20 @@
|
|
|
1
|
-
"use client";
|
|
2
1
|
//#region src/internal/announce.ts
|
|
2
|
+
/** Whether `target` has `ariaNotify()` (not jsdom, nor a lagging test build). */
|
|
3
|
+
function canAnnounce(target) {
|
|
4
|
+
return typeof target.ariaNotify === "function";
|
|
5
|
+
}
|
|
3
6
|
/**
|
|
4
|
-
* Speaks `message` in the context of `
|
|
5
|
-
* message, or an engine without `ariaNotify
|
|
7
|
+
* Speaks `message` in the context of `target` through `target.ariaNotify()`, with `priority`
|
|
8
|
+
* when given. An empty message, or an engine without `ariaNotify`, announces nothing.
|
|
6
9
|
*/
|
|
7
|
-
function announce(
|
|
10
|
+
function announce(target, message, priority) {
|
|
8
11
|
if (message === "") return;
|
|
9
|
-
const notifying =
|
|
10
|
-
if (typeof notifying.ariaNotify
|
|
12
|
+
const notifying = target;
|
|
13
|
+
if (typeof notifying.ariaNotify !== "function") return;
|
|
14
|
+
if (priority === void 0) notifying.ariaNotify(message);
|
|
15
|
+
else notifying.ariaNotify(message, { priority });
|
|
11
16
|
}
|
|
12
17
|
//#endregion
|
|
13
|
-
export { announce };
|
|
18
|
+
export { announce, canAnnounce };
|
|
14
19
|
|
|
15
20
|
//# sourceMappingURL=announce.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"announce.mjs","names":[],"sources":["../../src/internal/announce.ts"],"sourcesContent":["
|
|
1
|
+
{"version":3,"file":"announce.mjs","names":[],"sources":["../../src/internal/announce.ts"],"sourcesContent":["// Directive-free: screen-reader announcements (design/components/number-field.md 8.3,\n// conventions 8) through `ariaNotify()`, which every supported engine has (Chrome 141,\n// Firefox 150, Safari 27). No live region fallback (docs/vision.md: no fallbacks): a region in\n// `document.body` would be inert under a modal dialog anyway. No part renders a live region for\n// these announcements.\n\n/** `ariaNotify()` on an element or a document, where the engine has it (not in the DOM types yet). */\ninterface AriaNotifyTarget {\n ariaNotify?: (announcement: string, options?: { priority?: \"normal\" | \"high\" }) => void;\n}\n\n/** Whether `target` has `ariaNotify()` (not jsdom, nor a lagging test build). */\nexport function canAnnounce(target: Element | Document): boolean {\n return typeof (target as AriaNotifyTarget).ariaNotify === \"function\";\n}\n\n/**\n * Speaks `message` in the context of `target` through `target.ariaNotify()`, with `priority`\n * when given. An empty message, or an engine without `ariaNotify`, announces nothing.\n */\nexport function announce(\n target: Element | Document,\n message: string,\n priority?: \"normal\" | \"high\",\n): void {\n if (message === \"\") return;\n const notifying = target as AriaNotifyTarget;\n if (typeof notifying.ariaNotify !== \"function\") return;\n if (priority === undefined) notifying.ariaNotify(message);\n else notifying.ariaNotify(message, { priority });\n}\n"],"mappings":";;AAYA,SAAgB,YAAY,QAAqC;CAC/D,OAAO,OAAQ,OAA4B,eAAe;AAC5D;;;;;AAMA,SAAgB,SACd,QACA,SACA,UACM;CACN,IAAI,YAAY,IAAI;CACpB,MAAM,YAAY;CAClB,IAAI,OAAO,UAAU,eAAe,YAAY;CAChD,IAAI,aAAa,KAAA,GAAW,UAAU,WAAW,OAAO;MACnD,UAAU,WAAW,SAAS,EAAE,SAAS,CAAC;AACjD"}
|
|
@@ -1,15 +1,6 @@
|
|
|
1
1
|
import { sortByDocumentOrder } from "./dom-order.mjs";
|
|
2
|
+
import { announce } from "./announce.mjs";
|
|
2
3
|
//#region src/internal/focus-first-invalid.ts
|
|
3
|
-
/**
|
|
4
|
-
* Speaks `message` through `element.ariaNotify()` where the browser has it (design 5.3: the
|
|
5
|
-
* error is read when focus moves to the control; when focus is already there nothing would be
|
|
6
|
-
* read). Does nothing without `ariaNotify` or with an empty message.
|
|
7
|
-
*/
|
|
8
|
-
function announce(element, message) {
|
|
9
|
-
const notifying = element;
|
|
10
|
-
if (message === "" || typeof notifying.ariaNotify !== "function") return;
|
|
11
|
-
notifying.ariaNotify(message);
|
|
12
|
-
}
|
|
13
4
|
/** The submission attempt in progress: every target added during the current task. */
|
|
14
5
|
let batch = null;
|
|
15
6
|
/**
|
|
@@ -71,6 +62,6 @@ function focusFirst(current) {
|
|
|
71
62
|
}
|
|
72
63
|
}
|
|
73
64
|
//#endregion
|
|
74
|
-
export {
|
|
65
|
+
export { collectInvalid };
|
|
75
66
|
|
|
76
67
|
//# sourceMappingURL=focus-first-invalid.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"focus-first-invalid.mjs","names":[],"sources":["../../src/internal/focus-first-invalid.ts"],"sourcesContent":["// Directive-free: the module-level first-invalid collector (design/components/field-form.md 2.5).\nimport
|
|
1
|
+
{"version":3,"file":"focus-first-invalid.mjs","names":[],"sources":["../../src/internal/focus-first-invalid.ts"],"sourcesContent":["// Directive-free: the module-level first-invalid collector (design/components/field-form.md 2.5).\nimport { announce } from \"./announce.js\";\nimport { sortByDocumentOrder } from \"./dom-order.js\";\n\ninterface Batch {\n /** The elements whose `invalid` event was collected (a group's members, not its target). */\n readonly sources: Set<Element>;\n readonly targets: HTMLElement[];\n /** The message each target's Field shows, for the announcement when focus does not move. */\n readonly messages: Map<HTMLElement, string>;\n /** `document.activeElement` when the first target arrived. */\n readonly activeBefore: Element | null;\n /** The batch moved focus (later microtasks then re-focus, never announce). */\n moved: boolean;\n /** The target already announced. */\n announced: HTMLElement | null;\n}\n\n/** The submission attempt in progress: every target added during the current task. */\nlet batch: Batch | null = null;\n\n/**\n * Adds a control whose `invalid` event (fired on `source`) a Field cancelled during a submission\n * attempt, and focuses the first collected control in document order in a microtask, so the\n * result does not depend on the browser's dispatch order or on how many forms are on the page.\n *\n * The batch lives until the end of the task (a `setTimeout`), not just one microtask: when the\n * browser dispatches the `invalid` events itself (a click on a submit button), it runs a\n * microtask checkpoint after each listener, so the microtask of the first event runs before the\n * second event fires. Every add therefore queues a focus of the batch's first target; later ones\n * re-focus the same element, which is a no-op.\n *\n * A second `invalid` for the same `source` (the element the event fired on) starts a new batch:\n * one validation fires it once per element, so it belongs to the next attempt, even when that\n * attempt comes before the timer (two attempts in one task, or a test that does not yield to\n * timers between them). Joining the old batch would compare focus with the old attempt's.\n *\n * Skips the focus when focus moved during the attempt to an element that is not one of the\n * collected targets: a plain `<input required>` with no Field kept the platform's behaviour\n * (bubble and focus), and the library does not fight it.\n */\nexport function collectInvalid(target: HTMLElement | null, message: string, source: Element): void {\n if (target === null) return;\n if (batch !== null && batch.sources.has(source)) batch = null;\n if (batch === null) {\n const created: Batch = {\n sources: new Set(),\n targets: [],\n messages: new Map(),\n activeBefore: target.ownerDocument.activeElement,\n moved: false,\n announced: null,\n };\n batch = created;\n setTimeout(() => {\n if (batch === created) batch = null;\n }, 0);\n }\n const current = batch;\n current.sources.add(source);\n if (!current.targets.includes(target)) current.targets.push(target);\n current.messages.set(target, message);\n queueMicrotask(() => focusFirst(current));\n}\n\n/**\n * Tests only: forget the submission attempt in progress. Its timer is a task away, and the next\n * test can start before it runs (no task in between); its attempt would then join this one and\n * compare focus with an element of the previous test.\n */\nexport function resetInvalidBatch(): void {\n batch = null;\n}\n\nfunction focusFirst(current: Batch): void {\n const { targets, activeBefore } = current;\n const connected = targets.filter((t) => t.isConnected);\n if (connected.length === 0) return;\n const active = connected[0]!.ownerDocument.activeElement;\n if (active !== activeBefore && active !== null && !connected.includes(active as HTMLElement)) {\n return;\n }\n const first = sortByDocumentOrder(connected, (t) => t)[0]!;\n if (active !== first) {\n current.moved = true;\n first.focus();\n } else if (!current.moved && current.announced !== first) {\n // Focus was already on the first invalid control (an implicit submission with Enter): the\n // cancelled bubble was the only announcement, so speak the message instead.\n current.announced = first;\n announce(first, current.messages.get(first) ?? \"\");\n }\n}\n"],"mappings":";;;;AAmBA,IAAI,QAAsB;;;;;;;;;;;;;;;;;;;;;AAsB1B,SAAgB,eAAe,QAA4B,SAAiB,QAAuB;CACjG,IAAI,WAAW,MAAM;CACrB,IAAI,UAAU,QAAQ,MAAM,QAAQ,IAAI,MAAM,GAAG,QAAQ;CACzD,IAAI,UAAU,MAAM;EAClB,MAAM,UAAiB;GACrB,yBAAS,IAAI,IAAI;GACjB,SAAS,CAAC;GACV,0BAAU,IAAI,IAAI;GAClB,cAAc,OAAO,cAAc;GACnC,OAAO;GACP,WAAW;EACb;EACA,QAAQ;EACR,iBAAiB;GACf,IAAI,UAAU,SAAS,QAAQ;EACjC,GAAG,CAAC;CACN;CACA,MAAM,UAAU;CAChB,QAAQ,QAAQ,IAAI,MAAM;CAC1B,IAAI,CAAC,QAAQ,QAAQ,SAAS,MAAM,GAAG,QAAQ,QAAQ,KAAK,MAAM;CAClE,QAAQ,SAAS,IAAI,QAAQ,OAAO;CACpC,qBAAqB,WAAW,OAAO,CAAC;AAC1C;AAWA,SAAS,WAAW,SAAsB;CACxC,MAAM,EAAE,SAAS,iBAAiB;CAClC,MAAM,YAAY,QAAQ,QAAQ,MAAM,EAAE,WAAW;CACrD,IAAI,UAAU,WAAW,GAAG;CAC5B,MAAM,SAAS,UAAU,EAAE,CAAE,cAAc;CAC3C,IAAI,WAAW,gBAAgB,WAAW,QAAQ,CAAC,UAAU,SAAS,MAAqB,GACzF;CAEF,MAAM,QAAQ,oBAAoB,YAAY,MAAM,CAAC,CAAC,CAAC;CACvD,IAAI,WAAW,OAAO;EACpB,QAAQ,QAAQ;EAChB,MAAM,MAAM;CACd,OAAO,IAAI,CAAC,QAAQ,SAAS,QAAQ,cAAc,OAAO;EAGxD,QAAQ,YAAY;EACpB,SAAS,OAAO,QAAQ,SAAS,IAAI,KAAK,KAAK,EAAE;CACnD;AACF"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
//#region src/internal/focus-visible.ts
|
|
2
|
+
let focusVisibleOption;
|
|
3
|
+
/**
|
|
4
|
+
* The engine reads the `focusVisible` member of `focus()`'s options (Chromium 145, Firefox 104,
|
|
5
|
+
* Safari 18.4). Detected once through a getter: the bindings convert the dictionary before the
|
|
6
|
+
* method runs, so a detached element is enough and nothing is focused.
|
|
7
|
+
*/
|
|
8
|
+
function supportsFocusVisibleOption(doc) {
|
|
9
|
+
if (focusVisibleOption === void 0) {
|
|
10
|
+
let read = false;
|
|
11
|
+
try {
|
|
12
|
+
doc.createElement("div").focus({ get focusVisible() {
|
|
13
|
+
read = true;
|
|
14
|
+
return false;
|
|
15
|
+
} });
|
|
16
|
+
} catch {
|
|
17
|
+
read = false;
|
|
18
|
+
}
|
|
19
|
+
focusVisibleOption = read;
|
|
20
|
+
}
|
|
21
|
+
return focusVisibleOption;
|
|
22
|
+
}
|
|
23
|
+
//#endregion
|
|
24
|
+
export { supportsFocusVisibleOption };
|
|
25
|
+
|
|
26
|
+
//# sourceMappingURL=focus-visible.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"focus-visible.mjs","names":[],"sources":["../../src/internal/focus-visible.ts"],"sourcesContent":["// Directive-free: the `focus({ focusVisible })` probe behind a pointer open's quiet initial focus\n// (design/components/popover.md 6.1, menu.md 6.1).\n\n/**\n * An initial focus target opened by a pointer: where the engine reads `focus({ focusVisible })`,\n * the library focuses it with `focusVisible: false` right after `showPopover()` instead of\n * writing `autofocus` (WebKit shows the ring for an `autofocus` target after a click).\n * Elsewhere it is an ordinary target.\n */\nexport interface QuietFocusTarget {\n readonly element: HTMLElement;\n readonly focusVisible: false;\n}\n\nlet focusVisibleOption: boolean | undefined;\n\n/**\n * The engine reads the `focusVisible` member of `focus()`'s options (Chromium 145, Firefox 104,\n * Safari 18.4). Detected once through a getter: the bindings convert the dictionary before the\n * method runs, so a detached element is enough and nothing is focused.\n */\nexport function supportsFocusVisibleOption(doc: Document): boolean {\n if (focusVisibleOption === undefined) {\n let read = false;\n try {\n doc.createElement(\"div\").focus({\n get focusVisible() {\n read = true;\n return false;\n },\n } as FocusOptions);\n } catch {\n read = false;\n }\n focusVisibleOption = read;\n }\n return focusVisibleOption;\n}\n\n/** Tests only: forget the detection, so the next pointer open detects the option again. */\nexport function resetFocusVisibleOption(): void {\n focusVisibleOption = undefined;\n}\n"],"mappings":";AAcA,IAAI;;;;;;AAOJ,SAAgB,2BAA2B,KAAwB;CACjE,IAAI,uBAAuB,KAAA,GAAW;EACpC,IAAI,OAAO;EACX,IAAI;GACF,IAAI,cAAc,KAAK,CAAC,CAAC,MAAM,EAC7B,IAAI,eAAe;IACjB,OAAO;IACP,OAAO;GACT,EACF,CAAiB;EACnB,QAAQ;GACN,OAAO;EACT;EACA,qBAAqB;CACvB;CACA,OAAO;AACT"}
|
|
@@ -1,4 +1,21 @@
|
|
|
1
|
-
//#region src/internal/
|
|
1
|
+
//#region src/internal/invokers.ts
|
|
2
|
+
/**
|
|
3
|
+
* The `source` of a `ToggleEvent` (Chromium 140, Firefox 145, Safari 26.5), a `CommandEvent` or
|
|
4
|
+
* an `InterestEvent`: the invoker that caused it, `null` without one. Not in TypeScript's DOM lib
|
|
5
|
+
* for all three.
|
|
6
|
+
*/
|
|
7
|
+
function eventSource(event) {
|
|
8
|
+
return event.source ?? null;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Whether the `ToggleEvent.source` of a close is a `popovertarget` invoker of `popup`. A
|
|
12
|
+
* `commandfor` or `interestfor` invoker sets `source` too (Chromium's lost-interest hide, a
|
|
13
|
+
* dismissal), and so names no `popovertarget` here.
|
|
14
|
+
*/
|
|
15
|
+
function closedByPopoverTarget(event, popup) {
|
|
16
|
+
const source = eventSource(event);
|
|
17
|
+
return (source instanceof HTMLButtonElement || source instanceof HTMLInputElement) && source.popoverTargetElement === popup;
|
|
18
|
+
}
|
|
2
19
|
/** The `<input>` types HTML counts as buttons: the ones `popovertarget` applies to. */
|
|
3
20
|
const INPUT_BUTTON_TYPES = /* @__PURE__ */ new Set([
|
|
4
21
|
"submit",
|
|
@@ -11,7 +28,7 @@ const INPUT_BUTTON_TYPES = /* @__PURE__ */ new Set([
|
|
|
11
28
|
* `<button>`, or an `<input>` of a button type) is outside the popup and names it through
|
|
12
29
|
* `popovertarget`, or (a `<button>`) through `commandfor` with a popover command
|
|
13
30
|
* (`toggle-popover`, `show-popover`, `hide-popover`). HTML's invoker relationship, the one light
|
|
14
|
-
* dismiss exempts (conventions 3.5
|
|
31
|
+
* dismiss exempts (conventions 3.5): a disabled button and a submit button with a form owner
|
|
15
32
|
* invoke nothing. Read through the IDL, so an engine without it has no such invoker.
|
|
16
33
|
*/
|
|
17
34
|
function isPopoverInvoker(target, popup) {
|
|
@@ -28,7 +45,7 @@ function isPopoverInvoker(target, popup) {
|
|
|
28
45
|
}
|
|
29
46
|
/**
|
|
30
47
|
* While a popup that closes on focus leaving is shown: a primary-button `mousedown` on a foreign
|
|
31
|
-
* invoker of it moves no focus (conventions 3.5
|
|
48
|
+
* invoker of it moves no focus (conventions 3.5). Chromium and Firefox focus a button on
|
|
32
49
|
* press, which would close the popup at the `focusout` before the click's own toggle (as
|
|
33
50
|
* `"dismiss"`, and the toggle then re-showed it). Returns the cleanup.
|
|
34
51
|
*/
|
|
@@ -41,6 +58,6 @@ function listenInvokerPresses(popup) {
|
|
|
41
58
|
return () => doc.removeEventListener("mousedown", onMouseDown, true);
|
|
42
59
|
}
|
|
43
60
|
//#endregion
|
|
44
|
-
export { isPopoverInvoker, listenInvokerPresses };
|
|
61
|
+
export { closedByPopoverTarget, eventSource, isPopoverInvoker, listenInvokerPresses };
|
|
45
62
|
|
|
46
|
-
//# sourceMappingURL=
|
|
63
|
+
//# sourceMappingURL=invokers.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"invokers.mjs","names":[],"sources":["../../src/internal/invokers.ts"],"sourcesContent":["// No directive: DOM reads and listeners only (conventions 7.1). The platform's invoker\n// relationship between a button and a popover, as the overlays read it.\n\n/** An invoker button's IDL; absent where the engine lacks the Popover API or Invoker Commands. */\ninterface InvokerButton {\n readonly popoverTargetElement?: Element | null;\n readonly commandForElement?: Element | null;\n readonly command?: string;\n}\n\n/**\n * The `source` of a `ToggleEvent` (Chromium 140, Firefox 145, Safari 26.5), a `CommandEvent` or\n * an `InterestEvent`: the invoker that caused it, `null` without one. Not in TypeScript's DOM lib\n * for all three.\n */\nexport function eventSource(event: Event): Element | null {\n return (event as Event & { readonly source?: Element | null }).source ?? null;\n}\n\n/**\n * Whether the `ToggleEvent.source` of a close is a `popovertarget` invoker of `popup`. A\n * `commandfor` or `interestfor` invoker sets `source` too (Chromium's lost-interest hide, a\n * dismissal), and so names no `popovertarget` here.\n */\nexport function closedByPopoverTarget(event: ToggleEvent, popup: HTMLElement): boolean {\n const source = eventSource(event);\n return (\n (source instanceof HTMLButtonElement || source instanceof HTMLInputElement) &&\n source.popoverTargetElement === popup\n );\n}\n\n/** The `<input>` types HTML counts as buttons: the ones `popovertarget` applies to. */\nconst INPUT_BUTTON_TYPES = new Set([\"submit\", \"image\", \"reset\", \"button\"]);\n\n/**\n * Whether a press on `target` is a press on a foreign invoker of `popup`: its closest button (a\n * `<button>`, or an `<input>` of a button type) is outside the popup and names it through\n * `popovertarget`, or (a `<button>`) through `commandfor` with a popover command\n * (`toggle-popover`, `show-popover`, `hide-popover`). HTML's invoker relationship, the one light\n * dismiss exempts (conventions 3.5): a disabled button and a submit button with a form owner\n * invoke nothing. Read through the IDL, so an engine without it has no such invoker.\n */\nexport function isPopoverInvoker(target: EventTarget | null, popup: Element): boolean {\n if (!(target instanceof Element)) return false;\n const button = target.closest<HTMLButtonElement | HTMLInputElement>(\"button, input\");\n if (button === null || popup.contains(button)) return false;\n const isInput = button.tagName === \"INPUT\";\n if (isInput && !INPUT_BUTTON_TYPES.has(button.type)) return false;\n if (button.disabled) return false;\n if (button.form !== null && (button.type === \"submit\" || button.type === \"image\")) return false;\n const invoker = button as InvokerButton;\n if (invoker.popoverTargetElement === popup) return true;\n return !isInput && invoker.commandForElement === popup && /-popover$/.test(invoker.command ?? \"\");\n}\n\n/**\n * While a popup that closes on focus leaving is shown: a primary-button `mousedown` on a foreign\n * invoker of it moves no focus (conventions 3.5). Chromium and Firefox focus a button on\n * press, which would close the popup at the `focusout` before the click's own toggle (as\n * `\"dismiss\"`, and the toggle then re-showed it). Returns the cleanup.\n */\nexport function listenInvokerPresses(popup: HTMLElement): () => void {\n const doc = popup.ownerDocument;\n const onMouseDown = (event: MouseEvent) => {\n if (event.button === 0 && isPopoverInvoker(event.target, popup)) event.preventDefault();\n };\n doc.addEventListener(\"mousedown\", onMouseDown, true);\n return () => doc.removeEventListener(\"mousedown\", onMouseDown, true);\n}\n"],"mappings":";;;;;;AAeA,SAAgB,YAAY,OAA8B;CACxD,OAAQ,MAAuD,UAAU;AAC3E;;;;;;AAOA,SAAgB,sBAAsB,OAAoB,OAA6B;CACrF,MAAM,SAAS,YAAY,KAAK;CAChC,QACG,kBAAkB,qBAAqB,kBAAkB,qBAC1D,OAAO,yBAAyB;AAEpC;;AAGA,MAAM,qCAAqB,IAAI,IAAI;CAAC;CAAU;CAAS;CAAS;AAAQ,CAAC;;;;;;;;;AAUzE,SAAgB,iBAAiB,QAA4B,OAAyB;CACpF,IAAI,EAAE,kBAAkB,UAAU,OAAO;CACzC,MAAM,SAAS,OAAO,QAA8C,eAAe;CACnF,IAAI,WAAW,QAAQ,MAAM,SAAS,MAAM,GAAG,OAAO;CACtD,MAAM,UAAU,OAAO,YAAY;CACnC,IAAI,WAAW,CAAC,mBAAmB,IAAI,OAAO,IAAI,GAAG,OAAO;CAC5D,IAAI,OAAO,UAAU,OAAO;CAC5B,IAAI,OAAO,SAAS,SAAS,OAAO,SAAS,YAAY,OAAO,SAAS,UAAU,OAAO;CAC1F,MAAM,UAAU;CAChB,IAAI,QAAQ,yBAAyB,OAAO,OAAO;CACnD,OAAO,CAAC,WAAW,QAAQ,sBAAsB,SAAS,YAAY,KAAK,QAAQ,WAAW,EAAE;AAClG;;;;;;;AAQA,SAAgB,qBAAqB,OAAgC;CACnE,MAAM,MAAM,MAAM;CAClB,MAAM,eAAe,UAAsB;EACzC,IAAI,MAAM,WAAW,KAAK,iBAAiB,MAAM,QAAQ,KAAK,GAAG,MAAM,eAAe;CACxF;CACA,IAAI,iBAAiB,aAAa,aAAa,IAAI;CACnD,aAAa,IAAI,oBAAoB,aAAa,aAAa,IAAI;AACrE"}
|
|
@@ -25,7 +25,7 @@ declare module "react" {
|
|
|
25
25
|
/**
|
|
26
26
|
* `commandfor` (Invoker Commands): id of the element the button's `command` acts on.
|
|
27
27
|
* Not in `@types/react` 19.3.0 (DefinitelyTyped #74664). Rendered by `Popover.Close`, the
|
|
28
|
-
* Dialog parts and `Button`; the overlay Triggers use `popovertarget
|
|
28
|
+
* Dialog parts and `Button`; the overlay Triggers use `popovertarget`.
|
|
29
29
|
*/
|
|
30
30
|
commandfor?: string | undefined;
|
|
31
31
|
/**
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* `setPointerCapture`, which throws `NotFoundError` for a pointer the engine no longer tracks
|
|
4
4
|
* (context-menu.md 2.1). A silent no-op when no button is down. `true` when the capture was
|
|
5
5
|
* taken (the Menu's press-drag-release gesture runs only then, 2.6). The Combobox Input uses it
|
|
6
|
-
* to keep a press on the field from light-dismissing the listbox (combobox.md 5.4
|
|
6
|
+
* to keep a press on the field from light-dismissing the listbox (combobox.md 5.4).
|
|
7
7
|
*/
|
|
8
8
|
function capturePointer(element, pointerId) {
|
|
9
9
|
if (element === null || pointerId === void 0) return false;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pointer-capture.mjs","names":[],"sources":["../../src/internal/pointer-capture.ts"],"sourcesContent":["// No directive: a pure DOM call (conventions 7.1).\n\n/**\n * `setPointerCapture`, which throws `NotFoundError` for a pointer the engine no longer tracks\n * (context-menu.md 2.1). A silent no-op when no button is down. `true` when the capture was\n * taken (the Menu's press-drag-release gesture runs only then, 2.6). The Combobox Input uses it\n * to keep a press on the field from light-dismissing the listbox (combobox.md 5.4
|
|
1
|
+
{"version":3,"file":"pointer-capture.mjs","names":[],"sources":["../../src/internal/pointer-capture.ts"],"sourcesContent":["// No directive: a pure DOM call (conventions 7.1).\n\n/**\n * `setPointerCapture`, which throws `NotFoundError` for a pointer the engine no longer tracks\n * (context-menu.md 2.1). A silent no-op when no button is down. `true` when the capture was\n * taken (the Menu's press-drag-release gesture runs only then, 2.6). The Combobox Input uses it\n * to keep a press on the field from light-dismissing the listbox (combobox.md 5.4).\n */\nexport function capturePointer(element: Element | null, pointerId: number | undefined): boolean {\n if (element === null || pointerId === undefined) return false;\n try {\n element.setPointerCapture(pointerId);\n return true;\n } catch {\n // Not an active pointer (a synthetic event, a released button): nothing to capture.\n return false;\n }\n}\n"],"mappings":";;;;;;;AAQA,SAAgB,eAAe,SAAyB,WAAwC;CAC9F,IAAI,YAAY,QAAQ,cAAc,KAAA,GAAW,OAAO;CACxD,IAAI;EACF,QAAQ,kBAAkB,SAAS;EACnC,OAAO;CACT,QAAQ;EAEN,OAAO;CACT;AACF"}
|
|
@@ -5,7 +5,7 @@ const warned = /* @__PURE__ */ new WeakSet();
|
|
|
5
5
|
/**
|
|
6
6
|
* Registers `element` as the Root's one Trigger (`triggerRef`, last mounted wins) and returns
|
|
7
7
|
* the ref cleanup. In development, a second Trigger mounting while another is registered
|
|
8
|
-
* warns once per Root (
|
|
8
|
+
* warns once per Root (popover.md 14.2): only the registered one is the popup's `source` (anchor,
|
|
9
9
|
* focus return) and, in JS-free mode, the one whose `data-open` is kept current.
|
|
10
10
|
*/
|
|
11
11
|
function registerTrigger(triggerRef, element, part) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"trigger-ref.mjs","names":[],"sources":["../../src/internal/trigger-ref.ts"],"sourcesContent":["import type { RefObject } from \"react\";\n\nconst isDev = process.env.NODE_ENV !== \"production\";\n\n/** The Roots that already warned about a second Trigger, keyed by their `triggerRef`. */\nconst warned = new WeakSet<RefObject<HTMLElement | null>>();\n\n/**\n * Registers `element` as the Root's one Trigger (`triggerRef`, last mounted wins) and returns\n * the ref cleanup. In development, a second Trigger mounting while another is registered\n * warns once per Root (
|
|
1
|
+
{"version":3,"file":"trigger-ref.mjs","names":[],"sources":["../../src/internal/trigger-ref.ts"],"sourcesContent":["import type { RefObject } from \"react\";\n\nconst isDev = process.env.NODE_ENV !== \"production\";\n\n/** The Roots that already warned about a second Trigger, keyed by their `triggerRef`. */\nconst warned = new WeakSet<RefObject<HTMLElement | null>>();\n\n/**\n * Registers `element` as the Root's one Trigger (`triggerRef`, last mounted wins) and returns\n * the ref cleanup. In development, a second Trigger mounting while another is registered\n * warns once per Root (popover.md 14.2): only the registered one is the popup's `source` (anchor,\n * focus return) and, in JS-free mode, the one whose `data-open` is kept current.\n */\nexport function registerTrigger(\n triggerRef: RefObject<HTMLElement | null>,\n element: HTMLElement,\n part: string,\n): () => void {\n // A Trigger's own cleanup clears the ref first (a remount, StrictMode, a ref change), so a\n // registered element here is another, still mounted Trigger.\n if (isDev && triggerRef.current !== null) {\n if (!warned.has(triggerRef)) {\n warned.add(triggerRef);\n console.error(\n `${part}: a second ${part} mounted in the same Root. A Root supports one ${part}: ` +\n \"the popup only follows the last one mounted (its anchor, focus return and, \" +\n `without an action, data-open). Render one ${part} per Root.`,\n );\n }\n }\n triggerRef.current = element;\n return () => {\n if (triggerRef.current === element) triggerRef.current = null;\n };\n}\n"],"mappings":";AAEA,MAAM,QAAQ,QAAQ,IAAI,aAAa;;AAGvC,MAAM,yBAAS,IAAI,QAAuC;;;;;;;AAQ1D,SAAgB,gBACd,YACA,SACA,MACY;CAGZ,IAAI,SAAS,WAAW,YAAY,MAC9B;MAAA,CAAC,OAAO,IAAI,UAAU,GAAG;GAC3B,OAAO,IAAI,UAAU;GACrB,QAAQ,MACN,GAAG,KAAK,aAAa,KAAK,iDAAiD,KAAK,yHAEjC,KAAK,WACtD;EACF;;CAEF,WAAW,UAAU;CACrB,aAAa;EACX,IAAI,WAAW,YAAY,SAAS,WAAW,UAAU;CAC3D;AACF"}
|
|
@@ -9,6 +9,9 @@ export type Orientation = "horizontal" | "vertical";
|
|
|
9
9
|
* returns data, as Server Functions usually do (conventions 2.2).
|
|
10
10
|
*/
|
|
11
11
|
export type Action<Args extends readonly unknown[] = []> = (...args: Args) => unknown;
|
|
12
|
+
/**
|
|
13
|
+
* The base of every `details` object an action receives (the second argument of a change action).
|
|
14
|
+
*/
|
|
12
15
|
export interface ActionDetails {
|
|
13
16
|
/** The DOM event that caused the action, or `undefined` for programmatic changes. */
|
|
14
17
|
readonly event: Event | undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.mts","names":[],"sources":["../../src/internal/types.ts"],"mappings":";;;YAGY;;;;;;;YAQA,OAAO,4CAA4C,MAAM
|
|
1
|
+
{"version":3,"file":"types.d.mts","names":[],"sources":["../../src/internal/types.ts"],"mappings":";;;YAGY;;;;;;;YAQA,OAAO,4CAA4C,MAAM;;;;iBAKpD;;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"}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { isPopoverOpen } from "./popover-open.mjs";
|
|
3
|
+
import { eventSource } from "./invokers.mjs";
|
|
4
|
+
import { useCallback, useRef } from "react";
|
|
5
|
+
//#region src/internal/use-interest-dismiss.ts
|
|
6
|
+
/**
|
|
7
|
+
* Lost interest of an `interestfor` button naming the popup (library mode; Chromium; popover.md
|
|
8
|
+
* lost-interest amendment), for `usePopoverPopup`. The platform hides only a popover its own
|
|
9
|
+
* interest show opened (`invokedVia == kInterest`), and the library cancels that show and
|
|
10
|
+
* re-shows with `showPopover({ source })`, so the platform never hides: the library does, as a
|
|
11
|
+
* dismissal. Chromium also fires `loseinterest` from inside every hide of the popup while the
|
|
12
|
+
* button has interest (Escape, script, the library's own close), before the state flips, and a
|
|
13
|
+
* `hidePopover()` called from there re-enters the hide and loses its `toggle`: the hide waits one
|
|
14
|
+
* task and runs only if the popup is still shown and still meant to be open, and returns no focus
|
|
15
|
+
* to the Trigger. A pending interest open is cancelled instead.
|
|
16
|
+
*/
|
|
17
|
+
function useInterestDismiss(ctx) {
|
|
18
|
+
const isLibrary = ctx.mode === "library";
|
|
19
|
+
const { popupRef } = ctx;
|
|
20
|
+
const interestInvoker = useRef(null);
|
|
21
|
+
const interestOpen = useRef(false);
|
|
22
|
+
const interestHideTask = useRef(void 0);
|
|
23
|
+
const interestHide = useRef(false);
|
|
24
|
+
const onInterest = (event) => {
|
|
25
|
+
const element = popupRef.current;
|
|
26
|
+
if (!isLibrary || element === null || event.target !== element) return;
|
|
27
|
+
interestInvoker.current = eventSource(event);
|
|
28
|
+
};
|
|
29
|
+
const onLoseInterest = (event) => {
|
|
30
|
+
const element = popupRef.current;
|
|
31
|
+
if (!isLibrary || element === null || event.target !== element) return;
|
|
32
|
+
const source = eventSource(event);
|
|
33
|
+
if (source === null || source !== interestInvoker.current) return;
|
|
34
|
+
interestInvoker.current = null;
|
|
35
|
+
if (!interestOpen.current) return;
|
|
36
|
+
if (isPopoverOpen(element)) {
|
|
37
|
+
clearTimeout(interestHideTask.current);
|
|
38
|
+
interestHideTask.current = setTimeout(() => {
|
|
39
|
+
interestHideTask.current = void 0;
|
|
40
|
+
if (!isPopoverOpen(element) || !ctx.intended()) return;
|
|
41
|
+
if (interestInvoker.current !== null) return;
|
|
42
|
+
ctx.recordCloseIntent({
|
|
43
|
+
reason: "dismiss",
|
|
44
|
+
event
|
|
45
|
+
});
|
|
46
|
+
interestHide.current = true;
|
|
47
|
+
element.hidePopover();
|
|
48
|
+
}, 0);
|
|
49
|
+
} else if (ctx.intended()) {
|
|
50
|
+
interestOpen.current = false;
|
|
51
|
+
ctx.requestClose(event, "dismiss");
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
const noteOpen = (event) => {
|
|
55
|
+
const source = eventSource(event);
|
|
56
|
+
interestOpen.current = source !== null && source === interestInvoker.current;
|
|
57
|
+
};
|
|
58
|
+
const noteClosed = () => {
|
|
59
|
+
interestOpen.current = false;
|
|
60
|
+
};
|
|
61
|
+
const takeLostInterest = () => {
|
|
62
|
+
const lostInterest = interestHide.current;
|
|
63
|
+
interestHide.current = false;
|
|
64
|
+
return lostInterest;
|
|
65
|
+
};
|
|
66
|
+
return {
|
|
67
|
+
onInterest,
|
|
68
|
+
onLoseInterest,
|
|
69
|
+
noteOpen,
|
|
70
|
+
noteClosed,
|
|
71
|
+
takeLostInterest,
|
|
72
|
+
reset: useCallback(() => {
|
|
73
|
+
clearTimeout(interestHideTask.current);
|
|
74
|
+
interestHideTask.current = void 0;
|
|
75
|
+
interestHide.current = false;
|
|
76
|
+
interestInvoker.current = null;
|
|
77
|
+
interestOpen.current = false;
|
|
78
|
+
}, [])
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
//#endregion
|
|
82
|
+
export { useInterestDismiss };
|
|
83
|
+
|
|
84
|
+
//# sourceMappingURL=use-interest-dismiss.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-interest-dismiss.mjs","names":[],"sources":["../../src/internal/use-interest-dismiss.ts"],"sourcesContent":["\"use client\";\nimport { useCallback, useRef } from \"react\";\nimport { eventSource } from \"./invokers.js\";\nimport { isPopoverOpen } from \"./popover-open.js\";\nimport type { PopoverRootValue } from \"./use-overlay-root.js\";\n\nexport interface InterestDismiss {\n /** `interest` at the popup: remembers the button that has interest in it. */\n onInterest(event: Event): void;\n /** `loseinterest` at the popup: the lost-interest hide (see `useInterestDismiss`). */\n onLoseInterest(event: Event): void;\n /** The opening `beforetoggle` the Root routes: whether it is the interest invoker's open. */\n noteOpen(event: ToggleEvent): void;\n /** The popup's `toggle` reported it hidden: the interest open is over. */\n noteClosed(): void;\n /** Whether the hide whose `toggle` arrived was the lost-interest hide; clears it. */\n takeLostInterest(): boolean;\n /** The popup element detached: cancels a pending hide and forgets everything. Stable. */\n reset(): void;\n}\n\n/**\n * Lost interest of an `interestfor` button naming the popup (library mode; Chromium; popover.md\n * lost-interest amendment), for `usePopoverPopup`. The platform hides only a popover its own\n * interest show opened (`invokedVia == kInterest`), and the library cancels that show and\n * re-shows with `showPopover({ source })`, so the platform never hides: the library does, as a\n * dismissal. Chromium also fires `loseinterest` from inside every hide of the popup while the\n * button has interest (Escape, script, the library's own close), before the state flips, and a\n * `hidePopover()` called from there re-enters the hide and loses its `toggle`: the hide waits one\n * task and runs only if the popup is still shown and still meant to be open, and returns no focus\n * to the Trigger. A pending interest open is cancelled instead.\n */\nexport function useInterestDismiss(ctx: PopoverRootValue): InterestDismiss {\n const isLibrary = ctx.mode === \"library\";\n const { popupRef } = ctx;\n // The button that has interest in the popup (`InterestEvent.source`), whether the current open\n // was that button's interest open, the task that hides the popup on its lost interest, and\n // whether the hide in flight is that one.\n const interestInvoker = useRef<Element | null>(null);\n const interestOpen = useRef(false);\n const interestHideTask = useRef<ReturnType<typeof setTimeout> | undefined>(undefined);\n const interestHide = useRef(false);\n\n const onInterest = (event: Event): void => {\n const element = popupRef.current;\n if (!isLibrary || element === null || event.target !== element) return;\n interestInvoker.current = eventSource(event);\n };\n\n const onLoseInterest = (event: Event): void => {\n const element = popupRef.current;\n if (!isLibrary || element === null || event.target !== element) return;\n const source = eventSource(event);\n if (source === null || source !== interestInvoker.current) return;\n interestInvoker.current = null;\n if (!interestOpen.current) return;\n if (isPopoverOpen(element)) {\n clearTimeout(interestHideTask.current);\n interestHideTask.current = setTimeout(() => {\n interestHideTask.current = undefined;\n if (!isPopoverOpen(element) || !ctx.intended()) return;\n // Interest regained meanwhile (the pointer came back): the popup stays.\n if (interestInvoker.current !== null) return;\n // Recorded right before the hide, so its one-task clear cannot run first.\n ctx.recordCloseIntent({ reason: \"dismiss\", event });\n interestHide.current = true;\n element.hidePopover();\n }, 0);\n } else if (ctx.intended()) {\n interestOpen.current = false;\n ctx.requestClose(event, \"dismiss\");\n }\n };\n\n const noteOpen = (event: ToggleEvent): void => {\n // Chromium dispatches `interest` and then the interest show in one step, so a show whose\n // `source` is the remembered interest invoker is that button's interest open.\n const source = eventSource(event);\n interestOpen.current = source !== null && source === interestInvoker.current;\n };\n\n const noteClosed = (): void => {\n interestOpen.current = false;\n };\n\n const takeLostInterest = (): boolean => {\n const lostInterest = interestHide.current;\n interestHide.current = false;\n return lostInterest;\n };\n\n const reset = useCallback((): void => {\n clearTimeout(interestHideTask.current);\n interestHideTask.current = undefined;\n interestHide.current = false;\n interestInvoker.current = null;\n interestOpen.current = false;\n }, []);\n\n return { onInterest, onLoseInterest, noteOpen, noteClosed, takeLostInterest, reset };\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAgCA,SAAgB,mBAAmB,KAAwC;CACzE,MAAM,YAAY,IAAI,SAAS;CAC/B,MAAM,EAAE,aAAa;CAIrB,MAAM,kBAAkB,OAAuB,IAAI;CACnD,MAAM,eAAe,OAAO,KAAK;CACjC,MAAM,mBAAmB,OAAkD,KAAA,CAAS;CACpF,MAAM,eAAe,OAAO,KAAK;CAEjC,MAAM,cAAc,UAAuB;EACzC,MAAM,UAAU,SAAS;EACzB,IAAI,CAAC,aAAa,YAAY,QAAQ,MAAM,WAAW,SAAS;EAChE,gBAAgB,UAAU,YAAY,KAAK;CAC7C;CAEA,MAAM,kBAAkB,UAAuB;EAC7C,MAAM,UAAU,SAAS;EACzB,IAAI,CAAC,aAAa,YAAY,QAAQ,MAAM,WAAW,SAAS;EAChE,MAAM,SAAS,YAAY,KAAK;EAChC,IAAI,WAAW,QAAQ,WAAW,gBAAgB,SAAS;EAC3D,gBAAgB,UAAU;EAC1B,IAAI,CAAC,aAAa,SAAS;EAC3B,IAAI,cAAc,OAAO,GAAG;GAC1B,aAAa,iBAAiB,OAAO;GACrC,iBAAiB,UAAU,iBAAiB;IAC1C,iBAAiB,UAAU,KAAA;IAC3B,IAAI,CAAC,cAAc,OAAO,KAAK,CAAC,IAAI,SAAS,GAAG;IAEhD,IAAI,gBAAgB,YAAY,MAAM;IAEtC,IAAI,kBAAkB;KAAE,QAAQ;KAAW;IAAM,CAAC;IAClD,aAAa,UAAU;IACvB,QAAQ,YAAY;GACtB,GAAG,CAAC;EACN,OAAO,IAAI,IAAI,SAAS,GAAG;GACzB,aAAa,UAAU;GACvB,IAAI,aAAa,OAAO,SAAS;EACnC;CACF;CAEA,MAAM,YAAY,UAA6B;EAG7C,MAAM,SAAS,YAAY,KAAK;EAChC,aAAa,UAAU,WAAW,QAAQ,WAAW,gBAAgB;CACvE;CAEA,MAAM,mBAAyB;EAC7B,aAAa,UAAU;CACzB;CAEA,MAAM,yBAAkC;EACtC,MAAM,eAAe,aAAa;EAClC,aAAa,UAAU;EACvB,OAAO;CACT;CAUA,OAAO;EAAE;EAAY;EAAgB;EAAU;EAAY;EAAkB,OAR/D,kBAAwB;GACpC,aAAa,iBAAiB,OAAO;GACrC,iBAAiB,UAAU,KAAA;GAC3B,aAAa,UAAU;GACvB,gBAAgB,UAAU;GAC1B,aAAa,UAAU;EACzB,GAAG,CAAC,CAE6E;CAAE;AACrF"}
|
|
@@ -1 +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 * names no cause beyond its invoker (`ToggleEvent.source`: a `popovertarget`, `commandfor` or\n * `interestfor` button, #125); 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 on a non-button Trigger and the Combobox Input (#118; a `<button>`\n * Trigger renders none, #121). 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 /**\n * Record what causes the next close. Cleared after a task if the popover did not close.\n * `unlessRecorded`: keep an intent already recorded for this close (the `command` listener runs\n * before the `beforetoggle` of the same click, #125).\n */\n readonly recordCloseIntent: (\n intent: OverlayCloseIntent | undefined,\n options?: { readonly unlessRecorded?: boolean },\n ) => 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, options?: { readonly unlessRecorded?: boolean }) => {\n if (options?.unlessRecorded === true && closeIntent.current !== undefined) return;\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;;AA+IvC,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,QAAwC,YAAoD;EAC3F,IAAI,SAAS,mBAAmB,QAAQ,YAAY,YAAY,KAAA,GAAW;EAC3E,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
|
+
{"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 * names no cause beyond its invoker (`ToggleEvent.source`: a `popovertarget`, `commandfor` or\n * `interestfor` button); 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 on a non-button Trigger and the Combobox Input (a `<button>`\n * Trigger renders none). Written by a popover Popup in library mode; Dialog does not\n * maintain it, and its context omits 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 /**\n * Record what causes the next close. Cleared after a task if the popover did not close.\n * `unlessRecorded`: keep an intent already recorded for this close (the `command` listener runs\n * before the `beforetoggle` of the same click).\n */\n readonly recordCloseIntent: (\n intent: OverlayCloseIntent | undefined,\n options?: { readonly unlessRecorded?: boolean },\n ) => 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, options?: { readonly unlessRecorded?: boolean }) => {\n if (options?.unlessRecorded === true && closeIntent.current !== undefined) return;\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;;AA+IvC,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,QAAwC,YAAoD;EAC3F,IAAI,SAAS,mBAAmB,QAAQ,YAAY,YAAY,KAAA,GAAW;EAC3E,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"}
|