@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
|
@@ -0,0 +1,445 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
import { cva } from "class-variance-authority";
|
|
5
|
+
|
|
6
|
+
import { cn } from "@brightlocal/ui-components/lib/utils";
|
|
7
|
+
|
|
8
|
+
/* -------------------------------------------------------------------------------------------------
|
|
9
|
+
* Context
|
|
10
|
+
* -----------------------------------------------------------------------------------------------*/
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* How each term sits against its value.
|
|
14
|
+
* - `inline` — term column beside the value, every value starts on the same line
|
|
15
|
+
* - `stacked` — term above the value
|
|
16
|
+
* - `responsive` — stacked below the `sm` breakpoint, inline from `sm` up
|
|
17
|
+
* - `container` — stacked until the nearest `@container` is `@md` (28rem) wide,
|
|
18
|
+
* for lists in narrow panels on wide screens
|
|
19
|
+
* - `grid` — stacked items flowing into as many columns as fit (facts, plan limits)
|
|
20
|
+
*/
|
|
21
|
+
export type DescriptionListLayout =
|
|
22
|
+
"inline" | "stacked" | "responsive" | "container" | "grid";
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Where the value sits in an `inline` row (other layouts ignore it).
|
|
26
|
+
* - `start` — values line up in a column after the term
|
|
27
|
+
* - `end` — values pushed to the row's end (receipts, totals, counts)
|
|
28
|
+
*/
|
|
29
|
+
export type DescriptionListAlign = "start" | "end";
|
|
30
|
+
|
|
31
|
+
type DescriptionListContextValue = {
|
|
32
|
+
layout: DescriptionListLayout;
|
|
33
|
+
align: DescriptionListAlign;
|
|
34
|
+
/** Rows share one auto-sized term column (subgrid). */
|
|
35
|
+
autoTerm: boolean;
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
const DescriptionListContext = React.createContext<DescriptionListContextValue>(
|
|
39
|
+
{ layout: "inline", align: "start", autoTerm: false }
|
|
40
|
+
);
|
|
41
|
+
|
|
42
|
+
/* -------------------------------------------------------------------------------------------------
|
|
43
|
+
* Variants
|
|
44
|
+
* -----------------------------------------------------------------------------------------------*/
|
|
45
|
+
|
|
46
|
+
const descriptionListVariants = cva("min-w-0", {
|
|
47
|
+
variants: {
|
|
48
|
+
layout: {
|
|
49
|
+
inline: "flex flex-col",
|
|
50
|
+
stacked: "flex flex-col",
|
|
51
|
+
responsive: "flex flex-col",
|
|
52
|
+
container: "flex flex-col",
|
|
53
|
+
// Columns at least 8rem wide, as many as fit: a plan's limits or a record's
|
|
54
|
+
// facts reflow from one column on a phone to a full row on desktop.
|
|
55
|
+
grid: "grid grid-cols-[repeat(auto-fill,minmax(8rem,1fr))] gap-x-6 gap-y-4",
|
|
56
|
+
},
|
|
57
|
+
divided: {
|
|
58
|
+
// Lines between rows only: no padding above the first row or below the
|
|
59
|
+
// last, so the list sits at its container's own spacing.
|
|
60
|
+
true: [
|
|
61
|
+
"divide-border divide-y",
|
|
62
|
+
"[&>[data-slot=description-list-item]]:py-3",
|
|
63
|
+
"[&>[data-slot=description-list-item]:first-child]:pt-0",
|
|
64
|
+
"[&>[data-slot=description-list-item]:last-child]:pb-0",
|
|
65
|
+
],
|
|
66
|
+
false: "",
|
|
67
|
+
},
|
|
68
|
+
},
|
|
69
|
+
compoundVariants: [
|
|
70
|
+
{ layout: "inline", divided: false, className: "gap-3" },
|
|
71
|
+
{ layout: "stacked", divided: false, className: "gap-3" },
|
|
72
|
+
{ layout: "responsive", divided: false, className: "gap-3" },
|
|
73
|
+
{ layout: "container", divided: false, className: "gap-3" },
|
|
74
|
+
],
|
|
75
|
+
defaultVariants: {
|
|
76
|
+
layout: "inline",
|
|
77
|
+
divided: false,
|
|
78
|
+
},
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
const descriptionListItemVariants = cva("flex min-w-0", {
|
|
82
|
+
variants: {
|
|
83
|
+
layout: {
|
|
84
|
+
inline: "flex-row items-baseline gap-4",
|
|
85
|
+
stacked: "flex-col gap-1",
|
|
86
|
+
responsive: "flex-col gap-1 sm:flex-row sm:items-baseline sm:gap-4",
|
|
87
|
+
container: "flex-col gap-1 @md:flex-row @md:items-baseline @md:gap-4",
|
|
88
|
+
grid: "flex-col gap-1",
|
|
89
|
+
},
|
|
90
|
+
},
|
|
91
|
+
defaultVariants: {
|
|
92
|
+
layout: "inline",
|
|
93
|
+
},
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
const descriptionListTermVariants = cva(
|
|
97
|
+
"text-muted-foreground text-body-sm shrink-0",
|
|
98
|
+
{
|
|
99
|
+
variants: {
|
|
100
|
+
layout: {
|
|
101
|
+
inline: "w-(--dl-term-width)",
|
|
102
|
+
stacked: "",
|
|
103
|
+
responsive: "sm:w-(--dl-term-width)",
|
|
104
|
+
container: "@md:w-(--dl-term-width)",
|
|
105
|
+
grid: "",
|
|
106
|
+
},
|
|
107
|
+
},
|
|
108
|
+
defaultVariants: {
|
|
109
|
+
layout: "inline",
|
|
110
|
+
},
|
|
111
|
+
}
|
|
112
|
+
);
|
|
113
|
+
|
|
114
|
+
/* An auto-width term column has to be shared by every row, so the list
|
|
115
|
+
becomes a two-column grid and each row a subgrid of it. Only where the term
|
|
116
|
+
sits beside its value: below the breakpoint the row still stacks. */
|
|
117
|
+
const autoTermListClasses: Partial<Record<DescriptionListLayout, string>> = {
|
|
118
|
+
inline: "grid grid-cols-[max-content_1fr] gap-x-4",
|
|
119
|
+
responsive: "sm:grid sm:grid-cols-[max-content_1fr] sm:gap-x-4",
|
|
120
|
+
container: "@md:grid @md:grid-cols-[max-content_1fr] @md:gap-x-4",
|
|
121
|
+
};
|
|
122
|
+
|
|
123
|
+
const autoTermItemClasses: Partial<Record<DescriptionListLayout, string>> = {
|
|
124
|
+
inline: "col-span-2 grid grid-cols-subgrid",
|
|
125
|
+
responsive: "sm:col-span-2 sm:grid sm:grid-cols-subgrid",
|
|
126
|
+
container: "@md:col-span-2 @md:grid @md:grid-cols-subgrid",
|
|
127
|
+
};
|
|
128
|
+
|
|
129
|
+
/** Layouts where the term can sit beside its value. */
|
|
130
|
+
const SIDE_BY_SIDE: ReadonlyArray<DescriptionListLayout> = [
|
|
131
|
+
"inline",
|
|
132
|
+
"responsive",
|
|
133
|
+
"container",
|
|
134
|
+
];
|
|
135
|
+
|
|
136
|
+
/* -------------------------------------------------------------------------------------------------
|
|
137
|
+
* DescriptionList
|
|
138
|
+
* -----------------------------------------------------------------------------------------------*/
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* Props for the DescriptionList root.
|
|
142
|
+
* Extends native `<dl>` props with layout options and testing/analytics attributes.
|
|
143
|
+
*/
|
|
144
|
+
export interface DescriptionListProps extends React.ComponentProps<"dl"> {
|
|
145
|
+
/**
|
|
146
|
+
* Data hook for automated testing (required).
|
|
147
|
+
* @example "review-details", "plan-limits"
|
|
148
|
+
*/
|
|
149
|
+
dataHook: string;
|
|
150
|
+
/**
|
|
151
|
+
* Tracking element identifier for analytics.
|
|
152
|
+
* @default "description-list"
|
|
153
|
+
*/
|
|
154
|
+
trackingEl?: string;
|
|
155
|
+
/**
|
|
156
|
+
* Tracking label for analytics context.
|
|
157
|
+
*/
|
|
158
|
+
trackingLabel?: string;
|
|
159
|
+
/**
|
|
160
|
+
* How each term sits against its value.
|
|
161
|
+
* @default "inline"
|
|
162
|
+
*/
|
|
163
|
+
layout?: DescriptionListLayout;
|
|
164
|
+
/**
|
|
165
|
+
* Width of the term column when the term sits beside its value. A number is
|
|
166
|
+
* pixels; `"auto"` sizes the column to the longest term.
|
|
167
|
+
* Ignored by `stacked` and `grid`, and by `align="end"` on `inline`.
|
|
168
|
+
* @default 128
|
|
169
|
+
*/
|
|
170
|
+
termWidth?: number | "auto";
|
|
171
|
+
/**
|
|
172
|
+
* Where the value sits in an `inline` row. `end` pushes values to the row's
|
|
173
|
+
* end, for receipts and totals; other layouts ignore it.
|
|
174
|
+
* @default "start"
|
|
175
|
+
*/
|
|
176
|
+
align?: DescriptionListAlign;
|
|
177
|
+
/**
|
|
178
|
+
* Draw a hairline between items. Not used by the `grid` layout.
|
|
179
|
+
* @default false
|
|
180
|
+
*/
|
|
181
|
+
divided?: boolean;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
/**
|
|
185
|
+
* Label-and-value pairs describing one record: the details of a review, the
|
|
186
|
+
* read view of a settings card, a receipt. Renders a semantic `<dl>`.
|
|
187
|
+
*
|
|
188
|
+
* For several records compared by the same attributes, use Table instead.
|
|
189
|
+
*
|
|
190
|
+
* @example
|
|
191
|
+
* ```tsx
|
|
192
|
+
* <DescriptionList dataHook="review-details">
|
|
193
|
+
* <DescriptionListItem>
|
|
194
|
+
* <DescriptionListTerm>Source</DescriptionListTerm>
|
|
195
|
+
* <DescriptionListDetails>Google</DescriptionListDetails>
|
|
196
|
+
* </DescriptionListItem>
|
|
197
|
+
* </DescriptionList>
|
|
198
|
+
* ```
|
|
199
|
+
*/
|
|
200
|
+
const DescriptionList = React.forwardRef<
|
|
201
|
+
HTMLDListElement,
|
|
202
|
+
DescriptionListProps
|
|
203
|
+
>(
|
|
204
|
+
(
|
|
205
|
+
{
|
|
206
|
+
className,
|
|
207
|
+
style,
|
|
208
|
+
layout = "inline",
|
|
209
|
+
termWidth = 128,
|
|
210
|
+
align = "start",
|
|
211
|
+
divided = false,
|
|
212
|
+
dataHook,
|
|
213
|
+
trackingEl,
|
|
214
|
+
trackingLabel,
|
|
215
|
+
...props
|
|
216
|
+
},
|
|
217
|
+
ref
|
|
218
|
+
) => {
|
|
219
|
+
const sideBySide =
|
|
220
|
+
SIDE_BY_SIDE.includes(layout) &&
|
|
221
|
+
!(align === "end" && layout === "inline");
|
|
222
|
+
const autoTerm = sideBySide && termWidth === "auto";
|
|
223
|
+
const context = React.useMemo(
|
|
224
|
+
() => ({ layout, align, autoTerm }),
|
|
225
|
+
[layout, align, autoTerm]
|
|
226
|
+
);
|
|
227
|
+
|
|
228
|
+
return (
|
|
229
|
+
<DescriptionListContext.Provider value={context}>
|
|
230
|
+
<dl
|
|
231
|
+
ref={ref}
|
|
232
|
+
className={cn(
|
|
233
|
+
descriptionListVariants({
|
|
234
|
+
layout,
|
|
235
|
+
divided: layout === "grid" ? false : divided,
|
|
236
|
+
}),
|
|
237
|
+
autoTerm && autoTermListClasses[layout],
|
|
238
|
+
className
|
|
239
|
+
)}
|
|
240
|
+
data-align={align}
|
|
241
|
+
data-hook={dataHook}
|
|
242
|
+
data-layout={layout}
|
|
243
|
+
data-slot="description-list"
|
|
244
|
+
data-tracking-el={trackingEl || "description-list"}
|
|
245
|
+
data-tracking-label={trackingLabel}
|
|
246
|
+
style={
|
|
247
|
+
{
|
|
248
|
+
...(typeof termWidth === "number" && {
|
|
249
|
+
"--dl-term-width": `${termWidth}px`,
|
|
250
|
+
}),
|
|
251
|
+
...style,
|
|
252
|
+
} as React.CSSProperties
|
|
253
|
+
}
|
|
254
|
+
{...props}
|
|
255
|
+
/>
|
|
256
|
+
</DescriptionListContext.Provider>
|
|
257
|
+
);
|
|
258
|
+
}
|
|
259
|
+
);
|
|
260
|
+
DescriptionList.displayName = "DescriptionList";
|
|
261
|
+
|
|
262
|
+
/* -------------------------------------------------------------------------------------------------
|
|
263
|
+
* DescriptionListItem
|
|
264
|
+
* -----------------------------------------------------------------------------------------------*/
|
|
265
|
+
|
|
266
|
+
/**
|
|
267
|
+
* Props for DescriptionListItem — one term and its value.
|
|
268
|
+
*/
|
|
269
|
+
export interface DescriptionListItemProps extends React.ComponentProps<"div"> {
|
|
270
|
+
/**
|
|
271
|
+
* Data hook for automated testing.
|
|
272
|
+
*/
|
|
273
|
+
dataHook?: string;
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
/**
|
|
277
|
+
* One term and its value. Renders a `<div>`, the grouping element HTML allows
|
|
278
|
+
* inside a `<dl>`.
|
|
279
|
+
*/
|
|
280
|
+
const DescriptionListItem = React.forwardRef<
|
|
281
|
+
HTMLDivElement,
|
|
282
|
+
DescriptionListItemProps
|
|
283
|
+
>(({ className, dataHook, ...props }, ref) => {
|
|
284
|
+
const { layout, align, autoTerm } = React.useContext(DescriptionListContext);
|
|
285
|
+
const endAligned = align === "end" && layout === "inline";
|
|
286
|
+
|
|
287
|
+
return (
|
|
288
|
+
<div
|
|
289
|
+
ref={ref}
|
|
290
|
+
className={cn(
|
|
291
|
+
descriptionListItemVariants({ layout }),
|
|
292
|
+
endAligned && "justify-between",
|
|
293
|
+
autoTerm && autoTermItemClasses[layout],
|
|
294
|
+
className
|
|
295
|
+
)}
|
|
296
|
+
data-hook={dataHook}
|
|
297
|
+
data-slot="description-list-item"
|
|
298
|
+
{...props}
|
|
299
|
+
/>
|
|
300
|
+
);
|
|
301
|
+
});
|
|
302
|
+
DescriptionListItem.displayName = "DescriptionListItem";
|
|
303
|
+
|
|
304
|
+
/* -------------------------------------------------------------------------------------------------
|
|
305
|
+
* DescriptionListTerm
|
|
306
|
+
* -----------------------------------------------------------------------------------------------*/
|
|
307
|
+
|
|
308
|
+
/**
|
|
309
|
+
* Props for DescriptionListTerm — the label.
|
|
310
|
+
*/
|
|
311
|
+
export interface DescriptionListTermProps extends React.ComponentProps<"dt"> {
|
|
312
|
+
/**
|
|
313
|
+
* Data hook for automated testing.
|
|
314
|
+
*/
|
|
315
|
+
dataHook?: string;
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
/**
|
|
319
|
+
* The label of a pair. Muted, `text-body-sm`.
|
|
320
|
+
*/
|
|
321
|
+
const DescriptionListTerm = React.forwardRef<
|
|
322
|
+
HTMLElement,
|
|
323
|
+
DescriptionListTermProps
|
|
324
|
+
>(({ className, dataHook, ...props }, ref) => {
|
|
325
|
+
const { layout, align, autoTerm } = React.useContext(DescriptionListContext);
|
|
326
|
+
|
|
327
|
+
return (
|
|
328
|
+
<dt
|
|
329
|
+
ref={ref}
|
|
330
|
+
className={cn(
|
|
331
|
+
// The fixed width applies only when the term sits beside its value in
|
|
332
|
+
// a fixed column; an end-aligned or auto-width term sizes to its text.
|
|
333
|
+
descriptionListTermVariants({
|
|
334
|
+
layout: align === "end" || autoTerm ? "stacked" : layout,
|
|
335
|
+
}),
|
|
336
|
+
className
|
|
337
|
+
)}
|
|
338
|
+
data-hook={dataHook}
|
|
339
|
+
data-slot="description-list-term"
|
|
340
|
+
{...props}
|
|
341
|
+
/>
|
|
342
|
+
);
|
|
343
|
+
});
|
|
344
|
+
DescriptionListTerm.displayName = "DescriptionListTerm";
|
|
345
|
+
|
|
346
|
+
/* -------------------------------------------------------------------------------------------------
|
|
347
|
+
* DescriptionListDetails
|
|
348
|
+
* -----------------------------------------------------------------------------------------------*/
|
|
349
|
+
|
|
350
|
+
/**
|
|
351
|
+
* Props for DescriptionListDetails — the value.
|
|
352
|
+
*/
|
|
353
|
+
export interface DescriptionListDetailsProps extends React.ComponentProps<"dd"> {
|
|
354
|
+
/**
|
|
355
|
+
* Data hook for automated testing.
|
|
356
|
+
*/
|
|
357
|
+
dataHook?: string;
|
|
358
|
+
/**
|
|
359
|
+
* Text colour of the value. Use `muted` for an empty value ("Not set").
|
|
360
|
+
* @default "foreground"
|
|
361
|
+
*/
|
|
362
|
+
color?: "foreground" | "muted";
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
/**
|
|
366
|
+
* The value of a pair: text, a Badge, a Rating, a Link or an icon with text.
|
|
367
|
+
* Long values wrap.
|
|
368
|
+
*/
|
|
369
|
+
const DescriptionListDetails = React.forwardRef<
|
|
370
|
+
HTMLElement,
|
|
371
|
+
DescriptionListDetailsProps
|
|
372
|
+
>(({ className, color = "foreground", dataHook, ...props }, ref) => {
|
|
373
|
+
const { layout, align } = React.useContext(DescriptionListContext);
|
|
374
|
+
const endAligned = align === "end" && layout === "inline";
|
|
375
|
+
|
|
376
|
+
return (
|
|
377
|
+
<dd
|
|
378
|
+
ref={ref}
|
|
379
|
+
className={cn(
|
|
380
|
+
"text-body-sm min-w-0 flex-1 break-words",
|
|
381
|
+
color === "muted" ? "text-muted-foreground" : "text-foreground",
|
|
382
|
+
endAligned && "text-right tabular-nums",
|
|
383
|
+
className
|
|
384
|
+
)}
|
|
385
|
+
data-hook={dataHook}
|
|
386
|
+
data-slot="description-list-details"
|
|
387
|
+
{...props}
|
|
388
|
+
/>
|
|
389
|
+
);
|
|
390
|
+
});
|
|
391
|
+
DescriptionListDetails.displayName = "DescriptionListDetails";
|
|
392
|
+
|
|
393
|
+
/* -------------------------------------------------------------------------------------------------
|
|
394
|
+
* DescriptionListIconText
|
|
395
|
+
* -----------------------------------------------------------------------------------------------*/
|
|
396
|
+
|
|
397
|
+
/**
|
|
398
|
+
* Props for DescriptionListIconText — an icon or logo beside a text value.
|
|
399
|
+
*/
|
|
400
|
+
export interface DescriptionListIconTextProps extends React.ComponentProps<"span"> {
|
|
401
|
+
/**
|
|
402
|
+
* The icon or logo, sized to 16px.
|
|
403
|
+
*/
|
|
404
|
+
icon: React.ReactNode;
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
/**
|
|
408
|
+
* An icon or logo beside a text value, such as a review source and its name.
|
|
409
|
+
*/
|
|
410
|
+
const DescriptionListIconText = React.forwardRef<
|
|
411
|
+
HTMLSpanElement,
|
|
412
|
+
DescriptionListIconTextProps
|
|
413
|
+
>(({ className, icon, children, ...props }, ref) => (
|
|
414
|
+
<span
|
|
415
|
+
ref={ref}
|
|
416
|
+
className={cn(
|
|
417
|
+
"inline-flex max-w-full items-center gap-2 align-bottom [&_svg:not([class*='size-'])]:size-4",
|
|
418
|
+
className
|
|
419
|
+
)}
|
|
420
|
+
data-slot="description-list-icon-text"
|
|
421
|
+
{...props}
|
|
422
|
+
>
|
|
423
|
+
<span
|
|
424
|
+
aria-hidden="true"
|
|
425
|
+
className="inline-flex size-4 shrink-0 items-center justify-center"
|
|
426
|
+
>
|
|
427
|
+
{icon}
|
|
428
|
+
</span>
|
|
429
|
+
<span className="min-w-0">{children}</span>
|
|
430
|
+
</span>
|
|
431
|
+
));
|
|
432
|
+
DescriptionListIconText.displayName = "DescriptionListIconText";
|
|
433
|
+
|
|
434
|
+
/* -------------------------------------------------------------------------------------------------
|
|
435
|
+
* Exports
|
|
436
|
+
* -----------------------------------------------------------------------------------------------*/
|
|
437
|
+
|
|
438
|
+
export {
|
|
439
|
+
DescriptionList,
|
|
440
|
+
DescriptionListItem,
|
|
441
|
+
DescriptionListTerm,
|
|
442
|
+
DescriptionListDetails,
|
|
443
|
+
DescriptionListIconText,
|
|
444
|
+
descriptionListVariants,
|
|
445
|
+
};
|
|
@@ -111,8 +111,8 @@ function DrawerContent({
|
|
|
111
111
|
<DrawerPrimitive.Content
|
|
112
112
|
className={cn(
|
|
113
113
|
"group/drawer-content bg-background border-border fixed z-50 flex h-auto flex-col",
|
|
114
|
-
"data-[vaul-drawer-direction=top]:inset-x-0 data-[vaul-drawer-direction=top]:top-0 data-[vaul-drawer-direction=top]:mb-24 data-[vaul-drawer-direction=top]:max-h-[
|
|
115
|
-
"data-[vaul-drawer-direction=bottom]:inset-x-0 data-[vaul-drawer-direction=bottom]:bottom-0 data-[vaul-drawer-direction=bottom]:mt-24 data-[vaul-drawer-direction=bottom]:max-h-[
|
|
114
|
+
"data-[vaul-drawer-direction=top]:inset-x-0 data-[vaul-drawer-direction=top]:top-0 data-[vaul-drawer-direction=top]:mb-24 data-[vaul-drawer-direction=top]:max-h-[80svh] data-[vaul-drawer-direction=top]:rounded-b-[10px] data-[vaul-drawer-direction=top]:border-b",
|
|
115
|
+
"data-[vaul-drawer-direction=bottom]:inset-x-0 data-[vaul-drawer-direction=bottom]:bottom-0 data-[vaul-drawer-direction=bottom]:mt-24 data-[vaul-drawer-direction=bottom]:max-h-[80svh] data-[vaul-drawer-direction=bottom]:rounded-t-[10px] data-[vaul-drawer-direction=bottom]:border-t",
|
|
116
116
|
"data-[vaul-drawer-direction=right]:inset-y-0 data-[vaul-drawer-direction=right]:right-0 data-[vaul-drawer-direction=right]:w-3/4 data-[vaul-drawer-direction=right]:border-l data-[vaul-drawer-direction=right]:sm:max-w-sm",
|
|
117
117
|
"data-[vaul-drawer-direction=left]:inset-y-0 data-[vaul-drawer-direction=left]:left-0 data-[vaul-drawer-direction=left]:w-3/4 data-[vaul-drawer-direction=left]:border-r data-[vaul-drawer-direction=left]:sm:max-w-sm",
|
|
118
118
|
className
|
|
@@ -139,7 +139,7 @@ function DrawerHeader({ className, ...props }: React.ComponentProps<"div">) {
|
|
|
139
139
|
return (
|
|
140
140
|
<div
|
|
141
141
|
className={cn(
|
|
142
|
-
"
|
|
142
|
+
"flex w-full shrink-0 flex-col gap-1.5 p-4 text-center sm:text-left",
|
|
143
143
|
className
|
|
144
144
|
)}
|
|
145
145
|
data-slot="drawer-header"
|
|
@@ -157,7 +157,7 @@ function DrawerBody({ className, ...props }: React.ComponentProps<"div">) {
|
|
|
157
157
|
return (
|
|
158
158
|
<div
|
|
159
159
|
className={cn(
|
|
160
|
-
"
|
|
160
|
+
"min-h-0 w-full flex-1 overflow-x-hidden overflow-y-auto px-4",
|
|
161
161
|
"mt-4 group-has-[[data-slot=drawer-header]]/drawer-content:mt-0",
|
|
162
162
|
className
|
|
163
163
|
)}
|
|
@@ -176,7 +176,7 @@ function DrawerFooter({ className, ...props }: React.ComponentProps<"div">) {
|
|
|
176
176
|
return (
|
|
177
177
|
<div
|
|
178
178
|
className={cn(
|
|
179
|
-
"
|
|
179
|
+
"mt-auto flex w-full shrink-0 flex-col gap-2 p-4",
|
|
180
180
|
className
|
|
181
181
|
)}
|
|
182
182
|
data-slot="drawer-footer"
|
|
@@ -194,7 +194,7 @@ const DropdownMenuItem = React.forwardRef<
|
|
|
194
194
|
ref={ref}
|
|
195
195
|
className={cn(
|
|
196
196
|
[
|
|
197
|
-
"relative flex cursor-
|
|
197
|
+
"relative flex cursor-pointer items-center gap-2 self-stretch select-none",
|
|
198
198
|
"text-label rounded-sm px-2 py-1.5 outline-hidden",
|
|
199
199
|
// Text truncation for child text elements
|
|
200
200
|
"[&>span]:overflow-hidden [&>span]:text-ellipsis [&>span]:whitespace-nowrap",
|
|
@@ -262,7 +262,7 @@ const DropdownMenuCheckboxItem = React.forwardRef<
|
|
|
262
262
|
checked={checked}
|
|
263
263
|
className={cn(
|
|
264
264
|
[
|
|
265
|
-
"relative flex cursor-
|
|
265
|
+
"relative flex cursor-pointer items-center gap-2 select-none",
|
|
266
266
|
"text-label rounded-sm py-1.5 pr-2 pl-8 outline-hidden",
|
|
267
267
|
"focus:bg-accent focus:text-accent-foreground",
|
|
268
268
|
"data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
|
|
@@ -334,7 +334,7 @@ const DropdownMenuRadioItem = React.forwardRef<
|
|
|
334
334
|
ref={ref}
|
|
335
335
|
className={cn(
|
|
336
336
|
[
|
|
337
|
-
"relative flex cursor-
|
|
337
|
+
"relative flex cursor-pointer items-center gap-2 select-none",
|
|
338
338
|
"text-label rounded-sm py-1.5 pr-2 pl-8 outline-hidden",
|
|
339
339
|
"focus:bg-accent focus:text-accent-foreground",
|
|
340
340
|
"data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
|
|
@@ -496,7 +496,7 @@ const DropdownMenuSubTrigger = React.forwardRef<
|
|
|
496
496
|
ref={ref}
|
|
497
497
|
className={cn(
|
|
498
498
|
[
|
|
499
|
-
"flex cursor-
|
|
499
|
+
"flex cursor-pointer items-center gap-2 select-none data-[disabled]:cursor-not-allowed",
|
|
500
500
|
"text-label rounded-sm px-2 py-1.5 outline-hidden",
|
|
501
501
|
"focus:bg-accent focus:text-accent-foreground",
|
|
502
502
|
"data-[state=open]:bg-accent data-[state=open]:text-accent-foreground",
|
package/src/components/field.tsx
CHANGED
|
@@ -7,6 +7,7 @@ import { AlertCircle, type LucideProps } from "@brightlocal/icons";
|
|
|
7
7
|
import { cn } from "@brightlocal/ui-components/lib/utils";
|
|
8
8
|
import { Description } from "./description";
|
|
9
9
|
import { Label, type LabelProps } from "@brightlocal/ui-components/label";
|
|
10
|
+
import { FieldAriaProvider, useFieldAriaRegistration } from "../lib/field-aria";
|
|
10
11
|
|
|
11
12
|
function FieldSet({ className, ...props }: React.ComponentProps<"fieldset">) {
|
|
12
13
|
return (
|
|
@@ -188,21 +189,23 @@ function Field({
|
|
|
188
189
|
...props
|
|
189
190
|
}: FieldProps) {
|
|
190
191
|
return (
|
|
191
|
-
<
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
192
|
+
<FieldAriaProvider>
|
|
193
|
+
<div
|
|
194
|
+
className={cn(
|
|
195
|
+
fieldVariants({ orientation, variant }),
|
|
196
|
+
align === "end" &&
|
|
197
|
+
orientation === "horizontal" &&
|
|
198
|
+
"grid-cols-[1fr_auto]",
|
|
199
|
+
className
|
|
200
|
+
)}
|
|
201
|
+
data-hook={dataHook}
|
|
202
|
+
data-orientation={orientation}
|
|
203
|
+
data-slot="field"
|
|
204
|
+
data-variant={variant}
|
|
205
|
+
role="group"
|
|
206
|
+
{...props}
|
|
207
|
+
/>
|
|
208
|
+
</FieldAriaProvider>
|
|
206
209
|
);
|
|
207
210
|
}
|
|
208
211
|
|
|
@@ -277,8 +280,15 @@ interface FieldDescriptionProps extends React.ComponentProps<"p"> {
|
|
|
277
280
|
function FieldDescription({
|
|
278
281
|
className,
|
|
279
282
|
dataHook,
|
|
283
|
+
id: idProp,
|
|
280
284
|
...props
|
|
281
285
|
}: FieldDescriptionProps) {
|
|
286
|
+
// The hint registers its id with the enclosing Field so a text control can
|
|
287
|
+
// point aria-describedby at it without the consumer wiring it by hand.
|
|
288
|
+
const generatedId = React.useId();
|
|
289
|
+
const id = idProp ?? generatedId;
|
|
290
|
+
useFieldAriaRegistration("description", id, true);
|
|
291
|
+
|
|
282
292
|
return (
|
|
283
293
|
<Description
|
|
284
294
|
className={cn(
|
|
@@ -290,6 +300,7 @@ function FieldDescription({
|
|
|
290
300
|
)}
|
|
291
301
|
data-hook={dataHook}
|
|
292
302
|
data-slot="field-description"
|
|
303
|
+
id={id}
|
|
293
304
|
{...props}
|
|
294
305
|
/>
|
|
295
306
|
);
|
|
@@ -427,6 +438,7 @@ function FieldError({
|
|
|
427
438
|
dataHook,
|
|
428
439
|
children,
|
|
429
440
|
errors,
|
|
441
|
+
id: idProp,
|
|
430
442
|
...props
|
|
431
443
|
}: FieldErrorProps) {
|
|
432
444
|
// Filter out undefined errors and those without messages
|
|
@@ -436,6 +448,13 @@ function FieldError({
|
|
|
436
448
|
|
|
437
449
|
const hasMessage = Boolean(children) || Boolean(errorMessages?.length);
|
|
438
450
|
|
|
451
|
+
// While a message is on screen its id is registered with the enclosing
|
|
452
|
+
// Field, so a text control points aria-describedby at it automatically. An
|
|
453
|
+
// explicit `id` is kept, so existing hand-wiring keeps working.
|
|
454
|
+
const generatedId = React.useId();
|
|
455
|
+
const id = idProp ?? generatedId;
|
|
456
|
+
useFieldAriaRegistration("error", id, hasMessage);
|
|
457
|
+
|
|
439
458
|
// Screen readers only announce live-region content that arrives *after* the
|
|
440
459
|
// region is in the accessibility tree. Consumers typically mount FieldError
|
|
441
460
|
// together with the message, so when a message appears client-side the
|
|
@@ -454,6 +473,7 @@ function FieldError({
|
|
|
454
473
|
|
|
455
474
|
React.useEffect(() => {
|
|
456
475
|
if (!hasMessage) {
|
|
476
|
+
// eslint-disable-next-line react-hooks/set-state-in-effect -- derived live-region latch; refactor tracked in DS-1070
|
|
457
477
|
setDefer(true);
|
|
458
478
|
setAnnounced(false);
|
|
459
479
|
} else if (defer) {
|
|
@@ -486,6 +506,7 @@ function FieldError({
|
|
|
486
506
|
className={baseStyles}
|
|
487
507
|
data-hook={dataHook}
|
|
488
508
|
data-slot="field-error"
|
|
509
|
+
id={id}
|
|
489
510
|
role="status"
|
|
490
511
|
{...props}
|
|
491
512
|
>
|
|
@@ -54,7 +54,7 @@ const GlobalLayout = React.forwardRef<HTMLDivElement, GlobalLayoutProps>(
|
|
|
54
54
|
// sidebar from the viewport edge and make its 100dvh height
|
|
55
55
|
// overflow, so the page-level scroll region drops it.
|
|
56
56
|
className={cn(
|
|
57
|
-
"h-dvh w-full [&>[data-radix-scroll-area-viewport]]:p-0!
|
|
57
|
+
"h-dvh w-full [&>[data-radix-scroll-area-viewport]]:p-0!",
|
|
58
58
|
className
|
|
59
59
|
)}
|
|
60
60
|
dataHook={`${dataHook}-scroll`}
|