@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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"select-root.mjs","names":[],"sources":["../../src/select/select-root.tsx"],"sourcesContent":["\"use client\";\nimport { useMemo, useRef, useState } from \"react\";\nimport type { ChangeEvent, ComponentPropsWithRef, CSSProperties, ReactNode } from \"react\";\nimport { createActionDetails } from \"../internal/action-details.js\";\nimport { dataAttr } from \"../internal/data-attr.js\";\nimport { transitionTypes } from \"../internal/transition-types.js\";\nimport type {\n ActionDetails,\n ChangeAction,\n ChangeReason,\n RenderProp,\n StateValue,\n} from \"../internal/types.js\";\nimport { useControllableAction } from \"../internal/use-controllable-action.js\";\nimport {\n fieldInputProps,\n useFieldControl,\n useFieldValueChange,\n} from \"../internal/use-field-control.js\";\nimport { useMergedRefs } from \"../internal/use-merged-refs.js\";\nimport { useNativeSelectValue } from \"../internal/use-native-select-value.js\";\nimport { useRender } from \"../internal/use-render.js\";\nimport { SelectContext } from \"./select-context.js\";\nimport type { SelectContextValue } from \"./select-context.js\";\nimport { useSelectPartRef } from \"./select-dom.js\";\n\n/** Details passed as the second argument of `valueChangeAction`. */\nexport interface SelectValueChangeDetails extends ActionDetails {\n /**\n * `\"activate\"`: the user picked an option (pointer, keyboard, typeahead, or browser autofill,\n * which the library cannot tell from a pick); `details.event` is the native `change` event.\n * `\"platform\"`: the browser changed the value without a pick the library saw: a form reset\n * (`details.event` is the `reset` event), or a pick before hydration / Firefox form-state\n * restoration reconciled at mount (`details.event` is `undefined`).\n */\n readonly reason: ChangeReason;\n}\n\nexport interface SelectRootState {\n /** Optimistic value. Content rendered from it must not suspend. */\n readonly value: string;\n /** An action dispatched through this Select is in flight. */\n readonly pending: boolean;\n /** The `disabled` prop. */\n readonly disabled: boolean;\n}\n\nexport interface SelectRootProps extends Omit<\n ComponentPropsWithRef<\"select\">,\n | \"value\"\n | \"defaultValue\"\n | \"onChange\"\n | \"multiple\"\n | \"size\"\n | \"disabled\"\n | \"className\"\n | \"style\"\n | \"children\"\n> {\n /** Controlled value. `undefined` means uncontrolled. Use `\"\"` for the placeholder option. */\n value?: string;\n /**\n * Initial value in uncontrolled mode, and the value a form reset returns to (the latest prop is\n * mirrored into the options' `defaultSelected`). When omitted, the browser's choice (an option\n * whose value is `\"\"`, else the first enabled option) is adopted at mount, without a dispatch,\n * and is what a form reset returns to. Until a pick (or a platform change) sets the value,\n * options that mount later without the adopted one (a Suspense fallback) adopt again.\n */\n defaultValue?: string;\n /**\n * Runs inside the Root's transition whenever the selected option changes. May be sync or async\n * (also a Server Function); rejections reach the nearest Error Boundary and roll the selection\n * back.\n *\n * In engines whose closed select changes the value on every arrow press (Firefox, Safari with\n * native appearance), every press dispatches; the latest dispatch wins. A `setState` placed\n * after your own `await` is not a Transition update; wrap it in `startTransition` (React\n * limitation). Controlled mode is the way to veto a change.\n */\n valueChangeAction?: ChangeAction<string, SelectValueChangeDetails>;\n /** Native `disabled`. Never set by the library while pending. */\n disabled?: boolean;\n className?: StateValue<string | undefined, SelectRootState>;\n style?: StateValue<CSSProperties | undefined, SelectRootState>;\n children?: StateValue<ReactNode, SelectRootState>;\n /** Replace the rendered element. Must keep a `<select>`. */\n render?: RenderProp<ComponentPropsWithRef<\"select\">, SelectRootState>;\n}\n\n/**\n * The `<select>` itself: owns the value, the transition, the form-reset listener, the mount\n * reconciliation and the re-apply of late options (design/components/select.md 15.2). Renders\n * `value={optimistic}`: react-dom restores a controlled select to its props after every event,\n * and only the sync-lane optimistic value survives that restore.\n *\n * Owned keys (conventions 1.2): `value`, `disabled`, `data-pending`, `data-disabled`, `onChange`;\n * inside a `Field.Root` also `id`, `name`, `required`, `aria-invalid`, `aria-describedby`\n * (token-merged) and `data-invalid`, and `disabled` / `name` / `required` default from the Field.\n */\nexport function SelectRoot({\n value,\n defaultValue,\n valueChangeAction,\n disabled: disabledProp,\n className,\n style,\n children,\n render,\n ...rest\n}: SelectRootProps) {\n const { ref: libraryRef, node: selectRef } = useSelectPartRef<HTMLSelectElement>(\n \"Select.Root\",\n \"select\",\n );\n // Inside a Field.Root (design/components/field-form.md 7.2) the Field owns the id and the ARIA\n // wiring, and `name` / `required` / `disabled` default from it.\n const field = useFieldControl({\n labelable: true,\n name: rest.name,\n disabled: disabledProp,\n required: rest.required,\n id: rest.id,\n component: \"Select.Root\",\n });\n const disabled = field.disabled;\n const rootRef = useMergedRefs<HTMLSelectElement>(libraryRef, field.ref);\n\n const { optimistic, pending, dispatch, latestInFlight, adopt } = useControllableAction<\n string,\n SelectValueChangeDetails\n >({\n controlled: value,\n defaultValue,\n initialValue: \"\",\n action: valueChangeAction,\n transitionTypes: () => transitionTypes(\"select\"),\n warn: { component: \"Select.Root\", prop: \"value\" },\n });\n // Inside a Field: a value React writes with no event (a rejected action rolling back, a\n // controlled change) re-reads validity and `validate` after the commit.\n useFieldValueChange(optimistic);\n // Deliberately no warning when neither `value` nor `defaultValue` is given: the browser's\n // first-option default is adopted (design decisions 3 and 4).\n\n // Controlled: the mount-time value is the reset target (conventions 3.8 rule 6). Neither\n // `value` nor `defaultValue`: the value adopted at mount, chosen inside the hook.\n const [mountValue] = useState(value);\n const resetTarget = value === undefined ? defaultValue : (mountValue ?? value);\n\n // Any dispatch, a pick or a platform change, ends the adoption of the browser's default.\n const established = useRef(false);\n const dispatchChange = (next: string, details: SelectValueChangeDetails) => {\n established.current = true;\n dispatch(next, details);\n };\n\n const { optionMounted } = useNativeSelectValue({\n ref: selectRef,\n optimistic,\n latestInFlight,\n resetTarget,\n adoptDefault:\n value === undefined && defaultValue === undefined\n ? { adopt, established: () => established.current }\n : undefined,\n onPlatformChange: (next, event) =>\n dispatchChange(next, createActionDetails(event, { reason: \"platform\" })),\n });\n\n // Memoised: every member is a state value, a prop or a stable callback.\n const context = useMemo<SelectContextValue>(\n () => ({ optimistic, pending, disabled, groupDisabled: false, optionMounted }),\n [optimistic, pending, disabled, optionMounted],\n );\n const state: SelectRootState = { value: optimistic, pending, disabled };\n\n const element = useRender<ComponentPropsWithRef<\"select\">, SelectRootState>({\n defaultElement: \"select\",\n render,\n state,\n className,\n style,\n children,\n props: rest,\n libraryProps: {\n ...fieldInputProps(field),\n value: optimistic,\n disabled,\n \"data-pending\": dataAttr(pending),\n \"data-disabled\": dataAttr(disabled),\n onChange: (event: ChangeEvent<HTMLSelectElement>) => {\n // A natively disabled select fires no change; this covers `render` elements.\n if (disabled) return;\n const next = event.currentTarget.value;\n // No-op rule against the optimistic value (conventions 2.3, design 4.2).\n if (next === optimistic) return;\n dispatchChange(next, createActionDetails(event.nativeEvent, { reason: \"activate\" }));\n },\n },\n ref: rootRef,\n });\n\n return <SelectContext value={context}>{element}</SelectContext>;\n}\n\nSelectRoot.displayName = \"SelectRoot\";\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAmGA,SAAgB,WAAW,EACzB,OACA,cACA,mBACA,UAAU,cACV,WACA,OACA,UACA,QACA,GAAG,QACe;CAClB,MAAM,EAAE,KAAK,YAAY,MAAM,cAAc,iBAC3C,eACA,QACF;CAGA,MAAM,QAAQ,gBAAgB;EAC5B,WAAW;EACX,MAAM,KAAK;EACX,UAAU;EACV,UAAU,KAAK;EACf,IAAI,KAAK;EACT,WAAW;CACb,CAAC;CACD,MAAM,WAAW,MAAM;CACvB,MAAM,UAAU,cAAiC,YAAY,MAAM,GAAG;CAEtE,MAAM,EAAE,YAAY,SAAS,UAAU,gBAAgB,UAAU,sBAG/D;EACA,YAAY;EACZ;EACA,cAAc;EACd,QAAQ;EACR,uBAAuB,gBAAgB,QAAQ;EAC/C,MAAM;GAAE,WAAW;GAAe,MAAM;EAAQ;CAClD,CAAC;CAGD,oBAAoB,UAAU;CAM9B,MAAM,CAAC,cAAc,SAAS,KAAK;CACnC,MAAM,cAAc,UAAU,KAAA,IAAY,eAAgB,cAAc;CAGxE,MAAM,cAAc,OAAO,KAAK;CAChC,MAAM,kBAAkB,MAAc,YAAsC;EAC1E,YAAY,UAAU;EACtB,SAAS,MAAM,OAAO;CACxB;CAEA,MAAM,EAAE,kBAAkB,qBAAqB;EAC7C,KAAK;EACL;EACA;EACA;EACA,cACE,UAAU,KAAA,KAAa,iBAAiB,KAAA,IACpC;GAAE;GAAO,mBAAmB,YAAY;EAAQ,IAChD,KAAA;EACN,mBAAmB,MAAM,UACvB,eAAe,MAAM,oBAAoB,OAAO,EAAE,QAAQ,WAAW,CAAC,CAAC;CAC3E,CAAC;CAGD,MAAM,UAAU,eACP;EAAE;EAAY;EAAS;EAAU,eAAe;EAAO;CAAc,IAC5E;EAAC;EAAY;EAAS;EAAU;CAAa,CAC/C;CAGA,MAAM,UAAU,UAA4D;EAC1E,gBAAgB;EAChB;EACA,OAAA;GAL+B,OAAO;GAAY;GAAS;EAKvD;EACJ;EACA;EACA;EACA,OAAO;EACP,cAAc;GACZ,GAAG,gBAAgB,KAAK;GACxB,OAAO;GACP;GACA,gBAAgB,SAAS,OAAO;GAChC,iBAAiB,SAAS,QAAQ;GAClC,WAAW,UAA0C;IAEnD,IAAI,UAAU;IACd,MAAM,OAAO,MAAM,cAAc;IAEjC,IAAI,SAAS,YAAY;IACzB,eAAe,MAAM,oBAAoB,MAAM,aAAa,EAAE,QAAQ,WAAW,CAAC,CAAC;GACrF;EACF;EACA,KAAK;CACP,CAAC;CAED,OAAO,oBAAC,eAAD;EAAe,OAAO;EAAU,UAAA;CAAuB,CAAA;AAChE;AAEA,WAAW,cAAc"}
|
|
1
|
+
{"version":3,"file":"select-root.mjs","names":[],"sources":["../../src/select/select-root.tsx"],"sourcesContent":["\"use client\";\nimport { useMemo, useRef, useState } from \"react\";\nimport type { ChangeEvent, ComponentPropsWithRef, CSSProperties, ReactNode } from \"react\";\nimport { createActionDetails } from \"../internal/action-details.js\";\nimport { dataAttr } from \"../internal/data-attr.js\";\nimport { transitionTypes } from \"../internal/transition-types.js\";\nimport type {\n ActionDetails,\n ChangeAction,\n ChangeReason,\n RenderProp,\n StateValue,\n} from \"../internal/types.js\";\nimport { useControllableAction } from \"../internal/use-controllable-action.js\";\nimport {\n fieldInputProps,\n useFieldControl,\n useFieldValueChange,\n} from \"../internal/use-field-control.js\";\nimport { useMergedRefs } from \"../internal/use-merged-refs.js\";\nimport { useNativeSelectValue } from \"../internal/use-native-select-value.js\";\nimport { useRender } from \"../internal/use-render.js\";\nimport { SelectContext } from \"./select-context.js\";\nimport type { SelectContextValue } from \"./select-context.js\";\nimport { useSelectPartRef } from \"./select-dom.js\";\n\n/** Details passed as the second argument of `valueChangeAction`. */\nexport interface SelectValueChangeDetails extends ActionDetails {\n /**\n * `\"activate\"`: the user picked an option (pointer, keyboard, typeahead, or browser autofill,\n * which the library cannot tell from a pick); `details.event` is the native `change` event.\n * `\"platform\"`: the browser changed the value without a pick the library saw: a form reset\n * (`details.event` is the `reset` event), or a pick before hydration / Firefox form-state\n * restoration reconciled at mount (`details.event` is `undefined`).\n */\n readonly reason: ChangeReason;\n}\n\n/**\n * State of `Select.Root`, `Select.Trigger`, `Select.Value`, `Select.Group`, `Select.GroupLabel`,\n * `Select.Separator`, passed to the function forms of `className`, `style`, `children` and\n * `render`.\n */\nexport interface SelectRootState {\n /** Optimistic value. Content rendered from it must not suspend. */\n readonly value: string;\n /** An action dispatched through this Select is in flight. */\n readonly pending: boolean;\n /** The `disabled` prop. */\n readonly disabled: boolean;\n}\n\n/**\n * Props of `Select.Root`.\n *\n * @see https://ui.funstack.work/components/select\n */\nexport interface SelectRootProps extends Omit<\n ComponentPropsWithRef<\"select\">,\n | \"value\"\n | \"defaultValue\"\n | \"onChange\"\n | \"multiple\"\n | \"size\"\n | \"disabled\"\n | \"className\"\n | \"style\"\n | \"children\"\n> {\n /** Controlled value. `undefined` means uncontrolled. Use `\"\"` for the placeholder option. */\n value?: string;\n /**\n * Initial value in uncontrolled mode, and the value a form reset returns to (the latest prop is\n * mirrored into the options' `defaultSelected`). When omitted, the browser's choice (an option\n * whose value is `\"\"`, else the first enabled option) is adopted at mount, without a dispatch,\n * and is what a form reset returns to. Until a pick (or a platform change) sets the value,\n * options that mount later without the adopted one (a Suspense fallback) adopt again.\n *\n * @defaultValue the browser's choice\n */\n defaultValue?: string;\n /**\n * Runs inside the Root's transition whenever the selected option changes. May be sync or async\n * (also a Server Function); rejections reach the nearest Error Boundary and roll the selection\n * back.\n *\n * In engines whose closed select changes the value on every arrow press (Firefox, Safari with\n * native appearance), every press dispatches; the latest dispatch wins. A `setState` placed\n * after your own `await` is not a Transition update; wrap it in `startTransition` (React\n * limitation). Controlled mode is the way to veto a change.\n */\n valueChangeAction?: ChangeAction<string, SelectValueChangeDetails>;\n /**\n * Native `disabled`. Never set by the library while pending.\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, SelectRootState>;\n /** Inline style, or a function of the part's state that returns one. */\n style?: StateValue<CSSProperties | undefined, SelectRootState>;\n /**\n * The options and the Trigger. The function form receives the optimistic value; must not suspend.\n */\n children?: StateValue<ReactNode, SelectRootState>;\n /** Replace the rendered element. Must keep a `<select>`. */\n render?: RenderProp<ComponentPropsWithRef<\"select\">, SelectRootState>;\n}\n\n/**\n * The `<select>` itself: owns the value, the transition, the form-reset listener, the mount\n * reconciliation and the re-apply of late options (design/components/select.md 15.2). Renders\n * `value={optimistic}`: react-dom restores a controlled select to its props after every event,\n * and only the sync-lane optimistic value survives that restore.\n *\n * Owned keys (conventions 1.2): `value`, `disabled`, `data-pending`, `data-disabled`, `onChange`;\n * inside a `Field.Root` also `id`, `name`, `required`, `aria-invalid`, `aria-describedby`\n * (token-merged) and `data-invalid`, and `disabled` / `name` / `required` default from the Field.\n *\n * @see https://ui.funstack.work/components/select\n */\nexport function SelectRoot({\n value,\n defaultValue,\n valueChangeAction,\n disabled: disabledProp,\n className,\n style,\n children,\n render,\n ...rest\n}: SelectRootProps) {\n const { ref: libraryRef, node: selectRef } = useSelectPartRef<HTMLSelectElement>(\n \"Select.Root\",\n \"select\",\n );\n // Inside a Field.Root (design/components/field-form.md 7.2) the Field owns the id and the ARIA\n // wiring, and `name` / `required` / `disabled` default from it.\n const field = useFieldControl({\n labelable: true,\n name: rest.name,\n disabled: disabledProp,\n required: rest.required,\n id: rest.id,\n component: \"Select.Root\",\n });\n const disabled = field.disabled;\n const rootRef = useMergedRefs<HTMLSelectElement>(libraryRef, field.ref);\n\n const { optimistic, pending, dispatch, latestInFlight, adopt } = useControllableAction<\n string,\n SelectValueChangeDetails\n >({\n controlled: value,\n defaultValue,\n initialValue: \"\",\n action: valueChangeAction,\n transitionTypes: () => transitionTypes(\"select\"),\n warn: { component: \"Select.Root\", prop: \"value\" },\n });\n // Inside a Field: a value React writes with no event (a rejected action rolling back, a\n // controlled change) re-reads validity and `validate` after the commit.\n useFieldValueChange(optimistic);\n // Deliberately no warning when neither `value` nor `defaultValue` is given: the browser's\n // first-option default is adopted (design decisions 3 and 4).\n\n // Controlled: the mount-time value is the reset target (conventions 3.8 rule 6). Neither\n // `value` nor `defaultValue`: the value adopted at mount, chosen inside the hook.\n const [mountValue] = useState(value);\n const resetTarget = value === undefined ? defaultValue : (mountValue ?? value);\n\n // Any dispatch, a pick or a platform change, ends the adoption of the browser's default.\n const established = useRef(false);\n const dispatchChange = (next: string, details: SelectValueChangeDetails) => {\n established.current = true;\n dispatch(next, details);\n };\n\n const { optionMounted } = useNativeSelectValue({\n ref: selectRef,\n optimistic,\n latestInFlight,\n resetTarget,\n adoptDefault:\n value === undefined && defaultValue === undefined\n ? { adopt, established: () => established.current }\n : undefined,\n onPlatformChange: (next, event) =>\n dispatchChange(next, createActionDetails(event, { reason: \"platform\" })),\n });\n\n // Memoised: every member is a state value, a prop or a stable callback.\n const context = useMemo<SelectContextValue>(\n () => ({ optimistic, pending, disabled, groupDisabled: false, optionMounted }),\n [optimistic, pending, disabled, optionMounted],\n );\n const state: SelectRootState = { value: optimistic, pending, disabled };\n\n const element = useRender<ComponentPropsWithRef<\"select\">, SelectRootState>({\n defaultElement: \"select\",\n render,\n state,\n className,\n style,\n children,\n props: rest,\n libraryProps: {\n ...fieldInputProps(field),\n value: optimistic,\n disabled,\n \"data-pending\": dataAttr(pending),\n \"data-disabled\": dataAttr(disabled),\n onChange: (event: ChangeEvent<HTMLSelectElement>) => {\n // A natively disabled select fires no change; this covers `render` elements.\n if (disabled) return;\n const next = event.currentTarget.value;\n // No-op rule against the optimistic value (conventions 2.3, design 4.2).\n if (next === optimistic) return;\n dispatchChange(next, createActionDetails(event.nativeEvent, { reason: \"activate\" }));\n },\n },\n ref: rootRef,\n });\n\n return <SelectContext value={context}>{element}</SelectContext>;\n}\n\nSelectRoot.displayName = \"SelectRoot\";\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AA0HA,SAAgB,WAAW,EACzB,OACA,cACA,mBACA,UAAU,cACV,WACA,OACA,UACA,QACA,GAAG,QACe;CAClB,MAAM,EAAE,KAAK,YAAY,MAAM,cAAc,iBAC3C,eACA,QACF;CAGA,MAAM,QAAQ,gBAAgB;EAC5B,WAAW;EACX,MAAM,KAAK;EACX,UAAU;EACV,UAAU,KAAK;EACf,IAAI,KAAK;EACT,WAAW;CACb,CAAC;CACD,MAAM,WAAW,MAAM;CACvB,MAAM,UAAU,cAAiC,YAAY,MAAM,GAAG;CAEtE,MAAM,EAAE,YAAY,SAAS,UAAU,gBAAgB,UAAU,sBAG/D;EACA,YAAY;EACZ;EACA,cAAc;EACd,QAAQ;EACR,uBAAuB,gBAAgB,QAAQ;EAC/C,MAAM;GAAE,WAAW;GAAe,MAAM;EAAQ;CAClD,CAAC;CAGD,oBAAoB,UAAU;CAM9B,MAAM,CAAC,cAAc,SAAS,KAAK;CACnC,MAAM,cAAc,UAAU,KAAA,IAAY,eAAgB,cAAc;CAGxE,MAAM,cAAc,OAAO,KAAK;CAChC,MAAM,kBAAkB,MAAc,YAAsC;EAC1E,YAAY,UAAU;EACtB,SAAS,MAAM,OAAO;CACxB;CAEA,MAAM,EAAE,kBAAkB,qBAAqB;EAC7C,KAAK;EACL;EACA;EACA;EACA,cACE,UAAU,KAAA,KAAa,iBAAiB,KAAA,IACpC;GAAE;GAAO,mBAAmB,YAAY;EAAQ,IAChD,KAAA;EACN,mBAAmB,MAAM,UACvB,eAAe,MAAM,oBAAoB,OAAO,EAAE,QAAQ,WAAW,CAAC,CAAC;CAC3E,CAAC;CAGD,MAAM,UAAU,eACP;EAAE;EAAY;EAAS;EAAU,eAAe;EAAO;CAAc,IAC5E;EAAC;EAAY;EAAS;EAAU;CAAa,CAC/C;CAGA,MAAM,UAAU,UAA4D;EAC1E,gBAAgB;EAChB;EACA,OAAA;GAL+B,OAAO;GAAY;GAAS;EAKvD;EACJ;EACA;EACA;EACA,OAAO;EACP,cAAc;GACZ,GAAG,gBAAgB,KAAK;GACxB,OAAO;GACP;GACA,gBAAgB,SAAS,OAAO;GAChC,iBAAiB,SAAS,QAAQ;GAClC,WAAW,UAA0C;IAEnD,IAAI,UAAU;IACd,MAAM,OAAO,MAAM,cAAc;IAEjC,IAAI,SAAS,YAAY;IACzB,eAAe,MAAM,oBAAoB,MAAM,aAAa,EAAE,QAAQ,WAAW,CAAC,CAAC;GACrF;EACF;EACA,KAAK;CACP,CAAC;CAED,OAAO,oBAAC,eAAD;EAAe,OAAO;EAAU,UAAA;CAAuB,CAAA;AAChE;AAEA,WAAW,cAAc"}
|
|
@@ -2,8 +2,15 @@ import { RenderProp, StateValue } from "../internal/types.mjs";
|
|
|
2
2
|
import { SelectRootState } from "./select-root.mjs";
|
|
3
3
|
import { CSSProperties, ComponentPropsWithRef } from "react";
|
|
4
4
|
//#region src/select/select-separator.d.ts
|
|
5
|
+
/**
|
|
6
|
+
* Props of `Select.Separator`.
|
|
7
|
+
*
|
|
8
|
+
* @see https://ui.funstack.work/components/select
|
|
9
|
+
*/
|
|
5
10
|
export interface SelectSeparatorProps extends Omit<ComponentPropsWithRef<"hr">, "className" | "style" | "children"> {
|
|
11
|
+
/** Class name, or a function of the part's state that returns one. */
|
|
6
12
|
className?: StateValue<string | undefined, SelectRootState>;
|
|
13
|
+
/** Inline style, or a function of the part's state that returns one. */
|
|
7
14
|
style?: StateValue<CSSProperties | undefined, SelectRootState>;
|
|
8
15
|
/** Replace the rendered element. */
|
|
9
16
|
render?: RenderProp<ComponentPropsWithRef<"hr">, SelectRootState>;
|
|
@@ -11,6 +18,8 @@ export interface SelectSeparatorProps extends Omit<ComponentPropsWithRef<"hr">,
|
|
|
11
18
|
/**
|
|
12
19
|
* A decorative `<hr>` between options or groups (exposed as `separator` by Chromium's
|
|
13
20
|
* customizable select; a line in native pickers). Owns no keys.
|
|
21
|
+
*
|
|
22
|
+
* @see https://ui.funstack.work/components/select
|
|
14
23
|
*/
|
|
15
24
|
export declare function SelectSeparator({ className, style, render, ...rest }: SelectSeparatorProps): import("react").ReactNode;
|
|
16
25
|
export declare namespace SelectSeparator {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"select-separator.d.mts","names":[],"sources":["../../src/select/select-separator.tsx"],"mappings":"
|
|
1
|
+
{"version":3,"file":"select-separator.d.mts","names":[],"sources":["../../src/select/select-separator.tsx"],"mappings":";;;;;;;;;iBAYiB,6BAA6B,KAC5C;;EAIA,YAAY,+BAA+B;;EAE3C,QAAQ,WAAW,2BAA2B;;EAE9C,SAAS,WAAW,6BAA6B;;;;;;;;wBASnC,kBAAkB,WAAW,OAAO,WAAW,QAAQ,uCAAoB;yBAA3E"}
|
|
@@ -5,6 +5,8 @@ import { useSelectContext } from "./select-context.mjs";
|
|
|
5
5
|
/**
|
|
6
6
|
* A decorative `<hr>` between options or groups (exposed as `separator` by Chromium's
|
|
7
7
|
* customizable select; a line in native pickers). Owns no keys.
|
|
8
|
+
*
|
|
9
|
+
* @see https://ui.funstack.work/components/select
|
|
8
10
|
*/
|
|
9
11
|
function SelectSeparator({ className, style, render, ...rest }) {
|
|
10
12
|
const ctx = useSelectContext("Select.Separator");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"select-separator.mjs","names":[],"sources":["../../src/select/select-separator.tsx"],"sourcesContent":["\"use client\";\nimport type { ComponentPropsWithRef, CSSProperties } from \"react\";\nimport type { RenderProp, StateValue } from \"../internal/types.js\";\nimport { useRender } from \"../internal/use-render.js\";\nimport { useSelectContext } from \"./select-context.js\";\nimport type { SelectRootState } from \"./select-root.js\";\n\nexport interface SelectSeparatorProps extends Omit<\n ComponentPropsWithRef<\"hr\">,\n \"className\" | \"style\" | \"children\"\n> {\n className?: StateValue<string | undefined, SelectRootState>;\n style?: StateValue<CSSProperties | undefined, SelectRootState>;\n /** Replace the rendered element. */\n render?: RenderProp<ComponentPropsWithRef<\"hr\">, SelectRootState>;\n}\n\n/**\n * A decorative `<hr>` between options or groups (exposed as `separator` by Chromium's\n * customizable select; a line in native pickers). Owns no keys.\n */\nexport function SelectSeparator({ className, style, render, ...rest }: SelectSeparatorProps) {\n const ctx = useSelectContext(\"Select.Separator\");\n const state: SelectRootState = {\n value: ctx.optimistic,\n pending: ctx.pending,\n disabled: ctx.disabled,\n };\n return useRender<ComponentPropsWithRef<\"hr\">, SelectRootState>({\n defaultElement: \"hr\",\n render,\n state,\n className,\n style,\n children: undefined,\n props: rest,\n });\n}\n\nSelectSeparator.displayName = \"SelectSeparator\";\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"select-separator.mjs","names":[],"sources":["../../src/select/select-separator.tsx"],"sourcesContent":["\"use client\";\nimport type { ComponentPropsWithRef, CSSProperties } from \"react\";\nimport type { RenderProp, StateValue } from \"../internal/types.js\";\nimport { useRender } from \"../internal/use-render.js\";\nimport { useSelectContext } from \"./select-context.js\";\nimport type { SelectRootState } from \"./select-root.js\";\n\n/**\n * Props of `Select.Separator`.\n *\n * @see https://ui.funstack.work/components/select\n */\nexport interface SelectSeparatorProps extends Omit<\n ComponentPropsWithRef<\"hr\">,\n \"className\" | \"style\" | \"children\"\n> {\n /** Class name, or a function of the part's state that returns one. */\n className?: StateValue<string | undefined, SelectRootState>;\n /** Inline style, or a function of the part's state that returns one. */\n style?: StateValue<CSSProperties | undefined, SelectRootState>;\n /** Replace the rendered element. */\n render?: RenderProp<ComponentPropsWithRef<\"hr\">, SelectRootState>;\n}\n\n/**\n * A decorative `<hr>` between options or groups (exposed as `separator` by Chromium's\n * customizable select; a line in native pickers). Owns no keys.\n *\n * @see https://ui.funstack.work/components/select\n */\nexport function SelectSeparator({ className, style, render, ...rest }: SelectSeparatorProps) {\n const ctx = useSelectContext(\"Select.Separator\");\n const state: SelectRootState = {\n value: ctx.optimistic,\n pending: ctx.pending,\n disabled: ctx.disabled,\n };\n return useRender<ComponentPropsWithRef<\"hr\">, SelectRootState>({\n defaultElement: \"hr\",\n render,\n state,\n className,\n style,\n children: undefined,\n props: rest,\n });\n}\n\nSelectSeparator.displayName = \"SelectSeparator\";\n"],"mappings":";;;;;;;;;;AA8BA,SAAgB,gBAAgB,EAAE,WAAW,OAAO,QAAQ,GAAG,QAA8B;CAC3F,MAAM,MAAM,iBAAiB,kBAAkB;CAC/C,MAAM,QAAyB;EAC7B,OAAO,IAAI;EACX,SAAS,IAAI;EACb,UAAU,IAAI;CAChB;CACA,OAAO,UAAwD;EAC7D,gBAAgB;EAChB;EACA;EACA;EACA;EACA,UAAU,KAAA;EACV,OAAO;CACT,CAAC;AACH;AAEA,gBAAgB,cAAc"}
|
|
@@ -2,8 +2,15 @@ import { RenderProp, StateValue } from "../internal/types.mjs";
|
|
|
2
2
|
import { SelectRootState } from "./select-root.mjs";
|
|
3
3
|
import { CSSProperties, ComponentPropsWithRef, ReactNode } from "react";
|
|
4
4
|
//#region src/select/select-trigger.d.ts
|
|
5
|
+
/**
|
|
6
|
+
* Props of `Select.Trigger`.
|
|
7
|
+
*
|
|
8
|
+
* @see https://ui.funstack.work/components/select
|
|
9
|
+
*/
|
|
5
10
|
export interface SelectTriggerProps extends Omit<ComponentPropsWithRef<"button">, "type" | "className" | "style" | "children"> {
|
|
11
|
+
/** Class name, or a function of the part's state that returns one. */
|
|
6
12
|
className?: StateValue<string | undefined, SelectRootState>;
|
|
13
|
+
/** Inline style, or a function of the part's state that returns one. */
|
|
7
14
|
style?: StateValue<CSSProperties | undefined, SelectRootState>;
|
|
8
15
|
/**
|
|
9
16
|
* Non-interactive content only (HTML content model of a select's button), usually
|
|
@@ -20,6 +27,8 @@ export interface SelectTriggerProps extends Omit<ComponentPropsWithRef<"button">
|
|
|
20
27
|
* `children`.
|
|
21
28
|
*
|
|
22
29
|
* Owned keys: `type` (always `"button"`), `data-pending`, `data-disabled`.
|
|
30
|
+
*
|
|
31
|
+
* @see https://ui.funstack.work/components/select
|
|
23
32
|
*/
|
|
24
33
|
export declare function SelectTrigger({ className, style, children, render, ...rest }: SelectTriggerProps): ReactNode;
|
|
25
34
|
export declare namespace SelectTrigger {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"select-trigger.d.mts","names":[],"sources":["../../src/select/select-trigger.tsx"],"mappings":"
|
|
1
|
+
{"version":3,"file":"select-trigger.d.mts","names":[],"sources":["../../src/select/select-trigger.tsx"],"mappings":";;;;;;;;;iBAciB,2BAA2B,KAC1C;;EAIA,YAAY,+BAA+B;;EAE3C,QAAQ,WAAW,2BAA2B;;;;;EAK9C,WAAW,WAAW,WAAW;;EAEjC,SAAS,WAAW,iCAAiC;;;;;;;;;;;;wBAsBvC,gBAAgB,WAAW,OAAO,UAAU,WAAW,QAAQ,qBAAkB;yBAAjF"}
|
|
@@ -16,6 +16,8 @@ function firstChildOfSelect(el) {
|
|
|
16
16
|
* `children`.
|
|
17
17
|
*
|
|
18
18
|
* Owned keys: `type` (always `"button"`), `data-pending`, `data-disabled`.
|
|
19
|
+
*
|
|
20
|
+
* @see https://ui.funstack.work/components/select
|
|
19
21
|
*/
|
|
20
22
|
function SelectTrigger({ className, style, children, render, ...rest }) {
|
|
21
23
|
const ctx = useSelectContext("Select.Trigger");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"select-trigger.mjs","names":[],"sources":["../../src/select/select-trigger.tsx"],"sourcesContent":["\"use client\";\nimport type { ComponentPropsWithRef, CSSProperties, ReactNode } from \"react\";\nimport { dataAttr } from \"../internal/data-attr.js\";\nimport type { RenderProp, StateValue } from \"../internal/types.js\";\nimport { useRender } from \"../internal/use-render.js\";\nimport { useSelectContext } from \"./select-context.js\";\nimport { useSelectPartRef } from \"./select-dom.js\";\nimport type { SelectRootState } from \"./select-root.js\";\n\nexport interface SelectTriggerProps extends Omit<\n ComponentPropsWithRef<\"button\">,\n \"type\" | \"className\" | \"style\" | \"children\"\n> {\n className?: StateValue<string | undefined, SelectRootState>;\n style?: StateValue<CSSProperties | undefined, SelectRootState>;\n /**\n * Non-interactive content only (HTML content model of a select's button), usually\n * `<Select.Value />`. Not rendered by engines without customizable select (Firefox today).\n */\n children?: StateValue<ReactNode, SelectRootState>;\n /** Replace the rendered element. Must keep a `<button>`. */\n render?: RenderProp<ComponentPropsWithRef<\"button\">, SelectRootState>;\n}\n\nfunction firstChildOfSelect(el: HTMLButtonElement): string | null {\n const parent = el.parentElement;\n if (parent?.tagName === \"SELECT\" && parent.firstElementChild === el) return null;\n return (\n \"must be the first child of Select.Root's <select> (HTML content model); elsewhere the \" +\n \"browser does not use it as the select's button.\"\n );\n}\n\n/**\n * The select's own `<button>` (customizable select): replaces the UA button in engines with\n * `appearance: base-select`. Optional; **must be the first child** of `Select.Root`. Its state is\n * the Root's state, so a pending indicator next to `<Select.Value />` goes in its function\n * `children`.\n *\n * Owned keys: `type` (always `\"button\"`), `data-pending`, `data-disabled`.\n */\nexport function SelectTrigger({ className, style, children, render, ...rest }: SelectTriggerProps) {\n const ctx = useSelectContext(\"Select.Trigger\");\n const state: SelectRootState = {\n value: ctx.optimistic,\n pending: ctx.pending,\n disabled: ctx.disabled,\n };\n const { ref } = useSelectPartRef<HTMLButtonElement>(\n \"Select.Trigger\",\n \"button\",\n firstChildOfSelect,\n );\n return useRender<ComponentPropsWithRef<\"button\">, SelectRootState>({\n defaultElement: \"button\",\n render,\n state,\n className,\n style,\n children,\n props: rest,\n libraryProps: {\n // Explicit: Chromium 156 reports `.type === \"submit\"` for a select's button.\n type: \"button\",\n \"data-pending\": dataAttr(ctx.pending),\n \"data-disabled\": dataAttr(ctx.disabled),\n },\n ref,\n });\n}\n\nSelectTrigger.displayName = \"SelectTrigger\";\n"],"mappings":";;;;;;
|
|
1
|
+
{"version":3,"file":"select-trigger.mjs","names":[],"sources":["../../src/select/select-trigger.tsx"],"sourcesContent":["\"use client\";\nimport type { ComponentPropsWithRef, CSSProperties, ReactNode } from \"react\";\nimport { dataAttr } from \"../internal/data-attr.js\";\nimport type { RenderProp, StateValue } from \"../internal/types.js\";\nimport { useRender } from \"../internal/use-render.js\";\nimport { useSelectContext } from \"./select-context.js\";\nimport { useSelectPartRef } from \"./select-dom.js\";\nimport type { SelectRootState } from \"./select-root.js\";\n\n/**\n * Props of `Select.Trigger`.\n *\n * @see https://ui.funstack.work/components/select\n */\nexport interface SelectTriggerProps extends Omit<\n ComponentPropsWithRef<\"button\">,\n \"type\" | \"className\" | \"style\" | \"children\"\n> {\n /** Class name, or a function of the part's state that returns one. */\n className?: StateValue<string | undefined, SelectRootState>;\n /** Inline style, or a function of the part's state that returns one. */\n style?: StateValue<CSSProperties | undefined, SelectRootState>;\n /**\n * Non-interactive content only (HTML content model of a select's button), usually\n * `<Select.Value />`. Not rendered by engines without customizable select (Firefox today).\n */\n children?: StateValue<ReactNode, SelectRootState>;\n /** Replace the rendered element. Must keep a `<button>`. */\n render?: RenderProp<ComponentPropsWithRef<\"button\">, SelectRootState>;\n}\n\nfunction firstChildOfSelect(el: HTMLButtonElement): string | null {\n const parent = el.parentElement;\n if (parent?.tagName === \"SELECT\" && parent.firstElementChild === el) return null;\n return (\n \"must be the first child of Select.Root's <select> (HTML content model); elsewhere the \" +\n \"browser does not use it as the select's button.\"\n );\n}\n\n/**\n * The select's own `<button>` (customizable select): replaces the UA button in engines with\n * `appearance: base-select`. Optional; **must be the first child** of `Select.Root`. Its state is\n * the Root's state, so a pending indicator next to `<Select.Value />` goes in its function\n * `children`.\n *\n * Owned keys: `type` (always `\"button\"`), `data-pending`, `data-disabled`.\n *\n * @see https://ui.funstack.work/components/select\n */\nexport function SelectTrigger({ className, style, children, render, ...rest }: SelectTriggerProps) {\n const ctx = useSelectContext(\"Select.Trigger\");\n const state: SelectRootState = {\n value: ctx.optimistic,\n pending: ctx.pending,\n disabled: ctx.disabled,\n };\n const { ref } = useSelectPartRef<HTMLButtonElement>(\n \"Select.Trigger\",\n \"button\",\n firstChildOfSelect,\n );\n return useRender<ComponentPropsWithRef<\"button\">, SelectRootState>({\n defaultElement: \"button\",\n render,\n state,\n className,\n style,\n children,\n props: rest,\n libraryProps: {\n // Explicit: Chromium 156 reports `.type === \"submit\"` for a select's button.\n type: \"button\",\n \"data-pending\": dataAttr(ctx.pending),\n \"data-disabled\": dataAttr(ctx.disabled),\n },\n ref,\n });\n}\n\nSelectTrigger.displayName = \"SelectTrigger\";\n"],"mappings":";;;;;;AA+BA,SAAS,mBAAmB,IAAsC;CAChE,MAAM,SAAS,GAAG;CAClB,IAAI,QAAQ,YAAY,YAAY,OAAO,sBAAsB,IAAI,OAAO;CAC5E,OACE;AAGJ;;;;;;;;;;;AAYA,SAAgB,cAAc,EAAE,WAAW,OAAO,UAAU,QAAQ,GAAG,QAA4B;CACjG,MAAM,MAAM,iBAAiB,gBAAgB;CAC7C,MAAM,QAAyB;EAC7B,OAAO,IAAI;EACX,SAAS,IAAI;EACb,UAAU,IAAI;CAChB;CACA,MAAM,EAAE,QAAQ,iBACd,kBACA,UACA,kBACF;CACA,OAAO,UAA4D;EACjE,gBAAgB;EAChB;EACA;EACA;EACA;EACA;EACA,OAAO;EACP,cAAc;GAEZ,MAAM;GACN,gBAAgB,SAAS,IAAI,OAAO;GACpC,iBAAiB,SAAS,IAAI,QAAQ;EACxC;EACA;CACF,CAAC;AACH;AAEA,cAAc,cAAc"}
|
|
@@ -2,8 +2,15 @@ import { RenderProp, StateValue } from "../internal/types.mjs";
|
|
|
2
2
|
import { SelectRootState } from "./select-root.mjs";
|
|
3
3
|
import { CSSProperties, ComponentPropsWithRef } from "react";
|
|
4
4
|
//#region src/select/select-value.d.ts
|
|
5
|
+
/**
|
|
6
|
+
* Props of `Select.Value`.
|
|
7
|
+
*
|
|
8
|
+
* @see https://ui.funstack.work/components/select
|
|
9
|
+
*/
|
|
5
10
|
export interface SelectValueProps extends Omit<ComponentPropsWithRef<"selectedcontent">, "children" | "dangerouslySetInnerHTML" | "className" | "style"> {
|
|
11
|
+
/** Class name, or a function of the part's state that returns one. */
|
|
6
12
|
className?: StateValue<string | undefined, SelectRootState>;
|
|
13
|
+
/** Inline style, or a function of the part's state that returns one. */
|
|
7
14
|
style?: StateValue<CSSProperties | undefined, SelectRootState>;
|
|
8
15
|
/** Replace the rendered element. Must keep a `<selectedcontent>`. */
|
|
9
16
|
render?: RenderProp<ComponentPropsWithRef<"selectedcontent">, SelectRootState>;
|
|
@@ -22,6 +29,8 @@ export interface SelectValueProps extends Omit<ComponentPropsWithRef<"selectedco
|
|
|
22
29
|
* `HTMLSelectedContentElement` is undefined (Firefox today, jsdom): nothing is cloned there.
|
|
23
30
|
*
|
|
24
31
|
* Owned keys: `dangerouslySetInnerHTML`, `suppressHydrationWarning`, `children`.
|
|
32
|
+
*
|
|
33
|
+
* @see https://ui.funstack.work/components/select
|
|
25
34
|
*/
|
|
26
35
|
export declare function SelectValue({ className, style, render, ...rest }: SelectValueProps): import("react").ReactNode;
|
|
27
36
|
export declare namespace SelectValue {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"select-value.d.mts","names":[],"sources":["../../src/select/select-value.tsx"],"mappings":"
|
|
1
|
+
{"version":3,"file":"select-value.d.mts","names":[],"sources":["../../src/select/select-value.tsx"],"mappings":";;;;;;;;;iBAiBiB,yBAAyB,KACxC;;EAIA,YAAY,+BAA+B;;EAE3C,QAAQ,WAAW,2BAA2B;;EAE9C,SAAS,WAAW,0CAA0C;;;;;;;;;;;;;;;;;;;wBA6ChD,cAAc,WAAW,OAAO,WAAW,QAAQ,mCAAgB;yBAAnE"}
|
|
@@ -39,6 +39,8 @@ function refresh(select) {
|
|
|
39
39
|
* `HTMLSelectedContentElement` is undefined (Firefox today, jsdom): nothing is cloned there.
|
|
40
40
|
*
|
|
41
41
|
* Owned keys: `dangerouslySetInnerHTML`, `suppressHydrationWarning`, `children`.
|
|
42
|
+
*
|
|
43
|
+
* @see https://ui.funstack.work/components/select
|
|
42
44
|
*/
|
|
43
45
|
function SelectValue({ className, style, render, ...rest }) {
|
|
44
46
|
const ctx = useSelectContext("Select.Value");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"select-value.mjs","names":[],"sources":["../../src/select/select-value.tsx"],"sourcesContent":["\"use client\";\nimport { useLayoutEffect, useMemo } from \"react\";\nimport type { ComponentPropsWithRef, CSSProperties } from \"react\";\nimport type { RenderProp, StateValue } from \"../internal/types.js\";\nimport { useFormReset } from \"../internal/use-form-reset.js\";\nimport { useRender } from \"../internal/use-render.js\";\nimport { useSelectContext } from \"./select-context.js\";\nimport { useSelectPartRef } from \"./select-dom.js\";\nimport type { SelectRootState } from \"./select-root.js\";\n\nconst isDev = process.env.NODE_ENV !== \"production\";\n\nexport interface SelectValueProps extends Omit<\n ComponentPropsWithRef<\"selectedcontent\">,\n \"children\" | \"dangerouslySetInnerHTML\" | \"className\" | \"style\"\n> {\n className?: StateValue<string | undefined, SelectRootState>;\n style?: StateValue<CSSProperties | undefined, SelectRootState>;\n /** Replace the rendered element. Must keep a `<selectedcontent>`. */\n render?: RenderProp<ComponentPropsWithRef<\"selectedcontent\">, SelectRootState>;\n}\n\n/** Where the browser clones options into `<selectedcontent>` (Chromium 135+, Safari 27). */\nfunction supportsSelectedContent(): boolean {\n return typeof globalThis !== \"undefined\" && \"HTMLSelectedContentElement\" in globalThis;\n}\n\n/**\n * Whether a mutation record changes what `<selectedcontent>` shows: a record inside the selected\n * option. Attribute records on the option element itself are ignored (option attributes are not\n * cloned, and the library writes `data-*` there); records inside `<selectedcontent>` are never\n * inside an option, so the refresh's own clone does not loop.\n */\nfunction touchesSelected(record: MutationRecord, selected: HTMLOptionElement): boolean {\n if (record.type === \"attributes\" && record.target === selected) return false;\n return selected.contains(record.target);\n}\n\n/** Re-clones the selected option into `<selectedcontent>`. */\nfunction refresh(select: HTMLSelectElement): void {\n // Nothing selected: assigning the value would select the placeholder (probe case 7).\n if (select.selectedIndex === -1) return;\n // The assignment is the re-clone trigger; it fires no event and keeps the selection.\n const current = select.value;\n select.value = current;\n}\n\n/**\n * `<selectedcontent>`: the browser clones the selected option's content into it (inside\n * `Select.Trigger`). It has no `children`. Rendered with `suppressHydrationWarning` and an empty\n * `dangerouslySetInnerHTML` so that hydration accepts the content the parser cloned before React\n * ran (design/components/select.md 3.3).\n *\n * Also keeps it fresh: the platform re-clones only on selection changes, so when React changes\n * the selected option's content (a label, a state function, a Suspense boundary resolving inside\n * it), a `MutationObserver` re-assigns `select.value = select.value`, which re-clones without\n * events and without touching the selection or an open picker (6.3). The same refresh follows a\n * form reset, which Chromium does not re-clone for. Not installed where\n * `HTMLSelectedContentElement` is undefined (Firefox today, jsdom): nothing is cloned there.\n *\n * Owned keys: `dangerouslySetInnerHTML`, `suppressHydrationWarning`, `children`.\n */\nexport function SelectValue({ className, style, render, ...rest }: SelectValueProps) {\n const ctx = useSelectContext(\"Select.Value\");\n const { ref, node } = useSelectPartRef<HTMLElement>(\"Select.Value\", \"selectedcontent\");\n\n useLayoutEffect(() => {\n const el = node.current;\n if (el === null) return;\n const select = el.closest(\"select\");\n if (select === null) {\n if (isDev) {\n console.error(\n \"Select.Value: rendered outside the Select.Root's <select>; put it inside \" +\n \"Select.Trigger, the select's first child.\",\n );\n }\n return;\n }\n if (!supportsSelectedContent()) return;\n const observer = new MutationObserver((records) => {\n const selected = select.options[select.selectedIndex];\n if (selected === undefined) return;\n if (records.some((record) => touchesSelected(record, selected))) refresh(select);\n });\n observer.observe(select, {\n childList: true,\n characterData: true,\n attributes: true,\n subtree: true,\n });\n return () => {\n observer.disconnect();\n };\n }, [node]);\n\n // A form reset changes the selection without re-cloning (Chromium 156: `form.reset()` leaves\n // the old option's content in <selectedcontent>; memo/developer/select.md). `useFormReset`\n // listens on the select's form owner itself (so neither `stopPropagation()` on the form nor a\n // shadow root hides the event), follows a changed owner or `form` attribute, and calls back in\n // a microtask after an uncancelled reset. React's own reset after a form action is a\n // `form.reset()` too.\n const selectRef = useMemo(\n () => ({\n get current(): HTMLSelectElement | null {\n return node.current?.closest(\"select\") ?? null;\n },\n }),\n [node],\n );\n useFormReset(selectRef, () => {\n const select = selectRef.current;\n if (select !== null && supportsSelectedContent()) refresh(select);\n });\n\n const state: SelectRootState = {\n value: ctx.optimistic,\n pending: ctx.pending,\n disabled: ctx.disabled,\n };\n return useRender<ComponentPropsWithRef<\"selectedcontent\">, SelectRootState>({\n defaultElement: \"selectedcontent\",\n render,\n state,\n className,\n style,\n children: undefined,\n props: rest,\n libraryProps: {\n suppressHydrationWarning: true,\n dangerouslySetInnerHTML: { __html: \"\" },\n },\n ref,\n });\n}\n\nSelectValue.displayName = \"SelectValue\";\n"],"mappings":";;;;;;;AAUA,MAAM,QAAQ,QAAQ,IAAI,aAAa;;
|
|
1
|
+
{"version":3,"file":"select-value.mjs","names":[],"sources":["../../src/select/select-value.tsx"],"sourcesContent":["\"use client\";\nimport { useLayoutEffect, useMemo } from \"react\";\nimport type { ComponentPropsWithRef, CSSProperties } from \"react\";\nimport type { RenderProp, StateValue } from \"../internal/types.js\";\nimport { useFormReset } from \"../internal/use-form-reset.js\";\nimport { useRender } from \"../internal/use-render.js\";\nimport { useSelectContext } from \"./select-context.js\";\nimport { useSelectPartRef } from \"./select-dom.js\";\nimport type { SelectRootState } from \"./select-root.js\";\n\nconst isDev = process.env.NODE_ENV !== \"production\";\n\n/**\n * Props of `Select.Value`.\n *\n * @see https://ui.funstack.work/components/select\n */\nexport interface SelectValueProps extends Omit<\n ComponentPropsWithRef<\"selectedcontent\">,\n \"children\" | \"dangerouslySetInnerHTML\" | \"className\" | \"style\"\n> {\n /** Class name, or a function of the part's state that returns one. */\n className?: StateValue<string | undefined, SelectRootState>;\n /** Inline style, or a function of the part's state that returns one. */\n style?: StateValue<CSSProperties | undefined, SelectRootState>;\n /** Replace the rendered element. Must keep a `<selectedcontent>`. */\n render?: RenderProp<ComponentPropsWithRef<\"selectedcontent\">, SelectRootState>;\n}\n\n/** Where the browser clones options into `<selectedcontent>` (Chromium 135+, Safari 27). */\nfunction supportsSelectedContent(): boolean {\n return typeof globalThis !== \"undefined\" && \"HTMLSelectedContentElement\" in globalThis;\n}\n\n/**\n * Whether a mutation record changes what `<selectedcontent>` shows: a record inside the selected\n * option. Attribute records on the option element itself are ignored (option attributes are not\n * cloned, and the library writes `data-*` there); records inside `<selectedcontent>` are never\n * inside an option, so the refresh's own clone does not loop.\n */\nfunction touchesSelected(record: MutationRecord, selected: HTMLOptionElement): boolean {\n if (record.type === \"attributes\" && record.target === selected) return false;\n return selected.contains(record.target);\n}\n\n/** Re-clones the selected option into `<selectedcontent>`. */\nfunction refresh(select: HTMLSelectElement): void {\n // Nothing selected: assigning the value would select the placeholder (probe case 7).\n if (select.selectedIndex === -1) return;\n // The assignment is the re-clone trigger; it fires no event and keeps the selection.\n const current = select.value;\n select.value = current;\n}\n\n/**\n * `<selectedcontent>`: the browser clones the selected option's content into it (inside\n * `Select.Trigger`). It has no `children`. Rendered with `suppressHydrationWarning` and an empty\n * `dangerouslySetInnerHTML` so that hydration accepts the content the parser cloned before React\n * ran (design/components/select.md 3.3).\n *\n * Also keeps it fresh: the platform re-clones only on selection changes, so when React changes\n * the selected option's content (a label, a state function, a Suspense boundary resolving inside\n * it), a `MutationObserver` re-assigns `select.value = select.value`, which re-clones without\n * events and without touching the selection or an open picker (6.3). The same refresh follows a\n * form reset, which Chromium does not re-clone for. Not installed where\n * `HTMLSelectedContentElement` is undefined (Firefox today, jsdom): nothing is cloned there.\n *\n * Owned keys: `dangerouslySetInnerHTML`, `suppressHydrationWarning`, `children`.\n *\n * @see https://ui.funstack.work/components/select\n */\nexport function SelectValue({ className, style, render, ...rest }: SelectValueProps) {\n const ctx = useSelectContext(\"Select.Value\");\n const { ref, node } = useSelectPartRef<HTMLElement>(\"Select.Value\", \"selectedcontent\");\n\n useLayoutEffect(() => {\n const el = node.current;\n if (el === null) return;\n const select = el.closest(\"select\");\n if (select === null) {\n if (isDev) {\n console.error(\n \"Select.Value: rendered outside the Select.Root's <select>; put it inside \" +\n \"Select.Trigger, the select's first child.\",\n );\n }\n return;\n }\n if (!supportsSelectedContent()) return;\n const observer = new MutationObserver((records) => {\n const selected = select.options[select.selectedIndex];\n if (selected === undefined) return;\n if (records.some((record) => touchesSelected(record, selected))) refresh(select);\n });\n observer.observe(select, {\n childList: true,\n characterData: true,\n attributes: true,\n subtree: true,\n });\n return () => {\n observer.disconnect();\n };\n }, [node]);\n\n // A form reset changes the selection without re-cloning (Chromium 156: `form.reset()` leaves\n // the old option's content in <selectedcontent>; memo/developer/select.md). `useFormReset`\n // listens on the select's form owner itself (so neither `stopPropagation()` on the form nor a\n // shadow root hides the event), follows a changed owner or `form` attribute, and calls back in\n // a microtask after an uncancelled reset. React's own reset after a form action is a\n // `form.reset()` too.\n const selectRef = useMemo(\n () => ({\n get current(): HTMLSelectElement | null {\n return node.current?.closest(\"select\") ?? null;\n },\n }),\n [node],\n );\n useFormReset(selectRef, () => {\n const select = selectRef.current;\n if (select !== null && supportsSelectedContent()) refresh(select);\n });\n\n const state: SelectRootState = {\n value: ctx.optimistic,\n pending: ctx.pending,\n disabled: ctx.disabled,\n };\n return useRender<ComponentPropsWithRef<\"selectedcontent\">, SelectRootState>({\n defaultElement: \"selectedcontent\",\n render,\n state,\n className,\n style,\n children: undefined,\n props: rest,\n libraryProps: {\n suppressHydrationWarning: true,\n dangerouslySetInnerHTML: { __html: \"\" },\n },\n ref,\n });\n}\n\nSelectValue.displayName = \"SelectValue\";\n"],"mappings":";;;;;;;AAUA,MAAM,QAAQ,QAAQ,IAAI,aAAa;;AAoBvC,SAAS,0BAAmC;CAC1C,OAAO,OAAO,eAAe,eAAe,gCAAgC;AAC9E;;;;;;;AAQA,SAAS,gBAAgB,QAAwB,UAAsC;CACrF,IAAI,OAAO,SAAS,gBAAgB,OAAO,WAAW,UAAU,OAAO;CACvE,OAAO,SAAS,SAAS,OAAO,MAAM;AACxC;;AAGA,SAAS,QAAQ,QAAiC;CAEhD,IAAI,OAAO,kBAAkB,IAAI;CAGjC,OAAO,QADS,OAAO;AAEzB;;;;;;;;;;;;;;;;;;AAmBA,SAAgB,YAAY,EAAE,WAAW,OAAO,QAAQ,GAAG,QAA0B;CACnF,MAAM,MAAM,iBAAiB,cAAc;CAC3C,MAAM,EAAE,KAAK,SAAS,iBAA8B,gBAAgB,iBAAiB;CAErF,sBAAsB;EACpB,MAAM,KAAK,KAAK;EAChB,IAAI,OAAO,MAAM;EACjB,MAAM,SAAS,GAAG,QAAQ,QAAQ;EAClC,IAAI,WAAW,MAAM;GACnB,IAAI,OACF,QAAQ,MACN,oHAEF;GAEF;EACF;EACA,IAAI,CAAC,wBAAwB,GAAG;EAChC,MAAM,WAAW,IAAI,kBAAkB,YAAY;GACjD,MAAM,WAAW,OAAO,QAAQ,OAAO;GACvC,IAAI,aAAa,KAAA,GAAW;GAC5B,IAAI,QAAQ,MAAM,WAAW,gBAAgB,QAAQ,QAAQ,CAAC,GAAG,QAAQ,MAAM;EACjF,CAAC;EACD,SAAS,QAAQ,QAAQ;GACvB,WAAW;GACX,eAAe;GACf,YAAY;GACZ,SAAS;EACX,CAAC;EACD,aAAa;GACX,SAAS,WAAW;EACtB;CACF,GAAG,CAAC,IAAI,CAAC;CAQT,MAAM,YAAY,eACT,EACL,IAAI,UAAoC;EACtC,OAAO,KAAK,SAAS,QAAQ,QAAQ,KAAK;CAC5C,EACF,IACA,CAAC,IAAI,CACP;CACA,aAAa,iBAAiB;EAC5B,MAAM,SAAS,UAAU;EACzB,IAAI,WAAW,QAAQ,wBAAwB,GAAG,QAAQ,MAAM;CAClE,CAAC;CAED,MAAM,QAAyB;EAC7B,OAAO,IAAI;EACX,SAAS,IAAI;EACb,UAAU,IAAI;CAChB;CACA,OAAO,UAAqE;EAC1E,gBAAgB;EAChB;EACA;EACA;EACA;EACA,UAAU,KAAA;EACV,OAAO;EACP,cAAc;GACZ,0BAA0B;GAC1B,yBAAyB,EAAE,QAAQ,GAAG;EACxC;EACA;CACF,CAAC;AACH;AAEA,YAAY,cAAc"}
|
package/dist/slider/index.d.mts
CHANGED
|
@@ -13,6 +13,8 @@ import { SliderValuePart, SliderValueProps, SliderValueState } from "./slider-va
|
|
|
13
13
|
* `Value`. Two actions: `valueChangeAction` on every step (a transition; keep it cheap) and
|
|
14
14
|
* `valueCommitAction` once per gesture (the save; uncontrolled state is committed when it
|
|
15
15
|
* resolves and rolls back when it rejects).
|
|
16
|
+
*
|
|
17
|
+
* @see https://ui.funstack.work/components/slider
|
|
16
18
|
*/
|
|
17
19
|
export declare const Slider: {
|
|
18
20
|
readonly Root: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","names":["_$__slider_root_js0.SliderRootProps","_$__slider_root_js0.SliderValue"],"sources":["../../src/slider/index.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":["_$__slider_root_js0.SliderRootProps","_$__slider_root_js0.SliderValue"],"sources":["../../src/slider/index.ts"],"mappings":";;;;;;;;;;;;;;;;;;qBAoBa;WACX;K,OADWA,0C;;;;;WAEX,cAAK;WACL,cAAK;WACL,kBAAS;WACT,cAAK;WACL,cAAK"}
|
package/dist/slider/index.mjs
CHANGED
|
@@ -12,6 +12,8 @@ import { SliderValuePart } from "./slider-value.mjs";
|
|
|
12
12
|
* `Value`. Two actions: `valueChangeAction` on every step (a transition; keep it cheap) and
|
|
13
13
|
* `valueCommitAction` once per gesture (the save; uncontrolled state is committed when it
|
|
14
14
|
* resolves and rolls back when it rejects).
|
|
15
|
+
*
|
|
16
|
+
* @see https://ui.funstack.work/components/slider
|
|
15
17
|
*/
|
|
16
18
|
const Slider = {
|
|
17
19
|
Root: SliderRoot,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":[],"sources":["../../src/slider/index.ts"],"sourcesContent":["// Ships the platform attribute typings with this subpath (conventions 7.4). Type-only: the\n// built JS has no import of it.\nimport \"../internal/platform-attributes.js\";\nimport { SliderIndicator } from \"./slider-indicator.js\";\nimport { SliderLabel } from \"./slider-label.js\";\nimport { SliderRoot } from \"./slider-root.js\";\nimport { SliderThumb } from \"./slider-thumb.js\";\nimport { SliderTrack } from \"./slider-track.js\";\nimport { SliderValuePart } from \"./slider-value.js\";\n\n/**\n * Slider (WAI-ARIA APG Slider and Slider (Multi-Thumb) patterns): `Root` (`role=\"group\"` with\n * several thumbs), `Label`, `Track` (owns the pointer), `Indicator` (the fill), one `Thumb` per\n * value (a styled element containing a visually hidden native `<input type=\"range\">`), and\n * `Value`. Two actions: `valueChangeAction` on every step (a transition; keep it cheap) and\n * `valueCommitAction` once per gesture (the save; uncontrolled state is committed when it\n * resolves and rolls back when it rejects).\n */\nexport const Slider = {\n Root: SliderRoot,\n Label: SliderLabel,\n Track: SliderTrack,\n Indicator: SliderIndicator,\n Thumb: SliderThumb,\n Value: SliderValuePart,\n} as const;\n\nexport type {\n SliderValue,\n SliderOrientation,\n SliderRootProps,\n SliderRootState,\n SliderValueChangeDetails,\n SliderValueCommitDetails,\n} from \"./slider-root.js\";\nexport type { SliderLabelProps } from \"./slider-label.js\";\nexport type { SliderTrackProps, SliderTrackState } from \"./slider-track.js\";\nexport type { SliderIndicatorProps, SliderIndicatorState } from \"./slider-indicator.js\";\nexport type { SliderThumbProps, SliderThumbState } from \"./slider-thumb.js\";\nexport type { SliderValueProps, SliderValueState } from \"./slider-value.js\";\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../../src/slider/index.ts"],"sourcesContent":["// Ships the platform attribute typings with this subpath (conventions 7.4). Type-only: the\n// built JS has no import of it.\nimport \"../internal/platform-attributes.js\";\nimport { SliderIndicator } from \"./slider-indicator.js\";\nimport { SliderLabel } from \"./slider-label.js\";\nimport { SliderRoot } from \"./slider-root.js\";\nimport { SliderThumb } from \"./slider-thumb.js\";\nimport { SliderTrack } from \"./slider-track.js\";\nimport { SliderValuePart } from \"./slider-value.js\";\n\n/**\n * Slider (WAI-ARIA APG Slider and Slider (Multi-Thumb) patterns): `Root` (`role=\"group\"` with\n * several thumbs), `Label`, `Track` (owns the pointer), `Indicator` (the fill), one `Thumb` per\n * value (a styled element containing a visually hidden native `<input type=\"range\">`), and\n * `Value`. Two actions: `valueChangeAction` on every step (a transition; keep it cheap) and\n * `valueCommitAction` once per gesture (the save; uncontrolled state is committed when it\n * resolves and rolls back when it rejects).\n *\n * @see https://ui.funstack.work/components/slider\n */\nexport const Slider = {\n Root: SliderRoot,\n Label: SliderLabel,\n Track: SliderTrack,\n Indicator: SliderIndicator,\n Thumb: SliderThumb,\n Value: SliderValuePart,\n} as const;\n\nexport type {\n SliderValue,\n SliderOrientation,\n SliderRootProps,\n SliderRootState,\n SliderValueChangeDetails,\n SliderValueCommitDetails,\n} from \"./slider-root.js\";\nexport type { SliderLabelProps } from \"./slider-label.js\";\nexport type { SliderTrackProps, SliderTrackState } from \"./slider-track.js\";\nexport type { SliderIndicatorProps, SliderIndicatorState } from \"./slider-indicator.js\";\nexport type { SliderThumbProps, SliderThumbState } from \"./slider-thumb.js\";\nexport type { SliderValueProps, SliderValueState } from \"./slider-value.js\";\n"],"mappings":";;;;;;;;;;;;;;;;;AAoBA,MAAa,SAAS;CACpB,MAAM;CACN,OAAO;CACP,OAAO;CACP,WAAW;CACX,OAAO;CACP,OAAO;AACT"}
|
|
@@ -2,17 +2,29 @@ import { RenderProp, StateValue } from "../internal/types.mjs";
|
|
|
2
2
|
import { SliderTrackState } from "./slider-track.mjs";
|
|
3
3
|
import { CSSProperties, ComponentPropsWithRef, ReactNode } from "react";
|
|
4
4
|
//#region src/slider/slider-indicator.d.ts
|
|
5
|
+
/** State of `Slider.Indicator`: the same shape as `SliderTrackState`. */
|
|
5
6
|
export type SliderIndicatorState = SliderTrackState;
|
|
7
|
+
/**
|
|
8
|
+
* Props of `Slider.Indicator`.
|
|
9
|
+
*
|
|
10
|
+
* @see https://ui.funstack.work/components/slider
|
|
11
|
+
*/
|
|
6
12
|
export interface SliderIndicatorProps extends Omit<ComponentPropsWithRef<"span">, "className" | "style" | "children"> {
|
|
13
|
+
/** Class name, or a function of the part's state that returns one. */
|
|
7
14
|
className?: StateValue<string | undefined, SliderIndicatorState>;
|
|
15
|
+
/** Inline style, or a function of the part's state that returns one. */
|
|
8
16
|
style?: StateValue<CSSProperties | undefined, SliderIndicatorState>;
|
|
17
|
+
/** Content, or a function of the part's state. */
|
|
9
18
|
children?: StateValue<ReactNode, SliderIndicatorState>;
|
|
19
|
+
/** Replace the default `<span>` (element form) or take over rendering (function form). */
|
|
10
20
|
render?: RenderProp<ComponentPropsWithRef<"span">, SliderIndicatorState>;
|
|
11
21
|
}
|
|
12
22
|
/**
|
|
13
23
|
* The fill between the first and last thumb (from `min` to the value for one thumb). Renders no
|
|
14
24
|
* inline position: the consumer's CSS places it from the Root's inherited `--slider-start` /
|
|
15
25
|
* `--slider-end`. Owned keys: `data-orientation`, `data-disabled`.
|
|
26
|
+
*
|
|
27
|
+
* @see https://ui.funstack.work/components/slider
|
|
16
28
|
*/
|
|
17
29
|
export declare function SliderIndicator({ className, style, children, render, ...rest }: SliderIndicatorProps): ReactNode;
|
|
18
30
|
export declare namespace SliderIndicator {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"slider-indicator.d.mts","names":[],"sources":["../../src/slider/slider-indicator.tsx"],"mappings":"
|
|
1
|
+
{"version":3,"file":"slider-indicator.d.mts","names":[],"sources":["../../src/slider/slider-indicator.tsx"],"mappings":";;;;;YASY,uBAAuB;;;;;;iBAOlB,6BAA6B,KAC5C;;EAIA,YAAY,+BAA+B;;EAE3C,QAAQ,WAAW,2BAA2B;;EAE9C,WAAW,WAAW,WAAW;;EAEjC,SAAS,WAAW,+BAA+B;;;;;;;;;wBAUrC,kBACd,WACA,OACA,UACA,WACG,QACF,uBAAoB;yBANP"}
|
|
@@ -7,6 +7,8 @@ import { useSliderContext } from "./slider-context.mjs";
|
|
|
7
7
|
* The fill between the first and last thumb (from `min` to the value for one thumb). Renders no
|
|
8
8
|
* inline position: the consumer's CSS places it from the Root's inherited `--slider-start` /
|
|
9
9
|
* `--slider-end`. Owned keys: `data-orientation`, `data-disabled`.
|
|
10
|
+
*
|
|
11
|
+
* @see https://ui.funstack.work/components/slider
|
|
10
12
|
*/
|
|
11
13
|
function SliderIndicator({ className, style, children, render, ...rest }) {
|
|
12
14
|
const ctx = useSliderContext("Slider.Indicator");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"slider-indicator.mjs","names":[],"sources":["../../src/slider/slider-indicator.tsx"],"sourcesContent":["\"use client\";\nimport type { ComponentPropsWithRef, CSSProperties, ReactNode } from \"react\";\nimport { dataAttr } from \"../internal/data-attr.js\";\nimport type { RenderProp, StateValue } from \"../internal/types.js\";\nimport { useRender } from \"../internal/use-render.js\";\nimport { useSliderContext } from \"./slider-context.js\";\nimport type { SliderTrackState } from \"./slider-track.js\";\n\nexport type SliderIndicatorState = SliderTrackState;\n\nexport interface SliderIndicatorProps extends Omit<\n ComponentPropsWithRef<\"span\">,\n \"className\" | \"style\" | \"children\"\n> {\n className?: StateValue<string | undefined, SliderIndicatorState>;\n style?: StateValue<CSSProperties | undefined, SliderIndicatorState>;\n children?: StateValue<ReactNode, SliderIndicatorState>;\n render?: RenderProp<ComponentPropsWithRef<\"span\">, SliderIndicatorState>;\n}\n\n/**\n * The fill between the first and last thumb (from `min` to the value for one thumb). Renders no\n * inline position: the consumer's CSS places it from the Root's inherited `--slider-start` /\n * `--slider-end`. Owned keys: `data-orientation`, `data-disabled`.\n */\nexport function SliderIndicator({\n className,\n style,\n children,\n render,\n ...rest\n}: SliderIndicatorProps) {\n const ctx = useSliderContext(\"Slider.Indicator\");\n const state: SliderIndicatorState = {\n orientation: ctx.orientation,\n dragging: ctx.draggingThumb !== null,\n disabled: ctx.disabled,\n };\n return useRender<ComponentPropsWithRef<\"span\">, SliderIndicatorState>({\n defaultElement: \"span\",\n render,\n state,\n className,\n style,\n children,\n props: rest,\n libraryProps: {\n \"data-orientation\": ctx.orientation,\n \"data-disabled\": dataAttr(ctx.disabled),\n },\n });\n}\n\nSliderIndicator.displayName = \"SliderIndicator\";\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"slider-indicator.mjs","names":[],"sources":["../../src/slider/slider-indicator.tsx"],"sourcesContent":["\"use client\";\nimport type { ComponentPropsWithRef, CSSProperties, ReactNode } from \"react\";\nimport { dataAttr } from \"../internal/data-attr.js\";\nimport type { RenderProp, StateValue } from \"../internal/types.js\";\nimport { useRender } from \"../internal/use-render.js\";\nimport { useSliderContext } from \"./slider-context.js\";\nimport type { SliderTrackState } from \"./slider-track.js\";\n\n/** State of `Slider.Indicator`: the same shape as `SliderTrackState`. */\nexport type SliderIndicatorState = SliderTrackState;\n\n/**\n * Props of `Slider.Indicator`.\n *\n * @see https://ui.funstack.work/components/slider\n */\nexport interface SliderIndicatorProps extends Omit<\n ComponentPropsWithRef<\"span\">,\n \"className\" | \"style\" | \"children\"\n> {\n /** Class name, or a function of the part's state that returns one. */\n className?: StateValue<string | undefined, SliderIndicatorState>;\n /** Inline style, or a function of the part's state that returns one. */\n style?: StateValue<CSSProperties | undefined, SliderIndicatorState>;\n /** Content, or a function of the part's state. */\n children?: StateValue<ReactNode, SliderIndicatorState>;\n /** Replace the default `<span>` (element form) or take over rendering (function form). */\n render?: RenderProp<ComponentPropsWithRef<\"span\">, SliderIndicatorState>;\n}\n\n/**\n * The fill between the first and last thumb (from `min` to the value for one thumb). Renders no\n * inline position: the consumer's CSS places it from the Root's inherited `--slider-start` /\n * `--slider-end`. Owned keys: `data-orientation`, `data-disabled`.\n *\n * @see https://ui.funstack.work/components/slider\n */\nexport function SliderIndicator({\n className,\n style,\n children,\n render,\n ...rest\n}: SliderIndicatorProps) {\n const ctx = useSliderContext(\"Slider.Indicator\");\n const state: SliderIndicatorState = {\n orientation: ctx.orientation,\n dragging: ctx.draggingThumb !== null,\n disabled: ctx.disabled,\n };\n return useRender<ComponentPropsWithRef<\"span\">, SliderIndicatorState>({\n defaultElement: \"span\",\n render,\n state,\n className,\n style,\n children,\n props: rest,\n libraryProps: {\n \"data-orientation\": ctx.orientation,\n \"data-disabled\": dataAttr(ctx.disabled),\n },\n });\n}\n\nSliderIndicator.displayName = \"SliderIndicator\";\n"],"mappings":";;;;;;;;;;;;AAqCA,SAAgB,gBAAgB,EAC9B,WACA,OACA,UACA,QACA,GAAG,QACoB;CACvB,MAAM,MAAM,iBAAiB,kBAAkB;CAC/C,MAAM,QAA8B;EAClC,aAAa,IAAI;EACjB,UAAU,IAAI,kBAAkB;EAChC,UAAU,IAAI;CAChB;CACA,OAAO,UAA+D;EACpE,gBAAgB;EAChB;EACA;EACA;EACA;EACA;EACA,OAAO;EACP,cAAc;GACZ,oBAAoB,IAAI;GACxB,iBAAiB,SAAS,IAAI,QAAQ;EACxC;CACF,CAAC;AACH;AAEA,gBAAgB,cAAc"}
|
|
@@ -2,10 +2,18 @@ import { RenderProp, StateValue } from "../internal/types.mjs";
|
|
|
2
2
|
import { SliderRootState, SliderValue } from "./slider-root.mjs";
|
|
3
3
|
import { CSSProperties, ComponentPropsWithRef, ReactNode } from "react";
|
|
4
4
|
//#region src/slider/slider-label.d.ts
|
|
5
|
-
/**
|
|
5
|
+
/**
|
|
6
|
+
* Props of `Slider.Label`. `T` defaults to `SliderValue`; pass it to narrow the state
|
|
7
|
+
* (`<Slider.Label<number>>`).
|
|
8
|
+
*
|
|
9
|
+
* @see https://ui.funstack.work/components/slider
|
|
10
|
+
*/
|
|
6
11
|
export interface SliderLabelProps<T extends SliderValue = SliderValue> extends Omit<ComponentPropsWithRef<"label">, "htmlFor" | "id" | "className" | "style" | "children"> {
|
|
12
|
+
/** Class name, or a function of the part's state that returns one. */
|
|
7
13
|
className?: StateValue<string | undefined, SliderRootState<T>>;
|
|
14
|
+
/** Inline style, or a function of the part's state that returns one. */
|
|
8
15
|
style?: StateValue<CSSProperties | undefined, SliderRootState<T>>;
|
|
16
|
+
/** Content, or a function of the part's state. */
|
|
9
17
|
children?: StateValue<ReactNode, SliderRootState<T>>;
|
|
10
18
|
/** Must stay a `<label>` when the slider has one thumb (the `for` association). */
|
|
11
19
|
render?: RenderProp<ComponentPropsWithRef<"label">, SliderRootState<T>>;
|
|
@@ -14,6 +22,8 @@ export interface SliderLabelProps<T extends SliderValue = SliderValue> extends O
|
|
|
14
22
|
* The visible name of the slider: `<label for>` naming the only thumb's input, or, with several
|
|
15
23
|
* thumbs, the element whose `id` the Root's `aria-labelledby` (`role="group"`) points at, emitted
|
|
16
24
|
* only while a Label is mounted. Owned keys: `id`, `htmlFor`.
|
|
25
|
+
*
|
|
26
|
+
* @see https://ui.funstack.work/components/slider
|
|
17
27
|
*/
|
|
18
28
|
export declare function SliderLabel<T extends SliderValue = SliderValue>({ className, style, children, render, ...rest }: SliderLabelProps<T>): ReactNode;
|
|
19
29
|
export declare namespace SliderLabel {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"slider-label.d.mts","names":[],"sources":["../../src/slider/slider-label.tsx"],"mappings":"
|
|
1
|
+
{"version":3,"file":"slider-label.d.mts","names":[],"sources":["../../src/slider/slider-label.tsx"],"mappings":";;;;;;;;;;iBAiBiB,iBAAiB,UAAU,cAAc,qBAAqB,KAC7E;;EAIA,YAAY,+BAA+B,gBAAgB;;EAE3D,QAAQ,WAAW,2BAA2B,gBAAgB;;EAE9D,WAAW,WAAW,WAAW,gBAAgB;;EAEjD,SAAS,WAAW,gCAAgC,gBAAgB;;;;;;;;;wBAUtD,YAAY,UAAU,cAAc,eAClD,WACA,OACA,UACA,WACG,QACF,iBAAiB,KAAE;yBANN"}
|
|
@@ -9,6 +9,8 @@ const isDev = process.env.NODE_ENV !== "production";
|
|
|
9
9
|
* The visible name of the slider: `<label for>` naming the only thumb's input, or, with several
|
|
10
10
|
* thumbs, the element whose `id` the Root's `aria-labelledby` (`role="group"`) points at, emitted
|
|
11
11
|
* only while a Label is mounted. Owned keys: `id`, `htmlFor`.
|
|
12
|
+
*
|
|
13
|
+
* @see https://ui.funstack.work/components/slider
|
|
12
14
|
*/
|
|
13
15
|
function SliderLabel({ className, style, children, render, ...rest }) {
|
|
14
16
|
const ctx = useSliderContext("Slider.Label");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"slider-label.mjs","names":[],"sources":["../../src/slider/slider-label.tsx"],"sourcesContent":["\"use client\";\nimport { useLayoutEffect } from \"react\";\nimport type { ComponentPropsWithRef, CSSProperties, ReactNode } from \"react\";\nimport type { RenderProp, StateValue } from \"../internal/types.js\";\nimport { useElementCheck } from \"../internal/use-element-check.js\";\nimport { useRender } from \"../internal/use-render.js\";\nimport { useSliderContext } from \"./slider-context.js\";\nimport type { SliderRootState, SliderValue } from \"./slider-root.js\";\n\nconst isDev = process.env.NODE_ENV !== \"production\";\n\n
|
|
1
|
+
{"version":3,"file":"slider-label.mjs","names":[],"sources":["../../src/slider/slider-label.tsx"],"sourcesContent":["\"use client\";\nimport { useLayoutEffect } from \"react\";\nimport type { ComponentPropsWithRef, CSSProperties, ReactNode } from \"react\";\nimport type { RenderProp, StateValue } from \"../internal/types.js\";\nimport { useElementCheck } from \"../internal/use-element-check.js\";\nimport { useRender } from \"../internal/use-render.js\";\nimport { useSliderContext } from \"./slider-context.js\";\nimport type { SliderRootState, SliderValue } from \"./slider-root.js\";\n\nconst isDev = process.env.NODE_ENV !== \"production\";\n\n/**\n * Props of `Slider.Label`. `T` defaults to `SliderValue`; pass it to narrow the state\n * (`<Slider.Label<number>>`).\n *\n * @see https://ui.funstack.work/components/slider\n */\nexport interface SliderLabelProps<T extends SliderValue = SliderValue> extends Omit<\n ComponentPropsWithRef<\"label\">,\n \"htmlFor\" | \"id\" | \"className\" | \"style\" | \"children\"\n> {\n /** Class name, or a function of the part's state that returns one. */\n className?: StateValue<string | undefined, SliderRootState<T>>;\n /** Inline style, or a function of the part's state that returns one. */\n style?: StateValue<CSSProperties | undefined, SliderRootState<T>>;\n /** Content, or a function of the part's state. */\n children?: StateValue<ReactNode, SliderRootState<T>>;\n /** Must stay a `<label>` when the slider has one thumb (the `for` association). */\n render?: RenderProp<ComponentPropsWithRef<\"label\">, SliderRootState<T>>;\n}\n\n/**\n * The visible name of the slider: `<label for>` naming the only thumb's input, or, with several\n * thumbs, the element whose `id` the Root's `aria-labelledby` (`role=\"group\"`) points at, emitted\n * only while a Label is mounted. Owned keys: `id`, `htmlFor`.\n *\n * @see https://ui.funstack.work/components/slider\n */\nexport function SliderLabel<T extends SliderValue = SliderValue>({\n className,\n style,\n children,\n render,\n ...rest\n}: SliderLabelProps<T>) {\n const ctx = useSliderContext(\"Slider.Label\");\n const { registerLabel } = ctx;\n useLayoutEffect(registerLabel, [registerLabel]);\n\n const single = ctx.shown.length === 1;\n const libraryRef = useElementCheck(\n isDev &&\n ((element) =>\n single && element.tagName !== \"LABEL\"\n ? `Slider.Label: expected a <label> element but got <${element.tagName.toLowerCase()}>. ` +\n `With one thumb the Label names the input through \\`for\\`, which only a <label> has.`\n : null),\n [single],\n );\n\n return useRender<ComponentPropsWithRef<\"label\">, SliderRootState<T>>({\n defaultElement: \"label\",\n render,\n state: ctx.state as SliderRootState<T>,\n className,\n style,\n children,\n props: rest,\n ref: libraryRef,\n libraryProps: {\n id: ctx.labelId,\n htmlFor: single ? ctx.thumbId(0) : undefined,\n },\n });\n}\n\nSliderLabel.displayName = \"SliderLabel\";\n"],"mappings":";;;;;;AASA,MAAM,QAAQ,QAAQ,IAAI,aAAa;;;;;;;;AA6BvC,SAAgB,YAAiD,EAC/D,WACA,OACA,UACA,QACA,GAAG,QACmB;CACtB,MAAM,MAAM,iBAAiB,cAAc;CAC3C,MAAM,EAAE,kBAAkB;CAC1B,gBAAgB,eAAe,CAAC,aAAa,CAAC;CAE9C,MAAM,SAAS,IAAI,MAAM,WAAW;CACpC,MAAM,aAAa,gBACjB,WACI,YACA,UAAU,QAAQ,YAAY,UAC1B,qDAAqD,QAAQ,QAAQ,YAAY,EAAE,0FAEnF,OACR,CAAC,MAAM,CACT;CAEA,OAAO,UAA8D;EACnE,gBAAgB;EAChB;EACA,OAAO,IAAI;EACX;EACA;EACA;EACA,OAAO;EACP,KAAK;EACL,cAAc;GACZ,IAAI,IAAI;GACR,SAAS,SAAS,IAAI,QAAQ,CAAC,IAAI,KAAA;EACrC;CACF,CAAC;AACH;AAEA,YAAY,cAAc"}
|
|
@@ -3,6 +3,7 @@ import { CSSProperties, ComponentPropsWithRef, ReactNode } from "react";
|
|
|
3
3
|
//#region src/slider/slider-root.d.ts
|
|
4
4
|
/** One number (one thumb) or one number per thumb, in ascending order. */
|
|
5
5
|
export type SliderValue = number | readonly number[];
|
|
6
|
+
/** The arrow-key axis and layout of a Slider. */
|
|
6
7
|
export type SliderOrientation = Orientation;
|
|
7
8
|
/** Details passed as the second argument of `Slider.Root`'s `valueChangeAction` (each step). */
|
|
8
9
|
export interface SliderValueChangeDetails extends ActionDetails {
|
|
@@ -31,6 +32,10 @@ export interface SliderValueCommitDetails extends ActionDetails {
|
|
|
31
32
|
/** Index of the thumb the gesture moved; `null` on a platform path. */
|
|
32
33
|
readonly thumb: number | null;
|
|
33
34
|
}
|
|
35
|
+
/**
|
|
36
|
+
* State of `Slider.Root` and `Slider.Label`, passed to the function forms of `className`,
|
|
37
|
+
* `style`, `children` and `render`.
|
|
38
|
+
*/
|
|
34
39
|
export interface SliderRootState<T extends SliderValue = number> {
|
|
35
40
|
/**
|
|
36
41
|
* The value the thumbs show: the value a gesture has reached while a pointer is captured or a
|
|
@@ -44,18 +49,30 @@ export interface SliderRootState<T extends SliderValue = number> {
|
|
|
44
49
|
readonly pending: boolean;
|
|
45
50
|
/** A pointer is captured on a thumb. */
|
|
46
51
|
readonly dragging: boolean;
|
|
52
|
+
/** The `orientation` prop. */
|
|
47
53
|
readonly orientation: SliderOrientation;
|
|
54
|
+
/** The `disabled` prop, or the enclosing Field's. */
|
|
48
55
|
readonly disabled: boolean;
|
|
56
|
+
/** The `min` prop. */
|
|
49
57
|
readonly min: number;
|
|
58
|
+
/** The `max` prop. */
|
|
50
59
|
readonly max: number;
|
|
60
|
+
/** The `step` prop. */
|
|
51
61
|
readonly step: number;
|
|
52
62
|
}
|
|
63
|
+
/**
|
|
64
|
+
* Props of `Slider.Root`. `T` is `number` (one thumb) or `readonly number[]` (one entry per
|
|
65
|
+
* thumb), inferred from `value` / `defaultValue`.
|
|
66
|
+
*
|
|
67
|
+
* @see https://ui.funstack.work/components/slider
|
|
68
|
+
*/
|
|
53
69
|
export interface SliderRootProps<T extends SliderValue = number> extends Omit<ComponentPropsWithRef<"div">, "defaultValue" | "role" | "className" | "style" | "children" | "aria-valuemin" | "aria-valuemax" | "aria-valuenow" | "aria-valuetext" | "aria-orientation"> {
|
|
54
70
|
/** Controlled value: one number, or one per thumb in ascending order. `undefined`: uncontrolled. */
|
|
55
71
|
value?: T;
|
|
56
72
|
/**
|
|
57
|
-
* Initial value in uncontrolled mode; also the form-reset target (latest value).
|
|
58
|
-
*
|
|
73
|
+
* Initial value in uncontrolled mode; also the form-reset target (latest value).
|
|
74
|
+
*
|
|
75
|
+
* @defaultValue the platform's midpoint, `min + (max - min) / 2`, snapped to `step`
|
|
59
76
|
*/
|
|
60
77
|
defaultValue?: T;
|
|
61
78
|
/**
|
|
@@ -75,18 +92,36 @@ export interface SliderRootProps<T extends SliderValue = number> extends Omit<Co
|
|
|
75
92
|
* resolves and reverts to the previous value if it rejects. May be a Server Function.
|
|
76
93
|
*/
|
|
77
94
|
valueCommitAction?: ChangeAction<T, SliderValueCommitDetails>;
|
|
78
|
-
/**
|
|
95
|
+
/**
|
|
96
|
+
* Lower bound of the range.
|
|
97
|
+
*
|
|
98
|
+
* @defaultValue `0`
|
|
99
|
+
*/
|
|
79
100
|
min?: number;
|
|
80
101
|
/**
|
|
81
|
-
*
|
|
82
|
-
* native range (dev warning).
|
|
102
|
+
* Upper bound of the range. A `max` that is not on the step grid from `min` is unreachable, as
|
|
103
|
+
* on a native range (dev warning).
|
|
104
|
+
*
|
|
105
|
+
* @defaultValue `100`
|
|
83
106
|
*/
|
|
84
107
|
max?: number;
|
|
85
|
-
/**
|
|
108
|
+
/**
|
|
109
|
+
* Must be positive. Values snap to `min + n × step`.
|
|
110
|
+
*
|
|
111
|
+
* @defaultValue `1`
|
|
112
|
+
*/
|
|
86
113
|
step?: number;
|
|
87
|
-
/**
|
|
114
|
+
/**
|
|
115
|
+
* Minimum number of steps between two adjacent thumbs.
|
|
116
|
+
*
|
|
117
|
+
* @defaultValue `0` (thumbs may share a value)
|
|
118
|
+
*/
|
|
88
119
|
minStepsBetweenThumbs?: number;
|
|
89
|
-
/**
|
|
120
|
+
/**
|
|
121
|
+
* Layout and arrow-key axis. Vertical sliders have `min` at the bottom.
|
|
122
|
+
*
|
|
123
|
+
* @defaultValue `"horizontal"`
|
|
124
|
+
*/
|
|
90
125
|
orientation?: SliderOrientation;
|
|
91
126
|
/**
|
|
92
127
|
* `aria-valuetext` for a thumb, from the value it shows. Set it when the number alone is not
|
|
@@ -100,11 +135,20 @@ export interface SliderRootProps<T extends SliderValue = number> extends Omit<Co
|
|
|
100
135
|
name?: string;
|
|
101
136
|
/** The `form` attribute for every thumb's input (a Thumb's own `form` wins). */
|
|
102
137
|
form?: string;
|
|
103
|
-
/**
|
|
138
|
+
/**
|
|
139
|
+
* Disables every input (native `disabled`; not submitted) and the pointer. Never set while
|
|
140
|
+
* pending. Inside a `Field.Root`, the Field's `disabled` also applies.
|
|
141
|
+
*
|
|
142
|
+
* @defaultValue `false`
|
|
143
|
+
*/
|
|
104
144
|
disabled?: boolean;
|
|
145
|
+
/** Class name, or a function of the part's state that returns one. */
|
|
105
146
|
className?: StateValue<string | undefined, SliderRootState<T>>;
|
|
147
|
+
/** Inline style, or a function of the part's state that returns one. */
|
|
106
148
|
style?: StateValue<CSSProperties | undefined, SliderRootState<T>>;
|
|
149
|
+
/** Content, or a function of the part's state. */
|
|
107
150
|
children?: StateValue<ReactNode, SliderRootState<T>>;
|
|
151
|
+
/** Replace the default `<div>` (element form) or take over rendering (function form). */
|
|
108
152
|
render?: RenderProp<ComponentPropsWithRef<"div">, SliderRootState<T>>;
|
|
109
153
|
}
|
|
110
154
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"slider-root.d.mts","names":[],"sources":["../../src/slider/slider-root.tsx"],"mappings":";;;;
|
|
1
|
+
{"version":3,"file":"slider-root.d.mts","names":[],"sources":["../../src/slider/slider-root.tsx"],"mappings":";;;;YA2CY;;YAGA,oBAAoB;;iBAGf,iCAAiC;;;;;;;;;;WAUvC,QAAQ;;WAER;;;iBAIM,iCAAiC;;;;;;;WAOvC,QAAQ;;WAER;;;;;;iBAOM,gBAAgB,UAAU;;;;;;WAMhC,OAAO;;WAEP;;WAEA;;WAEA;;WAEA,aAAa;;WAEb;;WAEA;;WAEA;;WAEA;;;;;;;;iBASM,gBAAgB,UAAU,8BAA8B,KACvE;;EAcA,QAAQ;;;;;;EAMR,eAAe;;;;;;;;;;EAUf,oBAAoB,aAAa,GAAG;;;;;;;EAOpC,oBAAoB,aAAa,GAAG;;;;;;EAMpC;;;;;;;EAOA;;;;;;EAMA;;;;;;EAMA;;;;;;EAMA,cAAc;;;;;EAKd,oBAAoB,eAAe;;;;;EAKnC;;EAEA;;;;;;;EAOA;;EAEA,YAAY,+BAA+B,gBAAgB;;EAE3D,QAAQ,WAAW,2BAA2B,gBAAgB;;EAE9D,WAAW,WAAW,WAAW,gBAAgB;;EAEjD,SAAS,WAAW,8BAA8B,gBAAgB"}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { createActionDetails } from "../internal/action-details.mjs";
|
|
3
3
|
import { dataAttr } from "../internal/data-attr.mjs";
|
|
4
|
-
import { useSupersededRejection } from "../internal/use-superseded-rejection.mjs";
|
|
5
4
|
import { useActionTrigger } from "../internal/use-action-trigger.mjs";
|
|
6
5
|
import { useDevWarning } from "../internal/use-dev-warning.mjs";
|
|
7
6
|
import { mergeTokenLists } from "../internal/merge-props.mjs";
|
|
@@ -77,7 +76,6 @@ function SliderRootImpl(props) {
|
|
|
77
76
|
const activeGesture = useRef(null);
|
|
78
77
|
const commitSeq = useRef(0);
|
|
79
78
|
const trackRef = useRef(null);
|
|
80
|
-
const captureSuperseded = useSupersededRejection();
|
|
81
79
|
const runCommit = async (next, details) => {
|
|
82
80
|
const seq = ++commitSeq.current;
|
|
83
81
|
try {
|
|
@@ -99,15 +97,11 @@ function SliderRootImpl(props) {
|
|
|
99
97
|
warn: {
|
|
100
98
|
component: "Slider.Root",
|
|
101
99
|
prop: "value"
|
|
102
|
-
}
|
|
103
|
-
captureSuperseded
|
|
100
|
+
}
|
|
104
101
|
});
|
|
105
102
|
const { optimistic, committed, dispatch } = commitState;
|
|
106
103
|
const committedRef = useLatest(committed);
|
|
107
|
-
const { pending: stepPending, run: runStep } = useActionTrigger({
|
|
108
|
-
ignoreWhilePending: false,
|
|
109
|
-
captureSuperseded
|
|
110
|
-
});
|
|
104
|
+
const { pending: stepPending, run: runStep } = useActionTrigger({ ignoreWhilePending: false });
|
|
111
105
|
const optimisticValues = useMemo(() => toArray(optimistic), [optimistic]);
|
|
112
106
|
const shown = (gestureThumb !== null || stepHeld || stepPending || commitState.pending) && live !== null ? live : optimisticValues;
|
|
113
107
|
const pending = stepPending || commitState.pending;
|
|
@@ -495,6 +489,8 @@ SliderRootImpl.displayName = "SliderRoot";
|
|
|
495
489
|
* `Slider.Root`. Overloaded so that the value's shape is inferred from `value` / `defaultValue`
|
|
496
490
|
* as `number` or `readonly number[]` (an array literal would otherwise infer a mutable
|
|
497
491
|
* `number[]`), and every action and state function receives that shape (design 3.1).
|
|
492
|
+
*
|
|
493
|
+
* @see https://ui.funstack.work/components/slider
|
|
498
494
|
*/
|
|
499
495
|
const SliderRoot = SliderRootImpl;
|
|
500
496
|
//#endregion
|