@brightlocal/ui-components 3.2.0 → 3.4.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 +3 -1
- package/component-meta.json +1458 -380
- package/deprecations.json +44 -0
- 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 +6 -4
- package/dist/alert-dialog.d.ts.map +1 -1
- package/dist/alert-dialog.js +85 -133
- 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 +106 -168
- 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 +23 -1
- package/dist/badge.d.ts.map +1 -1
- package/dist/badge.js +90 -91
- package/dist/banner.cjs +1 -1
- package/dist/banner.js +102 -148
- package/dist/blocks/empty-state.cjs +1 -1
- package/dist/blocks/empty-state.d.ts +20 -3
- package/dist/blocks/empty-state.d.ts.map +1 -1
- package/dist/blocks/empty-state.js +73 -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 +138 -178
- package/dist/blocks/progress-state.cjs +1 -1
- package/dist/blocks/progress-state.js +223 -347
- package/dist/blocks/sidebar.cjs +1 -1
- package/dist/blocks/sidebar.d.ts +11 -6
- package/dist/blocks/sidebar.d.ts.map +1 -1
- package/dist/blocks/sidebar.js +763 -1092
- package/dist/brand-illustration-motif.cjs +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 +10 -4
- package/dist/card.d.ts.map +1 -1
- package/dist/card.js +233 -316
- 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 +23 -13
- package/dist/chart.d.ts.map +1 -1
- package/dist/chart.js +445 -651
- package/dist/checkbox.cjs +1 -1
- package/dist/checkbox.js +36 -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 +439 -638
- 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 +280 -129
- package/dist/data-table.d.ts.map +1 -1
- package/dist/data-table.js +687 -948
- 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-list.cjs +1 -0
- package/dist/description-list.d.ts +142 -0
- package/dist/description-list.d.ts.map +1 -0
- package/dist/description-list.js +173 -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.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.js +9 -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 +7 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +658 -614
- package/dist/info-tooltip.cjs +1 -1
- package/dist/info-tooltip.js +22 -36
- 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 +181 -230
- package/dist/input-group.cjs +1 -1
- package/dist/input-group.js +174 -221
- 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 +12 -16
- 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 +1 -1
- package/dist/lib/block-illustration.d.ts.map +1 -1
- package/dist/lib/block-illustration.js +16 -18
- 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 +14 -8
- 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.js +26 -33
- 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 +224 -39
- package/dist/list.d.ts.map +1 -1
- package/dist/list.js +323 -171
- 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 -1
- package/dist/multi-select-filter.d.ts +9 -1
- package/dist/multi-select-filter.d.ts.map +1 -1
- package/dist/multi-select-filter.js +357 -446
- 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 +17 -2
- package/dist/progress.d.ts.map +1 -1
- package/dist/progress.js +116 -162
- 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 -1
- package/dist/relative-date.d.ts.map +1 -1
- package/dist/relative-date.js +73 -89
- 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 +59 -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 +10 -10
- package/dist/select.d.ts.map +1 -1
- package/dist/select.js +118 -238
- package/dist/separator.cjs +1 -1
- package/dist/separator.js +90 -78
- package/dist/sheet.cjs +1 -1
- package/dist/sheet.d.ts +8 -5
- package/dist/sheet.d.ts.map +1 -1
- package/dist/sheet.js +250 -317
- package/dist/single-select-filter.cjs +1 -1
- package/dist/single-select-filter.d.ts +32 -0
- package/dist/single-select-filter.d.ts.map +1 -1
- package/dist/single-select-filter.js +201 -203
- 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 +101 -125
- package/dist/spinner.cjs +1 -1
- package/dist/spinner.js +22 -31
- package/dist/split-layout.cjs +1 -1
- package/dist/split-layout.js +52 -101
- 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 +103 -30
- package/dist/table.d.ts.map +1 -1
- package/dist/table.js +170 -209
- package/dist/tabs.cjs +1 -1
- package/dist/tabs.d.ts.map +1 -1
- package/dist/tabs.js +102 -147
- 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 +22 -35
- 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 +2 -2
- package/dist/tooltip.d.ts.map +1 -1
- package/dist/tooltip.js +157 -249
- 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.js +27 -57
- package/dist/typography.cjs +1 -1
- package/dist/typography.js +132 -340
- package/package.json +47 -47
- package/src/blocks/empty-state.tsx +34 -18
- package/src/blocks/input-list.tsx +14 -9
- package/src/blocks/sidebar.tsx +86 -31
- package/src/components/accordion.tsx +1 -1
- package/src/components/alert-dialog.tsx +4 -2
- package/src/components/badge.tsx +127 -15
- 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 +63 -10
- package/src/components/carousel.tsx +4 -1
- package/src/components/chart.tsx +151 -17
- package/src/components/checkbox.tsx +1 -1
- package/src/components/collapsible.tsx +4 -1
- package/src/components/combobox.tsx +40 -7
- package/src/components/command.tsx +9 -10
- package/src/components/context-menu.tsx +4 -4
- package/src/components/data-table.tsx +619 -237
- package/src/components/date-picker.tsx +31 -4
- package/src/components/delta.tsx +217 -0
- package/src/components/description-list.tsx +445 -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/input-chip.tsx +51 -7
- package/src/components/input-group.tsx +1 -1
- package/src/components/input-password.tsx +15 -19
- package/src/components/input.tsx +10 -1
- package/src/components/list.tsx +695 -72
- 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 +255 -121
- package/src/components/navigation-menu.tsx +2 -2
- package/src/components/pagination.tsx +86 -26
- package/src/components/progress.tsx +91 -23
- package/src/components/rating.tsx +200 -74
- package/src/components/relative-date.tsx +19 -11
- 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 +2 -2
- package/src/components/sheet.tsx +14 -4
- package/src/components/single-select-filter.tsx +136 -41
- package/src/components/slider.tsx +2 -2
- package/src/components/status.tsx +162 -0
- package/src/components/switch.tsx +1 -1
- package/src/components/table.tsx +278 -106
- package/src/components/tabs.tsx +1 -0
- package/src/components/textarea.tsx +20 -2
- package/src/components/toggle.tsx +2 -2
- package/src/components/tooltip.tsx +11 -20
- package/src/hooks/use-filter-search-params.ts +302 -0
- package/src/index.ts +7 -0
- 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/empty-chip.ts +0 -24
package/src/components/badge.tsx
CHANGED
|
@@ -1,9 +1,17 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
1
3
|
import * as React from "react";
|
|
2
4
|
import { Slot } from "@radix-ui/react-slot";
|
|
3
5
|
import { cva, type VariantProps } from "class-variance-authority";
|
|
4
6
|
|
|
5
7
|
import { cn } from "@brightlocal/ui-components/lib/utils";
|
|
6
8
|
import { useDevWarning } from "@brightlocal/ui-components/lib/use-dev-warning";
|
|
9
|
+
import {
|
|
10
|
+
Tooltip,
|
|
11
|
+
TooltipContent,
|
|
12
|
+
TooltipProvider,
|
|
13
|
+
TooltipTrigger,
|
|
14
|
+
} from "@brightlocal/ui-components/tooltip";
|
|
7
15
|
|
|
8
16
|
const badgeVariants = cva(
|
|
9
17
|
[
|
|
@@ -17,11 +25,11 @@ const badgeVariants = cva(
|
|
|
17
25
|
// Typography — type-scale role for badges (12/16 Figma 500; the weight
|
|
18
26
|
// drop from the old semibold is intentional, DS-925)
|
|
19
27
|
"text-label-sm whitespace-nowrap",
|
|
20
|
-
// Icons — direct children,
|
|
21
|
-
//
|
|
22
|
-
// other nested SVG
|
|
28
|
+
// Icons — direct children, the `srLabel` wrapper (display: contents),
|
|
29
|
+
// and the truncation label span
|
|
23
30
|
"[&>svg]:size-3 [&>svg]:pointer-events-none",
|
|
24
31
|
"[&>.contents>svg]:size-3 [&>.contents>svg]:pointer-events-none",
|
|
32
|
+
"[&>[data-slot=badge-label]>svg]:size-3 [&>[data-slot=badge-label]>svg]:pointer-events-none",
|
|
25
33
|
// Transition
|
|
26
34
|
"transition-[color,background-color,border-color,box-shadow] duration-fast ease-out",
|
|
27
35
|
// Focus
|
|
@@ -30,6 +38,8 @@ const badgeVariants = cva(
|
|
|
30
38
|
"dark:focus-visible:shadow-[0_0_0_1px_var(--background),0_0_0_2px_var(--color-ring),0_0_0_4px_rgba(255,255,255,0.1)]",
|
|
31
39
|
// Number badge (single digit)
|
|
32
40
|
"data-[number=true]:size-5 data-[number=true]:p-0 data-[number=true]:aspect-square",
|
|
41
|
+
// Icon-only mark (a round 20px disc holding one icon)
|
|
42
|
+
"data-[icon-only=true]:size-5 data-[icon-only=true]:p-0 data-[icon-only=true]:aspect-square",
|
|
33
43
|
],
|
|
34
44
|
{
|
|
35
45
|
variants: {
|
|
@@ -42,6 +52,9 @@ const badgeVariants = cva(
|
|
|
42
52
|
"border-transparent bg-destructive text-destructive-foreground",
|
|
43
53
|
outline:
|
|
44
54
|
"bg-background border-border text-foreground focus-visible:border-ring",
|
|
55
|
+
// Gold: a top or exceptional outcome (DS-1202) — not a warning
|
|
56
|
+
"highlight-gold":
|
|
57
|
+
"border-transparent bg-highlight-gold text-highlight-gold-foreground",
|
|
45
58
|
},
|
|
46
59
|
},
|
|
47
60
|
defaultVariants: {
|
|
@@ -80,6 +93,28 @@ interface BadgeProps
|
|
|
80
93
|
* @example srLabel="3 active"
|
|
81
94
|
*/
|
|
82
95
|
srLabel?: string;
|
|
96
|
+
/**
|
|
97
|
+
* Round icon-only mark: a 20px disc holding a single icon. The icon is
|
|
98
|
+
* decorative, so `srLabel` is the accessible name and is required in
|
|
99
|
+
* practice (a dev warning fires without it). Ignored with `asChild`.
|
|
100
|
+
* @default false
|
|
101
|
+
* @example <Badge iconOnly variant="highlight-gold" srLabel="In the knowledge panel"><Crown /></Badge>
|
|
102
|
+
*/
|
|
103
|
+
iconOnly?: boolean;
|
|
104
|
+
/**
|
|
105
|
+
* Truncate long text with an ellipsis. When the visible text overflows,
|
|
106
|
+
* a tooltip shows the full content on hover / tap — the same pattern
|
|
107
|
+
* Chip uses. The parent layout must constrain the badge's width for
|
|
108
|
+
* truncation to take effect (e.g. a flex parent, or an explicit
|
|
109
|
+
* `maxWidth`). Ignored with `asChild`.
|
|
110
|
+
* @default false
|
|
111
|
+
*/
|
|
112
|
+
truncate?: boolean;
|
|
113
|
+
/**
|
|
114
|
+
* Maximum width of the badge label before truncation (in pixels).
|
|
115
|
+
* Only applies when `truncate` is true.
|
|
116
|
+
*/
|
|
117
|
+
maxWidth?: number;
|
|
83
118
|
}
|
|
84
119
|
|
|
85
120
|
/**
|
|
@@ -96,6 +131,9 @@ const Badge = React.forwardRef<HTMLSpanElement, BadgeProps>(
|
|
|
96
131
|
trackingEl,
|
|
97
132
|
trackingLabel,
|
|
98
133
|
srLabel,
|
|
134
|
+
iconOnly = false,
|
|
135
|
+
truncate = false,
|
|
136
|
+
maxWidth,
|
|
99
137
|
children,
|
|
100
138
|
...props
|
|
101
139
|
},
|
|
@@ -103,6 +141,7 @@ const Badge = React.forwardRef<HTMLSpanElement, BadgeProps>(
|
|
|
103
141
|
) => {
|
|
104
142
|
const Comp = asChild ? Slot : "span";
|
|
105
143
|
const srLabelApplies = srLabel !== undefined && !asChild;
|
|
144
|
+
const truncateApplies = truncate && !asChild;
|
|
106
145
|
|
|
107
146
|
useDevWarning(
|
|
108
147
|
() => asChild && srLabel !== undefined,
|
|
@@ -111,37 +150,110 @@ const Badge = React.forwardRef<HTMLSpanElement, BadgeProps>(
|
|
|
111
150
|
[asChild, srLabel]
|
|
112
151
|
);
|
|
113
152
|
|
|
153
|
+
useDevWarning(
|
|
154
|
+
() => iconOnly && !asChild && srLabel === undefined,
|
|
155
|
+
"Badge iconOnly has no srLabel. An icon-only mark has no text, so pass srLabel as its accessible name.",
|
|
156
|
+
[iconOnly, asChild, srLabel]
|
|
157
|
+
);
|
|
158
|
+
|
|
159
|
+
useDevWarning(
|
|
160
|
+
() => asChild && truncate,
|
|
161
|
+
"truncate is set on a <Badge asChild>. Slot renders the child element as-is, " +
|
|
162
|
+
"so truncation cannot be applied — add truncation to the child instead.",
|
|
163
|
+
[asChild, truncate]
|
|
164
|
+
);
|
|
165
|
+
|
|
166
|
+
const labelRef = React.useRef<HTMLSpanElement>(null);
|
|
167
|
+
const [isTruncated, setIsTruncated] = React.useState(false);
|
|
168
|
+
|
|
169
|
+
React.useEffect(() => {
|
|
170
|
+
if (!truncateApplies) return;
|
|
171
|
+
|
|
172
|
+
const checkTruncation = () => {
|
|
173
|
+
if (labelRef.current) {
|
|
174
|
+
setIsTruncated(
|
|
175
|
+
labelRef.current.scrollWidth > labelRef.current.clientWidth
|
|
176
|
+
);
|
|
177
|
+
}
|
|
178
|
+
};
|
|
179
|
+
|
|
180
|
+
checkTruncation();
|
|
181
|
+
window.addEventListener("resize", checkTruncation);
|
|
182
|
+
return () => window.removeEventListener("resize", checkTruncation);
|
|
183
|
+
}, [truncateApplies, children]);
|
|
184
|
+
|
|
114
185
|
// Check if children is a single digit number (0-9)
|
|
115
186
|
const isNumberBadge =
|
|
116
187
|
typeof children === "string" && /^[0-9]$/.test(children);
|
|
117
188
|
|
|
189
|
+
// Build inner content — three modes: truncate, srLabel, or passthrough
|
|
190
|
+
let innerContent: React.ReactNode;
|
|
191
|
+
|
|
192
|
+
if (truncateApplies) {
|
|
193
|
+
const labelSpan = (
|
|
194
|
+
<span
|
|
195
|
+
ref={labelRef}
|
|
196
|
+
aria-hidden={srLabelApplies || undefined}
|
|
197
|
+
className="truncate"
|
|
198
|
+
data-slot="badge-label"
|
|
199
|
+
style={maxWidth ? { maxWidth } : undefined}
|
|
200
|
+
>
|
|
201
|
+
{children}
|
|
202
|
+
</span>
|
|
203
|
+
);
|
|
204
|
+
|
|
205
|
+
const wrappedLabel = isTruncated ? (
|
|
206
|
+
<TooltipProvider>
|
|
207
|
+
<Tooltip>
|
|
208
|
+
<TooltipTrigger asChild>{labelSpan}</TooltipTrigger>
|
|
209
|
+
<TooltipContent dataHook={`${dataHook}-tooltip`} sideOffset={8}>
|
|
210
|
+
{children}
|
|
211
|
+
</TooltipContent>
|
|
212
|
+
</Tooltip>
|
|
213
|
+
</TooltipProvider>
|
|
214
|
+
) : (
|
|
215
|
+
labelSpan
|
|
216
|
+
);
|
|
217
|
+
|
|
218
|
+
innerContent = srLabelApplies ? (
|
|
219
|
+
<>
|
|
220
|
+
{wrappedLabel}
|
|
221
|
+
<span className="sr-only">{srLabel}</span>
|
|
222
|
+
</>
|
|
223
|
+
) : (
|
|
224
|
+
wrappedLabel
|
|
225
|
+
);
|
|
226
|
+
} else if (srLabelApplies) {
|
|
227
|
+
innerContent = (
|
|
228
|
+
<>
|
|
229
|
+
<span aria-hidden="true" className="contents">
|
|
230
|
+
{children}
|
|
231
|
+
</span>
|
|
232
|
+
<span className="sr-only">{srLabel}</span>
|
|
233
|
+
</>
|
|
234
|
+
);
|
|
235
|
+
} else {
|
|
236
|
+
innerContent = children;
|
|
237
|
+
}
|
|
238
|
+
|
|
118
239
|
return (
|
|
119
240
|
<Comp
|
|
120
241
|
ref={ref}
|
|
121
242
|
className={cn(
|
|
122
243
|
badgeVariants({ variant }),
|
|
123
|
-
|
|
124
|
-
context so the phrase never escapes a scroll viewport. */
|
|
244
|
+
truncateApplies && "max-w-full min-w-0 shrink",
|
|
125
245
|
srLabelApplies && "relative",
|
|
126
246
|
className
|
|
127
247
|
)}
|
|
128
248
|
data-hook={dataHook}
|
|
249
|
+
data-icon-only={iconOnly || undefined}
|
|
129
250
|
data-number={isNumberBadge}
|
|
130
251
|
data-slot="badge"
|
|
131
252
|
data-tracking-el={trackingEl}
|
|
132
253
|
data-tracking-label={trackingLabel}
|
|
133
254
|
{...props}
|
|
134
255
|
>
|
|
135
|
-
{
|
|
136
|
-
<>
|
|
137
|
-
<span aria-hidden="true" className="contents">
|
|
138
|
-
{children}
|
|
139
|
-
</span>
|
|
140
|
-
<span className="sr-only">{srLabel}</span>
|
|
141
|
-
</>
|
|
142
|
-
) : (
|
|
143
|
-
children
|
|
144
|
-
)}
|
|
256
|
+
{innerContent}
|
|
145
257
|
</Comp>
|
|
146
258
|
);
|
|
147
259
|
}
|
|
@@ -112,7 +112,7 @@ const BreadcrumbLink = React.forwardRef<HTMLAnchorElement, BreadcrumbLinkProps>(
|
|
|
112
112
|
<Comp
|
|
113
113
|
ref={ref}
|
|
114
114
|
className={cn(
|
|
115
|
-
"hover:text-foreground focus-visible:shadow-default duration-fast rounded-sm transition-colors ease-out outline-none",
|
|
115
|
+
"hover:text-foreground focus-visible:shadow-default duration-fast cursor-pointer rounded-sm transition-colors ease-out outline-none",
|
|
116
116
|
className
|
|
117
117
|
)}
|
|
118
118
|
data-slot="breadcrumb-link"
|
|
@@ -19,6 +19,7 @@ type ButtonVariantProps = {
|
|
|
19
19
|
| "outline"
|
|
20
20
|
| "secondary"
|
|
21
21
|
| "ghost"
|
|
22
|
+
/** @deprecated Use `secondary` for moderate-risk actions or `destructive` for deletions. Will be removed in the next major version. */
|
|
22
23
|
| "warning";
|
|
23
24
|
/**
|
|
24
25
|
* Size variant of the button
|
|
@@ -72,12 +73,6 @@ const ButtonVariants = cva(
|
|
|
72
73
|
"hover:bg-secondary/80",
|
|
73
74
|
"focus-visible:shadow-default",
|
|
74
75
|
],
|
|
75
|
-
warning: [
|
|
76
|
-
"bg-warning-background",
|
|
77
|
-
"hover:bg-warning-background/80",
|
|
78
|
-
"text-warning-foreground",
|
|
79
|
-
"focus-visible:shadow-default",
|
|
80
|
-
],
|
|
81
76
|
destructive: [
|
|
82
77
|
"bg-destructive",
|
|
83
78
|
"dark:bg-red-400/90",
|
|
@@ -101,6 +96,13 @@ const ButtonVariants = cva(
|
|
|
101
96
|
"focus-visible:shadow-default",
|
|
102
97
|
"focus-visible:border-ring",
|
|
103
98
|
],
|
|
99
|
+
/** @deprecated Use `secondary` or `destructive` instead. */
|
|
100
|
+
warning: [
|
|
101
|
+
"bg-warning-background",
|
|
102
|
+
"hover:bg-warning-background/80",
|
|
103
|
+
"text-warning-foreground",
|
|
104
|
+
"focus-visible:shadow-default",
|
|
105
|
+
],
|
|
104
106
|
ghost: [
|
|
105
107
|
"bg-transparent",
|
|
106
108
|
"text-foreground",
|
|
@@ -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
|
@@ -36,6 +36,18 @@ const stickySurface: Record<CardVariant, string> = {
|
|
|
36
36
|
"transparent-flush": "bg-background",
|
|
37
37
|
};
|
|
38
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
|
+
};
|
|
50
|
+
|
|
39
51
|
function subPadding(flush: boolean, density: CardDensity): string | false {
|
|
40
52
|
if (flush) return false;
|
|
41
53
|
if (density === "condensed") return "px-3";
|
|
@@ -171,7 +183,11 @@ const Card = React.forwardRef<HTMLDivElement, CardProps>(
|
|
|
171
183
|
<CardContext.Provider value={{ flush, density, variant }}>
|
|
172
184
|
<div
|
|
173
185
|
ref={ref}
|
|
174
|
-
className={cn(
|
|
186
|
+
className={cn(
|
|
187
|
+
cardVariants({ variant, density }),
|
|
188
|
+
CONTENT_INSET[density],
|
|
189
|
+
className
|
|
190
|
+
)}
|
|
175
191
|
data-density={density}
|
|
176
192
|
data-hook={dataHook}
|
|
177
193
|
data-slot="card"
|
|
@@ -250,15 +266,52 @@ type CardHeaderProps = CardSubComponentProps & {
|
|
|
250
266
|
divider?: boolean;
|
|
251
267
|
/**
|
|
252
268
|
* Keeps the header pinned while the card scrolls past (DS-989) — for tall
|
|
253
|
-
* report cards whose table scrolls under the title and filters. Sticks
|
|
254
|
-
*
|
|
255
|
-
*
|
|
256
|
-
*
|
|
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).
|
|
257
279
|
* @default false
|
|
258
280
|
*/
|
|
259
281
|
sticky?: boolean;
|
|
260
282
|
};
|
|
261
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
|
+
|
|
262
315
|
/**
|
|
263
316
|
* Header section of the Card containing title and description.
|
|
264
317
|
*/
|
|
@@ -275,9 +328,12 @@ const CardHeader = React.forwardRef<HTMLDivElement, CardHeaderProps>(
|
|
|
275
328
|
ref
|
|
276
329
|
) => {
|
|
277
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);
|
|
278
334
|
return (
|
|
279
335
|
<div
|
|
280
|
-
ref={
|
|
336
|
+
ref={headerRef}
|
|
281
337
|
className={cn(
|
|
282
338
|
cardHeaderVariants({ align }),
|
|
283
339
|
subPadding(flush, density),
|
|
@@ -288,10 +344,7 @@ const CardHeader = React.forwardRef<HTMLDivElement, CardHeaderProps>(
|
|
|
288
344
|
divider && density === "default" && "pb-8",
|
|
289
345
|
divider && density === "condensed" && "pb-3",
|
|
290
346
|
divider && "border-border border-b",
|
|
291
|
-
sticky && [
|
|
292
|
-
"sticky top-(--ds-section-padding-y-sm) z-10 rounded-t-xl",
|
|
293
|
-
stickySurface[variant],
|
|
294
|
-
],
|
|
347
|
+
sticky && ["sticky top-0 z-10 rounded-t-xl", stickySurface[variant]],
|
|
295
348
|
className
|
|
296
349
|
)}
|
|
297
350
|
data-divider={divider ? "" : undefined}
|
|
@@ -172,6 +172,7 @@ const Carousel = React.forwardRef<HTMLDivElement, CarouselProps>(
|
|
|
172
172
|
|
|
173
173
|
React.useEffect(() => {
|
|
174
174
|
if (!api) return;
|
|
175
|
+
// eslint-disable-next-line react-hooks/set-state-in-effect -- Embla select sync; refactor tracked in DS-1070
|
|
175
176
|
onSelect(api);
|
|
176
177
|
api.on("reInit", onSelect);
|
|
177
178
|
api.on("select", onSelect);
|
|
@@ -205,6 +206,7 @@ const Carousel = React.forwardRef<HTMLDivElement, CarouselProps>(
|
|
|
205
206
|
|
|
206
207
|
React.useEffect(() => {
|
|
207
208
|
if (!api || !lazyLoad) return;
|
|
209
|
+
// eslint-disable-next-line react-hooks/set-state-in-effect -- Embla slidesInView sync; refactor tracked in DS-1070
|
|
208
210
|
updateLoadedSlides(api);
|
|
209
211
|
api.on("slidesInView", updateLoadedSlides);
|
|
210
212
|
api.on("select", updateLoadedSlides);
|
|
@@ -539,6 +541,7 @@ function CarouselDots({
|
|
|
539
541
|
React.useEffect(() => {
|
|
540
542
|
if (!api) return;
|
|
541
543
|
|
|
544
|
+
// eslint-disable-next-line react-hooks/set-state-in-effect -- Embla scroll snaps / selected index sync; refactor tracked in DS-1070
|
|
542
545
|
setScrollSnaps(api.scrollSnapList());
|
|
543
546
|
setSelectedIndex(api.selectedScrollSnap());
|
|
544
547
|
|
|
@@ -586,7 +589,7 @@ function CarouselDots({
|
|
|
586
589
|
: `Go to slide ${index + 1}`
|
|
587
590
|
}
|
|
588
591
|
className={cn(
|
|
589
|
-
"focus-visible:shadow-default duration-base size-3 rounded-full transition-[width,background-color] ease-in-out outline-none",
|
|
592
|
+
"focus-visible:shadow-default duration-base size-3 cursor-pointer rounded-full transition-[width,background-color] ease-in-out outline-none",
|
|
590
593
|
index === selectedIndex
|
|
591
594
|
? "bg-muted-foreground/50 dark:bg-muted-foreground/70 w-9"
|
|
592
595
|
: "bg-input hover:bg-muted-foreground/30 dark:bg-input/80 dark:hover:bg-muted-foreground/50"
|