@brightlocal/ui-components 3.1.0 → 3.3.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/AI_USAGE.md +10 -0
- package/README.md +8 -1
- package/component-meta.json +1591 -123
- package/deprecations.json +45 -1
- package/dist/_virtual/_rolldown/runtime.cjs +1 -0
- package/dist/accordion.cjs +1 -1
- package/dist/accordion.js +73 -102
- package/dist/alert-dialog.cjs +1 -1
- package/dist/alert-dialog.d.ts +36 -5
- package/dist/alert-dialog.d.ts.map +1 -1
- package/dist/alert-dialog.js +83 -128
- package/dist/alert.cjs +1 -1
- package/dist/alert.d.ts +4 -4
- package/dist/alert.d.ts.map +1 -1
- package/dist/alert.js +116 -177
- package/dist/aspect-ratio.cjs +1 -1
- package/dist/aspect-ratio.js +13 -16
- package/dist/avatar.cjs +1 -1
- package/dist/avatar.js +30 -45
- package/dist/badge.cjs +1 -1
- package/dist/badge.d.ts +32 -1
- package/dist/badge.d.ts.map +1 -1
- package/dist/badge.js +90 -71
- package/dist/banner.cjs +1 -0
- package/dist/banner.d.ts +81 -0
- package/dist/banner.d.ts.map +1 -0
- package/dist/banner.js +130 -0
- package/dist/blocks/empty-state.cjs +1 -1
- package/dist/blocks/empty-state.d.ts +24 -6
- package/dist/blocks/empty-state.d.ts.map +1 -1
- package/dist/blocks/empty-state.js +74 -140
- package/dist/blocks/input-list.cjs +2 -2
- package/dist/blocks/input-list.d.ts +2 -2
- package/dist/blocks/input-list.d.ts.map +1 -1
- package/dist/blocks/input-list.js +136 -176
- package/dist/blocks/progress-state.cjs +1 -1
- package/dist/blocks/progress-state.d.ts +2 -2
- package/dist/blocks/progress-state.js +223 -347
- package/dist/blocks/sidebar.cjs +1 -1
- package/dist/blocks/sidebar.d.ts +28 -6
- package/dist/blocks/sidebar.d.ts.map +1 -1
- package/dist/blocks/sidebar.js +763 -1086
- package/dist/brand-illustration-motif.cjs +1 -1
- package/dist/brand-illustration-motif.d.ts +1 -1
- package/dist/brand-illustration-motif.js +40 -61
- package/dist/breadcrumb.cjs +1 -1
- package/dist/breadcrumb.js +62 -102
- package/dist/button-group.cjs +1 -1
- package/dist/button-group.js +23 -31
- package/dist/button.cjs +1 -1
- package/dist/button.d.ts +4 -2
- package/dist/button.d.ts.map +1 -1
- package/dist/button.js +149 -189
- package/dist/calendar.cjs +1 -1
- package/dist/calendar.d.ts +87 -3
- package/dist/calendar.d.ts.map +1 -1
- package/dist/calendar.js +116 -173
- package/dist/callout.cjs +1 -1
- package/dist/callout.js +73 -96
- package/dist/card.cjs +1 -1
- package/dist/card.d.ts +92 -6
- package/dist/card.d.ts.map +1 -1
- package/dist/card.js +240 -234
- package/dist/carousel.cjs +1 -1
- package/dist/carousel.d.ts +3 -3
- package/dist/carousel.d.ts.map +1 -1
- package/dist/carousel.js +174 -268
- package/dist/centred-layout.cjs +1 -1
- package/dist/centred-layout.js +27 -48
- package/dist/chart-empty.cjs +1 -1
- package/dist/chart-empty.js +18 -27
- package/dist/chart.cjs +7 -7
- package/dist/chart.d.ts +253 -25
- package/dist/chart.d.ts.map +1 -1
- package/dist/chart.js +465 -511
- package/dist/checkbox.cjs +1 -1
- package/dist/checkbox.d.ts +1 -1
- package/dist/checkbox.d.ts.map +1 -1
- package/dist/checkbox.js +37 -69
- package/dist/chip.cjs +1 -1
- package/dist/chip.js +116 -173
- package/dist/collapsible.cjs +1 -1
- package/dist/collapsible.d.ts.map +1 -1
- package/dist/collapsible.js +35 -41
- package/dist/combobox.cjs +3 -3
- package/dist/combobox.d.ts +14 -4
- package/dist/combobox.d.ts.map +1 -1
- package/dist/combobox.js +440 -639
- package/dist/command.cjs +1 -1
- package/dist/command.d.ts.map +1 -1
- package/dist/command.js +273 -420
- package/dist/context-menu.cjs +1 -1
- package/dist/context-menu.d.ts +5 -5
- package/dist/context-menu.d.ts.map +1 -1
- package/dist/context-menu.js +121 -191
- package/dist/data-table.cjs +1 -1
- package/dist/data-table.d.ts +442 -144
- package/dist/data-table.d.ts.map +1 -1
- package/dist/data-table.js +708 -835
- package/dist/date-picker.cjs +1 -1
- package/dist/date-picker.d.ts +15 -4
- package/dist/date-picker.d.ts.map +1 -1
- package/dist/date-picker.js +156 -231
- package/dist/delta.cjs +1 -0
- package/dist/delta.d.ts +79 -0
- package/dist/delta.d.ts.map +1 -0
- package/dist/delta.js +62 -0
- package/dist/description.cjs +1 -1
- package/dist/description.js +11 -20
- package/dist/dialog.cjs +1 -1
- package/dist/dialog.d.ts +1 -1
- package/dist/dialog.d.ts.map +1 -1
- package/dist/dialog.js +76 -116
- package/dist/drawer.cjs +1 -1
- package/dist/drawer.d.ts +11 -11
- package/dist/drawer.d.ts.map +1 -1
- package/dist/drawer.js +76 -134
- package/dist/dropdown-menu.cjs +1 -1
- package/dist/dropdown-menu.d.ts +6 -6
- package/dist/dropdown-menu.d.ts.map +1 -1
- package/dist/dropdown-menu.js +179 -300
- package/dist/field.cjs +1 -1
- package/dist/field.d.ts +9 -9
- package/dist/field.d.ts.map +1 -1
- package/dist/field.js +166 -286
- package/dist/global-layout.cjs +1 -1
- package/dist/global-layout.js +203 -342
- package/dist/grid.cjs +1 -1
- package/dist/grid.d.ts +24 -1
- package/dist/grid.d.ts.map +1 -1
- package/dist/grid.js +16 -29
- package/dist/header.cjs +1 -1
- package/dist/header.js +21 -38
- package/dist/height-transition.cjs +1 -1
- package/dist/height-transition.js +38 -55
- package/dist/hooks/use-breakpoint.cjs +1 -1
- package/dist/hooks/use-breakpoint.d.ts +1 -1
- package/dist/hooks/use-breakpoint.d.ts.map +1 -1
- package/dist/hooks/use-breakpoint.js +10 -9
- package/dist/hooks/use-debounce.cjs +1 -1
- package/dist/hooks/use-debounce.js +12 -11
- package/dist/hooks/use-delayed-pending.cjs +1 -1
- package/dist/hooks/use-delayed-pending.js +8 -9
- package/dist/hooks/use-filter-search-params.cjs +1 -0
- package/dist/hooks/use-filter-search-params.d.ts +93 -0
- package/dist/hooks/use-filter-search-params.d.ts.map +1 -0
- package/dist/hooks/use-filter-search-params.js +122 -0
- package/dist/hooks/use-mobile.cjs +1 -1
- package/dist/hooks/use-mobile.js +6 -6
- package/dist/hooks/use-overlay-pointer-lock.cjs +1 -1
- package/dist/hooks/use-overlay-pointer-lock.js +8 -9
- package/dist/hooks/use-prefers-reduced-motion.cjs +1 -1
- package/dist/hooks/use-prefers-reduced-motion.js +5 -8
- package/dist/hover-card.cjs +1 -1
- package/dist/hover-card.d.ts +1 -1
- package/dist/hover-card.d.ts.map +1 -1
- package/dist/hover-card.js +30 -62
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +11 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +636 -582
- package/dist/info-tooltip.cjs +1 -0
- package/dist/info-tooltip.d.ts +39 -0
- package/dist/info-tooltip.d.ts.map +1 -0
- package/dist/info-tooltip.js +27 -0
- package/dist/input-chip.cjs +1 -1
- package/dist/input-chip.d.ts +32 -3
- package/dist/input-chip.d.ts.map +1 -1
- package/dist/input-chip.js +182 -231
- package/dist/input-group.cjs +1 -1
- package/dist/input-group.d.ts +33 -2
- package/dist/input-group.d.ts.map +1 -1
- package/dist/input-group.js +188 -122
- package/dist/input-otp.cjs +1 -1
- package/dist/input-otp.d.ts +3 -3
- package/dist/input-otp.d.ts.map +1 -1
- package/dist/input-otp.js +102 -146
- package/dist/input-password.cjs +1 -1
- package/dist/input-password.d.ts +26 -8
- package/dist/input-password.d.ts.map +1 -1
- package/dist/input-password.js +139 -171
- package/dist/input.cjs +1 -1
- package/dist/input.d.ts.map +1 -1
- package/dist/input.js +51 -73
- package/dist/label.cjs +1 -1
- package/dist/label.js +20 -38
- package/dist/lib/block-illustration.cjs +1 -1
- package/dist/lib/block-illustration.d.ts +5 -2
- package/dist/lib/block-illustration.d.ts.map +1 -1
- package/dist/lib/block-illustration.js +16 -17
- package/dist/lib/compose-event-handlers.cjs +1 -0
- package/dist/lib/compose-event-handlers.d.ts +9 -0
- package/dist/lib/compose-event-handlers.d.ts.map +1 -0
- package/dist/lib/compose-event-handlers.js +8 -0
- package/dist/lib/download-file.cjs +1 -0
- package/dist/lib/download-file.d.ts +14 -0
- package/dist/lib/download-file.d.ts.map +1 -0
- package/dist/lib/download-file.js +40 -0
- package/dist/lib/empty-canvas.cjs +1 -1
- package/dist/lib/empty-canvas.js +28 -56
- package/dist/lib/empty-chip.cjs +1 -1
- package/dist/lib/empty-chip.d.ts +14 -3
- package/dist/lib/empty-chip.d.ts.map +1 -1
- package/dist/lib/empty-chip.js +15 -11
- package/dist/lib/field-aria.cjs +1 -0
- package/dist/lib/field-aria.d.ts +34 -0
- package/dist/lib/field-aria.d.ts.map +1 -0
- package/dist/lib/field-aria.js +52 -0
- package/dist/lib/image-file-info.cjs +1 -0
- package/dist/lib/image-file-info.d.ts +25 -0
- package/dist/lib/image-file-info.d.ts.map +1 -0
- package/dist/lib/image-file-info.js +67 -0
- package/dist/lib/media-viewer-content.cjs +1 -0
- package/dist/lib/media-viewer-content.d.ts +102 -0
- package/dist/lib/media-viewer-content.d.ts.map +1 -0
- package/dist/lib/media-viewer-content.js +650 -0
- package/dist/lib/media-viewer-internal.cjs +1 -0
- package/dist/lib/media-viewer-internal.d.ts +98 -0
- package/dist/lib/media-viewer-internal.d.ts.map +1 -0
- package/dist/lib/media-viewer-internal.js +61 -0
- package/dist/lib/media-viewer-motion.cjs +1 -0
- package/dist/lib/media-viewer-motion.d.ts +40 -0
- package/dist/lib/media-viewer-motion.d.ts.map +1 -0
- package/dist/lib/media-viewer-motion.js +37 -0
- package/dist/lib/motion.cjs +1 -1
- package/dist/lib/motion.d.ts +8 -0
- package/dist/lib/motion.d.ts.map +1 -1
- package/dist/lib/motion.js +11 -10
- package/dist/lib/optical-center.cjs +1 -1
- package/dist/lib/optical-center.d.ts +1 -1
- package/dist/lib/optical-center.d.ts.map +1 -1
- package/dist/lib/optical-center.js +12 -5
- package/dist/lib/spring-settle.cjs +1 -1
- package/dist/lib/spring-settle.js +1 -1
- package/dist/lib/table-internal.cjs +1 -0
- package/dist/lib/table-internal.d.ts +62 -0
- package/dist/lib/table-internal.d.ts.map +1 -0
- package/dist/lib/table-internal.js +18 -0
- package/dist/lib/use-controllable.cjs +1 -0
- package/dist/lib/use-controllable.d.ts +12 -0
- package/dist/lib/use-controllable.d.ts.map +1 -0
- package/dist/lib/use-controllable.js +15 -0
- package/dist/lib/use-dev-warning.cjs +1 -1
- package/dist/lib/utils.cjs +1 -1
- package/dist/lib/utils.d.ts.map +1 -1
- package/dist/lib/utils.js +29 -35
- package/dist/link.cjs +1 -1
- package/dist/link.d.ts +1 -1
- package/dist/link.js +78 -124
- package/dist/list.cjs +1 -1
- package/dist/list.d.ts +8 -0
- package/dist/list.d.ts.map +1 -1
- package/dist/list.js +94 -156
- package/dist/loading.cjs +1 -1
- package/dist/loading.js +124 -151
- package/dist/logo-mark.cjs +1 -0
- package/dist/logo-mark.d.ts +79 -0
- package/dist/logo-mark.d.ts.map +1 -0
- package/dist/logo-mark.js +219 -0
- package/dist/logo.cjs +1 -1
- package/dist/logo.d.ts +1 -1
- package/dist/logo.d.ts.map +1 -1
- package/dist/logo.js +51 -87
- package/dist/map.cjs +1 -1
- package/dist/map.d.ts.map +1 -1
- package/dist/map.js +390 -586
- package/dist/media-empty.cjs +1 -1
- package/dist/media-empty.js +27 -42
- package/dist/media-viewer.cjs +1 -0
- package/dist/media-viewer.d.ts +224 -0
- package/dist/media-viewer.d.ts.map +1 -0
- package/dist/media-viewer.js +295 -0
- package/dist/menubar.cjs +1 -1
- package/dist/menubar.d.ts +14 -14
- package/dist/menubar.d.ts.map +1 -1
- package/dist/menubar.js +130 -267
- package/dist/multi-select-filter.cjs +1 -0
- package/dist/multi-select-filter.d.ts +186 -0
- package/dist/multi-select-filter.d.ts.map +1 -0
- package/dist/multi-select-filter.js +374 -0
- package/dist/navigation-menu.cjs +1 -1
- package/dist/navigation-menu.js +108 -172
- package/dist/pagination.cjs +1 -1
- package/dist/pagination.d.ts +36 -12
- package/dist/pagination.d.ts.map +1 -1
- package/dist/pagination.js +208 -281
- package/dist/popover.cjs +1 -1
- package/dist/popover.d.ts +1 -1
- package/dist/popover.d.ts.map +1 -1
- package/dist/popover.js +34 -45
- package/dist/progress.cjs +1 -1
- package/dist/progress.d.ts +139 -17
- package/dist/progress.d.ts.map +1 -1
- package/dist/progress.js +116 -148
- package/dist/radio-group.cjs +1 -1
- package/dist/radio-group.js +90 -146
- package/dist/rating.cjs +1 -1
- package/dist/rating.d.ts +80 -13
- package/dist/rating.d.ts.map +1 -1
- package/dist/rating.js +70 -65
- package/dist/relative-date.cjs +1 -0
- package/dist/relative-date.d.ts +65 -0
- package/dist/relative-date.d.ts.map +1 -0
- package/dist/relative-date.js +112 -0
- package/dist/resizable.cjs +1 -1
- package/dist/resizable.d.ts +39 -23
- package/dist/resizable.d.ts.map +1 -1
- package/dist/resizable.js +42 -44
- package/dist/result-count.cjs +1 -0
- package/dist/result-count.d.ts +110 -0
- package/dist/result-count.d.ts.map +1 -0
- package/dist/result-count.js +49 -0
- package/dist/route-progress.cjs +1 -1
- package/dist/route-progress.js +58 -102
- package/dist/scroll-area.cjs +1 -1
- package/dist/scroll-area.d.ts +9 -1
- package/dist/scroll-area.d.ts.map +1 -1
- package/dist/scroll-area.js +44 -79
- package/dist/select.cjs +2 -2
- package/dist/select.d.ts +20 -10
- package/dist/select.d.ts.map +1 -1
- package/dist/select.js +132 -236
- package/dist/separator.cjs +1 -1
- package/dist/separator.js +90 -78
- package/dist/sheet.cjs +1 -1
- package/dist/sheet.d.ts +86 -7
- package/dist/sheet.d.ts.map +1 -1
- package/dist/sheet.js +275 -235
- package/dist/single-select-filter.cjs +1 -0
- package/dist/single-select-filter.d.ts +113 -0
- package/dist/single-select-filter.d.ts.map +1 -0
- package/dist/single-select-filter.js +224 -0
- package/dist/skeleton.cjs +1 -1
- package/dist/skeleton.js +24 -38
- package/dist/slider.cjs +1 -1
- package/dist/slider.js +51 -81
- package/dist/sonner.cjs +1 -1
- package/dist/sonner.d.ts +1 -1
- package/dist/sonner.d.ts.map +1 -1
- package/dist/sonner.js +113 -137
- package/dist/spinner.cjs +1 -1
- package/dist/spinner.js +22 -31
- package/dist/split-layout.cjs +1 -1
- package/dist/split-layout.d.ts +1 -1
- package/dist/split-layout.js +53 -102
- package/dist/status.cjs +1 -0
- package/dist/status.d.ts +51 -0
- package/dist/status.d.ts.map +1 -0
- package/dist/status.js +60 -0
- package/dist/stepper.cjs +1 -1
- package/dist/stepper.js +184 -316
- package/dist/switch.cjs +1 -1
- package/dist/switch.js +17 -32
- package/dist/table.cjs +1 -1
- package/dist/table.d.ts +127 -13
- package/dist/table.d.ts.map +1 -1
- package/dist/table.js +170 -192
- package/dist/tabs.cjs +1 -1
- package/dist/tabs.d.ts +12 -1
- package/dist/tabs.d.ts.map +1 -1
- package/dist/tabs.js +123 -146
- package/dist/text-reveal-motion.cjs +1 -1
- package/dist/text-reveal-motion.js +307 -363
- package/dist/textarea.cjs +1 -1
- package/dist/textarea.d.ts.map +1 -1
- package/dist/textarea.js +23 -36
- package/dist/toggle-group.cjs +1 -1
- package/dist/toggle-group.js +43 -62
- package/dist/toggle.cjs +1 -1
- package/dist/toggle.js +34 -46
- package/dist/tooltip.cjs +1 -1
- package/dist/tooltip.d.ts +38 -36
- package/dist/tooltip.d.ts.map +1 -1
- package/dist/tooltip.js +175 -78
- package/dist/typography-heading.cjs +1 -1
- package/dist/typography-heading.js +25 -61
- package/dist/typography-text.cjs +1 -1
- package/dist/typography-text.d.ts +1 -2
- package/dist/typography-text.d.ts.map +1 -1
- package/dist/typography-text.js +27 -57
- package/dist/typography.cjs +1 -1
- package/dist/typography.d.ts +1 -1
- package/dist/typography.js +132 -340
- package/package.json +45 -46
- package/src/blocks/empty-state.tsx +42 -21
- package/src/blocks/progress-state.tsx +2 -2
- package/src/blocks/sidebar.tsx +111 -32
- package/src/components/accordion.tsx +1 -1
- package/src/components/alert-dialog.tsx +52 -5
- package/src/components/alert.tsx +16 -8
- package/src/components/badge.tsx +152 -3
- package/src/components/banner.tsx +288 -0
- package/src/components/brand-illustration-motif.tsx +1 -1
- package/src/components/breadcrumb.tsx +1 -1
- package/src/components/button.tsx +8 -6
- package/src/components/calendar.tsx +155 -9
- package/src/components/card.tsx +266 -26
- package/src/components/carousel.tsx +4 -1
- package/src/components/chart.tsx +664 -42
- package/src/components/checkbox.tsx +2 -2
- package/src/components/collapsible.tsx +4 -1
- package/src/components/combobox.tsx +42 -9
- package/src/components/command.tsx +10 -11
- package/src/components/context-menu.tsx +4 -4
- package/src/components/data-table.tsx +1363 -398
- package/src/components/date-picker.tsx +31 -4
- package/src/components/delta.tsx +217 -0
- package/src/components/drawer.tsx +5 -5
- package/src/components/dropdown-menu.tsx +4 -4
- package/src/components/field.tsx +36 -15
- package/src/components/global-layout.tsx +1 -1
- package/src/components/grid.tsx +32 -1
- package/src/components/info-tooltip.tsx +94 -0
- package/src/components/input-chip.tsx +52 -8
- package/src/components/input-group.tsx +247 -12
- package/src/components/input-otp.tsx +1 -1
- package/src/components/input-password.tsx +29 -11
- package/src/components/input.tsx +11 -2
- package/src/components/list.tsx +15 -3
- package/src/components/logo-mark.tsx +345 -0
- package/src/components/map.tsx +18 -20
- package/src/components/media-viewer.tsx +908 -0
- package/src/components/multi-select-filter.tsx +1046 -0
- package/src/components/navigation-menu.tsx +2 -2
- package/src/components/pagination.tsx +86 -26
- package/src/components/progress.tsx +281 -54
- package/src/components/rating.tsx +200 -74
- package/src/components/relative-date.tsx +238 -0
- package/src/components/resizable.tsx +86 -33
- package/src/components/result-count.tsx +253 -0
- package/src/components/scroll-area.tsx +31 -5
- package/src/components/select.tsx +37 -7
- package/src/components/sheet.tsx +252 -6
- package/src/components/single-select-filter.tsx +538 -0
- package/src/components/slider.tsx +2 -2
- package/src/components/sonner.tsx +16 -5
- package/src/components/split-layout.tsx +2 -2
- package/src/components/status.tsx +162 -0
- package/src/components/switch.tsx +1 -1
- package/src/components/table.tsx +305 -73
- package/src/components/tabs.tsx +94 -46
- package/src/components/textarea.tsx +21 -3
- package/src/components/toggle.tsx +2 -2
- package/src/components/tooltip.tsx +431 -68
- package/src/components/typography-text.tsx +1 -2
- package/src/components/typography.tsx +1 -1
- package/src/hooks/use-breakpoint.ts +2 -1
- package/src/hooks/use-filter-search-params.ts +302 -0
- package/src/index.ts +11 -0
- package/src/lib/block-illustration.tsx +5 -1
- package/src/lib/compose-event-handlers.ts +14 -0
- package/src/lib/download-file.ts +61 -0
- package/src/lib/empty-chip.tsx +52 -0
- package/src/lib/field-aria.tsx +97 -0
- package/src/lib/image-file-info.ts +102 -0
- package/src/lib/media-viewer-content.tsx +1587 -0
- package/src/lib/media-viewer-internal.tsx +191 -0
- package/src/lib/media-viewer-motion.ts +120 -0
- package/src/lib/motion.ts +9 -0
- package/src/lib/table-internal.ts +74 -0
- package/src/lib/use-controllable.ts +43 -0
- package/src/lib/utils.ts +1 -0
- package/src/lib/empty-chip.ts +0 -24
|
@@ -3,12 +3,14 @@
|
|
|
3
3
|
import * as React from "react";
|
|
4
4
|
import { ChevronDown, ChevronLeft, ChevronRight } from "@brightlocal/icons";
|
|
5
5
|
import {
|
|
6
|
+
DateLib,
|
|
6
7
|
DayButton,
|
|
7
8
|
DayPicker,
|
|
8
9
|
getDefaultClassNames,
|
|
9
10
|
type DayPickerProps,
|
|
10
11
|
} from "react-day-picker";
|
|
11
12
|
|
|
13
|
+
import { Button } from "@brightlocal/ui-components/button";
|
|
12
14
|
import { cn } from "@brightlocal/ui-components/lib/utils";
|
|
13
15
|
|
|
14
16
|
/**
|
|
@@ -20,6 +22,14 @@ export type CalendarProps = DayPickerProps & {
|
|
|
20
22
|
* @default 1
|
|
21
23
|
*/
|
|
22
24
|
numberOfMonths?: 1 | 2 | 3;
|
|
25
|
+
/**
|
|
26
|
+
* Stretch the calendar to fill its container instead of sizing to fit:
|
|
27
|
+
* the month, weekday headings and day cells share the width, and day
|
|
28
|
+
* buttons are at least 36px tall so they stay easy to tap. Use it in
|
|
29
|
+
* drawers, sheets and other narrow containers.
|
|
30
|
+
* @default false
|
|
31
|
+
*/
|
|
32
|
+
fullWidth?: boolean;
|
|
23
33
|
/**
|
|
24
34
|
* Data hook for testing and analytics
|
|
25
35
|
*/
|
|
@@ -35,7 +45,7 @@ export type CalendarProps = DayPickerProps & {
|
|
|
35
45
|
};
|
|
36
46
|
|
|
37
47
|
const navButtonStyles = cn(
|
|
38
|
-
"inline-flex items-center justify-center rounded-md",
|
|
48
|
+
"inline-flex cursor-pointer items-center justify-center rounded-md",
|
|
39
49
|
"text-muted-foreground hover:text-foreground",
|
|
40
50
|
"hover:bg-accent hover:text-accent-foreground",
|
|
41
51
|
"focus-visible:outline-none focus-visible:shadow-default",
|
|
@@ -63,7 +73,9 @@ const CalendarDayButton = ({
|
|
|
63
73
|
<button
|
|
64
74
|
ref={ref}
|
|
65
75
|
className={cn(
|
|
66
|
-
"text-foreground text-label h-8 w-8 rounded-md p-0",
|
|
76
|
+
"text-foreground text-label h-8 w-8 cursor-pointer rounded-md p-0",
|
|
77
|
+
"group-data-[full-width=true]/calendar:h-9 group-data-[full-width=true]/calendar:w-full",
|
|
78
|
+
"disabled:cursor-not-allowed disabled:line-through",
|
|
67
79
|
"hover:bg-accent hover:text-accent-foreground",
|
|
68
80
|
"focus-visible:ring-ring/50 focus-visible:ring-[3px] focus-visible:outline-none",
|
|
69
81
|
"group-data-[focused=true]/day:relative group-data-[focused=true]/day:z-10",
|
|
@@ -104,11 +116,13 @@ function Calendar({
|
|
|
104
116
|
numberOfMonths = 1,
|
|
105
117
|
captionLayout,
|
|
106
118
|
fixedWeeks = true,
|
|
119
|
+
fullWidth = false,
|
|
107
120
|
dataHook,
|
|
108
121
|
trackingEl,
|
|
109
122
|
trackingLabel,
|
|
110
123
|
components,
|
|
111
124
|
formatters,
|
|
125
|
+
labels,
|
|
112
126
|
...props
|
|
113
127
|
}: CalendarProps) {
|
|
114
128
|
const defaultClassNames = getDefaultClassNames();
|
|
@@ -117,12 +131,21 @@ function Calendar({
|
|
|
117
131
|
<DayPicker
|
|
118
132
|
captionLayout={captionLayout}
|
|
119
133
|
className={cn(
|
|
120
|
-
"bg-background border-border group/calendar relative
|
|
134
|
+
"bg-background border-border group/calendar relative rounded-lg border p-3 shadow-sm",
|
|
135
|
+
fullWidth ? "w-full" : "w-fit",
|
|
121
136
|
className
|
|
122
137
|
)}
|
|
123
138
|
classNames={{
|
|
124
|
-
months: cn(
|
|
125
|
-
|
|
139
|
+
months: cn(
|
|
140
|
+
"flex flex-col sm:flex-row gap-4",
|
|
141
|
+
fullWidth && "w-full",
|
|
142
|
+
defaultClassNames.months
|
|
143
|
+
),
|
|
144
|
+
month: cn(
|
|
145
|
+
"flex flex-col gap-4",
|
|
146
|
+
fullWidth && "w-full flex-1",
|
|
147
|
+
defaultClassNames.month
|
|
148
|
+
),
|
|
126
149
|
month_caption: cn(
|
|
127
150
|
"flex justify-center relative items-center w-full h-8",
|
|
128
151
|
defaultClassNames.month_caption
|
|
@@ -158,13 +181,15 @@ function Calendar({
|
|
|
158
181
|
"w-full border-collapse flex flex-col",
|
|
159
182
|
defaultClassNames.month_grid
|
|
160
183
|
),
|
|
161
|
-
weekdays: cn("flex", defaultClassNames.weekdays),
|
|
184
|
+
weekdays: cn("flex", fullWidth && "w-full", defaultClassNames.weekdays),
|
|
162
185
|
weekday: cn(
|
|
163
|
-
"text-muted-foreground rounded-md
|
|
186
|
+
"text-muted-foreground rounded-md h-5 flex items-center justify-center text-body-xs",
|
|
187
|
+
fullWidth ? "flex-1" : "w-8",
|
|
164
188
|
defaultClassNames.weekday
|
|
165
189
|
),
|
|
166
190
|
week: cn(defaultClassNames.week, "flex w-full mt-2"),
|
|
167
191
|
day: cn(
|
|
192
|
+
fullWidth && "flex-1",
|
|
168
193
|
"relative w-full h-full p-0 text-center text-label focus-within:relative focus-within:z-20 group/day select-none",
|
|
169
194
|
"[&:first-child[data-selected=true]_button]:!rounded-l-md",
|
|
170
195
|
"[&:last-child[data-selected=true]_button]:!rounded-r-md",
|
|
@@ -194,7 +219,7 @@ function Calendar({
|
|
|
194
219
|
defaultClassNames.outside
|
|
195
220
|
),
|
|
196
221
|
disabled: cn(
|
|
197
|
-
"text-foreground opacity-
|
|
222
|
+
"text-foreground opacity-40 cursor-not-allowed",
|
|
198
223
|
defaultClassNames.disabled
|
|
199
224
|
),
|
|
200
225
|
hidden: cn(defaultClassNames.hidden),
|
|
@@ -217,6 +242,7 @@ function Calendar({
|
|
|
217
242
|
DayButton: CalendarDayButton,
|
|
218
243
|
...components,
|
|
219
244
|
}}
|
|
245
|
+
data-full-width={fullWidth}
|
|
220
246
|
data-hook={dataHook}
|
|
221
247
|
data-slot="calendar"
|
|
222
248
|
data-tracking-el={trackingEl}
|
|
@@ -227,6 +253,19 @@ function Calendar({
|
|
|
227
253
|
date.toLocaleString("default", { month: "short" }),
|
|
228
254
|
...formatters,
|
|
229
255
|
}}
|
|
256
|
+
labels={{
|
|
257
|
+
// Lead with the visible day number so the accessible name contains the
|
|
258
|
+
// button text (WCAG 2.5.3 Label in Name); the default label spells the
|
|
259
|
+
// day out as "31st" and fails axe's label-content-name-mismatch.
|
|
260
|
+
labelDayButton: (date, modifiers, options, dateLib) => {
|
|
261
|
+
const lib = dateLib ?? new DateLib(options);
|
|
262
|
+
let label = `${lib.format(date, "d")}, ${lib.format(date, "EEEE, LLLL yyyy")}`;
|
|
263
|
+
if (modifiers.today) label = `Today, ${label}`;
|
|
264
|
+
if (modifiers.selected) label = `${label}, selected`;
|
|
265
|
+
return label;
|
|
266
|
+
},
|
|
267
|
+
...labels,
|
|
268
|
+
}}
|
|
230
269
|
numberOfMonths={numberOfMonths}
|
|
231
270
|
showOutsideDays={showOutsideDays}
|
|
232
271
|
{...props}
|
|
@@ -236,4 +275,111 @@ function Calendar({
|
|
|
236
275
|
|
|
237
276
|
Calendar.displayName = "Calendar";
|
|
238
277
|
|
|
239
|
-
|
|
278
|
+
/**
|
|
279
|
+
* A quick pick shown under the calendar.
|
|
280
|
+
*/
|
|
281
|
+
export type CalendarPreset = {
|
|
282
|
+
/** Visible label, e.g. "Tomorrow" */
|
|
283
|
+
label: string;
|
|
284
|
+
/** The date the preset selects, or a function returning it (resolved on click) */
|
|
285
|
+
date: Date | (() => Date);
|
|
286
|
+
};
|
|
287
|
+
|
|
288
|
+
export type CalendarPresetsProps = Omit<
|
|
289
|
+
React.ComponentPropsWithoutRef<"div">,
|
|
290
|
+
"onSelect"
|
|
291
|
+
> & {
|
|
292
|
+
/**
|
|
293
|
+
* Quick picks to render. The row wraps onto more lines; it never widens the calendar.
|
|
294
|
+
*/
|
|
295
|
+
presets: CalendarPreset[];
|
|
296
|
+
/**
|
|
297
|
+
* Called with the preset's date when a preset is clicked
|
|
298
|
+
*/
|
|
299
|
+
onSelect: (date: Date) => void;
|
|
300
|
+
/**
|
|
301
|
+
* Currently selected date. The matching preset is marked as pressed.
|
|
302
|
+
*/
|
|
303
|
+
selected?: Date;
|
|
304
|
+
/**
|
|
305
|
+
* Accessible name of the presets group
|
|
306
|
+
* @default "Quick picks"
|
|
307
|
+
*/
|
|
308
|
+
groupLabel?: string;
|
|
309
|
+
/**
|
|
310
|
+
* Data hook for testing and analytics
|
|
311
|
+
*/
|
|
312
|
+
dataHook: string;
|
|
313
|
+
/**
|
|
314
|
+
* Tracking element identifier
|
|
315
|
+
*/
|
|
316
|
+
trackingEl?: string;
|
|
317
|
+
/**
|
|
318
|
+
* Tracking label for analytics
|
|
319
|
+
*/
|
|
320
|
+
trackingLabel?: string;
|
|
321
|
+
};
|
|
322
|
+
|
|
323
|
+
const resolvePresetDate = (preset: CalendarPreset) =>
|
|
324
|
+
typeof preset.date === "function" ? preset.date() : preset.date;
|
|
325
|
+
|
|
326
|
+
/**
|
|
327
|
+
* Quick picks under the calendar. Pass it to `Calendar` as `footer` — it sits inside
|
|
328
|
+
* the calendar's own frame and owns the rule and spacing. The row takes the calendar's
|
|
329
|
+
* width and wraps, so it never widens the calendar or a popover around it.
|
|
330
|
+
*/
|
|
331
|
+
const CalendarPresets = React.forwardRef<HTMLDivElement, CalendarPresetsProps>(
|
|
332
|
+
(
|
|
333
|
+
{
|
|
334
|
+
presets,
|
|
335
|
+
onSelect,
|
|
336
|
+
selected,
|
|
337
|
+
groupLabel,
|
|
338
|
+
dataHook,
|
|
339
|
+
trackingEl,
|
|
340
|
+
trackingLabel,
|
|
341
|
+
className,
|
|
342
|
+
...props
|
|
343
|
+
},
|
|
344
|
+
ref
|
|
345
|
+
) => (
|
|
346
|
+
<div
|
|
347
|
+
ref={ref}
|
|
348
|
+
aria-label={groupLabel ?? "Quick picks"}
|
|
349
|
+
className={cn(
|
|
350
|
+
// w-0 + min-w-full: the row follows the calendar's width instead of adding to it
|
|
351
|
+
"border-border mt-3 flex w-0 min-w-full flex-wrap gap-2 border-t pt-3",
|
|
352
|
+
className
|
|
353
|
+
)}
|
|
354
|
+
data-hook={dataHook}
|
|
355
|
+
data-slot="calendar-presets"
|
|
356
|
+
data-tracking-el={trackingEl}
|
|
357
|
+
data-tracking-label={trackingLabel}
|
|
358
|
+
role="group"
|
|
359
|
+
{...props}
|
|
360
|
+
>
|
|
361
|
+
{presets.map((preset) => {
|
|
362
|
+
const date = resolvePresetDate(preset);
|
|
363
|
+
const isSelected =
|
|
364
|
+
selected !== undefined &&
|
|
365
|
+
date.toDateString() === selected.toDateString();
|
|
366
|
+
return (
|
|
367
|
+
<Button
|
|
368
|
+
key={preset.label}
|
|
369
|
+
aria-pressed={isSelected}
|
|
370
|
+
dataHook={`${dataHook}-${preset.label.toLowerCase().replace(/\s+/g, "-")}`}
|
|
371
|
+
size="sm"
|
|
372
|
+
variant="outline"
|
|
373
|
+
onClick={() => onSelect(resolvePresetDate(preset))}
|
|
374
|
+
>
|
|
375
|
+
{preset.label}
|
|
376
|
+
</Button>
|
|
377
|
+
);
|
|
378
|
+
})}
|
|
379
|
+
</div>
|
|
380
|
+
)
|
|
381
|
+
);
|
|
382
|
+
|
|
383
|
+
CalendarPresets.displayName = "CalendarPresets";
|
|
384
|
+
|
|
385
|
+
export { Calendar, CalendarDayButton, CalendarPresets };
|
package/src/components/card.tsx
CHANGED
|
@@ -14,7 +14,7 @@ type CardVariant = "filled" | "transparent" | "border" | "transparent-flush";
|
|
|
14
14
|
/**
|
|
15
15
|
* Card density type
|
|
16
16
|
*/
|
|
17
|
-
type CardDensity = "default" | "condensed";
|
|
17
|
+
type CardDensity = "default" | "condensed" | "data";
|
|
18
18
|
|
|
19
19
|
/**
|
|
20
20
|
* Context to pass variant information to sub-components
|
|
@@ -22,10 +22,39 @@ type CardDensity = "default" | "condensed";
|
|
|
22
22
|
const CardContext = React.createContext<{
|
|
23
23
|
flush: boolean;
|
|
24
24
|
density: CardDensity;
|
|
25
|
-
|
|
25
|
+
variant: CardVariant;
|
|
26
|
+
}>({ flush: false, density: "default", variant: "filled" });
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Opaque surface a sticky header paints so content never shows through it:
|
|
30
|
+
* the card's own fill, or the page background for unfilled variants.
|
|
31
|
+
*/
|
|
32
|
+
const stickySurface: Record<CardVariant, string> = {
|
|
33
|
+
filled: "bg-muted",
|
|
34
|
+
border: "bg-card",
|
|
35
|
+
transparent: "bg-background",
|
|
36
|
+
"transparent-flush": "bg-background",
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* The card's horizontal gutter, published as `--content-inset` for
|
|
41
|
+
* edge-to-edge content (a `Table`/`DataTable` with `frame="container"` inside
|
|
42
|
+
* `CardContent flush`) to align its first/last columns with the title
|
|
43
|
+
* (DS-1103). Mirrors `subPadding`.
|
|
44
|
+
*/
|
|
45
|
+
const CONTENT_INSET: Record<CardDensity, string> = {
|
|
46
|
+
default: "[--content-inset:var(--ds-section-padding-x-md)]",
|
|
47
|
+
condensed: "[--content-inset:0.75rem]",
|
|
48
|
+
data: "[--content-inset:var(--ds-content-padding)]",
|
|
49
|
+
};
|
|
26
50
|
|
|
27
51
|
function subPadding(flush: boolean, density: CardDensity): string | false {
|
|
28
|
-
|
|
52
|
+
if (flush) return false;
|
|
53
|
+
if (density === "condensed") return "px-3";
|
|
54
|
+
// Data cards use the fixed 24px content padding, not the responsive
|
|
55
|
+
// section scale — their content (tables, maps) sets its own rhythm.
|
|
56
|
+
if (density === "data") return "px-content";
|
|
57
|
+
return "px-section-md";
|
|
29
58
|
}
|
|
30
59
|
|
|
31
60
|
const cardVariants = cva(
|
|
@@ -35,29 +64,35 @@ const cardVariants = cva(
|
|
|
35
64
|
"rounded-xl",
|
|
36
65
|
"transition-colors duration-fast ease-out",
|
|
37
66
|
"w-full",
|
|
38
|
-
"max-w-[400px]",
|
|
39
67
|
],
|
|
40
68
|
{
|
|
41
69
|
variants: {
|
|
42
70
|
variant: {
|
|
71
|
+
// The tinted fill: the muted surface, a step below the white card.
|
|
43
72
|
filled: [
|
|
44
|
-
"bg-
|
|
73
|
+
"bg-muted",
|
|
45
74
|
"text-card-foreground",
|
|
46
75
|
"border",
|
|
47
76
|
"border-card-border",
|
|
48
77
|
],
|
|
49
78
|
transparent: ["bg-transparent", "text-foreground"],
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
"text-foreground",
|
|
53
|
-
"border",
|
|
54
|
-
"border-border",
|
|
55
|
-
],
|
|
79
|
+
// The card surface: solid white on the off-white page, neutral-900 in dark.
|
|
80
|
+
border: ["bg-card", "text-foreground", "border", "border-border"],
|
|
56
81
|
"transparent-flush": ["bg-transparent", "text-foreground"],
|
|
57
82
|
},
|
|
58
83
|
density: {
|
|
59
|
-
|
|
60
|
-
|
|
84
|
+
// Flush content right after a divider header cancels the root gap so
|
|
85
|
+
// it sits on the line, as it does in the data density.
|
|
86
|
+
default: [
|
|
87
|
+
"gap-8",
|
|
88
|
+
"py-section-md",
|
|
89
|
+
"[&>[data-divider]+[data-flush]]:-mt-8",
|
|
90
|
+
],
|
|
91
|
+
condensed: ["gap-3", "py-3", "[&>[data-divider]+[data-flush]]:-mt-3"],
|
|
92
|
+
// Data cards space via the sub-components, not a root gap: the header
|
|
93
|
+
// owns the top padding and its divider; content/footer pad below it.
|
|
94
|
+
// This lets flush content sit directly against the header divider.
|
|
95
|
+
data: ["pb-6"],
|
|
61
96
|
},
|
|
62
97
|
},
|
|
63
98
|
defaultVariants: {
|
|
@@ -77,7 +112,12 @@ type CardProps = React.ComponentProps<"div"> & {
|
|
|
77
112
|
*/
|
|
78
113
|
variant?: CardVariant;
|
|
79
114
|
/**
|
|
80
|
-
* Spacing density of the card
|
|
115
|
+
* Spacing density of the card.
|
|
116
|
+
* - `"default"` — responsive section-scale padding for standalone cards.
|
|
117
|
+
* - `"condensed"` — tight 12px scale for dense sidebars and widgets.
|
|
118
|
+
* - `"data"` — the report-page scale (DS-989): fixed 24px horizontal
|
|
119
|
+
* padding and a tighter header, tuned for cards that carry a filter
|
|
120
|
+
* row and a data view (table, map, chart).
|
|
81
121
|
* @default "default"
|
|
82
122
|
*/
|
|
83
123
|
density?: CardDensity;
|
|
@@ -140,10 +180,14 @@ const Card = React.forwardRef<HTMLDivElement, CardProps>(
|
|
|
140
180
|
: undefined;
|
|
141
181
|
|
|
142
182
|
return (
|
|
143
|
-
<CardContext.Provider value={{ flush, density }}>
|
|
183
|
+
<CardContext.Provider value={{ flush, density, variant }}>
|
|
144
184
|
<div
|
|
145
185
|
ref={ref}
|
|
146
|
-
className={cn(
|
|
186
|
+
className={cn(
|
|
187
|
+
cardVariants({ variant, density }),
|
|
188
|
+
CONTENT_INSET[density],
|
|
189
|
+
className
|
|
190
|
+
)}
|
|
147
191
|
data-density={density}
|
|
148
192
|
data-hook={dataHook}
|
|
149
193
|
data-slot="card"
|
|
@@ -186,7 +230,7 @@ type CardSubComponentProps = React.ComponentProps<"div"> & {
|
|
|
186
230
|
type CardHeaderAlign = "left" | "center" | "right";
|
|
187
231
|
|
|
188
232
|
const cardHeaderVariants = cva(
|
|
189
|
-
"@container/card-header grid auto-rows-min grid-rows-[auto_auto] gap-1
|
|
233
|
+
"@container/card-header grid auto-rows-min grid-rows-[auto_auto] gap-1 has-data-[slot=card-action]:grid-cols-[1fr_auto] has-data-[slot=card-metric]:grid-cols-[1fr_auto]",
|
|
190
234
|
{
|
|
191
235
|
variants: {
|
|
192
236
|
align: {
|
|
@@ -211,24 +255,102 @@ type CardHeaderProps = CardSubComponentProps & {
|
|
|
211
255
|
* @default "left"
|
|
212
256
|
*/
|
|
213
257
|
align?: CardHeaderAlign;
|
|
258
|
+
/**
|
|
259
|
+
* Closes the header with a full-width divider — the header's own bottom
|
|
260
|
+
* border, so it travels with a sticky header. Works in every density: the
|
|
261
|
+
* header pads its bottom by the density's section spacing so the line
|
|
262
|
+
* never touches the description, and flush content placed right after the
|
|
263
|
+
* header sits directly against the line (DS-989).
|
|
264
|
+
* @default false
|
|
265
|
+
*/
|
|
266
|
+
divider?: boolean;
|
|
267
|
+
/**
|
|
268
|
+
* Keeps the header pinned while the card scrolls past (DS-989) — for tall
|
|
269
|
+
* report cards whose table scrolls under the title and filters. Sticks at
|
|
270
|
+
* the top edge of the nearest scroll container (the page, a Sheet, a
|
|
271
|
+
* Dialog or any scrollable box), so nothing scrolls through a gap above
|
|
272
|
+
* it. Stays within the card and paints the card's surface so rows never
|
|
273
|
+
* show through. Pair with `divider` so the stuck header keeps its edge (DS-1211).
|
|
274
|
+
*
|
|
275
|
+
* A sticky header also publishes its rendered height on the card as
|
|
276
|
+
* `--content-sticky-top`, re-measured whenever it changes (a filter row
|
|
277
|
+
* that wraps), so content can stick directly beneath it — a `DataTable`
|
|
278
|
+
* with `stickyHeader="page"` pins its column headings there (DS-1215).
|
|
279
|
+
* @default false
|
|
280
|
+
*/
|
|
281
|
+
sticky?: boolean;
|
|
214
282
|
};
|
|
215
283
|
|
|
284
|
+
/**
|
|
285
|
+
* Publishes a sticky header's rendered height on its card as
|
|
286
|
+
* `--content-sticky-top` (DS-1215), so sticky content inside the card — a
|
|
287
|
+
* `DataTable` with `stickyHeader="page"` — sticks directly beneath it. Set on
|
|
288
|
+
* the DOM rather than through state so a resize never re-renders the card.
|
|
289
|
+
*/
|
|
290
|
+
function useStickyTopVar(
|
|
291
|
+
ref: React.RefObject<HTMLDivElement | null>,
|
|
292
|
+
sticky: boolean
|
|
293
|
+
) {
|
|
294
|
+
React.useLayoutEffect(() => {
|
|
295
|
+
const header = ref.current;
|
|
296
|
+
const card = header?.closest<HTMLElement>('[data-slot="card"]');
|
|
297
|
+
if (!sticky || !header || !card) return;
|
|
298
|
+
// The border box's layout size: padding and the divider count, and an
|
|
299
|
+
// ancestor transform (a Dialog's zoom-in) does not. The observer fires
|
|
300
|
+
// once on observe, so this also publishes the initial height.
|
|
301
|
+
const observer = new ResizeObserver(([entry]) => {
|
|
302
|
+
const height = entry?.borderBoxSize?.[0]?.blockSize;
|
|
303
|
+
if (height !== undefined) {
|
|
304
|
+
card.style.setProperty("--content-sticky-top", `${height}px`);
|
|
305
|
+
}
|
|
306
|
+
});
|
|
307
|
+
observer.observe(header, { box: "border-box" });
|
|
308
|
+
return () => {
|
|
309
|
+
observer.disconnect();
|
|
310
|
+
card.style.removeProperty("--content-sticky-top");
|
|
311
|
+
};
|
|
312
|
+
}, [ref, sticky]);
|
|
313
|
+
}
|
|
314
|
+
|
|
216
315
|
/**
|
|
217
316
|
* Header section of the Card containing title and description.
|
|
218
317
|
*/
|
|
219
318
|
const CardHeader = React.forwardRef<HTMLDivElement, CardHeaderProps>(
|
|
220
|
-
(
|
|
221
|
-
|
|
319
|
+
(
|
|
320
|
+
{
|
|
321
|
+
className,
|
|
322
|
+
align = "left",
|
|
323
|
+
divider = false,
|
|
324
|
+
sticky = false,
|
|
325
|
+
dataHook,
|
|
326
|
+
...props
|
|
327
|
+
},
|
|
328
|
+
ref
|
|
329
|
+
) => {
|
|
330
|
+
const { flush, density, variant } = React.useContext(CardContext);
|
|
331
|
+
const headerRef = React.useRef<HTMLDivElement>(null);
|
|
332
|
+
React.useImperativeHandle(ref, () => headerRef.current!, []);
|
|
333
|
+
useStickyTopVar(headerRef, sticky);
|
|
222
334
|
return (
|
|
223
335
|
<div
|
|
224
|
-
ref={
|
|
336
|
+
ref={headerRef}
|
|
225
337
|
className={cn(
|
|
226
338
|
cardHeaderVariants({ align }),
|
|
227
339
|
subPadding(flush, density),
|
|
340
|
+
// Data cards: the header owns the card's top padding (DS-989).
|
|
341
|
+
density === "data" && "pt-4 pb-4",
|
|
342
|
+
// Other densities have no header padding of their own; with a
|
|
343
|
+
// divider the line gets the density's section spacing above it.
|
|
344
|
+
divider && density === "default" && "pb-8",
|
|
345
|
+
divider && density === "condensed" && "pb-3",
|
|
346
|
+
divider && "border-border border-b",
|
|
347
|
+
sticky && ["sticky top-0 z-10 rounded-t-xl", stickySurface[variant]],
|
|
228
348
|
className
|
|
229
349
|
)}
|
|
350
|
+
data-divider={divider ? "" : undefined}
|
|
230
351
|
data-hook={dataHook}
|
|
231
352
|
data-slot="card-header"
|
|
353
|
+
data-sticky={sticky ? "" : undefined}
|
|
232
354
|
{...props}
|
|
233
355
|
/>
|
|
234
356
|
);
|
|
@@ -264,7 +386,8 @@ const cardTitleVariants = cva("", {
|
|
|
264
386
|
*/
|
|
265
387
|
type CardTitleProps = CardSubComponentProps & {
|
|
266
388
|
/**
|
|
267
|
-
* Title text size.
|
|
389
|
+
* Title text size. Report cards (`density="data"`) use `"small"` —
|
|
390
|
+
* pass it explicitly per the report-card recipe.
|
|
268
391
|
* @default "default"
|
|
269
392
|
*/
|
|
270
393
|
size?: CardTitleSize;
|
|
@@ -373,7 +496,9 @@ const CardAction = React.forwardRef<HTMLDivElement, CardSubComponentProps>(
|
|
|
373
496
|
<div
|
|
374
497
|
ref={ref}
|
|
375
498
|
className={cn(
|
|
376
|
-
|
|
499
|
+
// Vertically centered against the title block, per the header spec
|
|
500
|
+
// (DS-989) — Figma's Title Row centers its slot on the cross axis.
|
|
501
|
+
"col-start-2 row-span-2 row-start-1 self-center justify-self-end",
|
|
377
502
|
className
|
|
378
503
|
)}
|
|
379
504
|
data-hook={dataHook}
|
|
@@ -393,7 +518,11 @@ const CardMedia = React.forwardRef<HTMLDivElement, CardSubComponentProps>(
|
|
|
393
518
|
return (
|
|
394
519
|
<div
|
|
395
520
|
ref={ref}
|
|
396
|
-
className={cn(
|
|
521
|
+
className={cn(
|
|
522
|
+
subPadding(flush, density),
|
|
523
|
+
density === "data" && "pt-6",
|
|
524
|
+
className
|
|
525
|
+
)}
|
|
397
526
|
data-hook={dataHook}
|
|
398
527
|
data-slot="card-media"
|
|
399
528
|
{...props}
|
|
@@ -407,16 +536,38 @@ const CardMedia = React.forwardRef<HTMLDivElement, CardSubComponentProps>(
|
|
|
407
536
|
);
|
|
408
537
|
CardMedia.displayName = "CardMedia";
|
|
409
538
|
|
|
539
|
+
/**
|
|
540
|
+
* Props for the CardContent component.
|
|
541
|
+
*/
|
|
542
|
+
type CardContentProps = CardSubComponentProps & {
|
|
543
|
+
/**
|
|
544
|
+
* Runs the content to the card edge (drops the horizontal padding) while
|
|
545
|
+
* the card keeps its surface and border. Use for tables, maps and charts
|
|
546
|
+
* inside a `filled` or `border` card — unlike `variant="transparent-flush"`,
|
|
547
|
+
* only this section goes edge-to-edge; the header and footer keep their
|
|
548
|
+
* padding, and other content sections can stay padded.
|
|
549
|
+
* @default false
|
|
550
|
+
*/
|
|
551
|
+
flush?: boolean;
|
|
552
|
+
};
|
|
553
|
+
|
|
410
554
|
/**
|
|
411
555
|
* Main content area of the Card.
|
|
412
556
|
*/
|
|
413
|
-
const CardContent = React.forwardRef<HTMLDivElement,
|
|
414
|
-
({ className, dataHook, ...props }, ref) => {
|
|
557
|
+
const CardContent = React.forwardRef<HTMLDivElement, CardContentProps>(
|
|
558
|
+
({ className, flush: flushProp = false, dataHook, ...props }, ref) => {
|
|
415
559
|
const { flush, density } = React.useContext(CardContext);
|
|
416
560
|
return (
|
|
417
561
|
<div
|
|
418
562
|
ref={ref}
|
|
419
|
-
className={cn(
|
|
563
|
+
className={cn(
|
|
564
|
+
flushProp ? false : subPadding(flush, density),
|
|
565
|
+
// Data cards space below the header divider per section; flush
|
|
566
|
+
// content instead sits directly against the divider.
|
|
567
|
+
density === "data" && !flushProp && "pt-6",
|
|
568
|
+
className
|
|
569
|
+
)}
|
|
570
|
+
data-flush={flushProp ? "" : undefined}
|
|
420
571
|
data-hook={dataHook}
|
|
421
572
|
data-slot="card-content"
|
|
422
573
|
{...props}
|
|
@@ -426,6 +577,90 @@ const CardContent = React.forwardRef<HTMLDivElement, CardSubComponentProps>(
|
|
|
426
577
|
);
|
|
427
578
|
CardContent.displayName = "CardContent";
|
|
428
579
|
|
|
580
|
+
/**
|
|
581
|
+
* Toolbar row within the Card header (DS-989) — search, dimension filters
|
|
582
|
+
* and time/report-run pickers below the title and description (the Card
|
|
583
|
+
* counterpart of DataTableToolbar). Spans the full header width (under any
|
|
584
|
+
* CardAction/CardMetric), lays controls out left-to-right with an 8px gap,
|
|
585
|
+
* caps a search input (Input, InputGroup or DataTableSearch) at 360px so it
|
|
586
|
+
* doesn't dominate a sparse row, and lets select/combobox triggers hug their
|
|
587
|
+
* value. All of that styling reaches direct children only: wrap a control in
|
|
588
|
+
* any element to opt it out. Must be a direct child of CardHeader.
|
|
589
|
+
*
|
|
590
|
+
* Which toolbar: everything that narrows what the card shows, a table's
|
|
591
|
+
* `DataTableSearch` included, goes here in the header. `DataTableToolbar`
|
|
592
|
+
* holds the controls that page through the table (`DataTablePagination`)
|
|
593
|
+
* beside the table, and a table that stands without a card header. A report
|
|
594
|
+
* card uses both.
|
|
595
|
+
*
|
|
596
|
+
* Intentionally no `role="toolbar"`: the ARIA toolbar pattern requires a
|
|
597
|
+
* roving tabindex with arrow-key navigation, which is wrong for a row of
|
|
598
|
+
* inputs and selects. Don't add it.
|
|
599
|
+
*/
|
|
600
|
+
const CardToolbar = React.forwardRef<HTMLDivElement, CardSubComponentProps>(
|
|
601
|
+
({ className, dataHook, ...props }, ref) => (
|
|
602
|
+
<div
|
|
603
|
+
ref={ref}
|
|
604
|
+
className={cn(
|
|
605
|
+
// mt-2 + the header's gap-1 = the 12px title-block → filters gap.
|
|
606
|
+
// justify-self-stretch keeps the full width under align="center".
|
|
607
|
+
"col-span-full mt-2 flex flex-wrap items-center gap-2 justify-self-stretch",
|
|
608
|
+
"[&>[data-slot=data-table-search]]:max-w-90 [&>[data-slot=data-table-search]]:min-w-0 [&>[data-slot=input-group]]:max-w-90 [&>[data-slot=input-group]]:min-w-0 [&>[data-slot=input]]:max-w-90 [&>[data-slot=input]]:min-w-0",
|
|
609
|
+
// Select/combobox triggers are w-full for form layouts; in a filter
|
|
610
|
+
// row they hug their value instead.
|
|
611
|
+
"[&>[data-slot=combobox-trigger]]:w-fit [&>[data-slot=select-trigger]]:w-fit",
|
|
612
|
+
className
|
|
613
|
+
)}
|
|
614
|
+
data-hook={dataHook}
|
|
615
|
+
data-slot="card-toolbar"
|
|
616
|
+
{...props}
|
|
617
|
+
/>
|
|
618
|
+
)
|
|
619
|
+
);
|
|
620
|
+
CardToolbar.displayName = "CardToolbar";
|
|
621
|
+
|
|
622
|
+
/**
|
|
623
|
+
* Props for the CardMetric component.
|
|
624
|
+
*/
|
|
625
|
+
type CardMetricProps = Omit<CardSubComponentProps, "children"> & {
|
|
626
|
+
/**
|
|
627
|
+
* The metric value shown opposite the title, set in the `text-metric`
|
|
628
|
+
* type role.
|
|
629
|
+
*/
|
|
630
|
+
value: React.ReactNode;
|
|
631
|
+
/**
|
|
632
|
+
* Trend indicator rendered after the value — typically a Badge.
|
|
633
|
+
*/
|
|
634
|
+
trend?: React.ReactNode;
|
|
635
|
+
};
|
|
636
|
+
|
|
637
|
+
/**
|
|
638
|
+
* A headline metric in the Card header (DS-989) — a value and an optional
|
|
639
|
+
* trend badge sitting opposite the title, for cards whose own filters
|
|
640
|
+
* change the number. Occupies the same header area as CardAction, so use
|
|
641
|
+
* one or the other. Must be a direct child of CardHeader.
|
|
642
|
+
*/
|
|
643
|
+
const CardMetric = React.forwardRef<HTMLDivElement, CardMetricProps>(
|
|
644
|
+
({ className, value, trend, dataHook, ...props }, ref) => (
|
|
645
|
+
<div
|
|
646
|
+
ref={ref}
|
|
647
|
+
className={cn(
|
|
648
|
+
"col-start-2 row-span-2 row-start-1 flex items-baseline gap-2 self-center justify-self-end",
|
|
649
|
+
className
|
|
650
|
+
)}
|
|
651
|
+
data-hook={dataHook}
|
|
652
|
+
data-slot="card-metric"
|
|
653
|
+
{...props}
|
|
654
|
+
>
|
|
655
|
+
<span className="text-metric" data-slot="card-metric-value">
|
|
656
|
+
{value}
|
|
657
|
+
</span>
|
|
658
|
+
{trend}
|
|
659
|
+
</div>
|
|
660
|
+
)
|
|
661
|
+
);
|
|
662
|
+
CardMetric.displayName = "CardMetric";
|
|
663
|
+
|
|
429
664
|
/**
|
|
430
665
|
* Footer section of the Card for actions or metadata.
|
|
431
666
|
*/
|
|
@@ -438,6 +673,7 @@ const CardFooter = React.forwardRef<HTMLDivElement, CardSubComponentProps>(
|
|
|
438
673
|
className={cn(
|
|
439
674
|
"flex items-center",
|
|
440
675
|
subPadding(flush, density),
|
|
676
|
+
density === "data" && "pt-6",
|
|
441
677
|
className
|
|
442
678
|
)}
|
|
443
679
|
data-hook={dataHook}
|
|
@@ -456,7 +692,9 @@ export {
|
|
|
456
692
|
CardTitle,
|
|
457
693
|
CardAction,
|
|
458
694
|
CardDescription,
|
|
695
|
+
CardToolbar,
|
|
459
696
|
CardMedia,
|
|
697
|
+
CardMetric,
|
|
460
698
|
CardContent,
|
|
461
699
|
};
|
|
462
700
|
|
|
@@ -470,6 +708,8 @@ export type {
|
|
|
470
708
|
CardTitleProps,
|
|
471
709
|
CardTitleSize,
|
|
472
710
|
CardTitleLevel,
|
|
711
|
+
CardContentProps,
|
|
712
|
+
CardMetricProps,
|
|
473
713
|
CardVariant,
|
|
474
714
|
CardDensity,
|
|
475
715
|
};
|