@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
|
@@ -0,0 +1,508 @@
|
|
|
1
|
+
# Button
|
|
2
|
+
|
|
3
|
+
A button whose click is a transition. Compared with `<button onClick>`, a `Button` runs `action` in its own transition and shows `data-pending` until it settles, runs or ignores a click that comes while it is pending (`whilePending`), sends a rejection to the nearest Error Boundary, and takes a Server Function as `action` or `formAction`.
|
|
4
|
+
|
|
5
|
+
```tsx title="ButtonSave.tsx"
|
|
6
|
+
"use client";
|
|
7
|
+
import { startTransition, useOptimistic, useState } from "react";
|
|
8
|
+
import { Button } from "@funstack/ui/button";
|
|
9
|
+
import { toast } from "@funstack/ui/toast";
|
|
10
|
+
import { DemoErrorBoundary } from "./DemoErrorBoundary.js";
|
|
11
|
+
import { fakeSave } from "./fake-api.js";
|
|
12
|
+
|
|
13
|
+
// Three Buttons with a 1.2 s fake save. Click Save several times quickly: the action runs once
|
|
14
|
+
// (the call counter, optimistic so it counts at once), because whilePending="ignore" makes the
|
|
15
|
+
// Button ignore activation while its own action is pending. The second Button rejects into the
|
|
16
|
+
// Error Boundary; the third catches inside and shows a toast.
|
|
17
|
+
export function ButtonSave() {
|
|
18
|
+
const [calls, setCalls] = useState(0);
|
|
19
|
+
const [saved, setSaved] = useState(0);
|
|
20
|
+
const [optimisticCalls, addCall] = useOptimistic(calls, (n) => n + 1);
|
|
21
|
+
|
|
22
|
+
return (
|
|
23
|
+
<div className="demo-stack">
|
|
24
|
+
<div className="demo-row">
|
|
25
|
+
<Button
|
|
26
|
+
className="demo-btn"
|
|
27
|
+
whilePending="ignore"
|
|
28
|
+
action={async () => {
|
|
29
|
+
addCall(undefined);
|
|
30
|
+
setCalls((c) => c + 1);
|
|
31
|
+
await fakeSave("the draft", { ms: 1200 });
|
|
32
|
+
startTransition(() => setSaved((s) => s + 1));
|
|
33
|
+
}}
|
|
34
|
+
>
|
|
35
|
+
{({ pending }) => (
|
|
36
|
+
<>
|
|
37
|
+
{pending && <span className="demo-spinner" aria-hidden />}
|
|
38
|
+
{pending ? "Saving…" : "Save"}
|
|
39
|
+
</>
|
|
40
|
+
)}
|
|
41
|
+
</Button>
|
|
42
|
+
<output className="demo-readout">
|
|
43
|
+
Action calls: {optimisticCalls}. Saves: {saved}.
|
|
44
|
+
</output>
|
|
45
|
+
</div>
|
|
46
|
+
|
|
47
|
+
<DemoErrorBoundary>
|
|
48
|
+
<Button
|
|
49
|
+
className="demo-btn"
|
|
50
|
+
action={() => fakeSave("the deletion", { ms: 1200, fail: true })}
|
|
51
|
+
>
|
|
52
|
+
{({ pending }) => (pending ? "Deleting…" : "Delete (rejects)")}
|
|
53
|
+
</Button>
|
|
54
|
+
</DemoErrorBoundary>
|
|
55
|
+
|
|
56
|
+
<Button
|
|
57
|
+
className="demo-btn"
|
|
58
|
+
action={async () => {
|
|
59
|
+
try {
|
|
60
|
+
await fakeSave("the copy", { ms: 1200, fail: true });
|
|
61
|
+
toast({ title: "Copied" });
|
|
62
|
+
} catch (error) {
|
|
63
|
+
// Caught inside: the library counts this as success, so pending simply ends.
|
|
64
|
+
toast({ title: "Copy failed", description: String(error), type: "error" });
|
|
65
|
+
}
|
|
66
|
+
}}
|
|
67
|
+
>
|
|
68
|
+
{({ pending }) => (pending ? "Copying…" : "Copy (fails, caught)")}
|
|
69
|
+
</Button>
|
|
70
|
+
</div>
|
|
71
|
+
);
|
|
72
|
+
}
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
```css title="button.css"
|
|
76
|
+
/* Button: [data-pending] is the in-flight state, [data-disabled] the consumer's `disabled`. A
|
|
77
|
+
pending Button with whilePending="ignore" is also aria-disabled="true", so style "unavailable"
|
|
78
|
+
from [data-disabled] (or aria-disabled without data-pending), not from aria-disabled alone. */
|
|
79
|
+
.demo-btn {
|
|
80
|
+
display: inline-flex;
|
|
81
|
+
align-items: center;
|
|
82
|
+
gap: 0.4em;
|
|
83
|
+
padding: 0.35em 0.9em;
|
|
84
|
+
border: 1px solid var(--color-border);
|
|
85
|
+
border-radius: 6px;
|
|
86
|
+
background: var(--color-bg);
|
|
87
|
+
color: var(--color-text);
|
|
88
|
+
font: inherit;
|
|
89
|
+
cursor: pointer;
|
|
90
|
+
transition: opacity 120ms;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
.demo-btn:hover {
|
|
94
|
+
background: color-mix(in srgb, var(--color-text) 6%, var(--color-bg));
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
.demo-btn-primary {
|
|
98
|
+
background: var(--color-primary);
|
|
99
|
+
border-color: var(--color-primary);
|
|
100
|
+
color: var(--color-on-primary);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
.demo-btn[data-pending] {
|
|
104
|
+
cursor: progress;
|
|
105
|
+
opacity: 0.75;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/* CSS-only pending: the label hides and a spinner takes its place, no function children. */
|
|
109
|
+
.demo-btn-css-spinner {
|
|
110
|
+
position: relative;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
.demo-btn-css-spinner[data-pending] {
|
|
114
|
+
color: transparent;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
.demo-btn-css-spinner[data-pending]::after {
|
|
118
|
+
content: "";
|
|
119
|
+
position: absolute;
|
|
120
|
+
inset: 0;
|
|
121
|
+
margin: auto;
|
|
122
|
+
inline-size: 0.9em;
|
|
123
|
+
block-size: 0.9em;
|
|
124
|
+
border: 2px solid var(--color-text);
|
|
125
|
+
border-right-color: transparent;
|
|
126
|
+
border-radius: 50%;
|
|
127
|
+
animation: demo-spin 700ms linear infinite;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
.demo-btn[data-disabled],
|
|
131
|
+
.demo-btn[aria-disabled="true"]:not([data-pending]) {
|
|
132
|
+
opacity: 0.5;
|
|
133
|
+
cursor: not-allowed;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
.demo-btn:focus-visible {
|
|
137
|
+
outline: 2px solid var(--color-primary);
|
|
138
|
+
outline-offset: 2px;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
@media (prefers-reduced-motion: reduce) {
|
|
142
|
+
.demo-btn {
|
|
143
|
+
transition: none;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
.demo-btn-css-spinner[data-pending]::after {
|
|
147
|
+
animation-duration: 2s;
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
Click Save several times quickly: the action runs once, because Save has `whilePending="ignore"`. While it runs the button carries `data-pending` and `aria-disabled="true"` and keeps focus. The second button rejects into an Error Boundary; the third catches the error inside its action, which the library counts as success, and reports it with a toast.
|
|
153
|
+
|
|
154
|
+
```tsx title="ButtonCounter.tsx"
|
|
155
|
+
"use client";
|
|
156
|
+
import { startTransition, useState } from "react";
|
|
157
|
+
import { Button } from "@funstack/ui/button";
|
|
158
|
+
import { fakeSave } from "./fake-api.js";
|
|
159
|
+
|
|
160
|
+
// A "+1" Button with the default whilePending="run": every click runs the action, also while an
|
|
161
|
+
// earlier one is still pending. The Button shows data-pending until the last run has settled and
|
|
162
|
+
// is never aria-disabled meanwhile. Each run awaits a 1 s fake request, then counts.
|
|
163
|
+
export function ButtonCounter() {
|
|
164
|
+
const [count, setCount] = useState(0);
|
|
165
|
+
|
|
166
|
+
return (
|
|
167
|
+
<div className="demo-row">
|
|
168
|
+
<Button
|
|
169
|
+
className="demo-btn"
|
|
170
|
+
action={async () => {
|
|
171
|
+
await fakeSave("the increment", { ms: 1000 });
|
|
172
|
+
startTransition(() => setCount((c) => c + 1));
|
|
173
|
+
}}
|
|
174
|
+
>
|
|
175
|
+
+1
|
|
176
|
+
</Button>
|
|
177
|
+
<output className="demo-readout">Count: {count}</output>
|
|
178
|
+
</div>
|
|
179
|
+
);
|
|
180
|
+
}
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
`button.css`: the same file as above.
|
|
184
|
+
|
|
185
|
+
Without the prop every click runs: click +1 several times quickly and each click counts. The button shows `data-pending` until the last run has settled and is never `aria-disabled` meanwhile, since it still acts. React commits the runs' updates together once they have all finished. Holding Enter on a focused button repeats the click, as it does on any native button, and each repeat is a run.
|
|
186
|
+
|
|
187
|
+
## Anatomy
|
|
188
|
+
|
|
189
|
+
```tsx
|
|
190
|
+
import { Button } from "@funstack/ui/button";
|
|
191
|
+
|
|
192
|
+
<Button action={save}>Save</Button> {/* <button type="button"> */}
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
One element, no parts. It renders `<button type="button">`; `render` substitutes any element, such as `render={<a href />}` for a link that runs an action. The Button adds no `role`: a link stays a link to assistive technology.
|
|
196
|
+
|
|
197
|
+
## Props
|
|
198
|
+
|
|
199
|
+
| Prop | Type | Default | Description |
|
|
200
|
+
| - | - | - | - |
|
|
201
|
+
| `action` | `Action<[details: ButtonActionDetails]>` | – | Runs inside the Button's own transition on click, Enter or Space. Sync or async; may be a Server Function (`details` carries only the virtual `event`). A rejection reaches the nearest Error Boundary above the Button. A click while it is pending runs it again, unless `whilePending` is `"ignore"`. Not combinable with `formAction` (development error). |
|
|
202
|
+
| `formAction` | `string \| ((formData: FormData) => void \| Promise<void>)` | – | React's `formAction`: run by React instead of the form's `action` when this Button submits the form. With a function the Button is pending for its own submissions only and defaults to `type="submit"`; a click meanwhile submits again unless `whilePending` is `"ignore"` (see [Forms](#forms)). Prefer a stable function (a Server Function, a `useActionState` dispatch, `useCallback`) when the form is also submitted from script with `requestSubmit(button)`; an inline function works for clicks and Enter. The match is by function identity (React reports no submitter), so Buttons that share one function (one dispatch, different `name` / `value`) all show pending while either submits; give each its own function (`dispatch.bind(null, "draft")`) to tell them apart. |
|
|
203
|
+
| `whilePending` | `"run" \| "ignore"` | `"run"` | What a click, Enter or Space does while this Button's own `action` (or its own function `formAction` submission) is pending. `"run"`: it runs as well; the Button shows `data-pending` until every run has settled. `"ignore"`: it starts nothing, its default action is cancelled (no second submission, navigation or command), and the Button is `aria-disabled="true"` while pending. Use `"ignore"` for an action that must not run twice (Save, Pay, Delete). No effect on a Button with neither `action` nor a function `formAction`. Type `WhilePending`. |
|
|
204
|
+
| `type` | `"button" \| "submit" \| "reset"` | `"button", or "submit" with formAction` | Owned on a `<button>` and on a component `render` element (assumed to render a `<button>`; it should spread the prop): set it here, not on the element. Omitted for a host element of another tag (`<a>`). `action` together with `submit` / `reset` warns in development (one click would do two things). |
|
|
205
|
+
| `disabled` | `boolean` | `false` | Native `disabled` and `data-disabled`; never dispatches, and a disabled link does not navigate. With `focusableWhenDisabled`, inside a [Toolbar](toolbar.md), or when `render` is not a `<button>` (a link, where native `disabled` means nothing), renders `aria-disabled="true"` instead. |
|
|
206
|
+
| `focusableWhenDisabled` | `boolean` | `false (true inside a Toolbar.Root)` | Keep a disabled Button focusable: `aria-disabled="true"` instead of native `disabled`, so keyboard and screen-reader users still find it and a Tooltip on it still opens. |
|
|
207
|
+
| `transition` | `ViewTransitionClass` | – | Forwarded to the Button's `<ViewTransition default>`: animates the commit that ends the action (content keyed on `pending`), not the click. |
|
|
208
|
+
| `className` | `string \| ((state: ButtonState) => string \| undefined)` | – | A class name, or a function of the part's state. |
|
|
209
|
+
| `style` | `CSSProperties \| ((state: ButtonState) => CSSProperties \| undefined)` | – | Inline style, or a function of the part's state. |
|
|
210
|
+
| `children` | `ReactNode \| ((state: ButtonState) => ReactNode)` | – | Content, or a function of the part's state. |
|
|
211
|
+
| `render` | `ReactElement \| ((props, state: ButtonState) => ReactNode)` | – | Replace the default \<button> (element form) or take over rendering (function form). |
|
|
212
|
+
|
|
213
|
+
- **State**: `ButtonState` is `{ pending, disabled }`; `ButtonActionDetails` is `{ event }`.
|
|
214
|
+
- **Owned**: `type` (on a `<button>` only), `disabled`, `aria-disabled`, `onClick`, `data-pending`, `data-disabled`.
|
|
215
|
+
|
|
216
|
+
Every other `<button>` prop passes through, including `name`, `value`, `form`, `commandfor`, `command`, `aria-busy` and every event handler but `onClick` (pass-through handlers keep firing while pending).
|
|
217
|
+
|
|
218
|
+
## Data attributes
|
|
219
|
+
|
|
220
|
+
| Hook | Meaning |
|
|
221
|
+
| - | - |
|
|
222
|
+
| `data-pending` | The Button's own `action` is in flight (until the commit that ends it, including a Suspense wait), or a submission it started with its own function `formAction` is pending. |
|
|
223
|
+
| `data-disabled` | The `disabled` prop. Not set by pending. |
|
|
224
|
+
| `aria-disabled` | `"true"` while pending with `whilePending="ignore"`, and while `disabled` with `focusableWhenDisabled`, inside a Toolbar, or on a non-`<button>` `render` element. Never set by pending in the default `"run"` mode. |
|
|
225
|
+
|
|
226
|
+
Pending is not disabled: `[data-disabled]` and `state.disabled` are your `disabled` only, so the two states never have to look alike.
|
|
227
|
+
|
|
228
|
+
## Keyboard and ARIA
|
|
229
|
+
|
|
230
|
+
| Key | Native \<button> | render={\<a href>} |
|
|
231
|
+
| - | - | - |
|
|
232
|
+
| Enter | Click: runs `action` (unless disabled, or pending with `whilePending="ignore"`) | Click: `action` and navigation; while pending with `whilePending="ignore"`, neither |
|
|
233
|
+
| Space | Click on keyup: runs `action` | Nothing (a link); add `role="button"` and a key handler if a link must act on Space |
|
|
234
|
+
| Tab | Sequential, or the Toolbar's single Tab stop inside one | Same |
|
|
235
|
+
|
|
236
|
+
Focus never moves because of pending. The library announces nothing when an action starts or ends; the outcome is yours, and that is where status messages belong: a [toast](toast.md) (announced by its Viewport), a field error, content that replaces the button, or `ariaNotify` from the action. `aria-busy` is not set by default (screen readers either ignore it or may hide the button's name); pass it yourself if you want it. A label that changes with `pending` ("Saving…") is your choice, and like any name change on the focused element it is not reliably spoken.
|
|
237
|
+
|
|
238
|
+
## Transition types
|
|
239
|
+
|
|
240
|
+
Concept: [Transitions & ViewTransition](../concepts/transitions.md#transition-types)
|
|
241
|
+
|
|
242
|
+
None: the Button adds no transition types. Its `transition` prop animates the commit that ends its action.
|
|
243
|
+
|
|
244
|
+
## Optimistic and pending
|
|
245
|
+
|
|
246
|
+
Concept: [Pending & optimistic state](../concepts/pending-and-optimistic.md)
|
|
247
|
+
|
|
248
|
+
A [pure trigger](../concepts/pending-and-optimistic.md#pure-trigger): no optimistic state. `data-pending` while its own action (or a submission started by its own function `formAction`) is in flight. A second click, Enter or Space meanwhile runs again by default; with `whilePending="ignore"` it is ignored and the Button is `aria-disabled="true"`.
|
|
249
|
+
|
|
250
|
+
### A click while pending
|
|
251
|
+
|
|
252
|
+
A Button's action is yours alone, so by default (`whilePending="run"`) the Button does what React's `useTransition` does: every click, Enter or Space runs the action, also while an earlier run is pending. The runs overlap; the Button shows `data-pending` until the last has settled and is not `aria-disabled`, because it still acts. When runs overlap, the latest run's rejection reaches the Error Boundary and an older run's goes to `reportError` (see [Overlapping actions](../concepts/action-props.md#overlapping-actions)). A double click on a default Save therefore saves twice: give it `whilePending="ignore"`.
|
|
253
|
+
|
|
254
|
+
With `whilePending="ignore"`, a click, Enter or Space while the Button's own action is in flight (also a programmatic `click()` and the click an implicit form submission sends) starts no second run and is `preventDefault()`ed, so a link does not navigate again, a form does not submit again and a `command` does not run again. Nothing else is blocked: focus, hover and your own event handlers work as usual, and ancestors still see the click.
|
|
255
|
+
|
|
256
|
+
- The ignoring Button is `aria-disabled="true"` meanwhile, so a screen-reader user who presses again, or comes back to it, hears that it is unavailable. It is never natively `disabled`: Chromium and Firefox move focus to the page when a focused button becomes disabled.
|
|
257
|
+
- The guard is the Button's own run, not its look. React may hold the commit that ends the action while another async action elsewhere is pending (or while the result suspends): the button keeps `data-pending` and `aria-disabled` in that window, but its own work has settled, so a click there starts a new run rather than being dropped. A `formAction` Button follows React's form status instead and stays guarded until its submission commits.
|
|
258
|
+
- An ordered sequence whose steps see each other's results is `useActionState` (pass its dispatch as `formAction`, or call it from the action).
|
|
259
|
+
|
|
260
|
+
## Suspense
|
|
261
|
+
|
|
262
|
+
Concept: [Suspense](../concepts/suspense.md)
|
|
263
|
+
|
|
264
|
+
`data-pending` lasts until the commit that ends the action, including a Suspense wait of what that commit renders.
|
|
265
|
+
|
|
266
|
+
## Browser-owned state
|
|
267
|
+
|
|
268
|
+
Concept: [Browser-owned state](../concepts/browser-owned-state.md)
|
|
269
|
+
|
|
270
|
+
A `commandfor` / `command` Button's command and a link's navigation are performed by the browser.
|
|
271
|
+
|
|
272
|
+
## Before hydration
|
|
273
|
+
|
|
274
|
+
Concept: [Server Components](../concepts/server-components.md#before-hydration)
|
|
275
|
+
|
|
276
|
+
A `commandfor` / `command` Button runs its command, a Server Function `formAction` submits (React's progressive enhancement) and a `render={<a href>}` link navigates. An `action` Button does nothing until hydration; a Server Function is a valid `action` once hydrated. The server HTML carries no `aria-disabled` and no `data-pending`.
|
|
277
|
+
|
|
278
|
+
### From a Server Component
|
|
279
|
+
|
|
280
|
+
```tsx title="ButtonInvoker.tsx"
|
|
281
|
+
// No "use client": this file is a Server Component. It renders Button (a client module) with
|
|
282
|
+
// serialisable props only: `commandfor` / `command` are plain attributes, so the browser opens
|
|
283
|
+
// and closes the dialog before hydration and with JavaScript off. A Server Function would also be
|
|
284
|
+
// a valid `action` or `formAction` here; this static site has none.
|
|
285
|
+
import { Button } from "@funstack/ui/button";
|
|
286
|
+
import { ButtonCssPending } from "./ButtonCssPending.js";
|
|
287
|
+
|
|
288
|
+
export function ButtonInvoker() {
|
|
289
|
+
return (
|
|
290
|
+
<div className="demo-row">
|
|
291
|
+
<Button className="demo-btn" commandfor="button-invoker-preview" command="show-modal">
|
|
292
|
+
Preview
|
|
293
|
+
</Button>
|
|
294
|
+
<dialog id="button-invoker-preview" className="demo-dialog" aria-labelledby="bip-title">
|
|
295
|
+
<h2 id="bip-title">Preview</h2>
|
|
296
|
+
<p>Opened by the browser's Invoker Command, no JavaScript involved.</p>
|
|
297
|
+
<div className="demo-dialog-actions">
|
|
298
|
+
<Button className="demo-btn" commandfor="button-invoker-preview" command="close">
|
|
299
|
+
Close
|
|
300
|
+
</Button>
|
|
301
|
+
</div>
|
|
302
|
+
</dialog>
|
|
303
|
+
{/* Pending styled by [data-pending] CSS only (no function children). */}
|
|
304
|
+
<ButtonCssPending />
|
|
305
|
+
</div>
|
|
306
|
+
);
|
|
307
|
+
}
|
|
308
|
+
```
|
|
309
|
+
|
|
310
|
+
`ButtonInvoker.tsx` has no `"use client"`: it is a Server Component that renders Button (a client module) with serialisable props. The Preview button opens the dialog through the browser's Invoker Commands, before hydration and without JavaScript. Sync shows a pending look made by `[data-pending]` CSS alone (`ButtonCssPending.tsx` below; its fake action is the only reason it is a client module on this static site). A Server Component can also pass a Server Function as `action` (it receives `details` with `event` undefined) or as `formAction` (progressively enhanced: the button submits before hydration), and style pending with `[data-pending]` CSS. It cannot pass function `children`, `className`, `style` or `render`, nor a plain client function as `action`: the spinner-in-children pattern needs a Client Component.
|
|
311
|
+
|
|
312
|
+
```tsx title="ButtonCssPending.tsx"
|
|
313
|
+
"use client";
|
|
314
|
+
import { Button } from "@funstack/ui/button";
|
|
315
|
+
import { fakeSave } from "./fake-api.js";
|
|
316
|
+
|
|
317
|
+
// A Button whose pending look is CSS only: static children, a string className, and a spinner
|
|
318
|
+
// drawn by `.demo-btn-css-spinner[data-pending]::after` in button.css. In an app with Server
|
|
319
|
+
// Functions a Server Component renders this directly: `<Button action={sync} ...>`. This static
|
|
320
|
+
// site has none, so the fake action lives in this small client module.
|
|
321
|
+
export function ButtonCssPending() {
|
|
322
|
+
return (
|
|
323
|
+
<Button className="demo-btn demo-btn-css-spinner" action={() => fakeSave("the sync")}>
|
|
324
|
+
Sync
|
|
325
|
+
</Button>
|
|
326
|
+
);
|
|
327
|
+
}
|
|
328
|
+
```
|
|
329
|
+
|
|
330
|
+
```tsx
|
|
331
|
+
// A Server Component
|
|
332
|
+
import { Button } from "@funstack/ui/button";
|
|
333
|
+
import { archive } from "./actions"; // "use server"
|
|
334
|
+
|
|
335
|
+
<Button action={archive.bind(null, post.id)} className="row-action">Archive</Button>
|
|
336
|
+
```
|
|
337
|
+
|
|
338
|
+
Before hydration an `action` Button does nothing on click; a Server Function `formAction` submits natively, a command Button runs its command and a link navigates. The server HTML carries no `aria-disabled` and no `data-pending`.
|
|
339
|
+
|
|
340
|
+
## Forms
|
|
341
|
+
|
|
342
|
+
```tsx title="ButtonFormActions.tsx"
|
|
343
|
+
"use client";
|
|
344
|
+
import { startTransition, useState } from "react";
|
|
345
|
+
import { Button } from "@funstack/ui/button";
|
|
346
|
+
import { Form } from "@funstack/ui/form";
|
|
347
|
+
import { fakeSave } from "./fake-api.js";
|
|
348
|
+
|
|
349
|
+
// One form, three submitters. Form.Submit runs the form's own action and is pending for every
|
|
350
|
+
// submission of the form (the form channel). Each Button formAction runs its own function instead
|
|
351
|
+
// and is pending for its own submissions only; with whilePending="ignore" a second click on a
|
|
352
|
+
// pending one is ignored (by default it would submit again).
|
|
353
|
+
export function ButtonFormActions() {
|
|
354
|
+
const [log, setLog] = useState<string[]>([]);
|
|
355
|
+
const record = (line: string) => startTransition(() => setLog((l) => [line, ...l].slice(0, 4)));
|
|
356
|
+
|
|
357
|
+
return (
|
|
358
|
+
<div className="demo-stack">
|
|
359
|
+
<Form.Root
|
|
360
|
+
className="demo-stack"
|
|
361
|
+
action={async (data: FormData) => {
|
|
362
|
+
await fakeSave("the post", { ms: 1500 });
|
|
363
|
+
record(`Published “${String(data.get("title"))}”.`);
|
|
364
|
+
}}
|
|
365
|
+
>
|
|
366
|
+
<label className="demo-field">
|
|
367
|
+
Title <input name="title" defaultValue="Hello, world" required />
|
|
368
|
+
</label>
|
|
369
|
+
<div className="demo-row">
|
|
370
|
+
<Form.Submit className="demo-btn demo-btn-primary">
|
|
371
|
+
{({ pending }) => (pending ? "Working…" : "Publish")}
|
|
372
|
+
</Form.Submit>
|
|
373
|
+
<Button
|
|
374
|
+
className="demo-btn"
|
|
375
|
+
whilePending="ignore"
|
|
376
|
+
formAction={async (data: FormData) => {
|
|
377
|
+
await fakeSave("the draft", { ms: 1500 });
|
|
378
|
+
record(`Saved a draft of “${String(data.get("title"))}”.`);
|
|
379
|
+
}}
|
|
380
|
+
>
|
|
381
|
+
{({ pending }) => (pending ? "Saving draft…" : "Save draft")}
|
|
382
|
+
</Button>
|
|
383
|
+
<Button
|
|
384
|
+
className="demo-btn"
|
|
385
|
+
whilePending="ignore"
|
|
386
|
+
formAction={async () => {
|
|
387
|
+
await fakeSave("the discard", { ms: 2500 });
|
|
388
|
+
record("Discarded.");
|
|
389
|
+
}}
|
|
390
|
+
>
|
|
391
|
+
{({ pending }) => (pending ? "Discarding…" : "Discard")}
|
|
392
|
+
</Button>
|
|
393
|
+
</div>
|
|
394
|
+
</Form.Root>
|
|
395
|
+
<ul className="demo-readout">
|
|
396
|
+
{log.length === 0 ? <li>Nothing yet.</li> : log.map((line, i) => <li key={i}>{line}</li>)}
|
|
397
|
+
</ul>
|
|
398
|
+
</div>
|
|
399
|
+
);
|
|
400
|
+
}
|
|
401
|
+
```
|
|
402
|
+
|
|
403
|
+
A Button is `type="button"` by default, so an `action` Button never submits the form it sits in. With `formAction` it is a submit button that runs its own function instead of the form's `action`: constraint validation, `FormData` and React's automatic form reset all apply. It is pending for its own submissions only (React reports the submitter's function through `useFormStatus().action`).
|
|
404
|
+
|
|
405
|
+
> **Overlapping submissions**
|
|
406
|
+
>
|
|
407
|
+
> By default a second click on a pending `Button formAction` submits the form again, as React's own `<button formAction>` does. Those submissions are React's form channel, and React drops the rejection of an older overlapping submission: it reaches no Error Boundary and no `reportError`, and the library cannot see it. For a submission that must not overlap, use `whilePending="ignore"` (as in the example above), or pass a `useActionState` dispatch, which React runs in order.
|
|
408
|
+
|
|
409
|
+
| | Form.Submit | Button formAction | Button type="submit" |
|
|
410
|
+
| - | - | - | - |
|
|
411
|
+
| Submits | the form's own `action` | its own function instead | the form's own `action` |
|
|
412
|
+
| `pending` | the form channel: any submitter | its own submissions only | none |
|
|
413
|
+
| A click while pending | not blocked (a `useActionState` dispatch queues it, in order) | submits again; ignored with `whilePending="ignore"` | none |
|
|
414
|
+
| Use | the one primary submit button | secondary submitters | rarely; `Form.Submit` is the documented spelling |
|
|
415
|
+
|
|
416
|
+
Inside a [Form.Root](field.md), a `Button formAction` goes React's way: its function runs, the form's `action` does not, and `Form.Root` shows `data-pending` as for any submission (its `errors` are not fed by it; to route field errors, pass the dispatch of the same `useActionState` as `formAction`). Implicit submission (Enter in a text field) clicks the form's first submit button: if that is a pending `Button formAction`, it submits again, or with `whilePending="ignore"` the click is ignored and nothing is submitted twice.
|
|
417
|
+
|
|
418
|
+
> **Which button?**
|
|
419
|
+
>
|
|
420
|
+
> - Submits the form with its own action: [Form.Submit](field.md).
|
|
421
|
+
> - Runs an action, then closes an overlay: `Dialog.Close`, `Popover.Close`.
|
|
422
|
+
> - An item of a menu: [Menu.Item](menu.md). A Button inside a `Menu.Popup` is not a menu item.
|
|
423
|
+
> - Holds a pressed state: [Toggle](toggle.md).
|
|
424
|
+
> - A command in a [Toolbar](toolbar.md): `Button` itself.
|
|
425
|
+
> - Anything else whose click is a transition: Button.
|
|
426
|
+
|
|
427
|
+
## Styling
|
|
428
|
+
|
|
429
|
+
```css
|
|
430
|
+
.btn[data-pending] { cursor: progress; }
|
|
431
|
+
.btn[data-pending] .label { visibility: hidden; }
|
|
432
|
+
.btn[data-pending]::after { content: ""; /* spinner */ }
|
|
433
|
+
.btn[data-disabled], .btn[aria-disabled="true"]:not([data-pending]) { opacity: .5; }
|
|
434
|
+
|
|
435
|
+
@media (prefers-reduced-motion: reduce) {
|
|
436
|
+
::view-transition-group(*),
|
|
437
|
+
::view-transition-old(*),
|
|
438
|
+
::view-transition-new(*) {
|
|
439
|
+
animation: none !important;
|
|
440
|
+
}
|
|
441
|
+
}
|
|
442
|
+
```
|
|
443
|
+
|
|
444
|
+
Tailwind: `data-pending:cursor-progress data-disabled:opacity-50`. With `transition`, keep the reduced-motion block in your stylesheet; the Button adds no view transition types.
|
|
445
|
+
|
|
446
|
+
## Recipes
|
|
447
|
+
|
|
448
|
+
### Composition
|
|
449
|
+
|
|
450
|
+
```tsx title="ButtonCompose.tsx"
|
|
451
|
+
"use client";
|
|
452
|
+
import { startTransition, useState } from "react";
|
|
453
|
+
import { Button } from "@funstack/ui/button";
|
|
454
|
+
import { Dialog } from "@funstack/ui/dialog";
|
|
455
|
+
import { Tooltip } from "@funstack/ui/tooltip";
|
|
456
|
+
import { fakeSave } from "./fake-api.js";
|
|
457
|
+
|
|
458
|
+
// A Trigger that renders a Button: one click runs the Button's action and opens the dialog. The
|
|
459
|
+
// action does not await its work (`void`), because React commits the open together with the
|
|
460
|
+
// transition the click started: an awaited action would hold the dialog closed until it settles.
|
|
461
|
+
// The Tooltip on the Archive Button keeps opening on hover and focus while the Button is pending.
|
|
462
|
+
export function ButtonCompose() {
|
|
463
|
+
const [prefetches, setPrefetches] = useState(0);
|
|
464
|
+
|
|
465
|
+
return (
|
|
466
|
+
<div className="demo-row">
|
|
467
|
+
<Dialog.Root defaultOpen={false}>
|
|
468
|
+
<Dialog.Trigger
|
|
469
|
+
render={
|
|
470
|
+
<Button
|
|
471
|
+
className="demo-btn"
|
|
472
|
+
action={() => {
|
|
473
|
+
void fakeSave("the profile").then(() =>
|
|
474
|
+
startTransition(() => setPrefetches((n) => n + 1)),
|
|
475
|
+
);
|
|
476
|
+
}}
|
|
477
|
+
/>
|
|
478
|
+
}
|
|
479
|
+
>
|
|
480
|
+
Edit profile…
|
|
481
|
+
</Dialog.Trigger>
|
|
482
|
+
<Dialog.Popup className="demo-dialog">
|
|
483
|
+
<Dialog.Title>Edit profile</Dialog.Title>
|
|
484
|
+
<Dialog.Description>Profiles prefetched so far: {prefetches}.</Dialog.Description>
|
|
485
|
+
<div className="demo-dialog-actions">
|
|
486
|
+
<Dialog.Close className="demo-button">Close</Dialog.Close>
|
|
487
|
+
</div>
|
|
488
|
+
</Dialog.Popup>
|
|
489
|
+
</Dialog.Root>
|
|
490
|
+
|
|
491
|
+
<Tooltip.Root>
|
|
492
|
+
<Tooltip.Trigger
|
|
493
|
+
render={
|
|
494
|
+
<Button className="demo-btn" action={() => fakeSave("the archive", { ms: 3000 })} />
|
|
495
|
+
}
|
|
496
|
+
>
|
|
497
|
+
Archive
|
|
498
|
+
</Tooltip.Trigger>
|
|
499
|
+
<Tooltip.Popup className="demo-tip">Moves the thread out of your inbox</Tooltip.Popup>
|
|
500
|
+
</Tooltip.Root>
|
|
501
|
+
</div>
|
|
502
|
+
);
|
|
503
|
+
}
|
|
504
|
+
```
|
|
505
|
+
|
|
506
|
+
`<Dialog.Trigger render={<Button action={a} />}>` runs `a` and opens the dialog on one click: the Trigger's handler runs first and cancels the click (its command), and the Button runs its action anyway; a cancelled click is not a veto for a Button. The two updates start in one event, so React commits them together: **an awaited `a` holds the dialog closed until it settles** (the Trigger already shows `data-open` and `data-pending`). For a prefetch, do not await it, as above. The same works with `Popover.Trigger` and `Tooltip.Trigger`; a Tooltip keeps opening on hover and focus while the Button is pending, because a pending Button is not natively disabled and removes no listeners. A second click on the Trigger runs `a` again unless the Button has `whilePending="ignore"`.
|
|
507
|
+
|
|
508
|
+
`commandfor` / `command` pass through: without `action` the browser runs the command, before and after hydration. With both, one click runs the action and the command; a click while pending runs both again, or with `whilePending="ignore"` neither. Inside a [Toolbar](toolbar.md) a disabled Button stays focusable and in the arrow-key sequence (`aria-disabled`, the APG Toolbar rule).
|