@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
@@ -10,7 +10,8 @@ import { Button } from "@brightlocal/ui-components/button";
10
10
  import { cn } from "@brightlocal/ui-components/lib/utils";
11
11
  import { useDevWarning } from "@brightlocal/ui-components/lib/use-dev-warning";
12
12
 
13
- import { EmptyChip } from "../lib/empty-chip";
13
+ import { EmptyState } from "../blocks/empty-state";
14
+ import { hasEmptyActions } from "../lib/empty-chip";
14
15
 
15
16
  /* -------------------------------------------------------------------------------------------------
16
17
  * Command Context — shared state between CommandInput and CommandVirtualList
@@ -197,12 +198,13 @@ const CommandInput = React.forwardRef<
197
198
 
198
199
  // cmdk sets aria-controls/aria-activedescendant internally after
199
200
  // spreading props, so we override via DOM to point at our virtual listbox.
201
+ // Only while a CommandVirtualList is mounted (it sets listboxId): with
202
+ // regular cmdk items the attributes are cmdk's, and removing them here
203
+ // after every render left the input without an active descendant.
200
204
  React.useEffect(() => {
201
205
  const el = inputRef.current;
202
- if (!el) return;
203
- if (listboxId) {
204
- el.setAttribute("aria-controls", listboxId);
205
- }
206
+ if (!el || !listboxId) return;
207
+ el.setAttribute("aria-controls", listboxId);
206
208
  if (activeDescendantId) {
207
209
  el.setAttribute("aria-activedescendant", activeDescendantId);
208
210
  } else {
@@ -323,8 +325,9 @@ CommandList.displayName = "CommandList";
323
325
  /**
324
326
  * Props for the CommandEmpty component
325
327
  */
326
- export interface CommandEmptyProps extends React.ComponentProps<
327
- typeof CommandPrimitive.Empty
328
+ export interface CommandEmptyProps extends Omit<
329
+ React.ComponentProps<typeof CommandPrimitive.Empty>,
330
+ "title"
328
331
  > {
329
332
  /**
330
333
  * Data hook for automated testing
@@ -336,6 +339,14 @@ export interface CommandEmptyProps extends React.ComponentProps<
336
339
  * (Patterns/Empty States). Decorative; the message carries the state.
337
340
  */
338
341
  icon?: React.ReactNode;
342
+ /**
343
+ * The message, e.g. “No locations match “{search}””. Pass it here when the
344
+ * empty state carries actions: `children` then become the actions row under
345
+ * the description, the same split as EmptyState. The line keeps the compact
346
+ * body-sm size; it is never a heading. Without `title`, `children` are the
347
+ * message.
348
+ */
349
+ title?: React.ReactNode;
339
350
  /**
340
351
  * One quiet muted line under the message, e.g. "Try a different search."
341
352
  */
@@ -345,7 +356,9 @@ export interface CommandEmptyProps extends React.ComponentProps<
345
356
  /**
346
357
  * Empty state displayed when no results are found. Plain `children` render
347
358
  * the one-line form; pass `icon` and/or `description` for the compact form
348
- * the Empty States pattern uses at popover scope — never hand-roll it.
359
+ * the Empty States pattern uses at popover scope — never hand-roll it. To
360
+ * offer an action (Add location), pass the message as `title` and the
361
+ * buttons as `children`, as in EmptyState.
349
362
  *
350
363
  * @example
351
364
  * ```tsx
@@ -355,57 +368,90 @@ export interface CommandEmptyProps extends React.ComponentProps<
355
368
  * >
356
369
  * No locations match “{search}”
357
370
  * </CommandEmpty>
371
+ *
372
+ * <CommandEmpty
373
+ * description="Check the spelling, or add it as a new location."
374
+ * icon={<SearchX />}
375
+ * title={`No locations match “${search}”`}
376
+ * >
377
+ * <Button dataHook="add-location" size="sm" variant="secondary">
378
+ * <Plus />
379
+ * Add location
380
+ * </Button>
381
+ * </CommandEmpty>
358
382
  * ```
359
383
  */
360
384
  const CommandEmpty = React.forwardRef<
361
385
  React.ComponentRef<typeof CommandPrimitive.Empty>,
362
386
  CommandEmptyProps
363
- >(({ children, dataHook, description, icon, ...props }, ref) => {
387
+ >(({ children, dataHook, description, icon, title, ...props }, ref) => {
388
+ const isCompact = Boolean(icon || description) || title !== undefined;
389
+ // With `title`, children are the actions; without it, they are the message.
390
+ const hasActions = title !== undefined && hasEmptyActions(children);
391
+ const fallbackTitleId = React.useId();
392
+
364
393
  // cmdk hardcodes role="presentation" after spreading props, so we
365
394
  // override it via a callback ref to satisfy the listbox a11y contract
366
- // (role="listbox" requires option or group children).
395
+ // (role="listbox" requires option or group children). An option's content
396
+ // is presentational and cannot hold a button, so with actions the empty
397
+ // state is a group, labelled by EmptyState's title line.
367
398
  const setRef = React.useCallback(
368
399
  (node: HTMLDivElement | null) => {
369
- node?.setAttribute("role", "option");
400
+ if (node) {
401
+ node.setAttribute("role", hasActions ? "group" : "option");
402
+ const titleNode = hasActions
403
+ ? node.querySelector<HTMLElement>('[data-slot="empty-state-title"]')
404
+ : null;
405
+ if (titleNode) {
406
+ if (!titleNode.id) titleNode.id = fallbackTitleId;
407
+ node.setAttribute("aria-labelledby", titleNode.id);
408
+ } else {
409
+ node.removeAttribute("aria-labelledby");
410
+ }
411
+ }
370
412
  if (typeof ref === "function") ref(node);
371
413
  else if (ref) ref.current = node;
372
414
  },
373
- [ref]
415
+ [ref, hasActions, fallbackTitleId]
374
416
  );
375
417
 
376
418
  return (
377
419
  <CommandPrimitive.Empty
378
420
  ref={setRef}
379
- aria-disabled="true"
380
- aria-selected="false"
421
+ {...(hasActions
422
+ ? {}
423
+ : { "aria-disabled": "true", "aria-selected": "false" })}
381
424
  className="text-body-sm py-6 text-center"
382
425
  data-hook={dataHook}
383
426
  data-slot="command-empty"
427
+ /* cmdk prevents the default of every Enter that reaches the Command
428
+ root, which would swallow an action button's keyboard click, so
429
+ Enter stops here. Only the actions inside can take focus. */
430
+ onKeyDown={
431
+ hasActions
432
+ ? (event) => {
433
+ if (event.key === "Enter") event.stopPropagation();
434
+ }
435
+ : undefined
436
+ }
384
437
  {...props}
385
438
  >
386
- {icon || description ? (
387
- /* The compact form. Inside role="option" the content is
388
- presentational, so the message stays a plain line — never a
389
- heading — and the chip is aria-hidden. */
390
- <div className="flex flex-col items-center gap-1 px-4">
391
- {icon ? (
392
- <EmptyChip
393
- className="mb-1"
394
- dataHook={`${dataHook}-icon`}
395
- icon={icon}
396
- slot="command-empty-icon"
397
- />
398
- ) : null}
399
- <p data-slot="command-empty-message">{children}</p>
400
- {description ? (
401
- <p
402
- className="text-muted-foreground"
403
- data-slot="command-empty-description"
404
- >
405
- {description}
406
- </p>
407
- ) : null}
408
- </div>
439
+ {isCompact ? (
440
+ /* The compact form is EmptyState at size sm — one empty block
441
+ across the DS (Patterns/Empty States). */
442
+ <EmptyState
443
+ className="px-4"
444
+ /* The parts derive their hooks from it (`-icon`, `-title`,
445
+ `-message`); the root's own hook stays on the cmdk wrapper. */
446
+ data-hook={undefined}
447
+ dataHook={dataHook ?? "command-empty"}
448
+ description={description}
449
+ icon={icon}
450
+ size="sm"
451
+ title={title === undefined ? children : title}
452
+ >
453
+ {hasActions ? children : null}
454
+ </EmptyState>
409
455
  ) : (
410
456
  children
411
457
  )}
@@ -0,0 +1,188 @@
1
+ "use client";
2
+
3
+ import * as React from "react";
4
+
5
+ import { cn } from "@brightlocal/ui-components/lib/utils";
6
+ import { useFieldAriaRegistration } from "../lib/field-aria";
7
+
8
+ /**
9
+ * Whether the count is within its limit.
10
+ * - `neutral`: at or under the limit. Exactly at the limit is the count the
11
+ * user is allowed to reach, so it is not highlighted.
12
+ * - `over`: above the limit
13
+ */
14
+ type CountIndicatorState = "neutral" | "over";
15
+
16
+ /**
17
+ * Screen reader copy for the count indicator. Every string is optional;
18
+ * pass translations through `labels`.
19
+ */
20
+ interface CountIndicatorLabels {
21
+ /**
22
+ * Spoken value, read together with the field when it gets focus.
23
+ * @default (count, limit) => `${count} of ${limit}`
24
+ */
25
+ value: (count: number, limit: number) => string;
26
+ /**
27
+ * Announced once when the count goes over the limit.
28
+ * @default (excess) => `${excess} over the limit`
29
+ */
30
+ over: (excess: number) => string;
31
+ }
32
+
33
+ const DEFAULT_LABELS: CountIndicatorLabels = {
34
+ value: (count, limit) => `${count} of ${limit}`,
35
+ over: (excess) => `${excess} over the limit`,
36
+ };
37
+
38
+ /** Resolves the state for a count against a limit. */
39
+ function getCountState(count: number, limit: number): CountIndicatorState {
40
+ return count > limit ? "over" : "neutral";
41
+ }
42
+
43
+ interface CountIndicatorProps extends Omit<
44
+ React.HTMLAttributes<HTMLSpanElement>,
45
+ "children"
46
+ > {
47
+ /**
48
+ * Data hook for automated testing (REQUIRED)
49
+ * @example "description-count"
50
+ */
51
+ dataHook: string;
52
+ /**
53
+ * Current count: characters typed, or items added.
54
+ */
55
+ count: number;
56
+ /**
57
+ * Largest allowed count.
58
+ */
59
+ limit: number;
60
+ /**
61
+ * Screen reader copy. Pass translations here; omitted entries use English.
62
+ */
63
+ labels?: Partial<CountIndicatorLabels>;
64
+ /**
65
+ * Set to `false` while the count is not known yet (for example before a
66
+ * field has been read from the DOM). The first count after that becomes the
67
+ * silent starting point, so a saved value that is already over the limit is
68
+ * not announced.
69
+ * @default true
70
+ */
71
+ ready?: boolean;
72
+ /**
73
+ * Optional tracking prop for analytics tracking element identifier
74
+ */
75
+ trackingEl?: string;
76
+ /**
77
+ * Optional tracking prop for analytics tracking label
78
+ */
79
+ trackingLabel?: string;
80
+ }
81
+
82
+ /**
83
+ * A small count against a limit, such as `120 / 750`.
84
+ *
85
+ * It is the shared count for text fields: `Textarea` shows it with `limit`,
86
+ * `InputGroupCount` and `InputChipCount` place it inside an input group or a
87
+ * chip field. Use it directly only to build another field that needs it.
88
+ *
89
+ * The count never blocks typing. Over the limit it turns red, and the field
90
+ * around it gets the error border; the consumer shows the error message and
91
+ * stops the save.
92
+ *
93
+ * Screen readers hear the value with the field (`aria-describedby`, wired
94
+ * automatically inside a `Field`). A polite live region speaks only when the
95
+ * state changes, never on each keystroke.
96
+ *
97
+ * @example
98
+ * ```tsx
99
+ * <CountIndicator dataHook="alt-count" count={alt.length} limit={125} />
100
+ * ```
101
+ */
102
+ const CountIndicator = React.forwardRef<HTMLSpanElement, CountIndicatorProps>(
103
+ (
104
+ {
105
+ className,
106
+ dataHook,
107
+ count,
108
+ limit,
109
+ labels,
110
+ ready = true,
111
+ id,
112
+ trackingEl,
113
+ trackingLabel,
114
+ ...props
115
+ },
116
+ ref
117
+ ) => {
118
+ const generatedId = React.useId();
119
+ const indicatorId = id ?? generatedId;
120
+ const copy = { ...DEFAULT_LABELS, ...labels };
121
+ const state = getCountState(count, limit);
122
+
123
+ // Inside a Field, the control's aria-describedby picks this id up.
124
+ useFieldAriaRegistration("count", indicatorId, true);
125
+
126
+ // Speak only when the state changes. The first render stays silent, so a
127
+ // saved value that is already over the limit is not announced on load.
128
+ const [announced, setAnnounced] = React.useState({
129
+ state,
130
+ text: "",
131
+ seeded: ready,
132
+ });
133
+ if (!ready) {
134
+ if (announced.seeded) setAnnounced({ state, text: "", seeded: false });
135
+ } else if (!announced.seeded) {
136
+ // First known count: the starting point, never an announcement
137
+ setAnnounced({ state, text: "", seeded: true });
138
+ } else if (announced.state !== state) {
139
+ setAnnounced({
140
+ state,
141
+ text: state === "over" ? copy.over(count - limit) : "",
142
+ seeded: true,
143
+ });
144
+ }
145
+ const announcement = announced.text;
146
+
147
+ return (
148
+ <>
149
+ <span
150
+ ref={ref}
151
+ className={cn(
152
+ "text-body-xs shrink-0 tabular-nums",
153
+ state === "neutral" && "text-muted-foreground",
154
+ state === "over" && "text-destructive-foreground",
155
+ className
156
+ )}
157
+ data-hook={dataHook}
158
+ data-slot="count-indicator"
159
+ data-state={state}
160
+ data-tracking-el={trackingEl}
161
+ data-tracking-label={trackingLabel}
162
+ id={indicatorId}
163
+ {...props}
164
+ >
165
+ <span aria-hidden="true">
166
+ {count} / {limit}
167
+ </span>
168
+ <span className="sr-only">{copy.value(count, limit)}</span>
169
+ </span>
170
+ <span
171
+ aria-atomic="true"
172
+ aria-live="polite"
173
+ className="sr-only"
174
+ data-slot="count-indicator-announcer"
175
+ role="status"
176
+ >
177
+ {announcement}
178
+ </span>
179
+ </>
180
+ );
181
+ }
182
+ );
183
+
184
+ CountIndicator.displayName = "CountIndicator";
185
+
186
+ export { CountIndicator, getCountState };
187
+
188
+ export type { CountIndicatorLabels, CountIndicatorProps, CountIndicatorState };