@funstack/ui 0.1.0-alpha.15 → 0.1.0-alpha.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +22 -1
- package/dist/accordion/accordion-item.d.mts +19 -0
- package/dist/accordion/accordion-item.d.mts.map +1 -1
- package/dist/accordion/accordion-item.mjs +2 -0
- package/dist/accordion/accordion-item.mjs.map +1 -1
- package/dist/accordion/accordion-panel.d.mts +16 -0
- package/dist/accordion/accordion-panel.d.mts.map +1 -1
- package/dist/accordion/accordion-panel.mjs +2 -0
- package/dist/accordion/accordion-panel.mjs.map +1 -1
- package/dist/accordion/accordion-root.d.mts +36 -2
- package/dist/accordion/accordion-root.d.mts.map +1 -1
- package/dist/accordion/accordion-root.mjs +3 -1
- package/dist/accordion/accordion-root.mjs.map +1 -1
- package/dist/accordion/accordion-trigger.d.mts +9 -0
- package/dist/accordion/accordion-trigger.d.mts.map +1 -1
- package/dist/accordion/accordion-trigger.mjs +2 -0
- package/dist/accordion/accordion-trigger.mjs.map +1 -1
- package/dist/accordion/index.d.mts +2 -0
- package/dist/accordion/index.d.mts.map +1 -1
- package/dist/accordion/index.mjs +2 -0
- package/dist/accordion/index.mjs.map +1 -1
- package/dist/bin/skill-installer.d.mts +1 -0
- package/dist/bin/skill-installer.mjs +12 -0
- package/dist/bin/skill-installer.mjs.map +1 -0
- package/dist/button/button.d.mts +46 -15
- package/dist/button/button.d.mts.map +1 -1
- package/dist/button/button.mjs +10 -6
- package/dist/button/button.mjs.map +1 -1
- package/dist/checkbox/checkbox.d.mts +25 -3
- package/dist/checkbox/checkbox.d.mts.map +1 -1
- package/dist/checkbox/checkbox.mjs +2 -0
- package/dist/checkbox/checkbox.mjs.map +1 -1
- package/dist/checkbox-group/checkbox-group-item.d.mts +15 -0
- package/dist/checkbox-group/checkbox-group-item.d.mts.map +1 -1
- package/dist/checkbox-group/checkbox-group-item.mjs +2 -0
- package/dist/checkbox-group/checkbox-group-item.mjs.map +1 -1
- package/dist/checkbox-group/checkbox-group-label.d.mts +10 -0
- package/dist/checkbox-group/checkbox-group-label.d.mts.map +1 -1
- package/dist/checkbox-group/checkbox-group-label.mjs +2 -0
- package/dist/checkbox-group/checkbox-group-label.mjs.map +1 -1
- package/dist/checkbox-group/checkbox-group-parent.d.mts +19 -1
- package/dist/checkbox-group/checkbox-group-parent.d.mts.map +1 -1
- package/dist/checkbox-group/checkbox-group-parent.mjs +2 -0
- package/dist/checkbox-group/checkbox-group-parent.mjs.map +1 -1
- package/dist/checkbox-group/checkbox-group-root.d.mts +31 -4
- package/dist/checkbox-group/checkbox-group-root.d.mts.map +1 -1
- package/dist/checkbox-group/checkbox-group-root.mjs +7 -1
- package/dist/checkbox-group/checkbox-group-root.mjs.map +1 -1
- package/dist/checkbox-group/index.d.mts +2 -0
- package/dist/checkbox-group/index.d.mts.map +1 -1
- package/dist/checkbox-group/index.mjs +2 -0
- package/dist/checkbox-group/index.mjs.map +1 -1
- package/dist/combobox/combobox-clear.d.mts +18 -0
- package/dist/combobox/combobox-clear.d.mts.map +1 -1
- package/dist/combobox/combobox-clear.mjs +2 -0
- package/dist/combobox/combobox-clear.mjs.map +1 -1
- package/dist/combobox/combobox-group.d.mts +49 -1
- package/dist/combobox/combobox-group.d.mts.map +1 -1
- package/dist/combobox/combobox-group.mjs +11 -1
- package/dist/combobox/combobox-group.mjs.map +1 -1
- package/dist/combobox/combobox-input.d.mts +11 -0
- package/dist/combobox/combobox-input.d.mts.map +1 -1
- package/dist/combobox/combobox-input.mjs +2 -0
- package/dist/combobox/combobox-input.mjs.map +1 -1
- package/dist/combobox/combobox-label.d.mts +16 -0
- package/dist/combobox/combobox-label.d.mts.map +1 -1
- package/dist/combobox/combobox-label.mjs +2 -0
- package/dist/combobox/combobox-label.mjs.map +1 -1
- package/dist/combobox/combobox-list.d.mts +14 -0
- package/dist/combobox/combobox-list.d.mts.map +1 -1
- package/dist/combobox/combobox-list.mjs +2 -0
- package/dist/combobox/combobox-list.mjs.map +1 -1
- package/dist/combobox/combobox-option.d.mts +25 -3
- package/dist/combobox/combobox-option.d.mts.map +1 -1
- package/dist/combobox/combobox-option.mjs +2 -0
- package/dist/combobox/combobox-option.mjs.map +1 -1
- package/dist/combobox/combobox-popup.d.mts +20 -1
- package/dist/combobox/combobox-popup.d.mts.map +1 -1
- package/dist/combobox/combobox-popup.mjs +2 -0
- package/dist/combobox/combobox-popup.mjs.map +1 -1
- package/dist/combobox/combobox-root.d.mts +64 -17
- package/dist/combobox/combobox-root.d.mts.map +1 -1
- package/dist/combobox/combobox-root.mjs +11 -11
- package/dist/combobox/combobox-root.mjs.map +1 -1
- package/dist/combobox/combobox-trigger.d.mts +16 -0
- package/dist/combobox/combobox-trigger.d.mts.map +1 -1
- package/dist/combobox/combobox-trigger.mjs +9 -2
- package/dist/combobox/combobox-trigger.mjs.map +1 -1
- package/dist/combobox/index.d.mts +2 -0
- package/dist/combobox/index.d.mts.map +1 -1
- package/dist/combobox/index.mjs +2 -0
- package/dist/combobox/index.mjs.map +1 -1
- package/dist/csp/csp-provider.d.mts +8 -0
- package/dist/csp/csp-provider.d.mts.map +1 -1
- package/dist/csp/csp-provider.mjs +2 -0
- package/dist/csp/csp-provider.mjs.map +1 -1
- package/dist/csp/style-hashes.d.mts +2 -0
- package/dist/csp/style-hashes.d.mts.map +1 -1
- package/dist/csp/style-hashes.mjs +2 -0
- package/dist/csp/style-hashes.mjs.map +1 -1
- package/dist/dialog/dialog-close.d.mts +31 -3
- package/dist/dialog/dialog-close.d.mts.map +1 -1
- package/dist/dialog/dialog-close.mjs +5 -2
- package/dist/dialog/dialog-close.mjs.map +1 -1
- package/dist/dialog/dialog-context.mjs.map +1 -1
- package/dist/dialog/dialog-description.d.mts +12 -0
- package/dist/dialog/dialog-description.d.mts.map +1 -1
- package/dist/dialog/dialog-description.mjs +2 -0
- package/dist/dialog/dialog-description.mjs.map +1 -1
- package/dist/dialog/dialog-form.d.mts +20 -2
- package/dist/dialog/dialog-form.d.mts.map +1 -1
- package/dist/dialog/dialog-form.mjs +2 -0
- package/dist/dialog/dialog-form.mjs.map +1 -1
- package/dist/dialog/dialog-popup.d.mts +34 -8
- package/dist/dialog/dialog-popup.d.mts.map +1 -1
- package/dist/dialog/dialog-popup.mjs +14 -20
- package/dist/dialog/dialog-popup.mjs.map +1 -1
- package/dist/dialog/dialog-root.d.mts +53 -25
- package/dist/dialog/dialog-root.d.mts.map +1 -1
- package/dist/dialog/dialog-root.mjs +12 -8
- package/dist/dialog/dialog-root.mjs.map +1 -1
- package/dist/dialog/dialog-title.d.mts +11 -0
- package/dist/dialog/dialog-title.d.mts.map +1 -1
- package/dist/dialog/dialog-title.mjs +2 -0
- package/dist/dialog/dialog-title.mjs.map +1 -1
- package/dist/dialog/dialog-trigger.d.mts +19 -3
- package/dist/dialog/dialog-trigger.d.mts.map +1 -1
- package/dist/dialog/dialog-trigger.mjs +2 -0
- package/dist/dialog/dialog-trigger.mjs.map +1 -1
- package/dist/dialog/index.d.mts +7 -5
- package/dist/dialog/index.d.mts.map +1 -1
- package/dist/dialog/index.mjs +7 -5
- package/dist/dialog/index.mjs.map +1 -1
- package/dist/docs/components/accordion.md +426 -0
- package/dist/docs/components/button.md +508 -0
- package/dist/docs/components/checkbox-group.md +483 -0
- package/dist/docs/components/checkbox.md +373 -0
- package/dist/docs/components/combobox.md +698 -0
- package/dist/docs/components/context-menu.md +524 -0
- package/dist/docs/components/dialog.md +692 -0
- package/dist/docs/components/field.md +587 -0
- package/dist/docs/components/menu.md +670 -0
- package/dist/docs/components/meter.md +313 -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 +662 -0
- package/dist/docs/components/slider.md +558 -0
- package/dist/docs/components/switch.md +311 -0
- package/dist/docs/components/tabs.md +473 -0
- package/dist/docs/components/toast.md +599 -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 +182 -0
- package/dist/docs/roadmap.md +128 -0
- package/dist/docs/why.md +104 -0
- package/dist/field/field-control.d.mts +26 -3
- package/dist/field/field-control.d.mts.map +1 -1
- package/dist/field/field-control.mjs +2 -0
- package/dist/field/field-control.mjs.map +1 -1
- package/dist/field/field-description.d.mts +11 -0
- package/dist/field/field-description.d.mts.map +1 -1
- package/dist/field/field-description.mjs +2 -0
- package/dist/field/field-description.mjs.map +1 -1
- package/dist/field/field-error.d.mts +14 -2
- package/dist/field/field-error.d.mts.map +1 -1
- package/dist/field/field-error.mjs +2 -0
- package/dist/field/field-error.mjs.map +1 -1
- package/dist/field/field-label.d.mts +10 -0
- package/dist/field/field-label.d.mts.map +1 -1
- package/dist/field/field-label.mjs +2 -0
- package/dist/field/field-label.mjs.map +1 -1
- package/dist/field/field-root.d.mts +21 -2
- package/dist/field/field-root.d.mts.map +1 -1
- package/dist/field/field-root.mjs +2 -0
- package/dist/field/field-root.mjs.map +1 -1
- package/dist/field/index.d.mts +9 -0
- package/dist/field/index.d.mts.map +1 -1
- package/dist/field/index.mjs +9 -0
- package/dist/field/index.mjs.map +1 -1
- package/dist/form/form-root.d.mts +17 -1
- package/dist/form/form-root.d.mts.map +1 -1
- package/dist/form/form-root.mjs +2 -0
- package/dist/form/form-root.mjs.map +1 -1
- package/dist/form/form-submit.d.mts +18 -0
- package/dist/form/form-submit.d.mts.map +1 -1
- package/dist/form/form-submit.mjs +2 -0
- package/dist/form/form-submit.mjs.map +1 -1
- package/dist/form/index.d.mts +7 -0
- package/dist/form/index.d.mts.map +1 -1
- package/dist/form/index.mjs +7 -0
- package/dist/form/index.mjs.map +1 -1
- package/dist/index.d.mts +3 -2
- package/dist/internal/call-urgent-handler.mjs +37 -0
- package/dist/internal/call-urgent-handler.mjs.map +1 -0
- package/dist/internal/css-transition-cut.mjs +66 -0
- package/dist/internal/css-transition-cut.mjs.map +1 -0
- package/dist/internal/overlay-popup.mjs.map +1 -1
- package/dist/internal/report-dropped.mjs +45 -0
- package/dist/internal/report-dropped.mjs.map +1 -0
- package/dist/internal/types.d.mts +36 -7
- package/dist/internal/types.d.mts.map +1 -1
- package/dist/internal/use-action-trigger.mjs +32 -17
- package/dist/internal/use-action-trigger.mjs.map +1 -1
- package/dist/internal/use-controllable-action.mjs +52 -16
- package/dist/internal/use-controllable-action.mjs.map +1 -1
- package/dist/internal/use-exit-animation.mjs +1 -1
- package/dist/internal/use-exit-animation.mjs.map +1 -1
- package/dist/internal/use-native-group-reconciliation.mjs +4 -2
- package/dist/internal/use-native-group-reconciliation.mjs.map +1 -1
- package/dist/internal/use-overlay-close.mjs +10 -4
- package/dist/internal/use-overlay-close.mjs.map +1 -1
- package/dist/internal/use-overlay-root.mjs +40 -7
- package/dist/internal/use-overlay-root.mjs.map +1 -1
- package/dist/internal/use-popover-popup.mjs +22 -7
- package/dist/internal/use-popover-popup.mjs.map +1 -1
- package/dist/internal/use-popover-trigger.d.mts +2 -1
- package/dist/internal/use-popover-trigger.d.mts.map +1 -1
- package/dist/internal/use-popover-trigger.mjs +11 -3
- package/dist/internal/use-popover-trigger.mjs.map +1 -1
- package/dist/internal/validity.d.mts +11 -0
- package/dist/internal/validity.d.mts.map +1 -1
- package/dist/internal/validity.mjs.map +1 -1
- package/dist/menu/index.d.mts +2 -0
- package/dist/menu/index.d.mts.map +1 -1
- package/dist/menu/index.mjs +2 -0
- package/dist/menu/index.mjs.map +1 -1
- package/dist/menu/menu-checkbox-item.d.mts +27 -3
- package/dist/menu/menu-checkbox-item.d.mts.map +1 -1
- package/dist/menu/menu-checkbox-item.mjs +2 -0
- package/dist/menu/menu-checkbox-item.mjs.map +1 -1
- package/dist/menu/menu-context-trigger.d.mts +24 -2
- package/dist/menu/menu-context-trigger.d.mts.map +1 -1
- package/dist/menu/menu-context-trigger.mjs +2 -0
- package/dist/menu/menu-context-trigger.mjs.map +1 -1
- package/dist/menu/menu-group.d.mts +36 -1
- package/dist/menu/menu-group.d.mts.map +1 -1
- package/dist/menu/menu-group.mjs +9 -1
- package/dist/menu/menu-group.mjs.map +1 -1
- package/dist/menu/menu-item.d.mts +38 -5
- package/dist/menu/menu-item.d.mts.map +1 -1
- package/dist/menu/menu-item.mjs +12 -5
- package/dist/menu/menu-item.mjs.map +1 -1
- package/dist/menu/menu-outside.mjs +2 -2
- package/dist/menu/menu-outside.mjs.map +1 -1
- package/dist/menu/menu-popup.d.mts +36 -8
- package/dist/menu/menu-popup.d.mts.map +1 -1
- package/dist/menu/menu-popup.mjs +2 -0
- package/dist/menu/menu-popup.mjs.map +1 -1
- package/dist/menu/menu-radio-group.d.mts +20 -1
- package/dist/menu/menu-radio-group.d.mts.map +1 -1
- package/dist/menu/menu-radio-group.mjs +2 -0
- package/dist/menu/menu-radio-group.mjs.map +1 -1
- package/dist/menu/menu-radio-item.d.mts +16 -0
- package/dist/menu/menu-radio-item.d.mts.map +1 -1
- package/dist/menu/menu-radio-item.mjs +2 -0
- package/dist/menu/menu-radio-item.mjs.map +1 -1
- package/dist/menu/menu-root.d.mts +49 -15
- package/dist/menu/menu-root.d.mts.map +1 -1
- package/dist/menu/menu-root.mjs +7 -4
- package/dist/menu/menu-root.mjs.map +1 -1
- package/dist/menu/menu-submenu-trigger.d.mts +13 -0
- package/dist/menu/menu-submenu-trigger.d.mts.map +1 -1
- package/dist/menu/menu-submenu-trigger.mjs +2 -0
- package/dist/menu/menu-submenu-trigger.mjs.map +1 -1
- package/dist/menu/menu-trigger.d.mts +15 -0
- package/dist/menu/menu-trigger.d.mts.map +1 -1
- package/dist/menu/menu-trigger.mjs +2 -0
- package/dist/menu/menu-trigger.mjs.map +1 -1
- package/dist/meter/index.d.mts +2 -0
- package/dist/meter/index.d.mts.map +1 -1
- package/dist/meter/index.mjs +2 -0
- package/dist/meter/index.mjs.map +1 -1
- package/dist/meter/meter-indicator.d.mts +11 -0
- package/dist/meter/meter-indicator.d.mts.map +1 -1
- package/dist/meter/meter-indicator.mjs +2 -0
- package/dist/meter/meter-indicator.mjs.map +1 -1
- package/dist/meter/meter-label.d.mts +11 -0
- package/dist/meter/meter-label.d.mts.map +1 -1
- package/dist/meter/meter-label.mjs +2 -0
- package/dist/meter/meter-label.mjs.map +1 -1
- package/dist/meter/meter-region.d.mts +5 -0
- package/dist/meter/meter-region.d.mts.map +1 -1
- package/dist/meter/meter-region.mjs.map +1 -1
- package/dist/meter/meter-root.d.mts +52 -10
- package/dist/meter/meter-root.d.mts.map +1 -1
- package/dist/meter/meter-root.mjs +2 -0
- package/dist/meter/meter-root.mjs.map +1 -1
- package/dist/meter/meter-track.d.mts +11 -0
- package/dist/meter/meter-track.d.mts.map +1 -1
- package/dist/meter/meter-track.mjs +2 -0
- package/dist/meter/meter-track.mjs.map +1 -1
- package/dist/meter/meter-value.d.mts +15 -1
- package/dist/meter/meter-value.d.mts.map +1 -1
- package/dist/meter/meter-value.mjs +2 -0
- package/dist/meter/meter-value.mjs.map +1 -1
- package/dist/number-field/index.d.mts +2 -0
- package/dist/number-field/index.d.mts.map +1 -1
- package/dist/number-field/index.mjs +2 -0
- package/dist/number-field/index.mjs.map +1 -1
- package/dist/number-field/number-field-decrement.d.mts +2 -0
- package/dist/number-field/number-field-decrement.d.mts.map +1 -1
- package/dist/number-field/number-field-decrement.mjs +2 -0
- package/dist/number-field/number-field-decrement.mjs.map +1 -1
- package/dist/number-field/number-field-increment.d.mts +2 -0
- package/dist/number-field/number-field-increment.d.mts.map +1 -1
- package/dist/number-field/number-field-increment.mjs +2 -0
- package/dist/number-field/number-field-increment.mjs.map +1 -1
- package/dist/number-field/number-field-input.d.mts +9 -0
- package/dist/number-field/number-field-input.d.mts.map +1 -1
- package/dist/number-field/number-field-input.mjs +2 -0
- package/dist/number-field/number-field-input.mjs.map +1 -1
- package/dist/number-field/number-field-label.d.mts +10 -0
- package/dist/number-field/number-field-label.d.mts.map +1 -1
- package/dist/number-field/number-field-label.mjs +2 -0
- package/dist/number-field/number-field-label.mjs.map +1 -1
- package/dist/number-field/number-field-root.d.mts +62 -14
- package/dist/number-field/number-field-root.d.mts.map +1 -1
- package/dist/number-field/number-field-root.mjs +4 -8
- package/dist/number-field/number-field-root.mjs.map +1 -1
- package/dist/number-field/use-step-button.d.mts +20 -0
- package/dist/number-field/use-step-button.d.mts.map +1 -1
- package/dist/number-field/use-step-button.mjs.map +1 -1
- package/dist/popover/index.d.mts +5 -3
- package/dist/popover/index.d.mts.map +1 -1
- package/dist/popover/index.mjs +5 -3
- package/dist/popover/index.mjs.map +1 -1
- package/dist/popover/popover-close.d.mts +32 -3
- package/dist/popover/popover-close.d.mts.map +1 -1
- package/dist/popover/popover-close.mjs +6 -2
- package/dist/popover/popover-close.mjs.map +1 -1
- package/dist/popover/popover-description.d.mts +12 -0
- package/dist/popover/popover-description.d.mts.map +1 -1
- package/dist/popover/popover-description.mjs +2 -0
- package/dist/popover/popover-description.mjs.map +1 -1
- package/dist/popover/popover-popup.d.mts +36 -7
- package/dist/popover/popover-popup.d.mts.map +1 -1
- package/dist/popover/popover-popup.mjs +5 -2
- 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 +11 -7
- 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 +15 -0
- package/dist/popover/popover-trigger.d.mts.map +1 -1
- package/dist/popover/popover-trigger.mjs +2 -0
- package/dist/popover/popover-trigger.mjs.map +1 -1
- package/dist/progress/index.d.mts +2 -0
- package/dist/progress/index.d.mts.map +1 -1
- package/dist/progress/index.mjs +2 -0
- package/dist/progress/index.mjs.map +1 -1
- package/dist/progress/progress-indicator.d.mts +11 -0
- package/dist/progress/progress-indicator.d.mts.map +1 -1
- package/dist/progress/progress-indicator.mjs +2 -0
- package/dist/progress/progress-indicator.mjs.map +1 -1
- package/dist/progress/progress-label.d.mts +11 -0
- package/dist/progress/progress-label.d.mts.map +1 -1
- package/dist/progress/progress-label.mjs +2 -0
- package/dist/progress/progress-label.mjs.map +1 -1
- package/dist/progress/progress-root.d.mts +36 -8
- package/dist/progress/progress-root.d.mts.map +1 -1
- package/dist/progress/progress-root.mjs +2 -0
- package/dist/progress/progress-root.mjs.map +1 -1
- package/dist/progress/progress-track.d.mts +11 -0
- package/dist/progress/progress-track.d.mts.map +1 -1
- package/dist/progress/progress-track.mjs +2 -0
- package/dist/progress/progress-track.mjs.map +1 -1
- package/dist/progress/progress-value.d.mts +15 -1
- package/dist/progress/progress-value.d.mts.map +1 -1
- package/dist/progress/progress-value.mjs +2 -0
- package/dist/progress/progress-value.mjs.map +1 -1
- package/dist/radio-group/index.d.mts +2 -0
- package/dist/radio-group/index.d.mts.map +1 -1
- package/dist/radio-group/index.mjs +2 -0
- package/dist/radio-group/index.mjs.map +1 -1
- package/dist/radio-group/radio-group-item.d.mts +18 -1
- package/dist/radio-group/radio-group-item.d.mts.map +1 -1
- package/dist/radio-group/radio-group-item.mjs +2 -0
- package/dist/radio-group/radio-group-item.mjs.map +1 -1
- package/dist/radio-group/radio-group-label.d.mts +10 -0
- package/dist/radio-group/radio-group-label.d.mts.map +1 -1
- package/dist/radio-group/radio-group-label.mjs +2 -0
- package/dist/radio-group/radio-group-label.mjs.map +1 -1
- package/dist/radio-group/radio-group-root.d.mts +29 -5
- package/dist/radio-group/radio-group-root.d.mts.map +1 -1
- package/dist/radio-group/radio-group-root.mjs +2 -0
- package/dist/radio-group/radio-group-root.mjs.map +1 -1
- package/dist/select/index.d.mts +2 -0
- package/dist/select/index.d.mts.map +1 -1
- package/dist/select/index.mjs +2 -0
- package/dist/select/index.mjs.map +1 -1
- package/dist/select/select-group-label.d.mts +10 -0
- package/dist/select/select-group-label.d.mts.map +1 -1
- package/dist/select/select-group-label.mjs +2 -0
- package/dist/select/select-group-label.mjs.map +1 -1
- package/dist/select/select-group.d.mts +15 -1
- package/dist/select/select-group.d.mts.map +1 -1
- package/dist/select/select-group.mjs +2 -0
- package/dist/select/select-group.mjs.map +1 -1
- package/dist/select/select-option.d.mts +19 -1
- package/dist/select/select-option.d.mts.map +1 -1
- package/dist/select/select-option.mjs +2 -0
- package/dist/select/select-option.mjs.map +1 -1
- package/dist/select/select-root.d.mts +24 -1
- package/dist/select/select-root.d.mts.map +1 -1
- package/dist/select/select-root.mjs +2 -0
- package/dist/select/select-root.mjs.map +1 -1
- package/dist/select/select-separator.d.mts +9 -0
- package/dist/select/select-separator.d.mts.map +1 -1
- package/dist/select/select-separator.mjs +2 -0
- package/dist/select/select-separator.mjs.map +1 -1
- package/dist/select/select-trigger.d.mts +9 -0
- package/dist/select/select-trigger.d.mts.map +1 -1
- package/dist/select/select-trigger.mjs +2 -0
- package/dist/select/select-trigger.mjs.map +1 -1
- package/dist/select/select-value.d.mts +9 -0
- package/dist/select/select-value.d.mts.map +1 -1
- package/dist/select/select-value.mjs +2 -0
- package/dist/select/select-value.mjs.map +1 -1
- package/dist/slider/index.d.mts +2 -0
- package/dist/slider/index.d.mts.map +1 -1
- package/dist/slider/index.mjs +2 -0
- package/dist/slider/index.mjs.map +1 -1
- package/dist/slider/slider-indicator.d.mts +12 -0
- package/dist/slider/slider-indicator.d.mts.map +1 -1
- package/dist/slider/slider-indicator.mjs +2 -0
- package/dist/slider/slider-indicator.mjs.map +1 -1
- package/dist/slider/slider-label.d.mts +11 -1
- package/dist/slider/slider-label.d.mts.map +1 -1
- package/dist/slider/slider-label.mjs +2 -0
- package/dist/slider/slider-label.mjs.map +1 -1
- package/dist/slider/slider-root.d.mts +53 -9
- package/dist/slider/slider-root.d.mts.map +1 -1
- package/dist/slider/slider-root.mjs +4 -8
- package/dist/slider/slider-root.mjs.map +1 -1
- package/dist/slider/slider-thumb.d.mts +32 -3
- package/dist/slider/slider-thumb.d.mts.map +1 -1
- package/dist/slider/slider-thumb.mjs +2 -0
- package/dist/slider/slider-thumb.mjs.map +1 -1
- package/dist/slider/slider-track.d.mts +17 -0
- package/dist/slider/slider-track.d.mts.map +1 -1
- package/dist/slider/slider-track.mjs +2 -0
- package/dist/slider/slider-track.mjs.map +1 -1
- package/dist/slider/slider-value.d.mts +11 -0
- package/dist/slider/slider-value.d.mts.map +1 -1
- package/dist/slider/slider-value.mjs +2 -0
- package/dist/slider/slider-value.mjs.map +1 -1
- package/dist/switch/switch.d.mts +23 -3
- package/dist/switch/switch.d.mts.map +1 -1
- package/dist/switch/switch.mjs +2 -0
- package/dist/switch/switch.mjs.map +1 -1
- package/dist/tabs/index.d.mts +2 -0
- package/dist/tabs/index.d.mts.map +1 -1
- package/dist/tabs/index.mjs +2 -0
- package/dist/tabs/index.mjs.map +1 -1
- package/dist/tabs/tabs-context.d.mts +5 -0
- package/dist/tabs/tabs-context.d.mts.map +1 -1
- package/dist/tabs/tabs-context.mjs.map +1 -1
- package/dist/tabs/tabs-indicator.d.mts +17 -0
- package/dist/tabs/tabs-indicator.d.mts.map +1 -1
- package/dist/tabs/tabs-indicator.mjs +2 -0
- package/dist/tabs/tabs-indicator.mjs.map +1 -1
- package/dist/tabs/tabs-list.d.mts +19 -1
- package/dist/tabs/tabs-list.d.mts.map +1 -1
- package/dist/tabs/tabs-list.mjs +2 -0
- package/dist/tabs/tabs-list.mjs.map +1 -1
- package/dist/tabs/tabs-panel.d.mts +19 -0
- package/dist/tabs/tabs-panel.d.mts.map +1 -1
- package/dist/tabs/tabs-panel.mjs +2 -0
- package/dist/tabs/tabs-panel.mjs.map +1 -1
- package/dist/tabs/tabs-root.d.mts +39 -5
- package/dist/tabs/tabs-root.d.mts.map +1 -1
- package/dist/tabs/tabs-root.mjs +2 -0
- package/dist/tabs/tabs-root.mjs.map +1 -1
- package/dist/tabs/tabs-tab.d.mts +22 -1
- package/dist/tabs/tabs-tab.d.mts.map +1 -1
- package/dist/tabs/tabs-tab.mjs +2 -0
- package/dist/tabs/tabs-tab.mjs.map +1 -1
- package/dist/toast/index.d.mts +2 -0
- package/dist/toast/index.d.mts.map +1 -1
- package/dist/toast/index.mjs +2 -0
- package/dist/toast/index.mjs.map +1 -1
- package/dist/toast/toast-action.d.mts +42 -6
- package/dist/toast/toast-action.d.mts.map +1 -1
- package/dist/toast/toast-action.mjs +8 -4
- package/dist/toast/toast-action.mjs.map +1 -1
- package/dist/toast/toast-close.d.mts +16 -0
- package/dist/toast/toast-close.d.mts.map +1 -1
- package/dist/toast/toast-close.mjs +2 -0
- package/dist/toast/toast-close.mjs.map +1 -1
- package/dist/toast/toast-context.mjs.map +1 -1
- package/dist/toast/toast-description.d.mts +16 -1
- package/dist/toast/toast-description.d.mts.map +1 -1
- package/dist/toast/toast-description.mjs +2 -0
- package/dist/toast/toast-description.mjs.map +1 -1
- package/dist/toast/toast-queue.mjs.map +1 -1
- package/dist/toast/toast-root.d.mts +20 -0
- package/dist/toast/toast-root.d.mts.map +1 -1
- package/dist/toast/toast-root.mjs +2 -0
- package/dist/toast/toast-root.mjs.map +1 -1
- package/dist/toast/toast-title.d.mts +15 -1
- package/dist/toast/toast-title.d.mts.map +1 -1
- package/dist/toast/toast-title.mjs +2 -0
- package/dist/toast/toast-title.mjs.map +1 -1
- package/dist/toast/toast-viewport.d.mts +34 -5
- package/dist/toast/toast-viewport.d.mts.map +1 -1
- package/dist/toast/toast-viewport.mjs +17 -15
- package/dist/toast/toast-viewport.mjs.map +1 -1
- package/dist/toast/toast.d.mts +56 -13
- package/dist/toast/toast.d.mts.map +1 -1
- package/dist/toast/toast.mjs +4 -0
- package/dist/toast/toast.mjs.map +1 -1
- package/dist/toggle/toggle.d.mts +20 -2
- package/dist/toggle/toggle.d.mts.map +1 -1
- package/dist/toggle/toggle.mjs +2 -0
- package/dist/toggle/toggle.mjs.map +1 -1
- package/dist/toggle-group/index.d.mts +2 -0
- package/dist/toggle-group/index.d.mts.map +1 -1
- package/dist/toggle-group/index.mjs +2 -0
- package/dist/toggle-group/index.mjs.map +1 -1
- package/dist/toggle-group/toggle-group-context.d.mts +1 -0
- package/dist/toggle-group/toggle-group-context.d.mts.map +1 -1
- package/dist/toggle-group/toggle-group-context.mjs.map +1 -1
- package/dist/toggle-group/toggle-group-item.d.mts +16 -0
- package/dist/toggle-group/toggle-group-item.d.mts.map +1 -1
- package/dist/toggle-group/toggle-group-item.mjs +2 -0
- package/dist/toggle-group/toggle-group-item.mjs.map +1 -1
- package/dist/toggle-group/toggle-group-root.d.mts +73 -12
- package/dist/toggle-group/toggle-group-root.d.mts.map +1 -1
- package/dist/toggle-group/toggle-group-root.mjs +3 -1
- package/dist/toggle-group/toggle-group-root.mjs.map +1 -1
- package/dist/toolbar/index.d.mts +2 -0
- package/dist/toolbar/index.d.mts.map +1 -1
- package/dist/toolbar/index.mjs +2 -0
- package/dist/toolbar/index.mjs.map +1 -1
- package/dist/toolbar/toolbar-root.d.mts +30 -3
- package/dist/toolbar/toolbar-root.d.mts.map +1 -1
- package/dist/toolbar/toolbar-root.mjs +2 -0
- package/dist/toolbar/toolbar-root.mjs.map +1 -1
- package/dist/toolbar/toolbar-separator.d.mts +13 -0
- package/dist/toolbar/toolbar-separator.d.mts.map +1 -1
- package/dist/toolbar/toolbar-separator.mjs +2 -0
- package/dist/toolbar/toolbar-separator.mjs.map +1 -1
- package/dist/tooltip/index.d.mts +2 -0
- package/dist/tooltip/index.d.mts.map +1 -1
- package/dist/tooltip/index.mjs +2 -0
- package/dist/tooltip/index.mjs.map +1 -1
- package/dist/tooltip/tooltip-arrow.d.mts +16 -0
- package/dist/tooltip/tooltip-arrow.d.mts.map +1 -1
- package/dist/tooltip/tooltip-arrow.mjs +2 -0
- package/dist/tooltip/tooltip-arrow.mjs.map +1 -1
- package/dist/tooltip/tooltip-context.d.mts +4 -0
- package/dist/tooltip/tooltip-context.d.mts.map +1 -1
- package/dist/tooltip/tooltip-context.mjs.map +1 -1
- package/dist/tooltip/tooltip-popup.d.mts +24 -3
- package/dist/tooltip/tooltip-popup.d.mts.map +1 -1
- package/dist/tooltip/tooltip-popup.mjs +2 -0
- package/dist/tooltip/tooltip-popup.mjs.map +1 -1
- package/dist/tooltip/tooltip-root.d.mts +24 -2
- package/dist/tooltip/tooltip-root.d.mts.map +1 -1
- package/dist/tooltip/tooltip-root.mjs +2 -0
- package/dist/tooltip/tooltip-root.mjs.map +1 -1
- package/dist/tooltip/tooltip-trigger.d.mts +18 -1
- package/dist/tooltip/tooltip-trigger.d.mts.map +1 -1
- package/dist/tooltip/tooltip-trigger.mjs +2 -0
- package/dist/tooltip/tooltip-trigger.mjs.map +1 -1
- package/package.json +9 -1
- package/skills/funstack-ui-knowledge/SKILL.md +75 -0
- package/dist/internal/use-superseded-rejection.mjs +0 -47
- package/dist/internal/use-superseded-rejection.mjs.map +0 -1
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
import { ReactNode } from "react";
|
|
2
2
|
//#region src/csp/csp-provider.d.ts
|
|
3
|
+
/**
|
|
4
|
+
* Props of `CSPProvider`.
|
|
5
|
+
*
|
|
6
|
+
* @see https://ui.funstack.work/concepts/content-security-policy
|
|
7
|
+
*/
|
|
3
8
|
export interface CSPProviderProps {
|
|
4
9
|
/**
|
|
5
10
|
* The per-response nonce of a nonce-based `style-src` policy. Pass the same value as React's
|
|
@@ -8,6 +13,7 @@ export interface CSPProviderProps {
|
|
|
8
13
|
* the `nonce` when the option is absent or in its string form.
|
|
9
14
|
*/
|
|
10
15
|
nonce?: string;
|
|
16
|
+
/** The tree whose library parts receive the nonce. */
|
|
11
17
|
children?: ReactNode;
|
|
12
18
|
}
|
|
13
19
|
/**
|
|
@@ -16,6 +22,8 @@ export interface CSPProviderProps {
|
|
|
16
22
|
* `experimental_interestFor`), which forward it as the element's `nonce` (design/conventions.md
|
|
17
23
|
* 12). The library's only provider; its prop is serialisable, so a Server Component layout that
|
|
18
24
|
* knows the nonce renders it once. Hash-based policies need no provider: use `STYLE_SHA256`.
|
|
25
|
+
*
|
|
26
|
+
* @see https://ui.funstack.work/concepts/content-security-policy
|
|
19
27
|
*/
|
|
20
28
|
export declare function CSPProvider({ nonce, children }: CSPProviderProps): import("react").JSX.Element;
|
|
21
29
|
export declare namespace CSPProvider {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"csp-provider.d.mts","names":[],"sources":["../../src/csp/csp-provider.tsx"],"mappings":"
|
|
1
|
+
{"version":3,"file":"csp-provider.d.mts","names":[],"sources":["../../src/csp/csp-provider.tsx"],"mappings":";;;;;;;iBAWiB;;;;;;;EAOf;;EAEA,WAAW;;;;;;;;;;;wBAYG,cAAc,OAAO,YAAY,mCAAgB,IAAA;yBAAjD"}
|
|
@@ -9,6 +9,8 @@ import { jsx } from "react/jsx-runtime";
|
|
|
9
9
|
* `experimental_interestFor`), which forward it as the element's `nonce` (design/conventions.md
|
|
10
10
|
* 12). The library's only provider; its prop is serialisable, so a Server Component layout that
|
|
11
11
|
* knows the nonce renders it once. Hash-based policies need no provider: use `STYLE_SHA256`.
|
|
12
|
+
*
|
|
13
|
+
* @see https://ui.funstack.work/concepts/content-security-policy
|
|
12
14
|
*/
|
|
13
15
|
function CSPProvider({ nonce, children }) {
|
|
14
16
|
const value = useMemo(() => ({ nonce }), [nonce]);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"csp-provider.mjs","names":[],"sources":["../../src/csp/csp-provider.tsx"],"sourcesContent":["\"use client\";\nimport { useMemo } from \"react\";\nimport type { ReactNode } from \"react\";\nimport { CSPContext } from \"../internal/csp-context.js\";\nimport type { CSPContextValue } from \"../internal/csp-context.js\";\n\nexport interface CSPProviderProps {\n /**\n * The per-response nonce of a nonce-based `style-src` policy. Pass the same value as React's\n * `nonce: { style }` render option: during server rendering React drops a hoisted\n * `<style precedence>` whose `nonce` differs from it (a missing provider included), and strips\n * the `nonce` when the option is absent or in its string form.\n */\n nonce?: string;\n children?: ReactNode;\n}\n\n/**\n * Hands a Content Security Policy nonce to every library part that renders a hoisted `<style>`\n * (`Menu.Popup`'s point placement rules, `Tooltip.Trigger`'s skip-delay rule with\n * `experimental_interestFor`), which forward it as the element's `nonce` (design/conventions.md\n * 12). The library's only provider; its prop is serialisable, so a Server Component layout that\n * knows the nonce renders it once. Hash-based policies need no provider: use `STYLE_SHA256`.\n */\nexport function CSPProvider({ nonce, children }: CSPProviderProps) {\n const value = useMemo<CSPContextValue>(() => ({ nonce }), [nonce]);\n return <CSPContext value={value}>{children}</CSPContext>;\n}\n\nCSPProvider.displayName = \"CSPProvider\";\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"csp-provider.mjs","names":[],"sources":["../../src/csp/csp-provider.tsx"],"sourcesContent":["\"use client\";\nimport { useMemo } from \"react\";\nimport type { ReactNode } from \"react\";\nimport { CSPContext } from \"../internal/csp-context.js\";\nimport type { CSPContextValue } from \"../internal/csp-context.js\";\n\n/**\n * Props of `CSPProvider`.\n *\n * @see https://ui.funstack.work/concepts/content-security-policy\n */\nexport interface CSPProviderProps {\n /**\n * The per-response nonce of a nonce-based `style-src` policy. Pass the same value as React's\n * `nonce: { style }` render option: during server rendering React drops a hoisted\n * `<style precedence>` whose `nonce` differs from it (a missing provider included), and strips\n * the `nonce` when the option is absent or in its string form.\n */\n nonce?: string;\n /** The tree whose library parts receive the nonce. */\n children?: ReactNode;\n}\n\n/**\n * Hands a Content Security Policy nonce to every library part that renders a hoisted `<style>`\n * (`Menu.Popup`'s point placement rules, `Tooltip.Trigger`'s skip-delay rule with\n * `experimental_interestFor`), which forward it as the element's `nonce` (design/conventions.md\n * 12). The library's only provider; its prop is serialisable, so a Server Component layout that\n * knows the nonce renders it once. Hash-based policies need no provider: use `STYLE_SHA256`.\n *\n * @see https://ui.funstack.work/concepts/content-security-policy\n */\nexport function CSPProvider({ nonce, children }: CSPProviderProps) {\n const value = useMemo<CSPContextValue>(() => ({ nonce }), [nonce]);\n return <CSPContext value={value}>{children}</CSPContext>;\n}\n\nCSPProvider.displayName = \"CSPProvider\";\n"],"mappings":";;;;;;;;;;;;;;AAgCA,SAAgB,YAAY,EAAE,OAAO,YAA8B;CACjE,MAAM,QAAQ,eAAgC,EAAE,MAAM,IAAI,CAAC,KAAK,CAAC;CACjE,OAAO,oBAAC,YAAD;EAAmB;EAAQ;CAAqB,CAAA;AACzD;AAEA,YAAY,cAAc"}
|
|
@@ -10,6 +10,8 @@
|
|
|
10
10
|
*
|
|
11
11
|
* A blocked stylesheet degrades: the point menu opens at the point but never flips, and on the
|
|
12
12
|
* native tooltip path each tooltip waits its own `delay` (no skip-delay).
|
|
13
|
+
*
|
|
14
|
+
* @see https://ui.funstack.work/concepts/content-security-policy
|
|
13
15
|
*/
|
|
14
16
|
export declare const STYLE_SHA256: {
|
|
15
17
|
readonly "@funstack/ui/menu-point": "Wm5aBRstuZ3S9kDs0IbldhidU/prqpIW69jEAS0N9mc=";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"style-hashes.d.mts","names":[],"sources":["../../src/csp/style-hashes.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"style-hashes.d.mts","names":[],"sources":["../../src/csp/style-hashes.ts"],"mappings":";;;;;;;;;;;;;;;qBAkBa;WACX;WACA"}
|
|
@@ -10,6 +10,8 @@
|
|
|
10
10
|
*
|
|
11
11
|
* A blocked stylesheet degrades: the point menu opens at the point but never flips, and on the
|
|
12
12
|
* native tooltip path each tooltip waits its own `delay` (no skip-delay).
|
|
13
|
+
*
|
|
14
|
+
* @see https://ui.funstack.work/concepts/content-security-policy
|
|
13
15
|
*/
|
|
14
16
|
const STYLE_SHA256 = {
|
|
15
17
|
"@funstack/ui/menu-point": "Wm5aBRstuZ3S9kDs0IbldhidU/prqpIW69jEAS0N9mc=",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"style-hashes.mjs","names":[],"sources":["../../src/csp/style-hashes.ts"],"sourcesContent":["// The SHA-256 of every stylesheet the library ships (design/conventions.md 12), for hash-based\n// Content Security Policies. Committed constants: `csp.test.ts` recomputes them from the CSS\n// strings, so they cannot drift. No \"use client\" directive: data only (conventions 7.1).\n\n/**\n * The base64 SHA-256 of each shipped stylesheet, keyed by its `<style href>`. Allow them with\n * `style-src 'sha256-<value>'`:\n *\n * - `\"@funstack/ui/menu-point\"`: `Menu.Popup`'s `@position-try` rules for a menu opened at a\n * point (`Menu.ContextTrigger`), inserted on the client by the first such open.\n * - `\"@funstack/ui/tooltip-warm\"`: `Tooltip.Trigger`'s skip-delay rule, rendered only with\n * `experimental_interestFor` (during server rendering too).\n *\n * A blocked stylesheet degrades: the point menu opens at the point but never flips, and on the\n * native tooltip path each tooltip waits its own `delay` (no skip-delay).\n */\nexport const STYLE_SHA256 = {\n \"@funstack/ui/menu-point\": \"Wm5aBRstuZ3S9kDs0IbldhidU/prqpIW69jEAS0N9mc=\",\n \"@funstack/ui/tooltip-warm\": \"nFBZGhNvo46ITrlBb48hELUAyWzpeIdJCziCectFQa4=\",\n} as const;\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"style-hashes.mjs","names":[],"sources":["../../src/csp/style-hashes.ts"],"sourcesContent":["// The SHA-256 of every stylesheet the library ships (design/conventions.md 12), for hash-based\n// Content Security Policies. Committed constants: `csp.test.ts` recomputes them from the CSS\n// strings, so they cannot drift. No \"use client\" directive: data only (conventions 7.1).\n\n/**\n * The base64 SHA-256 of each shipped stylesheet, keyed by its `<style href>`. Allow them with\n * `style-src 'sha256-<value>'`:\n *\n * - `\"@funstack/ui/menu-point\"`: `Menu.Popup`'s `@position-try` rules for a menu opened at a\n * point (`Menu.ContextTrigger`), inserted on the client by the first such open.\n * - `\"@funstack/ui/tooltip-warm\"`: `Tooltip.Trigger`'s skip-delay rule, rendered only with\n * `experimental_interestFor` (during server rendering too).\n *\n * A blocked stylesheet degrades: the point menu opens at the point but never flips, and on the\n * native tooltip path each tooltip waits its own `delay` (no skip-delay).\n *\n * @see https://ui.funstack.work/concepts/content-security-policy\n */\nexport const STYLE_SHA256 = {\n \"@funstack/ui/menu-point\": \"Wm5aBRstuZ3S9kDs0IbldhidU/prqpIW69jEAS0N9mc=\",\n \"@funstack/ui/tooltip-warm\": \"nFBZGhNvo46ITrlBb48hELUAyWzpeIdJCziCectFQa4=\",\n} as const;\n"],"mappings":";;;;;;;;;;;;;;;AAkBA,MAAa,eAAe;CAC1B,2BAA2B;CAC3B,6BAA6B;AAC/B"}
|
|
@@ -1,9 +1,14 @@
|
|
|
1
|
-
import { Action, ActionDetails, RenderProp, StateValue } from "../internal/types.mjs";
|
|
1
|
+
import { Action, ActionDetails, RenderProp, StateValue, WhilePending } from "../internal/types.mjs";
|
|
2
2
|
import { CSSProperties, ComponentPropsWithRef, ReactNode } from "react";
|
|
3
3
|
//#region src/dialog/dialog-close.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* State of `Dialog.Close`, passed to the function forms of `className`, `style`, `children` and
|
|
6
|
+
* `render`.
|
|
7
|
+
*/
|
|
4
8
|
export interface DialogCloseState {
|
|
5
9
|
/** The `action` is in flight. */
|
|
6
10
|
readonly pending: boolean;
|
|
11
|
+
/** The `disabled` prop. */
|
|
7
12
|
readonly disabled: boolean;
|
|
8
13
|
}
|
|
9
14
|
/** Details passed to `Dialog.Close`'s `action`. */
|
|
@@ -11,6 +16,11 @@ export interface DialogCloseDetails extends ActionDetails {
|
|
|
11
16
|
/** The `value` the dialog closes with (`dialog.returnValue`); `""` without `value`. */
|
|
12
17
|
readonly returnValue: string;
|
|
13
18
|
}
|
|
19
|
+
/**
|
|
20
|
+
* Props of `Dialog.Close`.
|
|
21
|
+
*
|
|
22
|
+
* @see https://ui.funstack.work/components/dialog
|
|
23
|
+
*/
|
|
14
24
|
export interface DialogCloseProps extends Omit<ComponentPropsWithRef<"button">, "onClick" | "value" | "className" | "style" | "children"> {
|
|
15
25
|
/**
|
|
16
26
|
* Runs inside this part's own transition (`data-pending` on the button), then closes the
|
|
@@ -22,17 +32,33 @@ export interface DialogCloseProps extends Omit<ComponentPropsWithRef<"button">,
|
|
|
22
32
|
* button is a native `command="request-close"` invoker.
|
|
23
33
|
*/
|
|
24
34
|
action?: Action<[details: DialogCloseDetails]>;
|
|
35
|
+
/**
|
|
36
|
+
* What a click does while this part's `action` is pending. `"ignore"`: nothing (the click is
|
|
37
|
+
* cancelled, `aria-disabled="true"` meanwhile). `"run"`: the action runs again (`data-pending`
|
|
38
|
+
* until every run has settled); the dialog closes once, when the last run settles and only if
|
|
39
|
+
* the latest run resolved (a rejection leaves it open, as in `"ignore"` mode). No effect
|
|
40
|
+
* without `action`.
|
|
41
|
+
*
|
|
42
|
+
* @defaultValue `"ignore"`
|
|
43
|
+
*/
|
|
44
|
+
whilePending?: WhilePending;
|
|
25
45
|
/** Becomes `dialog.returnValue` (and `details.returnValue` of `openChangeAction(false)`). */
|
|
26
46
|
value?: string;
|
|
27
47
|
/**
|
|
28
48
|
* Never closes. Native `disabled` on a `<button>`; owned, so a `render` element cannot
|
|
29
49
|
* re-enable it. With a link or component `render` whose click this part handles (library mode,
|
|
30
50
|
* or with `action`), `aria-disabled="true"` instead: the element stays focusable.
|
|
51
|
+
*
|
|
52
|
+
* @defaultValue `false`
|
|
31
53
|
*/
|
|
32
54
|
disabled?: boolean;
|
|
55
|
+
/** Class name, or a function of the part's state that returns one. */
|
|
33
56
|
className?: StateValue<string | undefined, DialogCloseState>;
|
|
57
|
+
/** Inline style, or a function of the part's state that returns one. */
|
|
34
58
|
style?: StateValue<CSSProperties | undefined, DialogCloseState>;
|
|
59
|
+
/** Content, or a function of the part's state. */
|
|
35
60
|
children?: StateValue<ReactNode, DialogCloseState>;
|
|
61
|
+
/** Replace the default `<button>` (element form) or take over rendering (function form). */
|
|
36
62
|
render?: RenderProp<ComponentPropsWithRef<"button">, DialogCloseState>;
|
|
37
63
|
}
|
|
38
64
|
/**
|
|
@@ -42,13 +68,15 @@ export interface DialogCloseProps extends Omit<ComponentPropsWithRef<"button">,
|
|
|
42
68
|
* through the Root (`openChangeAction(false)` awaited, then `close(value)` in the commit, inside
|
|
43
69
|
* the view transition if the Popup's `transition` is set). With `action` the action runs first in
|
|
44
70
|
* this part's own transition (`data-pending` and `aria-disabled` on the button; a second click
|
|
45
|
-
* meanwhile is ignored); a rejection leaves the dialog open.
|
|
71
|
+
* meanwhile is ignored unless `whilePending="run"`); a rejection leaves the dialog open.
|
|
46
72
|
*
|
|
47
73
|
* Owned keys (conventions 1.2): `type` (on a `<button>` only), `disabled`, `commandfor`,
|
|
48
74
|
* `command`, `value`, `onClick` (library mode, or with `action`), `aria-disabled`, `data-pending`,
|
|
49
75
|
* `data-disabled`.
|
|
76
|
+
*
|
|
77
|
+
* @see https://ui.funstack.work/components/dialog
|
|
50
78
|
*/
|
|
51
|
-
export declare function DialogClose({ action, value, disabled, className, style, children, render, ...rest }: DialogCloseProps): ReactNode;
|
|
79
|
+
export declare function DialogClose({ action, whilePending, value, disabled, className, style, children, render, ...rest }: DialogCloseProps): ReactNode;
|
|
52
80
|
export declare namespace DialogClose {
|
|
53
81
|
var displayName: string;
|
|
54
82
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dialog-close.d.mts","names":[],"sources":["../../src/dialog/dialog-close.tsx"],"mappings":"
|
|
1
|
+
{"version":3,"file":"dialog-close.d.mts","names":[],"sources":["../../src/dialog/dialog-close.tsx"],"mappings":";;;;;;;iBAiBiB;;WAEN;;WAEA;;;iBAIM,2BAA2B;;WAEjC;;;;;;;iBAQM,yBAAyB,KACxC;;;;;;;;;;EAYA,SAAS,QAAQ,SAAS;;;;;;;;;;EAU1B,eAAe;;EAEf;;;;;;;;EAQA;;EAEA,YAAY,+BAA+B;;EAE3C,QAAQ,WAAW,2BAA2B;;EAE9C,WAAW,WAAW,WAAW;;EAEjC,SAAS,WAAW,iCAAiC;;;;;;;;;;;;;;;;;wBAkBvC,cACd,QACA,cACA,OACA,UACA,WACA,OACA,UACA,WACG,QACF,mBAAgB;yBAVH"}
|
|
@@ -10,13 +10,15 @@ import { useDialogContext } from "./dialog-context.mjs";
|
|
|
10
10
|
* through the Root (`openChangeAction(false)` awaited, then `close(value)` in the commit, inside
|
|
11
11
|
* the view transition if the Popup's `transition` is set). With `action` the action runs first in
|
|
12
12
|
* this part's own transition (`data-pending` and `aria-disabled` on the button; a second click
|
|
13
|
-
* meanwhile is ignored); a rejection leaves the dialog open.
|
|
13
|
+
* meanwhile is ignored unless `whilePending="run"`); a rejection leaves the dialog open.
|
|
14
14
|
*
|
|
15
15
|
* Owned keys (conventions 1.2): `type` (on a `<button>` only), `disabled`, `commandfor`,
|
|
16
16
|
* `command`, `value`, `onClick` (library mode, or with `action`), `aria-disabled`, `data-pending`,
|
|
17
17
|
* `data-disabled`.
|
|
18
|
+
*
|
|
19
|
+
* @see https://ui.funstack.work/components/dialog
|
|
18
20
|
*/
|
|
19
|
-
function DialogClose({ action, value, disabled = false, className, style, children, render, ...rest }) {
|
|
21
|
+
function DialogClose({ action, whilePending, value, disabled = false, className, style, children, render, ...rest }) {
|
|
20
22
|
const ctx = useDialogContext("Dialog.Close");
|
|
21
23
|
const { popupRef, recordCloseIntent } = ctx;
|
|
22
24
|
const isLibrary = ctx.mode === "library";
|
|
@@ -28,6 +30,7 @@ function DialogClose({ action, value, disabled = false, className, style, childr
|
|
|
28
30
|
command: "request-close",
|
|
29
31
|
openGeneration: ctx.openGeneration,
|
|
30
32
|
action,
|
|
33
|
+
whilePending,
|
|
31
34
|
details: (event) => createActionDetails(event, { returnValue: value ?? "" }),
|
|
32
35
|
close: (event) => {
|
|
33
36
|
const returnValue = value ?? "";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dialog-close.mjs","names":[],"sources":["../../src/dialog/dialog-close.tsx"],"sourcesContent":["\"use client\";\nimport type { ComponentPropsWithRef, CSSProperties, ReactNode } from \"react\";\nimport { createActionDetails } from \"../internal/action-details.js\";\nimport type {
|
|
1
|
+
{"version":3,"file":"dialog-close.mjs","names":[],"sources":["../../src/dialog/dialog-close.tsx"],"sourcesContent":["\"use client\";\nimport type { ComponentPropsWithRef, CSSProperties, ReactNode } from \"react\";\nimport { createActionDetails } from \"../internal/action-details.js\";\nimport type {\n Action,\n ActionDetails,\n RenderProp,\n StateValue,\n WhilePending,\n} from \"../internal/types.js\";\nimport { useOverlayClose } from \"../internal/use-overlay-close.js\";\nimport { useDialogContext } from \"./dialog-context.js\";\n\n/**\n * State of `Dialog.Close`, passed to the function forms of `className`, `style`, `children` and\n * `render`.\n */\nexport interface DialogCloseState {\n /** The `action` is in flight. */\n readonly pending: boolean;\n /** The `disabled` prop. */\n readonly disabled: boolean;\n}\n\n/** Details passed to `Dialog.Close`'s `action`. */\nexport interface DialogCloseDetails extends ActionDetails {\n /** The `value` the dialog closes with (`dialog.returnValue`); `\"\"` without `value`. */\n readonly returnValue: string;\n}\n\n/**\n * Props of `Dialog.Close`.\n *\n * @see https://ui.funstack.work/components/dialog\n */\nexport interface DialogCloseProps extends Omit<\n ComponentPropsWithRef<\"button\">,\n \"onClick\" | \"value\" | \"className\" | \"style\" | \"children\"\n> {\n /**\n * Runs inside this part's own transition (`data-pending` on the button), then closes the\n * dialog with `value` as `returnValue`: in library mode through the Root\n * (`openChangeAction(false)` awaited, view transition if set), in JS-free mode with\n * `close(value)`. A rejection reaches the nearest Error Boundary above the Close part and\n * leaves the dialog open. If the dialog was dismissed and opened again while the action ran,\n * the close is dropped: it belonged to the earlier open. Without `action` in JS-free mode the\n * button is a native `command=\"request-close\"` invoker.\n */\n action?: Action<[details: DialogCloseDetails]>;\n /**\n * What a click does while this part's `action` is pending. `\"ignore\"`: nothing (the click is\n * cancelled, `aria-disabled=\"true\"` meanwhile). `\"run\"`: the action runs again (`data-pending`\n * until every run has settled); the dialog closes once, when the last run settles and only if\n * the latest run resolved (a rejection leaves it open, as in `\"ignore\"` mode). No effect\n * without `action`.\n *\n * @defaultValue `\"ignore\"`\n */\n whilePending?: WhilePending;\n /** Becomes `dialog.returnValue` (and `details.returnValue` of `openChangeAction(false)`). */\n value?: string;\n /**\n * Never closes. Native `disabled` on a `<button>`; owned, so a `render` element cannot\n * re-enable it. With a link or component `render` whose click this part handles (library mode,\n * or with `action`), `aria-disabled=\"true\"` instead: the element stays focusable.\n *\n * @defaultValue `false`\n */\n disabled?: boolean;\n /** Class name, or a function of the part's state that returns one. */\n className?: StateValue<string | undefined, DialogCloseState>;\n /** Inline style, or a function of the part's state that returns one. */\n style?: StateValue<CSSProperties | undefined, DialogCloseState>;\n /** Content, or a function of the part's state. */\n children?: StateValue<ReactNode, DialogCloseState>;\n /** Replace the default `<button>` (element form) or take over rendering (function form). */\n render?: RenderProp<ComponentPropsWithRef<\"button\">, DialogCloseState>;\n}\n\n/**\n * A close button: `<button type=\"button\" commandfor command=\"request-close\">`. In JS-free mode\n * without `action` the browser closes the dialog (a close request: `cancel`, then `close`), with\n * `value` as the `returnValue`. In library mode the click is always cancelled and the close goes\n * through the Root (`openChangeAction(false)` awaited, then `close(value)` in the commit, inside\n * the view transition if the Popup's `transition` is set). With `action` the action runs first in\n * this part's own transition (`data-pending` and `aria-disabled` on the button; a second click\n * meanwhile is ignored unless `whilePending=\"run\"`); a rejection leaves the dialog open.\n *\n * Owned keys (conventions 1.2): `type` (on a `<button>` only), `disabled`, `commandfor`,\n * `command`, `value`, `onClick` (library mode, or with `action`), `aria-disabled`, `data-pending`,\n * `data-disabled`.\n *\n * @see https://ui.funstack.work/components/dialog\n */\nexport function DialogClose({\n action,\n whilePending,\n value,\n disabled = false,\n className,\n style,\n children,\n render,\n ...rest\n}: DialogCloseProps) {\n const ctx = useDialogContext(\"Dialog.Close\");\n const { popupRef, recordCloseIntent } = ctx;\n const isLibrary = ctx.mode === \"library\";\n return useOverlayClose({\n part: \"Dialog.Close\",\n noun: \"dialog\",\n isLibrary,\n popupId: ctx.ids.popup,\n command: \"request-close\",\n openGeneration: ctx.openGeneration,\n action,\n whilePending,\n details: (event) => createActionDetails(event, { returnValue: value ?? \"\" }),\n close: (event) => {\n const returnValue = value ?? \"\";\n if (isLibrary) {\n // A library-owned close (design 2.3): awaited, then `close(returnValue)` in the commit. A\n // no-op when `false` is already intended (a repeated click, or a dismissal meanwhile).\n ctx.requestClose(event, \"activate\", returnValue);\n return;\n }\n // JS-free mode with `action`: a browser-owned close; there is no Root state to go through.\n const dialog = popupRef.current;\n if (dialog === null || !dialog.open) return;\n recordCloseIntent({ reason: \"activate\", event });\n dialog.close(returnValue);\n },\n ownProps: { value },\n disabled,\n className,\n style,\n children,\n render,\n rest,\n });\n}\n\nDialogClose.displayName = \"DialogClose\";\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AA8FA,SAAgB,YAAY,EAC1B,QACA,cACA,OACA,WAAW,OACX,WACA,OACA,UACA,QACA,GAAG,QACgB;CACnB,MAAM,MAAM,iBAAiB,cAAc;CAC3C,MAAM,EAAE,UAAU,sBAAsB;CACxC,MAAM,YAAY,IAAI,SAAS;CAC/B,OAAO,gBAAgB;EACrB,MAAM;EACN,MAAM;EACN;EACA,SAAS,IAAI,IAAI;EACjB,SAAS;EACT,gBAAgB,IAAI;EACpB;EACA;EACA,UAAU,UAAU,oBAAoB,OAAO,EAAE,aAAa,SAAS,GAAG,CAAC;EAC3E,QAAQ,UAAU;GAChB,MAAM,cAAc,SAAS;GAC7B,IAAI,WAAW;IAGb,IAAI,aAAa,OAAO,YAAY,WAAW;IAC/C;GACF;GAEA,MAAM,SAAS,SAAS;GACxB,IAAI,WAAW,QAAQ,CAAC,OAAO,MAAM;GACrC,kBAAkB;IAAE,QAAQ;IAAY;GAAM,CAAC;GAC/C,OAAO,MAAM,WAAW;EAC1B;EACA,UAAU,EAAE,MAAM;EAClB;EACA;EACA;EACA;EACA;EACA;CACF,CAAC;AACH;AAEA,YAAY,cAAc"}
|
|
@@ -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 { ChangeReason } from \"../internal/types.js\";\nimport type { OverlayRootValue } from \"../internal/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, dismissals browser-owned
|
|
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/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, overlay-open-change.md).\n */\nexport interface DialogContextValue extends Omit<\n OverlayRootValue<HTMLDialogElement, [returnValue: string]>,\n // The popover `shown` mirror: Dialog does not maintain it.\n \"shown\" | \"setShown\"\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\nexport function useDialogContext(part: string): DialogContextValue {\n const context = use(DialogContext);\n if (context === null) {\n throw new Error(`${part} must be rendered inside a Dialog.Root.`);\n }\n return context;\n}\n"],"mappings":";;;AAoCA,MAAa,gBAAgB,cAAyC,IAAI;AAE1E,SAAgB,iBAAiB,MAAkC;CACjE,MAAM,UAAU,IAAI,aAAa;CACjC,IAAI,YAAY,MACd,MAAM,IAAI,MAAM,GAAG,KAAK,wCAAwC;CAElE,OAAO;AACT"}
|
|
@@ -2,17 +2,29 @@ import { RenderProp, StateValue } from "../internal/types.mjs";
|
|
|
2
2
|
import { DialogPopupState } from "./dialog-popup.mjs";
|
|
3
3
|
import { CSSProperties, ComponentPropsWithRef, ReactNode } from "react";
|
|
4
4
|
//#region src/dialog/dialog-description.d.ts
|
|
5
|
+
/** State of `Dialog.Description`: the Popup's state. */
|
|
5
6
|
export type DialogDescriptionState = DialogPopupState;
|
|
7
|
+
/**
|
|
8
|
+
* Props of `Dialog.Description`.
|
|
9
|
+
*
|
|
10
|
+
* @see https://ui.funstack.work/components/dialog
|
|
11
|
+
*/
|
|
6
12
|
export interface DialogDescriptionProps extends Omit<ComponentPropsWithRef<"p">, "id" | "className" | "style" | "children"> {
|
|
13
|
+
/** Class name, or a function of the part's state that returns one. */
|
|
7
14
|
className?: StateValue<string | undefined, DialogDescriptionState>;
|
|
15
|
+
/** Inline style, or a function of the part's state that returns one. */
|
|
8
16
|
style?: StateValue<CSSProperties | undefined, DialogDescriptionState>;
|
|
17
|
+
/** Content, or a function of the part's state. */
|
|
9
18
|
children?: StateValue<ReactNode, DialogDescriptionState>;
|
|
19
|
+
/** Replace the default `<p>` (element form) or take over rendering (function form). */
|
|
10
20
|
render?: RenderProp<ComponentPropsWithRef<"p">, DialogDescriptionState>;
|
|
11
21
|
}
|
|
12
22
|
/**
|
|
13
23
|
* The dialog's description: a `<p>` whose id the Popup references with `aria-describedby`.
|
|
14
24
|
*
|
|
15
25
|
* Owned key (conventions 1.2): `id`.
|
|
26
|
+
*
|
|
27
|
+
* @see https://ui.funstack.work/components/dialog
|
|
16
28
|
*/
|
|
17
29
|
export declare function DialogDescription({ className, style, children, render, ...rest }: DialogDescriptionProps): ReactNode;
|
|
18
30
|
export declare namespace DialogDescription {
|
|
@@ -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":";;;;;YAQY,yBAAyB;;;;;;iBAOpB,+BAA+B,KAC9C;;EAIA,YAAY,+BAA+B;;EAE3C,QAAQ,WAAW,2BAA2B;;EAE9C,WAAW,WAAW,WAAW;;EAEjC,SAAS,WAAW,4BAA4B;;;;;;;;;wBAUlC,oBACd,WACA,OACA,UACA,WACG,QACF,yBAAsB;yBANT"}
|
|
@@ -6,6 +6,8 @@ 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
12
|
function DialogDescription({ className, style, children, render, ...rest }) {
|
|
11
13
|
const ctx = useDialogContext("Dialog.Description");
|
|
@@ -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 className,\n style,\n children,\n render,\n ...rest\n}: DialogDescriptionProps) {\n const ctx = useDialogContext(\"Dialog.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\nDialogDescription.displayName = \"DialogDescription\";\n"],"mappings":"
|
|
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\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({\n className,\n style,\n children,\n render,\n ...rest\n}: DialogDescriptionProps) {\n const ctx = useDialogContext(\"Dialog.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\nDialogDescription.displayName = \"DialogDescription\";\n"],"mappings":";;;;;;;;;;;AAoCA,SAAgB,kBAAkB,EAChC,WACA,OACA,UACA,QACA,GAAG,QACsB;CACzB,MAAM,MAAM,iBAAiB,oBAAoB;CACjD,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;AAEA,kBAAkB,cAAc"}
|
|
@@ -1,10 +1,19 @@
|
|
|
1
1
|
import { RenderProp, StateValue } from "../internal/types.mjs";
|
|
2
2
|
import { CSSProperties, ComponentPropsWithRef, ReactNode } from "react";
|
|
3
3
|
//#region src/dialog/dialog-form.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* State of `Dialog.Form`, passed to the function forms of `className`, `style`, `children` and
|
|
6
|
+
* `render`.
|
|
7
|
+
*/
|
|
4
8
|
export interface DialogFormState {
|
|
5
9
|
/** `useFormStatus().pending` of this form, exposed for `className` / `children` functions. */
|
|
6
10
|
readonly pending: boolean;
|
|
7
11
|
}
|
|
12
|
+
/**
|
|
13
|
+
* Props of `Dialog.Form`.
|
|
14
|
+
*
|
|
15
|
+
* @see https://ui.funstack.work/components/dialog
|
|
16
|
+
*/
|
|
8
17
|
export interface DialogFormProps extends Omit<ComponentPropsWithRef<"form">, "method" | "action" | "className" | "style" | "children"> {
|
|
9
18
|
/**
|
|
10
19
|
* React form action (`(formData) => unknown`, may be a Server Function). Passed to the form
|
|
@@ -14,7 +23,8 @@ export interface DialogFormProps extends Omit<ComponentPropsWithRef<"form">, "me
|
|
|
14
23
|
* in JS-free mode with `close(value)`. A rejection leaves the dialog open. Without `action`
|
|
15
24
|
* the form renders `method="dialog"`: submitting closes the dialog, natively in JS-free mode
|
|
16
25
|
* and through the Root in library mode (a `preventDefault()` in your own `onSubmit` blocks
|
|
17
|
-
* both; `stopPropagation()` there leaves the close to the browser,
|
|
26
|
+
* both; `stopPropagation()` there leaves the close to the browser, reported to `onOpenChange`
|
|
27
|
+
* as a fact).
|
|
18
28
|
* A string `action` (a URL) is a plain navigating form.
|
|
19
29
|
*/
|
|
20
30
|
action?: string | ((formData: FormData) => unknown);
|
|
@@ -23,7 +33,7 @@ export interface DialogFormProps extends Omit<ComponentPropsWithRef<"form">, "me
|
|
|
23
33
|
* throwing and, when this form is rendered as a `Form.Root`
|
|
24
34
|
* (`render={<Form.Root errors={state.errors} />}`), with no field error: a settle whose
|
|
25
35
|
* `errors` has a non-empty entry (hidden stale ones included, the `autoReset` rule) keeps
|
|
26
|
-
* the dialog open and the Form focuses the first errored field.
|
|
36
|
+
* the dialog open and the Form focuses the first errored field.
|
|
27
37
|
*
|
|
28
38
|
* Without a `Form.Root` the library never sees a result, so any settle that does not throw
|
|
29
39
|
* counts, including a `useActionState` result that reports errors: render the form as a
|
|
@@ -35,6 +45,8 @@ export interface DialogFormProps extends Omit<ComponentPropsWithRef<"form">, "me
|
|
|
35
45
|
*
|
|
36
46
|
* The dialog is not closed either when it was closed (Escape, a Close part) while the action
|
|
37
47
|
* ran, also if the user re-opened it meanwhile.
|
|
48
|
+
*
|
|
49
|
+
* @defaultValue `true`
|
|
38
50
|
*/
|
|
39
51
|
closeOnSettle?: boolean;
|
|
40
52
|
/**
|
|
@@ -42,9 +54,13 @@ export interface DialogFormProps extends Omit<ComponentPropsWithRef<"form">, "me
|
|
|
42
54
|
* `"dialog"` without `action`, React's own with a function `action`.
|
|
43
55
|
*/
|
|
44
56
|
method?: ComponentPropsWithRef<"form">["method"];
|
|
57
|
+
/** Class name, or a function of the part's state that returns one. */
|
|
45
58
|
className?: StateValue<string | undefined, DialogFormState>;
|
|
59
|
+
/** Inline style, or a function of the part's state that returns one. */
|
|
46
60
|
style?: StateValue<CSSProperties | undefined, DialogFormState>;
|
|
61
|
+
/** Content, or a function of the part's state. */
|
|
47
62
|
children?: StateValue<ReactNode, DialogFormState>;
|
|
63
|
+
/** Replace the default `<form>` (element form) or take over rendering (function form). */
|
|
48
64
|
render?: RenderProp<ComponentPropsWithRef<"form">, DialogFormState>;
|
|
49
65
|
}
|
|
50
66
|
/**
|
|
@@ -62,6 +78,8 @@ export interface DialogFormProps extends Omit<ComponentPropsWithRef<"form">, "me
|
|
|
62
78
|
* `useFormStatus()` themselves.
|
|
63
79
|
*
|
|
64
80
|
* Owned keys (conventions 1.2): `method` (except with a string `action`), `action`.
|
|
81
|
+
*
|
|
82
|
+
* @see https://ui.funstack.work/components/dialog
|
|
65
83
|
*/
|
|
66
84
|
export declare function DialogForm({ action, closeOnSettle, method, className, style, children, render, ...rest }: DialogFormProps): ReactNode;
|
|
67
85
|
export declare namespace DialogForm {
|
|
@@ -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":";;;;;;;iBAiBiB;;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,aACd,QACA,eACA,QACA,WACA,OACA,UACA,WACG,QACF,kBAAe;yBATF"}
|
|
@@ -25,6 +25,8 @@ const isDev = process.env.NODE_ENV !== "production";
|
|
|
25
25
|
* `useFormStatus()` themselves.
|
|
26
26
|
*
|
|
27
27
|
* Owned keys (conventions 1.2): `method` (except with a string `action`), `action`.
|
|
28
|
+
*
|
|
29
|
+
* @see https://ui.funstack.work/components/dialog
|
|
28
30
|
*/
|
|
29
31
|
function DialogForm({ action, closeOnSettle = true, method, className, style, children, render, ...rest }) {
|
|
30
32
|
const ctx = useDialogContext("Dialog.Form");
|
|
@@ -1 +1 @@
|
|
|
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/field-context.js\";\nimport { FormStatusWatcher } from \"../internal/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/validity.js\";\nimport { useDialogContext } from \"./dialog-context.js\";\n\nconst isDev = process.env.NODE_ENV !== \"production\";\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`): 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, notified as a dismissal).\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. Default `true`.\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 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\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 */\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 { 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 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\nDialogForm.displayName = \"DialogForm\";\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 watches,\n missingAction,\n onPendingChange,\n onSettled,\n}: {\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 \"`Dialog.Form` rendered as a `Form.Root` needs a function `action`; without one the form \" +\n \"navigates instead of closing the dialog. Render a plain `<Dialog.Form>` for a \" +\n '`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":";;;;;;;;;;;AAWA,MAAM,QAAQ,QAAQ,IAAI,aAAa;;;;;;;;;;;;;;;;;AAqEvC,SAAgB,WAAW,EACzB,QACA,gBAAgB,MAChB,QACA,WACA,OACA,UACA,QACA,GAAG,QACe;CAClB,MAAM,MAAM,iBAAiB,aAAa;CAC1C,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;GACW;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;AAEA,WAAW,cAAc;;;;;;;AAQzB,SAAS,iBAAiB,EACxB,SACA,eACA,iBACA,aAMC;CACD,MAAM,OAAO,IAAI,WAAW;CAC5B,cACE,SAAS,QAAQ,eACjB,SACE,iMAGJ;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"}
|
|
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/field-context.js\";\nimport { FormStatusWatcher } from \"../internal/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/validity.js\";\nimport { useDialogContext } 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({\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 { 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 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\nDialogForm.displayName = \"DialogForm\";\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 watches,\n missingAction,\n onPendingChange,\n onSettled,\n}: {\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 \"`Dialog.Form` rendered as a `Form.Root` needs a function `action`; without one the form \" +\n \"navigates instead of closing the dialog. Render a plain `<Dialog.Form>` for a \" +\n '`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":";;;;;;;;;;;AAWA,MAAM,QAAQ,QAAQ,IAAI,aAAa;;;;;;;;;;;;;;;;;;;AAuFvC,SAAgB,WAAW,EACzB,QACA,gBAAgB,MAChB,QACA,WACA,OACA,UACA,QACA,GAAG,QACe;CAClB,MAAM,MAAM,iBAAiB,aAAa;CAC1C,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;GACW;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;AAEA,WAAW,cAAc;;;;;;;AAQzB,SAAS,iBAAiB,EACxB,SACA,eACA,iBACA,aAMC;CACD,MAAM,OAAO,IAAI,WAAW;CAC5B,cACE,SAAS,QAAQ,eACjB,SACE,iMAGJ;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"}
|
|
@@ -1,11 +1,21 @@
|
|
|
1
1
|
import { RenderProp, StateValue } from "../internal/types.mjs";
|
|
2
2
|
import { CSSProperties, ComponentPropsWithRef, ReactNode, RefObject, ViewTransitionClass } from "react";
|
|
3
3
|
//#region src/dialog/dialog-popup.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* State of `Dialog.Popup`, passed to the function forms of `className`, `style`, `children` and
|
|
6
|
+
* `render`.
|
|
7
|
+
*/
|
|
4
8
|
export interface DialogPopupState {
|
|
5
9
|
/** Committed open state (library mode); `false` in JS-free mode. Read `:open` for the DOM truth. */
|
|
6
10
|
readonly open: boolean;
|
|
11
|
+
/** The Root's `modal`. */
|
|
7
12
|
readonly modal: boolean;
|
|
8
13
|
}
|
|
14
|
+
/**
|
|
15
|
+
* Props of `Dialog.Popup`.
|
|
16
|
+
*
|
|
17
|
+
* @see https://ui.funstack.work/components/dialog
|
|
18
|
+
*/
|
|
9
19
|
export interface DialogPopupProps extends Omit<ComponentPropsWithRef<"dialog">, "id" | "open" | "closedby" | "onToggle" | "onBeforeToggle" | "className" | "style" | "children"> {
|
|
10
20
|
/**
|
|
11
21
|
* Library mode: what happens to the children while the dialog is closed.
|
|
@@ -16,47 +26,60 @@ export interface DialogPopupProps extends Omit<ComponentPropsWithRef<"dialog">,
|
|
|
16
26
|
* stopped, pre-rendered at low priority. Not in the server HTML.
|
|
17
27
|
*
|
|
18
28
|
* Ignored in JS-free mode (always mounted).
|
|
29
|
+
*
|
|
30
|
+
* @defaultValue `false`
|
|
19
31
|
*/
|
|
20
32
|
keepMounted?: boolean;
|
|
21
33
|
/**
|
|
22
34
|
* Element to focus when the dialog opens: a ref, or a selector resolved inside the dialog.
|
|
23
35
|
* The library writes `autofocus` on it right before `showModal()` / `show()` and the platform
|
|
24
|
-
* focuses it.
|
|
25
|
-
* none). Use `tabIndex={-1}` on a heading or wrapper for long or destructive dialogs (APG).
|
|
36
|
+
* focuses it. Use `tabIndex={-1}` on a heading or wrapper for long or destructive dialogs (APG).
|
|
26
37
|
*
|
|
27
38
|
* In JS-free mode the browser opens the dialog itself, so the attribute is written after
|
|
28
39
|
* hydration and kept while mounted; before hydration only `autoFocus` in the markup works.
|
|
40
|
+
*
|
|
41
|
+
* @defaultValue the platform's choice (first focusable descendant; the dialog itself if none)
|
|
29
42
|
*/
|
|
30
43
|
initialFocus?: RefObject<HTMLElement | null> | string;
|
|
31
44
|
/**
|
|
32
|
-
* Close on a click outside the dialog (on the backdrop for modal dialogs).
|
|
45
|
+
* Close on a click outside the dialog (on the backdrop for modal dialogs).
|
|
33
46
|
* Baseline: JS `pointerdown` + `click` listeners, which close only when both the press and the
|
|
34
47
|
* click land outside (a drag that starts inside, such as selecting text, never closes); with
|
|
35
48
|
* `experimental_closedBy`, native `closedby="any"`, which behaves the same. A click on the
|
|
36
49
|
* Trigger of an open non-modal dialog counts as outside, as it does natively.
|
|
50
|
+
*
|
|
51
|
+
* @defaultValue `false`
|
|
37
52
|
*/
|
|
38
53
|
lightDismiss?: boolean;
|
|
39
54
|
/**
|
|
40
55
|
* Experimental (Chrome 134+, Firefox 141+; Safari 27.0 ignores it). Renders `closedby`
|
|
41
56
|
* (`"any"` when `lightDismiss`, else `"closerequest"`) and skips the JS dismiss listeners where
|
|
42
57
|
* `HTMLDialogElement.prototype.closedBy` exists. Elsewhere the JS baseline stays active.
|
|
43
|
-
*
|
|
58
|
+
*
|
|
59
|
+
* @defaultValue `false`
|
|
44
60
|
*/
|
|
45
61
|
experimental_closedBy?: boolean;
|
|
46
62
|
/**
|
|
47
63
|
* Library mode only. Forwarded to the `<ViewTransition default>` around the dialog. Animates
|
|
48
64
|
* the opening commit, content changes while open, and every library-driven close (a Close
|
|
49
65
|
* part, a Form submit or settled action, a foreign close command, a controlled
|
|
50
|
-
* `open={false}`), in all engines; dismissals (Escape, a click outside) are the
|
|
51
|
-
* animate with CSS only. Ignored (dev warning) in
|
|
66
|
+
* `open={false}`), in all engines; dismissals (Escape, a click outside: `onOpenChange`) are the
|
|
67
|
+
* browser's and animate with CSS only, never with a view transition. Ignored (dev warning) in
|
|
68
|
+
* JS-free mode. While a view transition runs, the dialog's CSS transitions are turned off for
|
|
69
|
+
* the moment of the library's own show or close (an inline `transition: none !important`,
|
|
70
|
+
* restored right after), so that show or close runs no CSS transition (a `@keyframes`
|
|
71
|
+
* animation is not cut).
|
|
52
72
|
*
|
|
53
73
|
* Static: setting or unsetting it remounts the element. Any value, `"none"` included, makes a
|
|
54
74
|
* mount or `<Activity>` reveal inside a transition start a document view transition (a ~250 ms
|
|
55
75
|
* page cross-fade that the next transition waits for).
|
|
56
76
|
*/
|
|
57
77
|
transition?: ViewTransitionClass;
|
|
78
|
+
/** Class name, or a function of the part's state that returns one. */
|
|
58
79
|
className?: StateValue<string | undefined, DialogPopupState>;
|
|
80
|
+
/** Inline style, or a function of the part's state that returns one. */
|
|
59
81
|
style?: StateValue<CSSProperties | undefined, DialogPopupState>;
|
|
82
|
+
/** Content, or a function of the part's state. */
|
|
60
83
|
children?: StateValue<ReactNode, DialogPopupState>;
|
|
61
84
|
/** Must render a `<dialog>`. */
|
|
62
85
|
render?: RenderProp<ComponentPropsWithRef<"dialog">, DialogPopupState>;
|
|
@@ -73,11 +96,14 @@ export interface DialogPopupProps extends Omit<ComponentPropsWithRef<"dialog">,
|
|
|
73
96
|
* submit, a Form's settle close, a foreign close command) is cancelled and goes through the
|
|
74
97
|
* Root: `openChangeAction(false)` is awaited and `close(returnValue)` runs in the layout effect
|
|
75
98
|
* of the commit that ends it, inside the view transition if `transition` is set. A dismissal
|
|
76
|
-
* (Escape, a click outside) is the browser's: the native `close` event
|
|
77
|
-
* `
|
|
99
|
+
* (Escape, a click outside, script) is the browser's, a fact: the native `close` event makes
|
|
100
|
+
* committed state `false` urgently and calls `onOpenChange(false, { reason: "dismiss",
|
|
101
|
+
* returnValue })`; no view transition runs for it.
|
|
78
102
|
*
|
|
79
103
|
* Owned keys (conventions 1.2): `id`, `open`, `closedby`, `aria-labelledby` and
|
|
80
104
|
* `aria-describedby` (token-merged), `data-modal`, `suppressHydrationWarning`.
|
|
105
|
+
*
|
|
106
|
+
* @see https://ui.funstack.work/components/dialog
|
|
81
107
|
*/
|
|
82
108
|
export declare function DialogPopup({ keepMounted, initialFocus, lightDismiss, experimental_closedBy, transition, className, style, children, render, ...rest }: DialogPopupProps): ReactNode;
|
|
83
109
|
export declare namespace DialogPopup {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dialog-popup.d.mts","names":[],"sources":["../../src/dialog/dialog-popup.tsx"],"mappings":"
|
|
1
|
+
{"version":3,"file":"dialog-popup.d.mts","names":[],"sources":["../../src/dialog/dialog-popup.tsx"],"mappings":";;;;;;;iBAoCiB;;WAEN;;WAEA;;;;;;;iBAQM,yBAAyB,KACxC;;;;;;;;;;;;;EAeA;;;;;;;;;;;EAWA,eAAe,UAAU;;;;;;;;;;EAUzB;;;;;;;;EAQA;;;;;;;;;;;;;;;;EAgBA,aAAa;;EAEb,YAAY,+BAA+B;;EAE3C,QAAQ,WAAW,2BAA2B;;EAE9C,WAAW,WAAW,WAAW;;EAEjC,SAAS,WAAW,iCAAiC;;;;;;;;;;;;;;;;;;;;;;;wBAuFvC,cACd,aACA,cACA,cACA,uBACA,YACA,WACA,OACA,UACA,WACG,QACF,mBAAgB;yBAXH"}
|