@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
|
@@ -2,12 +2,24 @@
|
|
|
2
2
|
import { createContext, use } from "react";
|
|
3
3
|
//#region src/dialog/dialog-context.ts
|
|
4
4
|
const DialogContext = createContext(null);
|
|
5
|
+
/**
|
|
6
|
+
* The parts of `Dialog` and `AlertDialog` (design/components/alert-dialog.md 8) share this
|
|
7
|
+
* context. `part` is the public name (`"AlertDialog.Cancel"`); the error names the Root of the
|
|
8
|
+
* same namespace.
|
|
9
|
+
*/
|
|
5
10
|
function useDialogContext(part) {
|
|
6
11
|
const context = use(DialogContext);
|
|
7
|
-
if (context === null)
|
|
12
|
+
if (context === null) {
|
|
13
|
+
const root = rootPartOf(part);
|
|
14
|
+
throw new Error(`${part} must be rendered inside ${/^[AEIOU]/.test(root) ? "an" : "a"} ${root}.`);
|
|
15
|
+
}
|
|
8
16
|
return context;
|
|
9
17
|
}
|
|
18
|
+
/** `"AlertDialog.Cancel"` -> `"AlertDialog.Root"`. */
|
|
19
|
+
function rootPartOf(part) {
|
|
20
|
+
return `${part.slice(0, part.indexOf("."))}.Root`;
|
|
21
|
+
}
|
|
10
22
|
//#endregion
|
|
11
|
-
export { DialogContext, useDialogContext };
|
|
23
|
+
export { DialogContext, rootPartOf, useDialogContext };
|
|
12
24
|
|
|
13
25
|
//# sourceMappingURL=dialog-context.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dialog-context.mjs","names":[],"sources":["../../src/dialog/dialog-context.ts"],"sourcesContent":["\"use client\";\nimport { createContext, use } from \"react\";\nimport type {
|
|
1
|
+
{"version":3,"file":"dialog-context.mjs","names":[],"sources":["../../src/dialog/dialog-context.ts"],"sourcesContent":["\"use client\";\nimport { createContext, use } from \"react\";\nimport type { ChangeReason } from \"../internal/types.js\";\nimport type { OverlayRootValue } from \"../internal/overlay/use-overlay-root.js\";\n\n/**\n * The Root's machinery (`useOverlayRoot`, as Popover's) with the `<dialog>` as the popup element\n * and a close's `returnValue`. `mode` \"static\" is JS-free mode, where the browser owns open and\n * close through Invoker Commands; in \"library\" mode opening and the closes a part asks for are\n * library-owned requests, dismissals browser-owned facts reported to `onOpenChange` (design\n * section 2, conventions 3.9).\n */\nexport interface DialogContextValue extends OverlayRootValue<\n HTMLDialogElement,\n [returnValue: string]\n> {\n readonly modal: boolean;\n /**\n * A library-owned close (library mode, design 2.3): a Close part, a `method=\"dialog\"` submit,\n * a Form's settle close, a foreign close command. Records `returnValue` for the apply effect's\n * `close()` and dispatches `false` (`openChangeAction(false)` awaited). A no-op when `false` is\n * already intended. `notifyClosed` (a fact: a native close) records nothing.\n */\n readonly requestClose: (\n event: Event | undefined,\n reason: ChangeReason,\n returnValue: string,\n ) => void;\n /**\n * Read and clear the `returnValue` of the pending part-initiated close, for the apply effect's\n * `close()`; `\"\"` when there is none (a controlled close).\n */\n readonly takeCloseReturnValue: () => string;\n}\n\nexport const DialogContext = createContext<DialogContextValue | null>(null);\n\n/**\n * The namespace whose part names a shared part body uses in its messages: `Dialog`, or\n * `AlertDialog`, whose parts run the Dialog parts' code (design/components/alert-dialog.md 8).\n */\nexport type DialogNamespace = \"Dialog\" | \"AlertDialog\";\n\n/**\n * The parts of `Dialog` and `AlertDialog` (design/components/alert-dialog.md 8) share this\n * context. `part` is the public name (`\"AlertDialog.Cancel\"`); the error names the Root of the\n * same namespace.\n */\nexport function useDialogContext(part: string): DialogContextValue {\n const context = use(DialogContext);\n if (context === null) {\n const root = rootPartOf(part);\n throw new Error(\n `${part} must be rendered inside ${/^[AEIOU]/.test(root) ? \"an\" : \"a\"} ${root}.`,\n );\n }\n return context;\n}\n\n/** `\"AlertDialog.Cancel\"` -> `\"AlertDialog.Root\"`. */\nexport function rootPartOf(part: string): string {\n return `${part.slice(0, part.indexOf(\".\"))}.Root`;\n}\n"],"mappings":";;;AAmCA,MAAa,gBAAgB,cAAyC,IAAI;;;;;;AAa1E,SAAgB,iBAAiB,MAAkC;CACjE,MAAM,UAAU,IAAI,aAAa;CACjC,IAAI,YAAY,MAAM;EACpB,MAAM,OAAO,WAAW,IAAI;EAC5B,MAAM,IAAI,MACR,GAAG,KAAK,2BAA2B,WAAW,KAAK,IAAI,IAAI,OAAO,IAAI,GAAG,KAAK,EAChF;CACF;CACA,OAAO;AACT;;AAGA,SAAgB,WAAW,MAAsB;CAC/C,OAAO,GAAG,KAAK,MAAM,GAAG,KAAK,QAAQ,GAAG,CAAC,EAAE;AAC7C"}
|
|
@@ -1,20 +1,33 @@
|
|
|
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-description.d.ts
|
|
6
|
+
/** State of `Dialog.Description`: the Popup's state. */
|
|
5
7
|
export type DialogDescriptionState = DialogPopupState;
|
|
8
|
+
/**
|
|
9
|
+
* Props of `Dialog.Description`.
|
|
10
|
+
*
|
|
11
|
+
* @see https://ui.funstack.work/components/dialog
|
|
12
|
+
*/
|
|
6
13
|
export interface DialogDescriptionProps extends Omit<ComponentPropsWithRef<"p">, "id" | "className" | "style" | "children"> {
|
|
14
|
+
/** Class name, or a function of the part's state that returns one. */
|
|
7
15
|
className?: StateValue<string | undefined, DialogDescriptionState>;
|
|
16
|
+
/** Inline style, or a function of the part's state that returns one. */
|
|
8
17
|
style?: StateValue<CSSProperties | undefined, DialogDescriptionState>;
|
|
18
|
+
/** Content, or a function of the part's state. */
|
|
9
19
|
children?: StateValue<ReactNode, DialogDescriptionState>;
|
|
20
|
+
/** Replace the default `<p>` (element form) or take over rendering (function form). */
|
|
10
21
|
render?: RenderProp<ComponentPropsWithRef<"p">, DialogDescriptionState>;
|
|
11
22
|
}
|
|
12
23
|
/**
|
|
13
24
|
* The dialog's description: a `<p>` whose id the Popup references with `aria-describedby`.
|
|
14
25
|
*
|
|
15
26
|
* Owned key (conventions 1.2): `id`.
|
|
27
|
+
*
|
|
28
|
+
* @see https://ui.funstack.work/components/dialog
|
|
16
29
|
*/
|
|
17
|
-
export declare function DialogDescription(
|
|
30
|
+
export declare function DialogDescription(props: DialogDescriptionProps): ReactNode;
|
|
18
31
|
export declare namespace DialogDescription {
|
|
19
32
|
var displayName: string;
|
|
20
33
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dialog-description.d.mts","names":[],"sources":["../../src/dialog/dialog-description.tsx"],"mappings":"
|
|
1
|
+
{"version":3,"file":"dialog-description.d.mts","names":[],"sources":["../../src/dialog/dialog-description.tsx"],"mappings":";;;;;;YASY,yBAAyB;;;;;;iBAOpB,+BAA+B,KAC9C;;EAIA,YAAY,+BAA+B;;EAE3C,QAAQ,WAAW,2BAA2B;;EAE9C,WAAW,WAAW,WAAW;;EAEjC,SAAS,WAAW,4BAA4B;;;;;;;;;wBAUlC,kBAAkB,OAAO,yBAAsB;yBAA/C"}
|
|
@@ -6,9 +6,16 @@ import { useDialogContext } from "./dialog-context.mjs";
|
|
|
6
6
|
* The dialog's description: a `<p>` whose id the Popup references with `aria-describedby`.
|
|
7
7
|
*
|
|
8
8
|
* Owned key (conventions 1.2): `id`.
|
|
9
|
+
*
|
|
10
|
+
* @see https://ui.funstack.work/components/dialog
|
|
9
11
|
*/
|
|
10
|
-
function DialogDescription(
|
|
11
|
-
|
|
12
|
+
function DialogDescription(props) {
|
|
13
|
+
return useDialogDescription(props, "Dialog");
|
|
14
|
+
}
|
|
15
|
+
DialogDescription.displayName = "DialogDescription";
|
|
16
|
+
/** The body of `Dialog.Description`, also run by `AlertDialog.Description` (alert-dialog.md 8). */
|
|
17
|
+
function useDialogDescription({ className, style, children, render, ...rest }, namespace) {
|
|
18
|
+
const ctx = useDialogContext(`${namespace}.Description`);
|
|
12
19
|
const state = {
|
|
13
20
|
open: ctx.committed,
|
|
14
21
|
modal: ctx.modal
|
|
@@ -24,8 +31,7 @@ function DialogDescription({ className, style, children, render, ...rest }) {
|
|
|
24
31
|
libraryProps: { id: ctx.ids.description }
|
|
25
32
|
});
|
|
26
33
|
}
|
|
27
|
-
DialogDescription.displayName = "DialogDescription";
|
|
28
34
|
//#endregion
|
|
29
|
-
export { DialogDescription };
|
|
35
|
+
export { DialogDescription, useDialogDescription };
|
|
30
36
|
|
|
31
37
|
//# sourceMappingURL=dialog-description.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dialog-description.mjs","names":[],"sources":["../../src/dialog/dialog-description.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 DialogDescriptionState = DialogPopupState;\n\nexport interface DialogDescriptionProps extends Omit<\n ComponentPropsWithRef<\"p\">,\n \"id\" | \"className\" | \"style\" | \"children\"\n> {\n className?: StateValue<string | undefined, DialogDescriptionState>;\n style?: StateValue<CSSProperties | undefined, DialogDescriptionState>;\n children?: StateValue<ReactNode, DialogDescriptionState>;\n render?: RenderProp<ComponentPropsWithRef<\"p\">, DialogDescriptionState>;\n}\n\n/**\n * The dialog's description: a `<p>` whose id the Popup references with `aria-describedby`.\n *\n * Owned key (conventions 1.2): `id`.\n */\nexport function DialogDescription({\n
|
|
1
|
+
{"version":3,"file":"dialog-description.mjs","names":[],"sources":["../../src/dialog/dialog-description.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.Description`: the Popup's state. */\nexport type DialogDescriptionState = DialogPopupState;\n\n/**\n * Props of `Dialog.Description`.\n *\n * @see https://ui.funstack.work/components/dialog\n */\nexport interface DialogDescriptionProps extends Omit<\n ComponentPropsWithRef<\"p\">,\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, DialogDescriptionState>;\n /** Inline style, or a function of the part's state that returns one. */\n style?: StateValue<CSSProperties | undefined, DialogDescriptionState>;\n /** Content, or a function of the part's state. */\n children?: StateValue<ReactNode, DialogDescriptionState>;\n /** Replace the default `<p>` (element form) or take over rendering (function form). */\n render?: RenderProp<ComponentPropsWithRef<\"p\">, DialogDescriptionState>;\n}\n\n/**\n * The dialog's description: a `<p>` whose id the Popup references with `aria-describedby`.\n *\n * Owned key (conventions 1.2): `id`.\n *\n * @see https://ui.funstack.work/components/dialog\n */\nexport function DialogDescription(props: DialogDescriptionProps) {\n return useDialogDescription(props, \"Dialog\");\n}\n\nDialogDescription.displayName = \"DialogDescription\";\n\n/** The body of `Dialog.Description`, also run by `AlertDialog.Description` (alert-dialog.md 8). */\nexport function useDialogDescription(\n { className, style, children, render, ...rest }: DialogDescriptionProps,\n namespace: DialogNamespace,\n): ReactNode {\n const ctx = useDialogContext(`${namespace}.Description`);\n const state: DialogDescriptionState = { open: ctx.committed, modal: ctx.modal };\n return useRender<ComponentPropsWithRef<\"p\">, DialogDescriptionState>({\n defaultElement: \"p\",\n render,\n state,\n className,\n style,\n children,\n props: rest,\n libraryProps: { id: ctx.ids.description },\n });\n}\n"],"mappings":";;;;;;;;;;;AAqCA,SAAgB,kBAAkB,OAA+B;CAC/D,OAAO,qBAAqB,OAAO,QAAQ;AAC7C;AAEA,kBAAkB,cAAc;;AAGhC,SAAgB,qBACd,EAAE,WAAW,OAAO,UAAU,QAAQ,GAAG,QACzC,WACW;CACX,MAAM,MAAM,iBAAiB,GAAG,UAAU,aAAa;CACvD,MAAM,QAAgC;EAAE,MAAM,IAAI;EAAW,OAAO,IAAI;CAAM;CAC9E,OAAO,UAA8D;EACnE,gBAAgB;EAChB;EACA;EACA;EACA;EACA;EACA,OAAO;EACP,cAAc,EAAE,IAAI,IAAI,IAAI,YAAY;CAC1C,CAAC;AACH"}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import { isPopoverOpen } from "../internal/overlay/popover-open.mjs";
|
|
2
|
+
//#region src/dialog/dialog-dismiss.ts
|
|
3
|
+
/** The nearest `<dialog>` around a node (the dialog itself counts). */
|
|
4
|
+
function closestDialog(target) {
|
|
5
|
+
return target instanceof Element ? target.closest("dialog") : null;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* An open popover that takes Escape before the dialog: `auto` or `hint` (they have a close
|
|
9
|
+
* watcher). A `manual` popover, or `hint` where the engine maps it to `manual`, does not.
|
|
10
|
+
*/
|
|
11
|
+
function isOpenLightPopover(element) {
|
|
12
|
+
if (!element.hasAttribute("popover")) return false;
|
|
13
|
+
const reflected = element.popover;
|
|
14
|
+
if ((typeof reflected === "string" ? reflected : element.getAttribute("popover").toLowerCase()) === "manual") return false;
|
|
15
|
+
return isPopoverOpen(element);
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Whether Escape belongs to a layer inside `dialog` that sits above it (design 9: "closes the
|
|
19
|
+
* innermost one only"): the target is inside an open nested `<dialog>` or popover, or an open
|
|
20
|
+
* `auto` / `hint` popover inside the dialog would take the close request (close watchers are
|
|
21
|
+
* per document, not per focus).
|
|
22
|
+
*/
|
|
23
|
+
function escapeBelongsToInnerLayer(dialog, target) {
|
|
24
|
+
for (let node = target instanceof Element ? target : null; node !== null && node !== dialog; node = node.parentElement) {
|
|
25
|
+
if (node instanceof HTMLDialogElement && node.open) return true;
|
|
26
|
+
if (isOpenLightPopover(node)) return true;
|
|
27
|
+
}
|
|
28
|
+
for (const element of dialog.querySelectorAll("[popover]")) if (isOpenLightPopover(element)) return true;
|
|
29
|
+
return false;
|
|
30
|
+
}
|
|
31
|
+
/** Whether a pointer event on the dialog itself lies outside its border box (the `::backdrop`). */
|
|
32
|
+
function onBackdrop(dialog, event) {
|
|
33
|
+
if (event.target !== dialog) return false;
|
|
34
|
+
const { clientX, clientY } = event;
|
|
35
|
+
const rect = dialog.getBoundingClientRect();
|
|
36
|
+
return !(rect.top <= clientY && clientY <= rect.bottom && rect.left <= clientX && clientX <= rect.right);
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Installs the JS dismissals of `dialog` and returns their cleanup: Escape for a non-modal
|
|
40
|
+
* dialog, and with `lightDismiss` a click outside (on the backdrop for a modal dialog). Each
|
|
41
|
+
* calls `dialog.requestClose()`, so the close is the browser's, a fact (conventions 3.9.2).
|
|
42
|
+
* Not for a dialog where native `closedby` is in use.
|
|
43
|
+
*/
|
|
44
|
+
function listenDialogDismiss(dialog, { modal, lightDismiss }) {
|
|
45
|
+
const doc = dialog.ownerDocument;
|
|
46
|
+
const listeners = [];
|
|
47
|
+
if (!modal) listeners.push(["keydown", (event) => {
|
|
48
|
+
const keyboardEvent = event;
|
|
49
|
+
if (keyboardEvent.key !== "Escape" || keyboardEvent.defaultPrevented) return;
|
|
50
|
+
if (!dialog.open || closestDialog(keyboardEvent.target) !== dialog) return;
|
|
51
|
+
if (escapeBelongsToInnerLayer(dialog, keyboardEvent.target)) return;
|
|
52
|
+
keyboardEvent.preventDefault();
|
|
53
|
+
dialog.requestClose();
|
|
54
|
+
}]);
|
|
55
|
+
let pressedOutside = false;
|
|
56
|
+
const isOutside = (target) => {
|
|
57
|
+
return !(target instanceof Node) || !dialog.contains(target);
|
|
58
|
+
};
|
|
59
|
+
let outsideAttached = false;
|
|
60
|
+
const onOutsidePointerDown = (event) => {
|
|
61
|
+
pressedOutside = dialog.open && isOutside(event.target);
|
|
62
|
+
};
|
|
63
|
+
const onOutsideClick = (event) => {
|
|
64
|
+
const pressed = pressedOutside;
|
|
65
|
+
pressedOutside = false;
|
|
66
|
+
if (!dialog.open || !pressed || !isOutside(event.target)) return;
|
|
67
|
+
dialog.requestClose();
|
|
68
|
+
};
|
|
69
|
+
const syncOutside = () => {
|
|
70
|
+
const want = dialog.open;
|
|
71
|
+
if (want === outsideAttached) return;
|
|
72
|
+
outsideAttached = want;
|
|
73
|
+
pressedOutside = false;
|
|
74
|
+
if (want) {
|
|
75
|
+
doc.addEventListener("pointerdown", onOutsidePointerDown, true);
|
|
76
|
+
doc.addEventListener("click", onOutsideClick, true);
|
|
77
|
+
} else {
|
|
78
|
+
doc.removeEventListener("pointerdown", onOutsidePointerDown, true);
|
|
79
|
+
doc.removeEventListener("click", onOutsideClick, true);
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
if (lightDismiss) {
|
|
83
|
+
if (modal) listeners.push(["pointerdown", (event) => {
|
|
84
|
+
pressedOutside = dialog.open && onBackdrop(dialog, event);
|
|
85
|
+
}], ["click", (event) => {
|
|
86
|
+
const pressed = pressedOutside;
|
|
87
|
+
pressedOutside = false;
|
|
88
|
+
if (!dialog.open || !pressed || !onBackdrop(dialog, event)) return;
|
|
89
|
+
dialog.requestClose();
|
|
90
|
+
}]);
|
|
91
|
+
else {
|
|
92
|
+
listeners.push(["toggle", syncOutside]);
|
|
93
|
+
syncOutside();
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
for (const [type, listener] of listeners) dialog.addEventListener(type, listener);
|
|
97
|
+
return () => {
|
|
98
|
+
for (const [type, listener] of listeners) dialog.removeEventListener(type, listener);
|
|
99
|
+
if (outsideAttached) {
|
|
100
|
+
doc.removeEventListener("pointerdown", onOutsidePointerDown, true);
|
|
101
|
+
doc.removeEventListener("click", onOutsideClick, true);
|
|
102
|
+
}
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
//#endregion
|
|
106
|
+
export { listenDialogDismiss };
|
|
107
|
+
|
|
108
|
+
//# sourceMappingURL=dialog-dismiss.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dialog-dismiss.mjs","names":[],"sources":["../../src/dialog/dialog-dismiss.ts"],"sourcesContent":["// Dialog's JS baseline for what the platform gives only behind `closedby`: Escape on a\n// non-modal dialog and light dismiss (design/components/dialog.md 2.6). No \"use client\"\n// directive: DOM listeners only (conventions 7.1).\nimport { isPopoverOpen } from \"../internal/overlay/popover-open.js\";\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 return isPopoverOpen(element);\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\nexport interface DialogDismissOptions {\n /** The Root's `modal`. A modal dialog has the platform's close watcher Escape. */\n readonly modal: boolean;\n /** The Popup's `lightDismiss`. */\n readonly lightDismiss: boolean;\n}\n\n/**\n * Installs the JS dismissals of `dialog` and returns their cleanup: Escape for a non-modal\n * dialog, and with `lightDismiss` a click outside (on the backdrop for a modal dialog). Each\n * calls `dialog.requestClose()`, so the close is the browser's, a fact (conventions 3.9.2).\n * Not for a dialog where native `closedby` is in use.\n */\nexport function listenDialogDismiss(\n dialog: HTMLDialogElement,\n { modal, lightDismiss }: DialogDismissOptions,\n): () => void {\n const doc = dialog.ownerDocument;\n const listeners: [string, EventListener][] = [];\n\n if (!modal) {\n // Non-modal dialogs get no close watcher Escape from the platform (design 2.6).\n listeners.push([\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 ]);\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 // The Trigger counts as outside, as native `closedby=\"any\"` treats it.\n return !(target instanceof Node) || !dialog.contains(target);\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) {\n if (modal) {\n // A press or click on the ::backdrop targets the dialog itself, outside its border box.\n listeners.push(\n [\n \"pointerdown\",\n (event) => {\n pressedOutside = dialog.open && onBackdrop(dialog, event);\n },\n ],\n [\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 ],\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([\"toggle\", syncOutside]);\n syncOutside();\n }\n }\n\n for (const [type, listener] of listeners) dialog.addEventListener(type, listener);\n return () => {\n for (const [type, listener] of listeners) dialog.removeEventListener(type, listener);\n if (outsideAttached) {\n doc.removeEventListener(\"pointerdown\", onOutsidePointerDown, true);\n doc.removeEventListener(\"click\", onOutsideClick, true);\n }\n };\n}\n"],"mappings":";;;AAMA,SAAS,cAAc,QAA4C;CACjE,OAAO,kBAAkB,UAAU,OAAO,QAAQ,QAAQ,IAAI;AAChE;;;;;AAMA,SAAS,mBAAmB,SAA2B;CACrD,IAAI,CAAC,QAAQ,aAAa,SAAS,GAAG,OAAO;CAE7C,MAAM,YAAsB,QAAwB;CAGpD,KADE,OAAO,cAAc,WAAW,YAAY,QAAQ,aAAa,SAAS,CAAC,CAAE,YAAY,OAC7E,UAAU,OAAO;CAC/B,OAAO,cAAc,OAAO;AAC9B;;;;;;;AAQA,SAAS,0BAA0B,QAA2B,QAAqC;CACjG,KACE,IAAI,OAAO,kBAAkB,UAAU,SAAS,MAChD,SAAS,QAAQ,SAAS,QAC1B,OAAO,KAAK,eACZ;EACA,IAAI,gBAAgB,qBAAqB,KAAK,MAAM,OAAO;EAC3D,IAAI,mBAAmB,IAAI,GAAG,OAAO;CACvC;CACA,KAAK,MAAM,WAAW,OAAO,iBAAiB,WAAW,GACvD,IAAI,mBAAmB,OAAO,GAAG,OAAO;CAE1C,OAAO;AACT;;AAGA,SAAS,WAAW,QAA2B,OAAuB;CACpE,IAAI,MAAM,WAAW,QAAQ,OAAO;CACpC,MAAM,EAAE,SAAS,YAAY;CAC7B,MAAM,OAAO,OAAO,sBAAsB;CAC1C,OAAO,EACL,KAAK,OAAO,WACZ,WAAW,KAAK,UAChB,KAAK,QAAQ,WACb,WAAW,KAAK;AAEpB;;;;;;;AAeA,SAAgB,oBACd,QACA,EAAE,OAAO,gBACG;CACZ,MAAM,MAAM,OAAO;CACnB,MAAM,YAAuC,CAAC;CAE9C,IAAI,CAAC,OAEH,UAAU,KAAK,CACb,YACC,UAAU;EACT,MAAM,gBAAgB;EACtB,IAAI,cAAc,QAAQ,YAAY,cAAc,kBAAkB;EACtE,IAAI,CAAC,OAAO,QAAQ,cAAc,cAAc,MAAM,MAAM,QAAQ;EAGpE,IAAI,0BAA0B,QAAQ,cAAc,MAAM,GAAG;EAC7D,cAAc,eAAe;EAC7B,OAAO,aAAa;CACtB,CACF,CAAC;CAMH,IAAI,iBAAiB;CAErB,MAAM,aAAa,WAAwC;EAEzD,OAAO,EAAE,kBAAkB,SAAS,CAAC,OAAO,SAAS,MAAM;CAC7D;CACA,IAAI,kBAAkB;CACtB,MAAM,wBAAwB,UAAiB;EAC7C,iBAAiB,OAAO,QAAQ,UAAU,MAAM,MAAM;CACxD;CACA,MAAM,kBAAkB,UAAiB;EACvC,MAAM,UAAU;EAChB,iBAAiB;EACjB,IAAI,CAAC,OAAO,QAAQ,CAAC,WAAW,CAAC,UAAU,MAAM,MAAM,GAAG;EAC1D,OAAO,aAAa;CACtB;CACA,MAAM,oBAAoB;EACxB,MAAM,OAAO,OAAO;EACpB,IAAI,SAAS,iBAAiB;EAC9B,kBAAkB;EAClB,iBAAiB;EACjB,IAAI,MAAM;GACR,IAAI,iBAAiB,eAAe,sBAAsB,IAAI;GAC9D,IAAI,iBAAiB,SAAS,gBAAgB,IAAI;EACpD,OAAO;GACL,IAAI,oBAAoB,eAAe,sBAAsB,IAAI;GACjE,IAAI,oBAAoB,SAAS,gBAAgB,IAAI;EACvD;CACF;CAEA,IAAI,cAAc;EAChB,IAAI,OAEF,UAAU,KACR,CACE,gBACC,UAAU;GACT,iBAAiB,OAAO,QAAQ,WAAW,QAAQ,KAAK;EAC1D,CACF,GACA,CACE,UACC,UAAU;GACT,MAAM,UAAU;GAChB,iBAAiB;GACjB,IAAI,CAAC,OAAO,QAAQ,CAAC,WAAW,CAAC,WAAW,QAAQ,KAAK,GAAG;GAC5D,OAAO,aAAa;EACtB,CACF,CACF;OACK;GAIL,UAAU,KAAK,CAAC,UAAU,WAAW,CAAC;GACtC,YAAY;EACd;CACF;CAEA,KAAK,MAAM,CAAC,MAAM,aAAa,WAAW,OAAO,iBAAiB,MAAM,QAAQ;CAChF,aAAa;EACX,KAAK,MAAM,CAAC,MAAM,aAAa,WAAW,OAAO,oBAAoB,MAAM,QAAQ;EACnF,IAAI,iBAAiB;GACnB,IAAI,oBAAoB,eAAe,sBAAsB,IAAI;GACjE,IAAI,oBAAoB,SAAS,gBAAgB,IAAI;EACvD;CACF;AACF"}
|
|
@@ -1,30 +1,53 @@
|
|
|
1
1
|
import { RenderProp, StateValue } from "../internal/types.mjs";
|
|
2
|
+
import "./dialog-context.mjs";
|
|
2
3
|
import { CSSProperties, ComponentPropsWithRef, ReactNode } from "react";
|
|
3
4
|
//#region src/dialog/dialog-form.d.ts
|
|
5
|
+
/**
|
|
6
|
+
* State of `Dialog.Form`, passed to the function forms of `className`, `style`, `children` and
|
|
7
|
+
* `render`.
|
|
8
|
+
*/
|
|
4
9
|
export interface DialogFormState {
|
|
5
10
|
/** `useFormStatus().pending` of this form, exposed for `className` / `children` functions. */
|
|
6
11
|
readonly pending: boolean;
|
|
7
12
|
}
|
|
13
|
+
/**
|
|
14
|
+
* Props of `Dialog.Form`.
|
|
15
|
+
*
|
|
16
|
+
* @see https://ui.funstack.work/components/dialog
|
|
17
|
+
*/
|
|
8
18
|
export interface DialogFormProps extends Omit<ComponentPropsWithRef<"form">, "method" | "action" | "className" | "style" | "children"> {
|
|
9
19
|
/**
|
|
10
20
|
* React form action (`(formData) => unknown`, may be a Server Function). Passed to the form
|
|
11
21
|
* unwrapped so React's progressive enhancement is kept; the dialog closes with the submitter's
|
|
12
|
-
* `value` as `returnValue` once the action's transition settles (see `closeOnSettle`)
|
|
13
|
-
*
|
|
14
|
-
*
|
|
22
|
+
* `value` as `returnValue` once the action's transition settles (see `closeOnSettle`): in
|
|
23
|
+
* library mode through the Root (`openChangeAction(false)` awaited, view transition if set),
|
|
24
|
+
* in JS-free mode with `close(value)`. A rejection leaves the dialog open. Without `action`
|
|
25
|
+
* the form renders `method="dialog"`: submitting closes the dialog, natively in JS-free mode
|
|
26
|
+
* and through the Root in library mode (a `preventDefault()` in your own `onSubmit` blocks
|
|
27
|
+
* both; `stopPropagation()` there leaves the close to the browser, reported to `onOpenChange`
|
|
28
|
+
* as a fact).
|
|
29
|
+
* A string `action` (a URL) is a plain navigating form.
|
|
15
30
|
*/
|
|
16
31
|
action?: string | ((formData: FormData) => unknown);
|
|
17
32
|
/**
|
|
18
33
|
* With a function `action`: close the dialog once the action's transition settles without
|
|
19
|
-
* throwing
|
|
34
|
+
* throwing and, when this form is rendered as a `Form.Root`
|
|
35
|
+
* (`render={<Form.Root errors={state.errors} />}`), with no field error: a settle whose
|
|
36
|
+
* `errors` has a non-empty entry (hidden stale ones included, the `autoReset` rule) keeps
|
|
37
|
+
* the dialog open and the Form focuses the first errored field.
|
|
20
38
|
*
|
|
21
|
-
*
|
|
22
|
-
* that reports
|
|
23
|
-
*
|
|
24
|
-
* a `Dialog.Close`, a
|
|
39
|
+
* Without a `Form.Root` the library never sees a result, so any settle that does not throw
|
|
40
|
+
* counts, including a `useActionState` result that reports errors: render the form as a
|
|
41
|
+
* `Form.Root` to route them, throw to keep the dialog open, or set `closeOnSettle={false}`
|
|
42
|
+
* and close it yourself (a `Dialog.Close`, a submit button in a separate `method="dialog"`
|
|
43
|
+
* form, or a controlled `open`). A `formMethod="dialog"` submitter inside this form cannot
|
|
44
|
+
* close it: React prevents every submit of a form with a function `action` and runs the
|
|
45
|
+
* action again.
|
|
25
46
|
*
|
|
26
47
|
* The dialog is not closed either when it was closed (Escape, a Close part) while the action
|
|
27
48
|
* ran, also if the user re-opened it meanwhile.
|
|
49
|
+
*
|
|
50
|
+
* @defaultValue `true`
|
|
28
51
|
*/
|
|
29
52
|
closeOnSettle?: boolean;
|
|
30
53
|
/**
|
|
@@ -32,25 +55,34 @@ export interface DialogFormProps extends Omit<ComponentPropsWithRef<"form">, "me
|
|
|
32
55
|
* `"dialog"` without `action`, React's own with a function `action`.
|
|
33
56
|
*/
|
|
34
57
|
method?: ComponentPropsWithRef<"form">["method"];
|
|
58
|
+
/** Class name, or a function of the part's state that returns one. */
|
|
35
59
|
className?: StateValue<string | undefined, DialogFormState>;
|
|
60
|
+
/** Inline style, or a function of the part's state that returns one. */
|
|
36
61
|
style?: StateValue<CSSProperties | undefined, DialogFormState>;
|
|
62
|
+
/** Content, or a function of the part's state. */
|
|
37
63
|
children?: StateValue<ReactNode, DialogFormState>;
|
|
64
|
+
/** Replace the default `<form>` (element form) or take over rendering (function form). */
|
|
38
65
|
render?: RenderProp<ComponentPropsWithRef<"form">, DialogFormState>;
|
|
39
66
|
}
|
|
40
67
|
/**
|
|
41
68
|
* A form that completes the dialog. Without `action`: `<form method="dialog">`, so a submit
|
|
42
|
-
* closes the dialog
|
|
69
|
+
* closes the dialog with the submitter's `value` as `returnValue` (natively in JS-free mode;
|
|
70
|
+
* in library mode the Popup cancels the submission and closes through the Root). With a
|
|
43
71
|
* function `action`: `<form action={action}>` (React overrides the method) and a status watcher
|
|
44
72
|
* that closes the dialog once the action has settled, with the submitter's `value`, unless
|
|
45
|
-
* `closeOnSettle` is `false
|
|
73
|
+
* `closeOnSettle` is `false`, the dialog was closed while the action ran, or the form is rendered
|
|
74
|
+
* as a `Form.Root` and the result has a field error (`render={<Form.Root errors={...} />}`, the
|
|
75
|
+
* recommended composition for validation).
|
|
46
76
|
*
|
|
47
77
|
* `DialogFormState.pending` is this form's own status; it is not emitted as `data-pending` and
|
|
48
78
|
* is not folded into any control's `pending` (conventions 2.7). Submit buttons read
|
|
49
79
|
* `useFormStatus()` themselves.
|
|
50
80
|
*
|
|
51
81
|
* Owned keys (conventions 1.2): `method` (except with a string `action`), `action`.
|
|
82
|
+
*
|
|
83
|
+
* @see https://ui.funstack.work/components/dialog
|
|
52
84
|
*/
|
|
53
|
-
export declare function DialogForm(
|
|
85
|
+
export declare function DialogForm(props: DialogFormProps): ReactNode;
|
|
54
86
|
export declare namespace DialogForm {
|
|
55
87
|
var displayName: string;
|
|
56
88
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dialog-form.d.mts","names":[],"sources":["../../src/dialog/dialog-form.tsx"],"mappings":"
|
|
1
|
+
{"version":3,"file":"dialog-form.d.mts","names":[],"sources":["../../src/dialog/dialog-form.tsx"],"mappings":";;;;;;;;iBAkBiB;;WAEN;;;;;;;iBAQM,wBAAwB,KACvC;;;;;;;;;;;;;EAeA,oBAAoB,UAAU;;;;;;;;;;;;;;;;;;;;;EAqB9B;;;;;EAKA,SAAS;;EAET,YAAY,+BAA+B;;EAE3C,QAAQ,WAAW,2BAA2B;;EAE9C,WAAW,WAAW,WAAW;;EAEjC,SAAS,WAAW,+BAA+B;;;;;;;;;;;;;;;;;;;;wBAqBrC,WAAW,OAAO,kBAAe;yBAAjC"}
|
|
@@ -1,47 +1,42 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import {
|
|
2
|
+
import { useDevWarning } from "../internal/use-dev-warning.mjs";
|
|
3
|
+
import { resolveStateValue } from "../internal/render-element.mjs";
|
|
4
|
+
import { useRender } from "../internal/use-render.mjs";
|
|
5
|
+
import { FormContext } from "../internal/form/field-context.mjs";
|
|
3
6
|
import { useDialogContext } from "./dialog-context.mjs";
|
|
4
|
-
import {
|
|
7
|
+
import { FormStatusWatcher } from "../internal/form/form-status-watcher.mjs";
|
|
8
|
+
import { hasAnyError } from "../internal/form/validity.mjs";
|
|
9
|
+
import { use, useCallback, useRef, useState } from "react";
|
|
5
10
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
6
|
-
import { useFormStatus } from "react-dom";
|
|
7
11
|
//#region src/dialog/dialog-form.tsx
|
|
8
|
-
|
|
9
|
-
* Observes React's form channel (design 8.1): `useFormStatus().pending` covers the action's
|
|
10
|
-
* whole transition, including the Suspense wait of what it re-renders. On `true → false` the
|
|
11
|
-
* submission succeeded (a rejection unmounts the form through the nearest Error Boundary, so the
|
|
12
|
-
* edge is never seen).
|
|
13
|
-
*/
|
|
14
|
-
function FormStatusWatcher({ onPendingChange, onSettled }) {
|
|
15
|
-
const { pending } = useFormStatus();
|
|
16
|
-
const previous = useRef(false);
|
|
17
|
-
useEffect(() => {
|
|
18
|
-
const was = previous.current;
|
|
19
|
-
previous.current = pending;
|
|
20
|
-
if (was === pending) return;
|
|
21
|
-
onPendingChange(pending);
|
|
22
|
-
if (was && !pending) onSettled();
|
|
23
|
-
}, [
|
|
24
|
-
pending,
|
|
25
|
-
onPendingChange,
|
|
26
|
-
onSettled
|
|
27
|
-
]);
|
|
28
|
-
return null;
|
|
29
|
-
}
|
|
12
|
+
const isDev = process.env.NODE_ENV !== "production";
|
|
30
13
|
/**
|
|
31
14
|
* A form that completes the dialog. Without `action`: `<form method="dialog">`, so a submit
|
|
32
|
-
* closes the dialog
|
|
15
|
+
* closes the dialog with the submitter's `value` as `returnValue` (natively in JS-free mode;
|
|
16
|
+
* in library mode the Popup cancels the submission and closes through the Root). With a
|
|
33
17
|
* function `action`: `<form action={action}>` (React overrides the method) and a status watcher
|
|
34
18
|
* that closes the dialog once the action has settled, with the submitter's `value`, unless
|
|
35
|
-
* `closeOnSettle` is `false
|
|
19
|
+
* `closeOnSettle` is `false`, the dialog was closed while the action ran, or the form is rendered
|
|
20
|
+
* as a `Form.Root` and the result has a field error (`render={<Form.Root errors={...} />}`, the
|
|
21
|
+
* recommended composition for validation).
|
|
36
22
|
*
|
|
37
23
|
* `DialogFormState.pending` is this form's own status; it is not emitted as `data-pending` and
|
|
38
24
|
* is not folded into any control's `pending` (conventions 2.7). Submit buttons read
|
|
39
25
|
* `useFormStatus()` themselves.
|
|
40
26
|
*
|
|
41
27
|
* Owned keys (conventions 1.2): `method` (except with a string `action`), `action`.
|
|
28
|
+
*
|
|
29
|
+
* @see https://ui.funstack.work/components/dialog
|
|
42
30
|
*/
|
|
43
|
-
function DialogForm(
|
|
44
|
-
|
|
31
|
+
function DialogForm(props) {
|
|
32
|
+
return useDialogForm(props, "Dialog");
|
|
33
|
+
}
|
|
34
|
+
DialogForm.displayName = "DialogForm";
|
|
35
|
+
/** The body of `Dialog.Form`, also run by `AlertDialog.Form` (alert-dialog.md 8). */
|
|
36
|
+
function useDialogForm({ action, closeOnSettle = true, method, className, style, children, render, ...rest }, namespace) {
|
|
37
|
+
const ctx = useDialogContext(`${namespace}.Form`);
|
|
38
|
+
const { popupRef, recordCloseIntent, requestClose } = ctx;
|
|
39
|
+
const isLibrary = ctx.mode === "library";
|
|
45
40
|
const [pending, setPending] = useState(false);
|
|
46
41
|
const submission = useRef(null);
|
|
47
42
|
const closedSinceSubmit = useRef(false);
|
|
@@ -67,21 +62,29 @@ function DialogForm({ action, closeOnSettle = true, method, className, style, ch
|
|
|
67
62
|
dialog?.removeEventListener("close", onClose);
|
|
68
63
|
};
|
|
69
64
|
}, []);
|
|
70
|
-
const onSettled = useCallback(() => {
|
|
71
|
-
const dialog =
|
|
65
|
+
const onSettled = useCallback((clean) => {
|
|
66
|
+
const dialog = popupRef.current;
|
|
72
67
|
const submitted = submission.current;
|
|
73
68
|
submission.current = null;
|
|
74
69
|
if (!closeOnSettle || closedSinceSubmit.current) return;
|
|
70
|
+
if (!clean) return;
|
|
75
71
|
if (dialog === null || !dialog.open) return;
|
|
72
|
+
const returnValue = submitted?.returnValue ?? "";
|
|
73
|
+
if (isLibrary) {
|
|
74
|
+
requestClose(submitted?.event, "activate", returnValue);
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
76
77
|
recordCloseIntent({
|
|
77
78
|
reason: "activate",
|
|
78
79
|
event: submitted?.event
|
|
79
80
|
});
|
|
80
|
-
dialog.close(
|
|
81
|
+
dialog.close(returnValue);
|
|
81
82
|
}, [
|
|
82
83
|
closeOnSettle,
|
|
83
|
-
|
|
84
|
-
|
|
84
|
+
popupRef,
|
|
85
|
+
isLibrary,
|
|
86
|
+
recordCloseIntent,
|
|
87
|
+
requestClose
|
|
85
88
|
]);
|
|
86
89
|
return useRender({
|
|
87
90
|
defaultElement: "form",
|
|
@@ -89,7 +92,10 @@ function DialogForm({ action, closeOnSettle = true, method, className, style, ch
|
|
|
89
92
|
state: { pending },
|
|
90
93
|
className,
|
|
91
94
|
style,
|
|
92
|
-
children: (s) => /* @__PURE__ */ jsxs(Fragment, { children: [resolveStateValue(children, s),
|
|
95
|
+
children: (s) => /* @__PURE__ */ jsxs(Fragment, { children: [resolveStateValue(children, s), /* @__PURE__ */ jsx(DialogFormSettle, {
|
|
96
|
+
namespace,
|
|
97
|
+
watches,
|
|
98
|
+
missingAction: action === void 0,
|
|
93
99
|
onPendingChange: setPending,
|
|
94
100
|
onSettled
|
|
95
101
|
})] }),
|
|
@@ -101,8 +107,29 @@ function DialogForm({ action, closeOnSettle = true, method, className, style, ch
|
|
|
101
107
|
ref: libraryRef
|
|
102
108
|
});
|
|
103
109
|
}
|
|
104
|
-
|
|
110
|
+
/**
|
|
111
|
+
* Rendered among the form's children, so it reads the `FormContext` exactly when the form is a
|
|
112
|
+
* `Form.Root` (either orientation of the `render` composition): the settle close then waits for
|
|
113
|
+
* a result with no field error (`hasAnyError`, the `autoReset` predicate, hidden stale entries
|
|
114
|
+
* included).
|
|
115
|
+
*/
|
|
116
|
+
function DialogFormSettle({ namespace, watches, missingAction, onPendingChange, onSettled }) {
|
|
117
|
+
const form = use(FormContext);
|
|
118
|
+
useDevWarning(form !== null && missingAction, isDev && `${namespace}.Form: rendered as a \`Form.Root\`, it needs a function \`action\`; without one the form navigates instead of closing the dialog. Render a plain \`<${namespace}.Form>\` for a \`method="dialog"\` form.`);
|
|
119
|
+
const isForm = form !== null;
|
|
120
|
+
const errors = form?.errors;
|
|
121
|
+
const settled = useCallback(() => onSettled(!isForm || !hasAnyError(errors)), [
|
|
122
|
+
isForm,
|
|
123
|
+
errors,
|
|
124
|
+
onSettled
|
|
125
|
+
]);
|
|
126
|
+
if (!watches) return null;
|
|
127
|
+
return /* @__PURE__ */ jsx(FormStatusWatcher, {
|
|
128
|
+
onPendingChange,
|
|
129
|
+
onSettled: settled
|
|
130
|
+
});
|
|
131
|
+
}
|
|
105
132
|
//#endregion
|
|
106
|
-
export { DialogForm };
|
|
133
|
+
export { DialogForm, useDialogForm };
|
|
107
134
|
|
|
108
135
|
//# sourceMappingURL=dialog-form.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dialog-form.mjs","names":[],"sources":["../../src/dialog/dialog-form.tsx"],"sourcesContent":["\"use client\";\nimport { useCallback, useEffect, useRef, useState } from \"react\";\nimport type { ComponentPropsWithRef, CSSProperties, ReactNode } from \"react\";\nimport { useFormStatus } from \"react-dom\";\nimport type { RenderProp, StateValue } from \"../internal/types.js\";\nimport { resolveStateValue, useRender } from \"../internal/use-render.js\";\nimport { useDialogContext } from \"./dialog-context.js\";\n\nexport interface DialogFormState {\n /** `useFormStatus().pending` of this form, exposed for `className` / `children` functions. */\n readonly pending: boolean;\n}\n\nexport interface DialogFormProps extends Omit<\n ComponentPropsWithRef<\"form\">,\n \"method\" | \"action\" | \"className\" | \"style\" | \"children\"\n> {\n /**\n * React form action (`(formData) => unknown`, may be a Server Function). Passed to the form\n * unwrapped so React's progressive enhancement is kept; the dialog closes with the submitter's\n * `value` as `returnValue` once the action's transition settles (see `closeOnSettle`). A\n * rejection leaves the dialog open. Without `action` the form renders `method=\"dialog\"`:\n * submitting closes the dialog natively. A string `action` (a URL) is a plain navigating form.\n */\n action?: string | ((formData: FormData) => unknown);\n /**\n * With a function `action`: close the dialog once the action's transition settles without\n * throwing. Default `true`.\n *\n * Any result that does not throw counts as success, including a `useActionState`-style result\n * that reports validation errors: with the default the dialog closes and those errors are never\n * seen. Throw to keep the dialog open, or set `closeOnSettle={false}` and close it yourself:\n * a `Dialog.Close`, a submitter with `formMethod=\"dialog\"`, or a controlled `open`.\n *\n * The dialog is not closed either when it was closed (Escape, a Close part) while the action\n * ran, also if the user re-opened it meanwhile.\n */\n closeOnSettle?: boolean;\n /**\n * Only with a string `action` (a navigating form, for example `\"post\"`). Owned otherwise:\n * `\"dialog\"` without `action`, React's own with a function `action`.\n */\n method?: ComponentPropsWithRef<\"form\">[\"method\"];\n className?: StateValue<string | undefined, DialogFormState>;\n style?: StateValue<CSSProperties | undefined, DialogFormState>;\n children?: StateValue<ReactNode, DialogFormState>;\n render?: RenderProp<ComponentPropsWithRef<\"form\">, DialogFormState>;\n}\n\ninterface FormStatusWatcherProps {\n readonly onPendingChange: (pending: boolean) => void;\n readonly onSettled: () => void;\n}\n\n/**\n * Observes React's form channel (design 8.1): `useFormStatus().pending` covers the action's\n * whole transition, including the Suspense wait of what it re-renders. On `true → false` the\n * submission succeeded (a rejection unmounts the form through the nearest Error Boundary, so the\n * edge is never seen).\n */\nfunction FormStatusWatcher({ onPendingChange, onSettled }: FormStatusWatcherProps) {\n const { pending } = useFormStatus();\n const previous = useRef(false);\n useEffect(() => {\n const was = previous.current;\n previous.current = pending;\n if (was === pending) return;\n onPendingChange(pending);\n if (was && !pending) onSettled();\n }, [pending, onPendingChange, onSettled]);\n return null;\n}\n\n/**\n * A form that completes the dialog. Without `action`: `<form method=\"dialog\">`, so a submit\n * closes the dialog natively (JS-free) with the submitter's `value` as `returnValue`. With a\n * function `action`: `<form action={action}>` (React overrides the method) and a status watcher\n * that closes the dialog once the action has settled, with the submitter's `value`, unless\n * `closeOnSettle` is `false` or the dialog was closed while the action ran.\n *\n * `DialogFormState.pending` is this form's own status; it is not emitted as `data-pending` and\n * is not folded into any control's `pending` (conventions 2.7). Submit buttons read\n * `useFormStatus()` themselves.\n *\n * Owned keys (conventions 1.2): `method` (except with a string `action`), `action`.\n */\nexport function DialogForm({\n action,\n closeOnSettle = true,\n method,\n className,\n style,\n children,\n render,\n ...rest\n}: DialogFormProps) {\n const ctx = useDialogContext(\"Dialog.Form\");\n const { dialogRef, recordCloseIntent } = ctx;\n const [pending, setPending] = useState(false);\n const submission = useRef<{ event: Event; returnValue: string } | null>(null);\n // The dialog closed after the last submit (Escape, a Close part): the settle must not close it\n // again, also when the user re-opened it meanwhile (the review's walkthrough 11.8 variant).\n const closedSinceSubmit = useRef(false);\n const watches = typeof action === \"function\";\n\n // The submitter's `value` comes from the native `submit` event (capture, before React's\n // handler runs the action).\n const libraryRef = useCallback((form: HTMLFormElement) => {\n const onSubmit = (event: Event) => {\n if (event.target !== form) return;\n const submitter = (event as SubmitEvent).submitter as\n | HTMLButtonElement\n | HTMLInputElement\n | null;\n submission.current = { event, returnValue: submitter?.value ?? \"\" };\n closedSinceSubmit.current = false;\n };\n const dialog = form.closest(\"dialog\");\n const onClose = (event: Event) => {\n if (event.target === dialog) closedSinceSubmit.current = true;\n };\n form.addEventListener(\"submit\", onSubmit, true);\n dialog?.addEventListener(\"close\", onClose);\n return () => {\n form.removeEventListener(\"submit\", onSubmit, true);\n dialog?.removeEventListener(\"close\", onClose);\n };\n }, []);\n\n const onSettled = useCallback(() => {\n const dialog = dialogRef.current;\n const submitted = submission.current;\n submission.current = null;\n if (!closeOnSettle || closedSinceSubmit.current) return;\n if (dialog === null || !dialog.open) return;\n recordCloseIntent({ reason: \"activate\", event: submitted?.event });\n dialog.close(submitted?.returnValue ?? \"\");\n }, [closeOnSettle, dialogRef, recordCloseIntent]);\n\n const state: DialogFormState = { pending };\n\n return useRender<ComponentPropsWithRef<\"form\">, DialogFormState>({\n defaultElement: \"form\",\n render,\n state,\n className,\n style,\n children: (s) => (\n <>\n {resolveStateValue(children, s)}\n {watches && <FormStatusWatcher onPendingChange={setPending} onSettled={onSettled} />}\n </>\n ),\n props: rest,\n libraryProps: {\n method: action === undefined ? \"dialog\" : typeof action === \"string\" ? method : undefined,\n // React's own type wants `void | Promise<void>`; the library's actions return `unknown`\n // (conventions 2.2) and React ignores the result.\n action: action as ComponentPropsWithRef<\"form\">[\"action\"],\n },\n ref: libraryRef,\n });\n}\n\nDialogForm.displayName = \"DialogForm\";\n"],"mappings":";;;;;;;;;;;;;AA4DA,SAAS,kBAAkB,EAAE,iBAAiB,aAAqC;CACjF,MAAM,EAAE,YAAY,cAAc;CAClC,MAAM,WAAW,OAAO,KAAK;CAC7B,gBAAgB;EACd,MAAM,MAAM,SAAS;EACrB,SAAS,UAAU;EACnB,IAAI,QAAQ,SAAS;EACrB,gBAAgB,OAAO;EACvB,IAAI,OAAO,CAAC,SAAS,UAAU;CACjC,GAAG;EAAC;EAAS;EAAiB;CAAS,CAAC;CACxC,OAAO;AACT;;;;;;;;;;;;;;AAeA,SAAgB,WAAW,EACzB,QACA,gBAAgB,MAChB,QACA,WACA,OACA,UACA,QACA,GAAG,QACe;CAElB,MAAM,EAAE,WAAW,sBADP,iBAAiB,aACc;CAC3C,MAAM,CAAC,SAAS,cAAc,SAAS,KAAK;CAC5C,MAAM,aAAa,OAAqD,IAAI;CAG5E,MAAM,oBAAoB,OAAO,KAAK;CACtC,MAAM,UAAU,OAAO,WAAW;CAIlC,MAAM,aAAa,aAAa,SAA0B;EACxD,MAAM,YAAY,UAAiB;GACjC,IAAI,MAAM,WAAW,MAAM;GAC3B,MAAM,YAAa,MAAsB;GAIzC,WAAW,UAAU;IAAE;IAAO,aAAa,WAAW,SAAS;GAAG;GAClE,kBAAkB,UAAU;EAC9B;EACA,MAAM,SAAS,KAAK,QAAQ,QAAQ;EACpC,MAAM,WAAW,UAAiB;GAChC,IAAI,MAAM,WAAW,QAAQ,kBAAkB,UAAU;EAC3D;EACA,KAAK,iBAAiB,UAAU,UAAU,IAAI;EAC9C,QAAQ,iBAAiB,SAAS,OAAO;EACzC,aAAa;GACX,KAAK,oBAAoB,UAAU,UAAU,IAAI;GACjD,QAAQ,oBAAoB,SAAS,OAAO;EAC9C;CACF,GAAG,CAAC,CAAC;CAEL,MAAM,YAAY,kBAAkB;EAClC,MAAM,SAAS,UAAU;EACzB,MAAM,YAAY,WAAW;EAC7B,WAAW,UAAU;EACrB,IAAI,CAAC,iBAAiB,kBAAkB,SAAS;EACjD,IAAI,WAAW,QAAQ,CAAC,OAAO,MAAM;EACrC,kBAAkB;GAAE,QAAQ;GAAY,OAAO,WAAW;EAAM,CAAC;EACjE,OAAO,MAAM,WAAW,eAAe,EAAE;CAC3C,GAAG;EAAC;EAAe;EAAW;CAAiB,CAAC;CAIhD,OAAO,UAA0D;EAC/D,gBAAgB;EAChB;EACA,OAAA,EAL+B,QAK3B;EACJ;EACA;EACA,WAAW,MACT,qBAAA,UAAA,EAAA,UAAA,CACG,kBAAkB,UAAU,CAAC,GAC7B,WAAW,oBAAC,mBAAD;GAAmB,iBAAiB;GAAuB;EAAY,CAAA,CACnF,EAAA,CAAA;EAEJ,OAAO;EACP,cAAc;GACZ,QAAQ,WAAW,KAAA,IAAY,WAAW,OAAO,WAAW,WAAW,SAAS,KAAA;GAGxE;EACV;EACA,KAAK;CACP,CAAC;AACH;AAEA,WAAW,cAAc"}
|
|
1
|
+
{"version":3,"file":"dialog-form.mjs","names":[],"sources":["../../src/dialog/dialog-form.tsx"],"sourcesContent":["\"use client\";\nimport { use, useCallback, useRef, useState } from \"react\";\nimport type { ComponentPropsWithRef, CSSProperties, ReactNode } from \"react\";\nimport { FormContext } from \"../internal/form/field-context.js\";\nimport { FormStatusWatcher } from \"../internal/form/form-status-watcher.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 { hasAnyError } from \"../internal/form/validity.js\";\nimport { useDialogContext } from \"./dialog-context.js\";\nimport type { DialogNamespace } from \"./dialog-context.js\";\n\nconst isDev = process.env.NODE_ENV !== \"production\";\n\n/**\n * State of `Dialog.Form`, passed to the function forms of `className`, `style`, `children` and\n * `render`.\n */\nexport interface DialogFormState {\n /** `useFormStatus().pending` of this form, exposed for `className` / `children` functions. */\n readonly pending: boolean;\n}\n\n/**\n * Props of `Dialog.Form`.\n *\n * @see https://ui.funstack.work/components/dialog\n */\nexport interface DialogFormProps extends Omit<\n ComponentPropsWithRef<\"form\">,\n \"method\" | \"action\" | \"className\" | \"style\" | \"children\"\n> {\n /**\n * React form action (`(formData) => unknown`, may be a Server Function). Passed to the form\n * unwrapped so React's progressive enhancement is kept; the dialog closes with the submitter's\n * `value` as `returnValue` once the action's transition settles (see `closeOnSettle`): in\n * library mode through the Root (`openChangeAction(false)` awaited, view transition if set),\n * in JS-free mode with `close(value)`. A rejection leaves the dialog open. Without `action`\n * the form renders `method=\"dialog\"`: submitting closes the dialog, natively in JS-free mode\n * and through the Root in library mode (a `preventDefault()` in your own `onSubmit` blocks\n * both; `stopPropagation()` there leaves the close to the browser, reported to `onOpenChange`\n * as a fact).\n * A string `action` (a URL) is a plain navigating form.\n */\n action?: string | ((formData: FormData) => unknown);\n /**\n * With a function `action`: close the dialog once the action's transition settles without\n * throwing and, when this form is rendered as a `Form.Root`\n * (`render={<Form.Root errors={state.errors} />}`), with no field error: a settle whose\n * `errors` has a non-empty entry (hidden stale ones included, the `autoReset` rule) keeps\n * the dialog open and the Form focuses the first errored field.\n *\n * Without a `Form.Root` the library never sees a result, so any settle that does not throw\n * counts, including a `useActionState` result that reports errors: render the form as a\n * `Form.Root` to route them, throw to keep the dialog open, or set `closeOnSettle={false}`\n * and close it yourself (a `Dialog.Close`, a submit button in a separate `method=\"dialog\"`\n * form, or a controlled `open`). A `formMethod=\"dialog\"` submitter inside this form cannot\n * close it: React prevents every submit of a form with a function `action` and runs the\n * action again.\n *\n * The dialog is not closed either when it was closed (Escape, a Close part) while the action\n * ran, also if the user re-opened it meanwhile.\n *\n * @defaultValue `true`\n */\n closeOnSettle?: boolean;\n /**\n * Only with a string `action` (a navigating form, for example `\"post\"`). Owned otherwise:\n * `\"dialog\"` without `action`, React's own with a function `action`.\n */\n method?: ComponentPropsWithRef<\"form\">[\"method\"];\n /** Class name, or a function of the part's state that returns one. */\n className?: StateValue<string | undefined, DialogFormState>;\n /** Inline style, or a function of the part's state that returns one. */\n style?: StateValue<CSSProperties | undefined, DialogFormState>;\n /** Content, or a function of the part's state. */\n children?: StateValue<ReactNode, DialogFormState>;\n /** Replace the default `<form>` (element form) or take over rendering (function form). */\n render?: RenderProp<ComponentPropsWithRef<\"form\">, DialogFormState>;\n}\n\n/**\n * A form that completes the dialog. Without `action`: `<form method=\"dialog\">`, so a submit\n * closes the dialog with the submitter's `value` as `returnValue` (natively in JS-free mode;\n * in library mode the Popup cancels the submission and closes through the Root). With a\n * function `action`: `<form action={action}>` (React overrides the method) and a status watcher\n * that closes the dialog once the action has settled, with the submitter's `value`, unless\n * `closeOnSettle` is `false`, the dialog was closed while the action ran, or the form is rendered\n * as a `Form.Root` and the result has a field error (`render={<Form.Root errors={...} />}`, the\n * recommended composition for validation).\n *\n * `DialogFormState.pending` is this form's own status; it is not emitted as `data-pending` and\n * is not folded into any control's `pending` (conventions 2.7). Submit buttons read\n * `useFormStatus()` themselves.\n *\n * Owned keys (conventions 1.2): `method` (except with a string `action`), `action`.\n *\n * @see https://ui.funstack.work/components/dialog\n */\nexport function DialogForm(props: DialogFormProps) {\n return useDialogForm(props, \"Dialog\");\n}\n\nDialogForm.displayName = \"DialogForm\";\n\n/** The body of `Dialog.Form`, also run by `AlertDialog.Form` (alert-dialog.md 8). */\nexport function useDialogForm(\n {\n action,\n closeOnSettle = true,\n method,\n className,\n style,\n children,\n render,\n ...rest\n }: DialogFormProps,\n namespace: DialogNamespace,\n): ReactNode {\n const ctx = useDialogContext(`${namespace}.Form`);\n const { popupRef, recordCloseIntent, requestClose } = ctx;\n const isLibrary = ctx.mode === \"library\";\n const [pending, setPending] = useState(false);\n const submission = useRef<{ event: Event; returnValue: string } | null>(null);\n // The dialog closed after the last submit (Escape, a Close part): the settle must not close it\n // again, also when the user re-opened it meanwhile.\n const closedSinceSubmit = useRef(false);\n const watches = typeof action === \"function\";\n\n // The submitter's `value` comes from the native `submit` event (capture, before React's\n // handler runs the action).\n const libraryRef = useCallback((form: HTMLFormElement) => {\n const onSubmit = (event: Event) => {\n if (event.target !== form) return;\n const submitter = (event as SubmitEvent).submitter as\n | HTMLButtonElement\n | HTMLInputElement\n | null;\n submission.current = { event, returnValue: submitter?.value ?? \"\" };\n closedSinceSubmit.current = false;\n };\n const dialog = form.closest(\"dialog\");\n const onClose = (event: Event) => {\n if (event.target === dialog) closedSinceSubmit.current = true;\n };\n form.addEventListener(\"submit\", onSubmit, true);\n dialog?.addEventListener(\"close\", onClose);\n return () => {\n form.removeEventListener(\"submit\", onSubmit, true);\n dialog?.removeEventListener(\"close\", onClose);\n };\n }, []);\n\n // `clean`: no field error in the settle's result (always `true` without a `Form.Root`).\n const onSettled = useCallback(\n (clean: boolean) => {\n const dialog = popupRef.current;\n const submitted = submission.current;\n submission.current = null;\n if (!closeOnSettle || closedSinceSubmit.current) return;\n // A result with field errors keeps the dialog open; the Form.Root focuses the first errored\n // field (design/components/dialog.md, \"Dialog.Form and Form.Root\").\n if (!clean) return;\n if (dialog === null || !dialog.open) return;\n const returnValue = submitted?.returnValue ?? \"\";\n if (isLibrary) {\n // A library-owned close (design 2.3): `openChangeAction(false)` awaited, then\n // `close(returnValue)` in the commit, inside the view transition if set.\n requestClose(submitted?.event, \"activate\", returnValue);\n return;\n }\n recordCloseIntent({ reason: \"activate\", event: submitted?.event });\n dialog.close(returnValue);\n },\n [closeOnSettle, popupRef, isLibrary, recordCloseIntent, requestClose],\n );\n\n const state: DialogFormState = { pending };\n\n return useRender<ComponentPropsWithRef<\"form\">, DialogFormState>({\n defaultElement: \"form\",\n render,\n state,\n className,\n style,\n children: (s) => (\n <>\n {resolveStateValue(children, s)}\n <DialogFormSettle\n namespace={namespace}\n watches={watches}\n missingAction={action === undefined}\n onPendingChange={setPending}\n onSettled={onSettled}\n />\n </>\n ),\n props: rest,\n libraryProps: {\n method: action === undefined ? \"dialog\" : typeof action === \"string\" ? method : undefined,\n // React's own type wants `void | Promise<void>`; the library's actions return `unknown`\n // (conventions 2.2) and React ignores the result.\n action: action as ComponentPropsWithRef<\"form\">[\"action\"],\n },\n ref: libraryRef,\n });\n}\n\n/**\n * Rendered among the form's children, so it reads the `FormContext` exactly when the form is a\n * `Form.Root` (either orientation of the `render` composition): the settle close then waits for\n * a result with no field error (`hasAnyError`, the `autoReset` predicate, hidden stale entries\n * included).\n */\nfunction DialogFormSettle({\n namespace,\n watches,\n missingAction,\n onPendingChange,\n onSettled,\n}: {\n readonly namespace: DialogNamespace;\n readonly watches: boolean;\n readonly missingAction: boolean;\n readonly onPendingChange: (pending: boolean) => void;\n readonly onSettled: (clean: boolean) => void;\n}) {\n const form = use(FormContext);\n useDevWarning(\n form !== null && missingAction,\n isDev &&\n `${namespace}.Form: rendered as a \\`Form.Root\\`, it needs a function \\`action\\`; without ` +\n \"one the form navigates instead of closing the dialog. Render a plain \" +\n `\\`<${namespace}.Form>\\` for a \\`method=\"dialog\"\\` form.`,\n );\n const isForm = form !== null;\n const errors = form?.errors;\n const settled = useCallback(\n () => onSettled(!isForm || !hasAnyError(errors)),\n [isForm, errors, onSettled],\n );\n if (!watches) return null;\n return <FormStatusWatcher onPendingChange={onPendingChange} onSettled={settled} />;\n}\n"],"mappings":";;;;;;;;;;;AAYA,MAAM,QAAQ,QAAQ,IAAI,aAAa;;;;;;;;;;;;;;;;;;;AAuFvC,SAAgB,WAAW,OAAwB;CACjD,OAAO,cAAc,OAAO,QAAQ;AACtC;AAEA,WAAW,cAAc;;AAGzB,SAAgB,cACd,EACE,QACA,gBAAgB,MAChB,QACA,WACA,OACA,UACA,QACA,GAAG,QAEL,WACW;CACX,MAAM,MAAM,iBAAiB,GAAG,UAAU,MAAM;CAChD,MAAM,EAAE,UAAU,mBAAmB,iBAAiB;CACtD,MAAM,YAAY,IAAI,SAAS;CAC/B,MAAM,CAAC,SAAS,cAAc,SAAS,KAAK;CAC5C,MAAM,aAAa,OAAqD,IAAI;CAG5E,MAAM,oBAAoB,OAAO,KAAK;CACtC,MAAM,UAAU,OAAO,WAAW;CAIlC,MAAM,aAAa,aAAa,SAA0B;EACxD,MAAM,YAAY,UAAiB;GACjC,IAAI,MAAM,WAAW,MAAM;GAC3B,MAAM,YAAa,MAAsB;GAIzC,WAAW,UAAU;IAAE;IAAO,aAAa,WAAW,SAAS;GAAG;GAClE,kBAAkB,UAAU;EAC9B;EACA,MAAM,SAAS,KAAK,QAAQ,QAAQ;EACpC,MAAM,WAAW,UAAiB;GAChC,IAAI,MAAM,WAAW,QAAQ,kBAAkB,UAAU;EAC3D;EACA,KAAK,iBAAiB,UAAU,UAAU,IAAI;EAC9C,QAAQ,iBAAiB,SAAS,OAAO;EACzC,aAAa;GACX,KAAK,oBAAoB,UAAU,UAAU,IAAI;GACjD,QAAQ,oBAAoB,SAAS,OAAO;EAC9C;CACF,GAAG,CAAC,CAAC;CAGL,MAAM,YAAY,aACf,UAAmB;EAClB,MAAM,SAAS,SAAS;EACxB,MAAM,YAAY,WAAW;EAC7B,WAAW,UAAU;EACrB,IAAI,CAAC,iBAAiB,kBAAkB,SAAS;EAGjD,IAAI,CAAC,OAAO;EACZ,IAAI,WAAW,QAAQ,CAAC,OAAO,MAAM;EACrC,MAAM,cAAc,WAAW,eAAe;EAC9C,IAAI,WAAW;GAGb,aAAa,WAAW,OAAO,YAAY,WAAW;GACtD;EACF;EACA,kBAAkB;GAAE,QAAQ;GAAY,OAAO,WAAW;EAAM,CAAC;EACjE,OAAO,MAAM,WAAW;CAC1B,GACA;EAAC;EAAe;EAAU;EAAW;EAAmB;CAAY,CACtE;CAIA,OAAO,UAA0D;EAC/D,gBAAgB;EAChB;EACA,OAAA,EAL+B,QAK3B;EACJ;EACA;EACA,WAAW,MACT,qBAAA,UAAA,EAAA,UAAA,CACG,kBAAkB,UAAU,CAAC,GAC9B,oBAAC,kBAAD;GACa;GACF;GACT,eAAe,WAAW,KAAA;GAC1B,iBAAiB;GACN;EACZ,CAAA,CACD,EAAA,CAAA;EAEJ,OAAO;EACP,cAAc;GACZ,QAAQ,WAAW,KAAA,IAAY,WAAW,OAAO,WAAW,WAAW,SAAS,KAAA;GAGxE;EACV;EACA,KAAK;CACP,CAAC;AACH;;;;;;;AAQA,SAAS,iBAAiB,EACxB,WACA,SACA,eACA,iBACA,aAOC;CACD,MAAM,OAAO,IAAI,WAAW;CAC5B,cACE,SAAS,QAAQ,eACjB,SACE,GAAG,UAAU,sJAEL,UAAU,yCACtB;CACA,MAAM,SAAS,SAAS;CACxB,MAAM,SAAS,MAAM;CACrB,MAAM,UAAU,kBACR,UAAU,CAAC,UAAU,CAAC,YAAY,MAAM,CAAC,GAC/C;EAAC;EAAQ;EAAQ;CAAS,CAC5B;CACA,IAAI,CAAC,SAAS,OAAO;CACrB,OAAO,oBAAC,mBAAD;EAAoC;EAAiB,WAAW;CAAU,CAAA;AACnF"}
|