@justanarthur/modo-ui 0.5.0 → 0.6.0-canary.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/DESIGN.md +608 -0
- package/README.md +61 -39
- package/blocks/sidebar-app/examples.mdx +33 -0
- package/blocks/sidebar-app/index.tsx +218 -0
- package/blocks/sidebar-app/inset-topbar.tsx +25 -0
- package/blocks/sidebar-app/menu-grid.ts +26 -0
- package/blocks/sidebar-app/nav-data.ts +36 -0
- package/blocks/sidebar-app/search-field.tsx +48 -0
- package/blocks/sidebar-app/user-footer.tsx +67 -0
- package/blocks/sidebar-app/workspace-header.tsx +129 -0
- package/components/AI/input-message/examples.mdx +124 -0
- package/components/AI/input-message/file-thumbnail.tsx +173 -0
- package/components/AI/input-message/index.tsx +1383 -0
- package/components/AI/thinking-indicator/examples.mdx +27 -0
- package/components/AI/thinking-indicator/index.tsx +210 -0
- package/components/accordion/examples.mdx +148 -0
- package/components/accordion/index.tsx +1034 -0
- package/components/avatar/examples.mdx +95 -0
- package/components/avatar/index.tsx +129 -0
- package/components/badge/change-demo.tsx +29 -0
- package/components/badge/examples.mdx +120 -0
- package/components/badge/index.tsx +225 -0
- package/components/badge/variants.ts +73 -0
- package/components/button/examples.mdx +164 -0
- package/components/button/index.tsx +416 -0
- package/components/button/loading-demo.tsx +25 -0
- package/components/button/variants.ts +166 -0
- package/components/card/examples.mdx +212 -0
- package/components/card/index.tsx +1037 -0
- package/components/copy/examples.mdx +87 -0
- package/components/copy/index.tsx +482 -0
- package/components/inputs/checkbox/examples.mdx +83 -0
- package/components/inputs/checkbox/index.tsx +611 -0
- package/components/inputs/checkbox/select-all-demo.tsx +48 -0
- package/components/inputs/color-picker/examples.mdx +72 -0
- package/components/inputs/color-picker/index.tsx +1955 -0
- package/components/inputs/color-picker/variants.ts +401 -0
- package/components/inputs/combobox/examples.mdx +273 -0
- package/components/inputs/combobox/index.tsx +1436 -0
- package/components/inputs/combobox/remote-demo.tsx +101 -0
- package/components/inputs/date-time/calendar/examples.mdx +34 -0
- package/components/inputs/date-time/calendar/index.tsx +351 -0
- package/components/inputs/date-time/calendar/use-month-window.ts +163 -0
- package/components/inputs/date-time/date-picker/examples.mdx +166 -0
- package/components/inputs/date-time/date-picker/index.tsx +385 -0
- package/components/inputs/date-time/date-picker/masked-date-input.tsx +336 -0
- package/components/inputs/date-time/date-range-picker/examples.mdx +29 -0
- package/components/inputs/date-time/date-range-picker/index.tsx +217 -0
- package/components/inputs/date-time/duration-picker/examples.mdx +16 -0
- package/components/inputs/date-time/duration-picker/index.tsx +189 -0
- package/components/inputs/date-time/month-picker/examples.mdx +16 -0
- package/components/inputs/date-time/month-picker/index.tsx +190 -0
- package/components/inputs/date-time/picker-shell.tsx +395 -0
- package/components/inputs/date-time/time-columns.tsx +91 -0
- package/components/inputs/date-time/time-picker/examples.mdx +26 -0
- package/components/inputs/date-time/time-picker/index.tsx +166 -0
- package/components/inputs/field/examples.mdx +113 -0
- package/components/inputs/field/index.tsx +267 -0
- package/components/inputs/file-dropzone/examples.mdx +73 -0
- package/components/inputs/file-dropzone/file-row.tsx +201 -0
- package/components/inputs/file-dropzone/index.tsx +296 -0
- package/components/inputs/file-dropzone/upload-demo.tsx +67 -0
- package/components/inputs/file-dropzone/variants.ts +94 -0
- package/components/inputs/input/examples.mdx +135 -0
- package/components/inputs/input/index.tsx +494 -0
- package/components/inputs/input/password-demo.tsx +30 -0
- package/components/inputs/label/examples.mdx +67 -0
- package/components/inputs/label/index.tsx +85 -0
- package/components/inputs/number-input/examples.mdx +56 -0
- package/components/inputs/number-input/index.tsx +214 -0
- package/components/inputs/radio/examples.mdx +77 -0
- package/components/inputs/radio/index.tsx +636 -0
- package/components/inputs/search/examples.mdx +74 -0
- package/components/inputs/search/index.tsx +333 -0
- package/components/inputs/select/examples.mdx +218 -0
- package/components/inputs/select/index.tsx +862 -0
- package/components/inputs/select/variants.ts +32 -0
- package/components/inputs/slider/examples.mdx +127 -0
- package/components/inputs/slider/index.tsx +1725 -0
- package/components/inputs/switch/examples.mdx +94 -0
- package/components/inputs/switch/index.tsx +504 -0
- package/components/inputs/textarea/examples.mdx +88 -0
- package/components/inputs/textarea/index.tsx +161 -0
- package/components/navigation/navigation-menu/examples.mdx +109 -0
- package/components/navigation/navigation-menu/index.tsx +613 -0
- package/components/navigation/pagination/examples.mdx +64 -0
- package/components/navigation/pagination/index.tsx +395 -0
- package/components/navigation/sidebar/examples.mdx +319 -0
- package/components/navigation/sidebar/index.tsx +453 -0
- package/components/navigation/sidebar/sidebar-core.tsx +1408 -0
- package/components/navigation/sidebar/sidebar-menu.tsx +1495 -0
- package/components/navigation/sidebar/sidebar.css +74 -0
- package/components/navigation/sidebar/variants.ts +55 -0
- package/components/navigation/tabs/examples.mdx +89 -0
- package/components/navigation/tabs/index.tsx +494 -0
- package/components/navigation/tabs-subtle/examples.mdx +49 -0
- package/components/navigation/tabs-subtle/index.tsx +512 -0
- package/components/overlays/alert-dialog/examples.mdx +123 -0
- package/components/overlays/alert-dialog/index.tsx +258 -0
- package/components/overlays/alert-dialog/pending-demo.tsx +36 -0
- package/components/overlays/command/examples.mdx +113 -0
- package/components/overlays/command/index.tsx +416 -0
- package/components/overlays/context-menu/examples.mdx +56 -0
- package/components/overlays/context-menu/index.tsx +279 -0
- package/components/overlays/dialog/examples.mdx +144 -0
- package/components/overlays/dialog/index.tsx +366 -0
- package/components/overlays/dropdown/dropdown-search.tsx +395 -0
- package/components/overlays/dropdown/examples.mdx +294 -0
- package/components/overlays/dropdown/index.tsx +1168 -0
- package/components/overlays/dropdown/menu-item.tsx +464 -0
- package/components/overlays/dropdown/menu-parts.tsx +660 -0
- package/components/overlays/popover/anchored-demo.tsx +59 -0
- package/components/overlays/popover/examples.mdx +180 -0
- package/components/overlays/popover/index.tsx +315 -0
- package/components/overlays/preview-card/examples.mdx +61 -0
- package/components/overlays/preview-card/index.tsx +204 -0
- package/components/overlays/sheet/examples.mdx +89 -0
- package/components/overlays/sheet/index.tsx +247 -0
- package/components/overlays/toast/examples.mdx +68 -0
- package/components/overlays/toast/global-demo.tsx +72 -0
- package/components/overlays/toast/index.tsx +474 -0
- package/components/overlays/toast/manager.ts +193 -0
- package/components/overlays/tooltip/examples.mdx +106 -0
- package/components/overlays/tooltip/index.tsx +519 -0
- package/components/progress/examples.mdx +59 -0
- package/components/progress/index.tsx +174 -0
- package/components/progress/progress.css +49 -0
- package/components/progress/step-demo.tsx +27 -0
- package/components/table/examples.mdx +184 -0
- package/components/table/index.tsx +510 -0
- package/components/table/sort-demo.tsx +61 -0
- package/dist/base.css +100 -0
- package/dist/blocks/sidebar-app/index.js +39 -26
- package/dist/components/AI/input-message/index.js +22 -16
- package/dist/components/AI/thinking-indicator/index.js +9 -6
- package/dist/components/accordion/index.js +16 -13
- package/dist/components/avatar/index.d.ts +46 -0
- package/dist/components/avatar/index.js +18 -0
- package/dist/components/badge/index.d.ts +18 -11
- package/dist/components/badge/index.js +11 -7
- package/dist/components/badge/variants.d.ts +33 -0
- package/dist/components/badge/variants.js +10 -0
- package/dist/components/button/index.d.ts +53 -17
- package/dist/components/button/index.js +10 -6
- package/dist/components/button/variants.d.ts +39 -0
- package/dist/components/button/variants.js +8 -0
- package/dist/components/card/index.d.ts +16 -3
- package/dist/components/card/index.js +16 -11
- package/dist/components/copy/index.js +13 -9
- package/dist/components/inputs/checkbox/index.d.ts +28 -9
- package/dist/components/inputs/checkbox/index.js +17 -13
- package/dist/components/inputs/color-picker/index.d.ts +13 -13
- package/dist/components/inputs/color-picker/index.js +25 -18
- package/dist/components/inputs/color-picker/variants.d.ts +61 -0
- package/dist/components/inputs/color-picker/variants.js +28 -0
- package/dist/components/inputs/combobox/index.d.ts +60 -17
- package/dist/components/inputs/combobox/index.js +26 -18
- package/dist/components/inputs/date-time/calendar/index.js +14 -11
- package/dist/components/inputs/date-time/date-picker/index.d.ts +53 -11
- package/dist/components/inputs/date-time/date-picker/index.js +33 -25
- package/dist/components/inputs/date-time/date-range-picker/index.d.ts +3 -3
- package/dist/components/inputs/date-time/date-range-picker/index.js +32 -24
- package/dist/components/inputs/date-time/duration-picker/index.d.ts +3 -3
- package/dist/components/inputs/date-time/duration-picker/index.js +32 -24
- package/dist/components/inputs/date-time/month-picker/index.d.ts +3 -3
- package/dist/components/inputs/date-time/month-picker/index.js +31 -23
- package/dist/components/inputs/date-time/time-picker/index.d.ts +3 -3
- package/dist/components/inputs/date-time/time-picker/index.js +32 -24
- package/dist/components/inputs/field/index.d.ts +116 -0
- package/dist/components/inputs/field/index.js +28 -0
- package/dist/components/inputs/file-dropzone/index.d.ts +165 -0
- package/dist/components/inputs/file-dropzone/index.js +32 -0
- package/dist/components/inputs/file-dropzone/variants.d.ts +35 -0
- package/dist/components/inputs/file-dropzone/variants.js +12 -0
- package/dist/components/inputs/input/index.d.ts +95 -13
- package/dist/components/inputs/input/index.js +17 -9
- package/dist/components/inputs/label/index.d.ts +32 -0
- package/dist/components/inputs/label/index.js +11 -0
- package/dist/components/inputs/number-input/index.d.ts +84 -0
- package/dist/components/inputs/number-input/index.js +20 -0
- package/dist/components/inputs/radio/index.d.ts +20 -5
- package/dist/components/inputs/radio/index.js +15 -12
- package/dist/components/inputs/search/index.js +25 -18
- package/dist/components/inputs/select/index.d.ts +41 -11
- package/dist/components/inputs/select/index.js +27 -14
- package/dist/components/inputs/select/variants.d.ts +5 -0
- package/dist/components/inputs/select/variants.js +6 -0
- package/dist/components/inputs/slider/index.js +7 -5
- package/dist/components/inputs/switch/index.d.ts +8 -2
- package/dist/components/inputs/switch/index.js +14 -12
- package/dist/components/inputs/textarea/index.d.ts +4 -0
- package/dist/components/inputs/textarea/index.js +8 -6
- package/dist/components/navigation/navigation-menu/index.d.ts +114 -0
- package/dist/components/navigation/navigation-menu/index.js +40 -0
- package/dist/components/navigation/pagination/index.d.ts +73 -0
- package/dist/components/navigation/pagination/index.js +39 -0
- package/dist/components/navigation/sidebar/index.d.ts +44 -21
- package/dist/components/navigation/sidebar/index.js +41 -31
- package/dist/components/navigation/sidebar/variants.d.ts +25 -0
- package/dist/components/navigation/sidebar/variants.js +28 -0
- package/dist/components/navigation/tabs/index.d.ts +8 -2
- package/dist/components/navigation/tabs/index.js +14 -10
- package/dist/components/navigation/tabs-subtle/index.js +12 -10
- package/dist/components/overlays/alert-dialog/index.d.ts +121 -15
- package/dist/components/overlays/alert-dialog/index.js +22 -13
- package/dist/components/overlays/command/index.js +24 -17
- package/dist/components/overlays/context-menu/index.d.ts +33 -17
- package/dist/components/overlays/context-menu/index.js +27 -18
- package/dist/components/overlays/dialog/index.js +17 -12
- package/dist/components/overlays/dropdown/index.d.ts +257 -31
- package/dist/components/overlays/dropdown/index.js +42 -17
- package/dist/components/overlays/popover/index.d.ts +31 -9
- package/dist/components/overlays/popover/index.js +12 -9
- package/dist/components/overlays/preview-card/index.js +11 -8
- package/dist/components/overlays/sheet/index.js +18 -13
- package/dist/components/overlays/toast/index.d.ts +123 -47
- package/dist/components/overlays/toast/index.js +18 -10
- package/dist/components/overlays/tooltip/index.d.ts +113 -21
- package/dist/components/overlays/tooltip/index.js +15 -6
- package/dist/components/progress/index.d.ts +56 -0
- package/dist/components/progress/index.js +15 -0
- package/dist/components/table/index.d.ts +63 -8
- package/dist/components/table/index.js +19 -9
- package/dist/index.d.ts +2201 -736
- package/dist/index.js +223 -82
- package/dist/lib/date-locale.d.ts +14 -0
- package/dist/lib/date-locale.js +16 -0
- package/dist/lib/field-classes.d.ts +144 -0
- package/dist/lib/field-classes.js +40 -0
- package/dist/lib/field-variants.d.ts +47 -0
- package/dist/lib/field-variants.js +26 -0
- package/dist/lib/fluid-hover-highlight.d.ts +112 -0
- package/dist/lib/fluid-hover-highlight.js +17 -0
- package/dist/lib/focus-ring.d.ts +18 -0
- package/dist/lib/focus-ring.js +10 -0
- package/dist/lib/goo-indicator.d.ts +46 -0
- package/dist/lib/goo-indicator.js +14 -0
- package/dist/lib/icon-context.d.ts +30 -0
- package/dist/lib/icon-context.js +12 -0
- package/dist/lib/inert.d.ts +9 -0
- package/dist/lib/inert.js +8 -0
- package/dist/lib/morph-layers.d.ts +93 -0
- package/dist/lib/morph-layers.js +13 -0
- package/dist/lib/morph-part.d.ts +21 -0
- package/dist/lib/morph-part.js +12 -0
- package/dist/lib/popup.d.ts +20 -0
- package/dist/lib/popup.js +12 -0
- package/dist/lib/reduced-motion.d.ts +9 -0
- package/dist/lib/reduced-motion.js +6 -0
- package/dist/lib/row-index.d.ts +10 -0
- package/dist/lib/row-index.js +8 -0
- package/dist/lib/row-order.d.ts +28 -0
- package/dist/lib/row-order.js +10 -0
- package/dist/lib/scroll-column.d.ts +27 -0
- package/dist/lib/scroll-column.js +18 -0
- package/dist/lib/shape-context.d.ts +30 -0
- package/dist/lib/shape-context.js +12 -0
- package/dist/lib/size-context.d.ts +94 -0
- package/dist/lib/size-context.js +20 -0
- package/dist/lib/size-scale.d.ts +79 -0
- package/dist/lib/size-scale.js +8 -0
- package/dist/lib/slot.d.ts +12 -0
- package/dist/lib/slot.js +6 -0
- package/dist/lib/springs.d.ts +44 -0
- package/dist/lib/springs.js +8 -0
- package/dist/lib/surface-classes.d.ts +19 -0
- package/dist/lib/surface-classes.js +10 -0
- package/dist/lib/surface-context.d.ts +9 -0
- package/dist/lib/surface-context.js +8 -0
- package/dist/lib/use-controllable-state.d.ts +2 -0
- package/dist/lib/use-controllable-state.js +6 -0
- package/dist/lib/use-fluid-hover.d.ts +138 -0
- package/dist/lib/use-fluid-hover.js +14 -0
- package/dist/lib/use-is-mobile.d.ts +2 -0
- package/dist/lib/use-is-mobile.js +6 -0
- package/dist/lib/use-keyboard-nav-gate.d.ts +20 -0
- package/dist/lib/use-keyboard-nav-gate.js +7 -0
- package/dist/lib/use-merge-split.d.ts +47 -0
- package/dist/lib/use-merge-split.js +15 -0
- package/dist/lib/use-morph.d.ts +101 -0
- package/dist/lib/use-morph.js +20 -0
- package/dist/lib/use-touch-primary.d.ts +2 -0
- package/dist/lib/use-touch-primary.js +6 -0
- package/dist/lib/utils.d.ts +3 -0
- package/dist/lib/utils.js +6 -0
- package/dist/preset.d.ts +17 -0
- package/dist/preset.js +22 -2
- package/dist/primitives/code/index.js +7 -5
- package/dist/primitives/craft/index.js +9 -6
- package/dist/primitives/fluid-hover/index.js +9 -8
- package/dist/primitives/morph/index.js +15 -10
- package/dist/primitives/motion/index.js +10 -8
- package/dist/primitives/scroll-area/index.js +4 -3
- package/dist/primitives/separator/index.d.ts +25 -0
- package/dist/primitives/separator/index.js +9 -0
- package/dist/primitives/sizes/index.js +6 -4
- package/dist/primitives/skeleton/index.d.ts +35 -0
- package/dist/primitives/skeleton/index.js +12 -0
- package/dist/primitives/surface/index.js +6 -4
- package/dist/shared/{components-3mkepka5.js → components-0jmqhx2k.js} +28 -25
- package/dist/shared/components-124epb7f.js +53 -0
- package/dist/shared/{components-gz8zf3ec.js → components-1k0wv53d.js} +15 -43
- package/dist/shared/components-26snnbs9.js +322 -0
- package/dist/shared/{components-2dxkv6zm.js → components-2c0qcfx4.js} +8 -7
- package/dist/shared/{components-473g814w.js → components-2mt9te6d.js} +243 -137
- package/dist/shared/{components-hawvy2qz.js → components-2z48g4fp.js} +9 -30
- package/dist/shared/components-34txk9rj.js +35 -0
- package/dist/shared/components-3h92d94m.js +23 -0
- package/dist/shared/{components-zfnmn5d4.js → components-3sp623ae.js} +36 -31
- package/dist/shared/{components-jwst3vtj.js → components-3wxkjgqn.js} +186 -76
- package/dist/shared/{components-s2bz1xpk.js → components-49bsynbw.js} +8 -5
- package/dist/shared/components-4bwsd46w.js +71 -0
- package/dist/shared/components-4n4f5m3e.js +297 -0
- package/dist/shared/{components-0q0sqfh4.js → components-4y816hwp.js} +27 -49
- package/dist/shared/components-52ngsgca.js +399 -0
- package/dist/shared/{components-y9y0g8er.js → components-52r5763g.js} +22 -19
- package/dist/shared/components-559tf7yb.js +28 -0
- package/dist/shared/components-5mkga9hj.js +440 -0
- package/dist/shared/{components-kwa6mrf9.js → components-5s0nfqvw.js} +14 -9
- package/dist/shared/{components-dk0gjr5a.js → components-60atskhp.js} +19 -18
- package/dist/shared/{components-rr7a6ja9.js → components-658b26nb.js} +21 -18
- package/dist/shared/{components-xxvdw7k1.js → components-65vwfjs6.js} +37 -34
- package/dist/shared/{components-frw34b65.js → components-6j2fh74k.js} +114 -123
- package/dist/shared/components-6zg1yft7.js +167 -0
- package/dist/shared/components-6zng858q.js +53 -0
- package/dist/shared/components-72w4ge68.js +64 -0
- package/dist/shared/{components-cv16mryv.js → components-78x40gee.js} +13 -7
- package/dist/shared/{components-b2wyq2cq.js → components-7d4r7hh1.js} +39 -57
- package/dist/shared/components-7ntvvegr.js +316 -0
- package/dist/shared/components-8nwsqjn8.js +34 -0
- package/dist/shared/{components-5xc2j8jz.js → components-8tt3xbb5.js} +19 -18
- package/dist/shared/{components-vc7vq5nz.js → components-9as3rf68.js} +6 -3
- package/dist/shared/components-9mys9jna.js +255 -0
- package/dist/shared/components-adkarj8n.js +35 -0
- package/dist/shared/{components-b3c5et5b.js → components-ae9fncz4.js} +32 -31
- package/dist/shared/{components-hqeq3w9q.js → components-awra5sff.js} +24 -16
- package/dist/shared/components-b1e239g3.js +28 -0
- package/dist/shared/{components-q5xj5c16.js → components-b1f2bjf1.js} +9 -8
- package/dist/shared/{components-qmmjx1qw.js → components-bn42vq6d.js} +71 -72
- package/dist/shared/components-c96g82th.js +1444 -0
- package/dist/shared/components-c9yr4ed1.js +44 -0
- package/dist/shared/components-d3shbwqq.js +95 -0
- package/dist/shared/{components-jjw69c4c.js → components-dcc02hs2.js} +7 -4
- package/dist/shared/{components-men63rwj.js → components-de99ykt7.js} +3 -2
- package/dist/shared/components-dhgk6mbt.js +16 -0
- package/dist/shared/components-drxrtnp2.js +25 -0
- package/dist/shared/{components-6p8tfcd6.js → components-ds9fqat9.js} +21 -18
- package/dist/shared/{components-mjthm1kf.js → components-egy4tyjt.js} +11 -8
- package/dist/shared/components-f0xfpkhh.js +82 -0
- package/dist/shared/components-f7h57m6t.js +59 -0
- package/dist/shared/{components-d6xtjht3.js → components-fjkpbg6n.js} +33 -30
- package/dist/shared/{components-gc5vtq2f.js → components-gh0qeey3.js} +63 -29
- package/dist/shared/{components-39jq9va1.js → components-gvbapfen.js} +29 -24
- package/dist/shared/{components-5vgpnxgy.js → components-gzesg7hy.js} +19 -16
- package/dist/shared/components-h6p86be3.js +19 -0
- package/dist/shared/components-h83az0bz.js +33 -0
- package/dist/shared/components-jjrj6ymn.js +104 -0
- package/dist/shared/{components-wvp1m52g.js → components-jp5v0m0f.js} +15 -14
- package/dist/shared/{components-zrkzcayz.js → components-jqpefjsn.js} +54 -6
- package/dist/shared/{components-1z6tdadk.js → components-k74j4hwh.js} +20 -17
- package/dist/shared/components-kswxnm3h.js +24 -0
- package/dist/shared/{components-jbbmdr74.js → components-mkkbbgb7.js} +36 -17
- package/dist/shared/{components-pbmqctfa.js → components-mpw667rb.js} +169 -65
- package/dist/shared/{components-s5ngg32c.js → components-paa08427.js} +121 -47
- package/dist/shared/{components-vfbhxf5r.js → components-pd42emw3.js} +6 -5
- package/dist/shared/{components-hw9yk32z.js → components-pmfszv7a.js} +35 -23
- package/dist/shared/{components-chacnk61.js → components-pw06rbxq.js} +19 -19
- package/dist/shared/components-q03cktx8.js +246 -0
- package/dist/shared/{components-kvr7f9hy.js → components-qdm3yh26.js} +19 -10
- package/dist/shared/{components-27nnvrwe.js → components-qs4rkqsj.js} +15 -14
- package/dist/shared/{components-s083f38z.js → components-r6gbmkew.js} +22 -21
- package/dist/shared/{components-ta7shw28.js → components-r8eqs7gz.js} +4 -4
- package/dist/shared/{components-sn1rxx1d.js → components-rm02h9nt.js} +12 -11
- package/dist/shared/{components-c6s6b43g.js → components-rrbpmfx4.js} +3 -2
- package/dist/shared/{components-n7mjr357.js → components-tz1fv35x.js} +3 -2
- package/dist/shared/components-tz4gaf1v.js +23 -0
- package/dist/shared/{components-zx6b6yby.js → components-vf45j12c.js} +4 -18
- package/dist/shared/{components-3ky44908.js → components-vfjc9jzz.js} +2 -3
- package/dist/shared/{components-39vmfq9s.js → components-vsa625vk.js} +21 -20
- package/dist/shared/components-wawnmkph.js +500 -0
- package/dist/shared/components-wktrrb4m.js +38 -0
- package/dist/shared/{components-8snj490h.js → components-wwd363me.js} +78 -32
- package/dist/shared/{components-5pnw8183.js → components-xcwvgcrd.js} +23 -22
- package/dist/shared/components-xdqmt6ed.js +20 -0
- package/dist/shared/{components-h2ajmhwn.js → components-y1w3a6wx.js} +107 -35
- package/dist/shared/{components-ar66gnt0.js → components-y6578b8h.js} +37 -34
- package/dist/shared/{components-59efxjd9.js → components-yhgq0qxx.js} +13 -12
- package/dist/shared/{components-jthe1pwb.js → components-yz84gpkq.js} +101 -404
- package/dist/shared/components-z3v0n0de.js +11 -0
- package/dist/shared/{components-7r3etddy.js → components-z9n19fyk.js} +19 -54
- package/dist/shared/components-zbvjzh1p.js +141 -0
- package/dist/styles.css +241 -16
- package/dist/tailwind.css +13 -0
- package/dist/tokens.css +34 -0
- package/index.ts +60 -0
- package/lib/date-locale.ts +50 -0
- package/lib/field-classes.ts +115 -0
- package/lib/field-variants.ts +117 -0
- package/lib/fluid-hover-highlight.tsx +139 -0
- package/lib/focus-ring.tsx +46 -0
- package/lib/goo-indicator.tsx +261 -0
- package/lib/icon-context.tsx +310 -0
- package/lib/inert.ts +22 -0
- package/lib/morph-layers.tsx +102 -0
- package/lib/morph-part.tsx +49 -0
- package/lib/popup.ts +52 -0
- package/lib/reduced-motion.ts +19 -0
- package/lib/row-index.tsx +29 -0
- package/lib/row-order.tsx +115 -0
- package/lib/scroll-column.tsx +244 -0
- package/lib/shape-context.tsx +124 -0
- package/lib/size-context.tsx +66 -0
- package/lib/size-scale.ts +115 -0
- package/lib/slot.ts +25 -0
- package/lib/springs.ts +62 -0
- package/lib/surface-classes.ts +58 -0
- package/lib/surface-context.tsx +21 -0
- package/lib/use-controllable-state.ts +44 -0
- package/lib/use-fluid-hover.ts +541 -0
- package/lib/use-is-mobile.ts +25 -0
- package/lib/use-keyboard-nav-gate.ts +45 -0
- package/lib/use-merge-split.tsx +209 -0
- package/lib/use-morph.ts +557 -0
- package/lib/use-touch-primary.tsx +43 -0
- package/lib/utils.ts +37 -0
- package/package.json +177 -4
- package/preset.ts +196 -0
- package/primitives/code/examples.mdx +27 -0
- package/primitives/code/index.tsx +80 -0
- package/primitives/craft/demos.tsx +173 -0
- package/primitives/craft/examples.mdx +138 -0
- package/primitives/craft/index.tsx +76 -0
- package/primitives/fluid-hover/examples.mdx +84 -0
- package/primitives/fluid-hover/index.tsx +316 -0
- package/primitives/morph/examples.mdx +135 -0
- package/primitives/morph/index.tsx +192 -0
- package/primitives/motion/examples.mdx +100 -0
- package/primitives/motion/index.tsx +160 -0
- package/primitives/scroll-area/examples.mdx +58 -0
- package/primitives/scroll-area/index.tsx +200 -0
- package/primitives/separator/examples.mdx +30 -0
- package/primitives/separator/index.tsx +53 -0
- package/primitives/sizes/examples.mdx +167 -0
- package/primitives/sizes/index.tsx +89 -0
- package/primitives/skeleton/examples.mdx +51 -0
- package/primitives/skeleton/index.tsx +72 -0
- package/primitives/skeleton/skeleton.css +15 -0
- package/primitives/surface/examples.mdx +173 -0
- package/primitives/surface/index.tsx +109 -0
- package/primitives/surface/surface.css +176 -0
- package/dist/shared/components-0sn7ypjw.js +0 -61
- package/dist/shared/components-1434p1mh.js +0 -123
- package/dist/shared/components-a86dytt0.js +0 -986
- package/dist/shared/components-gf5s6ap9.js +0 -42
- package/dist/shared/components-hyq23phv.js +0 -310
- package/dist/shared/components-ng72k97e.js +0 -128
- package/dist/shared/components-raknhppb.js +0 -64
- package/dist/shared/components-vynjtrk6.js +0 -19
- package/dist/shared/components-wy9jpqny.js +0 -146
- /package/dist/shared/{components-1v7rxytx.js → components-3ey0hzpb.js} +0 -0
- /package/dist/shared/{components-ezxhrmer.js → components-jcnjay5g.js} +0 -0
|
@@ -0,0 +1,611 @@
|
|
|
1
|
+
// biome-ignore-all lint: vendored upstream code keeps its own patterns (see the header)
|
|
2
|
+
/*
|
|
3
|
+
* Ported from Fluid Functionalism — github.com/mickadesign/fluid-functionalism
|
|
4
|
+
* `registry/base/checkbox-group.tsx` @ b3587bdbd83fc66c2a6aae3817ffb856cb09260b
|
|
5
|
+
* MIT License © 2026 Micka Touillaud — fluidfunctionalism.com (notice: LICENSE.fluid-functionalism)
|
|
6
|
+
* Local modifications: `"use client"` dropped; `@/lib/*` and `@/hooks/*` imports
|
|
7
|
+
* rewritten to `../../../lib/*` (`SizeProvider` to `../../../primitives/sizes`),
|
|
8
|
+
* `@/components/ui/fluid-hover-highlight` to `../../../lib/fluid-hover-highlight`,
|
|
9
|
+
* `framer-motion` to `motion/react`;
|
|
10
|
+
* uncontrolled mode added — `checkedIndices` is optional, with
|
|
11
|
+
* `defaultCheckedIndices` (Set or array) and a group-level
|
|
12
|
+
* `onCheckedIndicesChange` backed by `useControllableState`, and the group
|
|
13
|
+
* context carries the checked set plus a setter; `CheckboxItem` `checked` and
|
|
14
|
+
* `onToggle` are optional and fall back to that context (a toggle always
|
|
15
|
+
* reports to the group as well); arrow-key focus guarded for
|
|
16
|
+
* `noUncheckedIndexedAccess`; modo docs — TSDoc with FF's docs/API text,
|
|
17
|
+
* statics typed via a cast on the root, default export.
|
|
18
|
+
* Styling reads DS tokens (AGENTS.md styling): inline `fontVariationSettings`
|
|
19
|
+
* → `weight-*`; the hex focus-ring fallback → `ring-focus-ring` /
|
|
20
|
+
* `border-focus-ring`; `rounded-[Npx]` → radius tokens; `duration-80|120|160`
|
|
21
|
+
* and tier-length JS durations → `duration-<tier>` / `spring.*`; the unchecked
|
|
22
|
+
* `border-neutral-400` / `dark:border-neutral-500` → `border-control`.
|
|
23
|
+
* The inline run grouping is the shared `useSelectionRuns`; the merged
|
|
24
|
+
* backgrounds melt and split through the goo (`lib/use-merge-split.tsx`).
|
|
25
|
+
* Renamed for modo (item `checkbox`): `CheckboxItem` → `Checkbox`, the
|
|
26
|
+
* default export, which also stands alone (its own state from
|
|
27
|
+
* `defaultChecked`, `onCheckedChange` on every toggle, a pointer hover and
|
|
28
|
+
* a focus ring of its own, a `size`); `CheckboxGroup` → its `Checkbox.Group`
|
|
29
|
+
* static. A row's `index` is optional: the group numbers its rows in order
|
|
30
|
+
* (`lib/row-index.tsx`).
|
|
31
|
+
* Local: `label` is optional and takes any node; without one (and outside a
|
|
32
|
+
* group) the checkbox is a bare box, Base UI's Checkbox.Root itself (focus,
|
|
33
|
+
* `id` / `<label htmlFor>`, `aria-label(ledby)`, `name` / `value` /
|
|
34
|
+
* `required` for forms). `indeterminate` (or `checked="indeterminate"`)
|
|
35
|
+
* shows the icon set's `minus`, swapped with the check in one cell
|
|
36
|
+
* (icon-swap recipe); `disabled` dims a row and takes it out of the group's
|
|
37
|
+
* hover and arrow keys.
|
|
38
|
+
*/
|
|
39
|
+
|
|
40
|
+
import { Checkbox as CheckboxPrimitive } from '@base-ui/react/checkbox'
|
|
41
|
+
import { AnimatePresence, motion } from 'motion/react'
|
|
42
|
+
import {
|
|
43
|
+
createContext,
|
|
44
|
+
type ForwardRefExoticComponent,
|
|
45
|
+
forwardRef,
|
|
46
|
+
type HTMLAttributes,
|
|
47
|
+
type ReactNode,
|
|
48
|
+
type RefAttributes,
|
|
49
|
+
useCallback,
|
|
50
|
+
useContext,
|
|
51
|
+
useEffect,
|
|
52
|
+
useId,
|
|
53
|
+
useRef,
|
|
54
|
+
useState,
|
|
55
|
+
} from 'react'
|
|
56
|
+
import { FluidHoverHighlight } from '../../../lib/fluid-hover-highlight'
|
|
57
|
+
import { useIcon } from '../../../lib/icon-context'
|
|
58
|
+
import { isDisabledRow } from '../../../lib/popup'
|
|
59
|
+
import { useReduceMotion } from '../../../lib/reduced-motion'
|
|
60
|
+
import { IndexedRows, useRowIndex } from '../../../lib/row-index'
|
|
61
|
+
import { useShape } from '../../../lib/shape-context'
|
|
62
|
+
import { type SizeVariant, useSize } from '../../../lib/size-context'
|
|
63
|
+
import { spring } from '../../../lib/springs'
|
|
64
|
+
import { useControllableState } from '../../../lib/use-controllable-state'
|
|
65
|
+
import { useFluidHover, useRegisterFluidHoverItem } from '../../../lib/use-fluid-hover'
|
|
66
|
+
import { SelectionBackgrounds, useMergeSplitBlocks, useSelectionRuns } from '../../../lib/use-merge-split'
|
|
67
|
+
import { cn } from '../../../lib/utils'
|
|
68
|
+
import { SizeProvider } from '../../../primitives/sizes'
|
|
69
|
+
|
|
70
|
+
interface CheckboxGroupContextValue {
|
|
71
|
+
registerItem: (index: number, element: HTMLElement | null) => void
|
|
72
|
+
activeIndex: number | null
|
|
73
|
+
/** Local: the group's checked set (controlled or internal). */
|
|
74
|
+
checkedIndices: Set<number>
|
|
75
|
+
/** Local: sets one row's checked state, through `onCheckedIndicesChange`. */
|
|
76
|
+
setItemChecked: (index: number, checked: boolean) => void
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
const CheckboxGroupContext = createContext<CheckboxGroupContextValue | null>(null)
|
|
80
|
+
|
|
81
|
+
interface CheckboxGroupProps extends HTMLAttributes<HTMLDivElement> {
|
|
82
|
+
/** `Checkbox` rows. */
|
|
83
|
+
children: ReactNode
|
|
84
|
+
/** Set of checked item indices; drives the merged background across contiguous picks. Controlled — pair it with `onCheckedIndicesChange` (or per-item `onToggle`). */
|
|
85
|
+
checkedIndices?: Set<number>
|
|
86
|
+
/** Checked indices on first render when uncontrolled (a Set or an array). Defaults to none. */
|
|
87
|
+
defaultCheckedIndices?: Set<number> | number[]
|
|
88
|
+
/** Called with the next checked set whenever an item is toggled. */
|
|
89
|
+
onCheckedIndicesChange?: (checkedIndices: Set<number>) => void
|
|
90
|
+
/** Pins the group's rows to one step of the size ladder (default 36px, compact 28px). Defaults to the surrounding SizeProvider. */
|
|
91
|
+
size?: SizeVariant
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
// `Checkbox.Group`: the list, its checked set, hover highlight and focus ring.
|
|
95
|
+
const CheckboxGroup = forwardRef<HTMLDivElement, CheckboxGroupProps>(
|
|
96
|
+
(
|
|
97
|
+
{
|
|
98
|
+
children,
|
|
99
|
+
checkedIndices: checkedIndicesProp,
|
|
100
|
+
defaultCheckedIndices,
|
|
101
|
+
onCheckedIndicesChange,
|
|
102
|
+
size,
|
|
103
|
+
className,
|
|
104
|
+
...props
|
|
105
|
+
},
|
|
106
|
+
ref,
|
|
107
|
+
) => {
|
|
108
|
+
const containerRef = useRef<HTMLDivElement>(null)
|
|
109
|
+
|
|
110
|
+
const [checkedIndices, setCheckedIndices] = useControllableState<Set<number>>(
|
|
111
|
+
checkedIndicesProp,
|
|
112
|
+
new Set(defaultCheckedIndices),
|
|
113
|
+
onCheckedIndicesChange,
|
|
114
|
+
)
|
|
115
|
+
const setItemChecked = useCallback(
|
|
116
|
+
(index: number, checked: boolean) => {
|
|
117
|
+
setCheckedIndices(prev => {
|
|
118
|
+
if (prev.has(index) === checked) return prev
|
|
119
|
+
const next = new Set(prev)
|
|
120
|
+
if (checked) next.add(index)
|
|
121
|
+
else next.delete(index)
|
|
122
|
+
return next
|
|
123
|
+
})
|
|
124
|
+
},
|
|
125
|
+
[setCheckedIndices],
|
|
126
|
+
)
|
|
127
|
+
|
|
128
|
+
const hover = useFluidHover(containerRef, { isItemDisabled: isDisabledRow })
|
|
129
|
+
const { activeIndex, setActiveIndex, itemRects, handlers, registerItem } = hover
|
|
130
|
+
|
|
131
|
+
const checkedGroups = useSelectionRuns([...checkedIndices])
|
|
132
|
+
|
|
133
|
+
const [focusedIndex, setFocusedIndex] = useState<number | null>(null)
|
|
134
|
+
|
|
135
|
+
const focusRect = focusedIndex !== null ? itemRects[focusedIndex] : null
|
|
136
|
+
const shape = useShape()
|
|
137
|
+
|
|
138
|
+
const blocks = useMergeSplitBlocks(checkedGroups, itemRects, shape.mergedRadius)
|
|
139
|
+
|
|
140
|
+
const group = (
|
|
141
|
+
<CheckboxGroupContext.Provider value={{ registerItem, activeIndex, checkedIndices, setItemChecked }}>
|
|
142
|
+
<div
|
|
143
|
+
ref={node => {
|
|
144
|
+
;(containerRef as React.MutableRefObject<HTMLDivElement | null>).current = node
|
|
145
|
+
if (typeof ref === 'function') ref(node)
|
|
146
|
+
else if (ref) (ref as React.MutableRefObject<HTMLDivElement | null>).current = node
|
|
147
|
+
}}
|
|
148
|
+
onMouseEnter={handlers.onMouseEnter}
|
|
149
|
+
onMouseMove={handlers.onMouseMove}
|
|
150
|
+
onMouseLeave={handlers.onMouseLeave}
|
|
151
|
+
onClick={handlers.onClick}
|
|
152
|
+
onFocus={e => {
|
|
153
|
+
const indexAttr = (e.target as HTMLElement)
|
|
154
|
+
.closest('[data-fluid-hover-index]')
|
|
155
|
+
?.getAttribute('data-fluid-hover-index')
|
|
156
|
+
if (indexAttr != null) {
|
|
157
|
+
const idx = Number(indexAttr)
|
|
158
|
+
setActiveIndex(idx)
|
|
159
|
+
setFocusedIndex((e.target as HTMLElement).matches(':focus-visible') ? idx : null)
|
|
160
|
+
}
|
|
161
|
+
}}
|
|
162
|
+
onBlur={e => {
|
|
163
|
+
// Don't clear hover when focus moves to another item within the group
|
|
164
|
+
if (containerRef.current?.contains(e.relatedTarget as Node)) return
|
|
165
|
+
setFocusedIndex(null)
|
|
166
|
+
setActiveIndex(null)
|
|
167
|
+
}}
|
|
168
|
+
onKeyDown={e => {
|
|
169
|
+
// Scope to row wrappers only. The inner checkbox primitive also
|
|
170
|
+
// carries role="checkbox", so a bare [role="checkbox"] selector
|
|
171
|
+
// matches twice per row and arrows skip onto the hidden control.
|
|
172
|
+
const items = Array.from(
|
|
173
|
+
containerRef.current?.querySelectorAll('[data-fluid-hover-index]:not([aria-disabled="true"])') ?? [],
|
|
174
|
+
) as HTMLElement[]
|
|
175
|
+
const currentIdx = items.indexOf(e.target as HTMLElement)
|
|
176
|
+
if (currentIdx === -1) return
|
|
177
|
+
|
|
178
|
+
if (['ArrowDown', 'ArrowUp'].includes(e.key)) {
|
|
179
|
+
e.preventDefault()
|
|
180
|
+
const next =
|
|
181
|
+
e.key === 'ArrowDown' ? (currentIdx + 1) % items.length : (currentIdx - 1 + items.length) % items.length
|
|
182
|
+
items[next]?.focus()
|
|
183
|
+
} else if (e.key === 'Home') {
|
|
184
|
+
e.preventDefault()
|
|
185
|
+
items[0]?.focus()
|
|
186
|
+
} else if (e.key === 'End') {
|
|
187
|
+
e.preventDefault()
|
|
188
|
+
items[items.length - 1]?.focus()
|
|
189
|
+
}
|
|
190
|
+
}}
|
|
191
|
+
role="group"
|
|
192
|
+
className={cn('relative flex flex-col w-72 max-w-full select-none', className)}
|
|
193
|
+
{...props}
|
|
194
|
+
>
|
|
195
|
+
<SelectionBackgrounds blocks={blocks} />
|
|
196
|
+
|
|
197
|
+
{/* Hover background */}
|
|
198
|
+
<FluidHoverHighlight hover={hover} className={shape.bg} />
|
|
199
|
+
|
|
200
|
+
{/* Focus ring */}
|
|
201
|
+
<AnimatePresence>
|
|
202
|
+
{focusRect && (
|
|
203
|
+
<motion.div
|
|
204
|
+
className={`absolute ${shape.focusRing} pointer-events-none z-20 border border-focus-ring`}
|
|
205
|
+
initial={false}
|
|
206
|
+
animate={{
|
|
207
|
+
left: focusRect.left - 2,
|
|
208
|
+
top: focusRect.top - 2,
|
|
209
|
+
width: focusRect.width + 4,
|
|
210
|
+
height: focusRect.height + 4,
|
|
211
|
+
}}
|
|
212
|
+
exit={{ opacity: 0, transition: spring.fast.exit }}
|
|
213
|
+
transition={{
|
|
214
|
+
...spring.fast,
|
|
215
|
+
opacity: { duration: spring.fast.duration },
|
|
216
|
+
}}
|
|
217
|
+
/>
|
|
218
|
+
)}
|
|
219
|
+
</AnimatePresence>
|
|
220
|
+
|
|
221
|
+
<IndexedRows>{children}</IndexedRows>
|
|
222
|
+
</div>
|
|
223
|
+
</CheckboxGroupContext.Provider>
|
|
224
|
+
)
|
|
225
|
+
|
|
226
|
+
// A size prop pins every row in the group to one ladder step.
|
|
227
|
+
return size ? <SizeProvider size={size}>{group}</SizeProvider> : group
|
|
228
|
+
},
|
|
229
|
+
)
|
|
230
|
+
|
|
231
|
+
CheckboxGroup.displayName = 'CheckboxGroup'
|
|
232
|
+
|
|
233
|
+
/** A checkbox's state: on, off, or `'indeterminate'` (partly on), as Radix and shadcn spell it. */
|
|
234
|
+
type CheckboxCheckedState = boolean | 'indeterminate'
|
|
235
|
+
|
|
236
|
+
interface CheckboxProps extends HTMLAttributes<HTMLDivElement> {
|
|
237
|
+
/** Label beside the box, any node. Omit it, outside a group, for a bare box (see Bare): name it with `aria-label`, `aria-labelledby` or a `<label htmlFor>` pointing at its `id`. */
|
|
238
|
+
label?: ReactNode
|
|
239
|
+
/** Whether the checkbox is checked (controlled); `'indeterminate'` shows the dash, as `indeterminate` does. Defaults to the group's checked set inside a `Checkbox.Group`, else its own state. */
|
|
240
|
+
checked?: CheckboxCheckedState
|
|
241
|
+
/** Whether a standalone checkbox starts checked (uncontrolled). Defaults to `false`. */
|
|
242
|
+
defaultChecked?: boolean
|
|
243
|
+
/** Shows a dash instead of the check: some, not all, of what it stands for is on. A press checks it. Defaults to `false`. */
|
|
244
|
+
indeterminate?: boolean
|
|
245
|
+
/** Called with the new state whenever the checkbox is toggled, in a group or not. */
|
|
246
|
+
onCheckedChange?: (checked: boolean) => void
|
|
247
|
+
/** Called when the checkbox is toggled (a group's `onCheckedIndicesChange` fires too). */
|
|
248
|
+
onToggle?: () => void
|
|
249
|
+
/** Dims the checkbox and ignores presses; in a group the hover and the arrow keys skip it. Defaults to `false`. */
|
|
250
|
+
disabled?: boolean
|
|
251
|
+
/** Form field name: a hidden checkbox input submits `value` while checked. */
|
|
252
|
+
name?: string
|
|
253
|
+
/** Value submitted with `name` while checked. Defaults to `"on"`. */
|
|
254
|
+
value?: string
|
|
255
|
+
/** Marks the hidden form input required. Defaults to `false`. */
|
|
256
|
+
required?: boolean
|
|
257
|
+
/** Position within a `Checkbox.Group`: the row's key in `checkedIndices`. Defaults to its order among the group's rows. */
|
|
258
|
+
index?: number
|
|
259
|
+
/** Pins the checkbox to one step of the size ladder (see Sizes). Defaults to the surrounding SizeProvider (a group's `size`). */
|
|
260
|
+
size?: SizeVariant
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
type CheckboxComponent = ForwardRefExoticComponent<CheckboxProps & RefAttributes<HTMLDivElement>> & {
|
|
264
|
+
Group: typeof CheckboxGroup
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
// Icon swap (motion.md): the dash and the check share one cell, so the box
|
|
268
|
+
// never resizes between them.
|
|
269
|
+
const SHOWN = { opacity: 1, scale: 1, filter: 'blur(0px)' }
|
|
270
|
+
const HIDDEN = { opacity: 0, scale: 0.6, filter: 'blur(4px)' }
|
|
271
|
+
const SHOWN_REDUCED = { opacity: 1 }
|
|
272
|
+
const HIDDEN_REDUCED = { opacity: 0 }
|
|
273
|
+
const swapEnter = { type: 'tween' as const, duration: spring.fast.duration, ease: 'easeOut' as const }
|
|
274
|
+
const swapLeave = { type: 'tween' as const, ...spring.fast.exit, ease: 'easeIn' as const }
|
|
275
|
+
|
|
276
|
+
interface CheckboxBoxProps {
|
|
277
|
+
checked: boolean
|
|
278
|
+
indeterminate: boolean
|
|
279
|
+
/** Lit: the border darkens. */
|
|
280
|
+
active: boolean
|
|
281
|
+
compact: boolean
|
|
282
|
+
/** Already checked at mount: the check is there, not drawn in. */
|
|
283
|
+
skipAnimation: boolean
|
|
284
|
+
/** A bare box keeps its border when marked: a lone check would read as a bullet. */
|
|
285
|
+
bare: boolean
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
/** The box's insides: the border, the self-drawing check and the dash. */
|
|
289
|
+
function CheckboxBox({ checked, indeterminate, active, compact, skipAnimation, bare }: CheckboxBoxProps) {
|
|
290
|
+
const Minus = useIcon('minus')
|
|
291
|
+
const reduced = useReduceMotion()
|
|
292
|
+
const marked = checked || indeterminate
|
|
293
|
+
|
|
294
|
+
return (
|
|
295
|
+
<>
|
|
296
|
+
{/* Border */}
|
|
297
|
+
<div
|
|
298
|
+
className={cn(
|
|
299
|
+
'absolute inset-0 border-solid transition-all duration-fast',
|
|
300
|
+
compact ? 'rounded-sm' : 'rounded-box',
|
|
301
|
+
marked
|
|
302
|
+
? bare
|
|
303
|
+
? 'border-[1.5px] border-control'
|
|
304
|
+
: 'border-[1.5px] border-transparent'
|
|
305
|
+
: active
|
|
306
|
+
? 'border-[1.5px] border-control'
|
|
307
|
+
: 'border-[1.5px] border-border',
|
|
308
|
+
)}
|
|
309
|
+
/>
|
|
310
|
+
{/* Check mark */}
|
|
311
|
+
<AnimatePresence>
|
|
312
|
+
{checked && !indeterminate && (
|
|
313
|
+
<CheckboxPrimitive.Indicator
|
|
314
|
+
keepMounted
|
|
315
|
+
render={indicatorProps => {
|
|
316
|
+
const {
|
|
317
|
+
style: _s,
|
|
318
|
+
onDrag: _onDrag,
|
|
319
|
+
onDragStart: _onDragStart,
|
|
320
|
+
onDragEnd: _onDragEnd,
|
|
321
|
+
onAnimationStart: _onAnimationStart,
|
|
322
|
+
onAnimationEnd: _onAnimationEnd,
|
|
323
|
+
onAnimationIteration: _onAnimationIteration,
|
|
324
|
+
...rest
|
|
325
|
+
} = indicatorProps as React.HTMLAttributes<SVGSVGElement>
|
|
326
|
+
return (
|
|
327
|
+
<motion.svg
|
|
328
|
+
{...rest}
|
|
329
|
+
width={compact ? 16 : 18}
|
|
330
|
+
height={compact ? 16 : 18}
|
|
331
|
+
viewBox="0 0 24 24"
|
|
332
|
+
fill="none"
|
|
333
|
+
stroke="currentColor"
|
|
334
|
+
strokeWidth={2}
|
|
335
|
+
strokeLinecap="round"
|
|
336
|
+
strokeLinejoin="round"
|
|
337
|
+
className="absolute left-1/2 top-1/2 -translate-x-1/2 -translate-y-1/2 text-foreground"
|
|
338
|
+
initial={{ opacity: 1 }}
|
|
339
|
+
animate={{ opacity: 1 }}
|
|
340
|
+
exit={{ opacity: 1 }}
|
|
341
|
+
>
|
|
342
|
+
<motion.path
|
|
343
|
+
d="M6 12L10 16L18 8"
|
|
344
|
+
initial={{ pathLength: skipAnimation ? 1 : 0 }}
|
|
345
|
+
animate={{
|
|
346
|
+
pathLength: 1,
|
|
347
|
+
transition: { duration: spring.fast.duration, ease: 'easeOut' },
|
|
348
|
+
}}
|
|
349
|
+
exit={{
|
|
350
|
+
pathLength: 0,
|
|
351
|
+
transition: { duration: 0.04, ease: 'easeIn' },
|
|
352
|
+
}}
|
|
353
|
+
/>
|
|
354
|
+
</motion.svg>
|
|
355
|
+
)
|
|
356
|
+
}}
|
|
357
|
+
/>
|
|
358
|
+
)}
|
|
359
|
+
</AnimatePresence>
|
|
360
|
+
{/* Dash: blurs in where the check retracts, and back. */}
|
|
361
|
+
<motion.span
|
|
362
|
+
aria-hidden
|
|
363
|
+
className="pointer-events-none absolute inset-0 flex items-center justify-center text-foreground"
|
|
364
|
+
initial={false}
|
|
365
|
+
animate={indeterminate ? (reduced ? SHOWN_REDUCED : SHOWN) : reduced ? HIDDEN_REDUCED : HIDDEN}
|
|
366
|
+
transition={indeterminate ? swapEnter : swapLeave}
|
|
367
|
+
>
|
|
368
|
+
<Minus size={compact ? 14 : 16} strokeWidth={2} />
|
|
369
|
+
</motion.span>
|
|
370
|
+
</>
|
|
371
|
+
)
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
/**
|
|
375
|
+
* Checkbox with a self-drawing check, alone, bare, or in a group with merged
|
|
376
|
+
* backgrounds for contiguous picks.
|
|
377
|
+
*
|
|
378
|
+
* The whole row is the hit target; Space or Enter toggles it, the check mark
|
|
379
|
+
* draws itself in, and the checked label animates to semibold without
|
|
380
|
+
* shifting its width. A standalone checkbox keeps its own state from
|
|
381
|
+
* `defaultChecked`, or is controlled with `checked`; `onCheckedChange`
|
|
382
|
+
* reports every toggle. `indeterminate` (or `checked="indeterminate"`) shows
|
|
383
|
+
* a dash, which blurs into the check when it is pressed, and back.
|
|
384
|
+
*
|
|
385
|
+
* Without a `label` the checkbox is just the box: Base UI's checkbox, so a
|
|
386
|
+
* `<label htmlFor>` pointing at its `id` toggles it, `aria-label` names it,
|
|
387
|
+
* and `name` / `value` / `required` take part in a form. It sits on its own
|
|
388
|
+
* in a table cell or beside a label you lay out yourself.
|
|
389
|
+
*
|
|
390
|
+
* In a `Checkbox.Group`, contiguous checked rows share one background: a
|
|
391
|
+
* checked row's background grows out of its center and melts into its
|
|
392
|
+
* neighbours, an unchecked one pinches off and shrinks away (the liquid
|
|
393
|
+
* indicators in Morph). A fluid hover highlight melts from row to row, and
|
|
394
|
+
* Arrow Up/Down, Home and End move focus, skipping disabled rows. The group
|
|
395
|
+
* numbers its rows in order, so they need no `index`; pass one to key a row
|
|
396
|
+
* explicitly.
|
|
397
|
+
*
|
|
398
|
+
* Statics:
|
|
399
|
+
* - `Checkbox.Group` — the list: uncontrolled with `defaultCheckedIndices`
|
|
400
|
+
* (a Set or an array of row indices), or controlled with `checkedIndices`
|
|
401
|
+
* plus `onCheckedIndicesChange`; `size` pins every row to one step of the
|
|
402
|
+
* size ladder. A row's own `checked` / `onToggle` still override the group
|
|
403
|
+
* for that row.
|
|
404
|
+
*
|
|
405
|
+
* @example {@include ./examples.mdx}
|
|
406
|
+
*/
|
|
407
|
+
const Checkbox = forwardRef<HTMLDivElement, CheckboxProps>(
|
|
408
|
+
(
|
|
409
|
+
{
|
|
410
|
+
label,
|
|
411
|
+
checked: checkedProp,
|
|
412
|
+
defaultChecked = false,
|
|
413
|
+
indeterminate: indeterminateProp = false,
|
|
414
|
+
onCheckedChange,
|
|
415
|
+
onToggle: onToggleProp,
|
|
416
|
+
disabled = false,
|
|
417
|
+
name,
|
|
418
|
+
value,
|
|
419
|
+
required = false,
|
|
420
|
+
index: indexProp,
|
|
421
|
+
size,
|
|
422
|
+
className,
|
|
423
|
+
...props
|
|
424
|
+
},
|
|
425
|
+
ref,
|
|
426
|
+
) => {
|
|
427
|
+
const internalRef = useRef<HTMLDivElement>(null)
|
|
428
|
+
const hasMounted = useRef(false)
|
|
429
|
+
const group = useContext(CheckboxGroupContext)
|
|
430
|
+
const index = useRowIndex(indexProp)
|
|
431
|
+
const labelId = useId()
|
|
432
|
+
const explicit = checkedProp === 'indeterminate' ? false : checkedProp
|
|
433
|
+
const [ownChecked, setOwnChecked] = useControllableState(explicit, defaultChecked, onCheckedChange)
|
|
434
|
+
const [hovered, setHovered] = useState(false)
|
|
435
|
+
|
|
436
|
+
// Local: an explicit `checked` wins; otherwise the group's set (or, alone,
|
|
437
|
+
// the row's own state) decides. A toggle reports to the group as well.
|
|
438
|
+
const checked = explicit ?? (group ? group.checkedIndices.has(index) : ownChecked)
|
|
439
|
+
const indeterminate = indeterminateProp || checkedProp === 'indeterminate'
|
|
440
|
+
const onToggle = () => {
|
|
441
|
+
if (disabled) return
|
|
442
|
+
// A dash checks, as a native mixed checkbox does.
|
|
443
|
+
const next = indeterminate || !checked
|
|
444
|
+
onToggleProp?.()
|
|
445
|
+
group?.setItemChecked(index, next)
|
|
446
|
+
// Checked and dashed at once: the state "changes" only by the dash going.
|
|
447
|
+
if (next === checked) onCheckedChange?.(next)
|
|
448
|
+
else setOwnChecked(next)
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
useRegisterFluidHoverItem(group?.registerItem, index, internalRef)
|
|
452
|
+
|
|
453
|
+
useEffect(() => {
|
|
454
|
+
hasMounted.current = true
|
|
455
|
+
}, [])
|
|
456
|
+
|
|
457
|
+
const isActive = group ? group.activeIndex === index : hovered
|
|
458
|
+
const skipAnimation = !hasMounted.current
|
|
459
|
+
const shape = useShape()
|
|
460
|
+
const sizeClasses = useSize(size)
|
|
461
|
+
const compact = sizeClasses.variant === 'compact'
|
|
462
|
+
const setRef = (node: HTMLDivElement | null) => {
|
|
463
|
+
;(internalRef as React.MutableRefObject<HTMLDivElement | null>).current = node
|
|
464
|
+
if (typeof ref === 'function') ref(node)
|
|
465
|
+
else if (ref) (ref as React.MutableRefObject<HTMLDivElement | null>).current = node
|
|
466
|
+
}
|
|
467
|
+
const box = (
|
|
468
|
+
<CheckboxBox
|
|
469
|
+
checked={checked}
|
|
470
|
+
indeterminate={indeterminate}
|
|
471
|
+
active={isActive}
|
|
472
|
+
compact={compact}
|
|
473
|
+
skipAnimation={skipAnimation}
|
|
474
|
+
bare={label === undefined && !group}
|
|
475
|
+
/>
|
|
476
|
+
)
|
|
477
|
+
|
|
478
|
+
// Bare: no label and no group — the box alone is the control.
|
|
479
|
+
if (label === undefined && !group) {
|
|
480
|
+
return (
|
|
481
|
+
<CheckboxPrimitive.Root
|
|
482
|
+
ref={setRef}
|
|
483
|
+
render={<div />}
|
|
484
|
+
checked={checked}
|
|
485
|
+
indeterminate={indeterminate}
|
|
486
|
+
onCheckedChange={() => onToggle()}
|
|
487
|
+
disabled={disabled}
|
|
488
|
+
name={name}
|
|
489
|
+
value={value}
|
|
490
|
+
required={required}
|
|
491
|
+
onPointerEnter={e => {
|
|
492
|
+
if (e.pointerType === 'mouse') setHovered(true)
|
|
493
|
+
}}
|
|
494
|
+
onPointerLeave={() => setHovered(false)}
|
|
495
|
+
className={cn(
|
|
496
|
+
'relative inline-flex shrink-0 cursor-pointer outline-none transition-[opacity] duration-fast',
|
|
497
|
+
'focus-visible:ring-1 focus-visible:ring-focus-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background',
|
|
498
|
+
compact ? 'size-3.5 rounded-sm' : 'size-4 rounded-box',
|
|
499
|
+
disabled && 'opacity-50 pointer-events-none',
|
|
500
|
+
className,
|
|
501
|
+
)}
|
|
502
|
+
// The root renders a div (`render`); its handlers are typed for Base UI's span.
|
|
503
|
+
{...(props as HTMLAttributes<HTMLSpanElement>)}
|
|
504
|
+
>
|
|
505
|
+
{box}
|
|
506
|
+
</CheckboxPrimitive.Root>
|
|
507
|
+
)
|
|
508
|
+
}
|
|
509
|
+
|
|
510
|
+
return (
|
|
511
|
+
<div
|
|
512
|
+
ref={setRef}
|
|
513
|
+
data-fluid-hover-index={index}
|
|
514
|
+
data-disabled={disabled || undefined}
|
|
515
|
+
tabIndex={disabled ? -1 : 0}
|
|
516
|
+
role="checkbox"
|
|
517
|
+
aria-checked={indeterminate ? 'mixed' : checked}
|
|
518
|
+
aria-disabled={disabled || undefined}
|
|
519
|
+
aria-label={typeof label === 'string' ? label : undefined}
|
|
520
|
+
aria-labelledby={label !== undefined && typeof label !== 'string' ? labelId : undefined}
|
|
521
|
+
onClick={onToggle}
|
|
522
|
+
onPointerEnter={e => {
|
|
523
|
+
if (e.pointerType === 'mouse') setHovered(true)
|
|
524
|
+
}}
|
|
525
|
+
onPointerLeave={() => setHovered(false)}
|
|
526
|
+
onMouseDown={e => {
|
|
527
|
+
// Clicking the 15px checkbox square would natively focus the hidden
|
|
528
|
+
// primitive (nearest focusable ancestor of the click target), after
|
|
529
|
+
// which arrow-key nav dead-zones: the group keydown handler can't
|
|
530
|
+
// find the target among the row wrappers. Prevent the native focus
|
|
531
|
+
// move (click still fires) and land focus on the row instead. Skip
|
|
532
|
+
// genuinely interactive children so we don't hijack their focus.
|
|
533
|
+
const interactive = (e.target as HTMLElement).closest(
|
|
534
|
+
'button:not([tabindex="-1"]), a[href], input, select, textarea, [tabindex]:not([tabindex="-1"])',
|
|
535
|
+
)
|
|
536
|
+
if (interactive && interactive !== e.currentTarget) return
|
|
537
|
+
e.preventDefault()
|
|
538
|
+
e.currentTarget.focus()
|
|
539
|
+
}}
|
|
540
|
+
onKeyDown={e => {
|
|
541
|
+
if (e.key === ' ' || e.key === 'Enter') {
|
|
542
|
+
e.preventDefault()
|
|
543
|
+
onToggle()
|
|
544
|
+
}
|
|
545
|
+
}}
|
|
546
|
+
className={cn(
|
|
547
|
+
// Fixed height (was py-1.5 around a 19.5px line box ≈ 31.5px) so the
|
|
548
|
+
// text-box trim on the label doesn't shrink the row.
|
|
549
|
+
`relative z-10 flex ${sizeClasses.control} items-center ${sizeClasses.gap} ${shape.item} ${sizeClasses.px} cursor-pointer outline-none transition-[opacity] duration-fast`,
|
|
550
|
+
// The group draws one travelling focus ring; alone, the row rings itself.
|
|
551
|
+
!group && 'focus-visible:ring-1 focus-visible:ring-focus-ring',
|
|
552
|
+
disabled && 'opacity-50 pointer-events-none',
|
|
553
|
+
className,
|
|
554
|
+
)}
|
|
555
|
+
{...props}
|
|
556
|
+
>
|
|
557
|
+
{/* Checkbox — Base UI primitive for accessibility and forms */}
|
|
558
|
+
<CheckboxPrimitive.Root
|
|
559
|
+
checked={checked}
|
|
560
|
+
indeterminate={indeterminate}
|
|
561
|
+
onCheckedChange={() => onToggle()}
|
|
562
|
+
disabled={disabled}
|
|
563
|
+
name={name}
|
|
564
|
+
value={value}
|
|
565
|
+
required={required}
|
|
566
|
+
tabIndex={-1}
|
|
567
|
+
aria-hidden
|
|
568
|
+
className={cn(
|
|
569
|
+
'relative shrink-0 appearance-none bg-transparent p-0 border-0 outline-none cursor-pointer',
|
|
570
|
+
compact ? 'w-[14px] h-[14px]' : 'w-[16px] h-[16px]',
|
|
571
|
+
)}
|
|
572
|
+
onClick={e => e.stopPropagation()}
|
|
573
|
+
>
|
|
574
|
+
{box}
|
|
575
|
+
</CheckboxPrimitive.Root>
|
|
576
|
+
|
|
577
|
+
{/* Label */}
|
|
578
|
+
{/* Both stacked spans carry the text-box trim so the invisible bold
|
|
579
|
+
sizer and the visible label keep identical boxes. */}
|
|
580
|
+
{label !== undefined && (
|
|
581
|
+
<span className={cn('inline-grid', sizeClasses.text)}>
|
|
582
|
+
<span
|
|
583
|
+
className="col-start-1 row-start-1 invisible [text-box:trim-both_cap_alphabetic] weight-semibold"
|
|
584
|
+
aria-hidden="true"
|
|
585
|
+
>
|
|
586
|
+
{label}
|
|
587
|
+
</span>
|
|
588
|
+
<span
|
|
589
|
+
id={labelId}
|
|
590
|
+
className={cn(
|
|
591
|
+
'col-start-1 row-start-1 transition-[color,font-variation-settings] duration-fast [text-box:trim-both_cap_alphabetic]',
|
|
592
|
+
checked || indeterminate || isActive ? 'text-foreground' : 'text-muted-foreground',
|
|
593
|
+
checked ? 'weight-semibold' : 'weight-normal',
|
|
594
|
+
)}
|
|
595
|
+
>
|
|
596
|
+
{label}
|
|
597
|
+
</span>
|
|
598
|
+
</span>
|
|
599
|
+
)}
|
|
600
|
+
</div>
|
|
601
|
+
)
|
|
602
|
+
},
|
|
603
|
+
) as CheckboxComponent
|
|
604
|
+
|
|
605
|
+
Checkbox.displayName = 'Checkbox'
|
|
606
|
+
|
|
607
|
+
Object.assign(Checkbox, { Group: CheckboxGroup })
|
|
608
|
+
|
|
609
|
+
export type { CheckboxCheckedState, CheckboxGroupProps, CheckboxProps }
|
|
610
|
+
export { Checkbox, CheckboxGroup }
|
|
611
|
+
export default Checkbox
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Local addition (not part of Fluid Functionalism): the docs stage of the
|
|
3
|
+
* Checkbox page's indeterminate example. A "select all" checkbox over bare
|
|
4
|
+
* row checkboxes: it shows the dash while some rows are checked, so the
|
|
5
|
+
* example stays hook-free.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import { useState } from 'react'
|
|
9
|
+
import { Label } from '../input'
|
|
10
|
+
import Checkbox from './index'
|
|
11
|
+
|
|
12
|
+
interface SelectAllDemoProps {
|
|
13
|
+
/** The rows' labels. */
|
|
14
|
+
rows: string[]
|
|
15
|
+
/** Rows checked at first, by position. Defaults to the first. */
|
|
16
|
+
defaultChecked?: number[]
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export default function SelectAllDemo({ rows, defaultChecked = [0] }: SelectAllDemoProps) {
|
|
20
|
+
const [checked, setChecked] = useState(() => new Set(defaultChecked))
|
|
21
|
+
const all = checked.size === rows.length
|
|
22
|
+
const some = checked.size > 0 && !all
|
|
23
|
+
|
|
24
|
+
return (
|
|
25
|
+
<div className="flex w-64 max-w-full flex-col gap-3">
|
|
26
|
+
<Checkbox
|
|
27
|
+
label="Select all"
|
|
28
|
+
checked={some ? 'indeterminate' : all}
|
|
29
|
+
onCheckedChange={next => setChecked(next ? new Set(rows.map((_, i) => i)) : new Set())}
|
|
30
|
+
/>
|
|
31
|
+
{rows.map((row, i) => (
|
|
32
|
+
<div key={row} className="flex items-center gap-2 pl-8">
|
|
33
|
+
<Checkbox
|
|
34
|
+
id={`select-all-${i}`}
|
|
35
|
+
checked={checked.has(i)}
|
|
36
|
+
onCheckedChange={next => {
|
|
37
|
+
const set = new Set(checked)
|
|
38
|
+
if (next) set.add(i)
|
|
39
|
+
else set.delete(i)
|
|
40
|
+
setChecked(set)
|
|
41
|
+
}}
|
|
42
|
+
/>
|
|
43
|
+
<Label htmlFor={`select-all-${i}`}>{row}</Label>
|
|
44
|
+
</div>
|
|
45
|
+
))}
|
|
46
|
+
</div>
|
|
47
|
+
)
|
|
48
|
+
}
|