@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/table.tsx
CHANGED
|
@@ -4,19 +4,28 @@ import * as React from "react";
|
|
|
4
4
|
import { cva, type VariantProps } from "class-variance-authority";
|
|
5
5
|
|
|
6
6
|
import { cn } from "@brightlocal/ui-components/lib/utils";
|
|
7
|
+
import { useDevWarning } from "@brightlocal/ui-components/lib/use-dev-warning";
|
|
8
|
+
import {
|
|
9
|
+
TABLE_CONTAINER_INSET,
|
|
10
|
+
TableSizeContext,
|
|
11
|
+
scrollRegionProps,
|
|
12
|
+
type TableFrame,
|
|
13
|
+
type TableSize,
|
|
14
|
+
} from "../lib/table-internal";
|
|
7
15
|
|
|
8
16
|
/* -------------------------------------------------------------------------------------------------
|
|
9
17
|
* CVA Variants
|
|
10
18
|
* -----------------------------------------------------------------------------------------------*/
|
|
11
19
|
|
|
12
20
|
const tableCellVariants = cva(
|
|
13
|
-
|
|
21
|
+
// `h-*` on a table cell is a min-height: the row still grows with
|
|
22
|
+
// multi-line content, so the size axis is the floor, never a clamp.
|
|
23
|
+
"align-middle bg-transparent p-2 text-body-sm text-foreground break-words",
|
|
14
24
|
{
|
|
15
25
|
variants: {
|
|
16
26
|
size: {
|
|
17
|
-
default: "h-12
|
|
18
|
-
|
|
19
|
-
lg: "h-24 p-2",
|
|
27
|
+
default: "h-12",
|
|
28
|
+
sm: "h-10",
|
|
20
29
|
},
|
|
21
30
|
align: {
|
|
22
31
|
left: "text-left",
|
|
@@ -34,9 +43,15 @@ const tableCellVariants = cva(
|
|
|
34
43
|
const tableHeadVariants = cva(
|
|
35
44
|
// bg-muted only for column headers inside <thead> — a <TableHead
|
|
36
45
|
// scope="row"> in the body must not paint over its row's state tint.
|
|
37
|
-
|
|
46
|
+
// No focus ring here: a <th> is never focusable — the sort control inside
|
|
47
|
+
// it (DataTableColumnHeader's Button) carries its own.
|
|
48
|
+
"[thead_&]:bg-muted p-2 align-middle text-muted-foreground text-label font-semibold break-words transition-colors duration-fast ease-out",
|
|
38
49
|
{
|
|
39
50
|
variants: {
|
|
51
|
+
size: {
|
|
52
|
+
default: "h-12",
|
|
53
|
+
sm: "h-9",
|
|
54
|
+
},
|
|
40
55
|
align: {
|
|
41
56
|
left: "text-left",
|
|
42
57
|
right: "text-right",
|
|
@@ -44,43 +59,19 @@ const tableHeadVariants = cva(
|
|
|
44
59
|
},
|
|
45
60
|
},
|
|
46
61
|
defaultVariants: {
|
|
62
|
+
size: "default",
|
|
47
63
|
align: "left",
|
|
48
64
|
},
|
|
49
65
|
}
|
|
50
66
|
);
|
|
51
67
|
|
|
52
|
-
/* -------------------------------------------------------------------------------------------------
|
|
53
|
-
* Scroll-region semantics (shared)
|
|
54
|
-
* -----------------------------------------------------------------------------------------------*/
|
|
55
|
-
|
|
56
|
-
/**
|
|
57
|
-
* Focusable scroll-region semantics for a table's scroll container:
|
|
58
|
-
* `role="region"` with an accessible name plus `tabIndex={0}`, so keyboard
|
|
59
|
-
* users can focus the container and scroll it (axe:
|
|
60
|
-
* scrollable-region-focusable).
|
|
61
|
-
*
|
|
62
|
-
* Single source of the contract and its "Scrollable table" default.
|
|
63
|
-
* `Table` applies it to its own wrapper (`scrollOwner="self"` + `minWidth`);
|
|
64
|
-
* `DataTable` / `VirtualizedDataTable` apply it to their outer wrapper,
|
|
65
|
-
* which owns scrolling instead. The caller decides *when* the container is
|
|
66
|
-
* a scroll region; this helper only says *what* that means.
|
|
67
|
-
*
|
|
68
|
-
* @internal Exported only so the DataTable module shares one copy — not a
|
|
69
|
-
* public contract; its shape may change without a major release.
|
|
70
|
-
*/
|
|
71
|
-
function scrollRegionProps(scrollRegionLabel: string | undefined) {
|
|
72
|
-
return {
|
|
73
|
-
role: "region",
|
|
74
|
-
"aria-label": scrollRegionLabel ?? "Scrollable table",
|
|
75
|
-
tabIndex: 0,
|
|
76
|
-
} as const;
|
|
77
|
-
}
|
|
78
|
-
|
|
79
68
|
/* -------------------------------------------------------------------------------------------------
|
|
80
69
|
* Table
|
|
81
70
|
* -----------------------------------------------------------------------------------------------*/
|
|
82
71
|
|
|
83
|
-
|
|
72
|
+
// `frame` shadows the legacy HTML `<table frame>` attribute (typed boolean in
|
|
73
|
+
// React); the DS prop replaces it and never reaches the DOM.
|
|
74
|
+
interface TableProps extends Omit<React.ComponentProps<"table">, "frame"> {
|
|
84
75
|
/**
|
|
85
76
|
* Data hook for automated testing (REQUIRED)
|
|
86
77
|
*/
|
|
@@ -93,6 +84,15 @@ interface TableProps extends React.ComponentProps<"table"> {
|
|
|
93
84
|
* Tracking label for analytics context
|
|
94
85
|
*/
|
|
95
86
|
trackingLabel?: string;
|
|
87
|
+
/**
|
|
88
|
+
* Row density for the whole table. Sets the min-height of every `TableCell`
|
|
89
|
+
* (`default` = `h-12` 48px, `sm` = `h-10` 40px) and `TableHead`
|
|
90
|
+
* (`default` = `h-12` 48px, `sm` = `h-9` 36px) beneath it. Rows still grow
|
|
91
|
+
* with multi-line content. Use `sm` for dense, scan-heavy tables inside
|
|
92
|
+
* cards, dialogs and side panels; keep `default` for page-level lists.
|
|
93
|
+
* @default "default"
|
|
94
|
+
*/
|
|
95
|
+
size?: TableSize;
|
|
96
96
|
/**
|
|
97
97
|
* Table layout algorithm.
|
|
98
98
|
* - `"auto"` (default) — browser sizes columns based on content.
|
|
@@ -139,6 +139,31 @@ interface TableProps extends React.ComponentProps<"table"> {
|
|
|
139
139
|
* @default "self"
|
|
140
140
|
*/
|
|
141
141
|
scrollOwner?: "self" | "parent";
|
|
142
|
+
/**
|
|
143
|
+
* Where the frame comes from (DS-1103).
|
|
144
|
+
* - `"own"` — the table draws its own 1px `border-border`, `rounded-md`
|
|
145
|
+
* frame; cells keep `p-2`. The standalone table.
|
|
146
|
+
* - `"container"` — no border, square corners, and the first/last cell of
|
|
147
|
+
* every row (head, body, footer, empty, skeleton) pads to the container's
|
|
148
|
+
* gutter, `var(--content-inset)` — `Card` publishes it per density (24px
|
|
149
|
+
* for `data`); 24px outside any container. Use inside `CardContent flush`,
|
|
150
|
+
* a Sheet or a dialog body so the page shows one box and the columns line
|
|
151
|
+
* up with the title.
|
|
152
|
+
* With `scrollOwner="parent"` the scrolling ancestor draws the frame
|
|
153
|
+
* (`DataTable` has the same prop); the cell rule still applies.
|
|
154
|
+
* @default "own"
|
|
155
|
+
*/
|
|
156
|
+
frame?: TableFrame;
|
|
157
|
+
/**
|
|
158
|
+
* Draw a faint `border-border` rule under every body row except the last
|
|
159
|
+
* (DS-1195), so a reader can follow one row across many columns. No zebra
|
|
160
|
+
* striping. Use it on long, dense tables with many numeric or grouped
|
|
161
|
+
* columns and on wide, horizontally scrolling tables; leave it off for
|
|
162
|
+
* short or simple tables, where the row height already separates rows.
|
|
163
|
+
* The header band and footer keep their own surfaces.
|
|
164
|
+
* @default false
|
|
165
|
+
*/
|
|
166
|
+
rowDividers?: boolean;
|
|
142
167
|
}
|
|
143
168
|
|
|
144
169
|
const Table = React.forwardRef<HTMLTableElement, TableProps>(
|
|
@@ -148,55 +173,75 @@ const Table = React.forwardRef<HTMLTableElement, TableProps>(
|
|
|
148
173
|
dataHook,
|
|
149
174
|
trackingEl,
|
|
150
175
|
trackingLabel,
|
|
176
|
+
size = "default",
|
|
151
177
|
layout = "auto",
|
|
152
178
|
minWidth,
|
|
153
179
|
scrollRegionLabel,
|
|
154
180
|
scrollOwner = "self",
|
|
181
|
+
frame = "own",
|
|
182
|
+
rowDividers = false,
|
|
155
183
|
style,
|
|
156
184
|
...props
|
|
157
185
|
},
|
|
158
186
|
ref
|
|
159
187
|
) => {
|
|
160
188
|
const ownsScroll = scrollOwner === "self";
|
|
189
|
+
const ownFrame = frame === "own";
|
|
161
190
|
return (
|
|
162
|
-
<
|
|
163
|
-
|
|
164
|
-
"relative w-full",
|
|
165
|
-
// `overflow-x-auto` makes the wrapper a scroll container in BOTH
|
|
166
|
-
// axes (an `auto` axis forces the other out of `visible`), which
|
|
167
|
-
// would confine a sticky <thead> here. With a parent scroll owner
|
|
168
|
-
// the wrapper must stay overflow-visible so sticky positioning
|
|
169
|
-
// and height bounds resolve against that ancestor (DS-912).
|
|
170
|
-
// `scrollbar` themes the native scrollbar with DS colors — the
|
|
171
|
-
// Command/Combobox treatment for bounded scroll containers.
|
|
172
|
-
ownsScroll && "scrollbar overflow-x-auto",
|
|
173
|
-
ownsScroll &&
|
|
174
|
-
minWidth &&
|
|
175
|
-
"focus-visible:shadow-default rounded-md outline-none"
|
|
176
|
-
)}
|
|
177
|
-
data-slot="table-container"
|
|
178
|
-
{...(ownsScroll && minWidth
|
|
179
|
-
? scrollRegionProps(scrollRegionLabel)
|
|
180
|
-
: undefined)}
|
|
181
|
-
>
|
|
182
|
-
<table
|
|
183
|
-
ref={ref}
|
|
191
|
+
<TableSizeContext.Provider value={size}>
|
|
192
|
+
<div
|
|
184
193
|
className={cn(
|
|
185
|
-
|
|
186
|
-
//
|
|
187
|
-
//
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
194
|
+
"relative w-full",
|
|
195
|
+
// `overflow-x-auto` makes the wrapper a scroll container in BOTH
|
|
196
|
+
// axes (an `auto` axis forces the other out of `visible`), which
|
|
197
|
+
// would confine a sticky <thead> here. With a parent scroll owner
|
|
198
|
+
// the wrapper must stay overflow-visible so sticky positioning
|
|
199
|
+
// and height bounds resolve against that ancestor (DS-912).
|
|
200
|
+
// `scrollbar` themes the native scrollbar with DS colors — the
|
|
201
|
+
// Command/Combobox treatment for bounded scroll containers.
|
|
202
|
+
ownsScroll && "scrollbar overflow-x-auto",
|
|
203
|
+
// `own`: the 1px frame and the rounded clip (header corners, focus
|
|
204
|
+
// ring). `container`: square and frameless — the container is the
|
|
205
|
+
// frame (DS-1103).
|
|
206
|
+
ownsScroll && ownFrame && "border-border rounded-md border",
|
|
207
|
+
ownsScroll &&
|
|
208
|
+
minWidth &&
|
|
209
|
+
"focus-visible:shadow-default outline-none"
|
|
191
210
|
)}
|
|
192
|
-
data-
|
|
193
|
-
data-slot="table"
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
211
|
+
data-frame={ownsScroll ? frame : undefined}
|
|
212
|
+
data-slot="table-container"
|
|
213
|
+
{...(ownsScroll && minWidth
|
|
214
|
+
? scrollRegionProps(scrollRegionLabel)
|
|
215
|
+
: undefined)}
|
|
216
|
+
>
|
|
217
|
+
<table
|
|
218
|
+
ref={ref}
|
|
219
|
+
className={cn(
|
|
220
|
+
// tabular-nums inherits into every cell (and into DataTable, which
|
|
221
|
+
// renders this root), so numeric columns align by default; a
|
|
222
|
+
// prose-heavy column can opt out with proportional-nums.
|
|
223
|
+
"text-body-sm w-full caption-bottom tabular-nums",
|
|
224
|
+
layout === "fixed" && "table-fixed",
|
|
225
|
+
// Edge cells pad to the container's gutter in both scroll modes.
|
|
226
|
+
!ownFrame && TABLE_CONTAINER_INSET,
|
|
227
|
+
// Rule under each body row but the last — the frame (or the
|
|
228
|
+
// container) closes the table, so the last row needs none.
|
|
229
|
+
rowDividers &&
|
|
230
|
+
"[&_[data-slot=table-body]>tr:not(:last-child)]:border-border [&_[data-slot=table-body]>tr:not(:last-child)]:border-b",
|
|
231
|
+
className
|
|
232
|
+
)}
|
|
233
|
+
data-frame={frame}
|
|
234
|
+
data-hook={dataHook}
|
|
235
|
+
data-row-dividers={rowDividers ? "true" : undefined}
|
|
236
|
+
data-size={size}
|
|
237
|
+
data-slot="table"
|
|
238
|
+
data-tracking-el={trackingEl}
|
|
239
|
+
data-tracking-label={trackingLabel}
|
|
240
|
+
style={{ minWidth, ...style }}
|
|
241
|
+
{...props}
|
|
242
|
+
/>
|
|
243
|
+
</div>
|
|
244
|
+
</TableSizeContext.Provider>
|
|
200
245
|
);
|
|
201
246
|
}
|
|
202
247
|
);
|
|
@@ -289,16 +334,16 @@ interface TableRowProps extends React.ComponentProps<"tr"> {
|
|
|
289
334
|
dataHook?: string;
|
|
290
335
|
}
|
|
291
336
|
|
|
337
|
+
// Selected rows share the table head's surface (bg-muted). Shared with
|
|
338
|
+
// TableEmpty, which renders its own <tr>.
|
|
339
|
+
const tableRowStyles =
|
|
340
|
+
"data-[state=selected]:bg-muted duration-fast transition-colors ease-out";
|
|
341
|
+
|
|
292
342
|
const TableRow = React.forwardRef<HTMLTableRowElement, TableRowProps>(
|
|
293
343
|
({ className, dataHook, ...props }, ref) => (
|
|
294
344
|
<tr
|
|
295
345
|
ref={ref}
|
|
296
|
-
className={cn(
|
|
297
|
-
// Selected rows share the table head's surface (bg-muted).
|
|
298
|
-
"data-[state=selected]:bg-muted",
|
|
299
|
-
"duration-fast transition-colors ease-out",
|
|
300
|
-
className
|
|
301
|
-
)}
|
|
346
|
+
className={cn(tableRowStyles, className)}
|
|
302
347
|
data-hook={dataHook}
|
|
303
348
|
data-slot="table-row"
|
|
304
349
|
{...props}
|
|
@@ -315,7 +360,7 @@ TableRow.displayName = "TableRow";
|
|
|
315
360
|
interface TableHeadProps
|
|
316
361
|
extends
|
|
317
362
|
Omit<React.ComponentProps<"th">, "align">,
|
|
318
|
-
VariantProps<typeof tableHeadVariants> {
|
|
363
|
+
Omit<VariantProps<typeof tableHeadVariants>, "size"> {
|
|
319
364
|
/**
|
|
320
365
|
* Data hook for automated testing
|
|
321
366
|
*/
|
|
@@ -348,17 +393,20 @@ const TableHead = React.forwardRef<HTMLTableCellElement, TableHeadProps>(
|
|
|
348
393
|
...props
|
|
349
394
|
},
|
|
350
395
|
ref
|
|
351
|
-
) =>
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
396
|
+
) => {
|
|
397
|
+
const size = React.useContext(TableSizeContext);
|
|
398
|
+
return (
|
|
399
|
+
<th
|
|
400
|
+
ref={ref}
|
|
401
|
+
className={cn(tableHeadVariants({ size, align }), className)}
|
|
402
|
+
data-hook={dataHook}
|
|
403
|
+
data-slot="table-head"
|
|
404
|
+
scope={scope}
|
|
405
|
+
style={{ width, minWidth, ...style }}
|
|
406
|
+
{...props}
|
|
407
|
+
/>
|
|
408
|
+
);
|
|
409
|
+
}
|
|
362
410
|
);
|
|
363
411
|
|
|
364
412
|
TableHead.displayName = "TableHead";
|
|
@@ -370,7 +418,7 @@ TableHead.displayName = "TableHead";
|
|
|
370
418
|
interface TableCellProps
|
|
371
419
|
extends
|
|
372
420
|
Omit<React.ComponentProps<"td">, "align">,
|
|
373
|
-
VariantProps<typeof tableCellVariants> {
|
|
421
|
+
Omit<VariantProps<typeof tableCellVariants>, "size"> {
|
|
374
422
|
/**
|
|
375
423
|
* Data hook for automated testing
|
|
376
424
|
*/
|
|
@@ -385,8 +433,10 @@ interface TableCellProps
|
|
|
385
433
|
*/
|
|
386
434
|
minWidth?: string;
|
|
387
435
|
/**
|
|
388
|
-
*
|
|
389
|
-
*
|
|
436
|
+
* @deprecated Since 3.3.0 — ignored. Row height is set once on the parent
|
|
437
|
+
* `Table` (`size="default" | "sm"`, DS-556); a per-cell size let one row
|
|
438
|
+
* disagree with its table and duplicated what sized content already does.
|
|
439
|
+
* Accepted so existing markup keeps compiling; removed in the next major.
|
|
390
440
|
*/
|
|
391
441
|
size?: "default" | "md" | "lg";
|
|
392
442
|
/**
|
|
@@ -394,26 +444,144 @@ interface TableCellProps
|
|
|
394
444
|
* @default "left"
|
|
395
445
|
*/
|
|
396
446
|
align?: "left" | "right" | "center";
|
|
447
|
+
/**
|
|
448
|
+
* Marks the cell as the first of a column group (DS-1195): draws a 1px
|
|
449
|
+
* `border-border` separator on its start edge. Set it on every body cell of
|
|
450
|
+
* the column that starts a group; the header band stays clean, so
|
|
451
|
+
* `TableHead` has no such prop. In `DataTable`, set `meta.groupStart` on the
|
|
452
|
+
* column instead.
|
|
453
|
+
* @default false
|
|
454
|
+
*/
|
|
455
|
+
groupStart?: boolean;
|
|
397
456
|
}
|
|
398
457
|
|
|
399
458
|
const TableCell = React.forwardRef<HTMLTableCellElement, TableCellProps>(
|
|
400
459
|
(
|
|
401
|
-
{
|
|
460
|
+
{
|
|
461
|
+
className,
|
|
462
|
+
dataHook,
|
|
463
|
+
// Deprecated no-op — destructured so it never reaches the DOM; only
|
|
464
|
+
// the dev warning below reads it (DS-556).
|
|
465
|
+
size: _deprecatedSize,
|
|
466
|
+
align,
|
|
467
|
+
groupStart = false,
|
|
468
|
+
width,
|
|
469
|
+
minWidth,
|
|
470
|
+
style,
|
|
471
|
+
...props
|
|
472
|
+
},
|
|
402
473
|
ref
|
|
403
|
-
) =>
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
474
|
+
) => {
|
|
475
|
+
const size = React.useContext(TableSizeContext);
|
|
476
|
+
useDevWarning(
|
|
477
|
+
() => _deprecatedSize !== undefined,
|
|
478
|
+
'TableCell: the "size" prop is deprecated since 3.3.0 and ignored — set size="default" | "sm" on the Table root instead (DS-556).',
|
|
479
|
+
[_deprecatedSize]
|
|
480
|
+
);
|
|
481
|
+
return (
|
|
482
|
+
<td
|
|
483
|
+
ref={ref}
|
|
484
|
+
className={cn(
|
|
485
|
+
tableCellVariants({ size, align }),
|
|
486
|
+
groupStart && "border-border border-l",
|
|
487
|
+
className
|
|
488
|
+
)}
|
|
489
|
+
data-group-start={groupStart ? "true" : undefined}
|
|
490
|
+
data-hook={dataHook}
|
|
491
|
+
data-slot="table-cell"
|
|
492
|
+
style={{ width, minWidth, ...style }}
|
|
493
|
+
{...props}
|
|
494
|
+
/>
|
|
495
|
+
);
|
|
496
|
+
}
|
|
413
497
|
);
|
|
414
498
|
|
|
415
499
|
TableCell.displayName = "TableCell";
|
|
416
500
|
|
|
501
|
+
/* -------------------------------------------------------------------------------------------------
|
|
502
|
+
* TableEmpty
|
|
503
|
+
* -----------------------------------------------------------------------------------------------*/
|
|
504
|
+
|
|
505
|
+
/**
|
|
506
|
+
* Props for the TableEmpty component.
|
|
507
|
+
*/
|
|
508
|
+
interface TableEmptyProps extends Omit<React.ComponentProps<"tr">, "children"> {
|
|
509
|
+
/**
|
|
510
|
+
* Number of columns the empty row spans — the table's column count, so the
|
|
511
|
+
* message centres across the whole table.
|
|
512
|
+
* @example 5
|
|
513
|
+
*/
|
|
514
|
+
colSpan: number;
|
|
515
|
+
/**
|
|
516
|
+
* What the table shows in place of rows.
|
|
517
|
+
*
|
|
518
|
+
* A string is a one-line message in an ordinary row at the table's `size`
|
|
519
|
+
* min-height — the bare fallback, announced politely.
|
|
520
|
+
*
|
|
521
|
+
* Pass an `<EmptyState size="md">` for the two designed states. A filtered
|
|
522
|
+
* or searched collection with nothing left (the Figma `No results` state):
|
|
523
|
+
* the `SearchX` icon, the echoed query as the title and one line of
|
|
524
|
+
* description — no action, the reader wants the outcome of their own query,
|
|
525
|
+
* not a CTA. An empty collection (the `Empty` state): a title, one line and
|
|
526
|
+
* the setup CTA. The row brings the block's breathing room (`py-6`) with
|
|
527
|
+
* it, so do not wrap it in a padding element; keep it to the standard
|
|
528
|
+
* anatomy — it sits in the same polite live region. Any non-string child is
|
|
529
|
+
* treated as a block and gets that padding.
|
|
530
|
+
* @default "No results."
|
|
531
|
+
*/
|
|
532
|
+
children?: React.ReactNode;
|
|
533
|
+
/**
|
|
534
|
+
* Data hook for automated testing
|
|
535
|
+
*/
|
|
536
|
+
dataHook?: string;
|
|
537
|
+
}
|
|
538
|
+
|
|
539
|
+
/**
|
|
540
|
+
* The single full-width row a table shows when it has no rows — the same row
|
|
541
|
+
* `DataTable` renders for `noResultsMessage`. Place it inside `TableBody`.
|
|
542
|
+
*
|
|
543
|
+
* ```tsx
|
|
544
|
+
* <TableBody>
|
|
545
|
+
* {rows.length > 0 ? rows.map(renderRow) : (
|
|
546
|
+
* <TableEmpty colSpan={columns.length}>No results.</TableEmpty>
|
|
547
|
+
* )}
|
|
548
|
+
* </TableBody>
|
|
549
|
+
* ```
|
|
550
|
+
*/
|
|
551
|
+
const TableEmpty = React.forwardRef<HTMLTableRowElement, TableEmptyProps>(
|
|
552
|
+
({ colSpan, children, dataHook, className, ...props }, ref) => {
|
|
553
|
+
const content = children ?? "No results.";
|
|
554
|
+
// A plain line sits in an ordinary row; a block gets 24 on top of the
|
|
555
|
+
// cell's own 8 — the 32 an EmptyState has anywhere else. A translated
|
|
556
|
+
// node (a fragment, <Trans>) counts as a block — pass a resolved string
|
|
557
|
+
// for the one-line row.
|
|
558
|
+
const isLine = typeof content === "string" || typeof content === "number";
|
|
559
|
+
return (
|
|
560
|
+
<tr
|
|
561
|
+
ref={ref}
|
|
562
|
+
className={cn(tableRowStyles, className)}
|
|
563
|
+
data-hook={dataHook}
|
|
564
|
+
data-slot="table-empty"
|
|
565
|
+
{...props}
|
|
566
|
+
>
|
|
567
|
+
<TableCell align="center" colSpan={colSpan}>
|
|
568
|
+
{/* Polite live region: the outcome of the reader's own query. */}
|
|
569
|
+
<div
|
|
570
|
+
aria-live="polite"
|
|
571
|
+
className={cn(!isLine && "py-6")}
|
|
572
|
+
data-slot="table-empty-message"
|
|
573
|
+
role="status"
|
|
574
|
+
>
|
|
575
|
+
{content}
|
|
576
|
+
</div>
|
|
577
|
+
</TableCell>
|
|
578
|
+
</tr>
|
|
579
|
+
);
|
|
580
|
+
}
|
|
581
|
+
);
|
|
582
|
+
|
|
583
|
+
TableEmpty.displayName = "TableEmpty";
|
|
584
|
+
|
|
417
585
|
/* -------------------------------------------------------------------------------------------------
|
|
418
586
|
* TableCaption
|
|
419
587
|
* -----------------------------------------------------------------------------------------------*/
|
|
@@ -446,9 +614,9 @@ interface TableCaptionProps extends React.ComponentProps<"caption"> {
|
|
|
446
614
|
* </Table>
|
|
447
615
|
*
|
|
448
616
|
* // After
|
|
449
|
-
* <
|
|
617
|
+
* <TypographyHeading level={3} dataHook="transactions-heading" id="transactions-heading">
|
|
450
618
|
* Recent transactions
|
|
451
|
-
* </
|
|
619
|
+
* </TypographyHeading>
|
|
452
620
|
* <Table aria-labelledby="transactions-heading" dataHook="transactions">
|
|
453
621
|
* ...
|
|
454
622
|
* </Table>
|
|
@@ -481,14 +649,17 @@ export {
|
|
|
481
649
|
TableHead,
|
|
482
650
|
TableRow,
|
|
483
651
|
TableCell,
|
|
652
|
+
TableEmpty,
|
|
484
653
|
TableCaption,
|
|
485
|
-
//
|
|
486
|
-
//
|
|
487
|
-
//
|
|
654
|
+
// Kept only because it shipped from this entry in 3.1 (DS-912). It is an
|
|
655
|
+
// internal helper (now in lib/table-internal) and leaves the public entry
|
|
656
|
+
// in the next major — see deprecations.json.
|
|
488
657
|
scrollRegionProps,
|
|
489
658
|
};
|
|
490
659
|
|
|
491
660
|
export type {
|
|
661
|
+
TableFrame,
|
|
662
|
+
TableSize,
|
|
492
663
|
TableProps,
|
|
493
664
|
TableHeaderProps,
|
|
494
665
|
TableBodyProps,
|
|
@@ -496,5 +667,6 @@ export type {
|
|
|
496
667
|
TableRowProps,
|
|
497
668
|
TableHeadProps,
|
|
498
669
|
TableCellProps,
|
|
670
|
+
TableEmptyProps,
|
|
499
671
|
TableCaptionProps,
|
|
500
672
|
};
|
package/src/components/tabs.tsx
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
1
3
|
import * as React from "react";
|
|
2
4
|
import { cva } from "class-variance-authority";
|
|
3
5
|
|
|
4
6
|
import { cn } from "@brightlocal/ui-components/lib/utils";
|
|
7
|
+
import { useFieldDescribedBy } from "../lib/field-aria";
|
|
5
8
|
|
|
6
9
|
const textareaVariants = cva([
|
|
7
10
|
// Layout & Size
|
|
@@ -51,7 +54,15 @@ interface TextareaProps extends Omit<
|
|
|
51
54
|
|
|
52
55
|
const Textarea = React.forwardRef<HTMLTextAreaElement, TextareaProps>(
|
|
53
56
|
(
|
|
54
|
-
{
|
|
57
|
+
{
|
|
58
|
+
className,
|
|
59
|
+
dataHook,
|
|
60
|
+
error,
|
|
61
|
+
trackingEl,
|
|
62
|
+
trackingLabel,
|
|
63
|
+
"aria-describedby": ariaDescribedBy,
|
|
64
|
+
...props
|
|
65
|
+
},
|
|
55
66
|
ref
|
|
56
67
|
) => {
|
|
57
68
|
// Support both error prop and aria-invalid for backwards compatibility
|
|
@@ -60,14 +71,21 @@ const Textarea = React.forwardRef<HTMLTextAreaElement, TextareaProps>(
|
|
|
60
71
|
props["aria-invalid"] === true ||
|
|
61
72
|
props["aria-invalid"] === "true";
|
|
62
73
|
|
|
74
|
+
// Inside a Field, point aria-describedby at the FieldError and
|
|
75
|
+
// FieldDescription automatically; a hand-wired value is kept and merged.
|
|
76
|
+
const describedBy = useFieldDescribedBy(ariaDescribedBy);
|
|
77
|
+
|
|
63
78
|
return (
|
|
64
79
|
<textarea
|
|
65
80
|
ref={ref}
|
|
81
|
+
aria-describedby={describedBy}
|
|
66
82
|
aria-invalid={hasError ? "true" : undefined}
|
|
67
83
|
className={cn(
|
|
68
84
|
textareaVariants(),
|
|
85
|
+
// scroll-mb-16 reserves room for a two-line error message under the
|
|
86
|
+
// field, so a phone keyboard scrolls the message into view with it
|
|
69
87
|
hasError &&
|
|
70
|
-
"border-destructive-40 focus-visible:border-destructive-40 focus-visible:shadow-destructive",
|
|
88
|
+
"border-destructive-40 focus-visible:border-destructive-40 focus-visible:shadow-destructive scroll-mb-16",
|
|
71
89
|
className
|
|
72
90
|
)}
|
|
73
91
|
data-hook={dataHook}
|
|
@@ -7,13 +7,13 @@ import { cva, type VariantProps } from "class-variance-authority";
|
|
|
7
7
|
import { cn } from "@brightlocal/ui-components/lib/utils";
|
|
8
8
|
|
|
9
9
|
const toggleVariants = cva(
|
|
10
|
-
"inline-flex items-center justify-center gap-2 rounded-md text-label hover:bg-muted hover:text-muted-foreground disabled:pointer-events-none disabled:opacity-50 data-[state=on]:bg-
|
|
10
|
+
"inline-flex cursor-pointer items-center justify-center gap-2 rounded-md text-label hover:bg-muted hover:text-muted-foreground disabled:pointer-events-none disabled:opacity-50 data-[state=on]:bg-secondary data-[state=on]:text-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0 focus-visible:border-ring focus-visible:shadow-default outline-none transition-[color,box-shadow] duration-fast ease-out whitespace-nowrap",
|
|
11
11
|
{
|
|
12
12
|
variants: {
|
|
13
13
|
variant: {
|
|
14
14
|
simple: "bg-transparent",
|
|
15
15
|
outline:
|
|
16
|
-
"border border-input bg-
|
|
16
|
+
"border border-input bg-background shadow-xs hover:text-accent-foreground",
|
|
17
17
|
},
|
|
18
18
|
size: {
|
|
19
19
|
default: "h-9 px-2 min-w-9",
|
|
@@ -4,6 +4,7 @@ import * as React from "react";
|
|
|
4
4
|
import * as PopoverPrimitive from "@radix-ui/react-popover";
|
|
5
5
|
import { Slot } from "@radix-ui/react-slot";
|
|
6
6
|
|
|
7
|
+
import { composeEventHandlers } from "../lib/compose-event-handlers";
|
|
7
8
|
import {
|
|
8
9
|
cn,
|
|
9
10
|
FLOATING_CONTENT_ANIMATION,
|
|
@@ -71,21 +72,6 @@ function TooltipProvider({
|
|
|
71
72
|
|
|
72
73
|
/* -------------------------------- Helpers --------------------------------- */
|
|
73
74
|
|
|
74
|
-
/**
|
|
75
|
-
* Calls the consumer's handler first, then ours — unless the consumer called
|
|
76
|
-
* `preventDefault()`. Mirrors Radix's `composeEventHandlers` without adding
|
|
77
|
-
* `@radix-ui/primitive` as a direct dependency.
|
|
78
|
-
*/
|
|
79
|
-
function composeEventHandlers<E extends { defaultPrevented: boolean }>(
|
|
80
|
-
theirs: ((event: E) => void) | undefined,
|
|
81
|
-
ours: (event: E) => void
|
|
82
|
-
) {
|
|
83
|
-
return (event: E) => {
|
|
84
|
-
theirs?.(event);
|
|
85
|
-
if (!event.defaultPrevented) ours(event);
|
|
86
|
-
};
|
|
87
|
-
}
|
|
88
|
-
|
|
89
75
|
/** Grace period (ms) before a hover-opened tooltip closes after the pointer leaves. */
|
|
90
76
|
const HOVER_CLOSE_GRACE_MS = 200;
|
|
91
77
|
|
|
@@ -211,23 +197,28 @@ function Tooltip({
|
|
|
211
197
|
|
|
212
198
|
const openFromHover = React.useCallback(() => {
|
|
213
199
|
clearTimers();
|
|
214
|
-
|
|
215
|
-
|
|
200
|
+
if (mode.current === "touch") {
|
|
201
|
+
// A tap already owns this tooltip; hover/focus must not restart its timers.
|
|
202
|
+
if (open) return;
|
|
203
|
+
// A tap that never opened it (a controlled `open` held it shut) leaves no
|
|
204
|
+
// owner behind — hover/focus take over again.
|
|
205
|
+
mode.current = "hover";
|
|
206
|
+
}
|
|
216
207
|
if (delayDuration > 0) {
|
|
217
208
|
delayTimer.current = setTimeout(() => setOpen(true), delayDuration);
|
|
218
209
|
} else {
|
|
219
210
|
setOpen(true);
|
|
220
211
|
}
|
|
221
|
-
}, [clearTimers, delayDuration, setOpen]);
|
|
212
|
+
}, [clearTimers, delayDuration, open, setOpen]);
|
|
222
213
|
|
|
223
214
|
const closeFromHover = React.useCallback(() => {
|
|
224
215
|
clearTimers();
|
|
225
|
-
if (mode.current === "touch") return;
|
|
216
|
+
if (mode.current === "touch" && open) return;
|
|
226
217
|
hoverTimeout.current = setTimeout(
|
|
227
218
|
() => setOpen(false),
|
|
228
219
|
HOVER_CLOSE_GRACE_MS
|
|
229
220
|
);
|
|
230
|
-
}, [clearTimers, setOpen]);
|
|
221
|
+
}, [clearTimers, open, setOpen]);
|
|
231
222
|
|
|
232
223
|
const onTriggerPointerEnter = React.useCallback(
|
|
233
224
|
(e: React.PointerEvent) => {
|