@funstack/ui 0.1.0-alpha.2 → 0.1.0-alpha.20
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-context.mjs.map +1 -1
- package/dist/accordion/accordion-item.d.mts +22 -4
- package/dist/accordion/accordion-item.d.mts.map +1 -1
- package/dist/accordion/accordion-item.mjs +32 -10
- package/dist/accordion/accordion-item.mjs.map +1 -1
- package/dist/accordion/accordion-panel.d.mts +19 -4
- package/dist/accordion/accordion-panel.d.mts.map +1 -1
- package/dist/accordion/accordion-panel.mjs +8 -6
- package/dist/accordion/accordion-panel.mjs.map +1 -1
- package/dist/accordion/accordion-root.d.mts +39 -5
- package/dist/accordion/accordion-root.d.mts.map +1 -1
- package/dist/accordion/accordion-root.mjs +75 -67
- package/dist/accordion/accordion-root.mjs.map +1 -1
- package/dist/accordion/accordion-trigger.d.mts +12 -4
- package/dist/accordion/accordion-trigger.d.mts.map +1 -1
- package/dist/accordion/accordion-trigger.mjs +14 -28
- 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/alert-dialog/alert-dialog-action.d.mts +73 -0
- package/dist/alert-dialog/alert-dialog-action.d.mts.map +1 -0
- package/dist/alert-dialog/alert-dialog-action.mjs +23 -0
- package/dist/alert-dialog/alert-dialog-action.mjs.map +1 -0
- package/dist/alert-dialog/alert-dialog-cancel.d.mts +31 -0
- package/dist/alert-dialog/alert-dialog-cancel.d.mts.map +1 -0
- package/dist/alert-dialog/alert-dialog-cancel.mjs +50 -0
- package/dist/alert-dialog/alert-dialog-cancel.mjs.map +1 -0
- package/dist/alert-dialog/alert-dialog-context.mjs +24 -0
- package/dist/alert-dialog/alert-dialog-context.mjs.map +1 -0
- package/dist/alert-dialog/alert-dialog-description.d.mts +25 -0
- package/dist/alert-dialog/alert-dialog-description.d.mts.map +1 -0
- package/dist/alert-dialog/alert-dialog-description.mjs +20 -0
- package/dist/alert-dialog/alert-dialog-description.mjs.map +1 -0
- package/dist/alert-dialog/alert-dialog-form.d.mts +27 -0
- package/dist/alert-dialog/alert-dialog-form.d.mts.map +1 -0
- package/dist/alert-dialog/alert-dialog-form.mjs +22 -0
- package/dist/alert-dialog/alert-dialog-form.mjs.map +1 -0
- package/dist/alert-dialog/alert-dialog-popup.d.mts +42 -0
- package/dist/alert-dialog/alert-dialog-popup.d.mts.map +1 -0
- package/dist/alert-dialog/alert-dialog-popup.mjs +53 -0
- package/dist/alert-dialog/alert-dialog-popup.mjs.map +1 -0
- package/dist/alert-dialog/alert-dialog-root.d.mts +31 -0
- package/dist/alert-dialog/alert-dialog-root.d.mts.map +1 -0
- package/dist/alert-dialog/alert-dialog-root.mjs +22 -0
- package/dist/alert-dialog/alert-dialog-root.mjs.map +1 -0
- package/dist/alert-dialog/alert-dialog-title.d.mts +23 -0
- package/dist/alert-dialog/alert-dialog-title.d.mts.map +1 -0
- package/dist/alert-dialog/alert-dialog-title.mjs +18 -0
- package/dist/alert-dialog/alert-dialog-title.mjs.map +1 -0
- package/dist/alert-dialog/alert-dialog-trigger.d.mts +23 -0
- package/dist/alert-dialog/alert-dialog-trigger.d.mts.map +1 -0
- package/dist/alert-dialog/alert-dialog-trigger.mjs +18 -0
- package/dist/alert-dialog/alert-dialog-trigger.mjs.map +1 -0
- package/dist/alert-dialog/index.d.mts +33 -0
- package/dist/alert-dialog/index.d.mts.map +1 -0
- package/dist/alert-dialog/index.mjs +33 -0
- package/dist/alert-dialog/index.mjs.map +1 -0
- 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 +118 -0
- package/dist/button/button.d.mts.map +1 -0
- package/dist/button/button.mjs +98 -0
- package/dist/button/button.mjs.map +1 -0
- package/dist/button/index.d.mts +3 -0
- package/dist/button/index.mjs +1 -0
- package/dist/checkbox/checkbox.d.mts +32 -9
- package/dist/checkbox/checkbox.d.mts.map +1 -1
- package/dist/checkbox/checkbox.mjs +25 -50
- package/dist/checkbox/checkbox.mjs.map +1 -1
- package/dist/checkbox-group/checkbox-group-context.mjs.map +1 -1
- package/dist/checkbox-group/checkbox-group-item.d.mts +20 -5
- package/dist/checkbox-group/checkbox-group-item.d.mts.map +1 -1
- package/dist/checkbox-group/checkbox-group-item.mjs +25 -27
- 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 +3 -6
- package/dist/checkbox-group/checkbox-group-label.mjs.map +1 -1
- package/dist/checkbox-group/checkbox-group-parent.d.mts +22 -5
- package/dist/checkbox-group/checkbox-group-parent.d.mts.map +1 -1
- package/dist/checkbox-group/checkbox-group-parent.mjs +17 -13
- package/dist/checkbox-group/checkbox-group-parent.mjs.map +1 -1
- package/dist/checkbox-group/checkbox-group-root.d.mts +37 -7
- package/dist/checkbox-group/checkbox-group-root.d.mts.map +1 -1
- package/dist/checkbox-group/checkbox-group-root.mjs +102 -102
- 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/collapsible/collapsible-context.mjs +8 -0
- package/dist/collapsible/collapsible-context.mjs.map +1 -0
- package/dist/collapsible/collapsible-panel.d.mts +53 -0
- package/dist/collapsible/collapsible-panel.d.mts.map +1 -0
- package/dist/collapsible/collapsible-panel.mjs +41 -0
- package/dist/collapsible/collapsible-panel.mjs.map +1 -0
- package/dist/collapsible/collapsible-root.d.mts +108 -0
- package/dist/collapsible/collapsible-root.d.mts.map +1 -0
- package/dist/collapsible/collapsible-root.mjs +147 -0
- package/dist/collapsible/collapsible-root.mjs.map +1 -0
- package/dist/collapsible/collapsible-trigger.d.mts +45 -0
- package/dist/collapsible/collapsible-trigger.d.mts.map +1 -0
- package/dist/collapsible/collapsible-trigger.mjs +62 -0
- package/dist/collapsible/collapsible-trigger.mjs.map +1 -0
- package/dist/collapsible/index.d.mts +21 -0
- package/dist/collapsible/index.d.mts.map +1 -0
- package/dist/collapsible/index.mjs +21 -0
- package/dist/collapsible/index.mjs.map +1 -0
- package/dist/combobox/chip-text.mjs +24 -0
- package/dist/combobox/chip-text.mjs.map +1 -0
- package/dist/combobox/combobox-chips.d.mts +159 -0
- package/dist/combobox/combobox-chips.d.mts.map +1 -0
- package/dist/combobox/combobox-chips.mjs +198 -0
- package/dist/combobox/combobox-chips.mjs.map +1 -0
- package/dist/combobox/combobox-clear.d.mts +29 -5
- package/dist/combobox/combobox-clear.d.mts.map +1 -1
- package/dist/combobox/combobox-clear.mjs +17 -8
- package/dist/combobox/combobox-clear.mjs.map +1 -1
- package/dist/combobox/combobox-context.mjs +4 -5
- 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 +14 -3
- package/dist/combobox/combobox-group.mjs.map +1 -1
- package/dist/combobox/combobox-input.d.mts +27 -5
- package/dist/combobox/combobox-input.d.mts.map +1 -1
- package/dist/combobox/combobox-input.mjs +53 -13
- package/dist/combobox/combobox-input.mjs.map +1 -1
- package/dist/combobox/combobox-keyboard.mjs +127 -0
- package/dist/combobox/combobox-keyboard.mjs.map +1 -0
- 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 +15 -1
- package/dist/combobox/combobox-list.d.mts.map +1 -1
- package/dist/combobox/combobox-list.mjs +13 -13
- package/dist/combobox/combobox-list.mjs.map +1 -1
- package/dist/combobox/combobox-option.d.mts +30 -5
- package/dist/combobox/combobox-option.d.mts.map +1 -1
- package/dist/combobox/combobox-option.mjs +9 -5
- package/dist/combobox/combobox-option.mjs.map +1 -1
- package/dist/combobox/combobox-popup.d.mts +24 -3
- package/dist/combobox/combobox-popup.d.mts.map +1 -1
- package/dist/combobox/combobox-popup.mjs +24 -29
- package/dist/combobox/combobox-popup.mjs.map +1 -1
- package/dist/combobox/combobox-root.d.mts +183 -43
- package/dist/combobox/combobox-root.d.mts.map +1 -1
- package/dist/combobox/combobox-root.mjs +476 -270
- package/dist/combobox/combobox-root.mjs.map +1 -1
- package/dist/combobox/combobox-trigger.d.mts +36 -8
- package/dist/combobox/combobox-trigger.d.mts.map +1 -1
- package/dist/combobox/combobox-trigger.mjs +50 -41
- package/dist/combobox/combobox-trigger.mjs.map +1 -1
- package/dist/combobox/index.d.mts +13 -5
- package/dist/combobox/index.d.mts.map +1 -1
- package/dist/combobox/index.mjs +13 -5
- package/dist/combobox/index.mjs.map +1 -1
- package/dist/combobox/use-combobox-form.mjs +53 -0
- package/dist/combobox/use-combobox-form.mjs.map +1 -0
- package/dist/combobox/use-combobox-text.mjs +43 -0
- package/dist/combobox/use-combobox-text.mjs.map +1 -0
- package/dist/csp/csp-provider.d.mts +33 -0
- package/dist/csp/csp-provider.d.mts.map +1 -0
- package/dist/csp/csp-provider.mjs +26 -0
- package/dist/csp/csp-provider.mjs.map +1 -0
- package/dist/csp/index.d.mts +3 -0
- package/dist/csp/index.mjs +3 -0
- package/dist/csp/style-hashes.d.mts +21 -0
- package/dist/csp/style-hashes.d.mts.map +1 -0
- package/dist/csp/style-hashes.mjs +23 -0
- package/dist/csp/style-hashes.mjs.map +1 -0
- package/dist/dialog/dialog-close.d.mts +56 -12
- package/dist/dialog/dialog-close.d.mts.map +1 -1
- package/dist/dialog/dialog-close.mjs +52 -55
- package/dist/dialog/dialog-close.mjs.map +1 -1
- package/dist/dialog/dialog-context.d.mts +2 -0
- package/dist/dialog/dialog-context.mjs +14 -2
- package/dist/dialog/dialog-context.mjs.map +1 -1
- package/dist/dialog/dialog-description.d.mts +14 -1
- package/dist/dialog/dialog-description.d.mts.map +1 -1
- package/dist/dialog/dialog-description.mjs +10 -4
- package/dist/dialog/dialog-description.mjs.map +1 -1
- package/dist/dialog/dialog-dismiss.mjs +108 -0
- package/dist/dialog/dialog-dismiss.mjs.map +1 -0
- package/dist/dialog/dialog-form.d.mts +43 -11
- package/dist/dialog/dialog-form.d.mts.map +1 -1
- package/dist/dialog/dialog-form.mjs +64 -37
- package/dist/dialog/dialog-form.mjs.map +1 -1
- package/dist/dialog/dialog-popup.d.mts +47 -14
- package/dist/dialog/dialog-popup.d.mts.map +1 -1
- package/dist/dialog/dialog-popup.mjs +167 -242
- package/dist/dialog/dialog-popup.mjs.map +1 -1
- package/dist/dialog/dialog-root.d.mts +54 -19
- package/dist/dialog/dialog-root.d.mts.map +1 -1
- package/dist/dialog/dialog-root.mjs +74 -92
- package/dist/dialog/dialog-root.mjs.map +1 -1
- package/dist/dialog/dialog-title.d.mts +13 -1
- package/dist/dialog/dialog-title.d.mts.map +1 -1
- package/dist/dialog/dialog-title.mjs +10 -4
- package/dist/dialog/dialog-title.mjs.map +1 -1
- package/dist/dialog/dialog-trigger.d.mts +30 -6
- package/dist/dialog/dialog-trigger.d.mts.map +1 -1
- package/dist/dialog/dialog-trigger.mjs +50 -28
- package/dist/dialog/dialog-trigger.mjs.map +1 -1
- package/dist/dialog/index.d.mts +7 -3
- package/dist/dialog/index.d.mts.map +1 -1
- package/dist/dialog/index.mjs +7 -3
- package/dist/dialog/index.mjs.map +1 -1
- package/dist/docs/components/accordion.md +428 -0
- package/dist/docs/components/alert-dialog.md +546 -0
- package/dist/docs/components/button.md +511 -0
- package/dist/docs/components/checkbox-group.md +483 -0
- package/dist/docs/components/checkbox.md +373 -0
- package/dist/docs/components/collapsible.md +408 -0
- package/dist/docs/components/combobox.md +960 -0
- package/dist/docs/components/context-menu.md +524 -0
- package/dist/docs/components/dialog.md +694 -0
- package/dist/docs/components/field.md +765 -0
- package/dist/docs/components/hover-card.md +494 -0
- package/dist/docs/components/menu.md +670 -0
- package/dist/docs/components/meter.md +313 -0
- package/dist/docs/components/multi-select.md +622 -0
- package/dist/docs/components/number-field.md +528 -0
- package/dist/docs/components/popover.md +656 -0
- package/dist/docs/components/progress.md +450 -0
- package/dist/docs/components/radio-group.md +457 -0
- package/dist/docs/components/select.md +670 -0
- package/dist/docs/components/separator.md +182 -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 +602 -0
- package/dist/docs/components/toggle-group.md +341 -0
- package/dist/docs/components/toggle.md +245 -0
- package/dist/docs/components/toolbar.md +390 -0
- package/dist/docs/components/tooltip.md +494 -0
- package/dist/docs/concepts/action-props.md +281 -0
- package/dist/docs/concepts/ai-agents.md +56 -0
- package/dist/docs/concepts/browser-owned-state.md +133 -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 +263 -0
- package/dist/docs/concepts/render.md +23 -0
- package/dist/docs/concepts/server-components.md +132 -0
- package/dist/docs/concepts/suspense.md +129 -0
- package/dist/docs/concepts/transitions.md +112 -0
- package/dist/docs/getting-started.md +102 -0
- package/dist/docs/index.md +187 -0
- package/dist/docs/roadmap.md +144 -0
- package/dist/docs/why.md +104 -0
- package/dist/field/field-control.d.mts +65 -0
- package/dist/field/field-control.d.mts.map +1 -0
- package/dist/field/field-control.mjs +92 -0
- package/dist/field/field-control.mjs.map +1 -0
- package/dist/field/field-description.d.mts +35 -0
- package/dist/field/field-description.d.mts.map +1 -0
- package/dist/field/field-description.mjs +35 -0
- package/dist/field/field-description.mjs.map +1 -0
- package/dist/field/field-error.d.mts +42 -0
- package/dist/field/field-error.d.mts.map +1 -0
- package/dist/field/field-error.mjs +43 -0
- package/dist/field/field-error.mjs.map +1 -0
- package/dist/field/field-label.d.mts +39 -0
- package/dist/field/field-label.d.mts.map +1 -0
- package/dist/field/field-label.mjs +50 -0
- package/dist/field/field-label.mjs.map +1 -0
- package/dist/field/field-root.d.mts +72 -0
- package/dist/field/field-root.d.mts.map +1 -0
- package/dist/field/field-root.mjs +309 -0
- package/dist/field/field-root.mjs.map +1 -0
- package/dist/field/index.d.mts +27 -0
- package/dist/field/index.d.mts.map +1 -0
- package/dist/field/index.mjs +26 -0
- package/dist/field/index.mjs.map +1 -0
- package/dist/field/use-server-error-visibility.mjs +44 -0
- package/dist/field/use-server-error-visibility.mjs.map +1 -0
- package/dist/form/form-root.d.mts +74 -0
- package/dist/form/form-root.d.mts.map +1 -0
- package/dist/form/form-root.mjs +158 -0
- package/dist/form/form-root.mjs.map +1 -0
- package/dist/form/form-submit.d.mts +56 -0
- package/dist/form/form-submit.d.mts.map +1 -0
- package/dist/form/form-submit.mjs +53 -0
- package/dist/form/form-submit.mjs.map +1 -0
- package/dist/form/index.d.mts +18 -0
- package/dist/form/index.d.mts.map +1 -0
- package/dist/form/index.mjs +18 -0
- package/dist/form/index.mjs.map +1 -0
- package/dist/hover-card/hover-card-context.mjs +13 -0
- package/dist/hover-card/hover-card-context.mjs.map +1 -0
- package/dist/hover-card/hover-card-popup.d.mts +102 -0
- package/dist/hover-card/hover-card-popup.d.mts.map +1 -0
- package/dist/hover-card/hover-card-popup.mjs +80 -0
- package/dist/hover-card/hover-card-popup.mjs.map +1 -0
- package/dist/hover-card/hover-card-root.d.mts +94 -0
- package/dist/hover-card/hover-card-root.d.mts.map +1 -0
- package/dist/hover-card/hover-card-root.mjs +74 -0
- package/dist/hover-card/hover-card-root.mjs.map +1 -0
- package/dist/hover-card/hover-card-trigger.d.mts +65 -0
- package/dist/hover-card/hover-card-trigger.d.mts.map +1 -0
- package/dist/hover-card/hover-card-trigger.mjs +109 -0
- package/dist/hover-card/hover-card-trigger.mjs.map +1 -0
- package/dist/hover-card/index.d.mts +24 -0
- package/dist/hover-card/index.d.mts.map +1 -0
- package/dist/hover-card/index.mjs +24 -0
- package/dist/hover-card/index.mjs.map +1 -0
- package/dist/hover-card/use-hover-card-interest.mjs +242 -0
- package/dist/hover-card/use-hover-card-interest.mjs.map +1 -0
- package/dist/index.d.mts +100 -13
- package/dist/index.mjs +19 -1
- package/dist/internal/{action-details.mjs → action/action-details.mjs} +1 -1
- package/dist/internal/action/action-details.mjs.map +1 -0
- package/dist/internal/action/call-urgent-handler.mjs +32 -0
- package/dist/internal/action/call-urgent-handler.mjs.map +1 -0
- package/dist/internal/action/report-dropped.mjs +27 -0
- package/dist/internal/action/report-dropped.mjs.map +1 -0
- package/dist/internal/action/use-action-trigger.mjs +67 -0
- package/dist/internal/action/use-action-trigger.mjs.map +1 -0
- package/dist/internal/action/use-connected.mjs +24 -0
- package/dist/internal/action/use-connected.mjs.map +1 -0
- package/dist/internal/action/use-controllable-action.mjs +153 -0
- package/dist/internal/action/use-controllable-action.mjs.map +1 -0
- package/dist/internal/action/use-multiple-selection.mjs +83 -0
- package/dist/internal/action/use-multiple-selection.mjs.map +1 -0
- package/dist/internal/action/use-pure-trigger.mjs +34 -0
- package/dist/internal/action/use-pure-trigger.mjs.map +1 -0
- package/dist/internal/action/use-step-commit.mjs +147 -0
- package/dist/internal/action/use-step-commit.mjs.map +1 -0
- package/dist/internal/announce.mjs +20 -0
- package/dist/internal/announce.mjs.map +1 -0
- package/dist/internal/arrow-keys.mjs +21 -0
- package/dist/internal/arrow-keys.mjs.map +1 -0
- package/dist/internal/csp-context.mjs +8 -0
- package/dist/internal/csp-context.mjs.map +1 -0
- package/dist/internal/decimal.mjs +33 -0
- package/dist/internal/decimal.mjs.map +1 -0
- package/dist/internal/details-summary.mjs +56 -0
- package/dist/internal/details-summary.mjs.map +1 -0
- package/dist/internal/dev-warn.mjs +17 -0
- package/dist/internal/dev-warn.mjs.map +1 -0
- package/dist/internal/dom-order.mjs +17 -0
- package/dist/internal/dom-order.mjs.map +1 -0
- package/dist/internal/form/field-context.d.mts +19 -0
- package/dist/internal/form/field-context.d.mts.map +1 -0
- package/dist/internal/form/field-context.mjs +24 -0
- package/dist/internal/form/field-context.mjs.map +1 -0
- package/dist/internal/form/focus-first-invalid.mjs +67 -0
- package/dist/internal/form/focus-first-invalid.mjs.map +1 -0
- package/dist/internal/form/form-status-watcher.mjs +31 -0
- package/dist/internal/form/form-status-watcher.mjs.map +1 -0
- package/dist/internal/form/group-member.mjs +37 -0
- package/dist/internal/form/group-member.mjs.map +1 -0
- package/dist/internal/form/hidden-values.mjs +29 -0
- package/dist/internal/form/hidden-values.mjs.map +1 -0
- package/dist/internal/{sync-presence.mjs → form/sync-presence.mjs} +6 -2
- package/dist/internal/form/sync-presence.mjs.map +1 -0
- package/dist/internal/form/use-checkable-input.mjs +79 -0
- package/dist/internal/form/use-checkable-input.mjs.map +1 -0
- package/dist/internal/form/use-field-control.mjs +125 -0
- package/dist/internal/form/use-field-control.mjs.map +1 -0
- package/dist/internal/form/use-fieldset-group.mjs +46 -0
- package/dist/internal/form/use-fieldset-group.mjs.map +1 -0
- package/dist/internal/form/use-form-owner-event.mjs +44 -0
- package/dist/internal/form/use-form-owner-event.mjs.map +1 -0
- package/dist/internal/form/use-form-reset.mjs +39 -0
- package/dist/internal/form/use-form-reset.mjs.map +1 -0
- package/dist/internal/{use-native-checked.mjs → form/use-native-checked.mjs} +8 -9
- package/dist/internal/form/use-native-checked.mjs.map +1 -0
- package/dist/internal/{use-native-group-reconciliation.mjs → form/use-native-group-reconciliation.mjs} +15 -12
- package/dist/internal/form/use-native-group-reconciliation.mjs.map +1 -0
- package/dist/internal/{use-native-select-value.mjs → form/use-native-select-value.mjs} +8 -6
- package/dist/internal/form/use-native-select-value.mjs.map +1 -0
- package/dist/internal/form/validity.d.mts +35 -0
- package/dist/internal/form/validity.d.mts.map +1 -0
- package/dist/internal/form/validity.mjs +98 -0
- package/dist/internal/form/validity.mjs.map +1 -0
- package/dist/internal/overlay/anchor-position.d.mts +15 -0
- package/dist/internal/overlay/anchor-position.d.mts.map +1 -0
- package/dist/internal/overlay/anchor-position.mjs +132 -0
- package/dist/internal/overlay/anchor-position.mjs.map +1 -0
- package/dist/internal/overlay/content-focus-probe.mjs +42 -0
- package/dist/internal/overlay/content-focus-probe.mjs.map +1 -0
- package/dist/internal/overlay/css-transition-cut.mjs +66 -0
- package/dist/internal/overlay/css-transition-cut.mjs.map +1 -0
- package/dist/internal/overlay/focus-visible.mjs +26 -0
- package/dist/internal/overlay/focus-visible.mjs.map +1 -0
- package/dist/internal/overlay/invokers.mjs +63 -0
- package/dist/internal/overlay/invokers.mjs.map +1 -0
- package/dist/internal/overlay/modal-registry.mjs +39 -0
- package/dist/internal/overlay/modal-registry.mjs.map +1 -0
- package/dist/internal/overlay/overlay-popup.mjs +103 -0
- package/dist/internal/overlay/overlay-popup.mjs.map +1 -0
- package/dist/internal/overlay/overlay-show.mjs +73 -0
- package/dist/internal/overlay/overlay-show.mjs.map +1 -0
- package/dist/internal/overlay/popover-open.mjs +18 -0
- package/dist/internal/overlay/popover-open.mjs.map +1 -0
- package/dist/internal/overlay/trigger-ref.mjs +26 -0
- package/dist/internal/overlay/trigger-ref.mjs.map +1 -0
- package/dist/internal/overlay/use-apply-open-state.mjs +44 -0
- package/dist/internal/overlay/use-apply-open-state.mjs.map +1 -0
- package/dist/internal/{use-exit-animation.mjs → overlay/use-exit-animation.mjs} +28 -8
- package/dist/internal/overlay/use-exit-animation.mjs.map +1 -0
- package/dist/internal/overlay/use-interest-dismiss.mjs +85 -0
- package/dist/internal/overlay/use-interest-dismiss.mjs.map +1 -0
- package/dist/internal/overlay/use-modal-registration.mjs +47 -0
- package/dist/internal/overlay/use-modal-registration.mjs.map +1 -0
- package/dist/internal/overlay/use-overlay-close.mjs +72 -0
- package/dist/internal/overlay/use-overlay-close.mjs.map +1 -0
- package/dist/internal/overlay/use-overlay-root.d.mts +2 -0
- package/dist/internal/overlay/use-overlay-root.mjs +193 -0
- package/dist/internal/overlay/use-overlay-root.mjs.map +1 -0
- package/dist/internal/overlay/use-popover-popup.mjs +287 -0
- package/dist/internal/overlay/use-popover-popup.mjs.map +1 -0
- package/dist/internal/overlay/use-popover-trigger.d.mts +16 -0
- package/dist/internal/overlay/use-popover-trigger.d.mts.map +1 -0
- package/dist/internal/overlay/use-popover-trigger.mjs +142 -0
- package/dist/internal/overlay/use-popover-trigger.mjs.map +1 -0
- package/dist/internal/overlay/use-resolved-placement.mjs +162 -0
- package/dist/internal/overlay/use-resolved-placement.mjs.map +1 -0
- package/dist/internal/platform-attributes.d.mts +2 -1
- package/dist/internal/platform-attributes.d.mts.map +1 -1
- package/dist/internal/pointer-capture.mjs +20 -0
- package/dist/internal/pointer-capture.mjs.map +1 -0
- package/dist/internal/range-value.mjs +51 -0
- package/dist/internal/range-value.mjs.map +1 -0
- package/dist/internal/render-element.d.mts +2 -0
- package/dist/internal/render-element.mjs +123 -0
- package/dist/internal/render-element.mjs.map +1 -0
- package/dist/internal/shipped-styles.mjs +14 -0
- package/dist/internal/shipped-styles.mjs.map +1 -0
- package/dist/internal/toolbar-context.mjs +17 -0
- package/dist/internal/toolbar-context.mjs.map +1 -0
- package/dist/internal/transition-boundary.mjs +5 -9
- package/dist/internal/transition-boundary.mjs.map +1 -1
- package/dist/internal/typeahead.mjs +52 -0
- package/dist/internal/typeahead.mjs.map +1 -0
- package/dist/internal/types.d.mts +42 -9
- package/dist/internal/types.d.mts.map +1 -1
- package/dist/internal/use-active-option.mjs +51 -0
- package/dist/internal/use-active-option.mjs.map +1 -0
- package/dist/internal/use-deferred-leave.mjs +113 -0
- package/dist/internal/use-deferred-leave.mjs.map +1 -0
- package/dist/internal/use-dev-warning.mjs +8 -4
- package/dist/internal/use-dev-warning.mjs.map +1 -1
- package/dist/internal/use-element-check.mjs +39 -0
- package/dist/internal/use-element-check.mjs.map +1 -0
- package/dist/internal/use-item-order.mjs +42 -0
- package/dist/internal/use-item-order.mjs.map +1 -0
- package/dist/internal/use-latest.mjs +28 -0
- package/dist/internal/use-latest.mjs.map +1 -0
- package/dist/internal/use-merged-refs.mjs +19 -0
- package/dist/internal/use-merged-refs.mjs.map +1 -0
- package/dist/internal/use-mount-fixed.mjs +22 -0
- package/dist/internal/use-mount-fixed.mjs.map +1 -0
- package/dist/internal/use-name-warning.mjs +140 -0
- package/dist/internal/use-name-warning.mjs.map +1 -0
- package/dist/internal/use-native-focusgroup.mjs +19 -0
- package/dist/internal/use-native-focusgroup.mjs.map +1 -0
- package/dist/internal/use-option-registry.mjs +70 -0
- package/dist/internal/use-option-registry.mjs.map +1 -0
- package/dist/internal/use-register-count.mjs +27 -0
- package/dist/internal/use-register-count.mjs.map +1 -0
- package/dist/internal/use-render.d.mts +2 -0
- package/dist/internal/use-render.mjs +12 -35
- package/dist/internal/use-render.mjs.map +1 -1
- package/dist/internal/use-roving-focus.mjs +288 -0
- package/dist/internal/use-roving-focus.mjs.map +1 -0
- package/dist/internal/use-value-set.mjs +20 -0
- package/dist/internal/use-value-set.mjs.map +1 -0
- package/dist/internal/value-set.mjs +41 -0
- package/dist/internal/value-set.mjs.map +1 -0
- package/dist/menu/index.d.mts +8 -2
- package/dist/menu/index.d.mts.map +1 -1
- package/dist/menu/index.mjs +7 -1
- package/dist/menu/index.mjs.map +1 -1
- package/dist/menu/menu-checkbox-item.d.mts +27 -3
- package/dist/menu/menu-checkbox-item.d.mts.map +1 -1
- package/dist/menu/menu-checkbox-item.mjs +6 -3
- package/dist/menu/menu-checkbox-item.mjs.map +1 -1
- package/dist/menu/menu-context-trigger.d.mts +63 -0
- package/dist/menu/menu-context-trigger.d.mts.map +1 -0
- package/dist/menu/menu-context-trigger.mjs +231 -0
- package/dist/menu/menu-context-trigger.mjs.map +1 -0
- package/dist/menu/menu-context.d.mts +1 -1
- package/dist/menu/menu-context.mjs +44 -1
- package/dist/menu/menu-context.mjs.map +1 -1
- package/dist/menu/menu-dom.mjs +35 -4
- package/dist/menu/menu-dom.mjs.map +1 -1
- package/dist/menu/menu-gestures.mjs +166 -0
- package/dist/menu/menu-gestures.mjs.map +1 -0
- package/dist/menu/menu-group.d.mts +36 -1
- package/dist/menu/menu-group.d.mts.map +1 -1
- package/dist/menu/menu-group.mjs +15 -5
- package/dist/menu/menu-group.mjs.map +1 -1
- package/dist/menu/menu-hover.mjs +0 -1
- package/dist/menu/menu-hover.mjs.map +1 -1
- package/dist/menu/menu-item.d.mts +42 -5
- package/dist/menu/menu-item.d.mts.map +1 -1
- package/dist/menu/menu-item.mjs +18 -9
- package/dist/menu/menu-item.mjs.map +1 -1
- package/dist/menu/menu-outside.mjs +101 -0
- package/dist/menu/menu-outside.mjs.map +1 -0
- package/dist/menu/menu-point.mjs +85 -0
- package/dist/menu/menu-point.mjs.map +1 -0
- package/dist/menu/menu-popup.d.mts +68 -11
- package/dist/menu/menu-popup.d.mts.map +1 -1
- package/dist/menu/menu-popup.mjs +106 -116
- 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 +14 -7
- package/dist/menu/menu-radio-group.mjs.map +1 -1
- package/dist/menu/menu-radio-item.d.mts +18 -0
- package/dist/menu/menu-radio-item.d.mts.map +1 -1
- package/dist/menu/menu-radio-item.mjs +5 -1
- package/dist/menu/menu-radio-item.mjs.map +1 -1
- package/dist/menu/menu-root.d.mts +61 -12
- package/dist/menu/menu-root.d.mts.map +1 -1
- package/dist/menu/menu-root.mjs +72 -17
- package/dist/menu/menu-root.mjs.map +1 -1
- package/dist/menu/menu-submenu-trigger.d.mts +24 -9
- package/dist/menu/menu-submenu-trigger.d.mts.map +1 -1
- package/dist/menu/menu-submenu-trigger.mjs +48 -26
- package/dist/menu/menu-submenu-trigger.mjs.map +1 -1
- package/dist/menu/menu-trigger.d.mts +37 -16
- package/dist/menu/menu-trigger.d.mts.map +1 -1
- package/dist/menu/menu-trigger.mjs +39 -23
- package/dist/menu/menu-trigger.mjs.map +1 -1
- package/dist/menu/use-menu-item.mjs +14 -16
- package/dist/menu/use-menu-item.mjs.map +1 -1
- package/dist/menu/use-menu-keyboard.mjs +68 -0
- package/dist/menu/use-menu-keyboard.mjs.map +1 -0
- package/dist/meter/index.d.mts +26 -0
- package/dist/meter/index.d.mts.map +1 -0
- package/dist/meter/index.mjs +25 -0
- package/dist/meter/index.mjs.map +1 -0
- package/dist/meter/meter-context.mjs +13 -0
- package/dist/meter/meter-context.mjs.map +1 -0
- package/dist/meter/meter-indicator.d.mts +30 -0
- package/dist/meter/meter-indicator.d.mts.map +1 -0
- package/dist/meter/meter-indicator.mjs +27 -0
- package/dist/meter/meter-indicator.mjs.map +1 -0
- package/dist/meter/meter-label.d.mts +30 -0
- package/dist/meter/meter-label.d.mts.map +1 -0
- package/dist/meter/meter-label.mjs +30 -0
- package/dist/meter/meter-label.mjs.map +1 -0
- package/dist/meter/meter-region.d.mts +9 -0
- package/dist/meter/meter-region.d.mts.map +1 -0
- package/dist/meter/meter-region.mjs +39 -0
- package/dist/meter/meter-region.mjs.map +1 -0
- package/dist/meter/meter-root.d.mts +113 -0
- package/dist/meter/meter-root.d.mts.map +1 -0
- package/dist/meter/meter-root.mjs +85 -0
- package/dist/meter/meter-root.mjs.map +1 -0
- package/dist/meter/meter-track.d.mts +30 -0
- package/dist/meter/meter-track.d.mts.map +1 -0
- package/dist/meter/meter-track.mjs +27 -0
- package/dist/meter/meter-track.mjs.map +1 -0
- package/dist/meter/meter-value.d.mts +34 -0
- package/dist/meter/meter-value.d.mts.map +1 -0
- package/dist/meter/meter-value.mjs +31 -0
- package/dist/meter/meter-value.mjs.map +1 -0
- package/dist/multi-select/index.d.mts +37 -0
- package/dist/multi-select/index.d.mts.map +1 -0
- package/dist/multi-select/index.mjs +37 -0
- package/dist/multi-select/index.mjs.map +1 -0
- package/dist/multi-select/multi-select-context.mjs +19 -0
- package/dist/multi-select/multi-select-context.mjs.map +1 -0
- package/dist/multi-select/multi-select-group.d.mts +120 -0
- package/dist/multi-select/multi-select-group.d.mts.map +1 -0
- package/dist/multi-select/multi-select-group.mjs +111 -0
- package/dist/multi-select/multi-select-group.mjs.map +1 -0
- package/dist/multi-select/multi-select-keyboard.mjs +145 -0
- package/dist/multi-select/multi-select-keyboard.mjs.map +1 -0
- package/dist/multi-select/multi-select-label.d.mts +42 -0
- package/dist/multi-select/multi-select-label.d.mts.map +1 -0
- package/dist/multi-select/multi-select-label.mjs +41 -0
- package/dist/multi-select/multi-select-label.mjs.map +1 -0
- package/dist/multi-select/multi-select-list.d.mts +47 -0
- package/dist/multi-select/multi-select-list.d.mts.map +1 -0
- package/dist/multi-select/multi-select-list.mjs +65 -0
- package/dist/multi-select/multi-select-list.mjs.map +1 -0
- package/dist/multi-select/multi-select-option.d.mts +68 -0
- package/dist/multi-select/multi-select-option.d.mts.map +1 -0
- package/dist/multi-select/multi-select-option.mjs +93 -0
- package/dist/multi-select/multi-select-option.mjs.map +1 -0
- package/dist/multi-select/multi-select-popup.d.mts +58 -0
- package/dist/multi-select/multi-select-popup.d.mts.map +1 -0
- package/dist/multi-select/multi-select-popup.mjs +71 -0
- package/dist/multi-select/multi-select-popup.mjs.map +1 -0
- package/dist/multi-select/multi-select-root.d.mts +125 -0
- package/dist/multi-select/multi-select-root.d.mts.map +1 -0
- package/dist/multi-select/multi-select-root.mjs +257 -0
- package/dist/multi-select/multi-select-root.mjs.map +1 -0
- package/dist/multi-select/multi-select-trigger.d.mts +66 -0
- package/dist/multi-select/multi-select-trigger.d.mts.map +1 -0
- package/dist/multi-select/multi-select-trigger.mjs +169 -0
- package/dist/multi-select/multi-select-trigger.mjs.map +1 -0
- package/dist/multi-select/multi-select-value.d.mts +57 -0
- package/dist/multi-select/multi-select-value.d.mts.map +1 -0
- package/dist/multi-select/multi-select-value.mjs +41 -0
- package/dist/multi-select/multi-select-value.mjs.map +1 -0
- package/dist/number-field/index.d.mts +29 -0
- package/dist/number-field/index.d.mts.map +1 -0
- package/dist/number-field/index.mjs +28 -0
- package/dist/number-field/index.mjs.map +1 -0
- package/dist/number-field/number-field-arithmetic.mjs +97 -0
- package/dist/number-field/number-field-arithmetic.mjs.map +1 -0
- package/dist/number-field/number-field-context.d.mts +7 -0
- package/dist/number-field/number-field-context.d.mts.map +1 -0
- package/dist/number-field/number-field-context.mjs +13 -0
- package/dist/number-field/number-field-context.mjs.map +1 -0
- package/dist/number-field/number-field-decrement.d.mts +19 -0
- package/dist/number-field/number-field-decrement.d.mts.map +1 -0
- package/dist/number-field/number-field-decrement.mjs +22 -0
- package/dist/number-field/number-field-decrement.mjs.map +1 -0
- package/dist/number-field/number-field-format.mjs +279 -0
- package/dist/number-field/number-field-format.mjs.map +1 -0
- package/dist/number-field/number-field-increment.d.mts +19 -0
- package/dist/number-field/number-field-increment.d.mts.map +1 -0
- package/dist/number-field/number-field-increment.mjs +22 -0
- package/dist/number-field/number-field-increment.mjs.map +1 -0
- package/dist/number-field/number-field-input.d.mts +38 -0
- package/dist/number-field/number-field-input.d.mts.map +1 -0
- package/dist/number-field/number-field-input.mjs +161 -0
- package/dist/number-field/number-field-input.mjs.map +1 -0
- package/dist/number-field/number-field-label.d.mts +33 -0
- package/dist/number-field/number-field-label.d.mts.map +1 -0
- package/dist/number-field/number-field-label.mjs +43 -0
- package/dist/number-field/number-field-label.mjs.map +1 -0
- package/dist/number-field/number-field-root.d.mts +157 -0
- package/dist/number-field/number-field-root.d.mts.map +1 -0
- package/dist/number-field/number-field-root.mjs +445 -0
- package/dist/number-field/number-field-root.mjs.map +1 -0
- package/dist/number-field/use-number-field-dev-warnings.mjs +28 -0
- package/dist/number-field/use-number-field-dev-warnings.mjs.map +1 -0
- package/dist/number-field/use-step-button.d.mts +44 -0
- package/dist/number-field/use-step-button.d.mts.map +1 -0
- package/dist/number-field/use-step-button.mjs +175 -0
- package/dist/number-field/use-step-button.mjs.map +1 -0
- package/dist/popover/index.d.mts +6 -4
- package/dist/popover/index.d.mts.map +1 -1
- package/dist/popover/index.mjs +6 -4
- package/dist/popover/index.mjs.map +1 -1
- package/dist/popover/popover-close.d.mts +48 -8
- package/dist/popover/popover-close.d.mts.map +1 -1
- package/dist/popover/popover-close.mjs +41 -67
- package/dist/popover/popover-close.mjs.map +1 -1
- package/dist/popover/popover-context.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 +64 -18
- package/dist/popover/popover-popup.d.mts.map +1 -1
- package/dist/popover/popover-popup.mjs +31 -36
- package/dist/popover/popover-popup.mjs.map +1 -1
- package/dist/popover/popover-root.d.mts +40 -18
- package/dist/popover/popover-root.d.mts.map +1 -1
- package/dist/popover/popover-root.mjs +15 -10
- 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 +38 -18
- package/dist/popover/popover-trigger.d.mts.map +1 -1
- package/dist/popover/popover-trigger.mjs +14 -9
- package/dist/popover/popover-trigger.mjs.map +1 -1
- package/dist/progress/index.d.mts +26 -0
- package/dist/progress/index.d.mts.map +1 -0
- package/dist/progress/index.mjs +26 -0
- package/dist/progress/index.mjs.map +1 -0
- package/dist/progress/progress-context.mjs +13 -0
- package/dist/progress/progress-context.mjs.map +1 -0
- package/dist/progress/progress-indicator.d.mts +30 -0
- package/dist/progress/progress-indicator.d.mts.map +1 -0
- package/dist/progress/progress-indicator.mjs +31 -0
- package/dist/progress/progress-indicator.mjs.map +1 -0
- package/dist/progress/progress-label.d.mts +30 -0
- package/dist/progress/progress-label.d.mts.map +1 -0
- package/dist/progress/progress-label.mjs +32 -0
- package/dist/progress/progress-label.mjs.map +1 -0
- package/dist/progress/progress-root.d.mts +96 -0
- package/dist/progress/progress-root.d.mts.map +1 -0
- package/dist/progress/progress-root.mjs +82 -0
- package/dist/progress/progress-root.mjs.map +1 -0
- package/dist/progress/progress-track.d.mts +30 -0
- package/dist/progress/progress-track.d.mts.map +1 -0
- package/dist/progress/progress-track.mjs +31 -0
- package/dist/progress/progress-track.mjs.map +1 -0
- package/dist/progress/progress-value.d.mts +34 -0
- package/dist/progress/progress-value.d.mts.map +1 -0
- package/dist/progress/progress-value.mjs +35 -0
- package/dist/progress/progress-value.mjs.map +1 -0
- 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-context.mjs.map +1 -1
- package/dist/radio-group/radio-group-item.d.mts +21 -5
- package/dist/radio-group/radio-group-item.d.mts.map +1 -1
- package/dist/radio-group/radio-group-item.mjs +22 -25
- 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 +3 -6
- package/dist/radio-group/radio-group-label.mjs.map +1 -1
- package/dist/radio-group/radio-group-root.d.mts +34 -8
- package/dist/radio-group/radio-group-root.d.mts.map +1 -1
- package/dist/radio-group/radio-group-root.mjs +48 -39
- 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-dom.mjs +9 -18
- package/dist/select/select-dom.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 +5 -1
- 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 +8 -4
- 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 +4 -2
- package/dist/select/select-option.mjs.map +1 -1
- package/dist/select/select-root.d.mts +28 -3
- package/dist/select/select-root.d.mts.map +1 -1
- package/dist/select/select-root.mjs +39 -12
- 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 +5 -1
- 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 +5 -6
- package/dist/select/select-value.mjs.map +1 -1
- package/dist/separator/index.d.mts +3 -0
- package/dist/separator/index.mjs +1 -0
- package/dist/separator/separator.d.mts +58 -0
- package/dist/separator/separator.d.mts.map +1 -0
- package/dist/separator/separator.mjs +41 -0
- package/dist/separator/separator.mjs.map +1 -0
- package/dist/slider/index.d.mts +34 -0
- package/dist/slider/index.d.mts.map +1 -0
- package/dist/slider/index.mjs +29 -0
- package/dist/slider/index.mjs.map +1 -0
- package/dist/slider/slider-arithmetic.mjs +165 -0
- package/dist/slider/slider-arithmetic.mjs.map +1 -0
- package/dist/slider/slider-context.mjs +13 -0
- package/dist/slider/slider-context.mjs.map +1 -0
- package/dist/slider/slider-indicator.d.mts +34 -0
- package/dist/slider/slider-indicator.d.mts.map +1 -0
- package/dist/slider/slider-indicator.mjs +38 -0
- package/dist/slider/slider-indicator.mjs.map +1 -0
- package/dist/slider/slider-label.d.mts +33 -0
- package/dist/slider/slider-label.d.mts.map +1 -0
- package/dist/slider/slider-label.mjs +40 -0
- package/dist/slider/slider-label.mjs.map +1 -0
- package/dist/slider/slider-root.d.mts +155 -0
- package/dist/slider/slider-root.d.mts.map +1 -0
- package/dist/slider/slider-root.mjs +434 -0
- package/dist/slider/slider-root.mjs.map +1 -0
- package/dist/slider/slider-thumb.d.mts +87 -0
- package/dist/slider/slider-thumb.d.mts.map +1 -0
- package/dist/slider/slider-thumb.mjs +150 -0
- package/dist/slider/slider-thumb.mjs.map +1 -0
- package/dist/slider/slider-track.d.mts +46 -0
- package/dist/slider/slider-track.d.mts.map +1 -0
- package/dist/slider/slider-track.mjs +57 -0
- package/dist/slider/slider-track.mjs.map +1 -0
- package/dist/slider/slider-value.d.mts +45 -0
- package/dist/slider/slider-value.d.mts.map +1 -0
- package/dist/slider/slider-value.mjs +41 -0
- package/dist/slider/slider-value.mjs.map +1 -0
- package/dist/slider/use-slider-dev-warnings.mjs +29 -0
- package/dist/slider/use-slider-dev-warnings.mjs.map +1 -0
- package/dist/slider/use-thumb-registry.mjs +51 -0
- package/dist/slider/use-thumb-registry.mjs.map +1 -0
- package/dist/switch/switch.d.mts +30 -9
- package/dist/switch/switch.d.mts.map +1 -1
- package/dist/switch/switch.mjs +24 -46
- 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 +7 -3
- 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 +4 -1
- 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 +12 -23
- package/dist/tabs/tabs-list.mjs.map +1 -1
- package/dist/tabs/tabs-panel.d.mts +22 -4
- package/dist/tabs/tabs-panel.d.mts.map +1 -1
- package/dist/tabs/tabs-panel.mjs +4 -2
- package/dist/tabs/tabs-panel.mjs.map +1 -1
- package/dist/tabs/tabs-root.d.mts +43 -8
- package/dist/tabs/tabs-root.d.mts.map +1 -1
- package/dist/tabs/tabs-root.mjs +23 -10
- package/dist/tabs/tabs-root.mjs.map +1 -1
- package/dist/tabs/tabs-tab.d.mts +25 -5
- package/dist/tabs/tabs-tab.d.mts.map +1 -1
- package/dist/tabs/tabs-tab.mjs +5 -2
- package/dist/tabs/tabs-tab.mjs.map +1 -1
- package/dist/{internal → tabs}/use-until-found.mjs +1 -1
- package/dist/tabs/use-until-found.mjs.map +1 -0
- package/dist/toast/index.d.mts +27 -0
- package/dist/toast/index.d.mts.map +1 -0
- package/dist/toast/index.mjs +28 -0
- package/dist/toast/index.mjs.map +1 -0
- package/dist/toast/toast-action.d.mts +86 -0
- package/dist/toast/toast-action.d.mts.map +1 -0
- package/dist/toast/toast-action.mjs +81 -0
- package/dist/toast/toast-action.mjs.map +1 -0
- package/dist/toast/toast-close.d.mts +52 -0
- package/dist/toast/toast-close.d.mts.map +1 -0
- package/dist/toast/toast-close.mjs +53 -0
- package/dist/toast/toast-close.mjs.map +1 -0
- package/dist/toast/toast-context.mjs +19 -0
- package/dist/toast/toast-context.mjs.map +1 -0
- package/dist/toast/toast-description.d.mts +39 -0
- package/dist/toast/toast-description.d.mts.map +1 -0
- package/dist/toast/toast-description.mjs +37 -0
- package/dist/toast/toast-description.mjs.map +1 -0
- package/dist/toast/toast-hotkey.mjs +27 -0
- package/dist/toast/toast-hotkey.mjs.map +1 -0
- package/dist/toast/toast-queue.mjs +137 -0
- package/dist/toast/toast-queue.mjs.map +1 -0
- package/dist/toast/toast-root.d.mts +63 -0
- package/dist/toast/toast-root.d.mts.map +1 -0
- package/dist/toast/toast-root.mjs +209 -0
- package/dist/toast/toast-root.mjs.map +1 -0
- package/dist/toast/toast-timers.mjs +65 -0
- package/dist/toast/toast-timers.mjs.map +1 -0
- package/dist/toast/toast-title.d.mts +38 -0
- package/dist/toast/toast-title.d.mts.map +1 -0
- package/dist/toast/toast-title.mjs +35 -0
- package/dist/toast/toast-title.mjs.map +1 -0
- package/dist/toast/toast-viewport.d.mts +81 -0
- package/dist/toast/toast-viewport.d.mts.map +1 -0
- package/dist/toast/toast-viewport.mjs +345 -0
- package/dist/toast/toast-viewport.mjs.map +1 -0
- package/dist/toast/toast.d.mts +162 -0
- package/dist/toast/toast.d.mts.map +1 -0
- package/dist/toast/toast.mjs +161 -0
- package/dist/toast/toast.mjs.map +1 -0
- package/dist/toast/use-modal-portal-host.mjs +52 -0
- package/dist/toast/use-modal-portal-host.mjs.map +1 -0
- package/dist/toast/use-toast-announcements.mjs +46 -0
- package/dist/toast/use-toast-announcements.mjs.map +1 -0
- package/dist/toast/use-toast-focus.mjs +75 -0
- package/dist/toast/use-toast-focus.mjs.map +1 -0
- package/dist/toast/use-toast-pauses.mjs +58 -0
- package/dist/toast/use-toast-pauses.mjs.map +1 -0
- package/dist/toggle/toggle.d.mts +26 -6
- package/dist/toggle/toggle.d.mts.map +1 -1
- package/dist/toggle/toggle.mjs +12 -6
- package/dist/toggle/toggle.mjs.map +1 -1
- package/dist/toggle-group/index.d.mts +18 -0
- package/dist/toggle-group/index.d.mts.map +1 -0
- package/dist/toggle-group/index.mjs +17 -0
- package/dist/toggle-group/index.mjs.map +1 -0
- package/dist/toggle-group/toggle-group-context.d.mts +6 -0
- package/dist/toggle-group/toggle-group-context.d.mts.map +1 -0
- package/dist/toggle-group/toggle-group-context.mjs +13 -0
- package/dist/toggle-group/toggle-group-context.mjs.map +1 -0
- package/dist/toggle-group/toggle-group-item.d.mts +71 -0
- package/dist/toggle-group/toggle-group-item.d.mts.map +1 -0
- package/dist/toggle-group/toggle-group-item.mjs +69 -0
- package/dist/toggle-group/toggle-group-item.mjs.map +1 -0
- package/dist/toggle-group/toggle-group-root.d.mts +156 -0
- package/dist/toggle-group/toggle-group-root.d.mts.map +1 -0
- package/dist/toggle-group/toggle-group-root.mjs +177 -0
- package/dist/toggle-group/toggle-group-root.mjs.map +1 -0
- package/dist/toolbar/index.d.mts +19 -0
- package/dist/toolbar/index.d.mts.map +1 -0
- package/dist/toolbar/index.mjs +19 -0
- package/dist/toolbar/index.mjs.map +1 -0
- package/dist/toolbar/toolbar-root.d.mts +65 -0
- package/dist/toolbar/toolbar-root.d.mts.map +1 -0
- package/dist/toolbar/toolbar-root.mjs +67 -0
- package/dist/toolbar/toolbar-root.mjs.map +1 -0
- package/dist/toolbar/toolbar-separator.d.mts +38 -0
- package/dist/toolbar/toolbar-separator.d.mts.map +1 -0
- package/dist/toolbar/toolbar-separator.mjs +33 -0
- package/dist/toolbar/toolbar-separator.mjs.map +1 -0
- package/dist/tooltip/index.d.mts +10 -5
- package/dist/tooltip/index.d.mts.map +1 -1
- package/dist/tooltip/index.mjs +8 -3
- package/dist/tooltip/index.mjs.map +1 -1
- package/dist/tooltip/tooltip-arrow.d.mts +46 -0
- package/dist/tooltip/tooltip-arrow.d.mts.map +1 -0
- package/dist/tooltip/tooltip-arrow.mjs +47 -0
- package/dist/tooltip/tooltip-arrow.mjs.map +1 -0
- package/dist/tooltip/tooltip-context.d.mts +11 -0
- package/dist/tooltip/tooltip-context.d.mts.map +1 -1
- package/dist/tooltip/tooltip-context.mjs +2 -1
- package/dist/tooltip/tooltip-context.mjs.map +1 -1
- package/dist/tooltip/tooltip-popup.d.mts +49 -7
- package/dist/tooltip/tooltip-popup.d.mts.map +1 -1
- package/dist/tooltip/tooltip-popup.mjs +37 -15
- 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 +29 -6
- package/dist/tooltip/tooltip-root.mjs.map +1 -1
- package/dist/tooltip/tooltip-trigger.d.mts +28 -3
- package/dist/tooltip/tooltip-trigger.d.mts.map +1 -1
- package/dist/tooltip/tooltip-trigger.mjs +26 -6
- package/dist/tooltip/tooltip-trigger.mjs.map +1 -1
- package/dist/tooltip/tooltip-warm.mjs +29 -0
- package/dist/tooltip/tooltip-warm.mjs.map +1 -0
- package/dist/tooltip/use-tooltip-interaction.mjs +128 -77
- package/dist/tooltip/use-tooltip-interaction.mjs.map +1 -1
- package/package.json +27 -2
- package/skills/funstack-ui-knowledge/SKILL.md +80 -0
- package/dist/accordion/accordion-context.d.mts +0 -5
- package/dist/accordion/accordion-context.d.mts.map +0 -1
- package/dist/internal/action-details.mjs.map +0 -1
- package/dist/internal/anchor-position.d.mts +0 -7
- package/dist/internal/anchor-position.d.mts.map +0 -1
- package/dist/internal/anchor-position.mjs +0 -16
- package/dist/internal/anchor-position.mjs.map +0 -1
- package/dist/internal/sync-presence.mjs.map +0 -1
- package/dist/internal/use-action-trigger.mjs +0 -58
- package/dist/internal/use-action-trigger.mjs.map +0 -1
- package/dist/internal/use-controllable-action.mjs +0 -119
- package/dist/internal/use-controllable-action.mjs.map +0 -1
- package/dist/internal/use-exit-animation.mjs.map +0 -1
- package/dist/internal/use-form-reset.mjs +0 -54
- package/dist/internal/use-form-reset.mjs.map +0 -1
- package/dist/internal/use-native-checked.mjs.map +0 -1
- package/dist/internal/use-native-group-reconciliation.mjs.map +0 -1
- package/dist/internal/use-native-select-value.mjs.map +0 -1
- package/dist/internal/use-popover-popup.mjs +0 -274
- package/dist/internal/use-popover-popup.mjs.map +0 -1
- package/dist/internal/use-popover-root.d.mts +0 -2
- package/dist/internal/use-popover-root.mjs +0 -112
- package/dist/internal/use-popover-root.mjs.map +0 -1
- package/dist/internal/use-popover-trigger.mjs +0 -86
- package/dist/internal/use-popover-trigger.mjs.map +0 -1
- package/dist/internal/use-until-found.mjs.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dialog-popup.mjs","names":[],"sources":["../../src/dialog/dialog-popup.tsx"],"sourcesContent":["\"use client\";\nimport {\n Activity,\n startTransition,\n useCallback,\n useEffect,\n useEffectEvent,\n useLayoutEffect,\n useRef,\n useState,\n} from \"react\";\nimport type {\n ComponentPropsWithRef,\n CSSProperties,\n ReactNode,\n RefObject,\n ViewTransitionClass,\n} from \"react\";\nimport { useTransitionBoundary } from \"../internal/transition-boundary.js\";\nimport { dataAttr } from \"../internal/data-attr.js\";\nimport type { RenderProp, StateValue } from \"../internal/types.js\";\nimport { useDevWarning } from \"../internal/use-dev-warning.js\";\nimport { resolveStateValue, useRender } from \"../internal/use-render.js\";\nimport type { DataAttributes } from \"../internal/use-render.js\";\nimport { useDialogContext } from \"./dialog-context.js\";\n\nexport interface DialogPopupState {\n /** Committed open state (library mode); `false` in JS-free mode. Read `:open` for the DOM truth. */\n readonly open: boolean;\n readonly modal: boolean;\n}\n\nexport interface DialogPopupProps extends Omit<\n ComponentPropsWithRef<\"dialog\">,\n \"id\" | \"open\" | \"closedby\" | \"onToggle\" | \"onBeforeToggle\" | \"className\" | \"style\" | \"children\"\n> {\n /**\n * Library mode: what happens to the children while the dialog is closed.\n * - `false` (default): not rendered. Mounting them is part of the opening transition, so\n * content that suspends holds the open until it is ready. Unmount waits for the dialog's\n * exit animations.\n * - `true`: rendered inside `<Activity mode=\"hidden\">`: DOM and state preserved, effects\n * stopped, pre-rendered at low priority. Not in the server HTML.\n *\n * Ignored in JS-free mode (always mounted).\n */\n keepMounted?: boolean;\n /**\n * Element to focus when the dialog opens: a ref, or a selector resolved inside the dialog.\n * The library writes `autofocus` on it right before `showModal()` / `show()` and the platform\n * focuses it. Default: the platform's choice (first focusable descendant; the dialog itself if\n * none). Use `tabIndex={-1}` on a heading or wrapper for long or destructive dialogs (APG).\n *\n * In JS-free mode the browser opens the dialog itself, so the attribute is written after\n * hydration and kept while mounted; before hydration only `autoFocus` in the markup works.\n */\n initialFocus?: RefObject<HTMLElement | null> | string;\n /**\n * Close on a click outside the dialog (on the backdrop for modal dialogs). Default `false`.\n * Baseline: JS `pointerdown` + `click` listeners, which close only when both the press and the\n * click land outside (a drag that starts inside, such as selecting text, never closes); with\n * `experimental_closedBy`, native `closedby=\"any\"`, which behaves the same.\n */\n lightDismiss?: boolean;\n /**\n * Experimental (Chrome 134+, Firefox 141+; Safari 27.0 ignores it). Renders `closedby`\n * (`\"any\"` when `lightDismiss`, else `\"closerequest\"`) and skips the JS dismiss listeners where\n * `HTMLDialogElement.prototype.closedBy` exists. Elsewhere the JS baseline stays active.\n * Default `false`.\n */\n experimental_closedBy?: boolean;\n /**\n * Library mode only. Forwarded to the `<ViewTransition default>` around the dialog. Animates\n * the opening commit and content changes while open; the close is the browser's and animates\n * with CSS. Ignored (dev warning) in JS-free mode.\n *\n * Static: without `transition` the part renders no `<ViewTransition>`; changing it between\n * `undefined` and a value remounts the element. Any value, `\"none\"` included, makes a mount or\n * `<Activity>` reveal of this part inside a transition start a document view transition: the\n * page cross-fades for about 250 ms and the next transition commit waits for it (issue #35).\n */\n transition?: ViewTransitionClass;\n className?: StateValue<string | undefined, DialogPopupState>;\n style?: StateValue<CSSProperties | undefined, DialogPopupState>;\n children?: StateValue<ReactNode, DialogPopupState>;\n /** Must render a `<dialog>`. */\n render?: RenderProp<ComponentPropsWithRef<\"dialog\">, DialogPopupState>;\n}\n\nconst isDev = process.env.NODE_ENV !== \"production\";\n\n/** Resolves `initialFocus` against the dialog (a ref, or a selector inside the dialog). */\nfunction resolveInitialFocus(\n dialog: HTMLDialogElement,\n initialFocus: RefObject<HTMLElement | null> | string,\n): HTMLElement | null {\n if (typeof initialFocus === \"string\") return dialog.querySelector<HTMLElement>(initialFocus);\n return initialFocus.current;\n}\n\n/** The nearest `<dialog>` around a node (the dialog itself counts). */\nfunction closestDialog(target: EventTarget | null): Element | null {\n return target instanceof Element ? target.closest(\"dialog\") : null;\n}\n\n/**\n * An open popover that takes Escape before the dialog: `auto` or `hint` (they have a close\n * watcher). A `manual` popover, or `hint` where the engine maps it to `manual`, does not.\n */\nfunction isOpenLightPopover(element: Element): boolean {\n if (!element.hasAttribute(\"popover\")) return false;\n // The IDL attribute reflects the state the engine applies; jsdom has none.\n const reflected: unknown = (element as HTMLElement).popover;\n const state =\n typeof reflected === \"string\" ? reflected : element.getAttribute(\"popover\")!.toLowerCase();\n if (state === \"manual\") return false;\n try {\n return element.matches(\":popover-open\");\n } catch {\n return false;\n }\n}\n\n/**\n * Whether Escape belongs to a layer inside `dialog` that sits above it (design 9: \"closes the\n * innermost one only\"): the target is inside an open nested `<dialog>` or popover, or an open\n * `auto` / `hint` popover inside the dialog would take the close request (close watchers are\n * per document, not per focus).\n */\nfunction escapeBelongsToInnerLayer(dialog: HTMLDialogElement, target: EventTarget | null): boolean {\n for (\n let node = target instanceof Element ? target : null;\n node !== null && node !== dialog;\n node = node.parentElement\n ) {\n if (node instanceof HTMLDialogElement && node.open) return true;\n if (isOpenLightPopover(node)) return true;\n }\n for (const element of dialog.querySelectorAll(\"[popover]\")) {\n if (isOpenLightPopover(element)) return true;\n }\n return false;\n}\n\n/** Whether a pointer event on the dialog itself lies outside its border box (the `::backdrop`). */\nfunction onBackdrop(dialog: HTMLDialogElement, event: Event): boolean {\n if (event.target !== dialog) return false;\n const { clientX, clientY } = event as MouseEvent;\n const rect = dialog.getBoundingClientRect();\n return !(\n rect.top <= clientY &&\n clientY <= rect.bottom &&\n rect.left <= clientX &&\n clientX <= rect.right\n );\n}\n\n/** An animation that ends: infinite ones (a spinner) would hold the content forever. */\nfunction ends(animation: Animation): boolean {\n const end = animation.effect?.getComputedTiming().endTime;\n return typeof end === \"number\" && Number.isFinite(end);\n}\n\n/**\n * The dialog itself: a `<dialog>` with the id the Trigger's `commandfor` names, wired to Title\n * and Description through `aria-labelledby` / `aria-describedby`. Never renders `open`: modal\n * opening and closing go through `showModal()` / `close()` only. Style it with `:open` and\n * `:modal`; it emits `data-modal` but no `data-open`.\n *\n * In library mode the children render from committed state, so content that suspends keeps the\n * dialog closed (and the Trigger pending) until it is ready; `showModal()` runs in the layout\n * effect of the commit that mounted them. Closing is the browser's: the native `close` event\n * becomes `openChangeAction(false, { reason, returnValue })`.\n *\n * Owned keys (conventions 1.2): `id`, `open`, `closedby`, `aria-labelledby` and\n * `aria-describedby` (token-merged), `data-modal`, `suppressHydrationWarning`.\n */\nexport function DialogPopup({\n keepMounted,\n initialFocus,\n lightDismiss = false,\n experimental_closedBy = false,\n transition,\n className,\n style,\n children,\n render,\n ...rest\n}: DialogPopupProps) {\n const ctx = useDialogContext(\"Dialog.Popup\");\n const isLibrary = ctx.mode === \"library\";\n const { modal, ids, dialogRef, triggerRef } = ctx;\n const [dialog, setDialog] = useState<HTMLDialogElement | null>(null);\n // Children stay mounted while the dialog's exit animation runs (design 4.4).\n const [exiting, setExiting] = useState(false);\n const exitGeneration = useRef(0);\n // Set by the synchronous `beforetoggle` of a close, cleared by the `close` event a task later:\n // the dialog is closed but its notification is not dispatched yet, so the apply effect must\n // not re-open it from a commit that lands in between.\n const awaitingClose = useRef(false);\n const warnedFocus = useRef(false);\n\n useDevWarning(\n !isLibrary && transition !== undefined,\n \"Dialog.Popup: `transition` has no effect in JS-free mode; the browser opens and closes the \" +\n \"dialog outside any React transition. Animate it with CSS (`@starting-style`).\",\n );\n useDevWarning(\n !isLibrary && keepMounted === false,\n \"Dialog.Popup: `keepMounted={false}` cannot be honoured in JS-free mode; the content is \" +\n \"always mounted so that the server HTML is complete.\",\n );\n\n const libraryRef = useCallback(\n (element: HTMLDialogElement) => {\n if (isDev && element.tagName !== \"DIALOG\") {\n console.error(\n `Dialog.Popup: expected to render a <dialog> element but got <${element.tagName.toLowerCase()}>. ` +\n \"Top layer, backdrop, focus and Escape all come from a real <dialog>.\",\n );\n }\n dialogRef.current = element;\n setDialog(element);\n return () => {\n if (dialogRef.current === element) dialogRef.current = null;\n setDialog(null);\n };\n },\n [dialogRef],\n );\n\n // --- Opening -----------------------------------------------------------------------------\n\n const openDialog = (element: HTMLDialogElement): void => {\n let target: HTMLElement | null = null;\n if (initialFocus !== undefined) {\n target = resolveInitialFocus(element, initialFocus);\n if (target === null || !element.contains(target)) {\n if (isDev && !warnedFocus.current) {\n warnedFocus.current = true;\n console.error(\n target === null\n ? \"Dialog.Popup: `initialFocus` resolved to no element; the platform picks the focus target.\"\n : \"Dialog.Popup: `initialFocus` is outside the dialog; the platform picks the focus target.\",\n );\n }\n target = null;\n }\n }\n // The platform's dialog focusing steps honour `autofocus`; React drops `autoFocus` on\n // client-rendered content (react/react#23301). Never `.focus()` (design 6.1).\n const added = target !== null && !target.hasAttribute(\"autofocus\");\n if (added) target!.setAttribute(\"autofocus\", \"\");\n try {\n if (modal) element.showModal();\n else element.show();\n } finally {\n if (added) target!.removeAttribute(\"autofocus\");\n }\n };\n\n // Mount reconciliation (design 2.4): a click before hydration opened the dialog natively.\n // Runs before the apply effect; the dispatch makes the apply effect wait for it.\n const reconcileOnMount = useEffectEvent(() => {\n const element = dialogRef.current;\n if (element === null || !element.open) return;\n ctx.requestOpen(undefined, \"platform\");\n });\n useLayoutEffect(() => {\n if (isLibrary) reconcileOnMount();\n }, [isLibrary]);\n\n // The apply effect (design 2.5): after every commit, once nothing is in flight, the DOM\n // follows committed state. Opens on the user's dispatch, `defaultOpen`, a controlled parent,\n // the re-open of a refused or failed close; closes after a controlled close or a refused\n // pre-hydration open.\n useLayoutEffect(() => {\n if (!isLibrary) return;\n const element = dialogRef.current;\n if (element === null || !element.isConnected) return;\n if (ctx.pending || ctx.latestInFlight() !== null) return;\n if (ctx.committed && !element.open) {\n if (awaitingClose.current) return;\n openDialog(element);\n } else if (!ctx.committed && element.open) {\n // An echo: the `close` listener finds nothing intended and skips the dispatch. `close()`,\n // not `requestClose()`: a parent's close is not vetoable.\n ctx.recordCloseIntent(undefined);\n element.close();\n }\n });\n\n // JS-free mode: there is no \"right before showModal()\" (the browser runs the command), so the\n // `autofocus` attribute stays on the target while it is mounted.\n useEffect(() => {\n if (isLibrary || initialFocus === undefined || dialog === null) return;\n const target = resolveInitialFocus(dialog, initialFocus);\n if (target === null || !dialog.contains(target) || target.hasAttribute(\"autofocus\")) return;\n target.setAttribute(\"autofocus\", \"\");\n return () => target.removeAttribute(\"autofocus\");\n }, [isLibrary, initialFocus, dialog]);\n\n // --- Native listeners (conventions 7.4) ---------------------------------------------------\n\n const onCommand = useEffectEvent((event: Event) => {\n if (event.target !== dialogRef.current || event.defaultPrevented) return;\n const command = String((event as Event & { command?: string }).command ?? \"\").toLowerCase();\n if (command === \"show-modal\") {\n // A foreign invoker (design 2.2): opening goes through the library in library mode.\n if (!isLibrary) return;\n event.preventDefault();\n ctx.requestOpen(event, \"activate\");\n } else if (command === \"request-close\" || command === \"close\") {\n ctx.recordCloseIntent({ reason: \"activate\", event });\n }\n });\n\n const onSubmit = useEffectEvent((event: Event) => {\n const element = dialogRef.current;\n const form = event.target;\n if (element === null || !(form instanceof HTMLFormElement)) return;\n if (form.closest(\"dialog\") !== element) return;\n const submitter = (event as SubmitEvent).submitter;\n const formMethod = submitter?.getAttribute(\"formmethod\");\n const method = formMethod != null ? formMethod.toLowerCase() : form.method;\n if (method !== \"dialog\") return;\n ctx.recordCloseIntent({ reason: \"activate\", event });\n });\n\n const onClose = useEffectEvent((event: Event) => {\n const element = dialogRef.current;\n if (element === null || event.target !== element) return;\n awaitingClose.current = false;\n\n // Focus return is the platform's; it leaves focus inside the hidden dialog only when the\n // opener is gone (design 6.2).\n const doc = element.ownerDocument;\n const active = doc.activeElement;\n if (active !== null && active !== doc.body && element.contains(active)) {\n const trigger = triggerRef.current;\n if (trigger !== null && trigger.isConnected) trigger.focus();\n else if (active instanceof HTMLElement) active.blur();\n }\n\n const intent = ctx.takeCloseIntent();\n if (!isLibrary) return;\n\n // Keep the children while the exit animation runs (design 4.4). Firefox has none.\n if (element.isConnected && typeof element.getAnimations === \"function\") {\n void getComputedStyle(element).opacity; // flush style so the exit transitions exist\n const animations = element.getAnimations({ subtree: true }).filter(ends);\n if (animations.length > 0) {\n const generation = ++exitGeneration.current;\n setExiting(true);\n void Promise.allSettled(animations.map((animation) => animation.finished)).then(() => {\n if (exitGeneration.current === generation) startTransition(() => setExiting(false));\n });\n }\n }\n\n ctx.notifyClosed(intent?.event ?? event, intent?.reason ?? \"dismiss\", element.returnValue);\n });\n\n const onBeforeToggle = useEffectEvent((event: Event) => {\n if (event.target !== dialogRef.current) return;\n const newState = (event as ToggleEvent).newState;\n awaitingClose.current = newState === \"closed\";\n // Every native open counts as a new opening (design 3.4, as Popover 14.1): foreign,\n // pre-hydration and JS-free opens too, so a Close action from an earlier opening skips its\n // close. Counted here, synchronously inside `showModal()` / `show()`, not at the queued\n // `toggle`: an action settling between the open and that task would otherwise still see the\n // old generation and close the new open.\n if (newState === \"open\") ctx.nextOpenGeneration();\n });\n\n useEffect(() => {\n if (dialog === null) return;\n const doc = dialog.ownerDocument;\n // Feature detection only with the flag on, inside an effect (conventions 8).\n const nativeClosedBy = experimental_closedBy && \"closedBy\" in dialog;\n\n const listeners: [EventTarget, string, EventListener, boolean][] = [\n [dialog, \"command\", onCommand, false],\n [dialog, \"submit\", onSubmit, false],\n [dialog, \"close\", onClose, false],\n [dialog, \"beforetoggle\", onBeforeToggle, false],\n ];\n\n if (!modal && !nativeClosedBy) {\n // Non-modal dialogs get no close watcher Escape from the platform (design 2.6).\n listeners.push([\n dialog,\n \"keydown\",\n (event) => {\n const keyboardEvent = event as KeyboardEvent;\n if (keyboardEvent.key !== \"Escape\" || keyboardEvent.defaultPrevented) return;\n if (!dialog.open || closestDialog(keyboardEvent.target) !== dialog) return;\n // A popover or nested dialog inside takes this Escape (its close watcher); leave the\n // event alone so that it can.\n if (escapeBelongsToInnerLayer(dialog, keyboardEvent.target)) return;\n keyboardEvent.preventDefault();\n dialog.requestClose();\n },\n false,\n ]);\n }\n\n // Light dismiss needs both the press and the click outside, like native `closedby=\"any\"`: a\n // drag that starts inside (selecting text in an input) and ends on the backdrop or outside\n // fires `click` on the common ancestor and must not close (it would lose a half-filled form).\n let pressedOutside = false;\n\n const isOutside = (target: EventTarget | null): boolean => {\n if (!(target instanceof Node)) return true;\n if (dialog.contains(target)) return false;\n // The Trigger re-opening a non-modal dialog is not a click outside.\n return !(triggerRef.current?.contains(target) ?? false);\n };\n let outsideAttached = false;\n const onOutsidePointerDown = (event: Event) => {\n pressedOutside = dialog.open && isOutside(event.target);\n };\n const onOutsideClick = (event: Event) => {\n const pressed = pressedOutside;\n pressedOutside = false;\n if (!dialog.open || !pressed || !isOutside(event.target)) return;\n dialog.requestClose();\n };\n const syncOutside = () => {\n const want = dialog.open;\n if (want === outsideAttached) return;\n outsideAttached = want;\n pressedOutside = false;\n if (want) {\n doc.addEventListener(\"pointerdown\", onOutsidePointerDown, true);\n doc.addEventListener(\"click\", onOutsideClick, true);\n } else {\n doc.removeEventListener(\"pointerdown\", onOutsidePointerDown, true);\n doc.removeEventListener(\"click\", onOutsideClick, true);\n }\n };\n\n if (lightDismiss && !nativeClosedBy) {\n if (modal) {\n // A press or click on the ::backdrop targets the dialog itself, outside its border box.\n listeners.push(\n [\n dialog,\n \"pointerdown\",\n (event) => {\n pressedOutside = dialog.open && onBackdrop(dialog, event);\n },\n false,\n ],\n [\n dialog,\n \"click\",\n (event) => {\n const pressed = pressedOutside;\n pressedOutside = false;\n if (!dialog.open || !pressed || !onBackdrop(dialog, event)) return;\n dialog.requestClose();\n },\n false,\n ],\n );\n } else {\n // A document listener only while open, following the native `toggle` (the React\n // `onToggle` prop never fires on a hydrated <dialog>); reads `dialog.open`, not\n // `newState` (coalescing).\n listeners.push([dialog, \"toggle\", syncOutside, false]);\n syncOutside();\n }\n }\n\n for (const [target, type, listener, capture] of listeners) {\n target.addEventListener(type, listener, capture);\n }\n return () => {\n for (const [target, type, listener, capture] of listeners) {\n target.removeEventListener(type, listener, capture);\n }\n if (outsideAttached) {\n doc.removeEventListener(\"pointerdown\", onOutsidePointerDown, true);\n doc.removeEventListener(\"click\", onOutsideClick, true);\n }\n };\n }, [dialog, modal, lightDismiss, experimental_closedBy, triggerRef]);\n\n // Development check: the dialog has an accessible name when it is (or can be) shown.\n const shown = !isLibrary || ctx.committed;\n useEffect(() => {\n if (!isDev || dialog === null || !shown) return;\n if (dialog.hasAttribute(\"aria-label\")) return;\n const labelledBy = (dialog.getAttribute(\"aria-labelledby\") ?? \"\").split(/\\s+/);\n const doc = dialog.ownerDocument;\n if (labelledBy.some((id) => id !== \"\" && doc.getElementById(id) !== null)) return;\n console.error(\n \"Dialog.Popup: the dialog has no accessible name. Render a Dialog.Title, or give the \" +\n \"Popup an `aria-label`.\",\n );\n }, [dialog, shown]);\n\n const state: DialogPopupState = { open: ctx.committed, modal };\n const visible = ctx.committed || exiting;\n\n const content = (s: DialogPopupState): ReactNode => {\n if (!isLibrary) return resolveStateValue(children, s);\n if (keepMounted === true) {\n // The mode changes with committed state, inside the Root's transition (conventions 5.5);\n // it stays visible while an exit animation runs.\n return (\n <Activity mode={visible ? \"visible\" : \"hidden\"}>{resolveStateValue(children, s)}</Activity>\n );\n }\n return visible ? resolveStateValue(children, s) : null;\n };\n\n const libraryProps: ComponentPropsWithRef<\"dialog\"> & DataAttributes = {\n id: ids.dialog,\n // Never rendered: removing `open` by hand hides a modal dialog without `close` and leaves\n // `:modal` true (research). Owned so a `render` element cannot add it.\n open: undefined,\n closedby: experimental_closedBy ? (lightDismiss ? \"any\" : \"closerequest\") : undefined,\n \"aria-labelledby\": ids.title,\n \"aria-describedby\": ids.description,\n \"data-modal\": dataAttr(modal),\n // A pre-hydration open leaves an `open` attribute the server did not render (design 2.4).\n suppressHydrationWarning: true,\n };\n\n const element = useRender<ComponentPropsWithRef<\"dialog\">, DialogPopupState>({\n defaultElement: \"dialog\",\n render,\n state,\n className,\n style,\n children: content,\n props: rest,\n libraryProps,\n ref: libraryRef,\n });\n\n return useTransitionBoundary(\"Dialog.Popup\", isLibrary ? transition : undefined, element);\n}\n\nDialogPopup.displayName = \"DialogPopup\";\n"],"mappings":";;;;;;;;;AAyFA,MAAM,QAAQ,QAAQ,IAAI,aAAa;;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ACnB,IAAI,WAAW,MAAM,OAAO,OAAO,MAAM,IAAI,eAAe,EAAE,MAAM,IAAI,GAAG;EAC3E,QAAQ,MACN,4GAEF;CACF,GAAG,CAAC,QAAQ,KAAK,CAAC;CAElB,MAAM,QAA0B;EAAE,MAAM,IAAI;EAAW;CAAM;CAC7D,MAAM,UAAU,IAAI,aAAa;CAEjC,MAAM,WAAW,MAAmC;EAClD,IAAI,CAAC,WAAW,OAAO,kBAAkB,UAAU,CAAC;EACpD,IAAI,gBAAgB,MAGlB,OACE,oBAAC,UAAD;GAAU,MAAM,UAAU,YAAY;GAAW,UAAA,kBAAkB,UAAU,CAAC;EAAY,CAAA;EAG9F,OAAO,UAAU,kBAAkB,UAAU,CAAC,IAAI;CACpD;CAEA,MAAM,eAAiE;EACrE,IAAI,IAAI;EAGR,MAAM,KAAA;EACN,UAAU,wBAAyB,eAAe,QAAQ,iBAAkB,KAAA;EAC5E,mBAAmB,IAAI;EACvB,oBAAoB,IAAI;EACxB,cAAc,SAAS,KAAK;EAE5B,0BAA0B;CAC5B;CAEA,MAAM,UAAU,UAA6D;EAC3E,gBAAgB;EAChB;EACA;EACA;EACA;EACA,UAAU;EACV,OAAO;EACP;EACA,KAAK;CACP,CAAC;CAED,OAAO,sBAAsB,gBAAgB,YAAY,aAAa,KAAA,GAAW,OAAO;AAC1F;AAEA,YAAY,cAAc"}
|
|
1
|
+
{"version":3,"file":"dialog-popup.mjs","names":[],"sources":["../../src/dialog/dialog-popup.tsx"],"sourcesContent":["\"use client\";\nimport { useCallback, useEffect, useEffectEvent, useLayoutEffect, useRef, useState } from \"react\";\nimport type {\n ComponentPropsWithRef,\n CSSProperties,\n ReactNode,\n RefObject,\n ViewTransitionClass,\n} from \"react\";\nimport { useContentFocusProbe } from \"../internal/overlay/content-focus-probe.js\";\nimport { withCssTransitionCut } from \"../internal/overlay/css-transition-cut.js\";\nimport {\n commandOf,\n renderOverlayContent,\n resolveInitialFocus,\n returnFocusToTrigger,\n useCloseHold,\n useInitialFocusTarget,\n useJsFreePropWarnings,\n} from \"../internal/overlay/overlay-popup.js\";\nimport { createPopupFlags, showWithFocus } from \"../internal/overlay/overlay-show.js\";\nimport { useApplyOpenState } from \"../internal/overlay/use-apply-open-state.js\";\nimport { eventSource } from \"../internal/overlay/invokers.js\";\nimport { useTransitionBoundary } from \"../internal/transition-boundary.js\";\nimport { dataAttr } from \"../internal/data-attr.js\";\nimport type { RenderProp, StateValue } from \"../internal/types.js\";\nimport { useElementCheck } from \"../internal/use-element-check.js\";\nimport { useLatest } from \"../internal/use-latest.js\";\nimport { useModalRegistration } from \"../internal/overlay/use-modal-registration.js\";\nimport { useShownNameWarning } from \"../internal/use-name-warning.js\";\nimport { resolveStateValue, useRender } from \"../internal/use-render.js\";\nimport type { DataAttributes } from \"../internal/use-render.js\";\nimport { useDialogContext } from \"./dialog-context.js\";\nimport type { DialogNamespace } from \"./dialog-context.js\";\nimport { listenDialogDismiss } from \"./dialog-dismiss.js\";\n\n/**\n * State of `Dialog.Popup`, passed to the function forms of `className`, `style`, `children` and\n * `render`.\n */\nexport interface DialogPopupState {\n /** Committed open state (library mode); `false` in JS-free mode. Read `:open` for the DOM truth. */\n readonly open: boolean;\n /** The Root's `modal`. */\n readonly modal: boolean;\n}\n\n/**\n * Props of `Dialog.Popup`.\n *\n * @see https://ui.funstack.work/components/dialog\n */\nexport interface DialogPopupProps extends Omit<\n ComponentPropsWithRef<\"dialog\">,\n \"id\" | \"open\" | \"closedby\" | \"onToggle\" | \"onBeforeToggle\" | \"className\" | \"style\" | \"children\"\n> {\n /**\n * Library mode: what happens to the children while the dialog is closed.\n * - `false` (default): not rendered. Mounting them is part of the opening transition, so\n * content that suspends holds the open until it is ready. Unmount waits for the dialog's\n * exit animations.\n * - `true`: rendered inside `<Activity mode=\"hidden\">`: DOM and state preserved, effects\n * stopped, pre-rendered at low priority. Not in the server HTML.\n *\n * Ignored in JS-free mode (always mounted).\n *\n * @defaultValue `false`\n */\n keepMounted?: boolean;\n /**\n * Element to focus when the dialog opens: a ref, or a selector resolved inside the dialog.\n * The library writes `autofocus` on it right before `showModal()` / `show()` and the platform\n * focuses it. Use `tabIndex={-1}` on a heading or wrapper for long or destructive dialogs (APG).\n *\n * In JS-free mode the browser opens the dialog itself, so the attribute is written after\n * hydration and kept while mounted; before hydration only `autoFocus` in the markup works.\n *\n * @defaultValue the platform's choice (first focusable descendant; the dialog itself if none)\n */\n initialFocus?: RefObject<HTMLElement | null> | string;\n /**\n * Close on a click outside the dialog (on the backdrop for modal dialogs).\n * Baseline: JS `pointerdown` + `click` listeners, which close only when both the press and the\n * click land outside (a drag that starts inside, such as selecting text, never closes); with\n * `experimental_closedBy`, native `closedby=\"any\"`, which behaves the same. A click on the\n * Trigger of an open non-modal dialog counts as outside, as it does natively.\n *\n * @defaultValue `false`\n */\n lightDismiss?: boolean;\n /**\n * Experimental (Chrome 134+, Firefox 141+; Safari 27.0 ignores it). Renders `closedby`\n * (`\"any\"` when `lightDismiss`, else `\"closerequest\"`) and skips the JS dismiss listeners where\n * `HTMLDialogElement.prototype.closedBy` exists. Elsewhere the JS baseline stays active.\n *\n * @defaultValue `false`\n */\n experimental_closedBy?: boolean;\n /**\n * Library mode only. Forwarded to the `<ViewTransition default>` around the dialog. Animates\n * the opening commit, content changes while open, and every library-driven close (a Close\n * part, a Form submit or settled action, a foreign close command, a controlled\n * `open={false}`), in all engines; dismissals (Escape, a click outside: `onOpenChange`) are the\n * browser's and animate with CSS only, never with a view transition. Ignored (dev warning) in\n * JS-free mode. While a view transition runs, the dialog's CSS transitions are turned off for\n * the moment of the library's own show or close (an inline `transition: none !important`,\n * restored right after), so that show or close runs no CSS transition (a `@keyframes`\n * animation is not cut).\n *\n * Static: setting or unsetting it remounts the element. Any value, `\"none\"` included, makes a\n * mount or `<Activity>` reveal inside a transition start a document view transition (a ~250 ms\n * page cross-fade that the next transition waits for).\n */\n transition?: ViewTransitionClass;\n /** Class name, or a function of the part's state that returns one. */\n className?: StateValue<string | undefined, DialogPopupState>;\n /** Inline style, or a function of the part's state that returns one. */\n style?: StateValue<CSSProperties | undefined, DialogPopupState>;\n /** Content, or a function of the part's state. */\n children?: StateValue<ReactNode, DialogPopupState>;\n /** Must render a `<dialog>`. */\n render?: RenderProp<ComponentPropsWithRef<\"dialog\">, DialogPopupState>;\n}\n\nconst isDev = process.env.NODE_ENV !== \"production\";\n\n/** The submitter's or invoker's `value` (`\"\"` without one, or where the engine gives no source). */\nfunction valueOf(element: unknown): string {\n if (element instanceof HTMLButtonElement || element instanceof HTMLInputElement) {\n return element.value;\n }\n return \"\";\n}\n\n/**\n * The dialog itself: a `<dialog>` with the id the Trigger's `commandfor` names, wired to Title\n * and Description through `aria-labelledby` / `aria-describedby`. Never renders `open`: modal\n * opening and closing go through `showModal()` / `close()` only. Style it with `:open` and\n * `:modal`; it emits `data-modal` but no `data-open`.\n *\n * In library mode the children render from committed state, so content that suspends keeps the\n * dialog closed (and the Trigger pending) until it is ready; `showModal()` runs in the layout\n * effect of the commit that mounted them. A close a part asks for (Close, a `method=\"dialog\"`\n * submit, a Form's settle close, a foreign close command) is cancelled and goes through the\n * Root: `openChangeAction(false)` is awaited and `close(returnValue)` runs in the layout effect\n * of the commit that ends it, inside the view transition if `transition` is set. A dismissal\n * (Escape, a click outside, script) is the browser's, a fact: the native `close` event makes\n * committed state `false` urgently and calls `onOpenChange(false, { reason: \"dismiss\",\n * returnValue })`; no view transition runs for it.\n *\n * Owned keys (conventions 1.2): `id`, `open`, `closedby`, `aria-labelledby` and\n * `aria-describedby` (token-merged), `data-modal`, `suppressHydrationWarning`.\n *\n * @see https://ui.funstack.work/components/dialog\n */\nexport function DialogPopup(props: DialogPopupProps) {\n return useDialogPopup(props, { namespace: \"Dialog\" });\n}\n\nDialogPopup.displayName = \"DialogPopup\";\n\n/** What a caller of `useDialogPopup` fixes (design/components/alert-dialog.md 8). */\nexport interface DialogPopupOptions {\n readonly namespace: DialogNamespace;\n /** An owned `role` (AlertDialog's); without it `role` passes through. */\n readonly role?: \"alertdialog\";\n /**\n * The initial focus target when `initialFocus` is not given (AlertDialog: the first enabled\n * Cancel), resolved right before a library open. `null` leaves the choice to the platform,\n * without a warning.\n */\n readonly defaultInitialFocus?: (dialog: HTMLDialogElement) => HTMLElement | null;\n /** Wraps the rendered children (AlertDialog's Cancel context). */\n readonly wrapChildren?: (children: ReactNode) => ReactNode;\n}\n\n/**\n * The body of `Dialog.Popup`, also run by `AlertDialog.Popup` with `role`, no light dismiss and\n * a default initial focus target (alert-dialog.md 8).\n */\nexport function useDialogPopup(\n {\n keepMounted,\n initialFocus,\n lightDismiss = false,\n experimental_closedBy = false,\n transition,\n className,\n style,\n children,\n render,\n ...rest\n }: DialogPopupProps,\n { namespace, role, defaultInitialFocus, wrapChildren }: DialogPopupOptions,\n): ReactNode {\n const part = `${namespace}.Popup`;\n const ctx = useDialogContext(part);\n const isLibrary = ctx.mode === \"library\";\n const { modal, ids, popupRef, triggerRef } = ctx;\n const [dialog, setDialog] = useState<HTMLDialogElement | null>(null);\n // `awaitingClose` (the `close` event of a close has not arrived), the library echo\n // `libraryClose` (every other close is a fact, dialog.md 2.7, reported the moment it happens,\n // also while a part's close is in flight) and `refusedFact` (conventions 3.9.4), as\n // usePopoverPopup's.\n const [flags] = useState(createPopupFlags);\n const initialFocusTarget = useInitialFocusTarget(part, \"dialog\");\n\n // `held`: children stay mounted while the close animates (design 4.4).\n const exit = useCloseHold(ctx.committed, isLibrary, transition);\n\n // Whether the content unmounted while holding focus since the dialog was last shown: a close\n // with `transition` removes the focused Close part before `close()` runs (design 6.2 rule 2).\n const contentProbe = useContentFocusProbe(popupRef);\n const { wrapContent } = contentProbe;\n\n // Toast's Viewport moves its region into the topmost open modal (design/components/toast.md 4.3).\n useModalRegistration(dialog);\n\n useJsFreePropWarnings(part, \"dialog\", isLibrary, transition, keepMounted);\n\n const checkElement = useElementCheck<HTMLDialogElement>(\n isDev &&\n ((element) =>\n element.tagName !== \"DIALOG\"\n ? `${part}: expected to render a <dialog> element but got <${element.tagName.toLowerCase()}>. ` +\n \"Top layer, backdrop, focus and Escape all come from a real <dialog>.\"\n : null),\n );\n // --- Opening -----------------------------------------------------------------------------\n\n const openDialog = (element: HTMLDialogElement): void => {\n // A refused re-open of a non-modal dialog never moves focus (#156): no initial focus target,\n // and the dialog is `inert` for the duration of `show()`, so the dialog focusing steps focus\n // nothing (a consumer's own `inert` is left alone). A modal dialog must hold focus: its\n // re-open is a normal open. Two steps on purpose: the flag is taken (and cleared) on every\n // show, a modal one included; `!modal && take()` would leave it set for a modal dialog.\n const wasRefused = flags.takeRefusedFact();\n const refused = wasRefused && !modal;\n // Otherwise the platform's dialog focusing steps honour `autofocus` (design 6.1).\n showWithFocus(element, {\n refused,\n autofocus: refused\n ? null\n : initialFocus === undefined && defaultInitialFocus !== undefined\n ? defaultInitialFocus(element)\n : initialFocusTarget(element, initialFocus),\n // A view transition animates the open: the CSS enter does not run next to it (conventions\n // 5.1).\n show: () =>\n withCssTransitionCut(element, transition !== undefined, () => {\n if (modal) element.showModal();\n else element.show();\n }),\n });\n };\n\n // Mount reconciliation (design 2.4): a click before hydration opened the dialog natively.\n // Runs before the apply effect; the dispatch makes the apply effect wait for it.\n const reconcileOnMount = useEffectEvent(() => {\n const element = popupRef.current;\n if (element === null || !element.open) return;\n ctx.requestOpen(undefined, \"platform\");\n });\n useLayoutEffect(() => {\n if (isLibrary) reconcileOnMount();\n }, [isLibrary]);\n\n // The apply effect (design 2.5), shared with usePopoverPopup. Keep this call right after mount\n // reconciliation (as there): layout effects run in call order, and at mount the\n // reconciliation's dispatch must come first, so that the first apply sees it in flight and\n // waits. Opens on the user's dispatch, `defaultOpen`, a controlled parent, the re-open of a\n // dismissal a controlled parent refused; closes after a part-initiated close settled, a\n // controlled close, or a refused pre-hydration open.\n useApplyOpenState(ctx, {\n flags,\n exit,\n probe: contentProbe,\n isShown: (element) => element.open,\n show: openDialog,\n hide: (element) => {\n // `close()`, not `requestClose()`: the veto point was `openChangeAction`, not `cancel`. The\n // part's `returnValue` (design 2.3), `\"\"` for a controlled close.\n const returnValue = ctx.takeCloseReturnValue();\n withCssTransitionCut(element, transition !== undefined, () => element.close(returnValue));\n // The close commit may have unmounted the focused content before `close()`: a non-modal\n // dialog restores focus only from inside, so do it now (a modal one always restores it on\n // `close()`).\n if (contentProbe.hadFocus()) {\n contentProbe.forget();\n returnFocusToTrigger(element, triggerRef.current);\n }\n },\n });\n\n // JS-free mode: there is no \"right before showModal()\" (the browser runs the command), so the\n // `autofocus` attribute stays on the target while it is mounted.\n useEffect(() => {\n if (isLibrary || initialFocus === undefined || dialog === null) return;\n const target = resolveInitialFocus(dialog, initialFocus);\n if (target === null || !dialog.contains(target) || target.hasAttribute(\"autofocus\")) return;\n target.setAttribute(\"autofocus\", \"\");\n return () => target.removeAttribute(\"autofocus\");\n }, [isLibrary, initialFocus, dialog]);\n\n // --- Native listeners (conventions 7.4) ---------------------------------------------------\n\n const onCommand = useEffectEvent((event: Event) => {\n const element = popupRef.current;\n if (element === null || event.target !== element || event.defaultPrevented) return;\n const command = commandOf(event);\n if (command === \"show-modal\") {\n // A foreign invoker (design 2.2): opening goes through the library in library mode.\n if (!isLibrary) return;\n event.preventDefault();\n ctx.requestOpen(event, \"activate\");\n } else if (command === \"request-close\" || command === \"close\") {\n if (isLibrary) {\n // A foreign close invoker (design 2.3) goes through the library like a foreign\n // `show-modal`: same markup as Dialog.Close, same behaviour. `source` is the invoker\n // (`\"\"` where an engine gives none).\n event.preventDefault();\n ctx.requestClose(event, \"activate\", valueOf(eventSource(event)));\n } else if (element.open) {\n // The `command` event fires whatever the dialog's state (HTML): a close at a closed\n // dialog leaves no intent for a later close.\n ctx.recordCloseIntent({ reason: \"activate\", event });\n }\n }\n });\n\n // On the dialog's root node (the document, or a shadow root: `submit` is not composed), bubble\n // phase: after React's root listener, so a consumer's `onSubmit` has run (design 8.1).\n const onSubmit = useEffectEvent((event: Event) => {\n const element = popupRef.current;\n const form = event.target;\n if (element === null || !(form instanceof HTMLFormElement)) return;\n if (form.closest(\"dialog\") !== element) return;\n const submitter = (event as SubmitEvent).submitter;\n const formMethod = submitter?.getAttribute(\"formmethod\");\n const method = formMethod != null ? formMethod.toLowerCase() : form.method;\n if (method !== \"dialog\") return;\n if (!isLibrary) {\n ctx.recordCloseIntent({ reason: \"activate\", event });\n return;\n }\n // The consumer blocked the submission: the form did not submit, the dialog stays open.\n if (event.defaultPrevented) return;\n // The consumer opted out with `stopPropagation()`: the browser closes the dialog, reported\n // as a fact. Checked explicitly because React's root can be this same node (FUNSTACK\n // Static hydrates the document), where `stopPropagation()` does not stop this listener.\n if (event.cancelBubble) return;\n // Cancel the native close; the library closes once `openChangeAction(false)` settled.\n event.preventDefault();\n ctx.requestClose(event, \"activate\", valueOf(submitter));\n });\n\n // The `close` listener's work, also replayed for an element that remounted before its `close`\n // event (#159; `event` is `undefined` there: no event fired).\n const handleClose = (element: HTMLDialogElement, event: Event | undefined): void => {\n flags.endClose();\n\n // Focus return is the platform's; it leaves focus inside the hidden dialog only when the\n // opener is gone (design 6.2).\n const active = element.ownerDocument.activeElement;\n if (active !== null && element.contains(active)) {\n returnFocusToTrigger(element, triggerRef.current);\n }\n\n const intent = ctx.takeCloseIntent();\n const echo = flags.takeLibraryClose();\n if (!isLibrary) return;\n\n // The library's own `close()` is no fact.\n exit.afterClose(element, echo);\n\n if (echo) return;\n flags.markFact();\n // Closed by the browser: a returnValue a pending part close recorded will never be used.\n ctx.takeCloseReturnValue();\n // A fact, also while a part's close is in flight: it supersedes that request (committed\n // `false` now) and `onOpenChange(false)` is called (conventions 3.9.5, dialog.md 2.7).\n ctx.notifyClosed(intent?.event ?? event, intent?.reason ?? \"dismiss\", element.returnValue);\n };\n const latestHandleClose = useLatest(handleClose);\n\n const onClose = useEffectEvent((event: Event) => {\n const element = popupRef.current;\n if (element === null || event.target !== element) return;\n handleClose(element, event);\n });\n\n // Whether the Popup is mounted, for the #159 replay. A passive effect: a Suspense hide detaches\n // the element's ref (and runs layout cleanups) but keeps passive effects, so a hidden Popup\n // still counts as mounted.\n const mounted = useRef(false);\n useEffect(() => {\n mounted.current = true;\n return () => {\n mounted.current = false;\n };\n }, [mounted]);\n\n const libraryRef = useCallback(\n (element: HTMLDialogElement) => {\n checkElement?.(element);\n popupRef.current = element;\n // A new element (a remount mid-close): the old one's `close` event never comes (#159). A\n // lost fact is replayed a timer task later, unless the Popup unmounted meanwhile; also while\n // a Suspense boundary hides it (the fact happened before the hide). Here, not in the\n // listener effect's cleanup: that passive cleanup runs after the remount's layout effects,\n // and no apply follows it.\n flags.attach(element, (lost) => {\n if (mounted.current) latestHandleClose.current(lost as HTMLDialogElement, undefined);\n });\n setDialog(element);\n return () => {\n if (popupRef.current === element) popupRef.current = null;\n setDialog(null);\n };\n },\n [checkElement, popupRef, flags, latestHandleClose, mounted],\n );\n\n const onBeforeToggle = useEffectEvent((event: Event) => {\n const element = popupRef.current;\n if (element === null || event.target !== element) return;\n const newState = (event as ToggleEvent).newState;\n // An open does not end a close (as Popover's): the close's `close` event still comes, HTML\n // queues it whatever follows, and nothing reads the flag while the dialog is shown (#159).\n if (newState === \"closed\") {\n flags.beginClose();\n // What already runs inside is not the exit.\n exit.recordBaseline(element);\n }\n // Every native open counts as a new opening (design 3.4, as Popover 14.1): foreign,\n // pre-hydration and JS-free opens too, so a Close action from an earlier opening skips its\n // close. Counted here, synchronously inside `showModal()` / `show()`, not at the queued\n // `toggle`: an action settling between the open and that task would otherwise still see the\n // old generation and close the new open.\n if (newState === \"open\") {\n ctx.nextOpenGeneration();\n contentProbe.forget();\n }\n });\n\n useEffect(() => {\n if (dialog === null) return;\n // The document, or the shadow root the dialog lives in (`submit` does not cross it).\n const root = dialog.getRootNode();\n // Feature detection only with the flag on, inside an effect (conventions 8).\n const nativeClosedBy = experimental_closedBy && \"closedBy\" in dialog;\n\n const listeners: [EventTarget, string, EventListener, boolean][] = [\n [dialog, \"command\", onCommand, false],\n // Bubble phase on the root node: after React's root listener (the consumer's `onSubmit`).\n [root, \"submit\", onSubmit, false],\n [dialog, \"close\", onClose, false],\n [dialog, \"beforetoggle\", onBeforeToggle, false],\n ];\n\n for (const [target, type, listener, capture] of listeners) {\n target.addEventListener(type, listener, capture);\n }\n // Escape on a non-modal dialog and light dismiss, where native `closedby` does not do them.\n const stopDismiss = nativeClosedBy\n ? null\n : listenDialogDismiss(dialog, { modal, lightDismiss });\n return () => {\n for (const [target, type, listener, capture] of listeners) {\n target.removeEventListener(type, listener, capture);\n }\n stopDismiss?.();\n };\n }, [dialog, modal, lightDismiss, experimental_closedBy]);\n\n // Development check (design 9): the dialog has an accessible name when it is (or can be)\n // shown.\n useShownNameWarning(\n dialog,\n !isLibrary || ctx.committed,\n isDev &&\n `${part}: the dialog has no accessible name. Render a ${namespace}.Title, or give the ` +\n \"Popup an `aria-label`.\",\n );\n\n const state: DialogPopupState = { open: ctx.committed, modal };\n const visible = ctx.committed || exit.held;\n\n const content = (s: DialogPopupState): ReactNode =>\n renderOverlayContent({ isLibrary, keepMounted, visible, wrapContent }, () =>\n wrapChildren === undefined\n ? resolveStateValue(children, s)\n : wrapChildren(resolveStateValue(children, s)),\n );\n\n const libraryProps: ComponentPropsWithRef<\"dialog\"> & DataAttributes = {\n id: ids.popup,\n // Never rendered: removing `open` by hand hides a modal dialog without `close` and leaves\n // `:modal` true (research). Owned so a `render` element cannot add it.\n open: undefined,\n closedby: experimental_closedBy ? (lightDismiss ? \"any\" : \"closerequest\") : undefined,\n \"aria-labelledby\": ids.title,\n \"aria-describedby\": ids.description,\n \"data-modal\": dataAttr(modal),\n // Owned when fixed (AlertDialog's `alertdialog`): a consumer's `role` is dropped.\n ...(role !== undefined && { role }),\n // A pre-hydration open leaves an `open` attribute the server did not render (design 2.4).\n suppressHydrationWarning: true,\n };\n\n const element = useRender<ComponentPropsWithRef<\"dialog\">, DialogPopupState>({\n defaultElement: \"dialog\",\n render,\n state,\n className,\n style,\n children: content,\n props: rest,\n libraryProps,\n ref: libraryRef,\n });\n\n return useT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a;GACX,KAAK,MAAM,CAAC,QAAQ,MAAM,UAAU,YAAY,WAC9C,OAAO,oBAAoB,MAAM,UAAU,OAAO;GAEpD,cAAc;EAChB;CACF,GAAG;EAAC;EAAQ;EAAO;EAAc;CAAqB,CAAC;CAIvD,oBACE,QACA,CAAC,aAAa,IAAI,WAClB,SACE,GAAG,KAAK,gDAAgD,UAAU,6CAEtE;CAEA,MAAM,QAA0B;EAAE,MAAM,IAAI;EAAW;CAAM;CAC7D,MAAM,UAAU,IAAI,aAAa,KAAK;CAEtC,MAAM,WAAW,MACf,qBAAqB;EAAE;EAAW;EAAa;EAAS;CAAY,SAClE,iBAAiB,KAAA,IACb,kBAAkB,UAAU,CAAC,IAC7B,aAAa,kBAAkB,UAAU,CAAC,CAAC,CACjD;CAEF,MAAM,eAAiE;EACrE,IAAI,IAAI;EAGR,MAAM,KAAA;EACN,UAAU,wBAAyB,eAAe,QAAQ,iBAAkB,KAAA;EAC5E,mBAAmB,IAAI;EACvB,oBAAoB,IAAI;EACxB,cAAc,SAAS,KAAK;EAE5B,GAAI,SAAS,KAAA,KAAa,EAAE,KAAK;EAEjC,0BAA0B;CAC5B;CAEA,MAAM,UAAU,UAA6D;EAC3E,gBAAgB;EAChB;EACA;EACA;EACA;EACA,UAAU;EACV,OAAO;EACP;EACA,KAAK;CACP,CAAC;CAED,OAAO,sBAAsB,MAAM,YAAY,aAAa,KAAA,GAAW,OAAO;AAChF"}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { ActionDetails, ChangeAction, ChangeReason, StateValue } from "../internal/types.mjs";
|
|
1
|
+
import { ActionDetails, ChangeAction, ChangeReason, StateValue, UrgentChangeHandler } from "../internal/types.mjs";
|
|
2
|
+
import "./dialog-context.mjs";
|
|
2
3
|
import { ReactNode } from "react";
|
|
3
4
|
//#region src/dialog/dialog-root.d.ts
|
|
4
|
-
/** Details passed as the second argument of `openChangeAction`. */
|
|
5
|
+
/** Details passed as the second argument of `openChangeAction` and `onOpenChange`. */
|
|
5
6
|
export interface DialogOpenChangeDetails extends ActionDetails {
|
|
6
7
|
/**
|
|
7
8
|
* `"activate"`: the user acted on a part: Trigger (open), Close or Form submit (close).
|
|
@@ -13,21 +14,30 @@ export interface DialogOpenChangeDetails extends ActionDetails {
|
|
|
13
14
|
readonly reason: ChangeReason;
|
|
14
15
|
/**
|
|
15
16
|
* On close: `dialog.returnValue`: the `value` of the Close button or the form submitter that
|
|
16
|
-
* closed it, `""` for
|
|
17
|
+
* closed it; for a fact (`onOpenChange`), what the browser left (`""` for Escape or a click
|
|
18
|
+
* outside, the argument of a script `close(value)`). On open: `undefined`.
|
|
17
19
|
*/
|
|
18
20
|
readonly returnValue: string | undefined;
|
|
19
21
|
}
|
|
22
|
+
/** State of `Dialog.Root`, passed to the function forms of `children`. */
|
|
20
23
|
export interface DialogRootState {
|
|
21
24
|
/** Optimistic open state (`false` in JS-free mode). Content rendered from it must not suspend. */
|
|
22
25
|
readonly open: boolean;
|
|
23
26
|
/** An `openChangeAction` dispatched through this Dialog is in flight (library mode only). */
|
|
24
27
|
readonly pending: boolean;
|
|
28
|
+
/** The `modal` prop. */
|
|
25
29
|
readonly modal: boolean;
|
|
26
30
|
}
|
|
31
|
+
/**
|
|
32
|
+
* Props of `Dialog.Root`.
|
|
33
|
+
*
|
|
34
|
+
* @see https://ui.funstack.work/components/dialog
|
|
35
|
+
*/
|
|
27
36
|
export interface DialogRootProps {
|
|
28
37
|
/**
|
|
29
|
-
* Controlled open state. `undefined` means uncontrolled (and, with `defaultOpen
|
|
30
|
-
* `openChangeAction` also absent, JS-free mode).
|
|
38
|
+
* Controlled open state. `undefined` means uncontrolled (and, with `defaultOpen`,
|
|
39
|
+
* `openChangeAction` and `onOpenChange` also absent, JS-free mode). A controlled Root needs
|
|
40
|
+
* `onOpenChange` too: the browser closes the dialog without asking (development warns).
|
|
31
41
|
*/
|
|
32
42
|
open?: boolean;
|
|
33
43
|
/**
|
|
@@ -36,33 +46,58 @@ export interface DialogRootProps {
|
|
|
36
46
|
*/
|
|
37
47
|
defaultOpen?: boolean;
|
|
38
48
|
/**
|
|
39
|
-
* Awaited for `true` (the dialog opens when it resolves and the content has
|
|
40
|
-
*
|
|
41
|
-
*
|
|
42
|
-
*
|
|
43
|
-
*
|
|
44
|
-
*
|
|
45
|
-
*
|
|
49
|
+
* Requests only. Awaited for `true` (the dialog opens when it resolves and the content has
|
|
50
|
+
* rendered) and for a `false` the user asked a part for (`Dialog.Close`, a `Dialog.Form`
|
|
51
|
+
* submit or settled action, a foreign close command: the dialog closes with
|
|
52
|
+
* `details.returnValue` when it resolves, with a view transition if the Popup's `transition` is
|
|
53
|
+
* set; a controlled parent that keeps `open` vetoes it). Never called for a dismissal: that goes
|
|
54
|
+
* to `onOpenChange`. May be a Server Function. Rejections reach the nearest Error Boundary
|
|
55
|
+
* above Root.
|
|
46
56
|
*
|
|
47
57
|
* A `setState` placed after your own `await` is not a Transition update; wrap it in
|
|
48
58
|
* `startTransition` (React limitation).
|
|
49
59
|
*/
|
|
50
60
|
openChangeAction?: ChangeAction<boolean, DialogOpenChangeDetails>;
|
|
51
|
-
/**
|
|
61
|
+
/**
|
|
62
|
+
* Facts only: the dialog was closed without the library closing it (Escape, Android back, an
|
|
63
|
+
* assistive-technology dismiss, a click outside with `lightDismiss`, script `close()` /
|
|
64
|
+
* `requestClose()`). Always `false`, with `returnValue` as the browser left it. Called
|
|
65
|
+
* synchronously in the platform's `close` event, outside any Transition, and not awaited:
|
|
66
|
+
* nothing is pending and no view transition runs; the dialog is already closed and its
|
|
67
|
+
* committed state is already `false` (uncontrolled). A dismissal while a part's close is in
|
|
68
|
+
* flight is reported at once and supersedes that close.
|
|
69
|
+
*
|
|
70
|
+
* Controlled: set your state **directly** here (`onOpenChange={setOpen}`), not in
|
|
71
|
+
* `startTransition` and not after an `await`; a parent that keeps `open={true}` gets the
|
|
72
|
+
* dialog re-opened at once. May return a promise (a Server Function); a rejection or a throw
|
|
73
|
+
* goes to `reportError`.
|
|
74
|
+
*/
|
|
75
|
+
onOpenChange?: UrgentChangeHandler<boolean, DialogOpenChangeDetails>;
|
|
76
|
+
/**
|
|
77
|
+
* `showModal()` (top layer, backdrop, inert page, Escape) or `show()`.
|
|
78
|
+
*
|
|
79
|
+
* @defaultValue `true`
|
|
80
|
+
*/
|
|
52
81
|
modal?: boolean;
|
|
82
|
+
/** The parts. The function form receives the optimistic state and must not suspend. */
|
|
53
83
|
children?: StateValue<ReactNode, DialogRootState>;
|
|
54
84
|
}
|
|
55
85
|
/**
|
|
56
86
|
* Owns the ids, the mode, the open state and the context. Renders no DOM, so it has no `ref`,
|
|
57
87
|
* `className` or `style`; `pending` is exposed through `children(state)` and the Trigger.
|
|
58
88
|
*
|
|
59
|
-
* Without `open`, `defaultOpen` and `
|
|
60
|
-
* Trigger is a native `command="show-modal"` invoker and the browser owns
|
|
61
|
-
* them it runs in **library mode**: opening is a
|
|
62
|
-
* content renders from committed state, `showModal()` runs
|
|
63
|
-
*
|
|
89
|
+
* Without `open`, `defaultOpen`, `openChangeAction` and `onOpenChange` the Dialog runs in
|
|
90
|
+
* **JS-free mode**: the Trigger is a native `command="show-modal"` invoker and the browser owns
|
|
91
|
+
* everything. With any of them it runs in **library mode**: opening is a request, a transition
|
|
92
|
+
* (the Trigger shows `data-pending`, content renders from committed state, `showModal()` runs
|
|
93
|
+
* when it has committed), and so is a close a part asks for (Close, Form, a foreign close
|
|
94
|
+
* command: `openChangeAction(false)` is awaited, `close(returnValue)` runs when it has
|
|
95
|
+
* committed). Dismissals (Escape, a click outside) are the browser's facts, reported to
|
|
96
|
+
* `onOpenChange`.
|
|
97
|
+
*
|
|
98
|
+
* @see https://ui.funstack.work/components/dialog
|
|
64
99
|
*/
|
|
65
|
-
export declare function DialogRoot({
|
|
100
|
+
export declare function DialogRoot({ modal, ...props }: DialogRootProps): ReactNode;
|
|
66
101
|
export declare namespace DialogRoot {
|
|
67
102
|
var displayName: string;
|
|
68
103
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dialog-root.d.mts","names":[],"sources":["../../src/dialog/dialog-root.tsx"],"mappings":"
|
|
1
|
+
{"version":3,"file":"dialog-root.d.mts","names":[],"sources":["../../src/dialog/dialog-root.tsx"],"mappings":";;;;;iBAkBiB,gCAAgC;;;;;;;;WAQtC,QAAQ;;;;;;WAMR;;;iBAIM;;WAEN;;WAEA;;WAEA;;;;;;;iBAQM;;;;;;EAMf;;;;;EAKA;;;;;;;;;;;;;EAaA,mBAAmB,sBAAsB;;;;;;;;;;;;;;;EAezC,eAAe,6BAA6B;;;;;;EAM5C;;EAEA,WAAW,WAAW,WAAW;;;;;;;;;;;;;;;;;wBA0BnB,aAAa,UAAiB,SAAS,kBAAe;yBAAtD"}
|
|
@@ -1,113 +1,95 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { createActionDetails } from "../internal/action-details.mjs";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import { useDevWarning } from "../internal/use-dev-warning.mjs";
|
|
2
|
+
import { createActionDetails } from "../internal/action/action-details.mjs";
|
|
3
|
+
import { resolveStateValue } from "../internal/render-element.mjs";
|
|
4
|
+
import { intendedValue } from "../internal/action/use-controllable-action.mjs";
|
|
5
|
+
import { useOverlayRoot } from "../internal/overlay/use-overlay-root.mjs";
|
|
7
6
|
import { DialogContext } from "./dialog-context.mjs";
|
|
8
|
-
import { useCallback,
|
|
7
|
+
import { useCallback, useInsertionEffect, useMemo, useRef } from "react";
|
|
9
8
|
import { jsx } from "react/jsx-runtime";
|
|
10
9
|
//#region src/dialog/dialog-root.tsx
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
}
|
|
10
|
+
const dialogDetails = (event, reason, returnValue) => createActionDetails(event, {
|
|
11
|
+
reason,
|
|
12
|
+
returnValue
|
|
13
|
+
});
|
|
14
|
+
const isDialogOpen = (dialog) => dialog.open;
|
|
17
15
|
/**
|
|
18
16
|
* Owns the ids, the mode, the open state and the context. Renders no DOM, so it has no `ref`,
|
|
19
17
|
* `className` or `style`; `pending` is exposed through `children(state)` and the Trigger.
|
|
20
18
|
*
|
|
21
|
-
* Without `open`, `defaultOpen` and `
|
|
22
|
-
* Trigger is a native `command="show-modal"` invoker and the browser owns
|
|
23
|
-
* them it runs in **library mode**: opening is a
|
|
24
|
-
* content renders from committed state, `showModal()` runs
|
|
25
|
-
*
|
|
19
|
+
* Without `open`, `defaultOpen`, `openChangeAction` and `onOpenChange` the Dialog runs in
|
|
20
|
+
* **JS-free mode**: the Trigger is a native `command="show-modal"` invoker and the browser owns
|
|
21
|
+
* everything. With any of them it runs in **library mode**: opening is a request, a transition
|
|
22
|
+
* (the Trigger shows `data-pending`, content renders from committed state, `showModal()` runs
|
|
23
|
+
* when it has committed), and so is a close a part asks for (Close, Form, a foreign close
|
|
24
|
+
* command: `openChangeAction(false)` is awaited, `close(returnValue)` runs when it has
|
|
25
|
+
* committed). Dismissals (Escape, a click outside) are the browser's facts, reported to
|
|
26
|
+
* `onOpenChange`.
|
|
27
|
+
*
|
|
28
|
+
* @see https://ui.funstack.work/components/dialog
|
|
26
29
|
*/
|
|
27
|
-
function DialogRoot({
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
useDevWarning(isLibrary !== isLibraryNow, "Dialog.Root: the mode changed after mount (`open`, `defaultOpen` and `openChangeAction` were all absent on one render and present on another). Switching between JS-free and library mode is not supported.");
|
|
32
|
-
const { committed, optimistic, pending, dispatch, latestInFlight } = useControllableAction({
|
|
33
|
-
controlled: isLibrary ? open : void 0,
|
|
34
|
-
defaultValue: isLibrary ? defaultOpen : void 0,
|
|
35
|
-
initialValue: false,
|
|
36
|
-
action: isLibrary ? openChangeAction : void 0,
|
|
37
|
-
transitionTypes: (next) => transitionTypes("dialog", next ? "open" : "close"),
|
|
38
|
-
warn: {
|
|
39
|
-
component: "Dialog.Root",
|
|
40
|
-
prop: "open"
|
|
41
|
-
}
|
|
30
|
+
function DialogRoot({ modal = true, ...props }) {
|
|
31
|
+
return useDialogRoot(props, {
|
|
32
|
+
namespace: "Dialog",
|
|
33
|
+
modal
|
|
42
34
|
});
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
35
|
+
}
|
|
36
|
+
DialogRoot.displayName = "DialogRoot";
|
|
37
|
+
/**
|
|
38
|
+
* The body of `Dialog.Root`, also run by `AlertDialog.Root` with `modal` fixed to `true`
|
|
39
|
+
* (design/components/alert-dialog.md 8).
|
|
40
|
+
*/
|
|
41
|
+
function useDialogRoot({ open, defaultOpen, openChangeAction, onOpenChange, children }, { namespace, modal }) {
|
|
42
|
+
const root = useOverlayRoot({
|
|
43
|
+
component: "dialog",
|
|
44
|
+
part: `${namespace}.Root`,
|
|
45
|
+
open,
|
|
46
|
+
defaultOpen,
|
|
47
|
+
openChangeAction,
|
|
48
|
+
onOpenChange,
|
|
49
|
+
details: dialogDetails,
|
|
50
|
+
isShown: isDialogOpen
|
|
51
|
+
});
|
|
52
|
+
const { mode, intended, latestInFlight, optimistic, requestClose: closeRoot } = root;
|
|
53
|
+
const closeReturnValue = useRef(void 0);
|
|
54
|
+
useInsertionEffect(() => {
|
|
55
|
+
if (intendedValue(latestInFlight, optimistic)) closeReturnValue.current = void 0;
|
|
56
|
+
});
|
|
57
|
+
const takeCloseReturnValue = useCallback(() => {
|
|
58
|
+
const value = closeReturnValue.current;
|
|
59
|
+
closeReturnValue.current = void 0;
|
|
60
|
+
return value ?? "";
|
|
60
61
|
}, []);
|
|
61
|
-
const
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
reason,
|
|
67
|
-
returnValue: void 0
|
|
68
|
-
}));
|
|
69
|
-
};
|
|
70
|
-
const notifyClosed = (event, reason, returnValue) => {
|
|
71
|
-
if (!isLibrary || !intended()) return;
|
|
72
|
-
dispatch(false, createActionDetails(event, {
|
|
73
|
-
reason,
|
|
74
|
-
returnValue
|
|
75
|
-
}));
|
|
76
|
-
};
|
|
77
|
-
const openState = isLibrary && optimistic;
|
|
78
|
-
const pendingState = isLibrary && pending;
|
|
79
|
-
const context = {
|
|
62
|
+
const requestClose = useCallback((event, reason, returnValue) => {
|
|
63
|
+
if (mode !== "library" || !intended()) return;
|
|
64
|
+
closeReturnValue.current = returnValue;
|
|
65
|
+
closeRoot(event, reason, returnValue);
|
|
66
|
+
}, [
|
|
80
67
|
mode,
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
68
|
+
intended,
|
|
69
|
+
closeRoot
|
|
70
|
+
]);
|
|
71
|
+
const context = useMemo(() => ({
|
|
72
|
+
...root,
|
|
73
|
+
modal,
|
|
74
|
+
requestClose,
|
|
75
|
+
takeCloseReturnValue
|
|
76
|
+
}), [
|
|
77
|
+
root,
|
|
86
78
|
modal,
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
dialogRef,
|
|
95
|
-
recordCloseIntent,
|
|
96
|
-
takeCloseIntent,
|
|
97
|
-
openGeneration,
|
|
98
|
-
nextOpenGeneration
|
|
79
|
+
requestClose,
|
|
80
|
+
takeCloseReturnValue
|
|
81
|
+
]);
|
|
82
|
+
const state = {
|
|
83
|
+
open: optimistic,
|
|
84
|
+
pending: root.pending,
|
|
85
|
+
modal
|
|
99
86
|
};
|
|
100
87
|
return /* @__PURE__ */ jsx(DialogContext, {
|
|
101
88
|
value: context,
|
|
102
|
-
children: resolveStateValue(children,
|
|
103
|
-
open: openState,
|
|
104
|
-
pending: pendingState,
|
|
105
|
-
modal
|
|
106
|
-
})
|
|
89
|
+
children: resolveStateValue(children, state)
|
|
107
90
|
});
|
|
108
91
|
}
|
|
109
|
-
DialogRoot.displayName = "DialogRoot";
|
|
110
92
|
//#endregion
|
|
111
|
-
export { DialogRoot };
|
|
93
|
+
export { DialogRoot, useDialogRoot };
|
|
112
94
|
|
|
113
95
|
//# sourceMappingURL=dialog-root.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dialog-root.mjs","names":[],"sources":["../../src/dialog/dialog-root.tsx"],"sourcesContent":["\"use client\";\nimport { useCallback, useId, useRef, useState } from \"react\";\nimport type { ReactNode } from \"react\";\nimport { createActionDetails } from \"../internal/action-details.js\";\nimport { transitionTypes } from \"../internal/transition-types.js\";\nimport type { ActionDetails, ChangeAction, ChangeReason, StateValue } from \"../internal/types.js\";\nimport { useControllableAction } from \"../internal/use-controllable-action.js\";\nimport { useDevWarning } from \"../internal/use-dev-warning.js\";\nimport { resolveStateValue } from \"../internal/use-render.js\";\nimport { DialogContext } from \"./dialog-context.js\";\nimport type { DialogCloseIntent, DialogContextValue, DialogMode } from \"./dialog-context.js\";\n\n/** Details passed as the second argument of `openChangeAction`. */\nexport interface DialogOpenChangeDetails extends ActionDetails {\n /**\n * `\"activate\"`: the user acted on a part: Trigger (open), Close or Form submit (close).\n * `\"dismiss\"`: the user closed the dialog without a part: Escape, Android back, an assistive-\n * technology dismiss gesture, or a click outside (`lightDismiss` / `closedby=\"any\"`).\n * `\"platform\"`: the dialog was found open on mount (opened before hydration); `event` is\n * `undefined`.\n */\n readonly reason: ChangeReason;\n /**\n * On close: `dialog.returnValue`: the `value` of the Close button or the form submitter that\n * closed it, `\"\"` for a dismiss. On open: `undefined`.\n */\n readonly returnValue: string | undefined;\n}\n\nexport interface DialogRootState {\n /** Optimistic open state (`false` in JS-free mode). Content rendered from it must not suspend. */\n readonly open: boolean;\n /** An `openChangeAction` dispatched through this Dialog is in flight (library mode only). */\n readonly pending: boolean;\n readonly modal: boolean;\n}\n\nexport interface DialogRootProps {\n /**\n * Controlled open state. `undefined` means uncontrolled (and, with `defaultOpen` and\n * `openChangeAction` also absent, JS-free mode).\n */\n open?: boolean;\n /**\n * Initial open state in uncontrolled library mode. The dialog opens after hydration, never in\n * the server HTML.\n */\n defaultOpen?: boolean;\n /**\n * Awaited for `true` (the dialog opens when it resolves and the content has rendered); a\n * notification for `false` (the dialog is already closed; the action runs inside the Root's\n * transition). May be a Server Function. Rejections reach the nearest Error Boundary above\n * Root.\n *\n * A controlled parent that does not adopt `false` gets the dialog re-opened once the action\n * settles: closing is the browser's, this is not a veto.\n *\n * A `setState` placed after your own `await` is not a Transition update; wrap it in\n * `startTransition` (React limitation).\n */\n openChangeAction?: ChangeAction<boolean, DialogOpenChangeDetails>;\n /** `showModal()` (top layer, backdrop, inert page, Escape) or `show()`. Default `true`. */\n modal?: boolean;\n children?: StateValue<ReactNode, DialogRootState>;\n}\n\n/** How long a recorded close intent survives when the dialog did not close (design 2.3). */\nfunction clearLater(\n intentRef: { current: DialogCloseIntent | undefined },\n intent: DialogCloseIntent,\n dialogRef: { current: HTMLDialogElement | null },\n): void {\n setTimeout(() => {\n // The dialog closed: its `close` event (queued as a task) consumes the intent. Still open:\n // the close was cancelled (a prevented `cancel` or `command`), so the intent is stale.\n if (intentRef.current === intent && dialogRef.current?.open === true) {\n intentRef.current = undefined;\n }\n }, 0);\n}\n\n/**\n * Owns the ids, the mode, the open state and the context. Renders no DOM, so it has no `ref`,\n * `className` or `style`; `pending` is exposed through `children(state)` and the Trigger.\n *\n * Without `open`, `defaultOpen` and `openChangeAction` the Dialog runs in **JS-free mode**: the\n * Trigger is a native `command=\"show-modal\"` invoker and the browser owns everything. With any of\n * them it runs in **library mode**: opening is a transition (the Trigger shows `data-pending`,\n * content renders from committed state, `showModal()` runs when it has committed); closing is\n * the browser's and `openChangeAction(false)` is a notification.\n */\nexport function DialogRoot({\n open,\n defaultOpen,\n openChangeAction,\n modal = true,\n children,\n}: DialogRootProps) {\n // Mode is decided once, from the first render's props (design 14).\n const isLibraryNow =\n open !== undefined || defaultOpen !== undefined || openChangeAction !== undefined;\n const [mode] = useState<DialogMode>(isLibraryNow ? \"library\" : \"static\");\n const isLibrary = mode === \"library\";\n useDevWarning(\n isLibrary !== isLibraryNow,\n \"Dialog.Root: 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: static mode calls the hook too and never dispatches.\n const { committed, optimistic, pending, dispatch, latestInFlight } = useControllableAction<\n boolean,\n DialogOpenChangeDetails\n >({\n controlled: isLibrary ? open : undefined,\n defaultValue: isLibrary ? defaultOpen : undefined,\n initialValue: false,\n action: isLibrary ? openChangeAction : undefined,\n transitionTypes: (next) => transitionTypes(\"dialog\", next ? \"open\" : \"close\"),\n warn: { component: \"Dialog.Root\", prop: \"open\" },\n });\n\n const id = useId();\n const triggerRef = useRef<HTMLElement | null>(null);\n const dialogRef = useRef<HTMLDialogElement | null>(null);\n const closeIntent = useRef<DialogCloseIntent | undefined>(undefined);\n\n const recordCloseIntent = useCallback((intent: DialogCloseIntent | undefined) => {\n closeIntent.current = intent;\n if (intent !== undefined) clearLater(closeIntent, intent, dialogRef);\n }, []);\n const takeCloseIntent = useCallback(() => {\n const intent = closeIntent.current;\n closeIntent.current = undefined;\n return intent;\n }, []);\n // Advanced on every open (the open dispatch and the Popup's native `beforetoggle` to open), so a Close action that\n // settles after the user dismissed and re-opened the dialog does not close the new open (the\n // PO's open-generation rule, design/components/popover.md 3.4; review M2).\n const generation = useRef(0);\n const openGeneration = useCallback(() => generation.current, []);\n const nextOpenGeneration = useCallback(() => {\n generation.current++;\n }, []);\n\n // What the user already intends: the latest in-flight dispatch, else the optimistic value\n // (conventions 3.8 rule 1). Judging no-ops against it also deduplicates the StrictMode re-run\n // of the mount reconciliation and recognises the library's own `close()` echoing back.\n const intended = (): boolean => latestInFlight()?.next ?? optimistic;\n\n const requestOpen = (event: Event | undefined, reason: ChangeReason): void => {\n if (!isLibrary || intended()) return;\n nextOpenGeneration();\n dispatch(true, createActionDetails(event, { reason, returnValue: undefined }));\n };\n\n const notifyClosed = (event: Event, reason: ChangeReason, returnValue: string): void => {\n if (!isLibrary || !intended()) return;\n dispatch(false, createActionDetails(event, { reason, returnValue }));\n };\n\n const openState = isLibrary && optimistic;\n const pendingState = isLibrary && pending;\n\n // Not memoised: `dispatch` is a new function on every render of the Root (Accordion does the\n // same), so parts re-render with the Root, which they do anyway when its state changes.\n const context: DialogContextValue = {\n mode,\n ids: { dialog: id, title: `${id}-title`, description: `${id}-description` },\n modal,\n committed: isLibrary && committed,\n optimistic: openState,\n pending: pendingState,\n requestOpen,\n notifyClosed,\n latestInFlight,\n triggerRef,\n dialogRef,\n recordCloseIntent,\n takeCloseIntent,\n openGeneration,\n nextOpenGeneration,\n };\n\n const state: DialogRootState = {\n open: openState,\n pending: pendingState,\n modal,\n };\n\n return <DialogContext value={context}>{resolveStateValue(children, state)}</DialogContext>;\n}\n\nDialogRoot.displayName = \"DialogRoot\";\n"],"mappings":";;;;;;;;;;;AAmEA,SAAS,WACP,WACA,QACA,WACM;CACN,iBAAiB;EAGf,IAAI,UAAU,YAAY,UAAU,UAAU,SAAS,SAAS,MAC9D,UAAU,UAAU,KAAA;CAExB,GAAG,CAAC;AACN;;;;;;;;;;;AAYA,SAAgB,WAAW,EACzB,MACA,aACA,kBACA,QAAQ,MACR,YACkB;CAElB,MAAM,eACJ,SAAS,KAAA,KAAa,gBAAgB,KAAA,KAAa,qBAAqB,KAAA;CAC1E,MAAM,CAAC,QAAQ,SAAqB,eAAe,YAAY,QAAQ;CACvE,MAAM,YAAY,SAAS;CAC3B,cACE,cAAc,cACd,6MAGF;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,K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;EACA;EACA;EACA;CACF;CAQA,OAAO,oBAAC,eAAD;EAAe,OAAO;EAAU,UAAA,kBAAkB,UAAU;GALjE,MAAM;GACN,SAAS;GACT;EAGqE,CAAC;CAAiB,CAAA;AAC3F;AAEA,WAAW,cAAc"}
|
|
1
|
+
{"version":3,"file":"dialog-root.mjs","names":[],"sources":["../../src/dialog/dialog-root.tsx"],"sourcesContent":["\"use client\";\nimport { useCallback, useInsertionEffect, useMemo, useRef } from \"react\";\nimport type { ReactNode } from \"react\";\nimport { createActionDetails } from \"../internal/action/action-details.js\";\nimport type {\n ActionDetails,\n ChangeAction,\n ChangeReason,\n StateValue,\n UrgentChangeHandler,\n} from \"../internal/types.js\";\nimport { intendedValue } from \"../internal/action/use-controllable-action.js\";\nimport { useOverlayRoot } from \"../internal/overlay/use-overlay-root.js\";\nimport { resolveStateValue } from \"../internal/use-render.js\";\nimport { DialogContext } from \"./dialog-context.js\";\nimport type { DialogContextValue, DialogNamespace } from \"./dialog-context.js\";\n\n/** Details passed as the second argument of `openChangeAction` and `onOpenChange`. */\nexport interface DialogOpenChangeDetails extends ActionDetails {\n /**\n * `\"activate\"`: the user acted on a part: Trigger (open), Close or Form submit (close).\n * `\"dismiss\"`: the user closed the dialog without a part: Escape, Android back, an assistive-\n * technology dismiss gesture, or a click outside (`lightDismiss` / `closedby=\"any\"`).\n * `\"platform\"`: the dialog was found open on mount (opened before hydration); `event` is\n * `undefined`.\n */\n readonly reason: ChangeReason;\n /**\n * On close: `dialog.returnValue`: the `value` of the Close button or the form submitter that\n * closed it; for a fact (`onOpenChange`), what the browser left (`\"\"` for Escape or a click\n * outside, the argument of a script `close(value)`). On open: `undefined`.\n */\n readonly returnValue: string | undefined;\n}\n\n/** State of `Dialog.Root`, passed to the function forms of `children`. */\nexport interface DialogRootState {\n /** Optimistic open state (`false` in JS-free mode). Content rendered from it must not suspend. */\n readonly open: boolean;\n /** An `openChangeAction` dispatched through this Dialog is in flight (library mode only). */\n readonly pending: boolean;\n /** The `modal` prop. */\n readonly modal: boolean;\n}\n\n/**\n * Props of `Dialog.Root`.\n *\n * @see https://ui.funstack.work/components/dialog\n */\nexport interface DialogRootProps {\n /**\n * Controlled open state. `undefined` means uncontrolled (and, with `defaultOpen`,\n * `openChangeAction` and `onOpenChange` also absent, JS-free mode). A controlled Root needs\n * `onOpenChange` too: the browser closes the dialog without asking (development warns).\n */\n open?: boolean;\n /**\n * Initial open state in uncontrolled library mode. The dialog opens after hydration, never in\n * the server HTML.\n */\n defaultOpen?: boolean;\n /**\n * Requests only. Awaited for `true` (the dialog opens when it resolves and the content has\n * rendered) and for a `false` the user asked a part for (`Dialog.Close`, a `Dialog.Form`\n * submit or settled action, a foreign close command: the dialog closes with\n * `details.returnValue` when it resolves, with a view transition if the Popup's `transition` is\n * set; a controlled parent that keeps `open` vetoes it). Never called for a dismissal: that goes\n * to `onOpenChange`. May be a Server Function. Rejections reach the nearest Error Boundary\n * above Root.\n *\n * A `setState` placed after your own `await` is not a Transition update; wrap it in\n * `startTransition` (React limitation).\n */\n openChangeAction?: ChangeAction<boolean, DialogOpenChangeDetails>;\n /**\n * Facts only: the dialog was closed without the library closing it (Escape, Android back, an\n * assistive-technology dismiss, a click outside with `lightDismiss`, script `close()` /\n * `requestClose()`). Always `false`, with `returnValue` as the browser left it. Called\n * synchronously in the platform's `close` event, outside any Transition, and not awaited:\n * nothing is pending and no view transition runs; the dialog is already closed and its\n * committed state is already `false` (uncontrolled). A dismissal while a part's close is in\n * flight is reported at once and supersedes that close.\n *\n * Controlled: set your state **directly** here (`onOpenChange={setOpen}`), not in\n * `startTransition` and not after an `await`; a parent that keeps `open={true}` gets the\n * dialog re-opened at once. May return a promise (a Server Function); a rejection or a throw\n * goes to `reportError`.\n */\n onOpenChange?: UrgentChangeHandler<boolean, DialogOpenChangeDetails>;\n /**\n * `showModal()` (top layer, backdrop, inert page, Escape) or `show()`.\n *\n * @defaultValue `true`\n */\n modal?: boolean;\n /** The parts. The function form receives the optimistic state and must not suspend. */\n children?: StateValue<ReactNode, DialogRootState>;\n}\n\nconst dialogDetails = (\n event: Event | undefined,\n reason: ChangeReason,\n returnValue?: string,\n): DialogOpenChangeDetails => createActionDetails(event, { reason, returnValue });\n\nconst isDialogOpen = (dialog: HTMLDialogElement): boolean => dialog.open;\n\n/**\n * Owns the ids, the mode, the open state and the context. Renders no DOM, so it has no `ref`,\n * `className` or `style`; `pending` is exposed through `children(state)` and the Trigger.\n *\n * Without `open`, `defaultOpen`, `openChangeAction` and `onOpenChange` the Dialog runs in\n * **JS-free mode**: the Trigger is a native `command=\"show-modal\"` invoker and the browser owns\n * everything. With any of them it runs in **library mode**: opening is a request, a transition\n * (the Trigger shows `data-pending`, content renders from committed state, `showModal()` runs\n * when it has committed), and so is a close a part asks for (Close, Form, a foreign close\n * command: `openChangeAction(false)` is awaited, `close(returnValue)` runs when it has\n * committed). Dismissals (Escape, a click outside) are the browser's facts, reported to\n * `onOpenChange`.\n *\n * @see https://ui.funstack.work/components/dialog\n */\nexport function DialogRoot({ modal = true, ...props }: DialogRootProps) {\n return useDialogRoot(props, { namespace: \"Dialog\", modal });\n}\n\nDialogRoot.displayName = \"DialogRoot\";\n\n/** What a caller of `useDialogRoot` fixes (design/components/alert-dialog.md 8). */\nexport interface DialogRootOptions {\n readonly namespace: DialogNamespace;\n readonly modal: boolean;\n}\n\n/**\n * The body of `Dialog.Root`, also run by `AlertDialog.Root` with `modal` fixed to `true`\n * (design/components/alert-dialog.md 8).\n */\nexport function useDialogRoot(\n { open, defaultOpen, openChangeAction, onOpenChange, children }: Omit<DialogRootProps, \"modal\">,\n { namespace, modal }: DialogRootOptions,\n): ReactNode {\n // The popover machinery (design/components/popover.md 14.1) with the `<dialog>`'s `open` and\n // `returnValue` in the details: an open's `returnValue` is an own `undefined`.\n const root = useOverlayRoot<DialogOpenChangeDetails, HTMLDialogElement, [returnValue: string]>({\n component: \"dialog\",\n part: `${namespace}.Root`,\n open,\n defaultOpen,\n openChangeAction,\n onOpenChange,\n details: dialogDetails,\n isShown: isDialogOpen,\n });\n const { mode, intended, latestInFlight, optimistic, requestClose: closeRoot } = root;\n\n // The `returnValue` of a pending part-initiated close (design 2.3), handed to the apply\n // effect's `close()`. Stale once `true` is intended again (a vetoed close snapped back, or a\n // re-open), so the commit that shows it clears it.\n const closeReturnValue = useRef<string | undefined>(undefined);\n useInsertionEffect(() => {\n if (intendedValue(latestInFlight, optimistic)) closeReturnValue.current = undefined;\n });\n const takeCloseReturnValue = useCallback((): string => {\n const value = closeReturnValue.current;\n closeReturnValue.current = undefined;\n return value ?? \"\";\n }, []);\n\n // A library-owned close (design 2.3): `openChangeAction(false)` is awaited and the Popup's\n // apply effect calls `close(returnValue)` in the commit that ends it. A fact's `notifyClosed`\n // records no `returnValue`.\n const requestClose = useCallback(\n (event: Event | undefined, reason: ChangeReason, returnValue: string): void => {\n if (mode !== \"library\" || !intended()) return;\n closeReturnValue.current = returnValue;\n closeRoot(event, reason, returnValue);\n },\n [mode, intended, closeRoot],\n );\n\n // Memoised: `root` changes only with the open state and pending, so the value changes only\n // with those and `modal`, and the parts do not re-render for an unrelated render of the Root.\n const context = useMemo<DialogContextValue>(\n () => ({ ...root, modal, requestClose, takeCloseReturnValue }),\n [root, modal, requestClose, takeCloseReturnValue],\n );\n\n const state: DialogRootState = { open: optimistic, pending: root.pending, modal };\n\n return <DialogContext value={context}>{resolveStateValue(children, state)}</DialogContext>;\n}\n"],"mappings":";;;;;;;;;AAoGA,MAAM,iBACJ,OACA,QACA,gBAC4B,oBAAoB,OAAO;CAAE;CAAQ;AAAY,CAAC;AAEhF,MAAM,gBAAgB,WAAuC,OAAO;;;;;;;;;;;;;;;;AAiBpE,SAAgB,WAAW,EAAE,QAAQ,MAAM,GAAG,SAA0B;CACtE,OAAO,cAAc,OAAO;EAAE,WAAW;EAAU;CAAM,CAAC;AAC5D;AAEA,WAAW,cAAc;;;;;AAYzB,SAAgB,cACd,EAAE,MAAM,aAAa,kBAAkB,cAAc,YACrD,EAAE,WAAW,SACF;CAGX,MAAM,OAAO,eAAkF;EAC7F,WAAW;EACX,MAAM,GAAG,UAAU;EACnB;EACA;EACA;EACA;EACA,SAAS;EACT,SAAS;CACX,CAAC;CACD,MAAM,EAAE,MAAM,UAAU,gBAAgB,YAAY,cAAc,cAAc;CAKhF,MAAM,mBAAmB,OAA2B,KAAA,CAAS;CAC7D,yBAAyB;EACvB,IAAI,cAAc,gBAAgB,UAAU,GAAG,iBAAiB,UAAU,KAAA;CAC5E,CAAC;CACD,MAAM,uBAAuB,kBAA0B;EACrD,MAAM,QAAQ,iBAAiB;EAC/B,iBAAiB,UAAU,KAAA;EAC3B,OAAO,SAAS;CAClB,GAAG,CAAC,CAAC;CAKL,MAAM,eAAe,aAClB,OAA0B,QAAsB,gBAA8B;EAC7E,IAAI,SAAS,aAAa,CAAC,SAAS,GAAG;EACvC,iBAAiB,UAAU;EAC3B,UAAU,OAAO,QAAQ,WAAW;CACtC,GACA;EAAC;EAAM;EAAU;CAAS,CAC5B;CAIA,MAAM,UAAU,eACP;EAAE,GAAG;EAAM;EAAO;EAAc;CAAqB,IAC5D;EAAC;EAAM;EAAO;EAAc;CAAoB,CAClD;CAEA,MAAM,QAAyB;EAAE,MAAM;EAAY,SAAS,KAAK;EAAS;CAAM;CAEhF,OAAO,oBAAC,eAAD;EAAe,OAAO;EAAU,UAAA,kBAAkB,UAAU,KAAK;CAAiB,CAAA;AAC3F"}
|
|
@@ -1,11 +1,21 @@
|
|
|
1
1
|
import { RenderProp, StateValue } from "../internal/types.mjs";
|
|
2
|
+
import "./dialog-context.mjs";
|
|
2
3
|
import { DialogPopupState } from "./dialog-popup.mjs";
|
|
3
4
|
import { CSSProperties, ComponentPropsWithRef, ReactNode } from "react";
|
|
4
5
|
//#region src/dialog/dialog-title.d.ts
|
|
6
|
+
/** State of `Dialog.Title`: the Popup's state. */
|
|
5
7
|
export type DialogTitleState = DialogPopupState;
|
|
8
|
+
/**
|
|
9
|
+
* Props of `Dialog.Title`.
|
|
10
|
+
*
|
|
11
|
+
* @see https://ui.funstack.work/components/dialog
|
|
12
|
+
*/
|
|
6
13
|
export interface DialogTitleProps extends Omit<ComponentPropsWithRef<"h2">, "id" | "className" | "style" | "children"> {
|
|
14
|
+
/** Class name, or a function of the part's state that returns one. */
|
|
7
15
|
className?: StateValue<string | undefined, DialogTitleState>;
|
|
16
|
+
/** Inline style, or a function of the part's state that returns one. */
|
|
8
17
|
style?: StateValue<CSSProperties | undefined, DialogTitleState>;
|
|
18
|
+
/** Content, or a function of the part's state. */
|
|
9
19
|
children?: StateValue<ReactNode, DialogTitleState>;
|
|
10
20
|
/** `render={<h3 />}` changes the heading level. */
|
|
11
21
|
render?: RenderProp<ComponentPropsWithRef<"h2">, DialogTitleState>;
|
|
@@ -14,8 +24,10 @@ export interface DialogTitleProps extends Omit<ComponentPropsWithRef<"h2">, "id"
|
|
|
14
24
|
* The dialog's name: an `<h2>` whose id the Popup references with `aria-labelledby`.
|
|
15
25
|
*
|
|
16
26
|
* Owned key (conventions 1.2): `id`.
|
|
27
|
+
*
|
|
28
|
+
* @see https://ui.funstack.work/components/dialog
|
|
17
29
|
*/
|
|
18
|
-
export declare function DialogTitle(
|
|
30
|
+
export declare function DialogTitle(props: DialogTitleProps): ReactNode;
|
|
19
31
|
export declare namespace DialogTitle {
|
|
20
32
|
var displayName: string;
|
|
21
33
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dialog-title.d.mts","names":[],"sources":["../../src/dialog/dialog-title.tsx"],"mappings":"
|
|
1
|
+
{"version":3,"file":"dialog-title.d.mts","names":[],"sources":["../../src/dialog/dialog-title.tsx"],"mappings":";;;;;;YASY,mBAAmB;;;;;;iBAOd,yBAAyB,KACxC;;EAIA,YAAY,+BAA+B;;EAE3C,QAAQ,WAAW,2BAA2B;;EAE9C,WAAW,WAAW,WAAW;;EAEjC,SAAS,WAAW,6BAA6B;;;;;;;;;wBAUnC,YAAY,OAAO,mBAAgB;yBAAnC"}
|
|
@@ -6,9 +6,16 @@ import { useDialogContext } from "./dialog-context.mjs";
|
|
|
6
6
|
* The dialog's name: an `<h2>` whose id the Popup references with `aria-labelledby`.
|
|
7
7
|
*
|
|
8
8
|
* Owned key (conventions 1.2): `id`.
|
|
9
|
+
*
|
|
10
|
+
* @see https://ui.funstack.work/components/dialog
|
|
9
11
|
*/
|
|
10
|
-
function DialogTitle(
|
|
11
|
-
|
|
12
|
+
function DialogTitle(props) {
|
|
13
|
+
return useDialogTitle(props, "Dialog");
|
|
14
|
+
}
|
|
15
|
+
DialogTitle.displayName = "DialogTitle";
|
|
16
|
+
/** The body of `Dialog.Title`, also run by `AlertDialog.Title` (alert-dialog.md 8). */
|
|
17
|
+
function useDialogTitle({ className, style, children, render, ...rest }, namespace) {
|
|
18
|
+
const ctx = useDialogContext(`${namespace}.Title`);
|
|
12
19
|
const state = {
|
|
13
20
|
open: ctx.committed,
|
|
14
21
|
modal: ctx.modal
|
|
@@ -24,8 +31,7 @@ function DialogTitle({ className, style, children, render, ...rest }) {
|
|
|
24
31
|
libraryProps: { id: ctx.ids.title }
|
|
25
32
|
});
|
|
26
33
|
}
|
|
27
|
-
DialogTitle.displayName = "DialogTitle";
|
|
28
34
|
//#endregion
|
|
29
|
-
export { DialogTitle };
|
|
35
|
+
export { DialogTitle, useDialogTitle };
|
|
30
36
|
|
|
31
37
|
//# sourceMappingURL=dialog-title.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dialog-title.mjs","names":[],"sources":["../../src/dialog/dialog-title.tsx"],"sourcesContent":["\"use client\";\nimport type { ComponentPropsWithRef, CSSProperties, ReactNode } from \"react\";\nimport type { RenderProp, StateValue } from \"../internal/types.js\";\nimport { useRender } from \"../internal/use-render.js\";\nimport { useDialogContext } from \"./dialog-context.js\";\nimport type { DialogPopupState } from \"./dialog-popup.js\";\n\nexport type DialogTitleState = DialogPopupState;\n\nexport interface DialogTitleProps extends Omit<\n ComponentPropsWithRef<\"h2\">,\n \"id\" | \"className\" | \"style\" | \"children\"\n> {\n className?: StateValue<string | undefined, DialogTitleState>;\n style?: StateValue<CSSProperties | undefined, DialogTitleState>;\n children?: StateValue<ReactNode, DialogTitleState>;\n /** `render={<h3 />}` changes the heading level. */\n render?: RenderProp<ComponentPropsWithRef<\"h2\">, DialogTitleState>;\n}\n\n/**\n * The dialog's name: an `<h2>` whose id the Popup references with `aria-labelledby`.\n *\n * Owned key (conventions 1.2): `id`.\n */\nexport function DialogTitle({ className, style, children, render, ...rest }: DialogTitleProps) {\n const ctx = useDialogContext(
|
|
1
|
+
{"version":3,"file":"dialog-title.mjs","names":[],"sources":["../../src/dialog/dialog-title.tsx"],"sourcesContent":["\"use client\";\nimport type { ComponentPropsWithRef, CSSProperties, ReactNode } from \"react\";\nimport type { RenderProp, StateValue } from \"../internal/types.js\";\nimport { useRender } from \"../internal/use-render.js\";\nimport { useDialogContext } from \"./dialog-context.js\";\nimport type { DialogNamespace } from \"./dialog-context.js\";\nimport type { DialogPopupState } from \"./dialog-popup.js\";\n\n/** State of `Dialog.Title`: the Popup's state. */\nexport type DialogTitleState = DialogPopupState;\n\n/**\n * Props of `Dialog.Title`.\n *\n * @see https://ui.funstack.work/components/dialog\n */\nexport interface DialogTitleProps extends Omit<\n ComponentPropsWithRef<\"h2\">,\n \"id\" | \"className\" | \"style\" | \"children\"\n> {\n /** Class name, or a function of the part's state that returns one. */\n className?: StateValue<string | undefined, DialogTitleState>;\n /** Inline style, or a function of the part's state that returns one. */\n style?: StateValue<CSSProperties | undefined, DialogTitleState>;\n /** Content, or a function of the part's state. */\n children?: StateValue<ReactNode, DialogTitleState>;\n /** `render={<h3 />}` changes the heading level. */\n render?: RenderProp<ComponentPropsWithRef<\"h2\">, DialogTitleState>;\n}\n\n/**\n * The dialog's name: an `<h2>` whose id the Popup references with `aria-labelledby`.\n *\n * Owned key (conventions 1.2): `id`.\n *\n * @see https://ui.funstack.work/components/dialog\n */\nexport function DialogTitle(props: DialogTitleProps) {\n return useDialogTitle(props, \"Dialog\");\n}\n\nDialogTitle.displayName = \"DialogTitle\";\n\n/** The body of `Dialog.Title`, also run by `AlertDialog.Title` (alert-dialog.md 8). */\nexport function useDialogTitle(\n { className, style, children, render, ...rest }: DialogTitleProps,\n namespace: DialogNamespace,\n): ReactNode {\n const ctx = useDialogContext(`${namespace}.Title`);\n const state: DialogTitleState = { open: ctx.committed, modal: ctx.modal };\n return useRender<ComponentPropsWithRef<\"h2\">, DialogTitleState>({\n defaultElement: \"h2\",\n render,\n state,\n className,\n style,\n children,\n props: rest,\n libraryProps: { id: ctx.ids.title },\n });\n}\n"],"mappings":";;;;;;;;;;;AAqCA,SAAgB,YAAY,OAAyB;CACnD,OAAO,eAAe,OAAO,QAAQ;AACvC;AAEA,YAAY,cAAc;;AAG1B,SAAgB,eACd,EAAE,WAAW,OAAO,UAAU,QAAQ,GAAG,QACzC,WACW;CACX,MAAM,MAAM,iBAAiB,GAAG,UAAU,OAAO;CACjD,MAAM,QAA0B;EAAE,MAAM,IAAI;EAAW,OAAO,IAAI;CAAM;CACxE,OAAO,UAAyD;EAC9D,gBAAgB;EAChB;EACA;EACA;EACA;EACA;EACA,OAAO;EACP,cAAc,EAAE,IAAI,IAAI,IAAI,MAAM;CACpC,CAAC;AACH"}
|