@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,106 @@
|
|
|
1
|
+
import Tooltip from './index'
|
|
2
|
+
import Button from '../../button'
|
|
3
|
+
import { Plus } from 'lucide-react'
|
|
4
|
+
|
|
5
|
+
# Basic
|
|
6
|
+
|
|
7
|
+
One `content` prop and a trigger child. The tooltip opens after the hover
|
|
8
|
+
delay and closes on pointer-out, blur or Escape.
|
|
9
|
+
|
|
10
|
+
<Tooltip content="Save your changes">
|
|
11
|
+
<Button>Hover me</Button>
|
|
12
|
+
</Tooltip>
|
|
13
|
+
|
|
14
|
+
# Placement
|
|
15
|
+
|
|
16
|
+
`side` picks the preferred side; `sideOffset` is the gap in pixels. A
|
|
17
|
+
tooltip that would collide with the viewport edge flips to the opposite
|
|
18
|
+
side and animates from there.
|
|
19
|
+
|
|
20
|
+
<div className="flex flex-wrap gap-3">
|
|
21
|
+
{['top', 'right', 'bottom', 'left'].map((side) => (
|
|
22
|
+
<Tooltip key={side} content={side} side={side}>
|
|
23
|
+
<Button variant="secondary" className="capitalize">{side}</Button>
|
|
24
|
+
</Tooltip>
|
|
25
|
+
))}
|
|
26
|
+
</div>
|
|
27
|
+
|
|
28
|
+
# Rich Content
|
|
29
|
+
|
|
30
|
+
`content` takes any node, not just a string — a shortcut hint, a label
|
|
31
|
+
with a description, a small stack of rows.
|
|
32
|
+
|
|
33
|
+
<Tooltip
|
|
34
|
+
content={
|
|
35
|
+
<div className="flex flex-col gap-1">
|
|
36
|
+
<span className="weight-semibold">Keyboard shortcut</span>
|
|
37
|
+
<span className="opacity-70">⌘ + S</span>
|
|
38
|
+
</div>
|
|
39
|
+
}
|
|
40
|
+
>
|
|
41
|
+
<Button leadingIcon={Plus}>Save</Button>
|
|
42
|
+
</Tooltip>
|
|
43
|
+
|
|
44
|
+
# Compound parts
|
|
45
|
+
|
|
46
|
+
Leave `content` out and `Tooltip` is the root of a compound tooltip: a
|
|
47
|
+
`Tooltip.Trigger` (`render` or Radix-style `asChild`) and a
|
|
48
|
+
`Tooltip.Content` with `side`, `align` and the offsets (and `render` or
|
|
49
|
+
`asChild` for the label's own element). It looks and moves the same as the
|
|
50
|
+
flat form.
|
|
51
|
+
|
|
52
|
+
<div className="flex flex-wrap gap-3">
|
|
53
|
+
<Tooltip>
|
|
54
|
+
<Tooltip.Trigger asChild>
|
|
55
|
+
<Button variant="secondary">Archive</Button>
|
|
56
|
+
</Tooltip.Trigger>
|
|
57
|
+
<Tooltip.Content asChild>
|
|
58
|
+
<span>Moves it out of the inbox</span>
|
|
59
|
+
</Tooltip.Content>
|
|
60
|
+
</Tooltip>
|
|
61
|
+
<Tooltip delay={0}>
|
|
62
|
+
<Tooltip.Trigger render={<Button variant="secondary">Start aligned</Button>} />
|
|
63
|
+
<Tooltip.Content side="bottom" align="start">Lines up with the trigger's left edge</Tooltip.Content>
|
|
64
|
+
</Tooltip>
|
|
65
|
+
</div>
|
|
66
|
+
|
|
67
|
+
# Follow cursor
|
|
68
|
+
|
|
69
|
+
For tall or wide triggers, a centered tooltip sits far from the pointer —
|
|
70
|
+
`followCursor` tracks it along one axis while the other stays anchored by
|
|
71
|
+
`side`.
|
|
72
|
+
|
|
73
|
+
<div className="flex flex-wrap items-center justify-center gap-6">
|
|
74
|
+
<Tooltip content="Following x" side="top" followCursor="x">
|
|
75
|
+
<div className="flex h-12 w-64 cursor-default items-center justify-center rounded-lg border border-border text-caption text-muted-foreground">
|
|
76
|
+
Move along me
|
|
77
|
+
</div>
|
|
78
|
+
</Tooltip>
|
|
79
|
+
<Tooltip content="Following y" side="right" followCursor="y">
|
|
80
|
+
<div className="flex h-40 w-12 cursor-default items-center justify-center rounded-lg border border-border text-caption text-muted-foreground">
|
|
81
|
+
<span className="rotate-90 whitespace-nowrap">Move along me</span>
|
|
82
|
+
</div>
|
|
83
|
+
</Tooltip>
|
|
84
|
+
</div>
|
|
85
|
+
|
|
86
|
+
# Delay
|
|
87
|
+
|
|
88
|
+
`delayDuration` overrides the hover delay per tooltip. Wrap a region in
|
|
89
|
+
`Tooltip.Provider` to share one delay and let adjacent tooltips skip it,
|
|
90
|
+
and the morph: the next label shows in place. The provider takes Base UI's
|
|
91
|
+
`delay` / `closeDelay` / `timeout` or Radix's `delayDuration` /
|
|
92
|
+
`skipDelayDuration`, so a Radix provider config spreads straight in.
|
|
93
|
+
|
|
94
|
+
<Tooltip.Provider delayDuration={300} skipDelayDuration={500}>
|
|
95
|
+
<div className="flex flex-wrap gap-3">
|
|
96
|
+
<Tooltip content="Instant" delayDuration={0}>
|
|
97
|
+
<Button variant="secondary">No delay</Button>
|
|
98
|
+
</Tooltip>
|
|
99
|
+
<Tooltip content="Grouped: 300ms, then instant between neighbours">
|
|
100
|
+
<Button variant="secondary">Grouped</Button>
|
|
101
|
+
</Tooltip>
|
|
102
|
+
<Tooltip content="Slow" delayDuration={500}>
|
|
103
|
+
<Button variant="secondary">500ms delay</Button>
|
|
104
|
+
</Tooltip>
|
|
105
|
+
</div>
|
|
106
|
+
</Tooltip.Provider>
|
|
@@ -0,0 +1,519 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Ported from Fluid Functionalism — github.com/mickadesign/fluid-functionalism
|
|
3
|
+
* `registry/base/tooltip.tsx` @ b3587bdbd83fc66c2a6aae3817ffb856cb09260b
|
|
4
|
+
* MIT License © 2026 Micka Touillaud — fluidfunctionalism.com (notice: LICENSE.fluid-functionalism)
|
|
5
|
+
* Local modifications:
|
|
6
|
+
* - `"use client"` directive dropped (no RSC here).
|
|
7
|
+
* - `framer-motion` → `motion/react`; `@/lib/{utils,springs,shape-context}` imports
|
|
8
|
+
* rewritten to `../../../lib/*` (the `@/lib/font-weight` import went with the inline
|
|
9
|
+
* `fontVariationSettings`, below).
|
|
10
|
+
* - `TooltipProps`: `className` / `children` docs filled in from the FF docs API table (modo's
|
|
11
|
+
* parser needs a description on every member).
|
|
12
|
+
* - modo item: TSDoc (from the FF "Tooltip" docs page), the `Tooltip.Provider` /
|
|
13
|
+
* `Tooltip.PortalContainer` statics (both still exported by name) and a default export.
|
|
14
|
+
* - Styling reads DS tokens (AGENTS.md styling): `text-[Npx]` →
|
|
15
|
+
* `text-<role>[-compact]`; inline `fontVariationSettings` → `weight-*`.
|
|
16
|
+
* - The 4px slide + fade (`getSlideOffset`, `spring.fast`) is replaced by the
|
|
17
|
+
* shared morph layer (`lib/use-morph.ts` + `MorphSurface`): the label grows
|
|
18
|
+
* out of its trigger with the goo neck by default, on `spring.goo`,
|
|
19
|
+
* with `from` / `effect` / `tier` props; `followCursor` tooltips fade, since
|
|
20
|
+
* their panel travels with the pointer. The popup's motion wrapper now only
|
|
21
|
+
* carries the cursor-follow offset.
|
|
22
|
+
* - Moving between adjacent tooltips under a `Tooltip.Provider` skips the
|
|
23
|
+
* morph (Base UI's `data-instant="delay"` hand-off): the next label shows
|
|
24
|
+
* in place and the last one goes at once.
|
|
25
|
+
* - Compound parts (local, for hosts with a Radix-shaped API): the flat
|
|
26
|
+
* tooltip is split into `TooltipRoot` (state, origin, grouping fallback),
|
|
27
|
+
* `TooltipTrigger` (`render` / `asChild` through `lib/slot.ts`) and
|
|
28
|
+
* `TooltipContent` (`side`, `align`, offsets, the morph options, `render` /
|
|
29
|
+
* `asChild` for the label's element, rest props on the popup). `Tooltip`
|
|
30
|
+
* without `content` acts as the root; with `content` it composes the three
|
|
31
|
+
* parts exactly as before. `TooltipProvider` also takes Base UI's names
|
|
32
|
+
* (`delay`, `closeDelay`, `timeout`) next to the Radix ones it had.
|
|
33
|
+
*/
|
|
34
|
+
|
|
35
|
+
import { Tooltip as TooltipPrimitive } from '@base-ui/react/tooltip'
|
|
36
|
+
import { type MotionValue, motion, useMotionValue } from 'motion/react'
|
|
37
|
+
import {
|
|
38
|
+
cloneElement,
|
|
39
|
+
createContext,
|
|
40
|
+
forwardRef,
|
|
41
|
+
type HTMLAttributes,
|
|
42
|
+
type MutableRefObject,
|
|
43
|
+
type ReactElement,
|
|
44
|
+
type ReactNode,
|
|
45
|
+
type RefObject,
|
|
46
|
+
useContext,
|
|
47
|
+
useEffect,
|
|
48
|
+
useImperativeHandle,
|
|
49
|
+
useMemo,
|
|
50
|
+
useRef,
|
|
51
|
+
useState,
|
|
52
|
+
} from 'react'
|
|
53
|
+
import { MorphSurface } from '../../../lib/morph-layers'
|
|
54
|
+
import { useShape } from '../../../lib/shape-context'
|
|
55
|
+
import { type SlotProps, slotRender } from '../../../lib/slot'
|
|
56
|
+
import { type MorphOrigin, useMorph, useMorphOrigin } from '../../../lib/use-morph'
|
|
57
|
+
import { cn } from '../../../lib/utils'
|
|
58
|
+
|
|
59
|
+
// ---------------------------------------------------------------------------
|
|
60
|
+
// Portal container context
|
|
61
|
+
// ---------------------------------------------------------------------------
|
|
62
|
+
|
|
63
|
+
const TooltipPortalContainerContext = createContext<HTMLElement | null>(null)
|
|
64
|
+
|
|
65
|
+
function TooltipPortalContainer({ value, children }: { value: HTMLElement | null; children: ReactNode }) {
|
|
66
|
+
return <TooltipPortalContainerContext.Provider value={value}>{children}</TooltipPortalContainerContext.Provider>
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
// ---------------------------------------------------------------------------
|
|
70
|
+
// Provider
|
|
71
|
+
// ---------------------------------------------------------------------------
|
|
72
|
+
|
|
73
|
+
const DEFAULT_DELAY = 200
|
|
74
|
+
const DEFAULT_TIMEOUT = 300
|
|
75
|
+
|
|
76
|
+
// Tracks whether an app-level <TooltipProvider> is above us. Each Tooltip
|
|
77
|
+
// only wraps itself in a local primitive Provider when there isn't one —
|
|
78
|
+
// a per-instance Provider would defeat cross-tooltip skip-delay grouping
|
|
79
|
+
// (moving between adjacent tooltips would re-wait the full delay).
|
|
80
|
+
const TooltipGroupContext = createContext(false)
|
|
81
|
+
|
|
82
|
+
interface TooltipProviderProps {
|
|
83
|
+
children: ReactNode
|
|
84
|
+
/** Hover delay before tooltips open, in ms. Defaults to 200. */
|
|
85
|
+
delay?: number
|
|
86
|
+
/** Delay before a tooltip closes once the pointer leaves, in ms. Defaults to 0. */
|
|
87
|
+
closeDelay?: number
|
|
88
|
+
/** After a tooltip closes, adjacent tooltips opened within this window
|
|
89
|
+
* skip the hover delay, in ms. Defaults to 300. */
|
|
90
|
+
timeout?: number
|
|
91
|
+
/** Radix name for `delay`; `delay` wins when both are set. */
|
|
92
|
+
delayDuration?: number
|
|
93
|
+
/** Radix name for `timeout`; `timeout` wins when both are set. A negative
|
|
94
|
+
* value, as some Radix configs use to turn the skip off, counts as 0. */
|
|
95
|
+
skipDelayDuration?: number
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/** Groups descendant Tooltips so that once one opens, moving to an adjacent
|
|
99
|
+
* trigger shows its tooltip instantly instead of re-waiting the full delay.
|
|
100
|
+
* Wrap once at the app (or section) level; bare Tooltips still work without
|
|
101
|
+
* it via a per-instance fallback. Takes Base UI's `delay` / `closeDelay` /
|
|
102
|
+
* `timeout`, or Radix's `delayDuration` / `skipDelayDuration`, so a Radix
|
|
103
|
+
* provider config can be spread into it. */
|
|
104
|
+
function TooltipProvider({
|
|
105
|
+
children,
|
|
106
|
+
delay,
|
|
107
|
+
closeDelay,
|
|
108
|
+
timeout,
|
|
109
|
+
delayDuration,
|
|
110
|
+
skipDelayDuration,
|
|
111
|
+
}: TooltipProviderProps) {
|
|
112
|
+
return (
|
|
113
|
+
<TooltipGroupContext.Provider value={true}>
|
|
114
|
+
<TooltipPrimitive.Provider
|
|
115
|
+
delay={delay ?? delayDuration ?? DEFAULT_DELAY}
|
|
116
|
+
closeDelay={closeDelay}
|
|
117
|
+
timeout={Math.max(0, timeout ?? skipDelayDuration ?? DEFAULT_TIMEOUT)}
|
|
118
|
+
>
|
|
119
|
+
{children}
|
|
120
|
+
</TooltipPrimitive.Provider>
|
|
121
|
+
</TooltipGroupContext.Provider>
|
|
122
|
+
)
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
// ---------------------------------------------------------------------------
|
|
126
|
+
// Root state, shared by the trigger and the content
|
|
127
|
+
// ---------------------------------------------------------------------------
|
|
128
|
+
|
|
129
|
+
type TooltipSide = 'top' | 'right' | 'bottom' | 'left'
|
|
130
|
+
type TooltipAlign = 'start' | 'center' | 'end'
|
|
131
|
+
|
|
132
|
+
interface TooltipState {
|
|
133
|
+
open: boolean
|
|
134
|
+
origin: RefObject<MorphOrigin>
|
|
135
|
+
// Set when Base UI closed this tooltip to hand off to a grouped neighbour.
|
|
136
|
+
handedOff: MutableRefObject<boolean>
|
|
137
|
+
delay?: number
|
|
138
|
+
closeDelay?: number
|
|
139
|
+
followCursor?: 'x' | 'y'
|
|
140
|
+
followOffset: MotionValue<number>
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
const TooltipStateContext = createContext<TooltipState | null>(null)
|
|
144
|
+
|
|
145
|
+
function useTooltipState(part: string) {
|
|
146
|
+
const state = useContext(TooltipStateContext)
|
|
147
|
+
if (!state) throw new Error(`${part} must be used inside a Tooltip (or Tooltip.Root).`)
|
|
148
|
+
return state
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
interface TooltipRootProps {
|
|
152
|
+
/** Controlled open state. While set, hover and focus only report through `onOpenChange`. */
|
|
153
|
+
open?: boolean
|
|
154
|
+
/** Initial open state, for an uncontrolled tooltip. Defaults to `false`. */
|
|
155
|
+
defaultOpen?: boolean
|
|
156
|
+
/** Called when hover, focus or Escape would open or close the tooltip. */
|
|
157
|
+
onOpenChange?: (open: boolean) => void
|
|
158
|
+
/** Hover delay before this tooltip opens, in ms. Defaults to the surrounding TooltipProvider's, else 200. */
|
|
159
|
+
delay?: number
|
|
160
|
+
/** Radix name for `delay`. */
|
|
161
|
+
delayDuration?: number
|
|
162
|
+
/** Delay before it closes once the pointer leaves, in ms. Defaults to the surrounding TooltipProvider's, else 0. */
|
|
163
|
+
closeDelay?: number
|
|
164
|
+
/** Follow the cursor along one axis while hovering the trigger (see Tooltip's `followCursor`). */
|
|
165
|
+
followCursor?: 'x' | 'y'
|
|
166
|
+
/** A `Tooltip.Trigger` and a `Tooltip.Content`. */
|
|
167
|
+
children?: ReactNode
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
/** The state of one compound tooltip: open state, what opened it, the delays and the cursor axis. */
|
|
171
|
+
function TooltipRoot({
|
|
172
|
+
open: openProp,
|
|
173
|
+
defaultOpen = false,
|
|
174
|
+
onOpenChange,
|
|
175
|
+
delay: delayProp,
|
|
176
|
+
delayDuration,
|
|
177
|
+
closeDelay,
|
|
178
|
+
followCursor,
|
|
179
|
+
children,
|
|
180
|
+
}: TooltipRootProps) {
|
|
181
|
+
// Not useControllableState: a forced `open` is an override, and the
|
|
182
|
+
// tooltip's own hover state resumes from where it was once it is lifted.
|
|
183
|
+
const [internalOpen, setInternalOpen] = useState(defaultOpen)
|
|
184
|
+
const open = openProp ?? internalOpen
|
|
185
|
+
const hasAmbientProvider = useContext(TooltipGroupContext)
|
|
186
|
+
const { origin, capture } = useMorphOrigin()
|
|
187
|
+
const handedOff = useRef(false)
|
|
188
|
+
const delay = delayProp ?? delayDuration
|
|
189
|
+
|
|
190
|
+
// Cursor-follow offset from the trigger's center, driven as a motion value
|
|
191
|
+
// so per-move updates skip React re-renders.
|
|
192
|
+
const followOffset = useMotionValue(0)
|
|
193
|
+
// A force-opened follow-cursor tooltip has no cursor to follow — it rests
|
|
194
|
+
// centered on the trigger until a real pointer takes over.
|
|
195
|
+
useEffect(() => {
|
|
196
|
+
if (openProp && followCursor) followOffset.set(0)
|
|
197
|
+
}, [openProp, followCursor, followOffset])
|
|
198
|
+
|
|
199
|
+
const state = useMemo<TooltipState>(
|
|
200
|
+
() => ({ open, origin, handedOff, delay, closeDelay, followCursor, followOffset }),
|
|
201
|
+
[open, origin, delay, closeDelay, followCursor, followOffset],
|
|
202
|
+
)
|
|
203
|
+
|
|
204
|
+
const root = (
|
|
205
|
+
<TooltipStateContext.Provider value={state}>
|
|
206
|
+
<TooltipPrimitive.Root
|
|
207
|
+
open={open}
|
|
208
|
+
onOpenChange={(next, details) => {
|
|
209
|
+
if (next) capture(details)
|
|
210
|
+
// Base UI's hand-off between grouped tooltips: the next one shows in
|
|
211
|
+
// place (its popup carries `data-instant="delay"`) and the last one,
|
|
212
|
+
// closed with reason `none`, goes at once.
|
|
213
|
+
handedOff.current = !next && details.reason === 'none'
|
|
214
|
+
setInternalOpen(next)
|
|
215
|
+
onOpenChange?.(next)
|
|
216
|
+
}}
|
|
217
|
+
>
|
|
218
|
+
{children}
|
|
219
|
+
</TooltipPrimitive.Root>
|
|
220
|
+
</TooltipStateContext.Provider>
|
|
221
|
+
)
|
|
222
|
+
|
|
223
|
+
// Fallback: without an ambient TooltipProvider, give this instance its own
|
|
224
|
+
// so a bare tooltip keeps the library's default delay. Grouped skip-delay
|
|
225
|
+
// needs the shared app-level TooltipProvider.
|
|
226
|
+
if (hasAmbientProvider) return root
|
|
227
|
+
|
|
228
|
+
return <TooltipPrimitive.Provider delay={delay ?? DEFAULT_DELAY}>{root}</TooltipPrimitive.Provider>
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
// ---------------------------------------------------------------------------
|
|
232
|
+
// Trigger
|
|
233
|
+
// ---------------------------------------------------------------------------
|
|
234
|
+
|
|
235
|
+
type TooltipTriggerProps = SlotProps
|
|
236
|
+
|
|
237
|
+
/** The element the tooltip describes: `render={<Button/>}`, Radix-style `asChild`, or a plain button around `children`. */
|
|
238
|
+
const TooltipTrigger = forwardRef<HTMLButtonElement, TooltipTriggerProps>(
|
|
239
|
+
({ render, asChild, children, onPointerMove, ...props }, ref) => {
|
|
240
|
+
const { delay, closeDelay, followCursor, followOffset } = useTooltipState('Tooltip.Trigger')
|
|
241
|
+
const el = slotRender(render, asChild, children)
|
|
242
|
+
|
|
243
|
+
const handleMove = (event: React.PointerEvent<HTMLButtonElement>) => {
|
|
244
|
+
onPointerMove?.(event)
|
|
245
|
+
if (!followCursor) return
|
|
246
|
+
const rect = event.currentTarget.getBoundingClientRect()
|
|
247
|
+
followOffset.set(
|
|
248
|
+
followCursor === 'y'
|
|
249
|
+
? event.clientY - (rect.top + rect.height / 2)
|
|
250
|
+
: event.clientX - (rect.left + rect.width / 2),
|
|
251
|
+
)
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
// An explicit delay overrides the ambient provider's; left undefined, the
|
|
255
|
+
// trigger inherits it from the provider.
|
|
256
|
+
const shared = { ref, delay, closeDelay, onPointerMove: followCursor ? handleMove : onPointerMove, ...props }
|
|
257
|
+
return el ? (
|
|
258
|
+
<TooltipPrimitive.Trigger {...shared} render={el} />
|
|
259
|
+
) : (
|
|
260
|
+
<TooltipPrimitive.Trigger {...shared}>{children}</TooltipPrimitive.Trigger>
|
|
261
|
+
)
|
|
262
|
+
},
|
|
263
|
+
)
|
|
264
|
+
TooltipTrigger.displayName = 'TooltipTrigger'
|
|
265
|
+
|
|
266
|
+
// ---------------------------------------------------------------------------
|
|
267
|
+
// Content
|
|
268
|
+
// ---------------------------------------------------------------------------
|
|
269
|
+
|
|
270
|
+
interface TooltipContentProps extends Omit<HTMLAttributes<HTMLDivElement>, 'children' | 'className'> {
|
|
271
|
+
/** The label. */
|
|
272
|
+
children?: ReactNode
|
|
273
|
+
/** An element to render the label as, inside the inverted surface; the label goes inside it. */
|
|
274
|
+
render?: ReactElement
|
|
275
|
+
/** Radix-style: the single child element is the label, rendered as-is inside the surface. Defaults to `false`. */
|
|
276
|
+
asChild?: boolean
|
|
277
|
+
/** Preferred side of the trigger; flips when it would collide with the viewport edge. Defaults to `"top"`. */
|
|
278
|
+
side?: TooltipSide
|
|
279
|
+
/** Alignment against the trigger along that side. Defaults to `"center"`. */
|
|
280
|
+
align?: TooltipAlign
|
|
281
|
+
/** Distance in pixels between the tooltip and the trigger. Defaults to `8`. */
|
|
282
|
+
sideOffset?: number
|
|
283
|
+
/** Shift in pixels along the alignment axis. Defaults to `0`. */
|
|
284
|
+
alignOffset?: number
|
|
285
|
+
/** Classes for the label's surface. */
|
|
286
|
+
className?: string
|
|
287
|
+
/** Classes for the portalled positioner — a z utility here lifts the tooltip above other fixed layers (default z-50). */
|
|
288
|
+
positionerClassName?: string
|
|
289
|
+
/** Where the label grows from (see Morph): the trigger, the pointer, its own center, a viewport edge, or a ref to any element. Defaults to `'trigger'`. */
|
|
290
|
+
from?: 'trigger' | 'pointer' | 'center' | 'top' | 'right' | 'bottom' | 'left' | RefObject<HTMLElement | null>
|
|
291
|
+
/** How it grows (see Morph): with the liquid goo neck, a plain morph, a slide or a fade. `followCursor` tooltips always fade. Defaults to `'goo'`. */
|
|
292
|
+
effect?: 'goo' | 'morph' | 'slide' | 'fade'
|
|
293
|
+
/** Spring tier of a plain morph, slide or fade; goo runs on its own `spring.goo`. Defaults to `'moderate'`. */
|
|
294
|
+
tier?: 'moderate' | 'slow'
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
/** The inverted label, portalled and positioned next to the trigger, grown out of it through the morph. */
|
|
298
|
+
const TooltipContent = forwardRef<HTMLDivElement, TooltipContentProps>(
|
|
299
|
+
(
|
|
300
|
+
{
|
|
301
|
+
children,
|
|
302
|
+
side = 'top',
|
|
303
|
+
align = 'center',
|
|
304
|
+
sideOffset = 8,
|
|
305
|
+
alignOffset = 0,
|
|
306
|
+
className,
|
|
307
|
+
positionerClassName,
|
|
308
|
+
from,
|
|
309
|
+
effect = 'goo',
|
|
310
|
+
tier = 'moderate',
|
|
311
|
+
render,
|
|
312
|
+
asChild,
|
|
313
|
+
style,
|
|
314
|
+
...props
|
|
315
|
+
},
|
|
316
|
+
ref,
|
|
317
|
+
) => {
|
|
318
|
+
const { open, origin, handedOff, followCursor, followOffset } = useTooltipState('Tooltip.Content')
|
|
319
|
+
const shape = useShape()
|
|
320
|
+
const portalContainer = useContext(TooltipPortalContainerContext)
|
|
321
|
+
const morph = useMorph(open, origin, {
|
|
322
|
+
from,
|
|
323
|
+
effect: followCursor ? 'fade' : effect,
|
|
324
|
+
tier,
|
|
325
|
+
instant: popup => handedOff.current || popup.dataset.instant === 'delay',
|
|
326
|
+
})
|
|
327
|
+
useImperativeHandle(ref, () => morph.popup as HTMLDivElement, [morph.popup])
|
|
328
|
+
const label = render
|
|
329
|
+
? children === undefined
|
|
330
|
+
? render
|
|
331
|
+
: cloneElement(render, undefined, children)
|
|
332
|
+
: (slotRender(undefined, asChild, children) ?? children)
|
|
333
|
+
|
|
334
|
+
return (
|
|
335
|
+
<TooltipPrimitive.Portal container={portalContainer ?? undefined}>
|
|
336
|
+
<TooltipPrimitive.Positioner
|
|
337
|
+
side={side}
|
|
338
|
+
align={align}
|
|
339
|
+
sideOffset={sideOffset}
|
|
340
|
+
alignOffset={alignOffset}
|
|
341
|
+
className={cn('z-50', positionerClassName)}
|
|
342
|
+
>
|
|
343
|
+
{/* Other props (id, data-*, aria-*, handlers) land on the popup. */}
|
|
344
|
+
<TooltipPrimitive.Popup
|
|
345
|
+
{...props}
|
|
346
|
+
ref={morph.popupRef}
|
|
347
|
+
className="relative outline-none"
|
|
348
|
+
render={<motion.div style={{ ...style, ...(followCursor ? { [followCursor]: followOffset } : {}) }} />}
|
|
349
|
+
>
|
|
350
|
+
<MorphSurface
|
|
351
|
+
morph={morph}
|
|
352
|
+
bg="bg-foreground"
|
|
353
|
+
radius={shape.bg}
|
|
354
|
+
className={cn(
|
|
355
|
+
// Trim recenters the label; the padding bump only applies
|
|
356
|
+
// where text-box is supported, keeping the same overall
|
|
357
|
+
// height (~26px) as untrimmed browsers.
|
|
358
|
+
'text-background text-caption px-2 py-1',
|
|
359
|
+
'[text-box:trim-both_cap_alphabetic] supports-[text-box:trim-both]:py-2',
|
|
360
|
+
'weight-medium',
|
|
361
|
+
className,
|
|
362
|
+
)}
|
|
363
|
+
>
|
|
364
|
+
{label}
|
|
365
|
+
</MorphSurface>
|
|
366
|
+
</TooltipPrimitive.Popup>
|
|
367
|
+
</TooltipPrimitive.Positioner>
|
|
368
|
+
</TooltipPrimitive.Portal>
|
|
369
|
+
)
|
|
370
|
+
},
|
|
371
|
+
)
|
|
372
|
+
TooltipContent.displayName = 'TooltipContent'
|
|
373
|
+
|
|
374
|
+
// ---------------------------------------------------------------------------
|
|
375
|
+
// Tooltip
|
|
376
|
+
// ---------------------------------------------------------------------------
|
|
377
|
+
|
|
378
|
+
interface TooltipProps {
|
|
379
|
+
/** The content displayed inside the tooltip. Leave it out to use `Tooltip` as the root of a compound tooltip (`Tooltip.Trigger` + `Tooltip.Content` inside). */
|
|
380
|
+
content?: ReactNode
|
|
381
|
+
/** The trigger element, which must accept a ref; or, without `content`, the compound parts. */
|
|
382
|
+
children?: ReactNode
|
|
383
|
+
/** Preferred side of the trigger to render the tooltip on. Defaults to `"top"`. */
|
|
384
|
+
side?: TooltipSide
|
|
385
|
+
/** Alignment against the trigger along that side. Defaults to `"center"`. */
|
|
386
|
+
align?: TooltipAlign
|
|
387
|
+
/** Distance in pixels between the tooltip and the trigger. Defaults to `8`. */
|
|
388
|
+
sideOffset?: number
|
|
389
|
+
/** Hover delay before this tooltip opens, in ms. Defaults to 200, or to the ambient TooltipProvider's delay when one is present. */
|
|
390
|
+
delayDuration?: number
|
|
391
|
+
/** Base UI name for `delayDuration`. */
|
|
392
|
+
delay?: number
|
|
393
|
+
/** Delay before it closes once the pointer leaves, in ms. Defaults to the ambient TooltipProvider's, else 0. */
|
|
394
|
+
closeDelay?: number
|
|
395
|
+
/** Additional classes applied to the tooltip content container. */
|
|
396
|
+
className?: string
|
|
397
|
+
/** Extra classes for the portalled positioner element — pass a z utility here to lift the whole tooltip above other fixed layers (default z-50). */
|
|
398
|
+
contentClassName?: string
|
|
399
|
+
/** When true, forces the tooltip open. When false, forces it closed. When undefined, uses default hover/focus behavior. */
|
|
400
|
+
forceOpen?: boolean
|
|
401
|
+
/** Controlled open state, the Radix spelling of `forceOpen`. */
|
|
402
|
+
open?: boolean
|
|
403
|
+
/** Initial open state, for an uncontrolled tooltip. Defaults to `false`. */
|
|
404
|
+
defaultOpen?: boolean
|
|
405
|
+
/** Follow the cursor along one axis while hovering the trigger — for tall or wide triggers (the Sidebar rail) where a centered tooltip sits far from the pointer. The other axis stays anchored by `side`. */
|
|
406
|
+
followCursor?: 'x' | 'y'
|
|
407
|
+
/** Called when the tooltip's internal open state changes (before forceOpen is applied). */
|
|
408
|
+
onOpenChange?: (open: boolean) => void
|
|
409
|
+
/** Where the label grows from (see Morph): the trigger, the pointer, its own center, a viewport edge, or a ref to any element. Defaults to `'trigger'`. */
|
|
410
|
+
from?: 'trigger' | 'pointer' | 'center' | 'top' | 'right' | 'bottom' | 'left' | RefObject<HTMLElement | null>
|
|
411
|
+
/** How it grows (see Morph): with the liquid goo neck, a plain morph, a slide or a fade. `followCursor` tooltips always fade. Defaults to `'goo'`. */
|
|
412
|
+
effect?: 'goo' | 'morph' | 'slide' | 'fade'
|
|
413
|
+
/** Spring tier of a plain morph, slide or fade; goo runs on its own `spring.goo`. Defaults to `'moderate'`. */
|
|
414
|
+
tier?: 'moderate' | 'slow'
|
|
415
|
+
}
|
|
416
|
+
|
|
417
|
+
/**
|
|
418
|
+
* Floating tooltip with spring-based animations, configurable placement, and
|
|
419
|
+
* rich content support.
|
|
420
|
+
*
|
|
421
|
+
* The trigger is whatever element you pass as the single child — it only has
|
|
422
|
+
* to accept a ref. The label is portalled and grows out of its trigger
|
|
423
|
+
* through the shared morph (see Morph), with the goo neck by default on
|
|
424
|
+
* `spring.goo`, and flips when it would collide with the viewport edge.
|
|
425
|
+
* `followCursor` tracks the pointer along one axis for tall or wide triggers,
|
|
426
|
+
* while the other stays anchored by `side`. Built on Base UI's Tooltip.
|
|
427
|
+
*
|
|
428
|
+
* Leave `content` out and `Tooltip` becomes the root of a compound tooltip:
|
|
429
|
+
* a `Tooltip.Trigger` and a `Tooltip.Content` inside it, the shape Radix
|
|
430
|
+
* code is written in. The label looks and moves the same either way.
|
|
431
|
+
*
|
|
432
|
+
* Statics:
|
|
433
|
+
* - `Tooltip.Root` — `TooltipRoot`: the compound root on its own: `open`,
|
|
434
|
+
* `defaultOpen`, `onOpenChange`, `delay` (or `delayDuration`),
|
|
435
|
+
* `closeDelay`, `followCursor`.
|
|
436
|
+
* - `Tooltip.Trigger` — `TooltipTrigger`: the described element,
|
|
437
|
+
* `render={<Button/>}` or Radix-style `asChild`.
|
|
438
|
+
* - `Tooltip.Content` — `TooltipContent`: the label: `side`, `align`,
|
|
439
|
+
* `sideOffset`, `alignOffset`, `positionerClassName`, the morph options
|
|
440
|
+
* `from`, `effect`, `tier`, and `render` or Radix-style `asChild` for the
|
|
441
|
+
* label's own element; other props land on the popup.
|
|
442
|
+
* - `Tooltip.Provider` — `TooltipProvider`: groups tooltips so moving from
|
|
443
|
+
* one trigger to an adjacent one skips the hover delay, and the morph: the
|
|
444
|
+
* next label shows in place. `delay`, `closeDelay`, `timeout`, or Radix's
|
|
445
|
+
* `delayDuration` and `skipDelayDuration`.
|
|
446
|
+
* - `Tooltip.PortalContainer` — `TooltipPortalContainer`: portal every
|
|
447
|
+
* descendant tooltip into a given element instead of the body.
|
|
448
|
+
*
|
|
449
|
+
* @example {@include ./examples.mdx}
|
|
450
|
+
*/
|
|
451
|
+
function Tooltip({
|
|
452
|
+
content,
|
|
453
|
+
children,
|
|
454
|
+
side,
|
|
455
|
+
align,
|
|
456
|
+
sideOffset,
|
|
457
|
+
delayDuration,
|
|
458
|
+
delay,
|
|
459
|
+
closeDelay,
|
|
460
|
+
className,
|
|
461
|
+
contentClassName,
|
|
462
|
+
forceOpen,
|
|
463
|
+
open,
|
|
464
|
+
defaultOpen,
|
|
465
|
+
onOpenChange,
|
|
466
|
+
followCursor,
|
|
467
|
+
from,
|
|
468
|
+
effect,
|
|
469
|
+
tier,
|
|
470
|
+
}: TooltipProps) {
|
|
471
|
+
const root = {
|
|
472
|
+
open: forceOpen ?? open,
|
|
473
|
+
defaultOpen,
|
|
474
|
+
onOpenChange,
|
|
475
|
+
delay: delay ?? delayDuration,
|
|
476
|
+
closeDelay,
|
|
477
|
+
followCursor,
|
|
478
|
+
}
|
|
479
|
+
if (content === undefined) return <TooltipRoot {...root}>{children}</TooltipRoot>
|
|
480
|
+
|
|
481
|
+
return (
|
|
482
|
+
<TooltipRoot {...root}>
|
|
483
|
+
<TooltipTrigger render={children as ReactElement} />
|
|
484
|
+
<TooltipContent
|
|
485
|
+
side={side}
|
|
486
|
+
align={align}
|
|
487
|
+
sideOffset={sideOffset}
|
|
488
|
+
className={className}
|
|
489
|
+
positionerClassName={contentClassName}
|
|
490
|
+
from={from}
|
|
491
|
+
effect={effect}
|
|
492
|
+
tier={tier}
|
|
493
|
+
>
|
|
494
|
+
{content}
|
|
495
|
+
</TooltipContent>
|
|
496
|
+
</TooltipRoot>
|
|
497
|
+
)
|
|
498
|
+
}
|
|
499
|
+
|
|
500
|
+
/* Compound members: the parts, the provider and the portal-container scope
|
|
501
|
+
hang off Tooltip as attributes, so examples read `<Tooltip.Provider>`. */
|
|
502
|
+
Tooltip.Root = TooltipRoot
|
|
503
|
+
Tooltip.Trigger = TooltipTrigger
|
|
504
|
+
Tooltip.Content = TooltipContent
|
|
505
|
+
Tooltip.Provider = TooltipProvider
|
|
506
|
+
Tooltip.PortalContainer = TooltipPortalContainer
|
|
507
|
+
|
|
508
|
+
export type {
|
|
509
|
+
TooltipAlign,
|
|
510
|
+
TooltipContentProps,
|
|
511
|
+
TooltipProps,
|
|
512
|
+
TooltipProviderProps,
|
|
513
|
+
TooltipRootProps,
|
|
514
|
+
TooltipSide,
|
|
515
|
+
TooltipTriggerProps,
|
|
516
|
+
}
|
|
517
|
+
export { Tooltip, TooltipContent, TooltipPortalContainer, TooltipProvider, TooltipRoot, TooltipTrigger }
|
|
518
|
+
|
|
519
|
+
export default Tooltip
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import Progress from './index'
|
|
2
|
+
import StepDemo from './step-demo'
|
|
3
|
+
import Button from '../button'
|
|
4
|
+
import SizeProvider from '../../primitives/sizes'
|
|
5
|
+
|
|
6
|
+
# Determinate
|
|
7
|
+
|
|
8
|
+
`value` between `min` and `max` (0 and 100 by default). `label` names the bar; `showValue` prints the amount beside it.
|
|
9
|
+
|
|
10
|
+
<div className="flex w-80 flex-col gap-6">
|
|
11
|
+
<Progress value={40} label="Uploading report.pdf" showValue />
|
|
12
|
+
<Progress value={100} label="Synced" showValue />
|
|
13
|
+
<Progress value={12} aria-label="Storage used" />
|
|
14
|
+
</div>
|
|
15
|
+
|
|
16
|
+
# The fill slides
|
|
17
|
+
|
|
18
|
+
Press Step. The fill slides to the new amount on the indicator spring instead of stretching, so its rounded end keeps its shape. `StepDemo` is a docs stage: a Progress whose `value` steps through `values` on each press.
|
|
19
|
+
|
|
20
|
+
<StepDemo values={[10, 35, 60, 90, 100, 0]} label="Importing contacts" showValue />
|
|
21
|
+
|
|
22
|
+
# Indeterminate
|
|
23
|
+
|
|
24
|
+
`value={null}` (the default) when nobody knows how far along it is: a segment sweeps the track. Under reduced motion it breathes in place.
|
|
25
|
+
|
|
26
|
+
<div className="flex w-80 flex-col gap-6">
|
|
27
|
+
<Progress label="Preparing export" />
|
|
28
|
+
<Progress aria-label="Loading" />
|
|
29
|
+
</div>
|
|
30
|
+
|
|
31
|
+
# Along an edge
|
|
32
|
+
|
|
33
|
+
Positioned along the top of a region, the bar is a loading line for everything under it.
|
|
34
|
+
|
|
35
|
+
<div className="relative w-80 overflow-hidden rounded-xl border border-border p-4">
|
|
36
|
+
<Progress aria-label="Loading results" className="absolute inset-x-0 top-0" />
|
|
37
|
+
<span className="text-body text-muted-foreground">Results are on their way.</span>
|
|
38
|
+
</div>
|
|
39
|
+
|
|
40
|
+
# Spinner
|
|
41
|
+
|
|
42
|
+
`Progress.Spinner` is the same wait in a small space: the loading glyph of Button, one control tall. It follows the size ladder, and `className` sizes it off the ladder.
|
|
43
|
+
|
|
44
|
+
<div className="flex flex-col gap-3">
|
|
45
|
+
<div className="flex items-center gap-3">
|
|
46
|
+
<Progress.Spinner />
|
|
47
|
+
<Progress.Spinner size="compact" />
|
|
48
|
+
<span className="inline-flex items-center gap-1 text-body text-muted-foreground">
|
|
49
|
+
<Progress.Spinner className="size-6" label="Saving" />
|
|
50
|
+
Saving
|
|
51
|
+
</span>
|
|
52
|
+
</div>
|
|
53
|
+
<SizeProvider size="compact">
|
|
54
|
+
<div className="flex items-center gap-2">
|
|
55
|
+
<Progress.Spinner />
|
|
56
|
+
<Button variant="tertiary" loading>Saving</Button>
|
|
57
|
+
</div>
|
|
58
|
+
</SizeProvider>
|
|
59
|
+
</div>
|