@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,87 @@
|
|
|
1
|
+
import Copy from './index'
|
|
2
|
+
|
|
3
|
+
# Basic
|
|
4
|
+
|
|
5
|
+
Icon-only: the value fills the row and the copy glyph sits at the
|
|
6
|
+
trailing edge, with a tooltip on hover.
|
|
7
|
+
|
|
8
|
+
<div className="w-72">
|
|
9
|
+
<Copy value="npx shadcn@latest add https://www.fluidfunctionalism.com/r/input-copy.json" />
|
|
10
|
+
</div>
|
|
11
|
+
|
|
12
|
+
# Copied morph
|
|
13
|
+
|
|
14
|
+
Click a row. The copy glyph's two sheets melt into a disc in the success
|
|
15
|
+
tint behind a check that draws itself, and split back into the glyph after
|
|
16
|
+
two seconds; a failed copy turns the disc red behind a ✕. The compact step
|
|
17
|
+
keeps the same disc.
|
|
18
|
+
|
|
19
|
+
<div className="flex w-72 flex-col gap-4">
|
|
20
|
+
<Copy value="bun add @base-ui/react motion" />
|
|
21
|
+
<Copy variant="button" size="compact" value="bun add @base-ui/react motion" />
|
|
22
|
+
</div>
|
|
23
|
+
|
|
24
|
+
# With Label
|
|
25
|
+
|
|
26
|
+
`label` renders a muted caption above the field and joins the button's
|
|
27
|
+
accessible name, so a screen reader announces "Copy Install command".
|
|
28
|
+
|
|
29
|
+
<div className="w-72">
|
|
30
|
+
<Copy
|
|
31
|
+
label="Install command"
|
|
32
|
+
value="npx shadcn@latest add https://www.fluidfunctionalism.com/r/input-copy.json"
|
|
33
|
+
/>
|
|
34
|
+
</div>
|
|
35
|
+
|
|
36
|
+
# Button Variant
|
|
37
|
+
|
|
38
|
+
`variant="button"` trades the tooltip for a visible Copy label. The label
|
|
39
|
+
slot is pre-sized to the widest state ("Copied"), so the row never
|
|
40
|
+
reflows when the state flips.
|
|
41
|
+
|
|
42
|
+
<div className="w-72">
|
|
43
|
+
<Copy
|
|
44
|
+
variant="button"
|
|
45
|
+
value="npx shadcn@latest add https://www.fluidfunctionalism.com/r/input-copy.json"
|
|
46
|
+
/>
|
|
47
|
+
</div>
|
|
48
|
+
|
|
49
|
+
# Left Aligned
|
|
50
|
+
|
|
51
|
+
`align="left"` puts the action on the leading edge, before the value —
|
|
52
|
+
in either variant.
|
|
53
|
+
|
|
54
|
+
<div className="flex flex-col gap-4 w-72">
|
|
55
|
+
<Copy
|
|
56
|
+
align="left"
|
|
57
|
+
value="npx shadcn@latest add https://www.fluidfunctionalism.com/r/input-copy.json"
|
|
58
|
+
/>
|
|
59
|
+
<Copy
|
|
60
|
+
variant="button"
|
|
61
|
+
align="left"
|
|
62
|
+
value="npx shadcn@latest add https://www.fluidfunctionalism.com/r/input-copy.json"
|
|
63
|
+
/>
|
|
64
|
+
</div>
|
|
65
|
+
|
|
66
|
+
# Disabled
|
|
67
|
+
|
|
68
|
+
Dims the row to 50% and drops pointer events, so the value stays readable
|
|
69
|
+
but nothing can be copied.
|
|
70
|
+
|
|
71
|
+
<div className="w-72">
|
|
72
|
+
<Copy label="Invite code" value="ABCD-1234-EFGH" disabled />
|
|
73
|
+
</div>
|
|
74
|
+
|
|
75
|
+
# Copy Callback
|
|
76
|
+
|
|
77
|
+
`onCopy` fires after a successful copy — count them, toast, or log the
|
|
78
|
+
share. The handler below is an empty arrow (examples hold no state of
|
|
79
|
+
their own); in an app it would be where you bump a counter.
|
|
80
|
+
|
|
81
|
+
<div className="w-72">
|
|
82
|
+
<Copy
|
|
83
|
+
label="Share link"
|
|
84
|
+
value="https://fluidfunctionalism.com/r/input-copy"
|
|
85
|
+
onCopy={() => {}}
|
|
86
|
+
/>
|
|
87
|
+
</div>
|
|
@@ -0,0 +1,482 @@
|
|
|
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/default/input-copy.tsx` @ b3587bdbd83fc66c2a6aae3817ffb856cb09260b
|
|
5
|
+
* MIT License © 2026 Micka Touillaud — fluidfunctionalism.com (notice: LICENSE.fluid-functionalism)
|
|
6
|
+
* Local modifications:
|
|
7
|
+
* - `"use client"` directive dropped (no RSC here).
|
|
8
|
+
* - `framer-motion` → `motion/react`; `@/lib/{utils,icon-context,shape-context,
|
|
9
|
+
* size-context,springs}` rewritten to `../../lib/*` (the `@/lib/font-weight`
|
|
10
|
+
* import went with the inline `fontVariationSettings`, below);
|
|
11
|
+
* `@/registry/radix/tooltip` → `../overlays/tooltip`.
|
|
12
|
+
* - React 18 types: `useRef<ReturnType<typeof setTimeout>>(null)` →
|
|
13
|
+
* `useRef<ReturnType<typeof setTimeout> | null>(null)` (React 19 allows the
|
|
14
|
+
* 1-arg null form, React 18's overloads don't).
|
|
15
|
+
* - `CopyProps`: member docs replaced by the FF docs API-table text with the
|
|
16
|
+
* defaults spelled into the prose (modo reads defaults from the description, not
|
|
17
|
+
* from the destructuring), and `className` re-declared so it is documented.
|
|
18
|
+
* - The tooltip comment's "Radix closes it on pointer down" reads "Base UI" here —
|
|
19
|
+
* this port's Tooltip is the Base UI flavor; behaviour is the same.
|
|
20
|
+
* - modo item: TSDoc from the FF "InputCopy" docs page. Renamed `Copy` (item
|
|
21
|
+
* `copy`, outside the inputs group): `InputCopy*` exports → `Copy*`.
|
|
22
|
+
* - Styling reads DS tokens (AGENTS.md styling): inline
|
|
23
|
+
* `fontVariationSettings` → `weight-*`; the hex focus-ring fallback →
|
|
24
|
+
* `ring-focus-ring` / `border-focus-ring`; literal colors → color tokens;
|
|
25
|
+
* `duration-80|120|160` and tier-length JS durations → `duration-<tier>` /
|
|
26
|
+
* `spring.*`.
|
|
27
|
+
* - The copied state morphs (local, in the morph layer's language): the copy
|
|
28
|
+
* glyph's two sheets melt through the shared goo filter (`GooFilter`,
|
|
29
|
+
* `GOO_BLUR_RATIO`) into a disc tinted like Toast's state chip
|
|
30
|
+
* (`--status-success`, `--status-error` for a failure), behind the check or
|
|
31
|
+
* ✕, and split back into the glyph when the state times out. The glyphs
|
|
32
|
+
* crossfade over one fixed slot instead of `mode="wait"`; the button
|
|
33
|
+
* variant keeps that one glyph slot and swaps only its word.
|
|
34
|
+
*/
|
|
35
|
+
|
|
36
|
+
import { AnimatePresence, animate, motion, useMotionValue } from 'motion/react'
|
|
37
|
+
import {
|
|
38
|
+
forwardRef,
|
|
39
|
+
type HTMLAttributes,
|
|
40
|
+
useCallback,
|
|
41
|
+
useEffect,
|
|
42
|
+
useId,
|
|
43
|
+
useLayoutEffect,
|
|
44
|
+
useRef,
|
|
45
|
+
useState,
|
|
46
|
+
} from 'react'
|
|
47
|
+
import { type IconComponent, useIcon } from '../../lib/icon-context'
|
|
48
|
+
import { GooFilter } from '../../lib/morph-layers'
|
|
49
|
+
import { useReduceMotion } from '../../lib/reduced-motion'
|
|
50
|
+
import { useShape } from '../../lib/shape-context'
|
|
51
|
+
import { type SizeVariant, useSize } from '../../lib/size-context'
|
|
52
|
+
import { spring } from '../../lib/springs'
|
|
53
|
+
import { GOO_BLUR_RATIO } from '../../lib/use-morph'
|
|
54
|
+
import { cn } from '../../lib/utils'
|
|
55
|
+
import { Tooltip } from '../overlays/tooltip'
|
|
56
|
+
|
|
57
|
+
type CopyVariant = 'icon' | 'button'
|
|
58
|
+
type CopyAlign = 'right' | 'left'
|
|
59
|
+
type CopyStatus = 'idle' | 'copied' | 'error'
|
|
60
|
+
|
|
61
|
+
interface Rect {
|
|
62
|
+
x: number
|
|
63
|
+
y: number
|
|
64
|
+
w: number
|
|
65
|
+
h: number
|
|
66
|
+
r: number
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
// The copied state's disc (local): lucide's copy glyph is two sheets on a
|
|
70
|
+
// 24-unit grid; scaled to the 14px glyph, they melt through the goo filter
|
|
71
|
+
// into one disc behind the check, and split back when the state times out.
|
|
72
|
+
const GLYPH = 14
|
|
73
|
+
const DISC = 20
|
|
74
|
+
const UNIT = GLYPH / 24
|
|
75
|
+
const sheet = (at: number): Rect => ({ x: at * UNIT, y: at * UNIT, w: 14 * UNIT, h: 14 * UNIT, r: 2 * UNIT })
|
|
76
|
+
const BACK = sheet(2)
|
|
77
|
+
const FRONT = sheet(8)
|
|
78
|
+
const DISC_RECT: Rect = { x: (GLYPH - DISC) / 2, y: (GLYPH - DISC) / 2, w: DISC, h: DISC, r: DISC / 2 }
|
|
79
|
+
const BLUR = (DISC / 2) * GOO_BLUR_RATIO
|
|
80
|
+
// The goo layer: the disc plus room for the blur on every side, in glyph coordinates.
|
|
81
|
+
const LAYER = { at: DISC_RECT.x - BLUR * 3, size: DISC + BLUR * 6 }
|
|
82
|
+
|
|
83
|
+
// Literal per state so the class extractor sees each one. The disc's tint is
|
|
84
|
+
// the layer's opacity, applied after the goo filter, which needs opaque shapes.
|
|
85
|
+
const TONE_BG = { copied: 'bg-status-success', error: 'bg-status-error' }
|
|
86
|
+
const TONE_TEXT = { copied: 'text-status-success', error: 'text-status-error' }
|
|
87
|
+
const CHECK_STROKE: Record<CopyVariant, string> = {
|
|
88
|
+
icon: '[&_svg]:stroke-[1.5] [&_svg]:transition-[stroke-width] [&_svg]:duration-fast group-hover:[&_svg]:stroke-[2]',
|
|
89
|
+
button: '[&_svg]:stroke-[2]',
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
const { exit: _exit, ...enter } = spring.slow
|
|
93
|
+
|
|
94
|
+
function placeSheet(el: HTMLElement | null, a: Rect, b: Rect, p: number) {
|
|
95
|
+
if (!el) return
|
|
96
|
+
const lerp = (from: number, to: number) => from + (to - from) * p
|
|
97
|
+
// The slow tier overshoots; a size never goes below zero on the way back.
|
|
98
|
+
const w = Math.max(0, lerp(a.w, b.w))
|
|
99
|
+
const h = Math.max(0, lerp(a.h, b.h))
|
|
100
|
+
el.style.left = `${lerp(a.x, b.x) - LAYER.at}px`
|
|
101
|
+
el.style.top = `${lerp(a.y, b.y) - LAYER.at}px`
|
|
102
|
+
el.style.width = `${w}px`
|
|
103
|
+
el.style.height = `${h}px`
|
|
104
|
+
el.style.borderRadius = `${Math.min(Math.max(0, lerp(a.r, b.r)), w / 2, h / 2)}px`
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/** The goo layer behind the glyph: two sheets on one progress value, idle at 0, copied (or failed) at 1. */
|
|
108
|
+
function CopyDisc({ status }: { status: CopyStatus }) {
|
|
109
|
+
const layer = useRef<HTMLSpanElement>(null)
|
|
110
|
+
const back = useRef<HTMLSpanElement>(null)
|
|
111
|
+
const front = useRef<HTMLSpanElement>(null)
|
|
112
|
+
const progress = useMotionValue(0)
|
|
113
|
+
const reduced = useReduceMotion()
|
|
114
|
+
const gooId = `copy-goo-${useId().replace(/:/g, '')}`
|
|
115
|
+
const tone = useRef<'copied' | 'error'>('copied')
|
|
116
|
+
const on = status !== 'idle'
|
|
117
|
+
if (on) tone.current = status
|
|
118
|
+
|
|
119
|
+
useLayoutEffect(() => {
|
|
120
|
+
if (!on && progress.get() === 0) return
|
|
121
|
+
const render = (p: number) => {
|
|
122
|
+
if (layer.current) layer.current.style.visibility = p > 0 ? 'visible' : 'hidden'
|
|
123
|
+
placeSheet(back.current, BACK, DISC_RECT, p)
|
|
124
|
+
placeSheet(front.current, FRONT, DISC_RECT, p)
|
|
125
|
+
}
|
|
126
|
+
const target = on ? 1 : 0
|
|
127
|
+
if (reduced) {
|
|
128
|
+
progress.jump(target)
|
|
129
|
+
return render(target)
|
|
130
|
+
}
|
|
131
|
+
const controls = animate(progress, target, { ...(on ? enter : spring.slow.exit), onUpdate: render })
|
|
132
|
+
return () => controls.stop()
|
|
133
|
+
}, [on, reduced])
|
|
134
|
+
|
|
135
|
+
return (
|
|
136
|
+
// Structural geometry: the layer box around the glyph slot, sized for the blur.
|
|
137
|
+
<span
|
|
138
|
+
aria-hidden
|
|
139
|
+
className="pointer-events-none absolute"
|
|
140
|
+
style={{ left: LAYER.at, top: LAYER.at, width: LAYER.size, height: LAYER.size }}
|
|
141
|
+
>
|
|
142
|
+
<GooFilter id={gooId} blur={BLUR} />
|
|
143
|
+
{/* The filter is the effect itself: it melts the two token-filled sheets into one. */}
|
|
144
|
+
<span ref={layer} className="invisible absolute inset-0 opacity-16" style={{ filter: `url(#${gooId})` }}>
|
|
145
|
+
<span ref={back} className={cn('absolute', TONE_BG[tone.current])} />
|
|
146
|
+
<span ref={front} className={cn('absolute', TONE_BG[tone.current])} />
|
|
147
|
+
</span>
|
|
148
|
+
</span>
|
|
149
|
+
)
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
const CHECK_PATH = 'M6 12L10 16L18 8'
|
|
153
|
+
const ERROR_PATH = 'M9 9L15 15M15 9L9 15'
|
|
154
|
+
|
|
155
|
+
/** The action's glyph slot: the copy icon, or the check / ✕ drawing itself over its disc. */
|
|
156
|
+
function CopyGlyph({
|
|
157
|
+
status,
|
|
158
|
+
copyCount,
|
|
159
|
+
variant,
|
|
160
|
+
CopyIcon,
|
|
161
|
+
}: {
|
|
162
|
+
status: CopyStatus
|
|
163
|
+
copyCount: number
|
|
164
|
+
variant: CopyVariant
|
|
165
|
+
CopyIcon: IconComponent
|
|
166
|
+
}) {
|
|
167
|
+
return (
|
|
168
|
+
<span className="relative flex size-3.5 shrink-0 items-center justify-center">
|
|
169
|
+
<CopyDisc status={status} />
|
|
170
|
+
<AnimatePresence initial={false}>
|
|
171
|
+
{status === 'idle' ? (
|
|
172
|
+
<motion.span
|
|
173
|
+
key="copy"
|
|
174
|
+
initial={{ opacity: 0, scale: 0.8 }}
|
|
175
|
+
animate={{ opacity: 1, scale: 1 }}
|
|
176
|
+
exit={{ opacity: 0, scale: 0.8, transition: spring.fast.exit }}
|
|
177
|
+
transition={spring.fast}
|
|
178
|
+
className="absolute inset-0 flex items-center justify-center"
|
|
179
|
+
>
|
|
180
|
+
<CopyIcon
|
|
181
|
+
size={14}
|
|
182
|
+
strokeWidth={1.5}
|
|
183
|
+
className="transition-[stroke-width] duration-fast group-hover:stroke-[2]"
|
|
184
|
+
/>
|
|
185
|
+
</motion.span>
|
|
186
|
+
) : (
|
|
187
|
+
<motion.span
|
|
188
|
+
key={`${status}-${copyCount}`}
|
|
189
|
+
initial={{ opacity: 0, scale: 0.6 }}
|
|
190
|
+
animate={{ opacity: 1, scale: 1 }}
|
|
191
|
+
exit={{ opacity: 0, scale: 0.8, transition: spring.fast.exit }}
|
|
192
|
+
transition={spring.fast}
|
|
193
|
+
className={cn(
|
|
194
|
+
'absolute inset-0 flex items-center justify-center',
|
|
195
|
+
TONE_TEXT[status],
|
|
196
|
+
CHECK_STROKE[variant],
|
|
197
|
+
)}
|
|
198
|
+
>
|
|
199
|
+
<svg
|
|
200
|
+
width={14}
|
|
201
|
+
height={14}
|
|
202
|
+
viewBox="2 4 20 16"
|
|
203
|
+
fill="none"
|
|
204
|
+
stroke="currentColor"
|
|
205
|
+
strokeLinecap="round"
|
|
206
|
+
strokeLinejoin="round"
|
|
207
|
+
>
|
|
208
|
+
<motion.path
|
|
209
|
+
d={status === 'error' ? ERROR_PATH : CHECK_PATH}
|
|
210
|
+
initial={{ pathLength: 0 }}
|
|
211
|
+
animate={{
|
|
212
|
+
pathLength: 1,
|
|
213
|
+
transition: { duration: spring.fast.duration, ease: 'easeOut' },
|
|
214
|
+
}}
|
|
215
|
+
/>
|
|
216
|
+
</svg>
|
|
217
|
+
</motion.span>
|
|
218
|
+
)}
|
|
219
|
+
</AnimatePresence>
|
|
220
|
+
</span>
|
|
221
|
+
)
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
interface CopyProps extends Omit<HTMLAttributes<HTMLDivElement>, 'children'> {
|
|
225
|
+
/** The text value to display and copy to clipboard. */
|
|
226
|
+
value: string
|
|
227
|
+
/** Optional label displayed above the input. */
|
|
228
|
+
label?: string
|
|
229
|
+
/** Callback fired after the value is successfully copied. */
|
|
230
|
+
onCopy?: () => void
|
|
231
|
+
/** Disables the input and copy button. Defaults to `false`. */
|
|
232
|
+
disabled?: boolean
|
|
233
|
+
/** Icon-only with tooltip, or button with visible label. Defaults to `"icon"`. */
|
|
234
|
+
variant?: CopyVariant
|
|
235
|
+
/** Position of the copy action relative to the value. Defaults to `"right"`. */
|
|
236
|
+
align?: CopyAlign
|
|
237
|
+
/** Pins the field to one step of the size ladder (default 36px, compact 28px — see Sizes). Omitted, it follows the surrounding SizeProvider. */
|
|
238
|
+
size?: SizeVariant
|
|
239
|
+
/** Extra classes for the wrapper around the label and the field. */
|
|
240
|
+
className?: string
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
/**
|
|
244
|
+
* Read-only input with a copy-to-clipboard button and animated check
|
|
245
|
+
* feedback.
|
|
246
|
+
*
|
|
247
|
+
* The whole row is the button: click anywhere on it and the value goes to
|
|
248
|
+
* the clipboard, the copy glyph's two sheets melt into a tinted disc (the
|
|
249
|
+
* goo of Morph) behind a check that draws itself, and the tooltip flips to
|
|
250
|
+
* "Copied" for 2 seconds; then the disc splits back into the glyph. The value is monospaced and
|
|
251
|
+
* highlights on hover so it reads as one selectable token rather than a
|
|
252
|
+
* text field, and the async Clipboard API falls back to an off-screen
|
|
253
|
+
* textarea + `execCommand` where it is unavailable (insecure context,
|
|
254
|
+
* permissions policy) — a failure animates a ✕ and says so. `variant`
|
|
255
|
+
* switches between the icon-only affordance (with a tooltip) and a labelled
|
|
256
|
+
* Copy button, `align` moves that action to the leading edge, and the field
|
|
257
|
+
* follows the surrounding SizeProvider unless `size` pins it.
|
|
258
|
+
*
|
|
259
|
+
* @example {@include ./examples.mdx}
|
|
260
|
+
*/
|
|
261
|
+
const Copy = forwardRef<HTMLDivElement, CopyProps>(
|
|
262
|
+
({ value, label, onCopy, disabled, variant = 'icon', align = 'right', size, className, ...props }, ref) => {
|
|
263
|
+
const CopyIcon = useIcon('copy')
|
|
264
|
+
// "copied" and "error" both occupy the same animation slot on the button
|
|
265
|
+
const [status, setStatus] = useState<CopyStatus>('idle')
|
|
266
|
+
const [copyCount, setCopyCount] = useState(0)
|
|
267
|
+
// "idle" = normal tooltip behavior, "copied" = force open, "suppressed" = force closed
|
|
268
|
+
const [tooltipState, setTooltipState] = useState<'idle' | 'copied' | 'suppressed'>('idle')
|
|
269
|
+
const timeoutRef = useRef<ReturnType<typeof setTimeout> | null>(null)
|
|
270
|
+
const tooltipVisibleRef = useRef(false)
|
|
271
|
+
const tooltipWasVisibleRef = useRef(false)
|
|
272
|
+
const shape = useShape()
|
|
273
|
+
const sizeClasses = useSize(size)
|
|
274
|
+
// The row's height comes from the padded children, so the paddings step
|
|
275
|
+
// down with the ladder (py-2 → 36px total, py-1 → 28px).
|
|
276
|
+
const rowPy = sizeClasses.variant === 'compact' ? 'py-1' : 'py-2'
|
|
277
|
+
|
|
278
|
+
// Associate the visible label with the button: the button's accessible
|
|
279
|
+
// name reads "Copy <label>" (its own state label + the field label).
|
|
280
|
+
const generatedId = useId()
|
|
281
|
+
const labelId = label ? `${generatedId}-label` : undefined
|
|
282
|
+
const buttonId = `${generatedId}-button`
|
|
283
|
+
|
|
284
|
+
const handlePointerDown = useCallback(() => {
|
|
285
|
+
// Capture tooltip visibility before Base UI closes it on pointer down
|
|
286
|
+
tooltipWasVisibleRef.current = tooltipVisibleRef.current
|
|
287
|
+
}, [])
|
|
288
|
+
|
|
289
|
+
// execCommand fallback for when the async Clipboard API is unavailable or
|
|
290
|
+
// denied (insecure context, permissions policy) — copies via a temporary
|
|
291
|
+
// off-screen textarea.
|
|
292
|
+
const copyViaExecCommand = useCallback(() => {
|
|
293
|
+
const textarea = document.createElement('textarea')
|
|
294
|
+
textarea.value = value
|
|
295
|
+
textarea.setAttribute('readonly', '')
|
|
296
|
+
textarea.style.position = 'fixed'
|
|
297
|
+
textarea.style.opacity = '0'
|
|
298
|
+
document.body.appendChild(textarea)
|
|
299
|
+
textarea.select()
|
|
300
|
+
let ok = false
|
|
301
|
+
try {
|
|
302
|
+
ok = document.execCommand('copy')
|
|
303
|
+
} catch {
|
|
304
|
+
ok = false
|
|
305
|
+
}
|
|
306
|
+
document.body.removeChild(textarea)
|
|
307
|
+
return ok
|
|
308
|
+
}, [value])
|
|
309
|
+
|
|
310
|
+
const handleCopy = useCallback(async () => {
|
|
311
|
+
if (disabled) return
|
|
312
|
+
let ok = true
|
|
313
|
+
try {
|
|
314
|
+
await navigator.clipboard.writeText(value)
|
|
315
|
+
} catch {
|
|
316
|
+
ok = copyViaExecCommand()
|
|
317
|
+
}
|
|
318
|
+
setStatus(ok ? 'copied' : 'error')
|
|
319
|
+
setCopyCount(c => c + 1)
|
|
320
|
+
setTooltipState(tooltipWasVisibleRef.current ? 'copied' : 'suppressed')
|
|
321
|
+
if (ok) onCopy?.()
|
|
322
|
+
if (timeoutRef.current) clearTimeout(timeoutRef.current)
|
|
323
|
+
timeoutRef.current = setTimeout(() => {
|
|
324
|
+
setStatus('idle')
|
|
325
|
+
setTooltipState('suppressed')
|
|
326
|
+
}, 2000)
|
|
327
|
+
}, [value, disabled, onCopy, copyViaExecCommand])
|
|
328
|
+
|
|
329
|
+
const handleTooltipOpenChange = useCallback((open: boolean) => {
|
|
330
|
+
tooltipVisibleRef.current = open
|
|
331
|
+
}, [])
|
|
332
|
+
|
|
333
|
+
useEffect(() => {
|
|
334
|
+
return () => {
|
|
335
|
+
if (timeoutRef.current) clearTimeout(timeoutRef.current)
|
|
336
|
+
}
|
|
337
|
+
}, [])
|
|
338
|
+
|
|
339
|
+
const handleMouseEnter = useCallback(() => {
|
|
340
|
+
setTooltipState(prev => (prev === 'suppressed' ? 'idle' : prev))
|
|
341
|
+
}, [])
|
|
342
|
+
|
|
343
|
+
const handleMouseLeave = useCallback(() => {
|
|
344
|
+
setTooltipState(prev => (prev === 'copied' ? 'suppressed' : prev))
|
|
345
|
+
}, [])
|
|
346
|
+
|
|
347
|
+
const actionElement =
|
|
348
|
+
variant === 'button' ? (
|
|
349
|
+
<span
|
|
350
|
+
className={cn(
|
|
351
|
+
'shrink-0 flex items-center gap-1.5 px-1.5 transition-colors duration-fast',
|
|
352
|
+
rowPy,
|
|
353
|
+
sizeClasses.text,
|
|
354
|
+
'text-muted-foreground group-hover:text-foreground',
|
|
355
|
+
'weight-normal',
|
|
356
|
+
)}
|
|
357
|
+
>
|
|
358
|
+
<CopyGlyph status={status} copyCount={copyCount} variant="button" CopyIcon={CopyIcon} />
|
|
359
|
+
<span className="select-none inline-grid text-left">
|
|
360
|
+
<span className="col-start-1 row-start-1 invisible" aria-hidden="true">
|
|
361
|
+
Copied
|
|
362
|
+
</span>
|
|
363
|
+
<AnimatePresence mode="wait" initial={false}>
|
|
364
|
+
<motion.span
|
|
365
|
+
key={status}
|
|
366
|
+
className={cn('col-start-1 row-start-1', status === 'error' && 'text-destructive')}
|
|
367
|
+
initial={{ opacity: 0, scale: 0.6 }}
|
|
368
|
+
animate={{ opacity: 1, scale: 1 }}
|
|
369
|
+
exit={{ opacity: 0, scale: 0.8, transition: spring.fast.exit }}
|
|
370
|
+
transition={spring.fast}
|
|
371
|
+
>
|
|
372
|
+
{status === 'copied' ? 'Copied' : status === 'error' ? 'Failed' : 'Copy'}
|
|
373
|
+
</motion.span>
|
|
374
|
+
</AnimatePresence>
|
|
375
|
+
</span>
|
|
376
|
+
</span>
|
|
377
|
+
) : (
|
|
378
|
+
<span
|
|
379
|
+
className={cn(
|
|
380
|
+
'shrink-0 flex px-1.5 transition-colors duration-fast',
|
|
381
|
+
rowPy,
|
|
382
|
+
'text-muted-foreground group-hover:text-foreground',
|
|
383
|
+
)}
|
|
384
|
+
>
|
|
385
|
+
<CopyGlyph status={status} copyCount={copyCount} variant="icon" CopyIcon={CopyIcon} />
|
|
386
|
+
</span>
|
|
387
|
+
)
|
|
388
|
+
|
|
389
|
+
const valueElement = (
|
|
390
|
+
<span
|
|
391
|
+
className={cn(
|
|
392
|
+
'flex-1 min-w-0 text-left text-foreground font-mono select-none truncate',
|
|
393
|
+
sizeClasses.text,
|
|
394
|
+
rowPy,
|
|
395
|
+
align === 'left' ? 'pl-1' : 'pl-0',
|
|
396
|
+
'weight-normal',
|
|
397
|
+
)}
|
|
398
|
+
>
|
|
399
|
+
<mark className="bg-transparent text-foreground transition-colors duration-fast group-hover:bg-brand/20 group-hover:text-foreground">
|
|
400
|
+
{value}
|
|
401
|
+
</mark>
|
|
402
|
+
</span>
|
|
403
|
+
)
|
|
404
|
+
|
|
405
|
+
const buttonContent =
|
|
406
|
+
align === 'left' ? (
|
|
407
|
+
<>
|
|
408
|
+
{actionElement}
|
|
409
|
+
{valueElement}
|
|
410
|
+
</>
|
|
411
|
+
) : (
|
|
412
|
+
<>
|
|
413
|
+
{valueElement}
|
|
414
|
+
{actionElement}
|
|
415
|
+
</>
|
|
416
|
+
)
|
|
417
|
+
|
|
418
|
+
const button = (
|
|
419
|
+
<button
|
|
420
|
+
id={buttonId}
|
|
421
|
+
type="button"
|
|
422
|
+
onPointerDown={handlePointerDown}
|
|
423
|
+
onClick={handleCopy}
|
|
424
|
+
disabled={disabled}
|
|
425
|
+
aria-label={
|
|
426
|
+
status === 'copied' ? 'Copied' : status === 'error' ? 'Copy failed' : label ? 'Copy' : 'Copy to clipboard'
|
|
427
|
+
}
|
|
428
|
+
aria-labelledby={label ? `${buttonId} ${labelId}` : undefined}
|
|
429
|
+
className={cn(
|
|
430
|
+
'group flex items-center w-full cursor-pointer outline-none transition-all duration-fast',
|
|
431
|
+
'focus-visible:ring-1 focus-visible:ring-focus-ring',
|
|
432
|
+
shape.input,
|
|
433
|
+
)}
|
|
434
|
+
>
|
|
435
|
+
{buttonContent}
|
|
436
|
+
</button>
|
|
437
|
+
)
|
|
438
|
+
|
|
439
|
+
return (
|
|
440
|
+
<div
|
|
441
|
+
ref={ref}
|
|
442
|
+
className={cn('flex flex-col gap-0.5', disabled && 'opacity-50 pointer-events-none', className)}
|
|
443
|
+
onMouseEnter={handleMouseEnter}
|
|
444
|
+
onMouseLeave={handleMouseLeave}
|
|
445
|
+
{...props}
|
|
446
|
+
>
|
|
447
|
+
{label && (
|
|
448
|
+
<span
|
|
449
|
+
id={labelId}
|
|
450
|
+
className={cn(
|
|
451
|
+
'text-muted-foreground',
|
|
452
|
+
sizeClasses.text,
|
|
453
|
+
align === 'left' ? 'pl-1' : 'pl-0',
|
|
454
|
+
'weight-normal',
|
|
455
|
+
)}
|
|
456
|
+
>
|
|
457
|
+
{label}
|
|
458
|
+
</span>
|
|
459
|
+
)}
|
|
460
|
+
{variant === 'icon' ? (
|
|
461
|
+
<Tooltip
|
|
462
|
+
content={tooltipState === 'idle' ? 'Copy to clipboard' : status === 'error' ? 'Copy failed' : 'Copied'}
|
|
463
|
+
delayDuration={500}
|
|
464
|
+
sideOffset={2}
|
|
465
|
+
forceOpen={tooltipState === 'copied' ? true : tooltipState === 'suppressed' ? false : undefined}
|
|
466
|
+
onOpenChange={handleTooltipOpenChange}
|
|
467
|
+
>
|
|
468
|
+
{button}
|
|
469
|
+
</Tooltip>
|
|
470
|
+
) : (
|
|
471
|
+
button
|
|
472
|
+
)}
|
|
473
|
+
</div>
|
|
474
|
+
)
|
|
475
|
+
},
|
|
476
|
+
)
|
|
477
|
+
|
|
478
|
+
Copy.displayName = 'Copy'
|
|
479
|
+
|
|
480
|
+
export type { CopyAlign, CopyProps, CopyVariant }
|
|
481
|
+
export { Copy }
|
|
482
|
+
export default Copy
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import Checkbox from './index'
|
|
2
|
+
import SelectAllDemo from './select-all-demo'
|
|
3
|
+
import { Label } from '../input'
|
|
4
|
+
|
|
5
|
+
# Basic
|
|
6
|
+
|
|
7
|
+
A standalone checkbox keeps its own state; pass `checked` and `onCheckedChange` to control it.
|
|
8
|
+
|
|
9
|
+
<div className="flex flex-col">
|
|
10
|
+
<Checkbox label="Accept the terms" />
|
|
11
|
+
<Checkbox label="Subscribe to the newsletter" defaultChecked />
|
|
12
|
+
</div>
|
|
13
|
+
|
|
14
|
+
# Group
|
|
15
|
+
|
|
16
|
+
`Checkbox.Group` stacks checkboxes: contiguous picks share one merged background, and the rows are numbered in order.
|
|
17
|
+
|
|
18
|
+
<Checkbox.Group defaultCheckedIndices={[0]}>
|
|
19
|
+
{['Apples', 'Bananas', 'Cherries', 'Dates'].map(label => (
|
|
20
|
+
<Checkbox key={label} label={label} />
|
|
21
|
+
))}
|
|
22
|
+
</Checkbox.Group>
|
|
23
|
+
|
|
24
|
+
# Compact
|
|
25
|
+
|
|
26
|
+
`size="compact"` pins every row to the 28px step of the size ladder.
|
|
27
|
+
|
|
28
|
+
<Checkbox.Group size="compact" defaultCheckedIndices={[1, 2]}>
|
|
29
|
+
{['Apples', 'Bananas', 'Cherries', 'Dates'].map(label => (
|
|
30
|
+
<Checkbox key={label} label={label} />
|
|
31
|
+
))}
|
|
32
|
+
</Checkbox.Group>
|
|
33
|
+
|
|
34
|
+
# Bare
|
|
35
|
+
|
|
36
|
+
Without a `label` the checkbox is just the box: point a `<label htmlFor>` at its `id`, or name it with `aria-label`. It joins forms through `name` and `value`.
|
|
37
|
+
|
|
38
|
+
<div className="flex flex-col gap-3">
|
|
39
|
+
<div className="flex items-center gap-2">
|
|
40
|
+
<Checkbox id="bare-terms" name="terms" defaultChecked />
|
|
41
|
+
<Label htmlFor="bare-terms">Accept the terms</Label>
|
|
42
|
+
</div>
|
|
43
|
+
<div className="flex items-center gap-4">
|
|
44
|
+
<Checkbox aria-label="Select row" />
|
|
45
|
+
<Checkbox aria-label="Select row, compact" size="compact" defaultChecked />
|
|
46
|
+
<Checkbox aria-label="Some rows selected" checked="indeterminate" />
|
|
47
|
+
</div>
|
|
48
|
+
</div>
|
|
49
|
+
|
|
50
|
+
# Indeterminate
|
|
51
|
+
|
|
52
|
+
`indeterminate`, or `checked="indeterminate"`, shows a dash: some, not all, of what it stands for is on. Check and uncheck the rows: the dash blurs into the check and back.
|
|
53
|
+
|
|
54
|
+
<SelectAllDemo rows={['Invoices', 'Receipts', 'Contracts']} />
|
|
55
|
+
|
|
56
|
+
# Node label
|
|
57
|
+
|
|
58
|
+
A label can be any node; the checkbox is then named by it.
|
|
59
|
+
|
|
60
|
+
<Checkbox
|
|
61
|
+
defaultChecked
|
|
62
|
+
label={
|
|
63
|
+
<span>
|
|
64
|
+
I agree to the <a className="underline" href="#">terms of service</a>
|
|
65
|
+
</span>
|
|
66
|
+
}
|
|
67
|
+
/>
|
|
68
|
+
|
|
69
|
+
# Disabled
|
|
70
|
+
|
|
71
|
+
`disabled` dims a checkbox and ignores presses; in a group the hover and the arrow keys skip it.
|
|
72
|
+
|
|
73
|
+
<div className="flex flex-col gap-3">
|
|
74
|
+
<Checkbox.Group defaultCheckedIndices={[0]}>
|
|
75
|
+
<Checkbox label="Email" />
|
|
76
|
+
<Checkbox label="SMS (not in your region)" disabled />
|
|
77
|
+
<Checkbox label="Push" />
|
|
78
|
+
</Checkbox.Group>
|
|
79
|
+
<div className="flex items-center gap-4 px-3">
|
|
80
|
+
<Checkbox aria-label="Disabled" disabled />
|
|
81
|
+
<Checkbox aria-label="Disabled, checked" disabled defaultChecked />
|
|
82
|
+
</div>
|
|
83
|
+
</div>
|