@brightlocal/ui-components 3.4.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 (196) hide show
  1. package/AI_USAGE.md +22 -3
  2. package/README.md +177 -109
  3. package/component-meta.json +1061 -102
  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.d.ts +1 -0
  17. package/dist/blocks/input-list.d.ts.map +1 -1
  18. package/dist/blocks/sidebar.cjs +1 -1
  19. package/dist/blocks/sidebar.d.ts +12 -6
  20. package/dist/blocks/sidebar.d.ts.map +1 -1
  21. package/dist/blocks/sidebar.js +64 -63
  22. package/dist/button.cjs +1 -1
  23. package/dist/button.d.ts.map +1 -1
  24. package/dist/button.js +47 -43
  25. package/dist/card.cjs +1 -1
  26. package/dist/card.d.ts +12 -0
  27. package/dist/card.d.ts.map +1 -1
  28. package/dist/card.js +115 -97
  29. package/dist/chart.cjs +6 -6
  30. package/dist/chart.d.ts +6 -10
  31. package/dist/chart.d.ts.map +1 -1
  32. package/dist/chart.js +281 -296
  33. package/dist/combobox.cjs +3 -3
  34. package/dist/combobox.d.ts.map +1 -1
  35. package/dist/combobox.js +430 -343
  36. package/dist/command.cjs +1 -1
  37. package/dist/command.d.ts +23 -2
  38. package/dist/command.d.ts.map +1 -1
  39. package/dist/command.js +212 -207
  40. package/dist/count-indicator.cjs +1 -0
  41. package/dist/count-indicator.d.ts +85 -0
  42. package/dist/count-indicator.d.ts.map +1 -0
  43. package/dist/count-indicator.js +72 -0
  44. package/dist/data-table.cjs +1 -1
  45. package/dist/data-table.d.ts +101 -11
  46. package/dist/data-table.d.ts.map +1 -1
  47. package/dist/data-table.js +593 -523
  48. package/dist/dialog.cjs +1 -1
  49. package/dist/dialog.d.ts +26 -3
  50. package/dist/dialog.d.ts.map +1 -1
  51. package/dist/dialog.js +62 -47
  52. package/dist/drawer.cjs +1 -1
  53. package/dist/drawer.d.ts +8 -4
  54. package/dist/drawer.d.ts.map +1 -1
  55. package/dist/drawer.js +37 -38
  56. package/dist/file-upload.cjs +1 -0
  57. package/dist/file-upload.d.ts +546 -0
  58. package/dist/file-upload.d.ts.map +1 -0
  59. package/dist/file-upload.js +1103 -0
  60. package/dist/global-layout.cjs +1 -1
  61. package/dist/global-layout.d.ts +7 -2
  62. package/dist/global-layout.d.ts.map +1 -1
  63. package/dist/global-layout.js +52 -52
  64. package/dist/hooks/use-file-dropzone.cjs +1 -0
  65. package/dist/hooks/use-file-dropzone.d.ts +75 -0
  66. package/dist/hooks/use-file-dropzone.d.ts.map +1 -0
  67. package/dist/hooks/use-file-dropzone.js +133 -0
  68. package/dist/hover-card.cjs +1 -1
  69. package/dist/hover-card.d.ts +29 -16
  70. package/dist/hover-card.d.ts.map +1 -1
  71. package/dist/hover-card.js +153 -36
  72. package/dist/index.cjs +1 -1
  73. package/dist/index.d.ts +3 -0
  74. package/dist/index.d.ts.map +1 -1
  75. package/dist/index.js +676 -640
  76. package/dist/input-chip.cjs +1 -1
  77. package/dist/input-chip.d.ts +30 -1
  78. package/dist/input-chip.d.ts.map +1 -1
  79. package/dist/input-chip.js +131 -115
  80. package/dist/input-group.cjs +1 -1
  81. package/dist/input-group.d.ts +37 -2
  82. package/dist/input-group.d.ts.map +1 -1
  83. package/dist/input-group.js +131 -114
  84. package/dist/input-password.cjs +1 -1
  85. package/dist/input-password.js +6 -6
  86. package/dist/lib/empty-canvas.cjs +1 -1
  87. package/dist/lib/empty-canvas.d.ts +27 -1
  88. package/dist/lib/empty-canvas.d.ts.map +1 -1
  89. package/dist/lib/empty-canvas.js +27 -23
  90. package/dist/lib/empty-chip.cjs +1 -1
  91. package/dist/lib/empty-chip.d.ts +19 -2
  92. package/dist/lib/empty-chip.d.ts.map +1 -1
  93. package/dist/lib/empty-chip.js +14 -9
  94. package/dist/lib/field-aria.cjs +1 -1
  95. package/dist/lib/field-aria.d.ts +4 -4
  96. package/dist/lib/field-aria.d.ts.map +1 -1
  97. package/dist/lib/field-aria.js +7 -5
  98. package/dist/lib/media-viewer-content.cjs +1 -1
  99. package/dist/lib/media-viewer-content.js +1 -1
  100. package/dist/lib/table-internal.cjs +1 -1
  101. package/dist/lib/table-internal.d.ts +19 -0
  102. package/dist/lib/table-internal.d.ts.map +1 -1
  103. package/dist/lib/table-internal.js +22 -7
  104. package/dist/list.cjs +1 -1
  105. package/dist/list.d.ts +13 -0
  106. package/dist/list.d.ts.map +1 -1
  107. package/dist/list.js +103 -82
  108. package/dist/logo-mark.cjs +1 -1
  109. package/dist/logo-mark.d.ts +18 -2
  110. package/dist/logo-mark.d.ts.map +1 -1
  111. package/dist/logo-mark.js +159 -79
  112. package/dist/media-empty.cjs +1 -1
  113. package/dist/media-empty.d.ts +50 -7
  114. package/dist/media-empty.d.ts.map +1 -1
  115. package/dist/media-empty.js +14 -13
  116. package/dist/media-viewer.cjs +1 -1
  117. package/dist/media-viewer.js +6 -6
  118. package/dist/multi-select-filter.cjs +1 -1
  119. package/dist/multi-select-filter.d.ts.map +1 -1
  120. package/dist/multi-select-filter.js +92 -101
  121. package/dist/pagination.cjs +1 -1
  122. package/dist/pagination.d.ts +11 -0
  123. package/dist/pagination.d.ts.map +1 -1
  124. package/dist/pagination.js +17 -17
  125. package/dist/relative-date.d.ts +6 -0
  126. package/dist/relative-date.d.ts.map +1 -1
  127. package/dist/resizable.d.ts +1 -1
  128. package/dist/result-count.cjs +1 -1
  129. package/dist/result-count.d.ts +13 -16
  130. package/dist/result-count.d.ts.map +1 -1
  131. package/dist/result-count.js +24 -33
  132. package/dist/sheet.cjs +1 -1
  133. package/dist/sheet.d.ts +22 -3
  134. package/dist/sheet.d.ts.map +1 -1
  135. package/dist/sheet.js +152 -125
  136. package/dist/single-select-filter.cjs +1 -1
  137. package/dist/single-select-filter.d.ts.map +1 -1
  138. package/dist/single-select-filter.js +67 -76
  139. package/dist/table.cjs +1 -1
  140. package/dist/table.d.ts.map +1 -1
  141. package/dist/table.js +77 -76
  142. package/dist/tabs.cjs +1 -1
  143. package/dist/tabs.d.ts +39 -3
  144. package/dist/tabs.d.ts.map +1 -1
  145. package/dist/tabs.js +127 -76
  146. package/dist/textarea.cjs +1 -1
  147. package/dist/textarea.d.ts +34 -0
  148. package/dist/textarea.d.ts.map +1 -1
  149. package/dist/textarea.js +115 -19
  150. package/dist/tooltip.cjs +1 -1
  151. package/dist/tooltip.d.ts.map +1 -1
  152. package/dist/tooltip.js +137 -131
  153. package/dist/typography-text.cjs +1 -1
  154. package/dist/typography-text.d.ts +6 -2
  155. package/dist/typography-text.d.ts.map +1 -1
  156. package/dist/typography-text.js +14 -13
  157. package/package.json +3 -4
  158. package/src/blocks/empty-state.tsx +108 -48
  159. package/src/blocks/input-list.tsx +1 -0
  160. package/src/blocks/sidebar.tsx +39 -16
  161. package/src/components/alert-dialog.tsx +18 -2
  162. package/src/components/banner.tsx +247 -68
  163. package/src/components/button.tsx +27 -10
  164. package/src/components/card.tsx +89 -7
  165. package/src/components/chart.tsx +47 -67
  166. package/src/components/combobox.tsx +221 -12
  167. package/src/components/command.tsx +83 -37
  168. package/src/components/count-indicator.tsx +188 -0
  169. package/src/components/data-table.tsx +506 -159
  170. package/src/components/dialog.tsx +74 -5
  171. package/src/components/drawer.tsx +52 -32
  172. package/src/components/file-upload.tsx +2574 -0
  173. package/src/components/global-layout.tsx +18 -5
  174. package/src/components/hover-card.tsx +395 -65
  175. package/src/components/input-chip.tsx +67 -2
  176. package/src/components/input-group.tsx +89 -6
  177. package/src/components/list.tsx +40 -3
  178. package/src/components/logo-mark.tsx +109 -25
  179. package/src/components/media-empty.tsx +62 -7
  180. package/src/components/multi-select-filter.tsx +9 -16
  181. package/src/components/pagination.tsx +15 -2
  182. package/src/components/relative-date.tsx +6 -0
  183. package/src/components/result-count.tsx +27 -54
  184. package/src/components/sheet.tsx +86 -8
  185. package/src/components/single-select-filter.tsx +9 -16
  186. package/src/components/table.tsx +16 -1
  187. package/src/components/tabs.tsx +223 -41
  188. package/src/components/textarea.tsx +271 -4
  189. package/src/components/tooltip.tsx +29 -2
  190. package/src/components/typography-text.tsx +7 -2
  191. package/src/hooks/use-file-dropzone.ts +325 -0
  192. package/src/index.ts +3 -0
  193. package/src/lib/empty-canvas.tsx +47 -20
  194. package/src/lib/empty-chip.tsx +38 -3
  195. package/src/lib/field-aria.tsx +11 -6
  196. package/src/lib/table-internal.ts +38 -0
@@ -41,7 +41,7 @@ import {
41
41
  PopoverContent,
42
42
  PopoverTrigger,
43
43
  } from "@brightlocal/ui-components/popover";
44
- import { EmptyChip } from "../lib/empty-chip";
44
+ import { EmptyState } from "../blocks/empty-state";
45
45
 
46
46
  /* MultiSelectFilter — the Filtering pattern's several-at-once filter
47
47
  (Patterns/Filtering → Which filter → Several at once): several values
@@ -752,21 +752,14 @@ const MultiSelectFilter = React.forwardRef<
752
752
  /* The compact no-match form of Patterns → Empty States: the
753
753
  muted chip, the message line, one quiet hint — the same
754
754
  form CommandEmpty draws in the menu. */
755
- <div
756
- className="text-body-sm flex flex-col items-center gap-1 py-6 text-center"
757
- data-hook={`${dataHook}-empty`}
758
- >
759
- <EmptyChip
760
- className="mb-1"
761
- dataHook={`${dataHook}-empty-icon`}
762
- icon={<SearchX />}
763
- slot="multi-select-filter-empty-icon"
764
- />
765
- <p>{emptyLabel ?? "No options found."}</p>
766
- <p className="text-muted-foreground">
767
- {emptyDescription ?? "Try another search."}
768
- </p>
769
- </div>
755
+ <EmptyState
756
+ className="py-6"
757
+ dataHook={`${dataHook}-empty`}
758
+ description={emptyDescription ?? "Try another search."}
759
+ icon={<SearchX />}
760
+ size="sm"
761
+ title={emptyLabel ?? "No options found."}
762
+ />
770
763
  ) : (
771
764
  <>
772
765
  {allLabel !== undefined && !searching ? (
@@ -468,6 +468,17 @@ interface PaginationControlsProps extends Omit<
468
468
  * @default "More pages"
469
469
  */
470
470
  ellipsisSrLabel?: string;
471
+ /**
472
+ * @deprecated No-op since 3.5.0 — the count holds its previous value
473
+ * during a refetch; the DataTable's `refetchingLabel` live region covers
474
+ * SR announcements. Will be removed in the next major version.
475
+ */
476
+ updating?: boolean;
477
+ /**
478
+ * @deprecated No-op since 3.5.0 — removed together with `updating`.
479
+ * Will be removed in the next major version.
480
+ */
481
+ updatingLabel?: string;
471
482
  /** Tracking element identifier for analytics. */
472
483
  trackingEl?: string;
473
484
  /** Tracking label for analytics context. */
@@ -545,6 +556,10 @@ const PaginationControls = React.forwardRef<
545
556
  nextAriaLabel,
546
557
  pageAriaLabel,
547
558
  ellipsisSrLabel,
559
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars -- deprecated no-ops
560
+ updating,
561
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
562
+ updatingLabel,
548
563
  trackingEl,
549
564
  trackingLabel,
550
565
  ...props
@@ -610,8 +625,6 @@ const PaginationControls = React.forwardRef<
610
625
  })();
611
626
 
612
627
  const showNav = totalPages > 1;
613
- // At zero items the default caption is only its screen-reader empty
614
- // label, so the bar keeps no height for it and the nav centres.
615
628
  const captionVisible =
616
629
  caption != null && (Boolean(renderCaption) || totalItems !== 0);
617
630
 
@@ -156,6 +156,12 @@ export function relativeWords(
156
156
  return dateLabel(date, now);
157
157
  }
158
158
 
159
+ /**
160
+ * Returns the current `Date`, re-rendering the consumer on a configurable interval.
161
+ *
162
+ * @param every - Refresh interval in milliseconds
163
+ * @default 30_000
164
+ */
159
165
  export function useNow(every = 30 * SECOND): Date {
160
166
  const [now, setNow] = useState(() => new Date());
161
167
  useEffect(() => {
@@ -2,15 +2,15 @@
2
2
 
3
3
  import * as React from "react";
4
4
 
5
- import { Spinner } from "@brightlocal/ui-components/spinner";
6
5
  import { cn } from "@brightlocal/ui-components/lib/utils";
7
6
 
8
7
  /* ResultCount — the one count text the DS renders for a collection
9
8
  (Patterns/Filtering → Where controls live, part 4). It is the screen's
10
9
  ONE live region: role="status", announced once per change — the rows
11
- themselves announce nothing. During a refetch it pairs the count with a
12
- spinner so a change is never dimming alone; the text swap is what
13
- announces "Updating results", then the new count — once each.
10
+ themselves announce nothing. During a scope-change refetch the count
11
+ holds its previous value (no dimming, no spinner) and the live region
12
+ announces "Updating results" once; the new count replaces the old one
13
+ atomically when data arrives.
14
14
 
15
15
  Two forms, one component: the plain form ("4 of 24 locations")
16
16
  says what the filters left; the range form ("1 to 20 of 45
@@ -27,20 +27,6 @@ interface ResultCountBaseProps extends Omit<
27
27
  * @example "locations-result-count"
28
28
  */
29
29
  dataHook: string;
30
- /**
31
- * Refetch in flight — the live region announces the updating message
32
- * alone, while the previous count stays on screen (aria-hidden) beside
33
- * the spinner. Dimming the rows is the consumer's job; this indicator is
34
- * what makes dimming never the only signal.
35
- * @default false
36
- */
37
- updating?: boolean;
38
- /**
39
- * Text shown beside the spinner during a refetch — and, on its own, the
40
- * whole of what the live region announces while it is in flight.
41
- * @default "Updating results"
42
- */
43
- updatingLabel?: string;
44
30
  /**
45
31
  * Screen-reader-only text while the collection is empty. The visible
46
32
  * count hides at zero — the empty state already says it — but the live
@@ -52,6 +38,17 @@ interface ResultCountBaseProps extends Omit<
52
38
  trackingEl?: string;
53
39
  /** Analytics label */
54
40
  trackingLabel?: string;
41
+ /**
42
+ * @deprecated No-op since 3.5.0 — the count holds its previous value
43
+ * during a refetch; the DataTable's `refetchingLabel` live region covers
44
+ * SR announcements. Will be removed in the next major version.
45
+ */
46
+ updating?: boolean;
47
+ /**
48
+ * @deprecated No-op since 3.5.0 — removed together with `updating`.
49
+ * Will be removed in the next major version.
50
+ */
51
+ updatingLabel?: string;
55
52
  }
56
53
 
57
54
  /** Plain form: how many records the filters left, out of an optional total. */
@@ -141,8 +138,8 @@ function format(template: string, values: Record<string, number>): string {
141
138
 
142
139
  /**
143
140
  * The collection's count as a `role="status"` live region — one per
144
- * screen. Announces the new count once per change, "Updating results" once
145
- * per refetch, and the empty label (screen-reader only) at zero.
141
+ * screen. Announces the new count once per change, and the empty label
142
+ * (screen-reader only) at zero.
146
143
  */
147
144
  const ResultCount = React.forwardRef<HTMLParagraphElement, ResultCountProps>(
148
145
  (
@@ -153,17 +150,19 @@ const ResultCount = React.forwardRef<HTMLParagraphElement, ResultCountProps>(
153
150
  from,
154
151
  to,
155
152
  total,
156
- updating = false,
157
153
  label,
158
154
  labelOne,
159
155
  noTotalLabel,
160
156
  noTotalLabelOne,
161
157
  rangeLabel,
162
158
  rangeLabelOne,
163
- updatingLabel,
164
159
  emptyLabel,
165
160
  trackingEl,
166
161
  trackingLabel,
162
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars -- deprecated no-ops, absorbed to keep them off the DOM
163
+ updating,
164
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
165
+ updatingLabel,
167
166
  ...props
168
167
  },
169
168
  ref
@@ -199,10 +198,7 @@ const ResultCount = React.forwardRef<HTMLParagraphElement, ResultCountProps>(
199
198
  return (
200
199
  <p
201
200
  ref={ref}
202
- className={cn(
203
- "text-muted-foreground text-body-sm relative flex items-center gap-2",
204
- className
205
- )}
201
+ className={cn("text-muted-foreground text-body-sm relative", className)}
206
202
  data-hook={dataHook}
207
203
  data-slot="result-count"
208
204
  data-tracking-el={trackingEl ?? "result-count"}
@@ -210,37 +206,14 @@ const ResultCount = React.forwardRef<HTMLParagraphElement, ResultCountProps>(
210
206
  role="status"
211
207
  {...props}
212
208
  >
213
- {/* The accessibility contract is "Updating results, then the new
214
- count — once each", so while a refetch is in flight the live
215
- region's ENTIRE accessible text is the updating message. The
216
- previous count stays visible for continuity but is aria-hidden:
217
- leaving it in the announced text made a screen reader re-read the
218
- stale count with a suffix ("40 of 128 results Updating…")
219
- instead of the documented message. */}
220
- {updating ? (
221
- <>
222
- {!isEmpty && (
223
- <span aria-hidden="true" data-slot="result-count-text">
224
- {text}
225
- </span>
226
- )}
227
- <span
228
- className="inline-flex items-center gap-1.5"
229
- data-slot="result-count-updating"
230
- >
231
- {/* No loadingLabel: the spinner stays decorative
232
- (aria-hidden) — the region's text change is the one
233
- announcement. */}
234
- <Spinner size="sm" />
235
- {updatingLabel ?? "Updating results"}
236
- </span>
237
- </>
238
- ) : isEmpty ? (
209
+ {!isEmpty && <span data-slot="result-count-text">{text}</span>}
210
+
211
+ {/* Empty — sr-only label so the region still announces "No results"
212
+ while the visible empty state already says it. */}
213
+ {isEmpty && (
239
214
  <span className="sr-only" data-slot="result-count-empty">
240
215
  {emptyLabel ?? "No results"}
241
216
  </span>
242
- ) : (
243
- <span data-slot="result-count-text">{text}</span>
244
217
  )}
245
218
  </p>
246
219
  );
@@ -8,6 +8,7 @@ import { ChevronDown, ChevronUp, X } from "@brightlocal/icons";
8
8
  import { cn } from "@brightlocal/ui-components/lib/utils";
9
9
  import { Button } from "@brightlocal/ui-components/button";
10
10
  import { ScrollArea } from "@brightlocal/ui-components/scroll-area";
11
+ import { Spinner } from "@brightlocal/ui-components/spinner";
11
12
  import { useOverlayPointerLock } from "@brightlocal/ui-components/hooks/use-overlay-pointer-lock";
12
13
 
13
14
  /**
@@ -26,8 +27,10 @@ export type SheetSide = "top" | "right" | "bottom" | "left";
26
27
  * partly visible behind it on phones (used by the Sidebar mobile nav)
27
28
  * - lg: Panel fills 75% of the viewport up to 512px — detail panels with
28
29
  * dense content (date pickers, thumbnail rows)
30
+ * - xl: Full width on phones, 480px from the `sm` breakpoint and 640px from
31
+ * `xl` — edit forms with a table or a row of selects (DS-1245)
29
32
  */
30
- export type SheetSize = "default" | "sm" | "lg";
33
+ export type SheetSize = "default" | "sm" | "lg" | "xl";
31
34
 
32
35
  const sheetContentVariants = cva(
33
36
  [
@@ -90,6 +93,7 @@ const sheetContentVariants = cva(
90
93
  default: [],
91
94
  sm: [],
92
95
  lg: [],
96
+ xl: [],
93
97
  },
94
98
  },
95
99
  compoundVariants: [
@@ -119,6 +123,15 @@ const sheetContentVariants = cva(
119
123
  size: "lg",
120
124
  className: ["w-3/4", "sm:max-w-lg"],
121
125
  },
126
+ // xl side panels are the form width (DS-1245): full width on phones,
127
+ // where 75% is too narrow for fields, then two fixed steps on the DS
128
+ // breakpoints — 480px from sm, 640px from xl — so the panel does not
129
+ // shift as the window resizes.
130
+ {
131
+ side: ["left", "right"],
132
+ size: "xl",
133
+ className: ["w-full", "sm:w-120", "xl:w-160"],
134
+ },
122
135
  ],
123
136
  defaultVariants: {
124
137
  side: "right",
@@ -223,7 +236,8 @@ interface SheetContentProps
223
236
  /**
224
237
  * Width preset for side panels. `sm` hugs the content between 288 and
225
238
  * 320px; `default` keeps the classic 75%-up-to-384px drawer width; `lg`
226
- * widens to 75%-up-to-512px for dense detail panels.
239
+ * widens to 75%-up-to-512px for dense detail panels; `xl` is the form
240
+ * width — full width on phones, 480px from `sm`, 640px from `xl`.
227
241
  * Ignored for top/bottom sheets.
228
242
  * @default "default"
229
243
  */
@@ -367,6 +381,22 @@ interface SheetPaginationProps extends Omit<
367
381
  */
368
382
  renderPosition?:
369
383
  ((info: SheetPaginationPositionInfo) => React.ReactNode) | null;
384
+ /**
385
+ * Marks the step the user just requested as in flight — e.g. the next item
386
+ * sits on a page that is still being fetched. The button that requested
387
+ * the step (by click or arrow key) swaps its chevron for a spinner and sets
388
+ * `aria-busy`; both buttons ignore clicks and arrow keys until the flag
389
+ * clears, without a disabled look, so focus stays where it is. Screen
390
+ * readers hear `loadingLabel`. Keep `hasPrevious` / `hasNext` describing
391
+ * the list, not the fetch.
392
+ * @default false
393
+ */
394
+ loading?: boolean;
395
+ /**
396
+ * Text announced to screen readers while `loading` is true.
397
+ * @default "Loading item"
398
+ */
399
+ loadingLabel?: string;
370
400
  /**
371
401
  * Accessible label for the item navigation group.
372
402
  * @default "Item navigation"
@@ -414,6 +444,8 @@ const SheetPagination = React.forwardRef<HTMLDivElement, SheetPaginationProps>(
414
444
  hasPrevious,
415
445
  hasNext,
416
446
  renderPosition,
447
+ loading = false,
448
+ loadingLabel,
417
449
  ariaLabel,
418
450
  prevAriaLabel,
419
451
  nextAriaLabel,
@@ -433,11 +465,30 @@ const SheetPagination = React.forwardRef<HTMLDivElement, SheetPaginationProps>(
433
465
  // The button that just triggered a step. Set only by our own
434
466
  // navigation, consumed on the next commit.
435
467
  const pendingRef = React.useRef<HTMLButtonElement | null>(null);
468
+ // The direction of the last requested step — the button that owns the
469
+ // spinner while `loading` (an arrow key on Previous can request Next).
470
+ const [requested, setRequested] = React.useState<
471
+ "previous" | "next" | null
472
+ >(null);
473
+
474
+ // Once the step lands (the position or a boundary changes, or `loading`
475
+ // finishes), forget the requester so a later refetch raised from outside
476
+ // does not spin the old button. Adjusted during render, not in an effect.
477
+ const settleKey = `${loading}|${current}|${total}|${canPrevious}|${canNext}`;
478
+ const [prevSettleKey, setPrevSettleKey] = React.useState(settleKey);
479
+ if (settleKey !== prevSettleKey) {
480
+ setPrevSettleKey(settleKey);
481
+ if (!loading) setRequested(null);
482
+ }
436
483
 
437
484
  // Reaching a boundary disables the button that was just pressed, which
438
485
  // drops focus to <body>. Hand it to the sibling instead so keyboard users
439
- // stay in the control.
486
+ // stay in the control. While a step is loading the boundary is not known
487
+ // yet — keep the pending hand-off until it lands. Runs only when the
488
+ // position, a boundary or `loading` changes, so the render caused by
489
+ // recording a request does not consume the hand-off early.
440
490
  React.useEffect(() => {
491
+ if (loading) return;
441
492
  const pending = pendingRef.current;
442
493
  pendingRef.current = null;
443
494
  if (!pending) return;
@@ -448,7 +499,7 @@ const SheetPagination = React.forwardRef<HTMLDivElement, SheetPaginationProps>(
448
499
  } else if (!canNext && pending === nextRef.current && canPrevious) {
449
500
  prevRef.current?.focus();
450
501
  }
451
- });
502
+ }, [loading, current, total, canPrevious, canNext]);
452
503
 
453
504
  const handleBlur = (event: React.FocusEvent<HTMLButtonElement>) => {
454
505
  // Focus left on purpose (to anything but the sibling) — drop any
@@ -463,17 +514,26 @@ const SheetPagination = React.forwardRef<HTMLDivElement, SheetPaginationProps>(
463
514
  direction: "previous" | "next",
464
515
  trigger: HTMLButtonElement
465
516
  ) => {
517
+ // Inert while a step is in flight — prevents a double fetch.
518
+ if (loading) return;
466
519
  if (direction === "previous") {
467
520
  if (!canPrevious) return;
468
521
  pendingRef.current = trigger;
522
+ setRequested("previous");
469
523
  onPrevious();
470
524
  } else {
471
525
  if (!canNext) return;
472
526
  pendingRef.current = trigger;
527
+ setRequested("next");
473
528
  onNext();
474
529
  }
475
530
  };
476
531
 
532
+ // Without a recorded request (loading set from outside), no button gets
533
+ // the spinner — the status still announces busy and input is ignored.
534
+ const previousBusy = loading && requested === "previous";
535
+ const nextBusy = loading && requested === "next";
536
+
477
537
  const handleKeyDown = (event: React.KeyboardEvent<HTMLButtonElement>) => {
478
538
  if (event.key === "ArrowUp" || event.key === "ArrowLeft") {
479
539
  event.preventDefault();
@@ -496,8 +556,8 @@ const SheetPagination = React.forwardRef<HTMLDivElement, SheetPaginationProps>(
496
556
  ref={ref}
497
557
  aria-label={ariaLabel ?? "Item navigation"}
498
558
  // mb-2 on top of SheetContent's gap-4 gives the 24px Figma gap to
499
- // the header below.
500
- className={cn("mb-2 flex items-center gap-1", className)}
559
+ // the header below. `relative` anchors the sr-only status below.
560
+ className={cn("relative mb-2 flex items-center gap-1", className)}
501
561
  data-hook={dataHook}
502
562
  data-slot="sheet-pagination"
503
563
  data-tracking-el={trackingEl}
@@ -507,6 +567,7 @@ const SheetPagination = React.forwardRef<HTMLDivElement, SheetPaginationProps>(
507
567
  >
508
568
  <Button
509
569
  ref={prevRef}
570
+ aria-busy={previousBusy ? "true" : undefined}
510
571
  ariaLabel={prevAriaLabel ?? "Previous item"}
511
572
  dataHook={`${dataHook}-previous`}
512
573
  disabled={!canPrevious}
@@ -515,10 +576,15 @@ const SheetPagination = React.forwardRef<HTMLDivElement, SheetPaginationProps>(
515
576
  onClick={(event) => step("previous", event.currentTarget)}
516
577
  onKeyDown={handleKeyDown}
517
578
  >
518
- <ChevronUp />
579
+ {previousBusy ? (
580
+ <Spinner dataHook={`${dataHook}-previous-loading`} />
581
+ ) : (
582
+ <ChevronUp />
583
+ )}
519
584
  </Button>
520
585
  <Button
521
586
  ref={nextRef}
587
+ aria-busy={nextBusy ? "true" : undefined}
522
588
  ariaLabel={nextAriaLabel ?? "Next item"}
523
589
  dataHook={`${dataHook}-next`}
524
590
  disabled={!canNext}
@@ -527,7 +593,11 @@ const SheetPagination = React.forwardRef<HTMLDivElement, SheetPaginationProps>(
527
593
  onClick={(event) => step("next", event.currentTarget)}
528
594
  onKeyDown={handleKeyDown}
529
595
  >
530
- <ChevronDown />
596
+ {nextBusy ? (
597
+ <Spinner dataHook={`${dataHook}-next-loading`} />
598
+ ) : (
599
+ <ChevronDown />
600
+ )}
531
601
  </Button>
532
602
  {position != null && (
533
603
  <span
@@ -538,6 +608,14 @@ const SheetPagination = React.forwardRef<HTMLDivElement, SheetPaginationProps>(
538
608
  {position}
539
609
  </span>
540
610
  )}
611
+ {/* Always mounted so the announcement fires when loading starts. */}
612
+ <span
613
+ className="sr-only"
614
+ data-slot="sheet-pagination-status"
615
+ role="status"
616
+ >
617
+ {loading ? (loadingLabel ?? "Loading item") : null}
618
+ </span>
541
619
  </div>
542
620
  );
543
621
  }
@@ -23,7 +23,7 @@ import {
23
23
  InputGroupInput,
24
24
  } from "@brightlocal/ui-components/input-group";
25
25
  import { Label } from "@brightlocal/ui-components/label";
26
- import { EmptyChip } from "../lib/empty-chip";
26
+ import { EmptyState } from "../blocks/empty-state";
27
27
  import {
28
28
  RadioGroup,
29
29
  RadioGroupItem,
@@ -384,21 +384,14 @@ function SingleSelectFilterInner<Value extends string = string>({
384
384
  ) : null}
385
385
  <DrawerBody className="flex min-h-0 flex-1 flex-col gap-4 overflow-y-auto pt-1 pb-2">
386
386
  {searching && visibleOptions.length === 0 ? (
387
- <div
388
- className="text-body-sm flex flex-col items-center gap-1 py-6 text-center"
389
- data-hook={`${dataHook}-empty`}
390
- >
391
- <EmptyChip
392
- className="mb-1"
393
- dataHook={`${dataHook}-empty-icon`}
394
- icon={<SearchX />}
395
- slot="single-select-filter-empty-icon"
396
- />
397
- <p>{emptyLabel ?? "No options found."}</p>
398
- <p className="text-muted-foreground">
399
- {emptyDescription ?? "Try another search."}
400
- </p>
401
- </div>
387
+ <EmptyState
388
+ className="py-6"
389
+ dataHook={`${dataHook}-empty`}
390
+ description={emptyDescription ?? "Try another search."}
391
+ icon={<SearchX />}
392
+ size="sm"
393
+ title={emptyLabel ?? "No options found."}
394
+ />
402
395
  ) : (
403
396
  <RadioGroup
404
397
  className="grid grid-cols-2 gap-x-4 gap-y-3"
@@ -11,6 +11,7 @@ import {
11
11
  scrollRegionProps,
12
12
  type TableFrame,
13
13
  type TableSize,
14
+ useTableViewInlineSize,
14
15
  } from "../lib/table-internal";
15
16
 
16
17
  /* -------------------------------------------------------------------------------------------------
@@ -187,9 +188,14 @@ const Table = React.forwardRef<HTMLTableElement, TableProps>(
187
188
  ) => {
188
189
  const ownsScroll = scrollOwner === "self";
189
190
  const ownFrame = frame === "own";
191
+ // DS-1105: as the scroll container, publish the visible width TableEmpty
192
+ // caps its message at.
193
+ const wrapperRef = React.useRef<HTMLDivElement>(null);
194
+ useTableViewInlineSize(wrapperRef, ownsScroll);
190
195
  return (
191
196
  <TableSizeContext.Provider value={size}>
192
197
  <div
198
+ ref={wrapperRef}
193
199
  className={cn(
194
200
  "relative w-full",
195
201
  // `overflow-x-auto` makes the wrapper a scroll container in BOTH
@@ -568,7 +574,16 @@ const TableEmpty = React.forwardRef<HTMLTableRowElement, TableEmptyProps>(
568
574
  {/* Polite live region: the outcome of the reader's own query. */}
569
575
  <div
570
576
  aria-live="polite"
571
- className={cn(!isLine && "py-6")}
577
+ className={cn(
578
+ !isLine && "py-6",
579
+ // DS-1105: pinned to the visible part of a table that scrolls
580
+ // sideways. The scroll container publishes its visible width as
581
+ // `--table-view-inline-size` (useTableViewInlineSize); capped at
582
+ // it, this block is exactly one viewport wide, so its centred
583
+ // content sits in view at any scroll offset. Unset (nothing
584
+ // measuring) the cap is `none` — the plain full-width row.
585
+ "sticky left-0 max-w-(--table-view-inline-size,none)"
586
+ )}
572
587
  data-slot="table-empty-message"
573
588
  role="status"
574
589
  >