@justanarthur/modo-ui 0.6.0-canary.9 → 1.0.0
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 +197 -643
- package/blocks/sidebar-app/examples.mdx +2 -2
- package/blocks/sidebar-app/index.tsx +20 -7
- package/blocks/sidebar-app/inset-topbar.tsx +3 -8
- package/blocks/sidebar-app/menu-grid.ts +8 -18
- package/blocks/sidebar-app/nav-data.ts +1 -1
- package/blocks/sidebar-app/search-field.tsx +8 -15
- package/blocks/sidebar-app/thread-page.tsx +58 -0
- package/blocks/sidebar-app/user-footer.tsx +8 -15
- package/blocks/sidebar-app/workspace-header.tsx +9 -28
- package/components/AI/input-message/examples.mdx +37 -33
- package/components/AI/input-message/file-preview-tile.tsx +59 -0
- package/components/AI/input-message/file-thumbnail.tsx +26 -53
- package/components/AI/input-message/index.tsx +362 -1122
- package/components/AI/input-message/input-message.css +25 -0
- package/components/AI/input-message/queued-row.tsx +102 -0
- package/components/AI/input-message/shared.ts +38 -0
- package/components/AI/input-message/suggestion-row.tsx +64 -0
- package/components/AI/input-message/use-composer-files.ts +142 -0
- package/components/AI/input-message/use-history-nav.ts +60 -0
- package/components/AI/input-message/use-message-queue.ts +108 -0
- package/components/AI/input-message/use-region-height.ts +34 -0
- package/components/AI/thinking-indicator/index.tsx +9 -31
- package/components/accordion/accordion-content.tsx +217 -0
- package/components/accordion/accordion-context.tsx +118 -0
- package/components/accordion/accordion-group.tsx +215 -0
- package/components/accordion/examples.mdx +64 -132
- package/components/accordion/index.tsx +127 -891
- package/components/avatar/examples.mdx +2 -2
- package/components/avatar/index.tsx +40 -34
- package/components/badge/change-demo.tsx +2 -0
- package/components/badge/examples.mdx +16 -34
- package/components/badge/index.tsx +31 -69
- package/components/badge/variants.ts +5 -30
- package/components/button/examples.mdx +79 -94
- package/components/button/index.tsx +97 -188
- package/components/button/loading-demo.tsx +2 -0
- package/components/button/variants.ts +12 -117
- package/components/card/card-group.tsx +184 -0
- package/components/card/card-media.tsx +207 -0
- package/components/card/card-parts.tsx +179 -0
- package/components/card/examples.mdx +91 -143
- package/components/card/index.tsx +190 -881
- package/components/copy/examples.mdx +29 -67
- package/components/copy/index.tsx +58 -285
- package/components/inputs/checkbox/examples.mdx +22 -39
- package/components/inputs/checkbox/index.tsx +103 -255
- package/components/inputs/checkbox/select-all-demo.tsx +8 -6
- package/components/inputs/color-picker/channel-sliders.tsx +70 -0
- package/components/inputs/color-picker/color-input.tsx +387 -0
- package/components/inputs/color-picker/{variants.ts → color-math.ts} +22 -57
- package/components/inputs/color-picker/context.ts +11 -0
- package/components/inputs/color-picker/examples.mdx +20 -59
- package/components/inputs/color-picker/format-menu.tsx +212 -0
- package/components/inputs/color-picker/index.tsx +190 -1776
- package/components/inputs/color-picker/inputs-row.tsx +196 -0
- package/components/inputs/color-picker/popover.tsx +161 -0
- package/components/inputs/color-picker/saturation-square.tsx +167 -0
- package/components/inputs/color-picker/swatches.tsx +178 -0
- package/components/inputs/combobox/context.ts +90 -0
- package/components/inputs/combobox/examples.mdx +103 -206
- package/components/inputs/combobox/fields.tsx +328 -0
- package/components/inputs/combobox/index.tsx +155 -1310
- package/components/inputs/combobox/list.tsx +415 -0
- package/components/inputs/combobox/remote-demo.tsx +70 -74
- package/components/inputs/date-time/calendar/examples.mdx +0 -11
- package/components/inputs/date-time/calendar/index.tsx +32 -59
- package/components/inputs/date-time/calendar/use-month-window.ts +35 -32
- package/components/inputs/date-time/date-picker/examples.mdx +59 -155
- package/components/inputs/date-time/date-picker/index.tsx +186 -370
- package/components/inputs/date-time/date-picker/masked-date-input.tsx +105 -247
- package/components/inputs/date-time/date-range-picker/examples.mdx +6 -62
- package/components/inputs/date-time/date-range-picker/index.tsx +105 -404
- package/components/inputs/date-time/date-value.ts +37 -0
- package/components/inputs/date-time/day-rules.ts +22 -0
- package/components/inputs/date-time/duration-picker/examples.mdx +0 -24
- package/components/inputs/date-time/duration-picker/index.tsx +50 -140
- package/components/inputs/date-time/month-picker/examples.mdx +0 -29
- package/components/inputs/date-time/month-picker/index.tsx +48 -132
- package/components/inputs/date-time/picker-shell.tsx +226 -347
- package/components/inputs/date-time/time-columns.tsx +11 -15
- package/components/inputs/date-time/time-picker/examples.mdx +0 -31
- package/components/inputs/date-time/time-picker/index.tsx +37 -118
- package/components/inputs/field/examples.mdx +81 -39
- package/components/inputs/field/index.tsx +113 -103
- package/components/inputs/file-dropzone/examples.mdx +23 -24
- package/components/inputs/file-dropzone/file-row.tsx +20 -21
- package/components/inputs/file-dropzone/index.tsx +130 -129
- package/components/inputs/file-dropzone/upload-demo.tsx +22 -18
- package/components/inputs/file-dropzone/variants.ts +3 -1
- package/components/inputs/input/examples.mdx +19 -74
- package/components/inputs/input/index.tsx +86 -149
- package/components/inputs/input/password-demo.tsx +5 -5
- package/components/inputs/label/examples.mdx +19 -26
- package/components/inputs/label/index.tsx +21 -34
- package/components/inputs/number-input/examples.mdx +63 -36
- package/components/inputs/number-input/index.tsx +62 -57
- package/components/inputs/radio/examples.mdx +24 -39
- package/components/inputs/radio/index.tsx +125 -328
- package/components/inputs/search/examples.mdx +3 -3
- package/components/inputs/search/index.tsx +46 -39
- package/components/inputs/select/examples.mdx +76 -167
- package/components/inputs/select/index.tsx +252 -776
- package/components/inputs/slider/comfortable.tsx +524 -0
- package/components/inputs/slider/compact.tsx +690 -0
- package/components/inputs/slider/examples.mdx +9 -35
- package/components/inputs/slider/geometry.ts +88 -0
- package/components/inputs/slider/index.tsx +65 -1796
- package/components/inputs/slider/value-display.tsx +184 -0
- package/components/inputs/switch/examples.mdx +31 -33
- package/components/inputs/switch/index.tsx +55 -107
- package/components/inputs/textarea/examples.mdx +23 -61
- package/components/inputs/textarea/index.tsx +21 -99
- package/components/navigation/navigation-menu/content.tsx +76 -0
- package/components/navigation/navigation-menu/context.ts +34 -0
- package/components/navigation/navigation-menu/examples.mdx +21 -84
- package/components/navigation/navigation-menu/index.tsx +139 -639
- package/components/navigation/navigation-menu/item.tsx +47 -0
- package/components/navigation/navigation-menu/link.tsx +104 -0
- package/components/navigation/navigation-menu/list.tsx +86 -0
- package/components/navigation/navigation-menu/trigger.tsx +78 -0
- package/components/navigation/navigation-menu/use-dom-rows.ts +56 -0
- package/components/navigation/pagination/examples.mdx +25 -34
- package/components/navigation/pagination/index.tsx +75 -153
- package/components/navigation/sidebar/examples.mdx +17 -23
- package/components/navigation/sidebar/index.tsx +59 -119
- package/components/navigation/sidebar/menu-scope.tsx +439 -0
- package/components/navigation/sidebar/row-label.tsx +61 -0
- package/components/navigation/sidebar/sidebar-context.tsx +71 -0
- package/components/navigation/sidebar/sidebar-group.tsx +299 -0
- package/components/navigation/sidebar/sidebar-menu-actions.tsx +209 -0
- package/components/navigation/sidebar/sidebar-menu-button.tsx +214 -0
- package/components/navigation/sidebar/sidebar-menu-item.tsx +207 -0
- package/components/navigation/sidebar/sidebar-menu-sub.tsx +180 -0
- package/components/navigation/sidebar/sidebar-parts.tsx +94 -0
- package/components/navigation/sidebar/sidebar-provider.tsx +248 -0
- package/components/navigation/sidebar/sidebar-rail.tsx +206 -0
- package/components/navigation/sidebar/sidebar-shell.tsx +180 -0
- package/components/navigation/sidebar/sidebar-shortcut.tsx +101 -0
- package/components/navigation/sidebar/sidebar.css +7 -11
- package/components/navigation/sidebar/use-measured-collapse.ts +62 -0
- package/components/navigation/tabs/context.ts +45 -0
- package/components/navigation/tabs/examples.mdx +63 -17
- package/components/navigation/tabs/index.tsx +82 -434
- package/components/navigation/tabs/item.tsx +161 -0
- package/components/navigation/tabs/list.tsx +143 -0
- package/components/overlays/alert-dialog/examples.mdx +2 -36
- package/components/overlays/alert-dialog/index.tsx +76 -90
- package/components/overlays/alert-dialog/pending-demo.tsx +3 -1
- package/components/overlays/command/index.tsx +28 -59
- package/components/overlays/context-menu/examples.mdx +58 -4
- package/components/overlays/context-menu/index.tsx +77 -221
- package/components/overlays/dialog/examples.mdx +8 -31
- package/components/overlays/dialog/index.tsx +81 -261
- package/components/overlays/dropdown/dropdown-search.tsx +33 -98
- package/components/overlays/dropdown/examples.mdx +77 -363
- package/components/overlays/dropdown/index.tsx +114 -1010
- package/components/overlays/dropdown/menu-item.tsx +98 -382
- package/components/overlays/dropdown/menu-popup.tsx +294 -0
- package/components/overlays/dropdown/panel-state.ts +176 -0
- package/components/overlays/dropdown/submenu.tsx +170 -0
- package/components/overlays/popover/anchored-demo.tsx +22 -13
- package/components/overlays/popover/examples.mdx +16 -65
- package/components/overlays/popover/index.tsx +93 -137
- package/components/overlays/preview-card/examples.mdx +4 -4
- package/components/overlays/preview-card/index.tsx +48 -103
- package/components/overlays/sheet/examples.mdx +0 -12
- package/components/overlays/sheet/index.tsx +44 -129
- package/components/overlays/toast/examples.mdx +33 -25
- package/components/overlays/toast/index.tsx +56 -203
- package/components/overlays/toast/manager.ts +63 -119
- package/components/overlays/tooltip/examples.mdx +6 -12
- package/components/overlays/tooltip/index.tsx +124 -264
- package/components/progress/index.tsx +24 -30
- package/components/progress/progress.css +6 -28
- package/components/progress/step-demo.tsx +2 -0
- package/components/table/context.ts +49 -0
- package/components/table/examples.mdx +40 -72
- package/components/table/head.tsx +105 -0
- package/components/table/index.tsx +73 -458
- package/components/table/parts.tsx +188 -0
- package/components/table/sort-demo.tsx +21 -30
- package/dist/base.css +141 -122
- package/dist/blocks/sidebar-app/index.d.ts +10 -2
- package/dist/blocks/sidebar-app/index.js +49 -40
- package/dist/components/AI/input-message/index.d.ts +22 -19
- package/dist/components/AI/input-message/index.js +30 -23
- package/dist/components/AI/thinking-indicator/index.d.ts +2 -0
- package/dist/components/AI/thinking-indicator/index.js +10 -9
- package/dist/components/accordion/index.d.ts +52 -85
- package/dist/components/accordion/index.js +25 -19
- package/dist/components/avatar/index.d.ts +10 -10
- package/dist/components/avatar/index.js +9 -8
- package/dist/components/badge/index.d.ts +11 -18
- package/dist/components/badge/index.js +9 -9
- package/dist/components/badge/variants.d.ts +2 -9
- package/dist/components/badge/variants.js +3 -5
- package/dist/components/button/index.d.ts +36 -60
- package/dist/components/button/index.js +12 -9
- package/dist/components/button/variants.d.ts +3 -34
- package/dist/components/button/variants.js +2 -4
- package/dist/components/card/index.d.ts +163 -108
- package/dist/components/card/index.js +30 -21
- package/dist/components/copy/index.d.ts +10 -41
- package/dist/components/copy/index.js +18 -15
- package/dist/components/inputs/checkbox/index.d.ts +25 -25
- package/dist/components/inputs/checkbox/index.js +22 -18
- package/dist/components/inputs/color-picker/index.d.ts +65 -53
- package/dist/components/inputs/color-picker/index.js +35 -29
- package/dist/components/inputs/combobox/index.d.ts +147 -152
- package/dist/components/inputs/combobox/index.js +31 -29
- package/dist/components/inputs/date-time/calendar/index.d.ts +18 -24
- package/dist/components/inputs/date-time/calendar/index.js +17 -15
- package/dist/components/inputs/date-time/date-picker/index.d.ts +52 -96
- package/dist/components/inputs/date-time/date-picker/index.js +42 -35
- package/dist/components/inputs/date-time/date-range-picker/index.d.ts +48 -108
- package/dist/components/inputs/date-time/date-range-picker/index.js +40 -35
- package/dist/components/inputs/date-time/duration-picker/index.d.ts +21 -67
- package/dist/components/inputs/date-time/duration-picker/index.js +39 -33
- package/dist/components/inputs/date-time/month-picker/index.d.ts +18 -61
- package/dist/components/inputs/date-time/month-picker/index.js +38 -32
- package/dist/components/inputs/date-time/time-picker/index.d.ts +18 -59
- package/dist/components/inputs/date-time/time-picker/index.js +39 -33
- package/dist/components/inputs/field/index.d.ts +37 -41
- package/dist/components/inputs/field/index.js +13 -14
- package/dist/components/inputs/file-dropzone/index.d.ts +32 -25
- package/dist/components/inputs/file-dropzone/index.js +18 -15
- package/dist/components/inputs/file-dropzone/variants.js +1 -1
- package/dist/components/inputs/input/index.d.ts +48 -50
- package/dist/components/inputs/input/index.js +14 -12
- package/dist/components/inputs/label/index.d.ts +12 -10
- package/dist/components/inputs/label/index.js +5 -4
- package/dist/components/inputs/number-input/index.d.ts +31 -23
- package/dist/components/inputs/number-input/index.js +16 -14
- package/dist/components/inputs/radio/index.d.ts +20 -16
- package/dist/components/inputs/radio/index.js +20 -16
- package/dist/components/inputs/search/index.d.ts +12 -5
- package/dist/components/inputs/search/index.js +33 -26
- package/dist/components/inputs/select/index.d.ts +88 -99
- package/dist/components/inputs/select/index.js +32 -29
- package/dist/components/inputs/slider/index.d.ts +26 -48
- package/dist/components/inputs/slider/index.js +9 -10
- package/dist/components/inputs/switch/index.d.ts +12 -6
- package/dist/components/inputs/switch/index.js +17 -15
- package/dist/components/inputs/textarea/index.d.ts +12 -22
- package/dist/components/inputs/textarea/index.js +12 -9
- package/dist/components/navigation/navigation-menu/index.d.ts +112 -83
- package/dist/components/navigation/navigation-menu/index.js +31 -27
- package/dist/components/navigation/pagination/index.d.ts +25 -38
- package/dist/components/navigation/pagination/index.js +27 -34
- package/dist/components/navigation/sidebar/index.d.ts +236 -230
- package/dist/components/navigation/sidebar/index.js +59 -55
- package/dist/components/navigation/tabs/index.d.ts +62 -45
- package/dist/components/navigation/tabs/index.js +23 -17
- package/dist/components/overlays/alert-dialog/index.d.ts +71 -106
- package/dist/components/overlays/alert-dialog/index.js +24 -19
- package/dist/components/overlays/command/index.d.ts +40 -31
- package/dist/components/overlays/command/index.js +31 -25
- package/dist/components/overlays/context-menu/index.d.ts +70 -84
- package/dist/components/overlays/context-menu/index.js +35 -31
- package/dist/components/overlays/dialog/index.d.ts +82 -98
- package/dist/components/overlays/dialog/index.js +23 -20
- package/dist/components/overlays/dropdown/index.d.ts +191 -357
- package/dist/components/overlays/dropdown/index.js +35 -41
- package/dist/components/overlays/popover/index.d.ts +81 -52
- package/dist/components/overlays/popover/index.js +17 -13
- package/dist/components/overlays/preview-card/index.d.ts +52 -26
- package/dist/components/overlays/preview-card/index.js +16 -12
- package/dist/components/overlays/sheet/index.d.ts +41 -45
- package/dist/components/overlays/sheet/index.js +24 -19
- package/dist/components/overlays/toast/index.d.ts +73 -183
- package/dist/components/overlays/toast/index.js +20 -21
- package/dist/components/overlays/tooltip/index.d.ts +80 -118
- package/dist/components/overlays/tooltip/index.js +14 -12
- package/dist/components/progress/index.d.ts +10 -11
- package/dist/components/progress/index.js +7 -6
- package/dist/components/table/index.d.ts +72 -71
- package/dist/components/table/index.js +18 -16
- package/dist/index.d.ts +2575 -3149
- package/dist/index.js +186 -202
- package/dist/lib/date-locale.d.ts +6 -13
- package/dist/lib/date-locale.js +5 -11
- package/dist/lib/date-mask.d.ts +41 -0
- package/dist/lib/date-mask.js +20 -0
- package/dist/lib/field-box.d.ts +114 -0
- package/dist/lib/field-box.js +18 -0
- package/dist/lib/field-classes.d.ts +15 -119
- package/dist/lib/field-classes.js +4 -21
- package/dist/lib/fluid-hover-highlight.d.ts +3 -25
- package/dist/lib/fluid-hover-highlight.js +8 -13
- package/dist/lib/focus-ring.d.ts +16 -10
- package/dist/lib/focus-ring.js +6 -6
- package/dist/lib/goo-indicator.js +6 -5
- package/dist/lib/icon-context.d.ts +2 -8
- package/dist/lib/icon-context.js +2 -6
- package/dist/lib/merge-refs.d.ts +10 -0
- package/dist/lib/merge-refs.js +8 -0
- package/dist/lib/morph-layers.d.ts +12 -6
- package/dist/lib/morph-layers.js +7 -6
- package/dist/lib/morph-part.js +3 -3
- package/dist/lib/overlay.d.ts +113 -0
- package/dist/lib/overlay.js +21 -0
- package/dist/lib/popup-rows.d.ts +101 -0
- package/dist/lib/popup-rows.js +25 -0
- package/dist/lib/popup-surface.d.ts +92 -0
- package/dist/lib/popup-surface.js +17 -0
- package/dist/lib/popup.d.ts +17 -1
- package/dist/lib/popup.js +4 -1
- package/dist/lib/rect.d.ts +16 -0
- package/dist/lib/rect.js +12 -0
- package/dist/lib/reduced-motion.js +1 -1
- package/dist/lib/row-group.d.ts +100 -0
- package/dist/lib/row-group.js +12 -0
- package/dist/lib/row-index.d.ts +12 -7
- package/dist/lib/row-index.js +4 -2
- package/dist/lib/scroll-column.d.ts +1 -5
- package/dist/lib/scroll-column.js +13 -12
- package/dist/lib/shape-classes.d.ts +16 -0
- package/dist/lib/shape-classes.js +6 -0
- package/dist/lib/shape-context.d.ts +2 -9
- package/dist/lib/shape-context.js +3 -7
- package/dist/lib/size-context.d.ts +1 -2
- package/dist/lib/size-context.js +2 -7
- package/dist/lib/size-scale.js +1 -1
- package/dist/lib/slot.d.ts +31 -26
- package/dist/lib/slot.js +9 -9
- package/dist/lib/spinner-glyph.d.ts +7 -0
- package/dist/lib/spinner-glyph.js +7 -0
- package/dist/lib/springs.d.ts +5 -1
- package/dist/lib/springs.js +4 -2
- package/dist/lib/surface-classes.js +1 -1
- package/dist/lib/surface-context.d.ts +3 -1
- package/dist/lib/surface-context.js +3 -1
- package/dist/lib/use-autosize-textarea.d.ts +16 -0
- package/dist/lib/use-autosize-textarea.js +7 -0
- package/dist/lib/use-controllable-state.d.ts +15 -1
- package/dist/lib/use-controllable-state.js +1 -1
- package/dist/lib/use-fluid-hover.d.ts +1 -49
- package/dist/lib/use-fluid-hover.js +1 -7
- package/dist/lib/use-is-mobile.js +1 -1
- package/dist/lib/use-iso-layout-effect.d.ts +7 -0
- package/dist/lib/use-iso-layout-effect.js +6 -0
- package/dist/lib/use-keyboard-nav-gate.js +3 -2
- package/dist/lib/use-merge-split.js +7 -6
- package/dist/lib/use-morph.d.ts +13 -7
- package/dist/lib/use-morph.js +4 -3
- package/dist/lib/use-touch-primary.js +1 -1
- package/dist/lib/utils.js +1 -1
- package/dist/lib/weight-label.d.ts +26 -0
- package/dist/lib/weight-label.js +7 -0
- package/dist/preset.d.ts +4 -8
- package/dist/preset.js +8 -8
- package/dist/primitives/code/index.js +8 -8
- package/dist/primitives/craft/index.d.ts +1 -1
- package/dist/primitives/craft/index.js +13 -12
- package/dist/primitives/fluid-hover/index.d.ts +13 -14
- package/dist/primitives/fluid-hover/index.js +13 -10
- package/dist/primitives/morph/index.d.ts +1 -1
- package/dist/primitives/morph/index.js +20 -16
- package/dist/primitives/motion/index.d.ts +2 -0
- package/dist/primitives/motion/index.js +14 -11
- package/dist/primitives/scroll-area/index.d.ts +5 -4
- package/dist/primitives/scroll-area/index.js +5 -5
- package/dist/primitives/separator/index.d.ts +12 -11
- package/dist/primitives/separator/index.js +2 -2
- package/dist/primitives/sizes/index.d.ts +17 -4
- package/dist/primitives/sizes/index.js +7 -4
- package/dist/primitives/skeleton/index.d.ts +8 -8
- package/dist/primitives/skeleton/index.js +7 -6
- package/dist/primitives/surface/index.d.ts +12 -25
- package/dist/primitives/surface/index.js +8 -6
- package/dist/shared/{components-yxmxn2jp.js → components-07g2gbjy.js} +30 -75
- package/dist/shared/components-099sdasz.js +552 -0
- package/dist/shared/{components-bsqynhaj.js → components-0h3f5jae.js} +49 -51
- package/dist/shared/{components-wbbckbw8.js → components-0mrhj88d.js} +13 -12
- package/dist/shared/{components-0h78g3b5.js → components-0p2na0cp.js} +19 -47
- package/dist/shared/components-1a7cr7vh.js +40 -0
- package/dist/shared/components-1axxc3tk.js +334 -0
- package/dist/shared/components-1hc3xv0y.js +381 -0
- package/dist/shared/{components-gyt7my41.js → components-1jxw899c.js} +94 -84
- package/dist/shared/{components-jqpefjsn.js → components-1nv9q3s8.js} +24 -44
- package/dist/shared/components-1p3k62x2.js +137 -0
- package/dist/shared/{components-kz5q11pp.js → components-2xmke84n.js} +12 -4
- package/dist/shared/{components-c7rwx0ap.js → components-346ged8v.js} +24 -3
- package/dist/shared/{components-4j3t39dd.js → components-34brwmgp.js} +12 -11
- package/dist/shared/components-38wa9nx5.js +19 -0
- package/dist/shared/components-3hgk57s0.js +27 -0
- package/dist/shared/{components-px2zm7dc.js → components-3js2vgds.js} +13 -6
- package/dist/shared/{components-ctqmge8t.js → components-3m4rqrqm.js} +10 -3
- package/dist/shared/{components-3ey0hzpb.js → components-45r18egt.js} +11 -1
- package/dist/shared/components-50rh4ggz.js +54 -0
- package/dist/shared/components-5atrr490.js +99 -0
- package/dist/shared/components-5f3tq4qb.js +70 -0
- package/dist/shared/{components-dc5q749x.js → components-5vyaexsj.js} +16 -17
- package/dist/shared/{components-pwayrkw9.js → components-5ynncdpn.js} +5 -4
- package/dist/shared/{components-1e64t8aj.js → components-62mg6pab.js} +232 -93
- package/dist/shared/{components-drxrtnp2.js → components-6f5pyzb2.js} +8 -0
- package/dist/shared/{components-868v7scv.js → components-6xfhc5qm.js} +104 -169
- package/dist/shared/{components-yhgq0qxx.js → components-7c4a0egq.js} +20 -12
- package/dist/shared/components-7fqnqbh0.js +79 -0
- package/dist/shared/components-7fsy0jxg.js +443 -0
- package/dist/shared/{components-p0fm0bab.js → components-7t3pz7v7.js} +496 -526
- package/dist/shared/components-85epgxwf.js +620 -0
- package/dist/shared/{components-wknae3m4.js → components-86vvx0c8.js} +75 -121
- package/dist/shared/{components-wgtjt2af.js → components-88ktjdg0.js} +30 -27
- package/dist/shared/{components-ft3zdc79.js → components-88r046aa.js} +6 -6
- package/dist/shared/{components-xd3emmy4.js → components-8hfrd2fk.js} +1462 -1464
- package/dist/shared/components-8sazy704.js +146 -0
- package/dist/shared/{components-rrbpmfx4.js → components-8wp8d8q1.js} +8 -0
- package/dist/shared/{components-rtadhd9j.js → components-9ybenn5v.js} +16 -16
- package/dist/shared/components-amsc86fb.js +293 -0
- package/dist/shared/{components-9as3rf68.js → components-az04rmng.js} +12 -6
- package/dist/shared/components-bdkm2jzy.js +34 -0
- package/dist/shared/{components-xjkdvnbg.js → components-be3wggg1.js} +54 -48
- package/dist/shared/components-bkwjvvkh.js +18 -0
- package/dist/shared/{components-vf45j12c.js → components-ceyn28cf.js} +7 -0
- package/dist/shared/{components-3h92d94m.js → components-cy5z8zxy.js} +1 -2
- package/dist/shared/components-dm86y7b3.js +105 -0
- package/dist/shared/{components-c9yr4ed1.js → components-ejn6tvbw.js} +8 -6
- package/dist/shared/{components-34txk9rj.js → components-ew4wq7mj.js} +7 -0
- package/dist/shared/{components-svkt577j.js → components-f75y4gn8.js} +53 -70
- package/dist/shared/components-f9adtfq8.js +34 -0
- package/dist/shared/{components-2a7hcand.js → components-gbsdhmrv.js} +48 -83
- package/dist/shared/{components-9sttq78t.js → components-gc5zky2w.js} +54 -59
- package/dist/shared/{components-bae8sbjx.js → components-gkdx1787.js} +12 -6
- package/dist/shared/{components-124epb7f.js → components-grxgqa75.js} +3 -7
- package/dist/shared/components-gw0wd7gd.js +986 -0
- package/dist/shared/components-j4z3rtw2.js +179 -0
- package/dist/shared/{components-t5pk5nmc.js → components-j8tcbm8y.js} +927 -953
- package/dist/shared/components-jm91mjm1.js +297 -0
- package/dist/shared/{components-b94t6qtj.js → components-jtfptckj.js} +44 -39
- package/dist/shared/components-jx9qb4z8.js +63 -0
- package/dist/shared/components-k785rge6.js +336 -0
- package/dist/shared/{components-r8eqs7gz.js → components-k81x1aea.js} +10 -6
- package/dist/shared/{components-qx27excf.js → components-kn5c7652.js} +11 -13
- package/dist/shared/components-mse06t0x.js +31 -0
- package/dist/shared/{components-cet3jpa0.js → components-n7e31ct4.js} +71 -49
- package/dist/shared/components-nskr4hwg.js +1008 -0
- package/dist/shared/components-nv5m3gcv.js +37 -0
- package/dist/shared/components-nwa2a9tq.js +27 -0
- package/dist/shared/{components-f7h57m6t.js → components-p0x8ren6.js} +3 -1
- package/dist/shared/{components-2krsc300.js → components-p0z99d5b.js} +67 -92
- package/dist/shared/{components-b1e239g3.js → components-pa43g2r2.js} +15 -4
- package/dist/shared/{components-m06yq8wk.js → components-pedbt2dc.js} +35 -49
- package/dist/shared/components-pva1wj1r.js +27 -0
- package/dist/shared/components-q4wyd06h.js +382 -0
- package/dist/shared/{components-71nbt03m.js → components-qrpdtvxa.js} +12 -45
- package/dist/shared/components-r33dxr5j.js +91 -0
- package/dist/shared/{components-005jt2nz.js → components-re8p99fj.js} +53 -179
- package/dist/shared/components-s217vq1n.js +35 -0
- package/dist/shared/{components-vc864c51.js → components-sesrjvcc.js} +7 -6
- package/dist/shared/{components-qh1cvj6p.js → components-skn189mp.js} +29 -36
- package/dist/shared/{components-tz4gaf1v.js → components-tcyz2tdn.js} +9 -1
- package/dist/shared/components-tjxy84s9.js +53 -0
- package/dist/shared/components-tnj6mkhg.js +89 -0
- package/dist/shared/{components-de99ykt7.js → components-tz0axc0f.js} +1 -0
- package/dist/shared/components-v2j3jx89.js +7 -0
- package/dist/shared/components-vcte8p75.js +71 -0
- package/dist/shared/{components-c74gf16d.js → components-vgzerqt0.js} +34 -47
- package/dist/shared/components-vp6vzsee.js +30 -0
- package/dist/shared/components-vpkh6j83.js +42 -0
- package/dist/shared/{components-4nck8acq.js → components-wgd1nebp.js} +21 -14
- package/dist/shared/{components-pt5ftm4p.js → components-wrbw67f6.js} +10 -3
- package/dist/shared/{components-tz1fv35x.js → components-wwd093xg.js} +1 -0
- package/dist/shared/components-wyfmhtw9.js +61 -0
- package/dist/shared/{components-d3shbwqq.js → components-xpw8dzb0.js} +16 -23
- package/dist/shared/{components-mattt5jp.js → components-xzcgr3gy.js} +62 -60
- package/dist/shared/{components-jcnjay5g.js → components-ycx2kxeq.js} +9 -1
- package/dist/shared/components-zbzx62pg.js +1771 -0
- package/dist/shared/{components-dtca4s6b.js → components-zf0nnvvg.js} +67 -147
- package/dist/shared/{components-h83az0bz.js → components-znspksk0.js} +9 -1
- package/dist/shared/components-zpatc9x3.js +78 -0
- package/dist/styles.css +218 -235
- package/dist/tailwind.css +20 -8
- package/dist/tokens.css +53 -68
- package/index.ts +16 -2
- package/lib/date-locale.ts +12 -149
- package/lib/date-mask.ts +146 -0
- package/lib/field-box.ts +117 -0
- package/lib/field-classes.ts +85 -100
- package/lib/fluid-hover-highlight.tsx +12 -57
- package/lib/focus-ring.tsx +25 -22
- package/lib/goo-indicator.tsx +2 -0
- package/lib/icon-context.tsx +23 -75
- package/lib/merge-refs.ts +29 -0
- package/lib/morph-layers.tsx +3 -1
- package/lib/morph-part.tsx +5 -3
- package/lib/overlay.tsx +118 -0
- package/lib/popup-rows.tsx +149 -0
- package/lib/popup-surface.tsx +52 -0
- package/lib/popup.ts +10 -9
- package/lib/rect.ts +48 -0
- package/lib/reduced-motion.ts +2 -0
- package/lib/row-group.tsx +113 -0
- package/lib/row-index.tsx +27 -10
- package/lib/scroll-column.tsx +26 -53
- package/lib/shape-classes.ts +56 -0
- package/lib/shape-context.tsx +10 -79
- package/lib/size-context.tsx +8 -21
- package/lib/size-scale.ts +3 -9
- package/lib/slot.tsx +124 -0
- package/lib/spinner-glyph.tsx +27 -0
- package/lib/springs.ts +8 -9
- package/lib/surface-classes.ts +3 -8
- package/lib/surface-context.tsx +10 -5
- package/lib/use-autosize-textarea.ts +64 -0
- package/lib/use-controllable-state.ts +30 -15
- package/lib/use-fluid-hover.ts +9 -11
- package/lib/use-is-mobile.ts +5 -5
- package/lib/use-iso-layout-effect.ts +14 -0
- package/lib/use-keyboard-nav-gate.ts +5 -6
- package/lib/use-merge-split.tsx +5 -15
- package/lib/use-morph.ts +34 -76
- package/lib/use-touch-primary.tsx +5 -5
- package/lib/utils.ts +4 -11
- package/lib/weight-label.tsx +69 -0
- package/package.json +57 -194
- package/primitives/code/index.tsx +4 -2
- package/primitives/craft/demos.tsx +4 -2
- package/primitives/craft/examples.mdx +32 -34
- package/primitives/craft/index.tsx +3 -0
- package/primitives/fluid-hover/examples.mdx +1 -1
- package/primitives/fluid-hover/index.tsx +33 -68
- package/primitives/morph/examples.mdx +16 -19
- package/primitives/morph/index.tsx +5 -3
- package/primitives/motion/examples.mdx +3 -3
- package/primitives/motion/index.tsx +6 -22
- package/primitives/scroll-area/examples.mdx +4 -4
- package/primitives/scroll-area/index.tsx +16 -41
- package/primitives/separator/examples.mdx +2 -2
- package/primitives/separator/index.tsx +15 -14
- package/primitives/sizes/examples.mdx +1 -1
- package/primitives/sizes/index.tsx +28 -42
- package/primitives/skeleton/examples.mdx +6 -6
- package/primitives/skeleton/index.tsx +24 -10
- package/primitives/skeleton/skeleton.css +8 -3
- package/primitives/surface/examples.mdx +11 -11
- package/primitives/surface/index.tsx +15 -40
- package/primitives/surface/surface.css +1 -1
- package/DESIGN.md +0 -623
- package/components/inputs/select/variants.ts +0 -32
- package/components/navigation/sidebar/sidebar-core.tsx +0 -1408
- package/components/navigation/sidebar/sidebar-menu.tsx +0 -1495
- package/components/navigation/sidebar/variants.ts +0 -55
- package/components/navigation/tabs-subtle/examples.mdx +0 -49
- package/components/navigation/tabs-subtle/index.tsx +0 -512
- package/components/overlays/dropdown/menu-parts.tsx +0 -725
- package/components/overlays/toast/global-demo.tsx +0 -72
- package/dist/components/inputs/color-picker/variants.d.ts +0 -61
- package/dist/components/inputs/color-picker/variants.js +0 -28
- package/dist/components/inputs/select/variants.d.ts +0 -5
- package/dist/components/inputs/select/variants.js +0 -6
- package/dist/components/navigation/sidebar/variants.d.ts +0 -25
- package/dist/components/navigation/sidebar/variants.js +0 -28
- package/dist/components/navigation/tabs-subtle/index.d.ts +0 -73
- package/dist/components/navigation/tabs-subtle/index.js +0 -24
- package/dist/docs/index.d.ts +0 -83
- package/dist/docs/index.js +0 -288
- package/dist/docs/vite.d.ts +0 -31
- package/dist/docs/vite.js +0 -45
- package/dist/lib/field-variants.d.ts +0 -47
- package/dist/lib/field-variants.js +0 -26
- package/dist/lib/inert.d.ts +0 -9
- package/dist/lib/inert.js +0 -8
- package/dist/lib/row-order.d.ts +0 -28
- package/dist/lib/row-order.js +0 -10
- package/dist/lib/shape-radius.d.ts +0 -19
- package/dist/lib/shape-radius.js +0 -6
- package/dist/shared/components-01w9qcfa.js +0 -277
- package/dist/shared/components-26snnbs9.js +0 -322
- package/dist/shared/components-2qbqqpgq.js +0 -1545
- package/dist/shared/components-303jf96s.js +0 -1478
- package/dist/shared/components-4vfm04wq.js +0 -82
- package/dist/shared/components-54nq988h.js +0 -123
- package/dist/shared/components-7qx17na9.js +0 -300
- package/dist/shared/components-7s7pykk5.js +0 -281
- package/dist/shared/components-8jrk5eye.js +0 -448
- package/dist/shared/components-91zw3d9f.js +0 -136
- package/dist/shared/components-9jmjnkqd.js +0 -503
- package/dist/shared/components-adkarj8n.js +0 -35
- package/dist/shared/components-c5w5zk0s.js +0 -218
- package/dist/shared/components-cnead5qm.js +0 -185
- package/dist/shared/components-czdvj1a8.js +0 -266
- package/dist/shared/components-dcc02hs2.js +0 -31
- package/dist/shared/components-dhgk6mbt.js +0 -16
- package/dist/shared/components-g3eafs70.js +0 -337
- package/dist/shared/components-gx4h5rbb.js +0 -40
- package/dist/shared/components-h6p86be3.js +0 -19
- package/dist/shared/components-hdzrqqpx.js +0 -55
- package/dist/shared/components-hgv6tygd.js +0 -986
- package/dist/shared/components-krtx3m5b.js +0 -84
- package/dist/shared/components-kswxnm3h.js +0 -24
- package/dist/shared/components-mhza2wdn.js +0 -482
- package/dist/shared/components-mrbaxt8q.js +0 -62
- package/dist/shared/components-pv1dyrtn.js +0 -678
- package/dist/shared/components-s8yqk2dc.js +0 -124
- package/dist/shared/components-syynwm1r.js +0 -114
- package/dist/shared/components-tv7b8tet.js +0 -271
- package/dist/shared/components-w2jqa6hx.js +0 -404
- package/dist/shared/components-xdqmt6ed.js +0 -20
- package/dist/shared/components-y0kfy2g4.js +0 -578
- package/dist/shared/components-z3v0n0de.js +0 -11
- package/dist/shared/components-z8fedth5.js +0 -305
- package/dist/shared/components-zkk3fmw8.js +0 -150
- package/dist/tokens/colors.css +0 -230
- package/dist/tokens/motion.css +0 -40
- package/dist/tokens/radius.css +0 -10
- package/dist/tokens/spacing.css +0 -9
- package/dist/tokens/typography.css +0 -119
- package/docs/chrome.css +0 -120
- package/docs/chrome.tsx +0 -283
- package/docs/index.ts +0 -9
- package/docs/vite.ts +0 -85
- package/lib/field-variants.ts +0 -117
- package/lib/inert.ts +0 -22
- package/lib/row-order.tsx +0 -126
- package/lib/shape-radius.ts +0 -67
- package/lib/slot.ts +0 -115
- package/preset.ts +0 -199
|
@@ -1,33 +1,38 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
|
|
3
|
-
useShape2
|
|
4
|
-
} from "./components-71nbt03m.js";
|
|
2
|
+
|
|
5
3
|
import {
|
|
6
4
|
useSizeVariant2
|
|
7
|
-
} from "./components-
|
|
8
|
-
import {
|
|
9
|
-
spring2
|
|
10
|
-
} from "./components-3ey0hzpb.js";
|
|
5
|
+
} from "./components-znspksk0.js";
|
|
11
6
|
import {
|
|
12
7
|
useControllableState2
|
|
13
|
-
} from "./components-
|
|
8
|
+
} from "./components-wwd093xg.js";
|
|
9
|
+
import {
|
|
10
|
+
mergeRefs2
|
|
11
|
+
} from "./components-bkwjvvkh.js";
|
|
12
|
+
import {
|
|
13
|
+
useShape2
|
|
14
|
+
} from "./components-qrpdtvxa.js";
|
|
15
|
+
import {
|
|
16
|
+
spring2
|
|
17
|
+
} from "./components-45r18egt.js";
|
|
14
18
|
import {
|
|
15
19
|
cn2
|
|
16
|
-
} from "./components-
|
|
20
|
+
} from "./components-ycx2kxeq.js";
|
|
17
21
|
|
|
18
22
|
// components/inputs/slider/index.tsx
|
|
23
|
+
import { forwardRef as forwardRef3 } from "react";
|
|
24
|
+
|
|
25
|
+
// components/inputs/slider/comfortable.tsx
|
|
19
26
|
import { Slider as SliderPrimitive } from "@base-ui/react/slider";
|
|
20
|
-
import { AnimatePresence, animate, motion, useMotionValue, useTransform } from "motion/react";
|
|
21
|
-
import {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
} from "react";
|
|
30
|
-
import { jsx, jsxs, Fragment } from "react/jsx-runtime";
|
|
27
|
+
import { AnimatePresence, animate, motion as motion2, useMotionValue, useTransform as useTransform2 } from "motion/react";
|
|
28
|
+
import { forwardRef, useCallback as useCallback2, useEffect as useEffect3, useMemo, useRef as useRef2, useState as useState3 } from "react";
|
|
29
|
+
|
|
30
|
+
// components/inputs/slider/geometry.ts
|
|
31
|
+
import { useEffect, useState } from "react";
|
|
32
|
+
/*!
|
|
33
|
+
* Part of the Slider port (Fluid Functionalism `registry/base/slider.tsx` @ b3587bdbd83fc66c2a6aae3817ffb856cb09260b,
|
|
34
|
+
* MIT License © 2026 Micka Touillaud). Local changes: see PORTING.md.
|
|
35
|
+
*/
|
|
31
36
|
var THUMB_SIZE = 20;
|
|
32
37
|
var THUMB_SIZE_REST = 16;
|
|
33
38
|
var TRACK_BG_HEIGHT = 18;
|
|
@@ -48,19 +53,54 @@ function nearestStepIndex(v, steps) {
|
|
|
48
53
|
}
|
|
49
54
|
return idx;
|
|
50
55
|
}
|
|
56
|
+
function snapValue(raw, min, max, step, stepValues = null) {
|
|
57
|
+
if (stepValues)
|
|
58
|
+
return stepValues[nearestStepIndex(raw, stepValues)];
|
|
59
|
+
return Math.max(min, Math.min(max, Math.round((raw - min) / step) * step + min));
|
|
60
|
+
}
|
|
51
61
|
function pixelToValue(px, min, max, step, trackWidth, stepValues = null) {
|
|
52
62
|
const usable = trackWidth - THUMB_SIZE;
|
|
53
63
|
if (usable <= 0)
|
|
54
64
|
return min;
|
|
55
|
-
|
|
56
|
-
if (stepValues)
|
|
57
|
-
return stepValues[nearestStepIndex(raw, stepValues)];
|
|
58
|
-
const snapped = Math.round((raw - min) / step) * step + min;
|
|
59
|
-
return Math.max(min, Math.min(max, snapped));
|
|
65
|
+
return snapValue(px / usable * (max - min) + min, min, max, step, stepValues);
|
|
60
66
|
}
|
|
61
67
|
function toRadixValue(value) {
|
|
62
68
|
return Array.isArray(value) ? value : [value];
|
|
63
69
|
}
|
|
70
|
+
function layoutX(clientX, el) {
|
|
71
|
+
const rect = el.getBoundingClientRect();
|
|
72
|
+
if (el.offsetWidth <= 0 || rect.width <= 0)
|
|
73
|
+
return null;
|
|
74
|
+
return (clientX - rect.left) * (el.offsetWidth / rect.width);
|
|
75
|
+
}
|
|
76
|
+
function useDelayedFlag(flag, delay) {
|
|
77
|
+
const [delayed, setDelayed] = useState(false);
|
|
78
|
+
useEffect(() => {
|
|
79
|
+
if (!flag) {
|
|
80
|
+
setDelayed(false);
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
const id = setTimeout(() => setDelayed(true), delay);
|
|
84
|
+
return () => clearTimeout(id);
|
|
85
|
+
}, [flag, delay]);
|
|
86
|
+
return delayed;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
// components/inputs/slider/value-display.tsx
|
|
90
|
+
import { motion, useTransform } from "motion/react";
|
|
91
|
+
import { useCallback, useEffect as useEffect2, useRef, useState as useState2 } from "react";
|
|
92
|
+
import { jsx, jsxs, Fragment } from "react/jsx-runtime";
|
|
93
|
+
/*!
|
|
94
|
+
* Part of the Slider port (Fluid Functionalism `registry/base/slider.tsx` @ b3587bdbd83fc66c2a6aae3817ffb856cb09260b,
|
|
95
|
+
* MIT License © 2026 Micka Touillaud). Local changes: see PORTING.md.
|
|
96
|
+
*/
|
|
97
|
+
function ValueBubble({ children }) {
|
|
98
|
+
const shape = useShape2();
|
|
99
|
+
return /* @__PURE__ */ jsx("span", {
|
|
100
|
+
className: cn2("text-caption text-background tabular-nums whitespace-nowrap bg-foreground px-2 py-1", shape.bg, "weight-medium"),
|
|
101
|
+
children
|
|
102
|
+
});
|
|
103
|
+
}
|
|
64
104
|
function ValueDisplay({
|
|
65
105
|
values,
|
|
66
106
|
editingIndex,
|
|
@@ -77,9 +117,9 @@ function ValueDisplay({
|
|
|
77
117
|
isInteracting
|
|
78
118
|
}) {
|
|
79
119
|
const shape = useShape2();
|
|
80
|
-
const [inputValue, setInputValue] =
|
|
120
|
+
const [inputValue, setInputValue] = useState2("");
|
|
81
121
|
const inputRef = useRef(null);
|
|
82
|
-
|
|
122
|
+
useEffect2(() => {
|
|
83
123
|
if (editingIndex !== null) {
|
|
84
124
|
setInputValue(String(values[editingIndex]));
|
|
85
125
|
requestAnimationFrame(() => inputRef.current?.select());
|
|
@@ -88,9 +128,7 @@ function ValueDisplay({
|
|
|
88
128
|
const commitEdit = useCallback((index) => {
|
|
89
129
|
const parsed = parseFloat(inputValue);
|
|
90
130
|
if (!isNaN(parsed)) {
|
|
91
|
-
|
|
92
|
-
const snapped = stepValues ? stepValues[nearestStepIndex(clamped, stepValues)] : Math.round((clamped - min) / step) * step + min;
|
|
93
|
-
onCommitEdit(index, snapped);
|
|
131
|
+
onCommitEdit(index, snapValue(parsed, min, max, step, stepValues));
|
|
94
132
|
} else {
|
|
95
133
|
onCancelEdit();
|
|
96
134
|
}
|
|
@@ -181,1067 +219,1003 @@ function ValueDisplay({
|
|
|
181
219
|
]
|
|
182
220
|
});
|
|
183
221
|
}
|
|
184
|
-
function TooltipValue({ value, formatValue, motionX
|
|
185
|
-
const shape = useShape2();
|
|
222
|
+
function TooltipValue({ value, formatValue, motionX }) {
|
|
186
223
|
const tooltipX = useTransform(motionX, (x) => x + THUMB_SIZE / 2);
|
|
187
|
-
const tooltipY = useTransform(motionX, (x) => -x);
|
|
188
224
|
return /* @__PURE__ */ jsx(motion.div, {
|
|
189
|
-
className:
|
|
190
|
-
style:
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
225
|
+
className: "absolute -translate-x-1/2 pointer-events-none z-20",
|
|
226
|
+
style: {
|
|
227
|
+
x: tooltipX,
|
|
228
|
+
top: -16
|
|
229
|
+
},
|
|
230
|
+
initial: { opacity: 0, y: 4 },
|
|
231
|
+
animate: { opacity: 1, y: 0 },
|
|
232
|
+
exit: { opacity: 0, y: 4, transition: spring2.fast.exit },
|
|
194
233
|
transition: spring2.fast,
|
|
195
|
-
children: /* @__PURE__ */ jsx(
|
|
196
|
-
className: cn2("text-caption text-background tabular-nums whitespace-nowrap bg-foreground px-2 py-1", shape.bg, "weight-medium"),
|
|
234
|
+
children: /* @__PURE__ */ jsx(ValueBubble, {
|
|
197
235
|
children: formatValue(value)
|
|
198
236
|
})
|
|
199
237
|
});
|
|
200
238
|
}
|
|
201
|
-
|
|
239
|
+
|
|
240
|
+
// components/inputs/slider/comfortable.tsx
|
|
241
|
+
import { jsx as jsx2, jsxs as jsxs2, Fragment as Fragment2 } from "react/jsx-runtime";
|
|
242
|
+
/*!
|
|
243
|
+
* Part of the Slider port (Fluid Functionalism `registry/base/slider.tsx` @ b3587bdbd83fc66c2a6aae3817ffb856cb09260b,
|
|
244
|
+
* MIT License © 2026 Micka Touillaud). Local changes: see PORTING.md.
|
|
245
|
+
*/
|
|
246
|
+
var ComfortableSlider = forwardRef(({
|
|
202
247
|
value,
|
|
203
|
-
|
|
204
|
-
min
|
|
205
|
-
max
|
|
248
|
+
onValueChange,
|
|
249
|
+
min = 0,
|
|
250
|
+
max = 100,
|
|
206
251
|
step = 1,
|
|
207
|
-
|
|
208
|
-
showSteps = false,
|
|
209
|
-
showValue = true,
|
|
210
|
-
valuePosition: valuePositionProp,
|
|
211
|
-
formatValue = String,
|
|
252
|
+
variant = "pips",
|
|
212
253
|
label,
|
|
254
|
+
formatValue = String,
|
|
213
255
|
disabled = false,
|
|
214
|
-
|
|
215
|
-
trackStyle,
|
|
216
|
-
fillClassName,
|
|
217
|
-
fillStyle,
|
|
218
|
-
hideFill = false,
|
|
219
|
-
thumbColor,
|
|
220
|
-
thumbBorderColor,
|
|
221
|
-
orientation = "horizontal",
|
|
222
|
-
onValueCommit,
|
|
256
|
+
name,
|
|
223
257
|
className,
|
|
224
|
-
"aria-label": ariaLabel,
|
|
225
258
|
...props
|
|
226
259
|
}, ref) => {
|
|
227
|
-
const
|
|
228
|
-
const
|
|
229
|
-
const
|
|
230
|
-
|
|
231
|
-
const
|
|
232
|
-
const
|
|
233
|
-
const
|
|
260
|
+
const containerRef = useRef2(null);
|
|
261
|
+
const dragging = useRef2(false);
|
|
262
|
+
const handleDragging = useRef2(false);
|
|
263
|
+
const [isHovered, setIsHovered] = useState3(false);
|
|
264
|
+
const [isPressed, setIsPressed] = useState3(false);
|
|
265
|
+
const [isFocused, setIsFocused] = useState3(false);
|
|
266
|
+
const [hoverPreview, setHoverPreview] = useState3(null);
|
|
267
|
+
const showHoverTooltip = useDelayedFlag(isHovered, 100);
|
|
234
268
|
const shape = useShape2();
|
|
235
|
-
const
|
|
236
|
-
const
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
const
|
|
243
|
-
const
|
|
244
|
-
const
|
|
245
|
-
const
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
const
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
269
|
+
const pipSteps = useMemo(() => Array.from({ length: Math.round((max - min) / step) + 1 }, (_, i) => min + i * step), [min, max, step]);
|
|
270
|
+
const pipCount = pipSteps.length;
|
|
271
|
+
const fillPercent = useMotionValue(max === min ? 0 : Math.max(0, Math.min(1, (value - min) / (max - min))));
|
|
272
|
+
const zeroTarget = variant === "pips" ? 8 : 17;
|
|
273
|
+
const zeroOffset = useMotionValue(value === min ? zeroTarget : 0);
|
|
274
|
+
const fillWidthStyle = useTransform2(fillPercent, (p) => `${p * 100}%`);
|
|
275
|
+
const handleLeftStyle = useTransform2([fillPercent, zeroOffset], ([p, zo]) => `calc(${p * 100}% - 8px + ${zo}px)`);
|
|
276
|
+
const handleLineLeftStyle = useTransform2([fillPercent, zeroOffset], ([p, zo]) => `calc(${p * 100}% - 9px + ${zo}px)`);
|
|
277
|
+
const pipsFillWidthStyle = useTransform2([fillPercent, zeroOffset], ([p, zo]) => `calc(${p * 100}% + ${20 - 20 * p - zo * 2.5}px)`);
|
|
278
|
+
const pipsHandleLineLeftStyle = useTransform2(fillPercent, (p) => `calc(${p * 100}% + ${11 - 24 * p}px)`);
|
|
279
|
+
const pipsMaskStyle = useTransform2([fillPercent, zeroOffset], ([p, zo]) => {
|
|
280
|
+
const offset = 20 - 20 * p - zo * 2.5;
|
|
281
|
+
return `linear-gradient(to right, transparent calc(${p * 100}% + ${offset}px), black calc(${p * 100}% + ${offset + 2}px))`;
|
|
282
|
+
});
|
|
283
|
+
const computeHoverPreview = useCallback2((clientX) => {
|
|
284
|
+
const el = containerRef.current;
|
|
285
|
+
if (!el)
|
|
286
|
+
return;
|
|
287
|
+
const w = el.clientWidth;
|
|
288
|
+
const x = layoutX(clientX, el);
|
|
289
|
+
if (w <= 0 || x === null)
|
|
290
|
+
return;
|
|
291
|
+
const borderLeft = (el.offsetWidth - w) / 2;
|
|
292
|
+
const clamped = Math.max(0, Math.min(w, x - borderLeft));
|
|
293
|
+
let snappedVal;
|
|
294
|
+
if (variant === "pips") {
|
|
295
|
+
if (pipCount <= 1)
|
|
296
|
+
return;
|
|
297
|
+
const index = Math.max(0, Math.min(pipCount - 1, Math.round(clamped / w * (pipCount - 1))));
|
|
298
|
+
snappedVal = pipSteps[index];
|
|
264
299
|
} else {
|
|
265
|
-
|
|
266
|
-
clearTimeout(hoverDelayRef.current);
|
|
267
|
-
setShowHoverTooltip(false);
|
|
300
|
+
snappedVal = snapValue(min + clamped / w * (max - min), min, max, step);
|
|
268
301
|
}
|
|
269
|
-
return () => {
|
|
270
|
-
if (hoverDelayRef.current)
|
|
271
|
-
clearTimeout(hoverDelayRef.current);
|
|
272
|
-
};
|
|
273
|
-
}, [isHovered]);
|
|
274
|
-
const motionX0 = useMotionValue(0);
|
|
275
|
-
const motionX1 = useMotionValue(0);
|
|
276
|
-
const fillLeft = useTransform(motionX0, (x) => isRange ? x + THUMB_SIZE / 2 - TRACK_INSET : 0);
|
|
277
|
-
const fillWidthSingle = useTransform(motionX0, (x) => x + THUMB_SIZE / 2 - TRACK_INSET);
|
|
278
|
-
const fillWidthRange = useTransform([motionX0, motionX1], ([x0, x1]) => x1 - x0);
|
|
279
|
-
const fillWidth = isRange ? fillWidthRange : fillWidthSingle;
|
|
280
|
-
const thumbY0 = useTransform(motionX0, (x) => -x);
|
|
281
|
-
const thumbY1 = useTransform(motionX1, (x) => -x);
|
|
282
|
-
const maskDir = vertical ? "to top" : "to right";
|
|
283
|
-
const stepDotsMaskSingle = useTransform(motionX0, (x) => {
|
|
284
|
-
const edge = x + THUMB_SIZE / 2;
|
|
285
|
-
return `linear-gradient(${maskDir}, transparent ${edge}px, black ${edge + 2}px)`;
|
|
286
|
-
});
|
|
287
|
-
const stepDotsMaskRange = useTransform([motionX0, motionX1], ([x0, x1]) => {
|
|
288
|
-
const left = x0 + THUMB_SIZE / 2;
|
|
289
|
-
const right = x1 + THUMB_SIZE / 2;
|
|
290
|
-
return `linear-gradient(${maskDir}, black ${left - 2}px, transparent ${left}px, transparent ${right}px, black ${right + 2}px)`;
|
|
291
|
-
});
|
|
292
|
-
const stepDotsMask = isRange ? stepDotsMaskRange : stepDotsMaskSingle;
|
|
293
|
-
const measure = useCallback((clientX, clientY) => {
|
|
294
|
-
const trackEl = trackRef.current;
|
|
295
|
-
if (!trackEl)
|
|
296
|
-
return null;
|
|
297
|
-
const rect = trackEl.getBoundingClientRect();
|
|
298
|
-
const length = vertical ? trackEl.offsetHeight : trackEl.offsetWidth;
|
|
299
|
-
const visual = vertical ? rect.height : rect.width;
|
|
300
|
-
if (length <= 0 || visual <= 0)
|
|
301
|
-
return null;
|
|
302
|
-
const scale = visual / length;
|
|
303
|
-
return { length, pos: (vertical ? rect.bottom - clientY : clientX - rect.left) / scale };
|
|
304
|
-
}, [vertical]);
|
|
305
|
-
const computeHoverPreview = useCallback((cursorX, trackWidth) => {
|
|
306
|
-
const usable = trackWidth - THUMB_SIZE;
|
|
307
|
-
const rawPx = cursorX - THUMB_SIZE / 2;
|
|
308
|
-
const clampedPx = Math.max(0, Math.min(usable, rawPx));
|
|
309
|
-
const rawVal = usable > 0 ? clampedPx / usable * (max - min) + min : min;
|
|
310
|
-
const snappedVal = stepValues ? stepValues[nearestStepIndex(rawVal, stepValues)] : Math.max(min, Math.min(max, Math.round((rawVal - min) / step) * step + min));
|
|
311
302
|
const snappedPercent = max === min ? 0 : (snappedVal - min) / (max - min);
|
|
312
|
-
const snappedX =
|
|
313
|
-
const
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
303
|
+
const snappedX = snappedPercent * w;
|
|
304
|
+
const currentPercent = fillPercent.get();
|
|
305
|
+
let handleX;
|
|
306
|
+
if (variant === "pips") {
|
|
307
|
+
const zo = zeroOffset.get();
|
|
308
|
+
handleX = currentPercent * w + (20 - 20 * currentPercent - zo * 2.5);
|
|
309
|
+
} else {
|
|
310
|
+
handleX = currentPercent * w;
|
|
311
|
+
}
|
|
312
|
+
const edgeX = snappedVal === min ? 0 : snappedVal === max ? w : snappedX;
|
|
313
|
+
const left = Math.min(handleX, edgeX);
|
|
314
|
+
const width = Math.abs(edgeX - handleX);
|
|
320
315
|
setHoverPreview({ left, width, snappedValue: snappedVal, cursorX: snappedX });
|
|
321
|
-
}, [
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
useLayoutEffect(() => {
|
|
325
|
-
const el = trackRef.current;
|
|
326
|
-
if (!el || initialSyncDone.current)
|
|
316
|
+
}, [variant, pipSteps, pipCount, min, max, step, fillPercent, zeroOffset]);
|
|
317
|
+
useEffect3(() => {
|
|
318
|
+
if (dragging.current || handleDragging.current)
|
|
327
319
|
return;
|
|
328
|
-
const
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
320
|
+
const percent = max === min ? 0 : Math.max(0, Math.min(1, (value - min) / (max - min)));
|
|
321
|
+
animate(fillPercent, percent, spring2.fast);
|
|
322
|
+
animate(zeroOffset, value === min ? zeroTarget : 0, spring2.fast);
|
|
323
|
+
}, [value, min, max, variant, fillPercent, zeroOffset, zeroTarget]);
|
|
324
|
+
const getValueFromX = useCallback2((clientX) => {
|
|
325
|
+
const rect = containerRef.current?.getBoundingClientRect();
|
|
326
|
+
if (!rect)
|
|
327
|
+
return min;
|
|
328
|
+
const x = clientX - rect.left;
|
|
329
|
+
const clamped = Math.max(0, Math.min(rect.width, x));
|
|
330
|
+
if (variant === "pips") {
|
|
331
|
+
if (pipCount <= 1)
|
|
332
|
+
return min;
|
|
333
|
+
const index = Math.max(0, Math.min(pipCount - 1, Math.round(clamped / rect.width * (pipCount - 1))));
|
|
334
|
+
return pipSteps[index];
|
|
335
335
|
}
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
const el = trackRef.current;
|
|
341
|
-
if (!el)
|
|
342
|
-
return;
|
|
343
|
-
const ro = new ResizeObserver(([entry]) => {
|
|
344
|
-
const w = vertical ? entry.contentRect.height : entry.contentRect.width;
|
|
345
|
-
trackWidthRef.current = w;
|
|
346
|
-
if (!dragging.current && initialSyncDone.current) {
|
|
347
|
-
const v = valuesRef.current;
|
|
348
|
-
const mn = minRef.current;
|
|
349
|
-
const mx = maxRef.current;
|
|
350
|
-
const px0 = valueToPixel(v[0], mn, mx, w);
|
|
351
|
-
animate(motionX0, px0, spring2.moderate);
|
|
352
|
-
if (isRange && v[1] !== undefined) {
|
|
353
|
-
const px1 = valueToPixel(v[1], mn, mx, w);
|
|
354
|
-
animate(motionX1, px1, spring2.moderate);
|
|
355
|
-
}
|
|
356
|
-
}
|
|
357
|
-
});
|
|
358
|
-
ro.observe(el);
|
|
359
|
-
return () => ro.disconnect();
|
|
360
|
-
}, [isRange, vertical, motionX0, motionX1]);
|
|
361
|
-
const valuesKey = values.join(",");
|
|
362
|
-
useEffect(() => {
|
|
363
|
-
if (!initialSyncDone.current)
|
|
336
|
+
return snapValue(min + clamped / rect.width * (max - min), min, max, step);
|
|
337
|
+
}, [variant, pipSteps, pipCount, min, max, step]);
|
|
338
|
+
const handlePointerDown = useCallback2((e) => {
|
|
339
|
+
if (disabled)
|
|
364
340
|
return;
|
|
365
|
-
if (
|
|
341
|
+
if (e.pointerType === "mouse" && e.button !== 0)
|
|
366
342
|
return;
|
|
367
|
-
|
|
368
|
-
|
|
343
|
+
e.preventDefault();
|
|
344
|
+
dragging.current = true;
|
|
345
|
+
setIsPressed(true);
|
|
346
|
+
const newVal = getValueFromX(e.clientX);
|
|
347
|
+
onValueChange(newVal);
|
|
348
|
+
const newPercent = Math.max(0, Math.min(1, (newVal - min) / (max - min)));
|
|
349
|
+
animate(fillPercent, newPercent, spring2.fast);
|
|
350
|
+
animate(zeroOffset, newVal === min ? zeroTarget : 0, spring2.fast);
|
|
351
|
+
e.currentTarget.setPointerCapture(e.pointerId);
|
|
352
|
+
}, [disabled, getValueFromX, onValueChange, fillPercent, zeroOffset, zeroTarget, min, max]);
|
|
353
|
+
const handlePointerMove = useCallback2((e) => {
|
|
354
|
+
if (!dragging.current)
|
|
369
355
|
return;
|
|
370
|
-
const
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
if (
|
|
374
|
-
|
|
375
|
-
animate(motionX1, px1, spring2.moderate);
|
|
376
|
-
}
|
|
377
|
-
}, [valuesKey, min, max, isRange, motionX0, motionX1]);
|
|
378
|
-
const clampForRange = useCallback((px, thumbIndex) => {
|
|
379
|
-
if (!isRange)
|
|
380
|
-
return px;
|
|
381
|
-
if (thumbIndex === 0) {
|
|
382
|
-
return Math.min(px, motionX1.get() - THUMB_SIZE * 0.5);
|
|
383
|
-
}
|
|
384
|
-
return Math.max(px, motionX0.get() + THUMB_SIZE * 0.5);
|
|
385
|
-
}, [isRange, motionX0, motionX1]);
|
|
386
|
-
const emitChange = useCallback((thumbIndex, newValue) => {
|
|
387
|
-
if (isRange) {
|
|
388
|
-
const newValues = [...values];
|
|
389
|
-
newValues[thumbIndex] = newValue;
|
|
390
|
-
latestValue.current = newValues;
|
|
391
|
-
onChange(newValues);
|
|
356
|
+
const newVal = getValueFromX(e.clientX);
|
|
357
|
+
onValueChange(newVal);
|
|
358
|
+
const newPercent = Math.max(0, Math.min(1, (newVal - min) / (max - min)));
|
|
359
|
+
if (variant === "scrubber") {
|
|
360
|
+
fillPercent.set(newPercent);
|
|
392
361
|
} else {
|
|
393
|
-
|
|
394
|
-
onChange(newValue);
|
|
362
|
+
animate(fillPercent, newPercent, spring2.fast);
|
|
395
363
|
}
|
|
396
|
-
|
|
397
|
-
|
|
364
|
+
animate(zeroOffset, newVal === min ? zeroTarget : 0, spring2.fast);
|
|
365
|
+
}, [getValueFromX, onValueChange, variant, fillPercent, zeroOffset, zeroTarget, min, max]);
|
|
366
|
+
const handlePointerUp = useCallback2(() => {
|
|
367
|
+
dragging.current = false;
|
|
368
|
+
setIsPressed(false);
|
|
369
|
+
setHoverPreview(null);
|
|
370
|
+
}, []);
|
|
371
|
+
const handleResizePointerDown = useCallback2((e) => {
|
|
398
372
|
if (disabled)
|
|
399
373
|
return;
|
|
400
374
|
if (e.pointerType === "mouse" && e.button !== 0)
|
|
401
375
|
return;
|
|
402
376
|
e.preventDefault();
|
|
403
377
|
e.stopPropagation();
|
|
404
|
-
|
|
405
|
-
if (!m)
|
|
406
|
-
return;
|
|
407
|
-
const layoutWidth = m.length;
|
|
408
|
-
const localX = m.pos - THUMB_SIZE / 2;
|
|
409
|
-
const clamped = Math.max(0, Math.min(layoutWidth - THUMB_SIZE, localX));
|
|
410
|
-
if (isRange) {
|
|
411
|
-
const dist0 = Math.abs(clamped - motionX0.get());
|
|
412
|
-
const dist1 = Math.abs(clamped - motionX1.get());
|
|
413
|
-
activeDragThumb.current = dist0 <= dist1 ? 0 : 1;
|
|
414
|
-
} else {
|
|
415
|
-
activeDragThumb.current = 0;
|
|
416
|
-
}
|
|
417
|
-
dragging.current = true;
|
|
378
|
+
handleDragging.current = true;
|
|
418
379
|
setIsPressed(true);
|
|
419
|
-
const
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
animate(motionX, finalPx, spring2.moderate);
|
|
424
|
-
const finalValue = pixelToValue(finalPx, min, max, step, layoutWidth, stepValues);
|
|
425
|
-
emitChange(activeDragThumb.current, finalValue);
|
|
380
|
+
const newVal = getValueFromX(e.clientX);
|
|
381
|
+
onValueChange(newVal);
|
|
382
|
+
fillPercent.set(Math.max(0, Math.min(1, (newVal - min) / (max - min))));
|
|
383
|
+
animate(zeroOffset, newVal === min ? zeroTarget : 0, spring2.fast);
|
|
426
384
|
e.currentTarget.setPointerCapture(e.pointerId);
|
|
427
|
-
}, [disabled,
|
|
428
|
-
const
|
|
429
|
-
if (!
|
|
430
|
-
return;
|
|
431
|
-
e.stopPropagation();
|
|
432
|
-
const m = measure(e.clientX, e.clientY);
|
|
433
|
-
if (!m)
|
|
434
|
-
return;
|
|
435
|
-
const layoutWidth = m.length;
|
|
436
|
-
const localX = m.pos - THUMB_SIZE / 2;
|
|
437
|
-
const clamped = Math.max(0, Math.min(layoutWidth - THUMB_SIZE, localX));
|
|
438
|
-
const motionX = activeDragThumb.current === 0 ? motionX0 : motionX1;
|
|
439
|
-
const snappedValue = pixelToValue(clamped, min, max, step, layoutWidth, stepValues);
|
|
440
|
-
const snappedPx = valueToPixel(snappedValue, min, max, layoutWidth);
|
|
441
|
-
const finalPx = clampForRange(snappedPx, activeDragThumb.current);
|
|
442
|
-
motionX.set(finalPx);
|
|
443
|
-
const finalValue = pixelToValue(finalPx, min, max, step, layoutWidth, stepValues);
|
|
444
|
-
emitChange(activeDragThumb.current, finalValue);
|
|
445
|
-
}, [min, max, step, stepValues, motionX0, motionX1, clampForRange, emitChange, measure]);
|
|
446
|
-
const handlePointerUp = useCallback(() => {
|
|
447
|
-
if (!dragging.current)
|
|
385
|
+
}, [disabled, getValueFromX, onValueChange, fillPercent, zeroOffset, zeroTarget, min, max]);
|
|
386
|
+
const handleResizePointerMove = useCallback2((e) => {
|
|
387
|
+
if (!handleDragging.current)
|
|
448
388
|
return;
|
|
449
|
-
|
|
450
|
-
|
|
389
|
+
const newVal = getValueFromX(e.clientX);
|
|
390
|
+
onValueChange(newVal);
|
|
391
|
+
fillPercent.set(Math.max(0, Math.min(1, (newVal - min) / (max - min))));
|
|
392
|
+
animate(zeroOffset, newVal === min ? zeroTarget : 0, spring2.fast);
|
|
393
|
+
}, [getValueFromX, onValueChange, fillPercent, zeroOffset, zeroTarget, min, max]);
|
|
394
|
+
const handleResizePointerUp = useCallback2(() => {
|
|
395
|
+
handleDragging.current = false;
|
|
451
396
|
setIsPressed(false);
|
|
452
397
|
setHoverPreview(null);
|
|
453
|
-
const tw = trackWidthRef.current;
|
|
454
|
-
const motionX = activeDragThumb.current === 0 ? motionX0 : motionX1;
|
|
455
|
-
const currentPx = motionX.get();
|
|
456
|
-
const snapped = pixelToValue(currentPx, min, max, step, tw, stepValues);
|
|
457
|
-
const snappedPx = valueToPixel(snapped, min, max, tw);
|
|
458
|
-
animate(motionX, snappedPx, spring2.moderate);
|
|
459
|
-
}, [min, max, step, stepValues, motionX0, motionX1]);
|
|
460
|
-
const handleRadixChange = useCallback((newValues) => {
|
|
461
|
-
if (dragging.current)
|
|
462
|
-
return;
|
|
463
|
-
const mapped = stepValues ? newValues.map((i) => stepValues[Math.round(i)]) : newValues;
|
|
464
|
-
if (isRange) {
|
|
465
|
-
onChange(mapped);
|
|
466
|
-
} else {
|
|
467
|
-
onChange(mapped[0]);
|
|
468
|
-
}
|
|
469
|
-
}, [isRange, onChange, stepValues]);
|
|
470
|
-
const handleRadixCommit = useCallback((newValues) => {
|
|
471
|
-
const mapped = stepValues ? newValues.map((i) => stepValues[Math.round(i)]) : newValues;
|
|
472
|
-
onValueCommitRef.current?.(isRange ? mapped : mapped[0]);
|
|
473
|
-
}, [isRange, stepValues]);
|
|
474
|
-
const handleStartEdit = useCallback((index) => {
|
|
475
|
-
setEditingIndex(index);
|
|
476
|
-
}, []);
|
|
477
|
-
const handleCommitEdit = useCallback((index, v) => {
|
|
478
|
-
emitChange(index, v);
|
|
479
|
-
onValueCommitRef.current?.(latestValue.current);
|
|
480
|
-
setEditingIndex(null);
|
|
481
|
-
}, [emitChange]);
|
|
482
|
-
const handleCancelEdit = useCallback(() => {
|
|
483
|
-
setEditingIndex(null);
|
|
484
398
|
}, []);
|
|
485
|
-
const
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
style: vertical ? {
|
|
522
|
-
width: THUMB_SIZE,
|
|
523
|
-
height: THUMB_SIZE,
|
|
524
|
-
marginLeft: -THUMB_SIZE / 2,
|
|
525
|
-
y: index === 0 ? thumbY0 : thumbY1,
|
|
526
|
-
position: "absolute",
|
|
527
|
-
left: "50%",
|
|
528
|
-
bottom: 0,
|
|
529
|
-
zIndex: 10
|
|
530
|
-
} : {
|
|
531
|
-
width: THUMB_SIZE,
|
|
532
|
-
height: THUMB_SIZE,
|
|
533
|
-
marginTop: -THUMB_SIZE / 2,
|
|
534
|
-
x: motionX,
|
|
535
|
-
position: "absolute",
|
|
536
|
-
top: "50%",
|
|
537
|
-
left: 0,
|
|
538
|
-
zIndex: 10
|
|
539
|
-
},
|
|
540
|
-
initial: false,
|
|
541
|
-
children: [
|
|
542
|
-
/* @__PURE__ */ jsx(motion.span, {
|
|
543
|
-
className: cn2("block rounded-full shadow-thumb", !thumbColor && "bg-thumb"),
|
|
544
|
-
initial: false,
|
|
545
|
-
animate: {
|
|
546
|
-
width: THUMB_SIZE_REST,
|
|
547
|
-
height: THUMB_SIZE_REST
|
|
548
|
-
},
|
|
399
|
+
const handleRadixChange = useCallback2((newValues) => {
|
|
400
|
+
onValueChange(newValues[0]);
|
|
401
|
+
}, [onValueChange]);
|
|
402
|
+
const isActive = isHovered || isFocused;
|
|
403
|
+
return /* @__PURE__ */ jsxs2("div", {
|
|
404
|
+
className: "relative w-full touch-none",
|
|
405
|
+
onPointerEnter: () => {
|
|
406
|
+
if (!disabled)
|
|
407
|
+
setIsHovered(true);
|
|
408
|
+
},
|
|
409
|
+
onPointerLeave: () => {
|
|
410
|
+
if (!disabled) {
|
|
411
|
+
setIsHovered(false);
|
|
412
|
+
setHoverPreview(null);
|
|
413
|
+
}
|
|
414
|
+
},
|
|
415
|
+
onMouseMove: (e) => {
|
|
416
|
+
if (disabled || dragging.current || handleDragging.current)
|
|
417
|
+
return;
|
|
418
|
+
computeHoverPreview(e.clientX);
|
|
419
|
+
},
|
|
420
|
+
children: [
|
|
421
|
+
/* @__PURE__ */ jsx2("div", {
|
|
422
|
+
className: "absolute cursor-ew-resize",
|
|
423
|
+
style: { left: -8, right: -8, top: 0, bottom: 0 },
|
|
424
|
+
onPointerDown: handlePointerDown,
|
|
425
|
+
onPointerMove: handlePointerMove,
|
|
426
|
+
onPointerUp: handlePointerUp,
|
|
427
|
+
onPointerCancel: handlePointerUp
|
|
428
|
+
}),
|
|
429
|
+
/* @__PURE__ */ jsx2(AnimatePresence, {
|
|
430
|
+
children: hoverPreview && showHoverTooltip && !isPressed && /* @__PURE__ */ jsx2(motion2.div, {
|
|
431
|
+
className: "absolute -translate-x-1/2 pointer-events-none z-20",
|
|
432
|
+
initial: { opacity: 0, y: 4 },
|
|
433
|
+
animate: { opacity: 1, y: 0 },
|
|
434
|
+
exit: { opacity: 0, y: 4, transition: spring2.fast.exit },
|
|
549
435
|
transition: spring2.fast,
|
|
550
436
|
style: {
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
}
|
|
554
|
-
}),
|
|
555
|
-
/* @__PURE__ */ jsx(motion.span, {
|
|
556
|
-
className: "absolute rounded-full border border-focus-ring pointer-events-none",
|
|
557
|
-
initial: false,
|
|
558
|
-
animate: {
|
|
559
|
-
opacity: focusedThumb === index ? 1 : 0,
|
|
560
|
-
width: THUMB_SIZE + 4,
|
|
561
|
-
height: THUMB_SIZE + 4
|
|
437
|
+
left: hoverPreview.cursorX,
|
|
438
|
+
top: -30
|
|
562
439
|
},
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
/* @__PURE__ */ jsxs("div", {
|
|
575
|
-
className: cn2("relative overflow-visible", vertical ? "min-h-0 min-w-0" : "flex-1", vertical && (valuePosition === "left" || valuePosition === "right" ? "h-full" : "flex-1")),
|
|
576
|
-
style: vertical ? { width: THUMB_SIZE + 16 } : {
|
|
577
|
-
height: valuePosition === "left" || valuePosition === "right" ? THUMB_SIZE + 16 : THUMB_SIZE + (valuePosition === "tooltip" ? 16 : 0),
|
|
578
|
-
paddingTop: valuePosition === "tooltip" ? 16 : 0
|
|
579
|
-
},
|
|
580
|
-
onPointerEnter: () => setIsHovered(true),
|
|
581
|
-
onPointerLeave: () => {
|
|
582
|
-
setIsHovered(false);
|
|
583
|
-
setHoverPreview(null);
|
|
584
|
-
},
|
|
585
|
-
onMouseMove: (e) => {
|
|
586
|
-
if (dragging.current)
|
|
587
|
-
return;
|
|
588
|
-
const m = measure(e.clientX, e.clientY);
|
|
589
|
-
if (!m)
|
|
590
|
-
return;
|
|
591
|
-
computeHoverPreview(Math.max(0, Math.min(m.length, m.pos)), m.length);
|
|
440
|
+
children: /* @__PURE__ */ jsx2(ValueBubble, {
|
|
441
|
+
children: formatValue(hoverPreview.snappedValue)
|
|
442
|
+
})
|
|
443
|
+
}, "hover-tooltip")
|
|
444
|
+
}),
|
|
445
|
+
/* @__PURE__ */ jsxs2(motion2.div, {
|
|
446
|
+
ref: mergeRefs2(containerRef, ref),
|
|
447
|
+
className: cn2("relative w-full h-8 select-none touch-none border border-border overflow-hidden outline-offset-2", variant === "scrubber" ? "flex items-center gap-3 px-4 cursor-ew-resize" : "cursor-ew-resize", shape.bg, disabled && "opacity-50 pointer-events-none", className),
|
|
448
|
+
initial: false,
|
|
449
|
+
animate: {
|
|
450
|
+
outline: isFocused ? "1px solid var(--focus-ring)" : "1px solid transparent"
|
|
592
451
|
},
|
|
452
|
+
transition: spring2.fast,
|
|
453
|
+
onPointerDown: handlePointerDown,
|
|
454
|
+
onPointerMove: handlePointerMove,
|
|
455
|
+
onPointerUp: handlePointerUp,
|
|
456
|
+
onPointerCancel: handlePointerUp,
|
|
457
|
+
...props,
|
|
593
458
|
children: [
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
isInteracting && /* @__PURE__ */ jsx(TooltipValue, {
|
|
597
|
-
value: values[0],
|
|
598
|
-
formatValue,
|
|
599
|
-
motionX: motionX0,
|
|
600
|
-
vertical
|
|
601
|
-
}, "tooltip-0"),
|
|
602
|
-
isInteracting && isRange && values[1] !== undefined && /* @__PURE__ */ jsx(TooltipValue, {
|
|
603
|
-
value: values[1],
|
|
604
|
-
formatValue,
|
|
605
|
-
motionX: motionX1,
|
|
606
|
-
vertical
|
|
607
|
-
}, "tooltip-1")
|
|
608
|
-
]
|
|
609
|
-
}),
|
|
610
|
-
/* @__PURE__ */ jsx(SliderPrimitive.Root, {
|
|
611
|
-
value: stepValues ? values.map((v) => nearestStepIndex(v, stepValues)) : values,
|
|
459
|
+
/* @__PURE__ */ jsx2(SliderPrimitive.Root, {
|
|
460
|
+
value: [value],
|
|
612
461
|
onValueChange: (v) => handleRadixChange(v),
|
|
613
|
-
|
|
614
|
-
min
|
|
615
|
-
max
|
|
616
|
-
step
|
|
617
|
-
orientation,
|
|
462
|
+
name,
|
|
463
|
+
min,
|
|
464
|
+
max,
|
|
465
|
+
step,
|
|
618
466
|
disabled,
|
|
619
|
-
className: "absolute inset-0 opacity-0 pointer-events-none",
|
|
620
|
-
|
|
621
|
-
children: /* @__PURE__ */ jsxs(SliderPrimitive.Control, {
|
|
467
|
+
className: "absolute inset-0 opacity-0 pointer-events-none [&_*]:pointer-events-none",
|
|
468
|
+
children: /* @__PURE__ */ jsxs2(SliderPrimitive.Control, {
|
|
622
469
|
className: "w-full h-full",
|
|
623
470
|
children: [
|
|
624
|
-
/* @__PURE__ */
|
|
471
|
+
/* @__PURE__ */ jsx2(SliderPrimitive.Track, {
|
|
625
472
|
className: "w-full h-full",
|
|
626
|
-
children: /* @__PURE__ */
|
|
473
|
+
children: /* @__PURE__ */ jsx2(SliderPrimitive.Indicator, {})
|
|
627
474
|
}),
|
|
628
|
-
/* @__PURE__ */
|
|
475
|
+
/* @__PURE__ */ jsx2(SliderPrimitive.Thumb, {
|
|
629
476
|
index: 0,
|
|
630
|
-
"aria-label":
|
|
631
|
-
getAriaValueText: stepValues ? () => formatValue(values[0]) : undefined,
|
|
632
|
-
className: "block outline-none",
|
|
633
|
-
style: { width: THUMB_SIZE, height: THUMB_SIZE },
|
|
634
|
-
onFocus: (e) => {
|
|
635
|
-
if (e.target.matches(":focus-visible"))
|
|
636
|
-
setFocusedThumb(0);
|
|
637
|
-
},
|
|
638
|
-
onBlur: () => setFocusedThumb((prev) => prev === 0 ? null : prev)
|
|
639
|
-
}),
|
|
640
|
-
isRange && /* @__PURE__ */ jsx(SliderPrimitive.Thumb, {
|
|
641
|
-
index: 1,
|
|
642
|
-
"aria-label": thumbAriaLabel(1),
|
|
643
|
-
getAriaValueText: stepValues ? () => formatValue(values[1]) : undefined,
|
|
477
|
+
"aria-label": label,
|
|
644
478
|
className: "block outline-none",
|
|
645
|
-
style: { width: THUMB_SIZE, height: THUMB_SIZE },
|
|
646
479
|
onFocus: (e) => {
|
|
647
|
-
if (e.
|
|
648
|
-
|
|
480
|
+
if (e.currentTarget.matches(":focus-visible"))
|
|
481
|
+
setIsFocused(true);
|
|
649
482
|
},
|
|
650
|
-
onBlur: () =>
|
|
483
|
+
onBlur: () => setIsFocused(false)
|
|
651
484
|
})
|
|
652
485
|
]
|
|
653
486
|
})
|
|
654
487
|
}),
|
|
655
|
-
/* @__PURE__ */
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
488
|
+
/* @__PURE__ */ jsx2(motion2.div, {
|
|
489
|
+
className: "absolute inset-y-0 bg-accent/40 pointer-events-none z-[3]",
|
|
490
|
+
initial: false,
|
|
491
|
+
animate: {
|
|
492
|
+
opacity: hoverPreview && !isPressed ? 1 : 0
|
|
493
|
+
},
|
|
494
|
+
transition: { opacity: { duration: 0.15 } },
|
|
495
|
+
style: {
|
|
496
|
+
left: hoverPreview ? hoverPreview.left : 0,
|
|
497
|
+
width: hoverPreview ? hoverPreview.width : 0
|
|
498
|
+
}
|
|
499
|
+
}),
|
|
500
|
+
variant === "pips" && /* @__PURE__ */ jsx2(motion2.div, {
|
|
501
|
+
className: "absolute inset-0 flex justify-between items-center px-3 pointer-events-none z-[1]",
|
|
502
|
+
style: { WebkitMaskImage: pipsMaskStyle, maskImage: pipsMaskStyle },
|
|
503
|
+
children: pipSteps.map((pipValue) => {
|
|
504
|
+
const isActivePip = pipValue === value;
|
|
505
|
+
return /* @__PURE__ */ jsx2("div", {
|
|
506
|
+
className: "relative flex items-center justify-center",
|
|
507
|
+
style: { width: PIP_SIZE, height: PIP_SIZE },
|
|
508
|
+
children: /* @__PURE__ */ jsx2(motion2.div, {
|
|
509
|
+
className: "rounded-full",
|
|
510
|
+
initial: false,
|
|
511
|
+
animate: {
|
|
512
|
+
backgroundColor: isActivePip ? "var(--foreground)" : "var(--muted-foreground)",
|
|
513
|
+
opacity: isActivePip ? 1 : 0.3
|
|
514
|
+
},
|
|
515
|
+
transition: spring2.fast,
|
|
516
|
+
style: { width: PIP_SIZE, height: PIP_SIZE }
|
|
517
|
+
})
|
|
518
|
+
}, pipValue);
|
|
519
|
+
})
|
|
520
|
+
}),
|
|
521
|
+
variant === "pips" && /* @__PURE__ */ jsxs2("div", {
|
|
522
|
+
className: "absolute inset-0 flex items-center px-2 z-[2] pointer-events-none",
|
|
523
|
+
"aria-hidden": true,
|
|
663
524
|
children: [
|
|
664
|
-
/* @__PURE__ */
|
|
665
|
-
className:
|
|
666
|
-
|
|
667
|
-
onPointerDown: handlePointerDown,
|
|
668
|
-
onPointerMove: handlePointerMove,
|
|
669
|
-
onPointerUp: handlePointerUp,
|
|
670
|
-
onPointerCancel: handlePointerUp
|
|
525
|
+
label && /* @__PURE__ */ jsx2("span", {
|
|
526
|
+
className: "text-body px-2 bg-background text-transparent select-none",
|
|
527
|
+
children: label
|
|
671
528
|
}),
|
|
672
|
-
/* @__PURE__ */
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
529
|
+
/* @__PURE__ */ jsx2("span", {
|
|
530
|
+
className: "text-body tabular-nums ml-auto px-2 bg-background text-transparent select-none",
|
|
531
|
+
style: { minWidth: `${String(formatValue(max)).length}ch` },
|
|
532
|
+
children: formatValue(value)
|
|
533
|
+
})
|
|
534
|
+
]
|
|
535
|
+
}),
|
|
536
|
+
variant === "pips" && /* @__PURE__ */ jsx2(motion2.div, {
|
|
537
|
+
className: "absolute left-0 top-0 bottom-0 bg-active pointer-events-none z-[3]",
|
|
538
|
+
style: {
|
|
539
|
+
width: pipsFillWidthStyle
|
|
540
|
+
}
|
|
541
|
+
}),
|
|
542
|
+
variant === "pips" && /* @__PURE__ */ jsx2(motion2.div, {
|
|
543
|
+
className: "absolute rounded-full pointer-events-none z-[3]",
|
|
544
|
+
initial: false,
|
|
545
|
+
animate: {
|
|
546
|
+
top: isActive ? 7 : 8,
|
|
547
|
+
bottom: isActive ? 7 : 8,
|
|
548
|
+
backgroundColor: isFocused ? "var(--foreground)" : isHovered ? "color-mix(in srgb, var(--foreground) 50%, transparent)" : "color-mix(in srgb, var(--foreground) 25%, transparent)"
|
|
549
|
+
},
|
|
550
|
+
transition: spring2.fast,
|
|
551
|
+
style: {
|
|
552
|
+
left: pipsHandleLineLeftStyle,
|
|
553
|
+
width: 2
|
|
554
|
+
}
|
|
555
|
+
}),
|
|
556
|
+
variant === "pips" && /* @__PURE__ */ jsxs2("div", {
|
|
557
|
+
className: "absolute inset-0 flex items-center px-2 z-[4] pointer-events-none",
|
|
558
|
+
children: [
|
|
559
|
+
label && /* @__PURE__ */ jsx2(motion2.span, {
|
|
560
|
+
className: "text-body px-2",
|
|
561
|
+
initial: false,
|
|
562
|
+
animate: { color: isActive ? "var(--foreground)" : "var(--muted-foreground)" },
|
|
563
|
+
transition: spring2.fast,
|
|
564
|
+
children: label
|
|
685
565
|
}),
|
|
686
|
-
/* @__PURE__ */
|
|
687
|
-
className:
|
|
566
|
+
/* @__PURE__ */ jsx2(motion2.span, {
|
|
567
|
+
className: "text-body tabular-nums ml-auto px-2",
|
|
688
568
|
initial: false,
|
|
689
|
-
animate:
|
|
569
|
+
animate: { color: isActive ? "var(--foreground)" : "var(--muted-foreground)" },
|
|
690
570
|
transition: spring2.fast,
|
|
691
|
-
style: {
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
className:
|
|
727
|
-
style: {
|
|
728
|
-
...vertical ? { left: 8 + (THUMB_SIZE - TRACK_BG_HEIGHT) / 2, width: TRACK_BG_HEIGHT } : { top: 8 + (THUMB_SIZE - TRACK_BG_HEIGHT) / 2, height: TRACK_BG_HEIGHT },
|
|
729
|
-
WebkitMaskImage: stepDotsMask,
|
|
730
|
-
maskImage: stepDotsMask
|
|
731
|
-
},
|
|
732
|
-
children: stepDots.map(({ value: v, percent }) => /* @__PURE__ */ jsx("div", {
|
|
733
|
-
className: "absolute pointer-events-none flex items-center justify-center",
|
|
734
|
-
style: {
|
|
735
|
-
...vertical ? {
|
|
736
|
-
bottom: `calc(${THUMB_SIZE / 2}px + ${percent} * (100% - ${THUMB_SIZE}px))`,
|
|
737
|
-
left: "50%"
|
|
738
|
-
} : {
|
|
739
|
-
left: `calc(${THUMB_SIZE / 2}px + ${percent} * (100% - ${THUMB_SIZE}px))`,
|
|
740
|
-
top: "50%"
|
|
741
|
-
},
|
|
742
|
-
width: 0,
|
|
743
|
-
height: 0
|
|
744
|
-
},
|
|
745
|
-
children: /* @__PURE__ */ jsx(motion.div, {
|
|
746
|
-
className: "rounded-full flex-shrink-0 bg-muted-foreground opacity-30",
|
|
747
|
-
initial: false,
|
|
748
|
-
animate: {
|
|
749
|
-
width: isHovered ? DOT_SIZE * 1.25 : DOT_SIZE,
|
|
750
|
-
height: isHovered ? DOT_SIZE * 1.25 : DOT_SIZE
|
|
751
|
-
},
|
|
752
|
-
transition: spring2.moderate
|
|
753
|
-
})
|
|
754
|
-
}, v))
|
|
571
|
+
style: { minWidth: `${String(formatValue(max)).length}ch`, textAlign: "right" },
|
|
572
|
+
children: formatValue(value)
|
|
573
|
+
})
|
|
574
|
+
]
|
|
575
|
+
}),
|
|
576
|
+
variant === "scrubber" && /* @__PURE__ */ jsx2(motion2.div, {
|
|
577
|
+
className: "absolute left-0 top-0 bottom-0 bg-active pointer-events-none",
|
|
578
|
+
style: {
|
|
579
|
+
width: fillWidthStyle
|
|
580
|
+
}
|
|
581
|
+
}),
|
|
582
|
+
variant === "scrubber" && /* @__PURE__ */ jsx2(motion2.div, {
|
|
583
|
+
className: "absolute rounded-full pointer-events-none z-10",
|
|
584
|
+
initial: false,
|
|
585
|
+
animate: {
|
|
586
|
+
top: isActive ? 7 : 8,
|
|
587
|
+
bottom: isActive ? 7 : 8,
|
|
588
|
+
backgroundColor: isFocused ? "var(--foreground)" : isHovered ? "color-mix(in srgb, var(--foreground) 50%, transparent)" : "color-mix(in srgb, var(--foreground) 25%, transparent)"
|
|
589
|
+
},
|
|
590
|
+
transition: spring2.fast,
|
|
591
|
+
style: {
|
|
592
|
+
left: handleLineLeftStyle,
|
|
593
|
+
width: 2
|
|
594
|
+
}
|
|
595
|
+
}),
|
|
596
|
+
variant === "scrubber" && label && /* @__PURE__ */ jsx2(motion2.span, {
|
|
597
|
+
className: "text-body shrink-0 z-10",
|
|
598
|
+
initial: false,
|
|
599
|
+
animate: { color: isActive ? "var(--foreground)" : "var(--muted-foreground)" },
|
|
600
|
+
transition: spring2.fast,
|
|
601
|
+
children: label
|
|
602
|
+
}),
|
|
603
|
+
variant === "scrubber" && /* @__PURE__ */ jsxs2(Fragment2, {
|
|
604
|
+
children: [
|
|
605
|
+
/* @__PURE__ */ jsx2("div", {
|
|
606
|
+
className: "flex-1"
|
|
755
607
|
}),
|
|
756
|
-
|
|
757
|
-
|
|
608
|
+
/* @__PURE__ */ jsx2(motion2.span, {
|
|
609
|
+
className: "text-body shrink-0 tabular-nums text-right z-10",
|
|
610
|
+
initial: false,
|
|
611
|
+
animate: { color: isActive ? "var(--foreground)" : "var(--muted-foreground)" },
|
|
612
|
+
transition: spring2.fast,
|
|
613
|
+
style: { minWidth: `${String(formatValue(max)).length}ch` },
|
|
614
|
+
children: formatValue(value)
|
|
615
|
+
})
|
|
758
616
|
]
|
|
617
|
+
}),
|
|
618
|
+
variant === "scrubber" && /* @__PURE__ */ jsx2(motion2.div, {
|
|
619
|
+
className: "absolute top-0 bottom-0 w-2 cursor-ew-resize z-20",
|
|
620
|
+
style: { left: handleLeftStyle },
|
|
621
|
+
onPointerDown: handleResizePointerDown,
|
|
622
|
+
onPointerMove: handleResizePointerMove,
|
|
623
|
+
onPointerUp: handleResizePointerUp,
|
|
624
|
+
onPointerCancel: handleResizePointerUp
|
|
759
625
|
})
|
|
760
626
|
]
|
|
761
|
-
})
|
|
762
|
-
(valuePosition === "bottom" || valuePosition === "right") && valueDisplay
|
|
627
|
+
})
|
|
763
628
|
]
|
|
764
629
|
});
|
|
765
630
|
});
|
|
766
|
-
|
|
767
|
-
|
|
631
|
+
ComfortableSlider.displayName = "ComfortableSlider";
|
|
632
|
+
|
|
633
|
+
// components/inputs/slider/compact.tsx
|
|
634
|
+
import { Slider as SliderPrimitive2 } from "@base-ui/react/slider";
|
|
635
|
+
import { AnimatePresence as AnimatePresence2, animate as animate2, motion as motion3, useMotionValue as useMotionValue2, useTransform as useTransform3 } from "motion/react";
|
|
636
|
+
import {
|
|
637
|
+
forwardRef as forwardRef2,
|
|
638
|
+
useCallback as useCallback3,
|
|
639
|
+
useEffect as useEffect4,
|
|
640
|
+
useLayoutEffect,
|
|
641
|
+
useMemo as useMemo2,
|
|
642
|
+
useRef as useRef3,
|
|
643
|
+
useState as useState4
|
|
644
|
+
} from "react";
|
|
645
|
+
import { jsx as jsx3, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
646
|
+
/*!
|
|
647
|
+
* Part of the Slider port (Fluid Functionalism `registry/base/slider.tsx` @ b3587bdbd83fc66c2a6aae3817ffb856cb09260b,
|
|
648
|
+
* MIT License © 2026 Micka Touillaud). Local changes: see PORTING.md.
|
|
649
|
+
*/
|
|
650
|
+
var CompactSlider = forwardRef2(({
|
|
768
651
|
value,
|
|
769
|
-
|
|
770
|
-
min = 0,
|
|
771
|
-
max = 100,
|
|
652
|
+
onValueChange,
|
|
653
|
+
min: minProp = 0,
|
|
654
|
+
max: maxProp = 100,
|
|
772
655
|
step = 1,
|
|
773
|
-
|
|
774
|
-
|
|
656
|
+
steps,
|
|
657
|
+
showSteps = false,
|
|
658
|
+
showValue = true,
|
|
659
|
+
valuePosition = "left",
|
|
775
660
|
formatValue = String,
|
|
661
|
+
label,
|
|
776
662
|
disabled = false,
|
|
777
|
-
|
|
663
|
+
name,
|
|
664
|
+
trackClassName,
|
|
665
|
+
trackStyle,
|
|
666
|
+
fillClassName,
|
|
667
|
+
fillStyle,
|
|
668
|
+
hideFill = false,
|
|
669
|
+
thumbColor,
|
|
670
|
+
thumbBorderColor,
|
|
778
671
|
className,
|
|
779
|
-
"aria-label": ariaLabel,
|
|
780
672
|
...props
|
|
781
673
|
}, ref) => {
|
|
782
|
-
const
|
|
783
|
-
const
|
|
784
|
-
|
|
785
|
-
const
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
const [
|
|
792
|
-
const [
|
|
793
|
-
const
|
|
794
|
-
const
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
const
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
const
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
const zeroTarget = variant === "pips" ? 8 : 17;
|
|
819
|
-
const zeroOffset = useMotionValue(value === min ? zeroTarget : 0);
|
|
820
|
-
const fillWidthStyle = useTransform(fillPercent, (p) => `${p * 100}%`);
|
|
821
|
-
const handleLeftStyle = useTransform([fillPercent, zeroOffset], ([p, zo]) => `calc(${p * 100}% - 8px + ${zo}px)`);
|
|
822
|
-
const handleLineLeftStyle = useTransform([fillPercent, zeroOffset], ([p, zo]) => `calc(${p * 100}% - 9px + ${zo}px)`);
|
|
823
|
-
const pipsFillWidthStyle = useTransform([fillPercent, zeroOffset], ([p, zo]) => `calc(${p * 100}% + ${20 - 20 * p - zo * 2.5}px)`);
|
|
824
|
-
const pipsHandleLineLeftStyle = useTransform(fillPercent, (p) => `calc(${p * 100}% + ${11 - 24 * p}px)`);
|
|
825
|
-
const pipsMaskStyle = useTransform([fillPercent, zeroOffset], ([p, zo]) => {
|
|
826
|
-
const offset = 20 - 20 * p - zo * 2.5;
|
|
827
|
-
return `linear-gradient(to right, transparent calc(${p * 100}% + ${offset}px), black calc(${p * 100}% + ${offset + 2}px))`;
|
|
674
|
+
const isRange = Array.isArray(value);
|
|
675
|
+
const values = toRadixValue(value);
|
|
676
|
+
const stepsKey = steps ? steps.join(",") : "";
|
|
677
|
+
const stepValues = useMemo2(() => {
|
|
678
|
+
if (!stepsKey)
|
|
679
|
+
return null;
|
|
680
|
+
const parsed = Array.from(new Set(stepsKey.split(",").map(Number))).sort((a, b) => a - b);
|
|
681
|
+
return parsed.length > 1 ? parsed : null;
|
|
682
|
+
}, [stepsKey]);
|
|
683
|
+
const min = stepValues ? stepValues[0] : minProp;
|
|
684
|
+
const max = stepValues ? stepValues[stepValues.length - 1] : maxProp;
|
|
685
|
+
const trackRef = useRef3(null);
|
|
686
|
+
const trackWidthRef = useRef3(0);
|
|
687
|
+
const dragging = useRef3(false);
|
|
688
|
+
const activeDragThumb = useRef3(0);
|
|
689
|
+
const valuesRef = useRef3(values);
|
|
690
|
+
const minRef = useRef3(min);
|
|
691
|
+
const maxRef = useRef3(max);
|
|
692
|
+
valuesRef.current = values;
|
|
693
|
+
minRef.current = min;
|
|
694
|
+
maxRef.current = max;
|
|
695
|
+
const [isHovered, setIsHovered] = useState4(false);
|
|
696
|
+
const [isPressed, setIsPressed] = useState4(false);
|
|
697
|
+
const [editingIndex, setEditingIndex] = useState4(null);
|
|
698
|
+
const [hoverPreview, setHoverPreview] = useState4(null);
|
|
699
|
+
const [focusedThumb, setFocusedThumb] = useState4(null);
|
|
700
|
+
const showHoverTooltip = useDelayedFlag(isHovered, 100);
|
|
701
|
+
const motionX0 = useMotionValue2(0);
|
|
702
|
+
const motionX1 = useMotionValue2(0);
|
|
703
|
+
const fillLeft = useTransform3(motionX0, (x) => isRange ? x + THUMB_SIZE / 2 - TRACK_INSET : 0);
|
|
704
|
+
const fillWidthSingle = useTransform3(motionX0, (x) => x + THUMB_SIZE / 2 - TRACK_INSET);
|
|
705
|
+
const fillWidthRange = useTransform3([motionX0, motionX1], ([x0, x1]) => x1 - x0);
|
|
706
|
+
const fillWidth = isRange ? fillWidthRange : fillWidthSingle;
|
|
707
|
+
const stepDotsMaskSingle = useTransform3(motionX0, (x) => {
|
|
708
|
+
const edge = x + THUMB_SIZE / 2;
|
|
709
|
+
return `linear-gradient(to right, transparent ${edge}px, black ${edge + 2}px)`;
|
|
828
710
|
});
|
|
829
|
-
const
|
|
830
|
-
const
|
|
711
|
+
const stepDotsMaskRange = useTransform3([motionX0, motionX1], ([x0, x1]) => {
|
|
712
|
+
const left = x0 + THUMB_SIZE / 2;
|
|
713
|
+
const right = x1 + THUMB_SIZE / 2;
|
|
714
|
+
return `linear-gradient(to right, black ${left - 2}px, transparent ${left}px, transparent ${right}px, black ${right + 2}px)`;
|
|
715
|
+
});
|
|
716
|
+
const stepDotsMask = isRange ? stepDotsMaskRange : stepDotsMaskSingle;
|
|
717
|
+
const computeHoverPreview = useCallback3((cursorX, trackWidth) => {
|
|
718
|
+
const usable = trackWidth - THUMB_SIZE;
|
|
719
|
+
const rawPx = cursorX - THUMB_SIZE / 2;
|
|
720
|
+
const clampedPx = Math.max(0, Math.min(usable, rawPx));
|
|
721
|
+
const rawVal = usable > 0 ? clampedPx / usable * (max - min) + min : min;
|
|
722
|
+
const snappedVal = snapValue(rawVal, min, max, step, stepValues);
|
|
723
|
+
const snappedPercent = max === min ? 0 : (snappedVal - min) / (max - min);
|
|
724
|
+
const snappedX = THUMB_SIZE / 2 + snappedPercent * usable;
|
|
725
|
+
const c0 = motionX0.get() + THUMB_SIZE / 2;
|
|
726
|
+
const c1 = motionX1.get() + THUMB_SIZE / 2;
|
|
727
|
+
const nearestIdx = isRange ? Math.abs(snappedX - c0) <= Math.abs(snappedX - c1) ? 0 : 1 : 0;
|
|
728
|
+
const nearest = nearestIdx === 0 ? c0 : c1;
|
|
729
|
+
const edgeX = snappedVal === min ? 0 : snappedVal === max ? trackWidth : snappedX;
|
|
730
|
+
const left = Math.min(nearest, edgeX);
|
|
731
|
+
const width = Math.abs(edgeX - nearest);
|
|
732
|
+
setHoverPreview({ left, width, snappedValue: snappedVal, cursorX: snappedX });
|
|
733
|
+
}, [min, max, step, stepValues, isRange, motionX0, motionX1]);
|
|
734
|
+
const initialSyncDone = useRef3(false);
|
|
735
|
+
const [ready, setReady] = useState4(false);
|
|
736
|
+
useLayoutEffect(() => {
|
|
737
|
+
const el = trackRef.current;
|
|
738
|
+
if (!el || initialSyncDone.current)
|
|
739
|
+
return;
|
|
740
|
+
const w = el.offsetWidth;
|
|
741
|
+
trackWidthRef.current = w;
|
|
742
|
+
const px0 = valueToPixel(values[0], min, max, w);
|
|
743
|
+
motionX0.set(px0);
|
|
744
|
+
if (isRange && values[1] !== undefined) {
|
|
745
|
+
const px1 = valueToPixel(values[1], min, max, w);
|
|
746
|
+
motionX1.set(px1);
|
|
747
|
+
}
|
|
748
|
+
initialSyncDone.current = true;
|
|
749
|
+
setReady(true);
|
|
750
|
+
}, []);
|
|
751
|
+
useEffect4(() => {
|
|
752
|
+
const el = trackRef.current;
|
|
831
753
|
if (!el)
|
|
832
754
|
return;
|
|
833
|
-
const
|
|
834
|
-
|
|
835
|
-
|
|
755
|
+
const ro = new ResizeObserver(([entry]) => {
|
|
756
|
+
const w = entry.contentRect.width;
|
|
757
|
+
trackWidthRef.current = w;
|
|
758
|
+
if (!dragging.current && initialSyncDone.current) {
|
|
759
|
+
const v = valuesRef.current;
|
|
760
|
+
const mn = minRef.current;
|
|
761
|
+
const mx = maxRef.current;
|
|
762
|
+
const px0 = valueToPixel(v[0], mn, mx, w);
|
|
763
|
+
animate2(motionX0, px0, spring2.moderate);
|
|
764
|
+
if (isRange && v[1] !== undefined) {
|
|
765
|
+
const px1 = valueToPixel(v[1], mn, mx, w);
|
|
766
|
+
animate2(motionX1, px1, spring2.moderate);
|
|
767
|
+
}
|
|
768
|
+
}
|
|
769
|
+
});
|
|
770
|
+
ro.observe(el);
|
|
771
|
+
return () => ro.disconnect();
|
|
772
|
+
}, [isRange, motionX0, motionX1]);
|
|
773
|
+
const valuesKey = values.join(",");
|
|
774
|
+
useEffect4(() => {
|
|
775
|
+
if (!initialSyncDone.current)
|
|
836
776
|
return;
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
const
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
const
|
|
847
|
-
|
|
848
|
-
} else {
|
|
849
|
-
const raw = min + clamped / w * (max - min);
|
|
850
|
-
snappedVal = Math.max(min, Math.min(max, Math.round((raw - min) / step) * step + min));
|
|
777
|
+
if (dragging.current)
|
|
778
|
+
return;
|
|
779
|
+
const tw = trackWidthRef.current;
|
|
780
|
+
if (tw <= 0)
|
|
781
|
+
return;
|
|
782
|
+
const v = valuesRef.current;
|
|
783
|
+
const px0 = valueToPixel(v[0], min, max, tw);
|
|
784
|
+
animate2(motionX0, px0, spring2.moderate);
|
|
785
|
+
if (isRange && v[1] !== undefined) {
|
|
786
|
+
const px1 = valueToPixel(v[1], min, max, tw);
|
|
787
|
+
animate2(motionX1, px1, spring2.moderate);
|
|
851
788
|
}
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
if (
|
|
857
|
-
|
|
858
|
-
handleX = currentPercent * w + (20 - 20 * currentPercent - zo * 2.5);
|
|
859
|
-
} else {
|
|
860
|
-
handleX = currentPercent * w;
|
|
789
|
+
}, [valuesKey, min, max, isRange, motionX0, motionX1]);
|
|
790
|
+
const clampForRange = useCallback3((px, thumbIndex) => {
|
|
791
|
+
if (!isRange)
|
|
792
|
+
return px;
|
|
793
|
+
if (thumbIndex === 0) {
|
|
794
|
+
return Math.min(px, motionX1.get() - THUMB_SIZE * 0.5);
|
|
861
795
|
}
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
animate(fillPercent, percent, spring2.fast);
|
|
872
|
-
animate(zeroOffset, value === min ? zeroTarget : 0, spring2.fast);
|
|
873
|
-
}, [value, min, max, variant, fillPercent, zeroOffset, zeroTarget]);
|
|
874
|
-
const getValueFromX = useCallback((clientX) => {
|
|
875
|
-
const rect = containerRef.current?.getBoundingClientRect();
|
|
876
|
-
if (!rect)
|
|
877
|
-
return min;
|
|
878
|
-
const x = clientX - rect.left;
|
|
879
|
-
const clamped = Math.max(0, Math.min(rect.width, x));
|
|
880
|
-
if (variant === "pips") {
|
|
881
|
-
if (pipCount <= 1)
|
|
882
|
-
return min;
|
|
883
|
-
const index = Math.max(0, Math.min(pipCount - 1, Math.round(clamped / rect.width * (pipCount - 1))));
|
|
884
|
-
return pipSteps[index];
|
|
796
|
+
return Math.max(px, motionX0.get() + THUMB_SIZE * 0.5);
|
|
797
|
+
}, [isRange, motionX0, motionX1]);
|
|
798
|
+
const emitChange = useCallback3((thumbIndex, newValue) => {
|
|
799
|
+
if (isRange) {
|
|
800
|
+
const newValues = [...values];
|
|
801
|
+
newValues[thumbIndex] = newValue;
|
|
802
|
+
onValueChange(newValues);
|
|
803
|
+
} else {
|
|
804
|
+
onValueChange(newValue);
|
|
885
805
|
}
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
return Math.max(min, Math.min(max, snapped));
|
|
889
|
-
}, [variant, pipSteps, pipCount, min, max, step]);
|
|
890
|
-
const handlePointerDown = useCallback((e) => {
|
|
806
|
+
}, [isRange, values, onValueChange]);
|
|
807
|
+
const handlePointerDown = useCallback3((e) => {
|
|
891
808
|
if (disabled)
|
|
892
809
|
return;
|
|
893
810
|
if (e.pointerType === "mouse" && e.button !== 0)
|
|
894
811
|
return;
|
|
895
812
|
e.preventDefault();
|
|
813
|
+
e.stopPropagation();
|
|
814
|
+
const trackEl = trackRef.current;
|
|
815
|
+
if (!trackEl)
|
|
816
|
+
return;
|
|
817
|
+
const x = layoutX(e.clientX, trackEl);
|
|
818
|
+
if (x === null)
|
|
819
|
+
return;
|
|
820
|
+
const layoutWidth = trackEl.offsetWidth;
|
|
821
|
+
const clamped = Math.max(0, Math.min(layoutWidth - THUMB_SIZE, x - THUMB_SIZE / 2));
|
|
822
|
+
if (isRange) {
|
|
823
|
+
const dist0 = Math.abs(clamped - motionX0.get());
|
|
824
|
+
const dist1 = Math.abs(clamped - motionX1.get());
|
|
825
|
+
activeDragThumb.current = dist0 <= dist1 ? 0 : 1;
|
|
826
|
+
} else {
|
|
827
|
+
activeDragThumb.current = 0;
|
|
828
|
+
}
|
|
896
829
|
dragging.current = true;
|
|
897
830
|
setIsPressed(true);
|
|
898
|
-
const
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
const
|
|
902
|
-
|
|
903
|
-
|
|
831
|
+
const motionX = activeDragThumb.current === 0 ? motionX0 : motionX1;
|
|
832
|
+
const snappedValue = pixelToValue(clamped, min, max, step, layoutWidth, stepValues);
|
|
833
|
+
const snappedPx = valueToPixel(snappedValue, min, max, layoutWidth);
|
|
834
|
+
const finalPx = clampForRange(snappedPx, activeDragThumb.current);
|
|
835
|
+
animate2(motionX, finalPx, spring2.moderate);
|
|
836
|
+
const finalValue = pixelToValue(finalPx, min, max, step, layoutWidth, stepValues);
|
|
837
|
+
emitChange(activeDragThumb.current, finalValue);
|
|
904
838
|
e.currentTarget.setPointerCapture(e.pointerId);
|
|
905
|
-
}, [disabled,
|
|
906
|
-
const handlePointerMove =
|
|
839
|
+
}, [disabled, isRange, min, max, step, stepValues, motionX0, motionX1, clampForRange, emitChange]);
|
|
840
|
+
const handlePointerMove = useCallback3((e) => {
|
|
907
841
|
if (!dragging.current)
|
|
908
842
|
return;
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
const newPercent = Math.max(0, Math.min(1, (newVal - min) / (max - min)));
|
|
913
|
-
if (variant === "scrubber") {
|
|
914
|
-
fillPercent.set(newPercent);
|
|
915
|
-
} else {
|
|
916
|
-
animate(fillPercent, newPercent, spring2.fast);
|
|
917
|
-
}
|
|
918
|
-
animate(zeroOffset, newVal === min ? zeroTarget : 0, spring2.fast);
|
|
919
|
-
}, [getValueFromX, onChange, variant, fillPercent, zeroOffset, zeroTarget, min, max]);
|
|
920
|
-
const handlePointerUp = useCallback(() => {
|
|
921
|
-
if (dragging.current)
|
|
922
|
-
onValueCommitRef.current?.(latestValue.current);
|
|
923
|
-
dragging.current = false;
|
|
924
|
-
setIsPressed(false);
|
|
925
|
-
setHoverPreview(null);
|
|
926
|
-
}, []);
|
|
927
|
-
const handleResizePointerDown = useCallback((e) => {
|
|
928
|
-
if (disabled)
|
|
843
|
+
e.stopPropagation();
|
|
844
|
+
const trackEl = trackRef.current;
|
|
845
|
+
if (!trackEl)
|
|
929
846
|
return;
|
|
930
|
-
|
|
847
|
+
const x = layoutX(e.clientX, trackEl);
|
|
848
|
+
if (x === null)
|
|
931
849
|
return;
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
const
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
if (!handleDragging.current)
|
|
850
|
+
const layoutWidth = trackEl.offsetWidth;
|
|
851
|
+
const clamped = Math.max(0, Math.min(layoutWidth - THUMB_SIZE, x - THUMB_SIZE / 2));
|
|
852
|
+
const motionX = activeDragThumb.current === 0 ? motionX0 : motionX1;
|
|
853
|
+
const snappedValue = pixelToValue(clamped, min, max, step, layoutWidth, stepValues);
|
|
854
|
+
const snappedPx = valueToPixel(snappedValue, min, max, layoutWidth);
|
|
855
|
+
const finalPx = clampForRange(snappedPx, activeDragThumb.current);
|
|
856
|
+
motionX.set(finalPx);
|
|
857
|
+
const finalValue = pixelToValue(finalPx, min, max, step, layoutWidth, stepValues);
|
|
858
|
+
emitChange(activeDragThumb.current, finalValue);
|
|
859
|
+
}, [min, max, step, stepValues, motionX0, motionX1, clampForRange, emitChange]);
|
|
860
|
+
const handlePointerUp = useCallback3(() => {
|
|
861
|
+
if (!dragging.current)
|
|
945
862
|
return;
|
|
946
|
-
|
|
947
|
-
latestValue.current = newVal;
|
|
948
|
-
onChange(newVal);
|
|
949
|
-
fillPercent.set(Math.max(0, Math.min(1, (newVal - min) / (max - min))));
|
|
950
|
-
animate(zeroOffset, newVal === min ? zeroTarget : 0, spring2.fast);
|
|
951
|
-
}, [getValueFromX, onChange, fillPercent, zeroOffset, zeroTarget, min, max]);
|
|
952
|
-
const handleResizePointerUp = useCallback(() => {
|
|
953
|
-
if (handleDragging.current)
|
|
954
|
-
onValueCommitRef.current?.(latestValue.current);
|
|
955
|
-
handleDragging.current = false;
|
|
863
|
+
dragging.current = false;
|
|
956
864
|
setIsPressed(false);
|
|
957
865
|
setHoverPreview(null);
|
|
866
|
+
const tw = trackWidthRef.current;
|
|
867
|
+
const motionX = activeDragThumb.current === 0 ? motionX0 : motionX1;
|
|
868
|
+
const currentPx = motionX.get();
|
|
869
|
+
const snapped = pixelToValue(currentPx, min, max, step, tw, stepValues);
|
|
870
|
+
const snappedPx = valueToPixel(snapped, min, max, tw);
|
|
871
|
+
animate2(motionX, snappedPx, spring2.moderate);
|
|
872
|
+
}, [min, max, step, stepValues, motionX0, motionX1]);
|
|
873
|
+
const handleRadixChange = useCallback3((newValues) => {
|
|
874
|
+
if (dragging.current)
|
|
875
|
+
return;
|
|
876
|
+
const mapped = stepValues ? newValues.map((i) => stepValues[Math.round(i)]) : newValues;
|
|
877
|
+
if (isRange) {
|
|
878
|
+
onValueChange(mapped);
|
|
879
|
+
} else {
|
|
880
|
+
onValueChange(mapped[0]);
|
|
881
|
+
}
|
|
882
|
+
}, [isRange, onValueChange, stepValues]);
|
|
883
|
+
const handleStartEdit = useCallback3((index) => {
|
|
884
|
+
setEditingIndex(index);
|
|
958
885
|
}, []);
|
|
959
|
-
const
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
886
|
+
const handleCommitEdit = useCallback3((index, v) => {
|
|
887
|
+
emitChange(index, v);
|
|
888
|
+
setEditingIndex(null);
|
|
889
|
+
}, [emitChange]);
|
|
890
|
+
const handleCancelEdit = useCallback3(() => {
|
|
891
|
+
setEditingIndex(null);
|
|
892
|
+
}, []);
|
|
893
|
+
const stepDots = useMemo2(() => showSteps ? stepValues ? stepValues.map((v) => ({
|
|
894
|
+
value: v,
|
|
895
|
+
percent: max === min ? 0 : (v - min) / (max - min)
|
|
896
|
+
})) : Array.from({ length: Math.round((max - min) / step) + 1 }, (_, i) => {
|
|
897
|
+
const v = min + i * step;
|
|
898
|
+
const percent = (v - min) / (max - min);
|
|
899
|
+
return { value: v, percent };
|
|
900
|
+
}) : [], [showSteps, min, max, step, stepValues]);
|
|
901
|
+
const isInteracting = isHovered || isPressed;
|
|
902
|
+
const thumbAriaLabel = (index) => {
|
|
903
|
+
if (!isRange)
|
|
904
|
+
return label;
|
|
905
|
+
if (!label)
|
|
906
|
+
return index === 0 ? "Minimum" : "Maximum";
|
|
907
|
+
return index === 0 ? `${label} minimum` : `${label} maximum`;
|
|
908
|
+
};
|
|
909
|
+
const valueDisplay = showValue && valuePosition !== "tooltip" && /* @__PURE__ */ jsx3(ValueDisplay, {
|
|
910
|
+
values,
|
|
911
|
+
editingIndex,
|
|
912
|
+
onStartEdit: handleStartEdit,
|
|
913
|
+
onCommitEdit: handleCommitEdit,
|
|
914
|
+
onCancelEdit: handleCancelEdit,
|
|
915
|
+
min,
|
|
916
|
+
max,
|
|
917
|
+
step,
|
|
918
|
+
stepValues,
|
|
919
|
+
formatValue,
|
|
920
|
+
label,
|
|
921
|
+
isRange,
|
|
922
|
+
isInteracting
|
|
923
|
+
});
|
|
924
|
+
const renderVisualThumb = (index) => {
|
|
925
|
+
const motionX = index === 0 ? motionX0 : motionX1;
|
|
926
|
+
return /* @__PURE__ */ jsxs3(motion3.span, {
|
|
927
|
+
className: "flex items-center justify-center pointer-events-none",
|
|
928
|
+
style: {
|
|
929
|
+
width: THUMB_SIZE,
|
|
930
|
+
height: THUMB_SIZE,
|
|
931
|
+
marginTop: -THUMB_SIZE / 2,
|
|
932
|
+
x: motionX,
|
|
933
|
+
position: "absolute",
|
|
934
|
+
top: "50%",
|
|
935
|
+
left: 0,
|
|
936
|
+
zIndex: 10
|
|
937
|
+
},
|
|
938
|
+
initial: false,
|
|
939
|
+
children: [
|
|
940
|
+
/* @__PURE__ */ jsx3(motion3.span, {
|
|
941
|
+
className: cn2("block rounded-full shadow-thumb", !thumbColor && "bg-thumb"),
|
|
942
|
+
initial: false,
|
|
943
|
+
animate: {
|
|
944
|
+
width: THUMB_SIZE_REST,
|
|
945
|
+
height: THUMB_SIZE_REST
|
|
946
|
+
},
|
|
995
947
|
transition: spring2.fast,
|
|
996
948
|
style: {
|
|
997
|
-
|
|
998
|
-
|
|
949
|
+
backgroundColor: thumbColor,
|
|
950
|
+
border: thumbBorderColor ? `1px solid ${thumbBorderColor}` : undefined
|
|
951
|
+
}
|
|
952
|
+
}),
|
|
953
|
+
/* @__PURE__ */ jsx3(motion3.span, {
|
|
954
|
+
className: "absolute rounded-full border border-focus-ring pointer-events-none",
|
|
955
|
+
initial: false,
|
|
956
|
+
animate: {
|
|
957
|
+
opacity: focusedThumb === index ? 1 : 0,
|
|
958
|
+
width: THUMB_SIZE + 4,
|
|
959
|
+
height: THUMB_SIZE + 4
|
|
999
960
|
},
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
961
|
+
transition: spring2.fast
|
|
962
|
+
})
|
|
963
|
+
]
|
|
964
|
+
}, `visual-thumb-${index}`);
|
|
965
|
+
};
|
|
966
|
+
return /* @__PURE__ */ jsxs3("div", {
|
|
967
|
+
ref,
|
|
968
|
+
className: cn2("flex flex-col gap-0 w-full select-none touch-none overflow-visible", valuePosition === "left" || valuePosition === "right" ? "flex-row items-center gap-2 mb-2" : "flex-col", disabled && "opacity-50 pointer-events-none", className),
|
|
969
|
+
...props,
|
|
970
|
+
children: [
|
|
971
|
+
(valuePosition === "top" || valuePosition === "left") && valueDisplay,
|
|
972
|
+
/* @__PURE__ */ jsxs3("div", {
|
|
973
|
+
className: "relative flex-1 overflow-visible",
|
|
974
|
+
style: {
|
|
975
|
+
height: valuePosition === "left" || valuePosition === "right" ? THUMB_SIZE + 16 : THUMB_SIZE + (valuePosition === "tooltip" ? 16 : 0),
|
|
976
|
+
paddingTop: valuePosition === "tooltip" ? 16 : 0
|
|
977
|
+
},
|
|
978
|
+
onPointerEnter: () => setIsHovered(true),
|
|
979
|
+
onPointerLeave: () => {
|
|
980
|
+
setIsHovered(false);
|
|
981
|
+
setHoverPreview(null);
|
|
982
|
+
},
|
|
983
|
+
onMouseMove: (e) => {
|
|
984
|
+
if (dragging.current)
|
|
985
|
+
return;
|
|
986
|
+
const trackEl = trackRef.current;
|
|
987
|
+
if (!trackEl)
|
|
988
|
+
return;
|
|
989
|
+
const x = layoutX(e.clientX, trackEl);
|
|
990
|
+
if (x === null)
|
|
991
|
+
return;
|
|
992
|
+
computeHoverPreview(Math.max(0, Math.min(trackEl.offsetWidth, x)), trackEl.offsetWidth);
|
|
1012
993
|
},
|
|
1013
|
-
transition: spring2.fast,
|
|
1014
|
-
onPointerDown: handlePointerDown,
|
|
1015
|
-
onPointerMove: handlePointerMove,
|
|
1016
|
-
onPointerUp: handlePointerUp,
|
|
1017
|
-
onPointerCancel: handlePointerUp,
|
|
1018
|
-
...props,
|
|
1019
994
|
children: [
|
|
1020
|
-
/* @__PURE__ */
|
|
1021
|
-
|
|
995
|
+
showValue && valuePosition === "tooltip" && /* @__PURE__ */ jsxs3(AnimatePresence2, {
|
|
996
|
+
children: [
|
|
997
|
+
isInteracting && /* @__PURE__ */ jsx3(TooltipValue, {
|
|
998
|
+
value: values[0],
|
|
999
|
+
formatValue,
|
|
1000
|
+
motionX: motionX0
|
|
1001
|
+
}, "tooltip-0"),
|
|
1002
|
+
isInteracting && isRange && values[1] !== undefined && /* @__PURE__ */ jsx3(TooltipValue, {
|
|
1003
|
+
value: values[1],
|
|
1004
|
+
formatValue,
|
|
1005
|
+
motionX: motionX1
|
|
1006
|
+
}, "tooltip-1")
|
|
1007
|
+
]
|
|
1008
|
+
}),
|
|
1009
|
+
/* @__PURE__ */ jsx3(SliderPrimitive2.Root, {
|
|
1010
|
+
value: stepValues ? values.map((v) => nearestStepIndex(v, stepValues)) : values,
|
|
1022
1011
|
onValueChange: (v) => handleRadixChange(v),
|
|
1023
|
-
|
|
1024
|
-
min,
|
|
1025
|
-
max,
|
|
1026
|
-
step,
|
|
1012
|
+
name,
|
|
1013
|
+
min: stepValues ? 0 : min,
|
|
1014
|
+
max: stepValues ? stepValues.length - 1 : max,
|
|
1015
|
+
step: stepValues ? 1 : step,
|
|
1027
1016
|
disabled,
|
|
1028
|
-
className: "absolute inset-0 opacity-0 pointer-events-none
|
|
1029
|
-
|
|
1017
|
+
className: "absolute inset-0 opacity-0 pointer-events-none",
|
|
1018
|
+
style: { height: THUMB_SIZE },
|
|
1019
|
+
children: /* @__PURE__ */ jsxs3(SliderPrimitive2.Control, {
|
|
1030
1020
|
className: "w-full h-full",
|
|
1031
1021
|
children: [
|
|
1032
|
-
/* @__PURE__ */
|
|
1022
|
+
/* @__PURE__ */ jsx3(SliderPrimitive2.Track, {
|
|
1033
1023
|
className: "w-full h-full",
|
|
1034
|
-
children: /* @__PURE__ */
|
|
1024
|
+
children: /* @__PURE__ */ jsx3(SliderPrimitive2.Indicator, {})
|
|
1035
1025
|
}),
|
|
1036
|
-
/* @__PURE__ */
|
|
1026
|
+
/* @__PURE__ */ jsx3(SliderPrimitive2.Thumb, {
|
|
1037
1027
|
index: 0,
|
|
1038
|
-
"aria-label":
|
|
1028
|
+
"aria-label": thumbAriaLabel(0),
|
|
1029
|
+
getAriaValueText: stepValues ? () => formatValue(values[0]) : undefined,
|
|
1039
1030
|
className: "block outline-none",
|
|
1031
|
+
style: { width: THUMB_SIZE, height: THUMB_SIZE },
|
|
1040
1032
|
onFocus: (e) => {
|
|
1041
|
-
if (e.
|
|
1042
|
-
|
|
1033
|
+
if (e.currentTarget.matches(":focus-visible"))
|
|
1034
|
+
setFocusedThumb(0);
|
|
1043
1035
|
},
|
|
1044
|
-
onBlur: () =>
|
|
1045
|
-
})
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
transition: { opacity: { duration: 0.15 } },
|
|
1056
|
-
style: {
|
|
1057
|
-
left: hoverPreview ? hoverPreview.left : 0,
|
|
1058
|
-
width: hoverPreview ? hoverPreview.width : 0
|
|
1059
|
-
}
|
|
1060
|
-
}),
|
|
1061
|
-
variant === "pips" && /* @__PURE__ */ jsx(motion.div, {
|
|
1062
|
-
className: "absolute inset-0 flex justify-between items-center px-3 pointer-events-none z-[1]",
|
|
1063
|
-
style: { WebkitMaskImage: pipsMaskStyle, maskImage: pipsMaskStyle },
|
|
1064
|
-
children: pipSteps.map((pipValue) => {
|
|
1065
|
-
const isActivePip = pipValue === value;
|
|
1066
|
-
return /* @__PURE__ */ jsx("div", {
|
|
1067
|
-
className: "relative flex items-center justify-center",
|
|
1068
|
-
style: { width: PIP_SIZE, height: PIP_SIZE },
|
|
1069
|
-
children: /* @__PURE__ */ jsx(motion.div, {
|
|
1070
|
-
className: "rounded-full",
|
|
1071
|
-
initial: false,
|
|
1072
|
-
animate: {
|
|
1073
|
-
backgroundColor: isActivePip ? "var(--foreground)" : "var(--muted-foreground)",
|
|
1074
|
-
opacity: isActivePip ? 1 : 0.3
|
|
1036
|
+
onBlur: () => setFocusedThumb((prev) => prev === 0 ? null : prev)
|
|
1037
|
+
}),
|
|
1038
|
+
isRange && /* @__PURE__ */ jsx3(SliderPrimitive2.Thumb, {
|
|
1039
|
+
index: 1,
|
|
1040
|
+
"aria-label": thumbAriaLabel(1),
|
|
1041
|
+
getAriaValueText: stepValues ? () => formatValue(values[1]) : undefined,
|
|
1042
|
+
className: "block outline-none",
|
|
1043
|
+
style: { width: THUMB_SIZE, height: THUMB_SIZE },
|
|
1044
|
+
onFocus: (e) => {
|
|
1045
|
+
if (e.currentTarget.matches(":focus-visible"))
|
|
1046
|
+
setFocusedThumb(1);
|
|
1075
1047
|
},
|
|
1076
|
-
|
|
1077
|
-
style: { width: PIP_SIZE, height: PIP_SIZE }
|
|
1048
|
+
onBlur: () => setFocusedThumb((prev) => prev === 1 ? null : prev)
|
|
1078
1049
|
})
|
|
1079
|
-
|
|
1050
|
+
]
|
|
1080
1051
|
})
|
|
1081
1052
|
}),
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
"
|
|
1053
|
+
/* @__PURE__ */ jsxs3("div", {
|
|
1054
|
+
ref: trackRef,
|
|
1055
|
+
className: "relative w-full cursor-ew-resize py-2",
|
|
1056
|
+
style: { height: THUMB_SIZE + 16, opacity: ready ? 1 : 0 },
|
|
1057
|
+
onPointerDown: handlePointerDown,
|
|
1058
|
+
onPointerMove: handlePointerMove,
|
|
1059
|
+
onPointerUp: handlePointerUp,
|
|
1060
|
+
onPointerCancel: handlePointerUp,
|
|
1085
1061
|
children: [
|
|
1086
|
-
|
|
1087
|
-
className: "
|
|
1088
|
-
|
|
1062
|
+
/* @__PURE__ */ jsx3("div", {
|
|
1063
|
+
className: "absolute cursor-ew-resize",
|
|
1064
|
+
style: { left: -8, right: -8, top: 0, bottom: 0 },
|
|
1065
|
+
onPointerDown: handlePointerDown,
|
|
1066
|
+
onPointerMove: handlePointerMove,
|
|
1067
|
+
onPointerUp: handlePointerUp,
|
|
1068
|
+
onPointerCancel: handlePointerUp
|
|
1089
1069
|
}),
|
|
1090
|
-
/* @__PURE__ */
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
initial: false,
|
|
1106
|
-
animate: {
|
|
1107
|
-
top: isActive ? 7 : 8,
|
|
1108
|
-
bottom: isActive ? 7 : 8,
|
|
1109
|
-
backgroundColor: isFocused ? "var(--foreground)" : isHovered ? "color-mix(in srgb, var(--foreground) 50%, transparent)" : "color-mix(in srgb, var(--foreground) 25%, transparent)"
|
|
1110
|
-
},
|
|
1111
|
-
transition: spring2.fast,
|
|
1112
|
-
style: {
|
|
1113
|
-
left: pipsHandleLineLeftStyle,
|
|
1114
|
-
width: 2
|
|
1115
|
-
}
|
|
1116
|
-
}),
|
|
1117
|
-
variant === "pips" && /* @__PURE__ */ jsxs("div", {
|
|
1118
|
-
className: "absolute inset-0 flex items-center px-2 z-[4] pointer-events-none",
|
|
1119
|
-
children: [
|
|
1120
|
-
label && /* @__PURE__ */ jsx(motion.span, {
|
|
1121
|
-
className: "text-body px-2",
|
|
1122
|
-
initial: false,
|
|
1123
|
-
animate: { color: isActive ? "var(--foreground)" : "var(--muted-foreground)" },
|
|
1124
|
-
transition: spring2.fast,
|
|
1125
|
-
children: label
|
|
1070
|
+
/* @__PURE__ */ jsx3(AnimatePresence2, {
|
|
1071
|
+
children: hoverPreview && showHoverTooltip && !isPressed && valuePosition !== "tooltip" && /* @__PURE__ */ jsx3(motion3.div, {
|
|
1072
|
+
className: "absolute -translate-x-1/2 pointer-events-none z-20",
|
|
1073
|
+
initial: { opacity: 0, y: 4 },
|
|
1074
|
+
animate: { opacity: 1, y: 0 },
|
|
1075
|
+
exit: { opacity: 0, y: 4, transition: spring2.fast.exit },
|
|
1076
|
+
transition: spring2.fast,
|
|
1077
|
+
style: {
|
|
1078
|
+
left: hoverPreview.cursorX,
|
|
1079
|
+
top: -20
|
|
1080
|
+
},
|
|
1081
|
+
children: /* @__PURE__ */ jsx3(ValueBubble, {
|
|
1082
|
+
children: formatValue(hoverPreview.snappedValue)
|
|
1083
|
+
})
|
|
1084
|
+
}, "hover-tooltip")
|
|
1126
1085
|
}),
|
|
1127
|
-
/* @__PURE__ */
|
|
1128
|
-
className: "
|
|
1086
|
+
/* @__PURE__ */ jsxs3(motion3.div, {
|
|
1087
|
+
className: cn2("absolute bg-transparent border border-border overflow-hidden rounded-full", trackClassName),
|
|
1129
1088
|
initial: false,
|
|
1130
|
-
animate: {
|
|
1089
|
+
animate: {
|
|
1090
|
+
height: TRACK_BG_HEIGHT,
|
|
1091
|
+
top: 8 + (THUMB_SIZE - TRACK_BG_HEIGHT) / 2
|
|
1092
|
+
},
|
|
1131
1093
|
transition: spring2.fast,
|
|
1132
|
-
style: {
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
children: label
|
|
1163
|
-
}),
|
|
1164
|
-
variant === "scrubber" && /* @__PURE__ */ jsxs(Fragment, {
|
|
1165
|
-
children: [
|
|
1166
|
-
/* @__PURE__ */ jsx("div", {
|
|
1167
|
-
className: "flex-1"
|
|
1094
|
+
style: {
|
|
1095
|
+
left: TRACK_INSET,
|
|
1096
|
+
right: TRACK_INSET,
|
|
1097
|
+
...trackStyle
|
|
1098
|
+
},
|
|
1099
|
+
children: [
|
|
1100
|
+
!hideFill && /* @__PURE__ */ jsx3(motion3.div, {
|
|
1101
|
+
className: cn2("absolute h-full bg-selected/50 dark:bg-accent/40", fillClassName),
|
|
1102
|
+
style: {
|
|
1103
|
+
left: fillLeft,
|
|
1104
|
+
width: fillWidth,
|
|
1105
|
+
...fillStyle
|
|
1106
|
+
}
|
|
1107
|
+
}),
|
|
1108
|
+
/* @__PURE__ */ jsx3(motion3.div, {
|
|
1109
|
+
className: "absolute h-full bg-accent/40 pointer-events-none z-[2]",
|
|
1110
|
+
initial: false,
|
|
1111
|
+
animate: {
|
|
1112
|
+
opacity: hoverPreview && !isPressed ? 1 : 0
|
|
1113
|
+
},
|
|
1114
|
+
transition: {
|
|
1115
|
+
opacity: { duration: 0.15 }
|
|
1116
|
+
},
|
|
1117
|
+
style: {
|
|
1118
|
+
left: hoverPreview ? hoverPreview.left - TRACK_INSET : 0,
|
|
1119
|
+
width: hoverPreview ? hoverPreview.width : 0,
|
|
1120
|
+
borderRadius: hoverPreview && hoverPreview.cursorX > hoverPreview.left ? "0 9999px 9999px 0" : "9999px 0 0 9999px"
|
|
1121
|
+
}
|
|
1122
|
+
})
|
|
1123
|
+
]
|
|
1168
1124
|
}),
|
|
1169
|
-
/* @__PURE__ */
|
|
1170
|
-
className: "
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1125
|
+
stepDots.length > 0 && /* @__PURE__ */ jsx3(motion3.div, {
|
|
1126
|
+
className: "absolute left-0 right-0 pointer-events-none",
|
|
1127
|
+
style: {
|
|
1128
|
+
top: 8 + (THUMB_SIZE - TRACK_BG_HEIGHT) / 2,
|
|
1129
|
+
height: TRACK_BG_HEIGHT,
|
|
1130
|
+
WebkitMaskImage: stepDotsMask,
|
|
1131
|
+
maskImage: stepDotsMask
|
|
1132
|
+
},
|
|
1133
|
+
children: stepDots.map(({ value: v, percent }) => /* @__PURE__ */ jsx3("div", {
|
|
1134
|
+
className: "absolute pointer-events-none flex items-center justify-center",
|
|
1135
|
+
style: {
|
|
1136
|
+
left: `calc(${THUMB_SIZE / 2}px + ${percent} * (100% - ${THUMB_SIZE}px))`,
|
|
1137
|
+
top: "50%",
|
|
1138
|
+
width: 0,
|
|
1139
|
+
height: 0
|
|
1140
|
+
},
|
|
1141
|
+
children: /* @__PURE__ */ jsx3(motion3.div, {
|
|
1142
|
+
className: "rounded-full flex-shrink-0 bg-muted-foreground opacity-30",
|
|
1143
|
+
initial: false,
|
|
1144
|
+
animate: {
|
|
1145
|
+
width: isHovered ? DOT_SIZE * 1.25 : DOT_SIZE,
|
|
1146
|
+
height: isHovered ? DOT_SIZE * 1.25 : DOT_SIZE
|
|
1147
|
+
},
|
|
1148
|
+
transition: spring2.moderate
|
|
1149
|
+
})
|
|
1150
|
+
}, v))
|
|
1151
|
+
}),
|
|
1152
|
+
renderVisualThumb(0),
|
|
1153
|
+
isRange && renderVisualThumb(1)
|
|
1177
1154
|
]
|
|
1178
|
-
}),
|
|
1179
|
-
variant === "scrubber" && /* @__PURE__ */ jsx(motion.div, {
|
|
1180
|
-
className: "absolute top-0 bottom-0 w-2 cursor-ew-resize z-20",
|
|
1181
|
-
style: { left: handleLeftStyle },
|
|
1182
|
-
onPointerDown: handleResizePointerDown,
|
|
1183
|
-
onPointerMove: handleResizePointerMove,
|
|
1184
|
-
onPointerUp: handleResizePointerUp,
|
|
1185
|
-
onPointerCancel: handleResizePointerUp
|
|
1186
1155
|
})
|
|
1187
1156
|
]
|
|
1188
|
-
})
|
|
1157
|
+
}),
|
|
1158
|
+
(valuePosition === "bottom" || valuePosition === "right") && valueDisplay
|
|
1189
1159
|
]
|
|
1190
1160
|
});
|
|
1191
1161
|
});
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1162
|
+
CompactSlider.displayName = "CompactSlider";
|
|
1163
|
+
|
|
1164
|
+
// components/inputs/slider/index.tsx
|
|
1165
|
+
import { jsx as jsx4 } from "react/jsx-runtime";
|
|
1166
|
+
/*!
|
|
1167
|
+
* Ported from Fluid Functionalism — github.com/mickadesign/fluid-functionalism
|
|
1168
|
+
* `registry/base/slider.tsx` @ b3587bdbd83fc66c2a6aae3817ffb856cb09260b
|
|
1169
|
+
* MIT License © 2026 Micka Touillaud — fluidfunctionalism.com (notice: LICENSE.fluid-functionalism)
|
|
1170
|
+
* Local changes: see PORTING.md.
|
|
1171
|
+
*/
|
|
1172
|
+
var COMPACT_ONLY = [
|
|
1173
|
+
"steps",
|
|
1174
|
+
"showSteps",
|
|
1175
|
+
"showValue",
|
|
1176
|
+
"valuePosition",
|
|
1177
|
+
"trackClassName",
|
|
1178
|
+
"trackStyle",
|
|
1179
|
+
"fillClassName",
|
|
1180
|
+
"fillStyle",
|
|
1181
|
+
"hideFill",
|
|
1182
|
+
"thumbColor",
|
|
1183
|
+
"thumbBorderColor"
|
|
1184
|
+
];
|
|
1185
|
+
var Slider2 = forwardRef3(({ size, variant = "pips", value: valueProp, defaultValue, onValueChange, ...rest }, ref) => {
|
|
1186
|
+
const [value, setValue] = useControllableState2(valueProp, defaultValue ?? (rest.steps && rest.steps.length > 0 ? Math.min(...rest.steps) : rest.min ?? 0), onValueChange);
|
|
1196
1187
|
const resolved = useSizeVariant2(size);
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
return /* @__PURE__ */ jsx(CompactSlider, {
|
|
1188
|
+
if (resolved === "compact" || Array.isArray(value) || COMPACT_ONLY.some((key) => rest[key] !== undefined)) {
|
|
1189
|
+
return /* @__PURE__ */ jsx4(CompactSlider, {
|
|
1200
1190
|
ref,
|
|
1201
|
-
...
|
|
1191
|
+
...rest,
|
|
1192
|
+
value,
|
|
1193
|
+
onValueChange: setValue
|
|
1202
1194
|
});
|
|
1203
1195
|
}
|
|
1204
1196
|
const {
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
trackStyle: _trackStyle,
|
|
1220
|
-
fillClassName: _fillClassName,
|
|
1221
|
-
fillStyle: _fillStyle,
|
|
1222
|
-
hideFill: _hideFill,
|
|
1223
|
-
thumbColor: _thumbColor,
|
|
1224
|
-
thumbBorderColor: _thumbBorderColor,
|
|
1225
|
-
orientation: _orientation,
|
|
1226
|
-
...html
|
|
1227
|
-
} = props;
|
|
1228
|
-
return /* @__PURE__ */ jsx(ComfortableSlider, {
|
|
1197
|
+
steps,
|
|
1198
|
+
showSteps,
|
|
1199
|
+
showValue,
|
|
1200
|
+
valuePosition,
|
|
1201
|
+
trackClassName,
|
|
1202
|
+
trackStyle,
|
|
1203
|
+
fillClassName,
|
|
1204
|
+
fillStyle,
|
|
1205
|
+
hideFill,
|
|
1206
|
+
thumbColor,
|
|
1207
|
+
thumbBorderColor,
|
|
1208
|
+
...comfortable
|
|
1209
|
+
} = rest;
|
|
1210
|
+
return /* @__PURE__ */ jsx4(ComfortableSlider, {
|
|
1229
1211
|
ref,
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
step,
|
|
1235
|
-
variant,
|
|
1236
|
-
label,
|
|
1237
|
-
formatValue,
|
|
1238
|
-
disabled,
|
|
1239
|
-
onValueCommit,
|
|
1240
|
-
...html
|
|
1212
|
+
...comfortable,
|
|
1213
|
+
value,
|
|
1214
|
+
onValueChange: setValue,
|
|
1215
|
+
variant
|
|
1241
1216
|
});
|
|
1242
1217
|
});
|
|
1243
1218
|
Slider2.displayName = "Slider";
|
|
1244
|
-
var SliderComfortable2 = ComfortableSlider;
|
|
1245
1219
|
var slider_default = Slider2;
|
|
1246
1220
|
|
|
1247
|
-
export { Slider2,
|
|
1221
|
+
export { Slider2, slider_default };
|