@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
|
@@ -0,0 +1,591 @@
|
|
|
1
|
+
# Popover
|
|
2
|
+
|
|
3
|
+
Built on `popover="auto"`, a `<dialog>` element, a `popovertarget` Trigger and an Invoker Command Close. The platform supplies the top layer, light dismiss, Escape, one-at-a-time stacking with nesting, placement next to the trigger, a declarative trigger that works before hydration, and focus return. The library adds the asynchronous half: opening a popover whose content loads is a transition, so the trigger shows `data-pending` and the popover opens once its content is ready; and the closes the user asks a part for run through the library too, so `<ViewTransition>` can animate the exit, in Firefox as well.
|
|
4
|
+
|
|
5
|
+
```tsx title="PopoverShare.tsx"
|
|
6
|
+
// No "use client": this file is a Server Component. The Popover.Root has no `open`, `defaultOpen`
|
|
7
|
+
// or `openChangeAction`, so it runs in JS-free mode: the Trigger is a native `popovertarget`
|
|
8
|
+
// invoker and Done is a `command="hide-popover"` button. The browser opens the popup in the top
|
|
9
|
+
// layer below the button, focuses the input (the first focusable element, through the dialog
|
|
10
|
+
// focusing steps), and closes it on Escape, a click outside or Done, before hydration and with
|
|
11
|
+
// JavaScript off. No `autoFocus`: React writes it only into
|
|
12
|
+
// server-rendered HTML, not after a client navigation; `initialFocus` covers both.
|
|
13
|
+
import { Popover } from "@funstack/ui/popover";
|
|
14
|
+
|
|
15
|
+
export function PopoverShare() {
|
|
16
|
+
return (
|
|
17
|
+
<Popover.Root>
|
|
18
|
+
<Popover.Trigger className="demo-button">Share</Popover.Trigger>
|
|
19
|
+
<Popover.Popup className="demo-popover" align="start">
|
|
20
|
+
<Popover.Title>Share this page</Popover.Title>
|
|
21
|
+
<input
|
|
22
|
+
className="demo-popover-input"
|
|
23
|
+
readOnly
|
|
24
|
+
value="https://ui.funstack.work/components/popover"
|
|
25
|
+
/>
|
|
26
|
+
<div className="demo-popover-actions">
|
|
27
|
+
<Popover.Close className="demo-button">Done</Popover.Close>
|
|
28
|
+
</div>
|
|
29
|
+
</Popover.Popup>
|
|
30
|
+
</Popover.Root>
|
|
31
|
+
);
|
|
32
|
+
}
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
```css title="popover.css"
|
|
36
|
+
/* Popover: the Popup is the <dialog popover> itself. Open state is `:popover-open` on it (exact
|
|
37
|
+
in both modes); the Trigger carries `data-open` in both modes and `data-pending` in library
|
|
38
|
+
mode only. A <button> Trigger has no `aria-expanded` (the browser exposes its state). */
|
|
39
|
+
|
|
40
|
+
.demo-popover {
|
|
41
|
+
/* The popover UA stylesheet sets `inset: 0; margin: auto`: reset both for anchored placement. */
|
|
42
|
+
margin: 0;
|
|
43
|
+
inset: auto;
|
|
44
|
+
min-inline-size: 14rem;
|
|
45
|
+
padding: 16px;
|
|
46
|
+
border: 1px solid var(--color-border);
|
|
47
|
+
border-radius: 10px;
|
|
48
|
+
background: var(--color-bg);
|
|
49
|
+
color: var(--color-text);
|
|
50
|
+
box-shadow: 0 12px 40px rgb(0 0 0 / 0.25);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/* The gap. `data-side` is where the browser placed the popup (absent with `side={null}`); a
|
|
54
|
+
flip swaps the popup's margins, so the gap goes on both sides of the axis. */
|
|
55
|
+
.demo-popover[data-side="bottom"],
|
|
56
|
+
.demo-popover[data-side="top"] {
|
|
57
|
+
margin-block: 6px;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
.demo-popover h2 {
|
|
61
|
+
margin: 0 0 8px;
|
|
62
|
+
padding: 0;
|
|
63
|
+
border: 0;
|
|
64
|
+
font-size: 1rem;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/* Enter and exit with CSS, both modes. Enter works everywhere; the exit animates in Chromium
|
|
68
|
+
(with `overlay`) and Safari and is instant in Firefox. On iOS, `position-try-fallbacks`
|
|
69
|
+
together with `@starting-style` can hang (WebKit bug 317926). */
|
|
70
|
+
.demo-popover {
|
|
71
|
+
opacity: 0;
|
|
72
|
+
translate: 0 -4px;
|
|
73
|
+
transition:
|
|
74
|
+
opacity 120ms,
|
|
75
|
+
translate 120ms,
|
|
76
|
+
display 120ms allow-discrete,
|
|
77
|
+
overlay 120ms allow-discrete;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
.demo-popover:popover-open {
|
|
81
|
+
opacity: 1;
|
|
82
|
+
translate: 0 0;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
@starting-style {
|
|
86
|
+
.demo-popover:popover-open {
|
|
87
|
+
opacity: 0;
|
|
88
|
+
translate: 0 -4px;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/* With `transition`, the view transition animates library-driven opens and closes (Firefox
|
|
93
|
+
included); dismissals keep the CSS exit above. While a view transition runs the CSS transition
|
|
94
|
+
is cut: otherwise a closing popover stays rendered through its fade, and Chromium captures it
|
|
95
|
+
in the close's new snapshot as well (a double image). */
|
|
96
|
+
html:active-view-transition .demo-popover-vt {
|
|
97
|
+
transition: none;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
::view-transition-new(.pop) {
|
|
101
|
+
animation: 160ms ease-out both demo-pop-in;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
::view-transition-old(.pop) {
|
|
105
|
+
animation: 120ms ease-in both demo-pop-out;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
@keyframes demo-pop-in {
|
|
109
|
+
from {
|
|
110
|
+
opacity: 0;
|
|
111
|
+
scale: 0.96;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
@keyframes demo-pop-out {
|
|
116
|
+
to {
|
|
117
|
+
opacity: 0;
|
|
118
|
+
scale: 0.96;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
@media (prefers-reduced-motion: reduce) {
|
|
123
|
+
.demo-popover {
|
|
124
|
+
transition: none;
|
|
125
|
+
}
|
|
126
|
+
::view-transition-group(*),
|
|
127
|
+
::view-transition-old(*),
|
|
128
|
+
::view-transition-new(*) {
|
|
129
|
+
animation: none !important;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
/* Dim the popup while a Close action runs (the Close button carries data-pending). */
|
|
134
|
+
.demo-popover:popover-open:has([data-pending]) {
|
|
135
|
+
opacity: 0.8;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
.demo-popover-actions {
|
|
139
|
+
display: flex;
|
|
140
|
+
justify-content: flex-end;
|
|
141
|
+
gap: 8px;
|
|
142
|
+
margin-top: 12px;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
.demo-popover-input {
|
|
146
|
+
box-sizing: border-box;
|
|
147
|
+
inline-size: 100%;
|
|
148
|
+
padding: 0.35em 0.6em;
|
|
149
|
+
border: 1px solid var(--color-border);
|
|
150
|
+
border-radius: 6px;
|
|
151
|
+
background: var(--color-bg);
|
|
152
|
+
color: var(--color-text);
|
|
153
|
+
font: inherit;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
/* The Trigger: `data-open` flips at the click in library mode and follows the shown popup in
|
|
157
|
+
JS-free mode. A page that never hydrates can use `.demo-button:has(+ :popover-open)`. */
|
|
158
|
+
.demo-button[data-open] {
|
|
159
|
+
border-color: var(--color-primary);
|
|
160
|
+
color: var(--color-primary);
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
.demo-button[data-pending] {
|
|
164
|
+
cursor: progress;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
ul.demo-list {
|
|
168
|
+
margin: 0 0 12px;
|
|
169
|
+
padding: 0;
|
|
170
|
+
list-style: none;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
ul.demo-list .demo-row {
|
|
174
|
+
justify-content: space-between;
|
|
175
|
+
max-inline-size: 20rem;
|
|
176
|
+
padding-block: 4px;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
ul.demo-list .demo-row[data-archived] > span {
|
|
180
|
+
color: var(--color-text-secondary);
|
|
181
|
+
text-decoration: line-through;
|
|
182
|
+
}
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
This share popover is a Server Component in JS-free mode. The Trigger and Done are native invokers, so it works before hydration and with JavaScript disabled; the platform's dialog focusing steps put focus on the input, the first focusable element.
|
|
186
|
+
|
|
187
|
+
## Anatomy
|
|
188
|
+
|
|
189
|
+
```tsx
|
|
190
|
+
import { Popover } from "@funstack/ui/popover";
|
|
191
|
+
|
|
192
|
+
<Popover.Root> {/* no DOM: ids, mode, state */}
|
|
193
|
+
<Popover.Trigger>Filters</Popover.Trigger> {/* button[popovertarget] */}
|
|
194
|
+
<Popover.Popup side="bottom" align="start"> {/* dialog[popover=auto][aria-modal=false] */}
|
|
195
|
+
<Popover.Title>Filters</Popover.Title> {/* h2, wired to aria-labelledby */}
|
|
196
|
+
<Popover.Description>…</Popover.Description> {/* p, wired to aria-describedby */}
|
|
197
|
+
<FilterForm />
|
|
198
|
+
<Popover.Close>Done</Popover.Close> {/* button[commandfor][command=hide-popover] */}
|
|
199
|
+
</Popover.Popup>
|
|
200
|
+
</Popover.Root>
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
- **Root renders no DOM.** Trigger and Popup are linked by id through `popovertarget`. Render the Popup **right after the Trigger** where the layout allows: Safari 27.0 does not put a far-away popover next in the Tab order after its trigger. A `<button popovertarget>` or `<button commandfor command>` of your own that targets the popover is a [foreign invoker](../concepts/browser-owned-state.md#foreign-invoker) (see [Other ways to open and close](#other-openers)).
|
|
204
|
+
- **Popup is the `<dialog popover>` itself.** There is no Portal, Positioner, Arrow or Backdrop part: the top layer and CSS Anchor Positioning make them unnecessary, and a portalled popover would be inert inside a modal Dialog. A Popover nested inside a Popup is a nested popover; a Dialog opened from a Popup keeps it open.
|
|
205
|
+
- No `Form` part: a popover-shown `<dialog>` ignores `<form method="dialog">`. "Submit, then close" is a `<form action>` plus a controlled `open` (recipe below), or a `Popover.Close action`.
|
|
206
|
+
- `render`: Popup renders a `<dialog>` (default) or a `<div>`; Trigger and Close render a `<button>` for the native invoker path, and another element works only through the library's click handler (library mode, or a Close with `action`). Wrong elements are development warnings.
|
|
207
|
+
|
|
208
|
+
## How it works
|
|
209
|
+
|
|
210
|
+
### Two modes
|
|
211
|
+
|
|
212
|
+
| | JS-free mode | Library mode |
|
|
213
|
+
| - | - | - |
|
|
214
|
+
| Selected when | Root has none of `open`, `defaultOpen`, `openChangeAction` | Root has any of them |
|
|
215
|
+
| Open | the browser toggles it (the Trigger's `popovertarget`) | the click is intercepted and dispatched in the Root's transition; `showPopover({ source: trigger })` runs in the commit that mounts the content. Any other open (a foreign invoker, a script) is cancelled at `beforetoggle` and routed the same way |
|
|
216
|
+
| Close by a part (Trigger, Close) | the browser | the library: `openChangeAction(false)` is awaited, then `hidePopover()` runs in the commit |
|
|
217
|
+
| Close by a dismissal (Escape, click outside, another popover) | the browser | the browser; `openChangeAction(false)` is a notification |
|
|
218
|
+
| Popup content | always mounted (in the server HTML) | rendered from committed `open`; unmounted while closed unless `keepMounted` |
|
|
219
|
+
| Trigger `data-open` | kept current on the element from the popup's `toggle` event | optimistic, rendered |
|
|
220
|
+
| Trigger `data-pending` | not emitted | emitted |
|
|
221
|
+
| Before hydration | everything works | the native open happens; the content arrives on hydration |
|
|
222
|
+
| `transition` on Popup | no effect (development warning) | animates opens, content swaps and every library-driven close |
|
|
223
|
+
|
|
224
|
+
In library mode, opening and [a part's close](../concepts/browser-owned-state.md#parts-close) are the library's; a [dismissal](../concepts/browser-owned-state.md#dismissal) (Escape, a click outside, another popover opening) is the browser's, and the Root is notified afterwards ([Parts vs dismissals](../concepts/browser-owned-state.md#parts-vs-dismissals)). The mode is decided on the first render; switching later is not supported (development warning).
|
|
225
|
+
|
|
226
|
+
### <a id="other-openers"></a>Other ways to open and close
|
|
227
|
+
|
|
228
|
+
- **[Foreign invokers](../concepts/browser-owned-state.md#foreign-invoker) and scripts:** in library mode any open that the library did not start (a `<button commandfor command="show-popover">`, a `<button popovertarget>`, a script `showPopover()`) is cancelled at `beforetoggle` and dispatched with that `ToggleEvent`. A foreign close happens natively and is reported as `"activate"`: a `hide-popover` or `toggle-popover` command with its `CommandEvent`, a `<button popovertarget>` with the `beforetoggle` `ToggleEvent`, whose `source` is the button. Escape, a click outside and a script `hidePopover()` stay `"dismiss"`.
|
|
229
|
+
- **Hover card (Chromium):** a `<button interestfor>` naming the Popup (your own button, or the Trigger with `interestfor` added) opens it on interest (hover or keyboard focus) through the library, and in library mode the Popup hides again on lost interest: `openChangeAction(false)` is a `"dismiss"` notification whose `details.event` is the `loseinterest` event (its `source` is the button). Lost interest while the open is still pending cancels it, so the card never appears under a pointer that has left. A Trigger-click open stays open on lost interest, as in the platform. As with the platform's own lost-interest hide, focus is not returned to the Trigger. Firefox and Safari ignore `interestfor`, so give the button a click path (make it the Trigger) when the card must open everywhere. For a name or description (`role="tooltip"` content), use [Tooltip](tooltip.md).
|
|
230
|
+
|
|
231
|
+
## Props
|
|
232
|
+
|
|
233
|
+
### `Popover.Root`
|
|
234
|
+
|
|
235
|
+
| Prop | Type | Default | Description |
|
|
236
|
+
| - | - | - | - |
|
|
237
|
+
| `open` | `boolean` | – | Controlled open state. undefined means uncontrolled. Selects library mode. |
|
|
238
|
+
| `defaultOpen` | `boolean` | – | Initial open state in uncontrolled library mode. A popover that starts open is shown after hydration (there is no attribute for an open popover in HTML); its content and the Trigger's `data-open` are already in the server HTML, while the Trigger is exposed collapsed until the popup is shown. `defaultOpen={false}` is the usual way to select library mode without an action. |
|
|
239
|
+
| `openChangeAction` | `ChangeAction<boolean, PopoverOpenChangeDetails>` | – | Awaited for `true` (the popover opens when it resolves and the content has rendered) and for a `false` the user asked a part for (Trigger, Close: the popover hides when it resolves). A notification for a dismissal: the popover is already hidden when it runs. Runs in the Root's transition; may be a Server Function; rejections reach the nearest Error Boundary above the Root. `details.reason`: `"activate"` (Trigger, Close, a foreign invoker), `"dismiss"` (Escape, a click outside, script, another popover or modal dialog, lost interest on an `interestfor` button) or `"platform"` (found open on hydration; `event` is `undefined`). Selects library mode. |
|
|
240
|
+
| `children` | `ReactNode \| ((state: PopoverRootState) => ReactNode)` | – | The parts. The function form receives the optimistic state and must not suspend. |
|
|
241
|
+
|
|
242
|
+
- **State**: `PopoverRootState` is `{ open, pending }`; `open` is optimistic, and both are `false` in JS-free mode.
|
|
243
|
+
- **Owned**: nothing rendered: the Root has no element (no `ref`, `className` or `style`), and no `disabled` (the Trigger has it).
|
|
244
|
+
|
|
245
|
+
### `Popover.Trigger`
|
|
246
|
+
|
|
247
|
+
A `<button popovertarget>`: see [Triggers of a popup](../concepts/browser-owned-state.md#popup-triggers) for what that gives it, and for a Trigger rendered as another element. One per Root: it is the popover's anchor and focus-return target, and a press on a second Trigger while open counts as outside.
|
|
248
|
+
|
|
249
|
+
| Prop | Type | Default | Description |
|
|
250
|
+
| - | - | - | - |
|
|
251
|
+
| `disabled` | `boolean` | `false` | Native `disabled`: a disabled button is not an invoker and never dispatches. Owned, so a `render` element cannot re-enable it. In library mode with a link or component `render`, `aria-disabled="true"` instead (the element stays focusable). |
|
|
252
|
+
| `className` | `string \| ((state: PopoverTriggerState) => string \| undefined)` | – | A class name, or a function of the part's state. |
|
|
253
|
+
| `style` | `CSSProperties \| ((state: PopoverTriggerState) => CSSProperties \| undefined)` | – | Inline style, or a function of the part's state. |
|
|
254
|
+
| `children` | `ReactNode \| ((state: PopoverTriggerState) => ReactNode)` | – | Rendered from optimistic state; must not suspend. |
|
|
255
|
+
| `render` | `ReactElement \| ((props, state: PopoverTriggerState) => ReactNode)` | – | Replace the default \<button> (element form) or take over rendering (function form). |
|
|
256
|
+
|
|
257
|
+
- **State**: `PopoverTriggerState` is `{ open, pending, disabled }`; `pending` is true while the Root is pending: an open, a part's close or a dismissal notification.
|
|
258
|
+
- **Owned**: `type` (only on a `<button>`), `disabled`, `aria-disabled` (library mode, link or component `render`), `popoverTarget` (only on an invoker), `aria-expanded` (only on a Trigger that is no invoker), `onClick` (library mode), `data-open`, `data-pending`, `data-disabled`. Owned and never written: `popoverTargetAction`, `commandfor`, `command`. Not in the props type: these three, `popoverTarget` and `aria-expanded`.
|
|
259
|
+
|
|
260
|
+
A click on a `<button>` Trigger while open is a part's close; a second click during a pending open cancels it (the latest intent wins). A Trigger rendered as another element (library mode only) is light-dismissed before its click; that close is reported as `"activate"`. `aria-haspopup` and `aria-controls` pass through.
|
|
261
|
+
|
|
262
|
+
### `Popover.Popup`
|
|
263
|
+
|
|
264
|
+
| Prop | Type | Default | Description |
|
|
265
|
+
| - | - | - | - |
|
|
266
|
+
| `side` | `"top" \| "bottom" \| "left" \| "right" \| "inline-start" \| "inline-end" \| null` | `"bottom"` | Placement relative to the Trigger through inline `position-area`, with `position-try-fallbacks: flip-block, flip-inline, flip-block flip-inline` flipping it when it does not fit. `inline-start` / `inline-end` follow the popup's direction (`inline-end` is the right in LTR, the left in RTL); the other four are physical. `null` emits no inline placement and no `data-side` / `data-align`: your stylesheet owns placement. |
|
|
267
|
+
| `align` | `"start" \| "center" \| "end"` | `"center"` | Alignment along the side. On a top / bottom side `start` / `end` are inline-relative (`start` lines up the inline-start edges: the left in LTR, the right in RTL); on the other sides the top / bottom edges. Ignored when `side` is `null`. |
|
|
268
|
+
| `keepMounted` | `boolean` | `false` | Library mode. `false`: children are not rendered while closed, so content that suspends holds the open until it is ready. `true`: children stay in `<Activity mode="hidden">` (state kept, effects stopped, pre-rendered at low priority; not in the server HTML). Unmounting waits for the popover's CSS exit animation, or happens in the close commit when `transition` is set. Ignored in JS-free mode (always mounted). |
|
|
269
|
+
| `initialFocus` | `RefObject<HTMLElement \| null> \| string` | – | The element to focus on open: a ref, or a selector resolved inside the popup. The library writes `autofocus` on it right before `showPopover()` and lets the platform focus it. Default: the platform's choice for a `<dialog>` (the first focusable element, else the popup); with `render={<div />}` focus stays on the Trigger. In JS-free mode the attribute is written after mount; prefer it to `autoFocus`, which React writes only into server-rendered HTML (not when the Popup renders on the client, for example after a client navigation to a Server Component page). |
|
|
270
|
+
| `transition` | `ViewTransitionClass` | – | Library mode only. Forwarded to a `<ViewTransition>` around the popover element itself: animates the opening commit, content swaps, and every library-driven close (Trigger, Close, a controlled `open={false}`) in all engines. Dismissals are the browser's and animate with CSS. Default: no boundary. Keep it static; any value makes a Root inserted by a transition run the page cross-fade. |
|
|
271
|
+
| `className` | `string \| ((state: PopoverPopupState) => string \| undefined)` | – | A class name, or a function of the part's state. |
|
|
272
|
+
| `style` | `CSSProperties \| ((state: PopoverPopupState) => CSSProperties \| undefined)` | – | Inline style, or a function of the part's state. |
|
|
273
|
+
| `children` | `ReactNode \| ((state: PopoverPopupState) => ReactNode)` | – | Content, or a function of the part's state. |
|
|
274
|
+
| `render` | `ReactElement \| ((props, state: PopoverPopupState) => ReactNode)` | – | Replace the default \<dialog> (element form) or take over rendering (function form). |
|
|
275
|
+
|
|
276
|
+
- **State**: `PopoverPopupState` is `{ open, side, align }`; `open` is committed (`false` in JS-free mode; `:popover-open` is the DOM truth); `side` / `align` are where the browser placed the popup while it is shown (a physical side, after any fallback flip, in both modes), your props otherwise.
|
|
277
|
+
- **Owned**: `id`, `popover` (`"auto"`), `open` (never rendered), `aria-modal` (`"false"`: Chromium exposes a `<dialog popover>` as modal otherwise), `data-side` / `data-align` (unless `side` is `null`); `aria-labelledby` and `aria-describedby` are merged with yours.
|
|
278
|
+
|
|
279
|
+
`role="dialog"` is a default you can override (`"region"` or `"group"` for a non-interactive card). `onToggle` and `onBeforeToggle` are not accepted; use a `ref` for the platform events. Your `style` wins over the inline placement.
|
|
280
|
+
|
|
281
|
+
### `Popover.Close`
|
|
282
|
+
|
|
283
|
+
| Prop | Type | Default | Description |
|
|
284
|
+
| - | - | - | - |
|
|
285
|
+
| `action` | `Action<[details: ActionDetails]>` | – | Runs in this button's own transition (`data-pending` on it), then closes the popover: in library mode through the Root (`openChangeAction(false)` awaited, view transition if set), in JS-free mode with `hidePopover()`. A rejection reaches the nearest Error Boundary above the button and leaves the popover open. A second click while it is pending is ignored, and the button is `aria-disabled="true"` meanwhile. Without `action` in JS-free mode the button is a native `command="hide-popover"` invoker. |
|
|
286
|
+
| `disabled` | `boolean` | `false` | Native `disabled`; owned, so a `render` element cannot re-enable it. With a link or component `render` where the Close handles the click (library mode, or with `action`), `aria-disabled="true"` instead (the element stays focusable). |
|
|
287
|
+
| `className` | `string \| ((state: PopoverCloseState) => string \| undefined)` | – | A class name, or a function of the part's state. |
|
|
288
|
+
| `style` | `CSSProperties \| ((state: PopoverCloseState) => CSSProperties \| undefined)` | – | Inline style, or a function of the part's state. |
|
|
289
|
+
| `children` | `ReactNode \| ((state: PopoverCloseState) => ReactNode)` | – | Content, or a function of the part's state. |
|
|
290
|
+
| `render` | `ReactElement \| ((props, state: PopoverCloseState) => ReactNode)` | – | Replace the default \<button> (element form) or take over rendering (function form). |
|
|
291
|
+
|
|
292
|
+
- **State**: `PopoverCloseState` is `{ pending, disabled }`.
|
|
293
|
+
- **Owned**: `type` (on a `<button>` only), `disabled`, `aria-disabled`, `commandfor`, `command` (not on a link or other non-button host element), `onClick` (library mode, or with `action`), `data-pending`, `data-disabled`; a `render` element cannot re-enable a disabled Close.
|
|
294
|
+
|
|
295
|
+
In library mode the click is always intercepted, so every Close goes through the Root. A second click while the action is pending is ignored (and cancelled), and the button is `aria-disabled="true"` for as long as it shows `data-pending` (the action and the hide); never natively disabled, so it keeps focus. To hide at once and finish the work in the background, do not return the promise: `action={() => { void apply(); }}`. If the user dismisses the popover and opens it again while the action runs, the action's close is dropped: it belonged to the earlier open. Popovers have no return value.
|
|
296
|
+
|
|
297
|
+
### `Popover.Title`, `Popover.Description`
|
|
298
|
+
|
|
299
|
+
| Prop | Type | Default | Description |
|
|
300
|
+
| - | - | - | - |
|
|
301
|
+
| `className` | `string \| ((state: PopoverTitleState) => string \| undefined)` | – | A class name, or a function of the part's state. |
|
|
302
|
+
| `style` | `CSSProperties \| ((state: PopoverTitleState) => CSSProperties \| undefined)` | – | Inline style, or a function of the part's state. |
|
|
303
|
+
| `children` | `ReactNode \| ((state: PopoverTitleState) => ReactNode)` | – | Content, or a function of the part's state. |
|
|
304
|
+
| `render` | `ReactElement \| ((props, state: PopoverTitleState) => ReactNode)` | – | Replace the default \<h2> (Title) or \<p> (Description). `render={<h3 />}` changes the heading level. |
|
|
305
|
+
|
|
306
|
+
- **State**: the Popup's (`PopoverTitleState` and `PopoverDescriptionState` are `PopoverPopupState`).
|
|
307
|
+
- **Owned**: `id`.
|
|
308
|
+
|
|
309
|
+
A dialog-role Popup with neither a Title nor an `aria-label` is a development warning once shown.
|
|
310
|
+
|
|
311
|
+
## Data attributes
|
|
312
|
+
|
|
313
|
+
| Hook | On | Meaning |
|
|
314
|
+
| - | - | - |
|
|
315
|
+
| `:popover-open` | Popup | The popover is shown (DOM truth, both modes). |
|
|
316
|
+
| `data-side`, `data-align` | Popup | While shown: where the browser placed the popup (`top` / `bottom` / `left` / `right`, after any flip; read from the computed `position-area`). Otherwise the requested placement. Absent with `side={null}`. |
|
|
317
|
+
| `aria-expanded` | Trigger, only when it is no [invoker](../concepts/browser-owned-state.md#popup-triggers): a link or other non-button element, or a disabled component `render` | Whether the popup is shown (library mode). A `<button>` Trigger has none: the browser exposes the state. |
|
|
318
|
+
| `data-open` | Trigger | Library mode: optimistic open state. JS-free mode: whether the popup is shown, written from its `toggle` event. |
|
|
319
|
+
| `data-pending` | Trigger | An open, a part-initiated close or a dismissal notification is in flight (library mode only). |
|
|
320
|
+
| `data-pending` | Close | Its `action` is in flight. |
|
|
321
|
+
| `aria-disabled` | Close | `"true"` while `data-pending`: a second click is ignored meanwhile. |
|
|
322
|
+
| `data-disabled` | Trigger, Close | The `disabled` prop (both modes). |
|
|
323
|
+
|
|
324
|
+
## Keyboard and ARIA
|
|
325
|
+
|
|
326
|
+
| Key | Behaviour | Who |
|
|
327
|
+
| - | - | - |
|
|
328
|
+
| Enter / Space on the Trigger | Toggles | the browser (JS-free) or the Trigger |
|
|
329
|
+
| Tab / Shift+Tab | Moves through the popup; the popup follows the Trigger in focus order. Tab past the end leaves, and the popover stays open | the browser |
|
|
330
|
+
| Escape | Closes the innermost open popover; focus returns to its Trigger; `openChangeAction(false, { reason: "dismiss" })` | the browser (and the library for a nested popover) |
|
|
331
|
+
| Escape in a modal Dialog opened from the popup | Closes the Dialog only; a second Escape closes the popover | the browser |
|
|
332
|
+
|
|
333
|
+
- **Initial focus.** With the default `<dialog>`, opening runs the dialog focusing steps: the `initialFocus` target, else the first focusable element, else the popup itself (the APG non-modal dialog), in every engine. For a disclosure-style card that keeps focus on the Trigger, render a `<div>`: `render={<div />}` with `role="region"` and an `aria-label`.
|
|
334
|
+
- **Focus return.** The platform returns focus to the Trigger for the first popover in a stack. For a **nested** popover it returns nothing, so the library focuses the inner Trigger when focus was inside the popup and was left on the body. A click outside leaves focus where the click put it.
|
|
335
|
+
- **ARIA.** The Popup has `role="dialog"` and `aria-modal="false"` explicitly (WebKit implements no minimum role for popovers; Chromium would expose a `<dialog popover>` as modal). The browser exposes the Trigger's expanded state ([Triggers of a popup](../concepts/browser-owned-state.md#popup-triggers)). No `aria-haspopup` (the APG disclosure shape); add `aria-haspopup="dialog"` or `aria-controls` yourself if you want them.
|
|
336
|
+
- No focus trap and no `lightDismiss` or `modal` prop: light dismiss and Escape are what `popover="auto"` is. A panel that must survive stray clicks is a [Dialog](dialog.md).
|
|
337
|
+
|
|
338
|
+
## Transition types
|
|
339
|
+
|
|
340
|
+
Concept: [Transitions & ViewTransition](../concepts/transitions.md#transition-types)
|
|
341
|
+
|
|
342
|
+
Library mode: `fsui-popover` plus `fsui-popover-open` or `fsui-popover-close`; a controlled close carries none. JS-free mode starts no transitions.
|
|
343
|
+
|
|
344
|
+
### ViewTransition: an exit in every engine
|
|
345
|
+
|
|
346
|
+
With `transition`, the Popup renders `<ViewTransition>` around the popover element itself. A library-driven open shows the popover in the layout effect of its commit and a library-driven close hides it in the layout effect of its commit, so the view transition captures the popup's box as `::view-transition-new` on open and `::view-transition-old` (with its content) on close. That is the only way a popover's exit can animate in Firefox.
|
|
347
|
+
|
|
348
|
+
```tsx
|
|
349
|
+
<Popover.Popup transition={{ "fsui-popover-open": "pop-in", "fsui-popover-close": "pop-out", default: "none" }}>
|
|
350
|
+
```
|
|
351
|
+
|
|
352
|
+
```css
|
|
353
|
+
::view-transition-new(.pop-in) { animation: 160ms ease-out both pop-in; }
|
|
354
|
+
::view-transition-old(.pop-out) { animation: 120ms ease-in both pop-out; }
|
|
355
|
+
/* Keep the CSS exit above for dismissals, but not while a view transition runs. */
|
|
356
|
+
html:active-view-transition .popover { transition: none; }
|
|
357
|
+
@media (prefers-reduced-motion: reduce) {
|
|
358
|
+
::view-transition-group(*), ::view-transition-old(*), ::view-transition-new(*) { animation: none !important; }
|
|
359
|
+
}
|
|
360
|
+
```
|
|
361
|
+
|
|
362
|
+
- Transition types: `fsui-popover` plus `fsui-popover-open` or `fsui-popover-close`. A controlled close carries none.
|
|
363
|
+
- Dismissals (Escape, a click outside) animate with the CSS exit only: keep it, and cut it while a view transition runs, as above ([A popup with a CSS exit and a view transition](../concepts/transitions.md#css-exit)).
|
|
364
|
+
- A plain open starts no document view transition: the content mounts under the already-mounted popover element. A Popup with `transition` that itself mounts inside a transition (a Root inserted by one, a nested Popup mounting with the outer content) runs the page cross-fade ([the transition prop](../concepts/transitions.md#transition-prop), issue [#35](https://github.com/uhyo/funstack-ui/issues/35)). The page receives no pointer events while a view transition runs: keep them short.
|
|
365
|
+
|
|
366
|
+
## Optimistic and pending
|
|
367
|
+
|
|
368
|
+
Concept: [Pending & optimistic state](../concepts/pending-and-optimistic.md)
|
|
369
|
+
|
|
370
|
+
Library mode: the Trigger shows the optimistic open state (`data-open`) and `data-pending` while an open, a part's close or a dismissal notification is in flight. The expanded state assistive technology hears follows the shown popup, so after Escape or a click outside it is collapsed at once, even while the dismissal notification runs. The Popup's content renders from the committed `open`. A Close with an `action` is a [pure trigger](../concepts/pending-and-optimistic.md#pure-trigger).
|
|
371
|
+
|
|
372
|
+
### Walkthrough (library mode)
|
|
373
|
+
|
|
374
|
+
```tsx title="PopoverActions.tsx"
|
|
375
|
+
"use client";
|
|
376
|
+
import { startTransition, use, useState } from "react";
|
|
377
|
+
import { Popover } from "@funstack/ui/popover";
|
|
378
|
+
import type { PopoverOpenChangeDetails } from "@funstack/ui/popover";
|
|
379
|
+
import { sleep } from "./fake-api.js";
|
|
380
|
+
|
|
381
|
+
// Cache the promises so `use()` sees the same one on every render.
|
|
382
|
+
const cache = new Map<string, Promise<readonly string[]>>();
|
|
383
|
+
function loadPermissions(id: string): Promise<readonly string[]> {
|
|
384
|
+
let promise = cache.get(id);
|
|
385
|
+
if (promise === undefined) {
|
|
386
|
+
promise = sleep(1000).then(() => (id === "notes" ? ["Rename"] : ["Rename", "Archive"]));
|
|
387
|
+
cache.set(id, promise);
|
|
388
|
+
}
|
|
389
|
+
return promise;
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
function RowActions({ id, archive }: { id: string; archive: () => Promise<void> }) {
|
|
393
|
+
const permissions = use(loadPermissions(id));
|
|
394
|
+
return (
|
|
395
|
+
<div className="demo-popover-actions">
|
|
396
|
+
<Popover.Close className="demo-button" action={() => sleep(400)}>
|
|
397
|
+
{({ pending }) => (pending ? "Renaming…" : "Rename")}
|
|
398
|
+
</Popover.Close>
|
|
399
|
+
{permissions.includes("Archive") && (
|
|
400
|
+
<Popover.Close className="demo-button demo-danger" action={archive}>
|
|
401
|
+
{({ pending }) => (pending ? "Archiving…" : "Archive")}
|
|
402
|
+
</Popover.Close>
|
|
403
|
+
)}
|
|
404
|
+
</div>
|
|
405
|
+
);
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
// Library mode: `defaultOpen={false}` (or any action prop) hands the open to the library. The
|
|
409
|
+
// Popup's children render from committed state, so <RowActions> mounts inside the opening
|
|
410
|
+
// transition and suspends: the popup stays hidden and the Trigger carries data-pending until the
|
|
411
|
+
// permissions are loaded, then it opens once, complete. A Close with an `action` runs it with its
|
|
412
|
+
// own pending state, then closes through the Root: the commit hides the popup, and
|
|
413
|
+
// `transition="pop"` animates that exit with a view transition, Firefox included. Escape and
|
|
414
|
+
// clicks outside are the browser's (reason "dismiss") and use the CSS fade.
|
|
415
|
+
export function PopoverActions() {
|
|
416
|
+
const [archived, setArchived] = useState<readonly string[]>([]);
|
|
417
|
+
const [last, setLast] = useState("(none yet)");
|
|
418
|
+
const record = (open: boolean, { reason }: PopoverOpenChangeDetails) => {
|
|
419
|
+
// The synchronous part of an action: this setState is a transition update.
|
|
420
|
+
setLast(`open=${open} reason="${reason}"`);
|
|
421
|
+
};
|
|
422
|
+
const rows = [
|
|
423
|
+
{ id: "report", name: "Quarterly report" },
|
|
424
|
+
{ id: "notes", name: "Offsite notes" },
|
|
425
|
+
];
|
|
426
|
+
return (
|
|
427
|
+
<>
|
|
428
|
+
<ul className="demo-list">
|
|
429
|
+
{rows.map(({ id, name }) => (
|
|
430
|
+
<li key={id} className="demo-row" data-archived={archived.includes(id) ? "" : undefined}>
|
|
431
|
+
<span>{name}</span>
|
|
432
|
+
<Popover.Root defaultOpen={false} openChangeAction={record}>
|
|
433
|
+
<Popover.Trigger className="demo-button" aria-label={`Actions for ${name}`}>
|
|
434
|
+
{({ pending }) => (pending ? <span className="demo-spinner" aria-hidden /> : "⋯")}
|
|
435
|
+
</Popover.Trigger>
|
|
436
|
+
<Popover.Popup className="demo-popover demo-popover-vt" align="end" transition="pop">
|
|
437
|
+
<Popover.Title>{name}</Popover.Title>
|
|
438
|
+
<RowActions
|
|
439
|
+
id={id}
|
|
440
|
+
archive={async () => {
|
|
441
|
+
await sleep(800);
|
|
442
|
+
// After an await: wrap the update in startTransition (React limitation).
|
|
443
|
+
startTransition(() => setArchived((ids) => [...ids, id]));
|
|
444
|
+
}}
|
|
445
|
+
/>
|
|
446
|
+
</Popover.Popup>
|
|
447
|
+
</Popover.Root>
|
|
448
|
+
</li>
|
|
449
|
+
))}
|
|
450
|
+
</ul>
|
|
451
|
+
<div className="demo-row">
|
|
452
|
+
<button type="button" className="demo-button" onClick={() => cache.clear()}>
|
|
453
|
+
Clear the cache
|
|
454
|
+
</button>
|
|
455
|
+
</div>
|
|
456
|
+
<output className="demo-readout">
|
|
457
|
+
last openChangeAction: <code>{last}</code>
|
|
458
|
+
</output>
|
|
459
|
+
</>
|
|
460
|
+
);
|
|
461
|
+
}
|
|
462
|
+
```
|
|
463
|
+
|
|
464
|
+
`popover.css`: the same file as above.
|
|
465
|
+
|
|
466
|
+
1. Click ⋯: the click is cancelled (so the native toggle does not run), the Trigger gets `data-open` and `data-pending` (it is exposed collapsed until the popup is shown), and `openChangeAction(true, { reason: "activate" })` runs.
|
|
467
|
+
2. The commit that sets committed `open` renders the Popup's children; `RowActions` suspends, so React holds the commit. The popup stays hidden; the Trigger keeps spinning.
|
|
468
|
+
3. The data arrives: the content commits and `showPopover({ source: trigger })` runs in the same commit, so the popup is anchored below the Trigger and the platform focuses fully rendered content. With `transition="pop"` it animates in.
|
|
469
|
+
4. Click Archive: the button shows its own pending label while its action runs; then the Close dispatches `openChangeAction(false, { reason: "activate" })` and the commit that ends it hides the popup inside a view transition: the exit animates in every engine.
|
|
470
|
+
5. Press Escape or click outside instead: the browser hides the popover at once (CSS fade), and the Root receives `openChangeAction(false, { reason: "dismiss" })`.
|
|
471
|
+
|
|
472
|
+
> **Refusing a close**
|
|
473
|
+
>
|
|
474
|
+
> A controlled parent that keeps `open` after a **part-initiated** close vetoes it: nothing was hidden, the Trigger's `data-open` snaps back. After a **dismissal** the popover is already hidden; a parent that keeps `open` gets it re-opened once the action settles, which the user sees as a blink. Adopt `false` for dismissals.
|
|
475
|
+
|
|
476
|
+
## Suspense
|
|
477
|
+
|
|
478
|
+
Concept: [Suspense](../concepts/suspense.md)
|
|
479
|
+
|
|
480
|
+
Content that suspends holds the open: the popup stays hidden with the Trigger pending, then shows once, complete. A `<Suspense>` inside the Popup opens at once with a skeleton instead.
|
|
481
|
+
|
|
482
|
+
## Browser-owned state
|
|
483
|
+
|
|
484
|
+
Concept: [Browser-owned state](../concepts/browser-owned-state.md)
|
|
485
|
+
|
|
486
|
+
JS-free mode: the browser owns everything through the Trigger's `popovertarget` and the Close's Invoker Command. Library mode: opening and a close asked for by a part are library-owned; a dismissal (Escape, a click outside, another popover opening) is the browser's: the popover closes at once and `openChangeAction(false)` is a notification with `reason: "dismiss"`. Dismissals animate with CSS only.
|
|
487
|
+
|
|
488
|
+
## Before hydration
|
|
489
|
+
|
|
490
|
+
Concept: [Server Components](../concepts/server-components.md#before-hydration)
|
|
491
|
+
|
|
492
|
+
JS-free mode: everything, including `autoFocus` in server-rendered markup. Library mode: the Trigger opens the popover natively, but the content is not in the HTML yet; on hydration the Popup finds it open, dispatches `openChangeAction(true)` with `reason: "platform"` and the content mounts.
|
|
493
|
+
|
|
494
|
+
### The [platform paths](../concepts/browser-owned-state.md#platform-path)
|
|
495
|
+
|
|
496
|
+
- **Before hydration, JS-free mode:** everything works, including `autoFocus` in server-rendered markup. After hydration, and for content React renders on the client, use `initialFocus`: React does not write `autofocus` on client-rendered elements.
|
|
497
|
+
- **Before hydration, library mode:** the Trigger already carries `popovertarget`, so a click opens the popover natively, but the content is not in the HTML yet (with `defaultOpen` it is, and the Trigger already has `data-open`; only the showing waits for hydration). On hydration the Popup finds it open and dispatches `openChangeAction(true, { reason: "platform" })` with no event; the content mounts into the open popover. If the action rejects or a controlled parent refuses, the popover closes again.
|
|
498
|
+
|
|
499
|
+
## Styling
|
|
500
|
+
|
|
501
|
+
The Trigger's styling hook is `data-open` in both modes (optimistic in library mode, written from the popup's `toggle` event in JS-free mode); a `<button>` Trigger has no `aria-expanded` to select on ([Triggers of a popup](../concepts/browser-owned-state.md#popup-triggers)). On a page that never hydrates, style the Trigger from the popup that follows it:
|
|
502
|
+
|
|
503
|
+
```css
|
|
504
|
+
.trigger[data-open] { color: var(--accent); }
|
|
505
|
+
/* Without JavaScript: the Popup right after the Trigger. */
|
|
506
|
+
.trigger:has(+ :popover-open) { color: var(--accent); }
|
|
507
|
+
```
|
|
508
|
+
|
|
509
|
+
The Popup emits no `data-open`: `:popover-open` is exact. Enter and exit animate in CSS, in both modes:
|
|
510
|
+
|
|
511
|
+
```css
|
|
512
|
+
.popover {
|
|
513
|
+
margin: 0;
|
|
514
|
+
inset: auto; /* the popover UA stylesheet sets inset: 0 */
|
|
515
|
+
opacity: 0;
|
|
516
|
+
translate: 0 -4px;
|
|
517
|
+
transition: opacity 120ms, translate 120ms, display 120ms allow-discrete, overlay 120ms allow-discrete;
|
|
518
|
+
}
|
|
519
|
+
.popover:popover-open { opacity: 1; translate: 0 0; }
|
|
520
|
+
@starting-style { .popover:popover-open { opacity: 0; translate: 0 -4px; } }
|
|
521
|
+
/* The gap, static on the requested edge (side="bottom"): a flip swaps the popup's margins, so
|
|
522
|
+
it moves to the other edge by itself. */
|
|
523
|
+
.popover { margin-block-start: 6px; }
|
|
524
|
+
/* A class that serves any side: both sides of the axis, keyed on data-side, the closed logical
|
|
525
|
+
values included so the first layout has the gap. A one-sided margin keyed on the resolved
|
|
526
|
+
data-side is the wrong form: after a flip it lands on the far edge. */
|
|
527
|
+
.popover-any[data-side="top"], .popover-any[data-side="bottom"] { margin-block: 6px; }
|
|
528
|
+
.popover-any[data-side="left"], .popover-any[data-side="right"],
|
|
529
|
+
.popover-any[data-side="inline-start"], .popover-any[data-side="inline-end"] { margin-inline: 6px; }
|
|
530
|
+
@media (prefers-reduced-motion: reduce) { .popover { transition: none; } }
|
|
531
|
+
```
|
|
532
|
+
|
|
533
|
+
`data-side` is where the popup **is**, read from the computed `position-area` while it is shown; the [Tooltip page](tooltip.md#data-attributes) explains the mechanism, its render cost and the margin and animation caveats, which apply here as they are. Popover has no Arrow part; an arrow drawn with a pseudo-element on `[data-side]` follows a flip (see the [Tooltip arrow](tooltip.md#arrow)).
|
|
534
|
+
|
|
535
|
+
## Recipes
|
|
536
|
+
|
|
537
|
+
### Submit, then close (controlled)
|
|
538
|
+
|
|
539
|
+
```tsx
|
|
540
|
+
const [open, setOpen] = useState(false);
|
|
541
|
+
|
|
542
|
+
<Popover.Root open={open} openChangeAction={(next) => { setOpen(next); }}>
|
|
543
|
+
<Popover.Trigger>Rename</Popover.Trigger>
|
|
544
|
+
<Popover.Popup initialFocus="[name=title]">
|
|
545
|
+
<Popover.Title>Rename</Popover.Title>
|
|
546
|
+
<form
|
|
547
|
+
action={async (formData) => {
|
|
548
|
+
await rename(formData);
|
|
549
|
+
startTransition(() => setOpen(false)); // a library-driven close: view transition if set
|
|
550
|
+
}}
|
|
551
|
+
>
|
|
552
|
+
<input name="title" defaultValue={title} />
|
|
553
|
+
<SubmitButton>Save</SubmitButton>
|
|
554
|
+
<Popover.Close>Cancel</Popover.Close>
|
|
555
|
+
</form>
|
|
556
|
+
</Popover.Popup>
|
|
557
|
+
</Popover.Root>
|
|
558
|
+
```
|
|
559
|
+
|
|
560
|
+
### Controlled, opened without a Trigger
|
|
561
|
+
|
|
562
|
+
```tsx
|
|
563
|
+
<Popover.Root open={open} openChangeAction={(next) => { setOpen(next); }}>
|
|
564
|
+
<Popover.Popup side={null} className="popover centered">…</Popover.Popup>
|
|
565
|
+
</Popover.Root>
|
|
566
|
+
```
|
|
567
|
+
|
|
568
|
+
Without a Trigger there is no anchor: the popover is centred by the UA stylesheet unless you position it, so use `side={null}`.
|
|
569
|
+
|
|
570
|
+
### Nested popovers
|
|
571
|
+
|
|
572
|
+
```tsx
|
|
573
|
+
<Popover.Root defaultOpen={false}>
|
|
574
|
+
<Popover.Trigger>Share</Popover.Trigger>
|
|
575
|
+
<Popover.Popup>
|
|
576
|
+
<Popover.Title>Share</Popover.Title>
|
|
577
|
+
<Popover.Root defaultOpen={false}> {/* nested auto popover */}
|
|
578
|
+
<Popover.Trigger>Permissions</Popover.Trigger>
|
|
579
|
+
<Popover.Popup side="right" align="start">…</Popover.Popup>
|
|
580
|
+
</Popover.Root>
|
|
581
|
+
</Popover.Popup>
|
|
582
|
+
</Popover.Root>
|
|
583
|
+
```
|
|
584
|
+
|
|
585
|
+
Opening the inner keeps the outer open; Escape closes the inner and focus returns to "Permissions"; a click outside closes both. Outer parts must sit outside the inner Root. Leave `transition` off an inner Popup unless you want the animation (it pays the page cross-fade when it mounts with the outer content). In Safari, a nested popover with `position-try-fallbacks` can hang (WebKit bug 302008): give the inner Popup `side={null}` and place it in CSS if you hit it.
|
|
586
|
+
|
|
587
|
+
## Browser notes
|
|
588
|
+
|
|
589
|
+
- **Right-to-left:** `side="inline-start"` / `"inline-end"` and `align` on a top or bottom side use the `self-*` keywords, which follow the popup's inherited direction: an RTL page and an RTL container both mirror them, with no JavaScript. Firefox misplaces a popover inside a direction island ([#89](https://github.com/uhyo/funstack-ui/issues/89); see [Tooltip](tooltip.md#browser-notes)).
|
|
590
|
+
- The CSS exit animates in Chromium and Safari; Firefox hides a popover instantly. The library keeps the content mounted until the exit animation ends, so a fading popover is never empty.
|
|
591
|
+
- On iOS, `position-try-fallbacks` together with `@starting-style` can hang (WebKit bug 317926).
|