@brightlocal/ui-components 3.3.0 → 3.5.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.
Files changed (207) hide show
  1. package/AI_USAGE.md +22 -3
  2. package/README.md +177 -109
  3. package/component-meta.json +1307 -113
  4. package/dist/alert-dialog.cjs +1 -1
  5. package/dist/alert-dialog.d.ts +13 -2
  6. package/dist/alert-dialog.d.ts.map +1 -1
  7. package/dist/alert-dialog.js +4 -3
  8. package/dist/banner.cjs +1 -1
  9. package/dist/banner.d.ts +47 -11
  10. package/dist/banner.d.ts.map +1 -1
  11. package/dist/banner.js +156 -79
  12. package/dist/blocks/empty-state.cjs +1 -1
  13. package/dist/blocks/empty-state.d.ts +40 -5
  14. package/dist/blocks/empty-state.d.ts.map +1 -1
  15. package/dist/blocks/empty-state.js +59 -52
  16. package/dist/blocks/input-list.cjs +1 -1
  17. package/dist/blocks/input-list.d.ts +1 -0
  18. package/dist/blocks/input-list.d.ts.map +1 -1
  19. package/dist/blocks/input-list.js +39 -39
  20. package/dist/blocks/sidebar.cjs +1 -1
  21. package/dist/blocks/sidebar.d.ts +12 -6
  22. package/dist/blocks/sidebar.d.ts.map +1 -1
  23. package/dist/blocks/sidebar.js +64 -63
  24. package/dist/button.cjs +1 -1
  25. package/dist/button.d.ts.map +1 -1
  26. package/dist/button.js +47 -43
  27. package/dist/card.cjs +1 -1
  28. package/dist/card.d.ts +12 -0
  29. package/dist/card.d.ts.map +1 -1
  30. package/dist/card.js +115 -97
  31. package/dist/chart.cjs +6 -6
  32. package/dist/chart.d.ts +6 -10
  33. package/dist/chart.d.ts.map +1 -1
  34. package/dist/chart.js +281 -296
  35. package/dist/combobox.cjs +3 -3
  36. package/dist/combobox.d.ts.map +1 -1
  37. package/dist/combobox.js +430 -343
  38. package/dist/command.cjs +1 -1
  39. package/dist/command.d.ts +23 -2
  40. package/dist/command.d.ts.map +1 -1
  41. package/dist/command.js +212 -207
  42. package/dist/count-indicator.cjs +1 -0
  43. package/dist/count-indicator.d.ts +85 -0
  44. package/dist/count-indicator.d.ts.map +1 -0
  45. package/dist/count-indicator.js +72 -0
  46. package/dist/data-table.cjs +1 -1
  47. package/dist/data-table.d.ts +101 -11
  48. package/dist/data-table.d.ts.map +1 -1
  49. package/dist/data-table.js +593 -523
  50. package/dist/description-list.cjs +1 -0
  51. package/dist/description-list.d.ts +142 -0
  52. package/dist/description-list.d.ts.map +1 -0
  53. package/dist/description-list.js +173 -0
  54. package/dist/dialog.cjs +1 -1
  55. package/dist/dialog.d.ts +26 -3
  56. package/dist/dialog.d.ts.map +1 -1
  57. package/dist/dialog.js +62 -47
  58. package/dist/drawer.cjs +1 -1
  59. package/dist/drawer.d.ts +8 -4
  60. package/dist/drawer.d.ts.map +1 -1
  61. package/dist/drawer.js +37 -38
  62. package/dist/file-upload.cjs +1 -0
  63. package/dist/file-upload.d.ts +546 -0
  64. package/dist/file-upload.d.ts.map +1 -0
  65. package/dist/file-upload.js +1103 -0
  66. package/dist/global-layout.cjs +1 -1
  67. package/dist/global-layout.d.ts +7 -2
  68. package/dist/global-layout.d.ts.map +1 -1
  69. package/dist/global-layout.js +52 -52
  70. package/dist/hooks/use-file-dropzone.cjs +1 -0
  71. package/dist/hooks/use-file-dropzone.d.ts +75 -0
  72. package/dist/hooks/use-file-dropzone.d.ts.map +1 -0
  73. package/dist/hooks/use-file-dropzone.js +133 -0
  74. package/dist/hover-card.cjs +1 -1
  75. package/dist/hover-card.d.ts +29 -16
  76. package/dist/hover-card.d.ts.map +1 -1
  77. package/dist/hover-card.js +153 -36
  78. package/dist/index.cjs +1 -1
  79. package/dist/index.d.ts +4 -0
  80. package/dist/index.d.ts.map +1 -1
  81. package/dist/index.js +681 -623
  82. package/dist/input-chip.cjs +1 -1
  83. package/dist/input-chip.d.ts +30 -1
  84. package/dist/input-chip.d.ts.map +1 -1
  85. package/dist/input-chip.js +131 -115
  86. package/dist/input-group.cjs +1 -1
  87. package/dist/input-group.d.ts +37 -2
  88. package/dist/input-group.d.ts.map +1 -1
  89. package/dist/input-group.js +131 -114
  90. package/dist/input-password.cjs +1 -1
  91. package/dist/input-password.js +6 -6
  92. package/dist/lib/empty-canvas.cjs +1 -1
  93. package/dist/lib/empty-canvas.d.ts +27 -1
  94. package/dist/lib/empty-canvas.d.ts.map +1 -1
  95. package/dist/lib/empty-canvas.js +27 -23
  96. package/dist/lib/empty-chip.cjs +1 -1
  97. package/dist/lib/empty-chip.d.ts +19 -2
  98. package/dist/lib/empty-chip.d.ts.map +1 -1
  99. package/dist/lib/empty-chip.js +14 -9
  100. package/dist/lib/field-aria.cjs +1 -1
  101. package/dist/lib/field-aria.d.ts +4 -4
  102. package/dist/lib/field-aria.d.ts.map +1 -1
  103. package/dist/lib/field-aria.js +7 -5
  104. package/dist/lib/media-viewer-content.cjs +1 -1
  105. package/dist/lib/media-viewer-content.js +1 -1
  106. package/dist/lib/motion.cjs +1 -1
  107. package/dist/lib/motion.js +15 -10
  108. package/dist/lib/table-internal.cjs +1 -1
  109. package/dist/lib/table-internal.d.ts +19 -0
  110. package/dist/lib/table-internal.d.ts.map +1 -1
  111. package/dist/lib/table-internal.js +22 -7
  112. package/dist/list.cjs +1 -1
  113. package/dist/list.d.ts +230 -40
  114. package/dist/list.d.ts.map +1 -1
  115. package/dist/list.js +301 -66
  116. package/dist/logo-mark.cjs +1 -1
  117. package/dist/logo-mark.d.ts +18 -2
  118. package/dist/logo-mark.d.ts.map +1 -1
  119. package/dist/logo-mark.js +159 -79
  120. package/dist/media-empty.cjs +1 -1
  121. package/dist/media-empty.d.ts +50 -7
  122. package/dist/media-empty.d.ts.map +1 -1
  123. package/dist/media-empty.js +14 -13
  124. package/dist/media-viewer.cjs +1 -1
  125. package/dist/media-viewer.js +6 -6
  126. package/dist/multi-select-filter.cjs +1 -1
  127. package/dist/multi-select-filter.d.ts.map +1 -1
  128. package/dist/multi-select-filter.js +92 -101
  129. package/dist/pagination.cjs +1 -1
  130. package/dist/pagination.d.ts +11 -0
  131. package/dist/pagination.d.ts.map +1 -1
  132. package/dist/pagination.js +17 -17
  133. package/dist/relative-date.d.ts +6 -0
  134. package/dist/relative-date.d.ts.map +1 -1
  135. package/dist/resizable.d.ts +1 -1
  136. package/dist/result-count.cjs +1 -1
  137. package/dist/result-count.d.ts +13 -16
  138. package/dist/result-count.d.ts.map +1 -1
  139. package/dist/result-count.js +24 -33
  140. package/dist/route-progress.cjs +1 -1
  141. package/dist/route-progress.js +24 -23
  142. package/dist/sheet.cjs +1 -1
  143. package/dist/sheet.d.ts +22 -3
  144. package/dist/sheet.d.ts.map +1 -1
  145. package/dist/sheet.js +152 -125
  146. package/dist/single-select-filter.cjs +1 -1
  147. package/dist/single-select-filter.d.ts.map +1 -1
  148. package/dist/single-select-filter.js +67 -76
  149. package/dist/table.cjs +1 -1
  150. package/dist/table.d.ts.map +1 -1
  151. package/dist/table.js +77 -76
  152. package/dist/tabs.cjs +1 -1
  153. package/dist/tabs.d.ts +39 -3
  154. package/dist/tabs.d.ts.map +1 -1
  155. package/dist/tabs.js +127 -76
  156. package/dist/textarea.cjs +1 -1
  157. package/dist/textarea.d.ts +34 -0
  158. package/dist/textarea.d.ts.map +1 -1
  159. package/dist/textarea.js +115 -19
  160. package/dist/tooltip.cjs +1 -1
  161. package/dist/tooltip.d.ts.map +1 -1
  162. package/dist/tooltip.js +137 -131
  163. package/dist/typography-text.cjs +1 -1
  164. package/dist/typography-text.d.ts +6 -2
  165. package/dist/typography-text.d.ts.map +1 -1
  166. package/dist/typography-text.js +14 -13
  167. package/package.json +2 -3
  168. package/src/blocks/empty-state.tsx +108 -48
  169. package/src/blocks/input-list.tsx +15 -9
  170. package/src/blocks/sidebar.tsx +39 -16
  171. package/src/components/alert-dialog.tsx +18 -2
  172. package/src/components/banner.tsx +247 -68
  173. package/src/components/button.tsx +27 -10
  174. package/src/components/card.tsx +89 -7
  175. package/src/components/chart.tsx +47 -67
  176. package/src/components/combobox.tsx +221 -12
  177. package/src/components/command.tsx +83 -37
  178. package/src/components/count-indicator.tsx +188 -0
  179. package/src/components/data-table.tsx +506 -159
  180. package/src/components/description-list.tsx +445 -0
  181. package/src/components/dialog.tsx +74 -5
  182. package/src/components/drawer.tsx +52 -32
  183. package/src/components/file-upload.tsx +2574 -0
  184. package/src/components/global-layout.tsx +18 -5
  185. package/src/components/hover-card.tsx +395 -65
  186. package/src/components/input-chip.tsx +67 -2
  187. package/src/components/input-group.tsx +89 -6
  188. package/src/components/list.tsx +720 -72
  189. package/src/components/logo-mark.tsx +109 -25
  190. package/src/components/media-empty.tsx +62 -7
  191. package/src/components/multi-select-filter.tsx +9 -16
  192. package/src/components/pagination.tsx +15 -2
  193. package/src/components/relative-date.tsx +6 -0
  194. package/src/components/result-count.tsx +27 -54
  195. package/src/components/sheet.tsx +86 -8
  196. package/src/components/single-select-filter.tsx +9 -16
  197. package/src/components/table.tsx +16 -1
  198. package/src/components/tabs.tsx +223 -41
  199. package/src/components/textarea.tsx +271 -4
  200. package/src/components/tooltip.tsx +29 -2
  201. package/src/components/typography-text.tsx +7 -2
  202. package/src/hooks/use-file-dropzone.ts +325 -0
  203. package/src/index.ts +4 -0
  204. package/src/lib/empty-canvas.tsx +47 -20
  205. package/src/lib/empty-chip.tsx +38 -3
  206. package/src/lib/field-aria.tsx +11 -6
  207. package/src/lib/table-internal.ts +38 -0
@@ -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
+ };
@@ -5,6 +5,7 @@ import * as DialogPrimitive from "@radix-ui/react-dialog";
5
5
  import { X } from "@brightlocal/icons";
6
6
 
7
7
  import { cn } from "@brightlocal/ui-components/lib/utils";
8
+ import { ScrollArea } from "@brightlocal/ui-components/scroll-area";
8
9
  import { useOverlayPointerLock } from "@brightlocal/ui-components/hooks/use-overlay-pointer-lock";
9
10
 
10
11
  /**
@@ -86,6 +87,24 @@ const DialogOverlay = React.forwardRef<
86
87
  ));
87
88
  DialogOverlay.displayName = "DialogOverlay";
88
89
 
90
+ const dialogContentClassName = cn(
91
+ // Width follows the content (DS-1249). min-content means only content with
92
+ // a real intrinsic width (a table, an image, anything with an explicit
93
+ // width) pushes the panel wider; text wraps instead, so it never stretches
94
+ // the dialog. The floor is 512px (32rem) and the ceiling 1024px (64rem);
95
+ // both keep a 16px gutter on each side of a narrower viewport. inset-x-0 +
96
+ // mx-auto centres it horizontally: with left-1/2 the shrink-to-fit space
97
+ // would be half the viewport.
98
+ "bg-background text-foreground border-card-border fixed inset-x-0 top-[50%] z-50 mx-auto w-min max-w-[min(64rem,100%-2rem)] min-w-[min(32rem,100%-2rem)] translate-y-[-50%] rounded-xl border p-8 shadow-lg",
99
+ // Flex column capped at 85% of the small viewport height (DS-1249): a
100
+ // DialogBody takes the leftover height and scrolls, keeping the header
101
+ // and footer in view. Without a DialogBody the whole panel scrolls, so
102
+ // the dialog never runs off the screen. Children stretch, so the header
103
+ // and footer span the full width of a wide dialog.
104
+ "flex max-h-[85svh] flex-col gap-8 overflow-y-auto",
105
+ "data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=open]:duration-slow ease-out data-[state=closed]:duration-250 data-[state=closed]:ease-in"
106
+ );
107
+
89
108
  /**
90
109
  * Props for DialogContent component
91
110
  */
@@ -113,7 +132,12 @@ interface DialogContentProps extends React.ComponentProps<
113
132
 
114
133
  /**
115
134
  * DialogContent - The main dialog content container
116
- * @description Contains the dialog's content including header, body, and footer
135
+ * @description Contains the dialog's content including header, body, and
136
+ * footer. The width follows the content: at least 512px, with text wrapping
137
+ * at 512px, and growing up to 1024px for content with its own width, such as
138
+ * a table or an image. A viewport narrower than that keeps a 16px gutter on
139
+ * each side. The height is capped at 85svh; wrap tall content in
140
+ * `DialogBody` so it scrolls between the header and footer.
117
141
  */
118
142
  const DialogContent = React.forwardRef<HTMLDivElement, DialogContentProps>(
119
143
  (
@@ -136,10 +160,7 @@ const DialogContent = React.forwardRef<HTMLDivElement, DialogContentProps>(
136
160
  <DialogOverlay />
137
161
  <DialogPrimitive.Content
138
162
  ref={ref}
139
- className={cn(
140
- "bg-background text-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 border-card-border data-[state=open]:duration-slow fixed top-[50%] left-[50%] z-50 grid w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-8 rounded-xl border p-8 shadow-lg ease-out data-[state=closed]:duration-250 data-[state=closed]:ease-in sm:max-w-lg",
141
- className
142
- )}
163
+ className={cn(dialogContentClassName, className)}
143
164
  data-hook={dataHook}
144
165
  data-slot="dialog-content"
145
166
  data-tracking-el={trackingEl}
@@ -175,6 +196,52 @@ const DialogHeader = React.forwardRef<
175
196
  ));
176
197
  DialogHeader.displayName = "DialogHeader";
177
198
 
199
+ /**
200
+ * Props for the DialogBody component
201
+ */
202
+ interface DialogBodyProps extends Omit<
203
+ React.ComponentProps<typeof ScrollArea>,
204
+ "dataHook"
205
+ > {
206
+ /**
207
+ * Data hook for automated testing
208
+ * @default "dialog-body"
209
+ */
210
+ dataHook?: string;
211
+ }
212
+
213
+ /**
214
+ * DialogBody - The scrollable region between DialogHeader and DialogFooter.
215
+ * @description Takes the height left inside the 85svh cap and scrolls long
216
+ * content with DS scrollbars in a keyboard-focusable viewport, while the
217
+ * header, footer and close button stay in view.
218
+ */
219
+ const DialogBody = React.forwardRef<
220
+ React.ComponentRef<typeof ScrollArea>,
221
+ DialogBodyProps
222
+ >(({ className, children, dataHook, ...props }, ref) => (
223
+ <ScrollArea
224
+ ref={ref}
225
+ // -mx-8 escapes DialogContent's p-8 so the scrollbar sits at the panel
226
+ // edge; the inner px-7 plus the viewport's built-in p-1 restores the
227
+ // 32px content inset. The viewport's outer focus ring would be clipped by
228
+ // the scroll root and the panel edge, so it is drawn inset here.
229
+ className={cn(
230
+ "-mx-8 flex min-h-0 flex-1 flex-col",
231
+ "[&>[data-slot=scroll-area-viewport]]:focus-visible:shadow-[inset_0_0_0_var(--ds-spread-xs)_var(--color-outline)]",
232
+ className
233
+ )}
234
+ data-slot="dialog-body"
235
+ dataHook={dataHook ?? "dialog-body"}
236
+ {...props}
237
+ >
238
+ <div className="px-7" data-slot="dialog-body-content">
239
+ {children}
240
+ </div>
241
+ </ScrollArea>
242
+ ));
243
+ DialogBody.displayName = "DialogBody";
244
+
178
245
  /**
179
246
  * DialogFooter - Container for dialog action buttons.
180
247
  * @description Groups action buttons at the bottom of the dialog
@@ -259,6 +326,7 @@ DialogDescription.displayName = "DialogDescription";
259
326
 
260
327
  export {
261
328
  Dialog,
329
+ DialogBody,
262
330
  DialogClose,
263
331
  DialogContent,
264
332
  DialogDescription,
@@ -271,6 +339,7 @@ export {
271
339
  };
272
340
 
273
341
  export type {
342
+ DialogBodyProps,
274
343
  DialogContentProps,
275
344
  DialogDescriptionProps,
276
345
  DialogTitleProps,
@@ -91,44 +91,64 @@ type DrawerContentProps = React.ComponentProps<
91
91
  * Tracking label for analytics context
92
92
  */
93
93
  trackingLabel?: string;
94
+ /**
95
+ * Expand the drawer to the full viewport height (100svh) instead of the
96
+ * default 80svh cap. Use for mobile filter sheets or other tall content
97
+ * that needs the entire screen.
98
+ * @default false
99
+ */
100
+ fullHeight?: boolean;
94
101
  };
95
102
 
96
103
  /**
97
104
  * DrawerContent - The main drawer content container
98
105
  * @description Contains the drawer's content including header, body, and footer
99
106
  */
100
- function DrawerContent({
101
- className,
102
- children,
103
- dataHook,
104
- trackingEl,
105
- trackingLabel,
106
- ...props
107
- }: DrawerContentProps) {
108
- return (
109
- <DrawerPortal>
110
- <DrawerOverlay />
111
- <DrawerPrimitive.Content
112
- className={cn(
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-[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
- "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
- "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
- className
119
- )}
120
- data-hook={dataHook}
121
- data-slot="drawer-content"
122
- data-tracking-el={trackingEl}
123
- data-tracking-label={trackingLabel}
124
- {...props}
125
- >
126
- <div className="bg-muted mx-auto mt-4 hidden h-2 w-[120px] shrink-0 rounded-full group-data-[vaul-drawer-direction=bottom]/drawer-content:block" />
127
- {children}
128
- </DrawerPrimitive.Content>
129
- </DrawerPortal>
130
- );
131
- }
107
+ const DrawerContent = React.forwardRef<
108
+ React.ComponentRef<typeof DrawerPrimitive.Content>,
109
+ DrawerContentProps
110
+ >(
111
+ (
112
+ {
113
+ className,
114
+ children,
115
+ dataHook,
116
+ trackingEl,
117
+ trackingLabel,
118
+ fullHeight,
119
+ ...props
120
+ },
121
+ ref
122
+ ) => {
123
+ return (
124
+ <DrawerPortal>
125
+ <DrawerOverlay />
126
+ <DrawerPrimitive.Content
127
+ ref={ref}
128
+ className={cn(
129
+ "group/drawer-content bg-background border-border fixed z-50 flex h-auto flex-col",
130
+ "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]:rounded-b-[10px] data-[vaul-drawer-direction=top]:border-b",
131
+ "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]:rounded-t-[10px] data-[vaul-drawer-direction=bottom]:border-t",
132
+ fullHeight
133
+ ? "data-[vaul-drawer-direction=bottom]:max-h-[100svh] data-[vaul-drawer-direction=top]:max-h-[100svh]"
134
+ : "data-[vaul-drawer-direction=bottom]:max-h-[80svh] data-[vaul-drawer-direction=top]:max-h-[80svh]",
135
+ "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",
136
+ "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",
137
+ className
138
+ )}
139
+ data-hook={dataHook}
140
+ data-slot="drawer-content"
141
+ data-tracking-el={trackingEl}
142
+ data-tracking-label={trackingLabel}
143
+ {...props}
144
+ >
145
+ <div className="bg-muted mx-auto mt-4 hidden h-2 w-[120px] shrink-0 rounded-full group-data-[vaul-drawer-direction=bottom]/drawer-content:block" />
146
+ {children}
147
+ </DrawerPrimitive.Content>
148
+ </DrawerPortal>
149
+ );
150
+ }
151
+ );
132
152
  DrawerContent.displayName = "DrawerContent";
133
153
 
134
154
  /**