@justanarthur/modo-ui 0.6.0-canary.9 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +197 -643
- package/blocks/sidebar-app/examples.mdx +2 -2
- package/blocks/sidebar-app/index.tsx +20 -7
- package/blocks/sidebar-app/inset-topbar.tsx +3 -8
- package/blocks/sidebar-app/menu-grid.ts +8 -18
- package/blocks/sidebar-app/nav-data.ts +1 -1
- package/blocks/sidebar-app/search-field.tsx +8 -15
- package/blocks/sidebar-app/thread-page.tsx +58 -0
- package/blocks/sidebar-app/user-footer.tsx +8 -15
- package/blocks/sidebar-app/workspace-header.tsx +9 -28
- package/components/AI/input-message/examples.mdx +37 -33
- package/components/AI/input-message/file-preview-tile.tsx +59 -0
- package/components/AI/input-message/file-thumbnail.tsx +26 -53
- package/components/AI/input-message/index.tsx +362 -1122
- package/components/AI/input-message/input-message.css +25 -0
- package/components/AI/input-message/queued-row.tsx +102 -0
- package/components/AI/input-message/shared.ts +38 -0
- package/components/AI/input-message/suggestion-row.tsx +64 -0
- package/components/AI/input-message/use-composer-files.ts +142 -0
- package/components/AI/input-message/use-history-nav.ts +60 -0
- package/components/AI/input-message/use-message-queue.ts +108 -0
- package/components/AI/input-message/use-region-height.ts +34 -0
- package/components/AI/thinking-indicator/index.tsx +9 -31
- package/components/accordion/accordion-content.tsx +217 -0
- package/components/accordion/accordion-context.tsx +118 -0
- package/components/accordion/accordion-group.tsx +215 -0
- package/components/accordion/examples.mdx +64 -132
- package/components/accordion/index.tsx +127 -891
- package/components/avatar/examples.mdx +2 -2
- package/components/avatar/index.tsx +40 -34
- package/components/badge/change-demo.tsx +2 -0
- package/components/badge/examples.mdx +16 -34
- package/components/badge/index.tsx +31 -69
- package/components/badge/variants.ts +5 -30
- package/components/button/examples.mdx +79 -94
- package/components/button/index.tsx +97 -188
- package/components/button/loading-demo.tsx +2 -0
- package/components/button/variants.ts +12 -117
- package/components/card/card-group.tsx +184 -0
- package/components/card/card-media.tsx +207 -0
- package/components/card/card-parts.tsx +179 -0
- package/components/card/examples.mdx +91 -143
- package/components/card/index.tsx +190 -881
- package/components/copy/examples.mdx +29 -67
- package/components/copy/index.tsx +58 -285
- package/components/inputs/checkbox/examples.mdx +22 -39
- package/components/inputs/checkbox/index.tsx +103 -255
- package/components/inputs/checkbox/select-all-demo.tsx +8 -6
- package/components/inputs/color-picker/channel-sliders.tsx +70 -0
- package/components/inputs/color-picker/color-input.tsx +387 -0
- package/components/inputs/color-picker/{variants.ts → color-math.ts} +22 -57
- package/components/inputs/color-picker/context.ts +11 -0
- package/components/inputs/color-picker/examples.mdx +20 -59
- package/components/inputs/color-picker/format-menu.tsx +212 -0
- package/components/inputs/color-picker/index.tsx +190 -1776
- package/components/inputs/color-picker/inputs-row.tsx +196 -0
- package/components/inputs/color-picker/popover.tsx +161 -0
- package/components/inputs/color-picker/saturation-square.tsx +167 -0
- package/components/inputs/color-picker/swatches.tsx +178 -0
- package/components/inputs/combobox/context.ts +90 -0
- package/components/inputs/combobox/examples.mdx +103 -206
- package/components/inputs/combobox/fields.tsx +328 -0
- package/components/inputs/combobox/index.tsx +155 -1310
- package/components/inputs/combobox/list.tsx +415 -0
- package/components/inputs/combobox/remote-demo.tsx +70 -74
- package/components/inputs/date-time/calendar/examples.mdx +0 -11
- package/components/inputs/date-time/calendar/index.tsx +32 -59
- package/components/inputs/date-time/calendar/use-month-window.ts +35 -32
- package/components/inputs/date-time/date-picker/examples.mdx +59 -155
- package/components/inputs/date-time/date-picker/index.tsx +186 -370
- package/components/inputs/date-time/date-picker/masked-date-input.tsx +105 -247
- package/components/inputs/date-time/date-range-picker/examples.mdx +6 -62
- package/components/inputs/date-time/date-range-picker/index.tsx +105 -404
- package/components/inputs/date-time/date-value.ts +37 -0
- package/components/inputs/date-time/day-rules.ts +22 -0
- package/components/inputs/date-time/duration-picker/examples.mdx +0 -24
- package/components/inputs/date-time/duration-picker/index.tsx +50 -140
- package/components/inputs/date-time/month-picker/examples.mdx +0 -29
- package/components/inputs/date-time/month-picker/index.tsx +48 -132
- package/components/inputs/date-time/picker-shell.tsx +226 -347
- package/components/inputs/date-time/time-columns.tsx +11 -15
- package/components/inputs/date-time/time-picker/examples.mdx +0 -31
- package/components/inputs/date-time/time-picker/index.tsx +37 -118
- package/components/inputs/field/examples.mdx +81 -39
- package/components/inputs/field/index.tsx +113 -103
- package/components/inputs/file-dropzone/examples.mdx +23 -24
- package/components/inputs/file-dropzone/file-row.tsx +20 -21
- package/components/inputs/file-dropzone/index.tsx +130 -129
- package/components/inputs/file-dropzone/upload-demo.tsx +22 -18
- package/components/inputs/file-dropzone/variants.ts +3 -1
- package/components/inputs/input/examples.mdx +19 -74
- package/components/inputs/input/index.tsx +86 -149
- package/components/inputs/input/password-demo.tsx +5 -5
- package/components/inputs/label/examples.mdx +19 -26
- package/components/inputs/label/index.tsx +21 -34
- package/components/inputs/number-input/examples.mdx +63 -36
- package/components/inputs/number-input/index.tsx +62 -57
- package/components/inputs/radio/examples.mdx +24 -39
- package/components/inputs/radio/index.tsx +125 -328
- package/components/inputs/search/examples.mdx +3 -3
- package/components/inputs/search/index.tsx +46 -39
- package/components/inputs/select/examples.mdx +76 -167
- package/components/inputs/select/index.tsx +252 -776
- package/components/inputs/slider/comfortable.tsx +524 -0
- package/components/inputs/slider/compact.tsx +690 -0
- package/components/inputs/slider/examples.mdx +9 -35
- package/components/inputs/slider/geometry.ts +88 -0
- package/components/inputs/slider/index.tsx +65 -1796
- package/components/inputs/slider/value-display.tsx +184 -0
- package/components/inputs/switch/examples.mdx +31 -33
- package/components/inputs/switch/index.tsx +55 -107
- package/components/inputs/textarea/examples.mdx +23 -61
- package/components/inputs/textarea/index.tsx +21 -99
- package/components/navigation/navigation-menu/content.tsx +76 -0
- package/components/navigation/navigation-menu/context.ts +34 -0
- package/components/navigation/navigation-menu/examples.mdx +21 -84
- package/components/navigation/navigation-menu/index.tsx +139 -639
- package/components/navigation/navigation-menu/item.tsx +47 -0
- package/components/navigation/navigation-menu/link.tsx +104 -0
- package/components/navigation/navigation-menu/list.tsx +86 -0
- package/components/navigation/navigation-menu/trigger.tsx +78 -0
- package/components/navigation/navigation-menu/use-dom-rows.ts +56 -0
- package/components/navigation/pagination/examples.mdx +25 -34
- package/components/navigation/pagination/index.tsx +75 -153
- package/components/navigation/sidebar/examples.mdx +17 -23
- package/components/navigation/sidebar/index.tsx +59 -119
- package/components/navigation/sidebar/menu-scope.tsx +439 -0
- package/components/navigation/sidebar/row-label.tsx +61 -0
- package/components/navigation/sidebar/sidebar-context.tsx +71 -0
- package/components/navigation/sidebar/sidebar-group.tsx +299 -0
- package/components/navigation/sidebar/sidebar-menu-actions.tsx +209 -0
- package/components/navigation/sidebar/sidebar-menu-button.tsx +214 -0
- package/components/navigation/sidebar/sidebar-menu-item.tsx +207 -0
- package/components/navigation/sidebar/sidebar-menu-sub.tsx +180 -0
- package/components/navigation/sidebar/sidebar-parts.tsx +94 -0
- package/components/navigation/sidebar/sidebar-provider.tsx +248 -0
- package/components/navigation/sidebar/sidebar-rail.tsx +206 -0
- package/components/navigation/sidebar/sidebar-shell.tsx +180 -0
- package/components/navigation/sidebar/sidebar-shortcut.tsx +101 -0
- package/components/navigation/sidebar/sidebar.css +7 -11
- package/components/navigation/sidebar/use-measured-collapse.ts +62 -0
- package/components/navigation/tabs/context.ts +45 -0
- package/components/navigation/tabs/examples.mdx +63 -17
- package/components/navigation/tabs/index.tsx +82 -434
- package/components/navigation/tabs/item.tsx +161 -0
- package/components/navigation/tabs/list.tsx +143 -0
- package/components/overlays/alert-dialog/examples.mdx +2 -36
- package/components/overlays/alert-dialog/index.tsx +76 -90
- package/components/overlays/alert-dialog/pending-demo.tsx +3 -1
- package/components/overlays/command/index.tsx +28 -59
- package/components/overlays/context-menu/examples.mdx +58 -4
- package/components/overlays/context-menu/index.tsx +77 -221
- package/components/overlays/dialog/examples.mdx +8 -31
- package/components/overlays/dialog/index.tsx +81 -261
- package/components/overlays/dropdown/dropdown-search.tsx +33 -98
- package/components/overlays/dropdown/examples.mdx +77 -363
- package/components/overlays/dropdown/index.tsx +114 -1010
- package/components/overlays/dropdown/menu-item.tsx +98 -382
- package/components/overlays/dropdown/menu-popup.tsx +294 -0
- package/components/overlays/dropdown/panel-state.ts +176 -0
- package/components/overlays/dropdown/submenu.tsx +170 -0
- package/components/overlays/popover/anchored-demo.tsx +22 -13
- package/components/overlays/popover/examples.mdx +16 -65
- package/components/overlays/popover/index.tsx +93 -137
- package/components/overlays/preview-card/examples.mdx +4 -4
- package/components/overlays/preview-card/index.tsx +48 -103
- package/components/overlays/sheet/examples.mdx +0 -12
- package/components/overlays/sheet/index.tsx +44 -129
- package/components/overlays/toast/examples.mdx +33 -25
- package/components/overlays/toast/index.tsx +56 -203
- package/components/overlays/toast/manager.ts +63 -119
- package/components/overlays/tooltip/examples.mdx +6 -12
- package/components/overlays/tooltip/index.tsx +124 -264
- package/components/progress/index.tsx +24 -30
- package/components/progress/progress.css +6 -28
- package/components/progress/step-demo.tsx +2 -0
- package/components/table/context.ts +49 -0
- package/components/table/examples.mdx +40 -72
- package/components/table/head.tsx +105 -0
- package/components/table/index.tsx +73 -458
- package/components/table/parts.tsx +188 -0
- package/components/table/sort-demo.tsx +21 -30
- package/dist/base.css +141 -122
- package/dist/blocks/sidebar-app/index.d.ts +10 -2
- package/dist/blocks/sidebar-app/index.js +49 -40
- package/dist/components/AI/input-message/index.d.ts +22 -19
- package/dist/components/AI/input-message/index.js +30 -23
- package/dist/components/AI/thinking-indicator/index.d.ts +2 -0
- package/dist/components/AI/thinking-indicator/index.js +10 -9
- package/dist/components/accordion/index.d.ts +52 -85
- package/dist/components/accordion/index.js +25 -19
- package/dist/components/avatar/index.d.ts +10 -10
- package/dist/components/avatar/index.js +9 -8
- package/dist/components/badge/index.d.ts +11 -18
- package/dist/components/badge/index.js +9 -9
- package/dist/components/badge/variants.d.ts +2 -9
- package/dist/components/badge/variants.js +3 -5
- package/dist/components/button/index.d.ts +36 -60
- package/dist/components/button/index.js +12 -9
- package/dist/components/button/variants.d.ts +3 -34
- package/dist/components/button/variants.js +2 -4
- package/dist/components/card/index.d.ts +163 -108
- package/dist/components/card/index.js +30 -21
- package/dist/components/copy/index.d.ts +10 -41
- package/dist/components/copy/index.js +18 -15
- package/dist/components/inputs/checkbox/index.d.ts +25 -25
- package/dist/components/inputs/checkbox/index.js +22 -18
- package/dist/components/inputs/color-picker/index.d.ts +65 -53
- package/dist/components/inputs/color-picker/index.js +35 -29
- package/dist/components/inputs/combobox/index.d.ts +147 -152
- package/dist/components/inputs/combobox/index.js +31 -29
- package/dist/components/inputs/date-time/calendar/index.d.ts +18 -24
- package/dist/components/inputs/date-time/calendar/index.js +17 -15
- package/dist/components/inputs/date-time/date-picker/index.d.ts +52 -96
- package/dist/components/inputs/date-time/date-picker/index.js +42 -35
- package/dist/components/inputs/date-time/date-range-picker/index.d.ts +48 -108
- package/dist/components/inputs/date-time/date-range-picker/index.js +40 -35
- package/dist/components/inputs/date-time/duration-picker/index.d.ts +21 -67
- package/dist/components/inputs/date-time/duration-picker/index.js +39 -33
- package/dist/components/inputs/date-time/month-picker/index.d.ts +18 -61
- package/dist/components/inputs/date-time/month-picker/index.js +38 -32
- package/dist/components/inputs/date-time/time-picker/index.d.ts +18 -59
- package/dist/components/inputs/date-time/time-picker/index.js +39 -33
- package/dist/components/inputs/field/index.d.ts +37 -41
- package/dist/components/inputs/field/index.js +13 -14
- package/dist/components/inputs/file-dropzone/index.d.ts +32 -25
- package/dist/components/inputs/file-dropzone/index.js +18 -15
- package/dist/components/inputs/file-dropzone/variants.js +1 -1
- package/dist/components/inputs/input/index.d.ts +48 -50
- package/dist/components/inputs/input/index.js +14 -12
- package/dist/components/inputs/label/index.d.ts +12 -10
- package/dist/components/inputs/label/index.js +5 -4
- package/dist/components/inputs/number-input/index.d.ts +31 -23
- package/dist/components/inputs/number-input/index.js +16 -14
- package/dist/components/inputs/radio/index.d.ts +20 -16
- package/dist/components/inputs/radio/index.js +20 -16
- package/dist/components/inputs/search/index.d.ts +12 -5
- package/dist/components/inputs/search/index.js +33 -26
- package/dist/components/inputs/select/index.d.ts +88 -99
- package/dist/components/inputs/select/index.js +32 -29
- package/dist/components/inputs/slider/index.d.ts +26 -48
- package/dist/components/inputs/slider/index.js +9 -10
- package/dist/components/inputs/switch/index.d.ts +12 -6
- package/dist/components/inputs/switch/index.js +17 -15
- package/dist/components/inputs/textarea/index.d.ts +12 -22
- package/dist/components/inputs/textarea/index.js +12 -9
- package/dist/components/navigation/navigation-menu/index.d.ts +112 -83
- package/dist/components/navigation/navigation-menu/index.js +31 -27
- package/dist/components/navigation/pagination/index.d.ts +25 -38
- package/dist/components/navigation/pagination/index.js +27 -34
- package/dist/components/navigation/sidebar/index.d.ts +236 -230
- package/dist/components/navigation/sidebar/index.js +59 -55
- package/dist/components/navigation/tabs/index.d.ts +62 -45
- package/dist/components/navigation/tabs/index.js +23 -17
- package/dist/components/overlays/alert-dialog/index.d.ts +71 -106
- package/dist/components/overlays/alert-dialog/index.js +24 -19
- package/dist/components/overlays/command/index.d.ts +40 -31
- package/dist/components/overlays/command/index.js +31 -25
- package/dist/components/overlays/context-menu/index.d.ts +70 -84
- package/dist/components/overlays/context-menu/index.js +35 -31
- package/dist/components/overlays/dialog/index.d.ts +82 -98
- package/dist/components/overlays/dialog/index.js +23 -20
- package/dist/components/overlays/dropdown/index.d.ts +191 -357
- package/dist/components/overlays/dropdown/index.js +35 -41
- package/dist/components/overlays/popover/index.d.ts +81 -52
- package/dist/components/overlays/popover/index.js +17 -13
- package/dist/components/overlays/preview-card/index.d.ts +52 -26
- package/dist/components/overlays/preview-card/index.js +16 -12
- package/dist/components/overlays/sheet/index.d.ts +41 -45
- package/dist/components/overlays/sheet/index.js +24 -19
- package/dist/components/overlays/toast/index.d.ts +73 -183
- package/dist/components/overlays/toast/index.js +20 -21
- package/dist/components/overlays/tooltip/index.d.ts +80 -118
- package/dist/components/overlays/tooltip/index.js +14 -12
- package/dist/components/progress/index.d.ts +10 -11
- package/dist/components/progress/index.js +7 -6
- package/dist/components/table/index.d.ts +72 -71
- package/dist/components/table/index.js +18 -16
- package/dist/index.d.ts +2575 -3149
- package/dist/index.js +186 -202
- package/dist/lib/date-locale.d.ts +6 -13
- package/dist/lib/date-locale.js +5 -11
- package/dist/lib/date-mask.d.ts +41 -0
- package/dist/lib/date-mask.js +20 -0
- package/dist/lib/field-box.d.ts +114 -0
- package/dist/lib/field-box.js +18 -0
- package/dist/lib/field-classes.d.ts +15 -119
- package/dist/lib/field-classes.js +4 -21
- package/dist/lib/fluid-hover-highlight.d.ts +3 -25
- package/dist/lib/fluid-hover-highlight.js +8 -13
- package/dist/lib/focus-ring.d.ts +16 -10
- package/dist/lib/focus-ring.js +6 -6
- package/dist/lib/goo-indicator.js +6 -5
- package/dist/lib/icon-context.d.ts +2 -8
- package/dist/lib/icon-context.js +2 -6
- package/dist/lib/merge-refs.d.ts +10 -0
- package/dist/lib/merge-refs.js +8 -0
- package/dist/lib/morph-layers.d.ts +12 -6
- package/dist/lib/morph-layers.js +7 -6
- package/dist/lib/morph-part.js +3 -3
- package/dist/lib/overlay.d.ts +113 -0
- package/dist/lib/overlay.js +21 -0
- package/dist/lib/popup-rows.d.ts +101 -0
- package/dist/lib/popup-rows.js +25 -0
- package/dist/lib/popup-surface.d.ts +92 -0
- package/dist/lib/popup-surface.js +17 -0
- package/dist/lib/popup.d.ts +17 -1
- package/dist/lib/popup.js +4 -1
- package/dist/lib/rect.d.ts +16 -0
- package/dist/lib/rect.js +12 -0
- package/dist/lib/reduced-motion.js +1 -1
- package/dist/lib/row-group.d.ts +100 -0
- package/dist/lib/row-group.js +12 -0
- package/dist/lib/row-index.d.ts +12 -7
- package/dist/lib/row-index.js +4 -2
- package/dist/lib/scroll-column.d.ts +1 -5
- package/dist/lib/scroll-column.js +13 -12
- package/dist/lib/shape-classes.d.ts +16 -0
- package/dist/lib/shape-classes.js +6 -0
- package/dist/lib/shape-context.d.ts +2 -9
- package/dist/lib/shape-context.js +3 -7
- package/dist/lib/size-context.d.ts +1 -2
- package/dist/lib/size-context.js +2 -7
- package/dist/lib/size-scale.js +1 -1
- package/dist/lib/slot.d.ts +31 -26
- package/dist/lib/slot.js +9 -9
- package/dist/lib/spinner-glyph.d.ts +7 -0
- package/dist/lib/spinner-glyph.js +7 -0
- package/dist/lib/springs.d.ts +5 -1
- package/dist/lib/springs.js +4 -2
- package/dist/lib/surface-classes.js +1 -1
- package/dist/lib/surface-context.d.ts +3 -1
- package/dist/lib/surface-context.js +3 -1
- package/dist/lib/use-autosize-textarea.d.ts +16 -0
- package/dist/lib/use-autosize-textarea.js +7 -0
- package/dist/lib/use-controllable-state.d.ts +15 -1
- package/dist/lib/use-controllable-state.js +1 -1
- package/dist/lib/use-fluid-hover.d.ts +1 -49
- package/dist/lib/use-fluid-hover.js +1 -7
- package/dist/lib/use-is-mobile.js +1 -1
- package/dist/lib/use-iso-layout-effect.d.ts +7 -0
- package/dist/lib/use-iso-layout-effect.js +6 -0
- package/dist/lib/use-keyboard-nav-gate.js +3 -2
- package/dist/lib/use-merge-split.js +7 -6
- package/dist/lib/use-morph.d.ts +13 -7
- package/dist/lib/use-morph.js +4 -3
- package/dist/lib/use-touch-primary.js +1 -1
- package/dist/lib/utils.js +1 -1
- package/dist/lib/weight-label.d.ts +26 -0
- package/dist/lib/weight-label.js +7 -0
- package/dist/preset.d.ts +4 -8
- package/dist/preset.js +8 -8
- package/dist/primitives/code/index.js +8 -8
- package/dist/primitives/craft/index.d.ts +1 -1
- package/dist/primitives/craft/index.js +13 -12
- package/dist/primitives/fluid-hover/index.d.ts +13 -14
- package/dist/primitives/fluid-hover/index.js +13 -10
- package/dist/primitives/morph/index.d.ts +1 -1
- package/dist/primitives/morph/index.js +20 -16
- package/dist/primitives/motion/index.d.ts +2 -0
- package/dist/primitives/motion/index.js +14 -11
- package/dist/primitives/scroll-area/index.d.ts +5 -4
- package/dist/primitives/scroll-area/index.js +5 -5
- package/dist/primitives/separator/index.d.ts +12 -11
- package/dist/primitives/separator/index.js +2 -2
- package/dist/primitives/sizes/index.d.ts +17 -4
- package/dist/primitives/sizes/index.js +7 -4
- package/dist/primitives/skeleton/index.d.ts +8 -8
- package/dist/primitives/skeleton/index.js +7 -6
- package/dist/primitives/surface/index.d.ts +12 -25
- package/dist/primitives/surface/index.js +8 -6
- package/dist/shared/{components-yxmxn2jp.js → components-07g2gbjy.js} +30 -75
- package/dist/shared/components-099sdasz.js +552 -0
- package/dist/shared/{components-bsqynhaj.js → components-0h3f5jae.js} +49 -51
- package/dist/shared/{components-wbbckbw8.js → components-0mrhj88d.js} +13 -12
- package/dist/shared/{components-0h78g3b5.js → components-0p2na0cp.js} +19 -47
- package/dist/shared/components-1a7cr7vh.js +40 -0
- package/dist/shared/components-1axxc3tk.js +334 -0
- package/dist/shared/components-1hc3xv0y.js +381 -0
- package/dist/shared/{components-gyt7my41.js → components-1jxw899c.js} +94 -84
- package/dist/shared/{components-jqpefjsn.js → components-1nv9q3s8.js} +24 -44
- package/dist/shared/components-1p3k62x2.js +137 -0
- package/dist/shared/{components-kz5q11pp.js → components-2xmke84n.js} +12 -4
- package/dist/shared/{components-c7rwx0ap.js → components-346ged8v.js} +24 -3
- package/dist/shared/{components-4j3t39dd.js → components-34brwmgp.js} +12 -11
- package/dist/shared/components-38wa9nx5.js +19 -0
- package/dist/shared/components-3hgk57s0.js +27 -0
- package/dist/shared/{components-px2zm7dc.js → components-3js2vgds.js} +13 -6
- package/dist/shared/{components-ctqmge8t.js → components-3m4rqrqm.js} +10 -3
- package/dist/shared/{components-3ey0hzpb.js → components-45r18egt.js} +11 -1
- package/dist/shared/components-50rh4ggz.js +54 -0
- package/dist/shared/components-5atrr490.js +99 -0
- package/dist/shared/components-5f3tq4qb.js +70 -0
- package/dist/shared/{components-dc5q749x.js → components-5vyaexsj.js} +16 -17
- package/dist/shared/{components-pwayrkw9.js → components-5ynncdpn.js} +5 -4
- package/dist/shared/{components-1e64t8aj.js → components-62mg6pab.js} +232 -93
- package/dist/shared/{components-drxrtnp2.js → components-6f5pyzb2.js} +8 -0
- package/dist/shared/{components-868v7scv.js → components-6xfhc5qm.js} +104 -169
- package/dist/shared/{components-yhgq0qxx.js → components-7c4a0egq.js} +20 -12
- package/dist/shared/components-7fqnqbh0.js +79 -0
- package/dist/shared/components-7fsy0jxg.js +443 -0
- package/dist/shared/{components-p0fm0bab.js → components-7t3pz7v7.js} +496 -526
- package/dist/shared/components-85epgxwf.js +620 -0
- package/dist/shared/{components-wknae3m4.js → components-86vvx0c8.js} +75 -121
- package/dist/shared/{components-wgtjt2af.js → components-88ktjdg0.js} +30 -27
- package/dist/shared/{components-ft3zdc79.js → components-88r046aa.js} +6 -6
- package/dist/shared/{components-xd3emmy4.js → components-8hfrd2fk.js} +1462 -1464
- package/dist/shared/components-8sazy704.js +146 -0
- package/dist/shared/{components-rrbpmfx4.js → components-8wp8d8q1.js} +8 -0
- package/dist/shared/{components-rtadhd9j.js → components-9ybenn5v.js} +16 -16
- package/dist/shared/components-amsc86fb.js +293 -0
- package/dist/shared/{components-9as3rf68.js → components-az04rmng.js} +12 -6
- package/dist/shared/components-bdkm2jzy.js +34 -0
- package/dist/shared/{components-xjkdvnbg.js → components-be3wggg1.js} +54 -48
- package/dist/shared/components-bkwjvvkh.js +18 -0
- package/dist/shared/{components-vf45j12c.js → components-ceyn28cf.js} +7 -0
- package/dist/shared/{components-3h92d94m.js → components-cy5z8zxy.js} +1 -2
- package/dist/shared/components-dm86y7b3.js +105 -0
- package/dist/shared/{components-c9yr4ed1.js → components-ejn6tvbw.js} +8 -6
- package/dist/shared/{components-34txk9rj.js → components-ew4wq7mj.js} +7 -0
- package/dist/shared/{components-svkt577j.js → components-f75y4gn8.js} +53 -70
- package/dist/shared/components-f9adtfq8.js +34 -0
- package/dist/shared/{components-2a7hcand.js → components-gbsdhmrv.js} +48 -83
- package/dist/shared/{components-9sttq78t.js → components-gc5zky2w.js} +54 -59
- package/dist/shared/{components-bae8sbjx.js → components-gkdx1787.js} +12 -6
- package/dist/shared/{components-124epb7f.js → components-grxgqa75.js} +3 -7
- package/dist/shared/components-gw0wd7gd.js +986 -0
- package/dist/shared/components-j4z3rtw2.js +179 -0
- package/dist/shared/{components-t5pk5nmc.js → components-j8tcbm8y.js} +927 -953
- package/dist/shared/components-jm91mjm1.js +297 -0
- package/dist/shared/{components-b94t6qtj.js → components-jtfptckj.js} +44 -39
- package/dist/shared/components-jx9qb4z8.js +63 -0
- package/dist/shared/components-k785rge6.js +336 -0
- package/dist/shared/{components-r8eqs7gz.js → components-k81x1aea.js} +10 -6
- package/dist/shared/{components-qx27excf.js → components-kn5c7652.js} +11 -13
- package/dist/shared/components-mse06t0x.js +31 -0
- package/dist/shared/{components-cet3jpa0.js → components-n7e31ct4.js} +71 -49
- package/dist/shared/components-nskr4hwg.js +1008 -0
- package/dist/shared/components-nv5m3gcv.js +37 -0
- package/dist/shared/components-nwa2a9tq.js +27 -0
- package/dist/shared/{components-f7h57m6t.js → components-p0x8ren6.js} +3 -1
- package/dist/shared/{components-2krsc300.js → components-p0z99d5b.js} +67 -92
- package/dist/shared/{components-b1e239g3.js → components-pa43g2r2.js} +15 -4
- package/dist/shared/{components-m06yq8wk.js → components-pedbt2dc.js} +35 -49
- package/dist/shared/components-pva1wj1r.js +27 -0
- package/dist/shared/components-q4wyd06h.js +382 -0
- package/dist/shared/{components-71nbt03m.js → components-qrpdtvxa.js} +12 -45
- package/dist/shared/components-r33dxr5j.js +91 -0
- package/dist/shared/{components-005jt2nz.js → components-re8p99fj.js} +53 -179
- package/dist/shared/components-s217vq1n.js +35 -0
- package/dist/shared/{components-vc864c51.js → components-sesrjvcc.js} +7 -6
- package/dist/shared/{components-qh1cvj6p.js → components-skn189mp.js} +29 -36
- package/dist/shared/{components-tz4gaf1v.js → components-tcyz2tdn.js} +9 -1
- package/dist/shared/components-tjxy84s9.js +53 -0
- package/dist/shared/components-tnj6mkhg.js +89 -0
- package/dist/shared/{components-de99ykt7.js → components-tz0axc0f.js} +1 -0
- package/dist/shared/components-v2j3jx89.js +7 -0
- package/dist/shared/components-vcte8p75.js +71 -0
- package/dist/shared/{components-c74gf16d.js → components-vgzerqt0.js} +34 -47
- package/dist/shared/components-vp6vzsee.js +30 -0
- package/dist/shared/components-vpkh6j83.js +42 -0
- package/dist/shared/{components-4nck8acq.js → components-wgd1nebp.js} +21 -14
- package/dist/shared/{components-pt5ftm4p.js → components-wrbw67f6.js} +10 -3
- package/dist/shared/{components-tz1fv35x.js → components-wwd093xg.js} +1 -0
- package/dist/shared/components-wyfmhtw9.js +61 -0
- package/dist/shared/{components-d3shbwqq.js → components-xpw8dzb0.js} +16 -23
- package/dist/shared/{components-mattt5jp.js → components-xzcgr3gy.js} +62 -60
- package/dist/shared/{components-jcnjay5g.js → components-ycx2kxeq.js} +9 -1
- package/dist/shared/components-zbzx62pg.js +1771 -0
- package/dist/shared/{components-dtca4s6b.js → components-zf0nnvvg.js} +67 -147
- package/dist/shared/{components-h83az0bz.js → components-znspksk0.js} +9 -1
- package/dist/shared/components-zpatc9x3.js +78 -0
- package/dist/styles.css +218 -235
- package/dist/tailwind.css +20 -8
- package/dist/tokens.css +53 -68
- package/index.ts +16 -2
- package/lib/date-locale.ts +12 -149
- package/lib/date-mask.ts +146 -0
- package/lib/field-box.ts +117 -0
- package/lib/field-classes.ts +85 -100
- package/lib/fluid-hover-highlight.tsx +12 -57
- package/lib/focus-ring.tsx +25 -22
- package/lib/goo-indicator.tsx +2 -0
- package/lib/icon-context.tsx +23 -75
- package/lib/merge-refs.ts +29 -0
- package/lib/morph-layers.tsx +3 -1
- package/lib/morph-part.tsx +5 -3
- package/lib/overlay.tsx +118 -0
- package/lib/popup-rows.tsx +149 -0
- package/lib/popup-surface.tsx +52 -0
- package/lib/popup.ts +10 -9
- package/lib/rect.ts +48 -0
- package/lib/reduced-motion.ts +2 -0
- package/lib/row-group.tsx +113 -0
- package/lib/row-index.tsx +27 -10
- package/lib/scroll-column.tsx +26 -53
- package/lib/shape-classes.ts +56 -0
- package/lib/shape-context.tsx +10 -79
- package/lib/size-context.tsx +8 -21
- package/lib/size-scale.ts +3 -9
- package/lib/slot.tsx +124 -0
- package/lib/spinner-glyph.tsx +27 -0
- package/lib/springs.ts +8 -9
- package/lib/surface-classes.ts +3 -8
- package/lib/surface-context.tsx +10 -5
- package/lib/use-autosize-textarea.ts +64 -0
- package/lib/use-controllable-state.ts +30 -15
- package/lib/use-fluid-hover.ts +9 -11
- package/lib/use-is-mobile.ts +5 -5
- package/lib/use-iso-layout-effect.ts +14 -0
- package/lib/use-keyboard-nav-gate.ts +5 -6
- package/lib/use-merge-split.tsx +5 -15
- package/lib/use-morph.ts +34 -76
- package/lib/use-touch-primary.tsx +5 -5
- package/lib/utils.ts +4 -11
- package/lib/weight-label.tsx +69 -0
- package/package.json +57 -194
- package/primitives/code/index.tsx +4 -2
- package/primitives/craft/demos.tsx +4 -2
- package/primitives/craft/examples.mdx +32 -34
- package/primitives/craft/index.tsx +3 -0
- package/primitives/fluid-hover/examples.mdx +1 -1
- package/primitives/fluid-hover/index.tsx +33 -68
- package/primitives/morph/examples.mdx +16 -19
- package/primitives/morph/index.tsx +5 -3
- package/primitives/motion/examples.mdx +3 -3
- package/primitives/motion/index.tsx +6 -22
- package/primitives/scroll-area/examples.mdx +4 -4
- package/primitives/scroll-area/index.tsx +16 -41
- package/primitives/separator/examples.mdx +2 -2
- package/primitives/separator/index.tsx +15 -14
- package/primitives/sizes/examples.mdx +1 -1
- package/primitives/sizes/index.tsx +28 -42
- package/primitives/skeleton/examples.mdx +6 -6
- package/primitives/skeleton/index.tsx +24 -10
- package/primitives/skeleton/skeleton.css +8 -3
- package/primitives/surface/examples.mdx +11 -11
- package/primitives/surface/index.tsx +15 -40
- package/primitives/surface/surface.css +1 -1
- package/DESIGN.md +0 -623
- package/components/inputs/select/variants.ts +0 -32
- package/components/navigation/sidebar/sidebar-core.tsx +0 -1408
- package/components/navigation/sidebar/sidebar-menu.tsx +0 -1495
- package/components/navigation/sidebar/variants.ts +0 -55
- package/components/navigation/tabs-subtle/examples.mdx +0 -49
- package/components/navigation/tabs-subtle/index.tsx +0 -512
- package/components/overlays/dropdown/menu-parts.tsx +0 -725
- package/components/overlays/toast/global-demo.tsx +0 -72
- package/dist/components/inputs/color-picker/variants.d.ts +0 -61
- package/dist/components/inputs/color-picker/variants.js +0 -28
- package/dist/components/inputs/select/variants.d.ts +0 -5
- package/dist/components/inputs/select/variants.js +0 -6
- package/dist/components/navigation/sidebar/variants.d.ts +0 -25
- package/dist/components/navigation/sidebar/variants.js +0 -28
- package/dist/components/navigation/tabs-subtle/index.d.ts +0 -73
- package/dist/components/navigation/tabs-subtle/index.js +0 -24
- package/dist/docs/index.d.ts +0 -83
- package/dist/docs/index.js +0 -288
- package/dist/docs/vite.d.ts +0 -31
- package/dist/docs/vite.js +0 -45
- package/dist/lib/field-variants.d.ts +0 -47
- package/dist/lib/field-variants.js +0 -26
- package/dist/lib/inert.d.ts +0 -9
- package/dist/lib/inert.js +0 -8
- package/dist/lib/row-order.d.ts +0 -28
- package/dist/lib/row-order.js +0 -10
- package/dist/lib/shape-radius.d.ts +0 -19
- package/dist/lib/shape-radius.js +0 -6
- package/dist/shared/components-01w9qcfa.js +0 -277
- package/dist/shared/components-26snnbs9.js +0 -322
- package/dist/shared/components-2qbqqpgq.js +0 -1545
- package/dist/shared/components-303jf96s.js +0 -1478
- package/dist/shared/components-4vfm04wq.js +0 -82
- package/dist/shared/components-54nq988h.js +0 -123
- package/dist/shared/components-7qx17na9.js +0 -300
- package/dist/shared/components-7s7pykk5.js +0 -281
- package/dist/shared/components-8jrk5eye.js +0 -448
- package/dist/shared/components-91zw3d9f.js +0 -136
- package/dist/shared/components-9jmjnkqd.js +0 -503
- package/dist/shared/components-adkarj8n.js +0 -35
- package/dist/shared/components-c5w5zk0s.js +0 -218
- package/dist/shared/components-cnead5qm.js +0 -185
- package/dist/shared/components-czdvj1a8.js +0 -266
- package/dist/shared/components-dcc02hs2.js +0 -31
- package/dist/shared/components-dhgk6mbt.js +0 -16
- package/dist/shared/components-g3eafs70.js +0 -337
- package/dist/shared/components-gx4h5rbb.js +0 -40
- package/dist/shared/components-h6p86be3.js +0 -19
- package/dist/shared/components-hdzrqqpx.js +0 -55
- package/dist/shared/components-hgv6tygd.js +0 -986
- package/dist/shared/components-krtx3m5b.js +0 -84
- package/dist/shared/components-kswxnm3h.js +0 -24
- package/dist/shared/components-mhza2wdn.js +0 -482
- package/dist/shared/components-mrbaxt8q.js +0 -62
- package/dist/shared/components-pv1dyrtn.js +0 -678
- package/dist/shared/components-s8yqk2dc.js +0 -124
- package/dist/shared/components-syynwm1r.js +0 -114
- package/dist/shared/components-tv7b8tet.js +0 -271
- package/dist/shared/components-w2jqa6hx.js +0 -404
- package/dist/shared/components-xdqmt6ed.js +0 -20
- package/dist/shared/components-y0kfy2g4.js +0 -578
- package/dist/shared/components-z3v0n0de.js +0 -11
- package/dist/shared/components-z8fedth5.js +0 -305
- package/dist/shared/components-zkk3fmw8.js +0 -150
- package/dist/tokens/colors.css +0 -230
- package/dist/tokens/motion.css +0 -40
- package/dist/tokens/radius.css +0 -10
- package/dist/tokens/spacing.css +0 -9
- package/dist/tokens/typography.css +0 -119
- package/docs/chrome.css +0 -120
- package/docs/chrome.tsx +0 -283
- package/docs/index.ts +0 -9
- package/docs/vite.ts +0 -85
- package/lib/field-variants.ts +0 -117
- package/lib/inert.ts +0 -22
- package/lib/row-order.tsx +0 -126
- package/lib/shape-radius.ts +0 -67
- package/lib/slot.ts +0 -115
- package/preset.ts +0 -199
|
@@ -1,250 +1,60 @@
|
|
|
1
|
-
|
|
2
|
-
/*
|
|
1
|
+
/*!
|
|
3
2
|
* Ported from Fluid Functionalism — github.com/mickadesign/fluid-functionalism
|
|
4
3
|
* `registry/default/card.tsx` @ b3587bdbd83fc66c2a6aae3817ffb856cb09260b
|
|
5
4
|
* MIT License © 2026 Micka Touillaud — fluidfunctionalism.com (notice: LICENSE.fluid-functionalism)
|
|
6
|
-
* Local
|
|
7
|
-
* - `"use client"` dropped; `@/lib/*`, `@/hooks/*` and
|
|
8
|
-
* `@/components/ui/fluid-hover-highlight` → `../../lib/*`, except
|
|
9
|
-
* `SizeProvider` → `../../primitives/sizes`.
|
|
10
|
-
* - `next/link` replaced with plain anchors (no Next.js in modo) — the
|
|
11
|
-
* stretched card link and CardButton's `href` form.
|
|
12
|
-
* - Prop JSDoc on CardProps rewritten from the FF docs API table (`children`
|
|
13
|
-
* re-declared so it is documented); modo TSDoc and examples on `Card`.
|
|
14
|
-
* - Compound statics `Card.Group/.Header/.Title/.Description/.Action/
|
|
15
|
-
* .Content/.Footer/.Media/.Image/.Eyebrow/.Feature/.Button` attached with
|
|
16
|
-
* `Object.assign`, typed through a `CardComponent` cast on the forwardRef.
|
|
17
|
-
* Upstream's named exports are kept.
|
|
18
|
-
* - Styling reads DS tokens (AGENTS.md styling): `text-[Npx]` →
|
|
19
|
-
* `text-<role>[-compact]`; inline `fontVariationSettings` → `weight-*`; the
|
|
20
|
-
* hex focus-ring fallback → `ring-focus-ring` / `border-focus-ring`;
|
|
21
|
-
* `rounded-[Npx]` → radius tokens; `duration-80|120|160` and tier-length JS
|
|
22
|
-
* durations → `duration-<tier>` / `spring.*`.
|
|
23
|
-
* - `border` on a standalone Card (local): `"outlined"` draws the same hairline
|
|
24
|
-
* frame an outlined Card.Group gives its tiles; inside a group the group's
|
|
25
|
-
* `border` still decides. Borderless stays the default.
|
|
26
|
-
* - `Card.Divider` / `CardDivider` (local): a hairline across the card between
|
|
27
|
-
* its parts (full-bleed, spaced like the parts), vertical in an inline card;
|
|
28
|
-
* the Separator primitive in the card's divider tone.
|
|
29
|
-
* - `CardTitle` takes `as` (a heading level or another tag; a `span` by default)
|
|
30
|
-
* and `CardContent` takes `bodyText` (the ladder's body size instead of the
|
|
31
|
-
* inherited one), both local and opt-in.
|
|
5
|
+
* Local changes: see PORTING.md.
|
|
32
6
|
*/
|
|
33
7
|
|
|
8
|
+
'use client'
|
|
9
|
+
|
|
34
10
|
import {
|
|
35
11
|
Children,
|
|
36
|
-
cloneElement,
|
|
37
|
-
createContext,
|
|
38
12
|
type ForwardRefExoticComponent,
|
|
39
13
|
forwardRef,
|
|
40
14
|
type HTMLAttributes,
|
|
41
15
|
isValidElement,
|
|
42
|
-
type MouseEventHandler,
|
|
43
|
-
type ReactElement,
|
|
44
16
|
type ReactNode,
|
|
45
|
-
type Ref,
|
|
46
17
|
type RefAttributes,
|
|
47
18
|
useContext,
|
|
48
19
|
useMemo,
|
|
49
20
|
useRef,
|
|
50
21
|
} from 'react'
|
|
51
|
-
import {
|
|
52
|
-
import {
|
|
22
|
+
import { useIcon } from '../../lib/icon-context'
|
|
23
|
+
import { mergeRefs } from '../../lib/merge-refs'
|
|
24
|
+
import { useRowPosition } from '../../lib/row-index'
|
|
53
25
|
import { useShape } from '../../lib/shape-context'
|
|
54
26
|
import { type SizeVariant, useSize } from '../../lib/size-context'
|
|
55
|
-
import {
|
|
27
|
+
import { useRegisterFluidHoverItem } from '../../lib/use-fluid-hover'
|
|
28
|
+
import { useIsoLayoutEffect } from '../../lib/use-iso-layout-effect'
|
|
56
29
|
import { cn } from '../../lib/utils'
|
|
57
|
-
import
|
|
58
|
-
import {
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
// system) and lean on hairline dividers / the fluid hover highlight rather than
|
|
71
|
-
// a drawn frame. A Card renders fine on its own; inside a CardGroup it
|
|
72
|
-
// registers itself so the group's highlight can find it.
|
|
73
|
-
// ---------------------------------------------------------------------------
|
|
74
|
-
|
|
75
|
-
type CardOrientation = 'card' | 'inline'
|
|
76
|
-
type CardBorder = 'none' | 'outlined'
|
|
77
|
-
|
|
78
|
-
// ── Group context ────────────────────────────────────────
|
|
79
|
-
|
|
80
|
-
interface CardGroupContextValue {
|
|
81
|
-
registerItem: (index: number, element: HTMLElement | null) => void
|
|
82
|
-
activeIndex: number | null
|
|
83
|
-
/** Index of the persistently-selected card, or -1. Its neighbours drop the
|
|
84
|
-
* hairline that would otherwise cut across the selection fill. */
|
|
85
|
-
selectedIndex: number
|
|
86
|
-
orientation: CardOrientation
|
|
87
|
-
columns: number
|
|
88
|
-
count: number
|
|
89
|
-
/** Individual cards carry their own border/tile shape (separated grids). */
|
|
90
|
-
separated: boolean
|
|
91
|
-
/** Inner hairline dividers are drawn between adjacent cards. */
|
|
92
|
-
divided: boolean
|
|
93
|
-
outlined: boolean
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
const CardGroupContext = createContext<CardGroupContextValue | null>(null)
|
|
97
|
-
|
|
98
|
-
// ── Per-card context ─────────────────────────────────────
|
|
99
|
-
// Lets the compositional parts (title, header, footer…) adapt to the card
|
|
100
|
-
// they're inside without threading props: the title reads `emphasized` to
|
|
101
|
-
// animate its weight; parts read `orientation` to switch padding/flow.
|
|
102
|
-
|
|
103
|
-
interface CardContextValue {
|
|
104
|
-
emphasized: boolean
|
|
105
|
-
orientation: CardOrientation
|
|
106
|
-
clickable: boolean
|
|
107
|
-
/** An inline card holding a full CardImage centres its text + actions in a
|
|
108
|
-
* column beside the image, so the footer drops below the text (hugged and
|
|
109
|
-
* vertically centred) instead of trailing to the right. */
|
|
110
|
-
hasImage: boolean
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
const CardContext = createContext<CardContextValue>({
|
|
114
|
-
emphasized: false,
|
|
115
|
-
orientation: 'card',
|
|
116
|
-
clickable: false,
|
|
117
|
-
hasImage: false,
|
|
118
|
-
})
|
|
119
|
-
|
|
120
|
-
// ── CardGroup ────────────────────────────────────────────
|
|
121
|
-
|
|
122
|
-
interface CardGroupProps extends Omit<HTMLAttributes<HTMLDivElement>, 'onDrag'> {
|
|
123
|
-
/** How each card lays its own content out.
|
|
124
|
-
* "card" — stacked vertically (media/header on top). "inline" — a
|
|
125
|
-
* horizontal row (leading media, trailing footer), like a Table row.
|
|
126
|
-
* @default "card" */
|
|
127
|
-
orientation?: CardOrientation
|
|
128
|
-
/** Number of grid columns. >1 enables 2-D fluid hover across rows and columns.
|
|
129
|
-
* @default 1 */
|
|
130
|
-
columns?: number
|
|
131
|
-
/** "none" — borderless (default), separated only by subtle dividers.
|
|
132
|
-
* "outlined" — draws a border: one shared frame when grouped, or one per
|
|
133
|
-
* card when `separated`. @default "none" */
|
|
134
|
-
border?: CardBorder
|
|
135
|
-
/** Split the group into individually-shaped cards with a gap between them
|
|
136
|
-
* (a grid of tiles) instead of one continuous divided block. @default false */
|
|
137
|
-
separated?: boolean
|
|
138
|
-
/** Enable the magnetic fluid-hover highlight. @default true */
|
|
139
|
-
fluidHover?: boolean
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
const CardGroup = forwardRef<HTMLDivElement, CardGroupProps>(
|
|
143
|
-
(
|
|
144
|
-
{
|
|
145
|
-
orientation = 'card',
|
|
146
|
-
columns = 1,
|
|
147
|
-
border = 'none',
|
|
148
|
-
separated = false,
|
|
149
|
-
fluidHover = true,
|
|
150
|
-
className,
|
|
151
|
-
children,
|
|
152
|
-
...props
|
|
153
|
-
},
|
|
154
|
-
ref,
|
|
155
|
-
) => {
|
|
156
|
-
const containerRef = useRef<HTMLDivElement>(null)
|
|
157
|
-
const shape = useShape()
|
|
158
|
-
|
|
159
|
-
// >1 column wraps into a grid, where nearest-item must be resolved in two
|
|
160
|
-
// dimensions; a single column is a plain vertical list.
|
|
161
|
-
const axis = columns > 1 ? 'xy' : 'y'
|
|
162
|
-
// A card grid has generous whitespace, so a gap click only routes when it
|
|
163
|
-
// lands within a hand's width of the highlighted card.
|
|
164
|
-
const hover = useFluidHover(containerRef, { axis, gapClick: { maxDistance: 16 } })
|
|
165
|
-
const { activeIndex, handlers, registerItem } = hover
|
|
166
|
-
|
|
167
|
-
// Assign each valid child a stable fluid hover index so callers never thread
|
|
168
|
-
// one through by hand (Table asks for it; here the group owns it).
|
|
169
|
-
const childArray = Children.toArray(children).filter(isValidElement)
|
|
170
|
-
const count = childArray.length
|
|
171
|
-
const indexed = childArray.map((child, i) => cloneElement(child as ReactElement<{ index?: number }>, { index: i }))
|
|
172
|
-
// Which card is selected — so its neighbours can drop the divider that
|
|
173
|
-
// would otherwise slice through the selection fill.
|
|
174
|
-
const selectedIndex = childArray.findIndex(child => (child.props as { selected?: boolean }).selected)
|
|
175
|
-
|
|
176
|
-
const outlined = border === 'outlined'
|
|
177
|
-
const divided = !separated
|
|
178
|
-
|
|
179
|
-
const contextValue = useMemo<CardGroupContextValue>(
|
|
180
|
-
() => ({
|
|
181
|
-
registerItem,
|
|
182
|
-
activeIndex,
|
|
183
|
-
selectedIndex,
|
|
184
|
-
orientation,
|
|
185
|
-
columns,
|
|
186
|
-
count,
|
|
187
|
-
separated,
|
|
188
|
-
divided,
|
|
189
|
-
outlined,
|
|
190
|
-
}),
|
|
191
|
-
[registerItem, activeIndex, selectedIndex, orientation, columns, count, separated, divided, outlined],
|
|
192
|
-
)
|
|
193
|
-
|
|
194
|
-
return (
|
|
195
|
-
<CardGroupContext.Provider value={contextValue}>
|
|
196
|
-
<div
|
|
197
|
-
ref={node => {
|
|
198
|
-
;(containerRef as React.MutableRefObject<HTMLDivElement | null>).current = node
|
|
199
|
-
if (typeof ref === 'function') ref(node)
|
|
200
|
-
else if (ref) (ref as React.MutableRefObject<HTMLDivElement | null>).current = node
|
|
201
|
-
}}
|
|
202
|
-
{...props}
|
|
203
|
-
data-slot="card-group"
|
|
204
|
-
data-orientation={orientation}
|
|
205
|
-
className={cn(
|
|
206
|
-
'relative grid',
|
|
207
|
-
// A shared frame clips the highlight + dividers to its rounded
|
|
208
|
-
// corners; separated tiles clip themselves.
|
|
209
|
-
outlined && !separated && `border border-border/60 overflow-hidden ${shape.container}`,
|
|
210
|
-
separated ? 'gap-2' : 'gap-0',
|
|
211
|
-
className,
|
|
212
|
-
)}
|
|
213
|
-
style={{
|
|
214
|
-
gridTemplateColumns: `repeat(${Math.max(1, columns)}, minmax(0, 1fr))`,
|
|
215
|
-
}}
|
|
216
|
-
onMouseEnter={fluidHover ? handlers.onMouseEnter : undefined}
|
|
217
|
-
onMouseMove={fluidHover ? handlers.onMouseMove : undefined}
|
|
218
|
-
onMouseLeave={fluidHover ? handlers.onMouseLeave : undefined}
|
|
219
|
-
onClick={fluidHover ? handlers.onClick : undefined}
|
|
220
|
-
>
|
|
221
|
-
{/* Fluid hover highlight — a single magnetic layer that springs to the
|
|
222
|
-
card nearest the cursor, previewing where a click will land. */}
|
|
223
|
-
<FluidHoverHighlight hover={hover} hidden={!fluidHover} className={cn('z-0', shape.container)} />
|
|
224
|
-
|
|
225
|
-
{indexed}
|
|
226
|
-
</div>
|
|
227
|
-
</CardGroupContext.Provider>
|
|
228
|
-
)
|
|
229
|
-
},
|
|
230
|
-
)
|
|
231
|
-
|
|
232
|
-
CardGroup.displayName = 'CardGroup'
|
|
233
|
-
|
|
234
|
-
// ── Card ─────────────────────────────────────────────────
|
|
30
|
+
import { SizeScope } from '../../primitives/sizes'
|
|
31
|
+
import { type CardBorder, CardContext, type CardContextValue, CardGroup, CardGroupContext } from './card-group'
|
|
32
|
+
import { CardButton, CardFeature, CardImage, CardMedia } from './card-media'
|
|
33
|
+
import {
|
|
34
|
+
CardAction,
|
|
35
|
+
CardContent,
|
|
36
|
+
CardDescription,
|
|
37
|
+
CardDivider,
|
|
38
|
+
CardEyebrow,
|
|
39
|
+
CardFooter,
|
|
40
|
+
CardHeader,
|
|
41
|
+
CardTitle,
|
|
42
|
+
} from './card-parts'
|
|
235
43
|
|
|
236
44
|
interface CardProps extends Omit<HTMLAttributes<HTMLDivElement>, 'onClick'> {
|
|
237
45
|
/** Compositional parts: Card.Image, Card.Media, Card.Header, Card.Content, Card.Footer. */
|
|
238
46
|
children?: ReactNode
|
|
239
|
-
/** Makes the whole card a clickable target (stretched button); fluid hover previews it.
|
|
240
|
-
onClick?:
|
|
47
|
+
/** Makes the whole card a clickable target (stretched button); fluid hover previews it. */
|
|
48
|
+
onClick?: () => void
|
|
241
49
|
/** Makes the whole card a link (stretched anchor). */
|
|
242
50
|
href?: string
|
|
243
51
|
/** Opens href in a new tab. Defaults to `false`. */
|
|
244
52
|
external?: boolean
|
|
245
|
-
/** Accessible name for the stretched link
|
|
53
|
+
/** Accessible name for the stretched link or button when the whole card is clickable (the visible title isn't wired up automatically). */
|
|
246
54
|
label?: string
|
|
247
|
-
/**
|
|
55
|
+
/** In a Card.Group: the value the group selects when this card is clicked, which makes the card clickable. */
|
|
56
|
+
value?: string
|
|
57
|
+
/** Persistent selected fill + title emphasis, on top of fluid hover; overrides the group's `value`. The group drops the hairlines around a selected card. Defaults to the group's selection, else `false`. */
|
|
248
58
|
selected?: boolean
|
|
249
59
|
/** Dims and disables the card. Defaults to `false`. */
|
|
250
60
|
disabled?: boolean
|
|
@@ -256,10 +66,10 @@ interface CardProps extends Omit<HTMLAttributes<HTMLDivElement>, 'onClick'> {
|
|
|
256
66
|
onDismiss?: () => void
|
|
257
67
|
/** Pins the card to one step of the size ladder — compact tightens type and padding. Omitted, it follows the surrounding SizeProvider. */
|
|
258
68
|
size?: SizeVariant
|
|
259
|
-
/**
|
|
260
|
-
border?: CardBorder
|
|
261
|
-
/** Injected by Card.Group — do not set by hand. */
|
|
69
|
+
/** Position in its Card.Group. Defaults to the card's place among the group's children. */
|
|
262
70
|
index?: number
|
|
71
|
+
/** Frame of a standalone card: `"outlined"` draws the hairline an outlined Card.Group gives its tiles. In a Card.Group the group's `border` decides. Defaults to `"none"`. */
|
|
72
|
+
border?: CardBorder
|
|
263
73
|
}
|
|
264
74
|
|
|
265
75
|
type CardComponent = ForwardRefExoticComponent<CardProps & RefAttributes<HTMLDivElement>> & {
|
|
@@ -278,6 +88,10 @@ type CardComponent = ForwardRefExoticComponent<CardProps & RefAttributes<HTMLDiv
|
|
|
278
88
|
Button: typeof CardButton
|
|
279
89
|
}
|
|
280
90
|
|
|
91
|
+
const isCardImage = (child: ReactNode) =>
|
|
92
|
+
isValidElement(child) &&
|
|
93
|
+
(child.type === CardImage || (child.type as { displayName?: string }).displayName === 'CardImage')
|
|
94
|
+
|
|
281
95
|
/**
|
|
282
96
|
* shadcn's compositional card, dressed in Fluid Functionalism. Stacked,
|
|
283
97
|
* inline, or grid — borderless by default with fluid hover that previews
|
|
@@ -285,26 +99,29 @@ type CardComponent = ForwardRefExoticComponent<CardProps & RefAttributes<HTMLDiv
|
|
|
285
99
|
*
|
|
286
100
|
* The same parts and data-slot contract as shadcn's Card, on a transparent,
|
|
287
101
|
* borderless surface: a card inherits its parent's substrate and leans on
|
|
288
|
-
* hairline dividers rather than a drawn frame
|
|
289
|
-
*
|
|
290
|
-
*
|
|
291
|
-
*
|
|
292
|
-
*
|
|
293
|
-
*
|
|
102
|
+
* hairline dividers rather than a drawn frame. Card.Group owns the layout (a
|
|
103
|
+
* stacked list, inline rows or a grid) and numbers its cards for the fluid
|
|
104
|
+
* hover; only a clickable card (`onClick`, `href` or a `value`) joins the
|
|
105
|
+
* magnetic highlight. A clickable card is one stretched button or link, while
|
|
106
|
+
* footer actions and Card.Action stay independently clickable above it.
|
|
107
|
+
* Selection works both ways: the group's `value` / `defaultValue` /
|
|
108
|
+
* `onValueChange` against each card's `value`, or `selected` per card.
|
|
294
109
|
*
|
|
295
|
-
* Statics:
|
|
296
|
-
*
|
|
297
|
-
* grid
|
|
298
|
-
*
|
|
299
|
-
* Card.Action
|
|
300
|
-
*
|
|
301
|
-
*
|
|
302
|
-
* Card.Image
|
|
303
|
-
* Card.Eyebrow
|
|
304
|
-
*
|
|
305
|
-
*
|
|
110
|
+
* Statics:
|
|
111
|
+
* - `Card.Group` — the layout and the hover: `orientation`, `columns`, `border`, `separated`, `fluidHover`, `value`.
|
|
112
|
+
* - `Card.Header` — the title and description grid; pins Card.Action top-right.
|
|
113
|
+
* - `Card.Title` — weight-animates while the card is selected.
|
|
114
|
+
* - `Card.Description`, `Card.Action`, `Card.Content`, `Card.Footer` (the actions row).
|
|
115
|
+
* - `Card.Divider` — a hairline between parts, full-bleed; vertical in an inline card.
|
|
116
|
+
* - `Card.Media` — an icon tile, a logo or a `[logoA, logoB]` pair.
|
|
117
|
+
* - `Card.Image` — a full-bleed banner, or a leading image when inline.
|
|
118
|
+
* - `Card.Eyebrow` — a small muted label above the title.
|
|
119
|
+
* - `Card.Feature` — an icon + title + description row.
|
|
120
|
+
* - `Card.Button` — a compact Button for the footer; a link when given `href`.
|
|
306
121
|
*
|
|
307
122
|
* @example {@include ./examples.mdx}
|
|
123
|
+
* @source https://github.com/mickadesign/fluid-functionalism/blob/b3587bdbd83fc66c2a6aae3817ffb856cb09260b/registry/default/card.tsx Fluid Functionalism
|
|
124
|
+
* @license MIT © 2026 Micka Touillaud
|
|
308
125
|
*/
|
|
309
126
|
const Card = forwardRef<HTMLDivElement, CardProps>(
|
|
310
127
|
(
|
|
@@ -313,14 +130,15 @@ const Card = forwardRef<HTMLDivElement, CardProps>(
|
|
|
313
130
|
href,
|
|
314
131
|
external,
|
|
315
132
|
label,
|
|
316
|
-
|
|
133
|
+
value,
|
|
134
|
+
selected: selectedProp,
|
|
317
135
|
disabled = false,
|
|
318
136
|
dismissible = false,
|
|
319
137
|
dismissOnHover = true,
|
|
320
138
|
onDismiss,
|
|
321
139
|
size,
|
|
140
|
+
index: indexProp,
|
|
322
141
|
border = 'none',
|
|
323
|
-
index,
|
|
324
142
|
className,
|
|
325
143
|
children,
|
|
326
144
|
...props
|
|
@@ -329,12 +147,11 @@ const Card = forwardRef<HTMLDivElement, CardProps>(
|
|
|
329
147
|
) => {
|
|
330
148
|
const internalRef = useRef<HTMLDivElement>(null)
|
|
331
149
|
const shape = useShape()
|
|
332
|
-
|
|
333
|
-
// gaps agree with the SizeProvider it renders for its children.
|
|
334
|
-
const sizeClasses = useSize(size)
|
|
335
|
-
const compact = sizeClasses.variant === 'compact'
|
|
150
|
+
const compact = useSize(size).variant === 'compact'
|
|
336
151
|
const group = useContext(CardGroupContext)
|
|
337
152
|
const XIcon = useIcon('x')
|
|
153
|
+
const position = useRowPosition()
|
|
154
|
+
const index = indexProp ?? position
|
|
338
155
|
|
|
339
156
|
const orientation = group?.orientation ?? 'card'
|
|
340
157
|
const columns = group?.columns ?? 1
|
|
@@ -343,687 +160,187 @@ const Card = forwardRef<HTMLDivElement, CardProps>(
|
|
|
343
160
|
const divided = group?.divided ?? false
|
|
344
161
|
const outlined = group?.outlined ?? false
|
|
345
162
|
const activeIndex = group?.activeIndex ?? null
|
|
346
|
-
const
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
//
|
|
357
|
-
//
|
|
358
|
-
//
|
|
359
|
-
|
|
163
|
+
const selectable = group !== null && value !== undefined
|
|
164
|
+
const selected = selectedProp ?? (selectable && group.value === value)
|
|
165
|
+
const clickable = !!href || !!onClick || selectable
|
|
166
|
+
const press = selectable
|
|
167
|
+
? () => {
|
|
168
|
+
group.select(value)
|
|
169
|
+
onClick?.()
|
|
170
|
+
}
|
|
171
|
+
: onClick
|
|
172
|
+
|
|
173
|
+
// A highlight on a card with nothing to click would promise a click that
|
|
174
|
+
// has nowhere to land. The stable callback, not the context, so a hover
|
|
175
|
+
// frame doesn't re-register every card.
|
|
176
|
+
useRegisterFluidHoverItem(clickable ? group?.registerItem : undefined, index, internalRef)
|
|
177
|
+
|
|
178
|
+
const markSelected = group?.markSelected
|
|
179
|
+
useIsoLayoutEffect(() => {
|
|
180
|
+
if (!markSelected || index === undefined || !selected) return
|
|
181
|
+
markSelected(index, true)
|
|
182
|
+
return () => markSelected(index, false)
|
|
183
|
+
}, [markSelected, index, selected])
|
|
184
|
+
|
|
185
|
+
// A hairline toward the neighbour below and to the right, dropped beside
|
|
186
|
+
// the active or a selected card so the fill reads clean.
|
|
187
|
+
const self = index ?? -1
|
|
188
|
+
const col = self % columns
|
|
360
189
|
const hasBelow = index !== undefined && index + columns < count
|
|
361
190
|
const hasRight = index !== undefined && col < columns - 1 && index + 1 < count
|
|
362
|
-
const
|
|
363
|
-
const
|
|
364
|
-
const
|
|
365
|
-
const showBottom = divided && hasBelow && !(touchesBelow(activeIndex ?? -1) || touchesBelow(selectedIndex))
|
|
366
|
-
const showRight = divided && hasRight && !(touchesRight(activeIndex ?? -1) || touchesRight(selectedIndex))
|
|
191
|
+
const lit = (i: number) => i === activeIndex || !!group?.selectedRows.has(i)
|
|
192
|
+
const showBottom = divided && hasBelow && !(lit(self) || lit(self + columns))
|
|
193
|
+
const showRight = divided && hasRight && !(lit(self) || lit(self + 1))
|
|
367
194
|
|
|
368
195
|
const isInline = orientation === 'inline'
|
|
369
|
-
// An inline card with a full-bleed image reflows so its actions stack under
|
|
370
|
-
// the text (see the body wrapper below + CardHeader/CardFooter). Match the
|
|
371
|
-
// image child by identity OR displayName so detection and the split below
|
|
372
|
-
// agree even when module identity drifts (e.g. HMR duplication).
|
|
373
|
-
const isCardImage = (child: ReactNode) =>
|
|
374
|
-
isValidElement(child) &&
|
|
375
|
-
(child.type === CardImage || (child.type as { displayName?: string })?.displayName === 'CardImage')
|
|
376
196
|
const hasImage = Children.toArray(children).some(isCardImage)
|
|
377
197
|
const inlineImage = isInline && hasImage
|
|
378
|
-
const clickable = !!href || !!onClick
|
|
379
|
-
// Title weight follows the persistent selected state only — fluid hover
|
|
380
|
-
// previews via the highlight fill, not by bolding the label.
|
|
381
|
-
const emphasized = selected
|
|
382
198
|
|
|
383
|
-
//
|
|
384
|
-
//
|
|
385
|
-
//
|
|
386
|
-
// hug, so it stays unclipped and its media reads as a plain square, and a
|
|
387
|
-
// card in a continuous block leans on the shared group frame for both.
|
|
199
|
+
// Standalone, a card is its own tile. In a group, a separated tile clips
|
|
200
|
+
// only when it draws a frame (a borderless one has no surface to hug);
|
|
201
|
+
// a card in a continuous block leans on the group's frame.
|
|
388
202
|
const tileShape = !group
|
|
389
203
|
? cn(shape.container, 'overflow-hidden', border === 'outlined' && 'border border-border/60')
|
|
390
204
|
: separated && outlined
|
|
391
205
|
? cn(shape.container, 'overflow-hidden border border-border/60')
|
|
392
206
|
: ''
|
|
393
207
|
|
|
394
|
-
//
|
|
395
|
-
//
|
|
396
|
-
//
|
|
397
|
-
//
|
|
398
|
-
|
|
208
|
+
// The stretched overlay makes the whole card the target while actions
|
|
209
|
+
// (higher z) stay clickable: the accessible alternative to nesting controls
|
|
210
|
+
// in a button. A disabled card drops it, so it can't be tabbed to
|
|
211
|
+
// (pointer-events-none only blocks the mouse).
|
|
212
|
+
const overlayClass =
|
|
213
|
+
'absolute inset-0 z-20 outline-none focus-visible:ring-1 focus-visible:ring-focus-ring rounded-[inherit]'
|
|
399
214
|
const overlay =
|
|
400
215
|
clickable && !disabled ? (
|
|
401
216
|
href ? (
|
|
217
|
+
// biome-ignore lint/a11y/useAnchorContent: named by `label`; the card's content sits beside the stretched link.
|
|
402
218
|
<a
|
|
403
219
|
href={href}
|
|
404
|
-
onClick={
|
|
220
|
+
onClick={press}
|
|
405
221
|
target={external ? '_blank' : undefined}
|
|
406
222
|
rel={external ? 'noopener noreferrer' : undefined}
|
|
407
223
|
aria-label={label}
|
|
408
|
-
|
|
224
|
+
aria-current={selected || undefined}
|
|
225
|
+
className={overlayClass}
|
|
409
226
|
/>
|
|
410
227
|
) : (
|
|
411
228
|
<button
|
|
412
229
|
type="button"
|
|
413
|
-
onClick={
|
|
230
|
+
onClick={press}
|
|
414
231
|
aria-label={label}
|
|
415
232
|
aria-pressed={selected || undefined}
|
|
416
|
-
className=
|
|
233
|
+
className={overlayClass}
|
|
417
234
|
/>
|
|
418
235
|
)
|
|
419
236
|
) : null
|
|
420
237
|
|
|
421
238
|
const cardContext = useMemo<CardContextValue>(
|
|
422
|
-
() => ({ emphasized, orientation, clickable, hasImage }),
|
|
423
|
-
[
|
|
239
|
+
() => ({ emphasized: selected, orientation, clickable, hasImage }),
|
|
240
|
+
[selected, orientation, clickable, hasImage],
|
|
424
241
|
)
|
|
425
242
|
|
|
426
|
-
// Inline image cards
|
|
427
|
-
// title, description, and actions hug together and sit vertically centred
|
|
428
|
-
// against the image instead of stretching to its full height.
|
|
243
|
+
// Inline image cards stack their other parts in a centred column beside the image.
|
|
429
244
|
let body: ReactNode = children
|
|
430
245
|
if (inlineImage) {
|
|
431
246
|
const parts = Children.toArray(children)
|
|
432
247
|
const image = parts.find(isCardImage)
|
|
433
|
-
const rest = parts.filter(part => part !== image)
|
|
434
248
|
body = (
|
|
435
249
|
<>
|
|
436
250
|
{image}
|
|
437
251
|
<div
|
|
438
252
|
className={cn('flex min-w-0 flex-1 flex-col justify-center gap-2', compact ? 'py-2.5 pr-3' : 'py-3.5 pr-4')}
|
|
439
253
|
>
|
|
440
|
-
{
|
|
254
|
+
{parts.filter(part => part !== image)}
|
|
441
255
|
</div>
|
|
442
256
|
</>
|
|
443
257
|
)
|
|
444
258
|
}
|
|
445
259
|
|
|
446
|
-
|
|
447
|
-
<
|
|
448
|
-
<
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
:
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
// Over media the control needs its own ground, or the icon
|
|
525
|
-
// reads against whatever the image happens to be. Elsewhere
|
|
526
|
-
// the usual hover fill is enough. The chip takes the button
|
|
527
|
-
// radius either way.
|
|
528
|
-
hasImage ? 'bg-card/70 backdrop-blur-sm hover:bg-card' : 'hover:bg-hover',
|
|
529
|
-
// Revealed on hover / focus. focus-visible covers the keyboard
|
|
530
|
-
// path, since the control is the only way to dismiss.
|
|
531
|
-
// pointer-events gates alongside opacity: an invisible
|
|
532
|
-
// control must not swallow taps meant for the card (touch has
|
|
533
|
-
// no hover to reveal it). Keyboard focus still reaches it —
|
|
534
|
-
// pointer-events never blocks tabbing.
|
|
535
|
-
dismissOnHover &&
|
|
536
|
-
'pointer-events-none opacity-0 transition-opacity duration-fast group-hover/card:pointer-events-auto group-hover/card:opacity-100 group-focus-within/card:pointer-events-auto group-focus-within/card:opacity-100 focus-visible:pointer-events-auto focus-visible:opacity-100',
|
|
537
|
-
shape.button,
|
|
538
|
-
)}
|
|
539
|
-
>
|
|
540
|
-
<XIcon size={compact ? 13 : 15} strokeWidth={1.5} />
|
|
541
|
-
</button>
|
|
542
|
-
)}
|
|
543
|
-
</div>
|
|
544
|
-
</CardContext.Provider>
|
|
260
|
+
return (
|
|
261
|
+
<SizeScope size={size}>
|
|
262
|
+
<CardContext.Provider value={cardContext}>
|
|
263
|
+
<div
|
|
264
|
+
ref={mergeRefs(internalRef, ref)}
|
|
265
|
+
data-slot="card"
|
|
266
|
+
data-fluid-hover-index={index}
|
|
267
|
+
data-selected={selected || undefined}
|
|
268
|
+
data-orientation={orientation}
|
|
269
|
+
aria-disabled={disabled || undefined}
|
|
270
|
+
className={cn(
|
|
271
|
+
'group/card relative z-10 min-w-0 min-h-[60px]',
|
|
272
|
+
inlineImage
|
|
273
|
+
? cn('flex flex-row items-center', compact ? 'gap-2.5' : 'gap-3')
|
|
274
|
+
: isInline
|
|
275
|
+
? cn('flex flex-row items-center', compact ? 'gap-2.5 pl-3' : 'gap-3 pl-4')
|
|
276
|
+
: cn('flex flex-col', compact ? 'pb-3' : 'pb-4'),
|
|
277
|
+
// Without a group's highlight, a clickable card tints itself.
|
|
278
|
+
!group && clickable && !disabled && 'transition-colors duration-fast hover:bg-hover',
|
|
279
|
+
// An inline row's dismiss would sit on the title's tail: the
|
|
280
|
+
// header yields the room while the control shows.
|
|
281
|
+
dismissible &&
|
|
282
|
+
isInline &&
|
|
283
|
+
(dismissOnHover
|
|
284
|
+
? '[&:hover_[data-slot=card-header]]:pr-10 [&:focus-within_[data-slot=card-header]]:pr-10'
|
|
285
|
+
: '[&_[data-slot=card-header]]:pr-10'),
|
|
286
|
+
tileShape,
|
|
287
|
+
disabled && 'opacity-50 pointer-events-none',
|
|
288
|
+
className,
|
|
289
|
+
)}
|
|
290
|
+
{...props}
|
|
291
|
+
>
|
|
292
|
+
{/* Fill and dividers sit behind the content (-z-10), the overlay above it (z-20), actions above that (z-30). */}
|
|
293
|
+
{selected && (
|
|
294
|
+
<span
|
|
295
|
+
aria-hidden
|
|
296
|
+
className={cn('absolute inset-0 -z-10 bg-active pointer-events-none', shape.container)}
|
|
297
|
+
/>
|
|
298
|
+
)}
|
|
299
|
+
{showBottom && (
|
|
300
|
+
<span aria-hidden className="absolute inset-x-0 bottom-0 h-px bg-border/60 pointer-events-none -z-10" />
|
|
301
|
+
)}
|
|
302
|
+
{/* Stops 1px short of a bottom hairline, which owns the crossing pixel: two 60% lines would stack brighter. */}
|
|
303
|
+
{showRight && (
|
|
304
|
+
<span
|
|
305
|
+
aria-hidden
|
|
306
|
+
className={cn(
|
|
307
|
+
'absolute top-0 right-0 w-px bg-border/60 pointer-events-none -z-10',
|
|
308
|
+
showBottom ? 'bottom-px' : 'bottom-0',
|
|
309
|
+
)}
|
|
310
|
+
/>
|
|
311
|
+
)}
|
|
312
|
+
|
|
313
|
+
{overlay}
|
|
314
|
+
{body}
|
|
315
|
+
|
|
316
|
+
{dismissible && (
|
|
317
|
+
<button
|
|
318
|
+
type="button"
|
|
319
|
+
onClick={onDismiss}
|
|
320
|
+
aria-label="Dismiss"
|
|
321
|
+
className={cn(
|
|
322
|
+
'absolute right-2 top-2 z-30 flex h-7 w-7 items-center justify-center text-muted-foreground hover:text-foreground cursor-pointer outline-none transition-colors duration-fast focus-visible:ring-1 focus-visible:ring-focus-ring',
|
|
323
|
+
// Over media the icon needs its own ground.
|
|
324
|
+
hasImage ? 'bg-card/70 backdrop-blur-sm hover:bg-card' : 'hover:bg-hover',
|
|
325
|
+
// An invisible control must not swallow taps meant for the card
|
|
326
|
+
// (touch has no hover to reveal it); pointer-events never blocks tabbing.
|
|
327
|
+
dismissOnHover &&
|
|
328
|
+
'pointer-events-none opacity-0 transition-opacity duration-fast group-hover/card:pointer-events-auto group-hover/card:opacity-100 group-focus-within/card:pointer-events-auto group-focus-within/card:opacity-100 focus-visible:pointer-events-auto focus-visible:opacity-100',
|
|
329
|
+
shape.button,
|
|
330
|
+
)}
|
|
331
|
+
>
|
|
332
|
+
<XIcon size={compact ? 13 : 15} strokeWidth={1.5} />
|
|
333
|
+
</button>
|
|
334
|
+
)}
|
|
335
|
+
</div>
|
|
336
|
+
</CardContext.Provider>
|
|
337
|
+
</SizeScope>
|
|
545
338
|
)
|
|
546
|
-
|
|
547
|
-
// A size prop pins the card (and everything ladder-aware inside it) to one
|
|
548
|
-
// ladder step; the parts read the context.
|
|
549
|
-
return size ? <SizeProvider size={size}>{card}</SizeProvider> : card
|
|
550
339
|
},
|
|
551
340
|
) as CardComponent
|
|
552
341
|
|
|
553
342
|
Card.displayName = 'Card'
|
|
554
343
|
|
|
555
|
-
// ── CardHeader ───────────────────────────────────────────
|
|
556
|
-
// shadcn's header grid: title + description stack, with CardAction pinned to
|
|
557
|
-
// the top-right column. In an inline card it becomes the flexible text column
|
|
558
|
-
// between the leading media and trailing footer.
|
|
559
|
-
|
|
560
|
-
const CardHeader = forwardRef<HTMLDivElement, HTMLAttributes<HTMLDivElement>>(({ className, ...props }, ref) => {
|
|
561
|
-
const { orientation, hasImage } = useContext(CardContext)
|
|
562
|
-
const inlineImage = orientation === 'inline' && hasImage
|
|
563
|
-
const sizeClasses = useSize()
|
|
564
|
-
const compact = sizeClasses.variant === 'compact'
|
|
565
|
-
return (
|
|
566
|
-
<div
|
|
567
|
-
ref={ref}
|
|
568
|
-
data-slot="card-header"
|
|
569
|
-
className={cn(
|
|
570
|
-
'grid auto-rows-min items-start gap-1 has-data-[slot=card-action]:grid-cols-[1fr_auto]',
|
|
571
|
-
inlineImage
|
|
572
|
-
? 'min-w-0'
|
|
573
|
-
: orientation === 'inline'
|
|
574
|
-
? cn('min-w-0 flex-1', compact ? 'py-2.5' : 'py-3.5')
|
|
575
|
-
: compact
|
|
576
|
-
? 'px-3 pt-3'
|
|
577
|
-
: 'px-4 pt-4',
|
|
578
|
-
className,
|
|
579
|
-
)}
|
|
580
|
-
{...props}
|
|
581
|
-
/>
|
|
582
|
-
)
|
|
583
|
-
})
|
|
584
|
-
|
|
585
|
-
CardHeader.displayName = 'CardHeader'
|
|
586
|
-
|
|
587
|
-
// ── CardTitle ────────────────────────────────────────────
|
|
588
|
-
|
|
589
|
-
type CardTitleTag = 'span' | 'div' | 'p' | 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6'
|
|
590
|
-
|
|
591
|
-
interface CardTitleProps extends HTMLAttributes<HTMLSpanElement> {
|
|
592
|
-
/** The element the title renders as: a heading level (`'h2'`, `'h3'`, …) for a page outline, or another tag. The title keeps its look whatever the tag. Defaults to `'span'`. */
|
|
593
|
-
as?: CardTitleTag
|
|
594
|
-
}
|
|
595
|
-
|
|
596
|
-
const CardTitle = forwardRef<HTMLSpanElement, CardTitleProps>(
|
|
597
|
-
({ as: Tag = 'span', className, children, ...props }, ref) => {
|
|
598
|
-
const { emphasized, orientation } = useContext(CardContext)
|
|
599
|
-
const sizeClasses = useSize()
|
|
600
|
-
const compact = sizeClasses.variant === 'compact'
|
|
601
|
-
// Inline rows trim the title to cap height so it centres tightly against
|
|
602
|
-
// the media/actions; stacked cards keep the natural line box.
|
|
603
|
-
const trim = orientation === 'inline' ? '[text-box:trim-both_cap_alphabetic]' : ''
|
|
604
|
-
// Ghost-span pattern: an invisible semibold copy reserves the width so the
|
|
605
|
-
// resting→active weight animation never reflows the row.
|
|
606
|
-
//
|
|
607
|
-
// Truncation support: a consumer's `truncate` lands on this grid, whose
|
|
608
|
-
// text-overflow can't ellipsize (only a block's own line boxes can — grid
|
|
609
|
-
// children just clip). The nowrap it sets inherits into the cell spans,
|
|
610
|
-
// so giving those spans overflow-hidden + ellipsis renders the … there
|
|
611
|
-
// instead; minmax(0,1fr) clamps the implicit track to the clipped grid's
|
|
612
|
-
// width so the ellipsis falls inside the visible box. All of it is inert
|
|
613
|
-
// while titles wrap normally.
|
|
614
|
-
return (
|
|
615
|
-
<Tag
|
|
616
|
-
ref={ref as Ref<HTMLHeadingElement>}
|
|
617
|
-
data-slot="card-title"
|
|
618
|
-
className={cn(
|
|
619
|
-
'inline-grid grid-cols-[minmax(0,1fr)] leading-snug',
|
|
620
|
-
Tag !== 'span' && 'm-0',
|
|
621
|
-
compact ? 'text-subtitle-compact' : 'text-subtitle',
|
|
622
|
-
className,
|
|
623
|
-
)}
|
|
624
|
-
{...props}
|
|
625
|
-
>
|
|
626
|
-
<span
|
|
627
|
-
className={cn(
|
|
628
|
-
'col-start-1 row-start-1 invisible min-w-0 overflow-hidden text-ellipsis',
|
|
629
|
-
trim,
|
|
630
|
-
'weight-semibold',
|
|
631
|
-
)}
|
|
632
|
-
aria-hidden="true"
|
|
633
|
-
>
|
|
634
|
-
{children}
|
|
635
|
-
</span>
|
|
636
|
-
<span
|
|
637
|
-
className={cn(
|
|
638
|
-
'col-start-1 row-start-1 min-w-0 overflow-hidden text-ellipsis text-foreground transition-[font-variation-settings] duration-fast',
|
|
639
|
-
trim,
|
|
640
|
-
// normal → semibold on emphasis, matching nav-item / menu-item /
|
|
641
|
-
// table (the opsz-paired tokens keep the advance width ~constant).
|
|
642
|
-
emphasized ? 'weight-semibold' : 'weight-normal',
|
|
643
|
-
)}
|
|
644
|
-
>
|
|
645
|
-
{children}
|
|
646
|
-
</span>
|
|
647
|
-
</Tag>
|
|
648
|
-
)
|
|
649
|
-
},
|
|
650
|
-
)
|
|
651
|
-
|
|
652
|
-
CardTitle.displayName = 'CardTitle'
|
|
653
|
-
|
|
654
|
-
// ── CardDescription ──────────────────────────────────────
|
|
655
|
-
|
|
656
|
-
const CardDescription = forwardRef<HTMLParagraphElement, HTMLAttributes<HTMLParagraphElement>>(
|
|
657
|
-
({ className, ...props }, ref) => {
|
|
658
|
-
const sizeClasses = useSize()
|
|
659
|
-
const compact = sizeClasses.variant === 'compact'
|
|
660
|
-
return (
|
|
661
|
-
<p
|
|
662
|
-
ref={ref}
|
|
663
|
-
data-slot="card-description"
|
|
664
|
-
className={cn(
|
|
665
|
-
'leading-normal text-muted-foreground',
|
|
666
|
-
compact ? 'text-subtitle-compact' : 'text-subtitle',
|
|
667
|
-
className,
|
|
668
|
-
)}
|
|
669
|
-
{...props}
|
|
670
|
-
/>
|
|
671
|
-
)
|
|
672
|
-
},
|
|
673
|
-
)
|
|
674
|
-
|
|
675
|
-
CardDescription.displayName = 'CardDescription'
|
|
676
|
-
|
|
677
|
-
// ── CardAction ───────────────────────────────────────────
|
|
678
|
-
// Pinned to the header's top-right column (shadcn's slot). Sits above the
|
|
679
|
-
// stretched overlay so any control inside stays independently clickable.
|
|
680
|
-
|
|
681
|
-
const CardAction = forwardRef<HTMLDivElement, HTMLAttributes<HTMLDivElement>>(({ className, ...props }, ref) => (
|
|
682
|
-
<div
|
|
683
|
-
ref={ref}
|
|
684
|
-
data-slot="card-action"
|
|
685
|
-
className={cn('relative z-30 col-start-2 row-span-2 row-start-1 self-start justify-self-end', className)}
|
|
686
|
-
{...props}
|
|
687
|
-
/>
|
|
688
|
-
))
|
|
689
|
-
|
|
690
|
-
CardAction.displayName = 'CardAction'
|
|
691
|
-
|
|
692
|
-
// ── CardContent ──────────────────────────────────────────
|
|
693
|
-
|
|
694
|
-
interface CardContentProps extends HTMLAttributes<HTMLDivElement> {
|
|
695
|
-
/** Sets the size ladder's body text (`text-body`, one step down in a compact region) on the content, so plain text there no longer takes the size of whatever surrounds the card. Off, the content inherits it, as before. Defaults to `false`. */
|
|
696
|
-
bodyText?: boolean
|
|
697
|
-
}
|
|
698
|
-
|
|
699
|
-
const CardContent = forwardRef<HTMLDivElement, CardContentProps>(({ bodyText = false, className, ...props }, ref) => {
|
|
700
|
-
const { orientation } = useContext(CardContext)
|
|
701
|
-
const sizeClasses = useSize()
|
|
702
|
-
const compact = sizeClasses.variant === 'compact'
|
|
703
|
-
return (
|
|
704
|
-
<div
|
|
705
|
-
ref={ref}
|
|
706
|
-
data-slot="card-content"
|
|
707
|
-
className={cn(
|
|
708
|
-
orientation === 'inline' ? '' : compact ? 'px-3 pt-2.5' : 'px-4 pt-3',
|
|
709
|
-
bodyText && sizeClasses.text,
|
|
710
|
-
className,
|
|
711
|
-
)}
|
|
712
|
-
{...props}
|
|
713
|
-
/>
|
|
714
|
-
)
|
|
715
|
-
})
|
|
716
|
-
|
|
717
|
-
CardContent.displayName = 'CardContent'
|
|
718
|
-
|
|
719
|
-
// ── CardFooter ───────────────────────────────────────────
|
|
720
|
-
// Actions row. Rises above the stretched overlay (z-30) so buttons stay
|
|
721
|
-
// clickable. In an inline card it becomes the trailing, right-aligned slot.
|
|
722
|
-
|
|
723
|
-
const CardFooter = forwardRef<HTMLDivElement, HTMLAttributes<HTMLDivElement>>(({ className, ...props }, ref) => {
|
|
724
|
-
const { orientation, hasImage } = useContext(CardContext)
|
|
725
|
-
const inlineImage = orientation === 'inline' && hasImage
|
|
726
|
-
const sizeClasses = useSize()
|
|
727
|
-
const compact = sizeClasses.variant === 'compact'
|
|
728
|
-
return (
|
|
729
|
-
<div
|
|
730
|
-
ref={ref}
|
|
731
|
-
data-slot="card-footer"
|
|
732
|
-
className={cn(
|
|
733
|
-
'relative z-30 flex items-center gap-1',
|
|
734
|
-
inlineImage
|
|
735
|
-
? // Under the text, left-aligned in natural order (the inline
|
|
736
|
-
// wrapper owns the spacing).
|
|
737
|
-
'flex-wrap'
|
|
738
|
-
: orientation === 'inline'
|
|
739
|
-
? cn('shrink-0 ml-auto', compact ? 'pr-3' : 'pr-4')
|
|
740
|
-
: cn('flex-wrap', compact ? 'px-3 pt-2.5' : 'px-4 pt-3'),
|
|
741
|
-
className,
|
|
742
|
-
)}
|
|
743
|
-
{...props}
|
|
744
|
-
/>
|
|
745
|
-
)
|
|
746
|
-
})
|
|
747
|
-
|
|
748
|
-
CardFooter.displayName = 'CardFooter'
|
|
749
|
-
|
|
750
|
-
// ── CardDivider ──────────────────────────────────────────
|
|
751
|
-
// Local: a hairline across the card between two parts. The card has no
|
|
752
|
-
// padding of its own, so a direct child runs edge to edge; its top margin
|
|
753
|
-
// matches the parts' top padding, so the gap reads the same on both sides.
|
|
754
|
-
|
|
755
|
-
const CardDivider = forwardRef<HTMLDivElement, SeparatorProps>(({ className, orientation, ...props }, ref) => {
|
|
756
|
-
const { orientation: cardOrientation } = useContext(CardContext)
|
|
757
|
-
const compact = useSize().variant === 'compact'
|
|
758
|
-
const vertical = (orientation ?? (cardOrientation === 'inline' ? 'vertical' : 'horizontal')) === 'vertical'
|
|
759
|
-
return (
|
|
760
|
-
<Separator
|
|
761
|
-
ref={ref}
|
|
762
|
-
data-slot="card-divider"
|
|
763
|
-
{...props}
|
|
764
|
-
orientation={vertical ? 'vertical' : 'horizontal'}
|
|
765
|
-
className={cn(
|
|
766
|
-
'bg-border/60',
|
|
767
|
-
vertical ? (compact ? 'my-2.5' : 'my-3.5') : compact ? 'mt-2.5' : 'mt-3',
|
|
768
|
-
className,
|
|
769
|
-
)}
|
|
770
|
-
/>
|
|
771
|
-
)
|
|
772
|
-
})
|
|
773
|
-
|
|
774
|
-
CardDivider.displayName = 'CardDivider'
|
|
775
|
-
|
|
776
|
-
// ── CardMedia ────────────────────────────────────────────
|
|
777
|
-
// FF addition: a leading icon or brand logo(s). Not part of shadcn's anatomy,
|
|
778
|
-
// but the connective tissue most product cards need. A tuple renders a
|
|
779
|
-
// connected logo pair (e.g. a trigger — target).
|
|
780
|
-
|
|
781
|
-
type CardLogo = string | [string, string]
|
|
782
|
-
|
|
783
|
-
interface CardMediaProps {
|
|
784
|
-
logo?: CardLogo
|
|
785
|
-
logoAlt?: string
|
|
786
|
-
icon?: IconComponent
|
|
787
|
-
size?: number
|
|
788
|
-
className?: string
|
|
789
|
-
}
|
|
790
|
-
|
|
791
|
-
function CardMedia({ logo, logoAlt, icon: Icon, size = 22, className }: CardMediaProps) {
|
|
792
|
-
const { orientation } = useContext(CardContext)
|
|
793
|
-
const shape = useShape()
|
|
794
|
-
const sizeClasses = useSize()
|
|
795
|
-
const compact = sizeClasses.variant === 'compact'
|
|
796
|
-
// Stacked: sits in the header grid; add an extra 8px so the gap below the
|
|
797
|
-
// icon reads 12px (header gap-1 + mb-2). Inline: leading slot — the card owns
|
|
798
|
-
// the left inset, so no extra padding here.
|
|
799
|
-
const wrap = cn(orientation === 'inline' ? '' : 'mb-2', className)
|
|
800
|
-
|
|
801
|
-
if (logo) {
|
|
802
|
-
const logos = Array.isArray(logo) ? logo : [logo]
|
|
803
|
-
return (
|
|
804
|
-
<span data-slot="card-media" className={cn('inline-flex items-center gap-1.5 shrink-0', wrap)}>
|
|
805
|
-
{logos.map((src, i) => (
|
|
806
|
-
<span key={i} className="inline-flex items-center gap-1.5">
|
|
807
|
-
{i > 0 && <span aria-hidden className="w-2 h-px bg-border" />}
|
|
808
|
-
{/* eslint-disable-next-line @next/next/no-img-element */}
|
|
809
|
-
<img
|
|
810
|
-
src={src}
|
|
811
|
-
alt={logoAlt ?? ''}
|
|
812
|
-
width={size}
|
|
813
|
-
height={size}
|
|
814
|
-
className={cn('object-contain', shape.bg)}
|
|
815
|
-
style={{ width: size, height: size }}
|
|
816
|
-
/>
|
|
817
|
-
</span>
|
|
818
|
-
))}
|
|
819
|
-
</span>
|
|
820
|
-
)
|
|
821
|
-
}
|
|
822
|
-
if (Icon) {
|
|
823
|
-
// The icon sits in a 32×32 tinted tile so it reads as a media slot rather
|
|
824
|
-
// than a bare glyph. The tile is an overlay tint (not a solid surface) so it
|
|
825
|
-
// blends over whatever is behind it — the substrate or the hover highlight.
|
|
826
|
-
return (
|
|
827
|
-
<span
|
|
828
|
-
data-slot="card-media"
|
|
829
|
-
className={cn('inline-flex items-center justify-center shrink-0 size-8 bg-hover', shape.bg, wrap)}
|
|
830
|
-
>
|
|
831
|
-
<Icon size={compact ? 16 : 18} strokeWidth={1.5} className="text-muted-foreground" />
|
|
832
|
-
</span>
|
|
833
|
-
)
|
|
834
|
-
}
|
|
835
|
-
return null
|
|
836
|
-
}
|
|
837
|
-
|
|
838
|
-
// ── CardImage ────────────────────────────────────────────
|
|
839
|
-
// FF addition: the prominent, full-bleed image (distinct from a small logo).
|
|
840
|
-
// Stacked → a top banner; inline → a full-height leading image on the left that
|
|
841
|
-
// bleeds past the card's left inset to sit flush against the edge.
|
|
842
|
-
|
|
843
|
-
interface CardImageProps {
|
|
844
|
-
src: string
|
|
845
|
-
alt?: string
|
|
846
|
-
className?: string
|
|
847
|
-
}
|
|
848
|
-
|
|
849
|
-
function CardImage({ src, alt, className }: CardImageProps) {
|
|
850
|
-
const { orientation } = useContext(CardContext)
|
|
851
|
-
return (
|
|
852
|
-
// eslint-disable-next-line @next/next/no-img-element
|
|
853
|
-
<img
|
|
854
|
-
src={src}
|
|
855
|
-
alt={alt ?? ''}
|
|
856
|
-
data-slot="card-image"
|
|
857
|
-
// The image keeps a fixed 2px corner radius in every state — stacked or
|
|
858
|
-
// inline, framed or borderless — rather than inheriting a frame's larger
|
|
859
|
-
// clip. (A framed tile still clips the surrounding surface as before.)
|
|
860
|
-
className={cn(
|
|
861
|
-
'object-cover rounded-xs',
|
|
862
|
-
orientation === 'inline' ? 'size-40 shrink-0' : 'w-full aspect-[16/9]',
|
|
863
|
-
className,
|
|
864
|
-
)}
|
|
865
|
-
/>
|
|
866
|
-
)
|
|
867
|
-
}
|
|
868
|
-
|
|
869
|
-
// A stable marker so the Card can recognise an image child by name, surviving
|
|
870
|
-
// module-identity mismatches (e.g. HMR duplication) that break `type ===`.
|
|
871
|
-
CardImage.displayName = 'CardImage'
|
|
872
|
-
|
|
873
|
-
// ── CardEyebrow ──────────────────────────────────────────
|
|
874
|
-
// Small uppercase label above the title (e.g. "New Model"). Typographically
|
|
875
|
-
// it's the caption role of the type scale in uppercase — see /docs/sizes.
|
|
876
|
-
|
|
877
|
-
const CardEyebrow = forwardRef<HTMLSpanElement, HTMLAttributes<HTMLSpanElement>>(({ className, ...props }, ref) => {
|
|
878
|
-
const compact = useSize().variant === 'compact'
|
|
879
|
-
return (
|
|
880
|
-
<span
|
|
881
|
-
ref={ref}
|
|
882
|
-
data-slot="card-eyebrow"
|
|
883
|
-
className={cn(
|
|
884
|
-
compact ? 'text-caption-compact' : 'text-caption',
|
|
885
|
-
'uppercase tracking-wide text-muted-foreground',
|
|
886
|
-
'weight-semibold',
|
|
887
|
-
className,
|
|
888
|
-
)}
|
|
889
|
-
{...props}
|
|
890
|
-
/>
|
|
891
|
-
)
|
|
892
|
-
})
|
|
893
|
-
|
|
894
|
-
CardEyebrow.displayName = 'CardEyebrow'
|
|
895
|
-
|
|
896
|
-
// ── CardFeature ──────────────────────────────────────────
|
|
897
|
-
// FF addition: an icon + title + description row, for feature lists inside
|
|
898
|
-
// CardContent.
|
|
899
|
-
|
|
900
|
-
interface CardFeatureProps {
|
|
901
|
-
icon?: IconComponent
|
|
902
|
-
title: string
|
|
903
|
-
description?: string
|
|
904
|
-
}
|
|
905
|
-
|
|
906
|
-
function CardFeature({ icon: Icon, title, description }: CardFeatureProps) {
|
|
907
|
-
const sizeClasses = useSize()
|
|
908
|
-
const compact = sizeClasses.variant === 'compact'
|
|
909
|
-
return (
|
|
910
|
-
<div data-slot="card-feature" className={cn('flex items-start', sizeClasses.gap)}>
|
|
911
|
-
{Icon && <Icon size={sizeClasses.icon} strokeWidth={1.5} className="mt-0.5 shrink-0 text-muted-foreground" />}
|
|
912
|
-
<div className="flex flex-col gap-0.5 min-w-0">
|
|
913
|
-
<span className={cn('text-foreground [text-box:trim-both_cap_alphabetic]', sizeClasses.text, 'weight-medium')}>
|
|
914
|
-
{title}
|
|
915
|
-
</span>
|
|
916
|
-
{description && (
|
|
917
|
-
<span
|
|
918
|
-
className={cn('leading-relaxed text-muted-foreground', compact ? 'text-caption-compact' : 'text-caption')}
|
|
919
|
-
>
|
|
920
|
-
{description}
|
|
921
|
-
</span>
|
|
922
|
-
)}
|
|
923
|
-
</div>
|
|
924
|
-
</div>
|
|
925
|
-
)
|
|
926
|
-
}
|
|
927
|
-
|
|
928
|
-
// ── CardButton ───────────────────────────────────────────
|
|
929
|
-
// Self-contained action button for the footer (keeps Card free of a Button
|
|
930
|
-
// dependency, so it installs standalone). Renders an anchor when `href` is set.
|
|
931
|
-
|
|
932
|
-
type CardButtonVariant = 'primary' | 'secondary' | 'ghost' | 'link'
|
|
933
|
-
|
|
934
|
-
const CARD_BUTTON_VARIANTS: Record<CardButtonVariant, string> = {
|
|
935
|
-
primary: 'bg-foreground text-background hover:bg-foreground/90 active:bg-foreground/80',
|
|
936
|
-
secondary: 'bg-accent text-foreground hover:bg-accent/80 active:bg-accent',
|
|
937
|
-
ghost: 'text-muted-foreground hover:text-foreground hover:bg-hover active:bg-active',
|
|
938
|
-
link: 'text-foreground underline-offset-4 hover:underline !px-0 !h-auto',
|
|
939
|
-
}
|
|
940
|
-
|
|
941
|
-
interface CardButtonProps {
|
|
942
|
-
children: React.ReactNode
|
|
943
|
-
onClick?: () => void
|
|
944
|
-
href?: string
|
|
945
|
-
variant?: CardButtonVariant
|
|
946
|
-
icon?: IconComponent
|
|
947
|
-
iconPosition?: 'start' | 'end'
|
|
948
|
-
/** Opens the href in a new tab and appends an outward arrow glyph. */
|
|
949
|
-
external?: boolean
|
|
950
|
-
disabled?: boolean
|
|
951
|
-
}
|
|
952
|
-
|
|
953
|
-
function CardButton({
|
|
954
|
-
children,
|
|
955
|
-
onClick,
|
|
956
|
-
href,
|
|
957
|
-
variant = 'ghost',
|
|
958
|
-
icon: Icon,
|
|
959
|
-
iconPosition,
|
|
960
|
-
external = false,
|
|
961
|
-
disabled = false,
|
|
962
|
-
}: CardButtonProps) {
|
|
963
|
-
const shape = useShape()
|
|
964
|
-
const ArrowRight = useIcon('arrow-right')
|
|
965
|
-
const sizeClasses = useSize()
|
|
966
|
-
const compact = sizeClasses.variant === 'compact'
|
|
967
|
-
const position = iconPosition ?? (external ? 'end' : 'start')
|
|
968
|
-
|
|
969
|
-
const glyph = Icon ? (
|
|
970
|
-
<Icon
|
|
971
|
-
size={compact ? 12 : 14}
|
|
972
|
-
strokeWidth={1.5}
|
|
973
|
-
className="shrink-0 transition-[stroke-width] duration-fast group-hover/action:stroke-[2]"
|
|
974
|
-
/>
|
|
975
|
-
) : null
|
|
976
|
-
const externalGlyph = external ? (
|
|
977
|
-
<ArrowRight
|
|
978
|
-
size={13}
|
|
979
|
-
strokeWidth={1.5}
|
|
980
|
-
className="shrink-0 -rotate-45 transition-[stroke-width] duration-fast group-hover/action:stroke-[2]"
|
|
981
|
-
/>
|
|
982
|
-
) : null
|
|
983
|
-
|
|
984
|
-
const inner = (
|
|
985
|
-
<>
|
|
986
|
-
{position === 'start' && glyph}
|
|
987
|
-
<span className="[text-box:trim-both_cap_alphabetic]">{children}</span>
|
|
988
|
-
{position === 'end' && glyph}
|
|
989
|
-
{externalGlyph}
|
|
990
|
-
</>
|
|
991
|
-
)
|
|
992
|
-
|
|
993
|
-
const classes = cn(
|
|
994
|
-
'group/action relative z-30 inline-flex items-center justify-center gap-1.5 h-7 px-2.5 cursor-pointer outline-none',
|
|
995
|
-
compact ? 'text-caption-compact' : 'text-caption',
|
|
996
|
-
'weight-medium',
|
|
997
|
-
'transition-colors duration-fast',
|
|
998
|
-
'focus-visible:ring-1 focus-visible:ring-focus-ring',
|
|
999
|
-
'disabled:opacity-50 disabled:pointer-events-none',
|
|
1000
|
-
shape.button,
|
|
1001
|
-
CARD_BUTTON_VARIANTS[variant],
|
|
1002
|
-
)
|
|
1003
|
-
|
|
1004
|
-
if (href) {
|
|
1005
|
-
return (
|
|
1006
|
-
<a
|
|
1007
|
-
href={href}
|
|
1008
|
-
onClick={onClick}
|
|
1009
|
-
target={external ? '_blank' : undefined}
|
|
1010
|
-
rel={external ? 'noopener noreferrer' : undefined}
|
|
1011
|
-
className={classes}
|
|
1012
|
-
>
|
|
1013
|
-
{inner}
|
|
1014
|
-
</a>
|
|
1015
|
-
)
|
|
1016
|
-
}
|
|
1017
|
-
|
|
1018
|
-
return (
|
|
1019
|
-
<button type="button" onClick={onClick} disabled={disabled} className={classes}>
|
|
1020
|
-
{inner}
|
|
1021
|
-
</button>
|
|
1022
|
-
)
|
|
1023
|
-
}
|
|
1024
|
-
|
|
1025
|
-
// Compound statics: `<Card.Group>`, `<Card.Header>`, … (typed by the
|
|
1026
|
-
// CardComponent cast on the forwardRef above).
|
|
1027
344
|
Object.assign(Card, {
|
|
1028
345
|
Group: CardGroup,
|
|
1029
346
|
Header: CardHeader,
|
|
@@ -1040,17 +357,9 @@ Object.assign(Card, {
|
|
|
1040
357
|
Button: CardButton,
|
|
1041
358
|
})
|
|
1042
359
|
|
|
1043
|
-
export type {
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
CardButtonVariant,
|
|
1047
|
-
CardContentProps,
|
|
1048
|
-
CardGroupProps,
|
|
1049
|
-
CardLogo,
|
|
1050
|
-
CardProps,
|
|
1051
|
-
CardTitleProps,
|
|
1052
|
-
CardTitleTag,
|
|
1053
|
-
}
|
|
360
|
+
export type { CardBorder, CardGroupProps, CardOrientation } from './card-group'
|
|
361
|
+
export type { CardButtonProps, CardFeatureProps, CardImageProps, CardLogo, CardMediaProps } from './card-media'
|
|
362
|
+
export type { CardProps }
|
|
1054
363
|
export {
|
|
1055
364
|
Card,
|
|
1056
365
|
CardAction,
|