@brightlocal/ui-components 3.0.0 → 3.1.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 (105) hide show
  1. package/README.md +2 -1
  2. package/component-meta.json +90 -19
  3. package/deprecations.json +113 -3
  4. package/dist/accordion.cjs +1 -1
  5. package/dist/accordion.d.ts +36 -0
  6. package/dist/accordion.d.ts.map +1 -1
  7. package/dist/accordion.js +74 -61
  8. package/dist/blocks/empty-state.cjs +1 -1
  9. package/dist/blocks/empty-state.d.ts.map +1 -1
  10. package/dist/blocks/empty-state.js +41 -49
  11. package/dist/button-group.cjs +1 -0
  12. package/dist/button-group.d.ts +36 -0
  13. package/dist/button-group.d.ts.map +1 -0
  14. package/dist/button-group.js +47 -0
  15. package/dist/button.cjs +1 -1
  16. package/dist/button.js +1 -1
  17. package/dist/card.cjs +1 -1
  18. package/dist/card.d.ts +20 -2
  19. package/dist/card.d.ts.map +1 -1
  20. package/dist/card.js +83 -75
  21. package/dist/chart.cjs +2 -2
  22. package/dist/chart.d.ts +40 -12
  23. package/dist/chart.d.ts.map +1 -1
  24. package/dist/chart.js +86 -71
  25. package/dist/chip.cjs +1 -1
  26. package/dist/chip.d.ts +38 -4
  27. package/dist/chip.d.ts.map +1 -1
  28. package/dist/chip.js +95 -81
  29. package/dist/command.cjs +1 -1
  30. package/dist/command.d.ts +23 -1
  31. package/dist/command.d.ts.map +1 -1
  32. package/dist/command.js +250 -224
  33. package/dist/data-table.cjs +1 -1
  34. package/dist/data-table.d.ts +32 -1
  35. package/dist/data-table.d.ts.map +1 -1
  36. package/dist/data-table.js +340 -330
  37. package/dist/date-picker.cjs +1 -1
  38. package/dist/date-picker.d.ts +13 -5
  39. package/dist/date-picker.d.ts.map +1 -1
  40. package/dist/date-picker.js +54 -53
  41. package/dist/field.cjs +1 -1
  42. package/dist/field.d.ts +8 -1
  43. package/dist/field.d.ts.map +1 -1
  44. package/dist/field.js +79 -52
  45. package/dist/global-layout.cjs +1 -1
  46. package/dist/global-layout.d.ts +105 -13
  47. package/dist/global-layout.d.ts.map +1 -1
  48. package/dist/global-layout.js +146 -129
  49. package/dist/grid.d.ts +2 -2
  50. package/dist/hooks/use-mobile.cjs +1 -0
  51. package/dist/hooks/use-mobile.js +8 -0
  52. package/dist/index.cjs +1 -1
  53. package/dist/index.d.ts +1 -0
  54. package/dist/index.d.ts.map +1 -1
  55. package/dist/index.js +547 -538
  56. package/dist/input-password.cjs +1 -1
  57. package/dist/input-password.d.ts +17 -9
  58. package/dist/input-password.d.ts.map +1 -1
  59. package/dist/input-password.js +26 -25
  60. package/dist/lib/empty-chip.cjs +1 -0
  61. package/dist/lib/empty-chip.d.ts +4 -0
  62. package/dist/lib/empty-chip.d.ts.map +1 -0
  63. package/dist/lib/empty-chip.js +13 -0
  64. package/dist/pagination.cjs +1 -1
  65. package/dist/pagination.d.ts +3 -0
  66. package/dist/pagination.d.ts.map +1 -1
  67. package/dist/pagination.js +57 -57
  68. package/dist/scroll-area.cjs +1 -1
  69. package/dist/scroll-area.d.ts +15 -6
  70. package/dist/scroll-area.d.ts.map +1 -1
  71. package/dist/scroll-area.js +38 -36
  72. package/dist/select.cjs +2 -2
  73. package/dist/select.d.ts +13 -2
  74. package/dist/select.d.ts.map +1 -1
  75. package/dist/select.js +87 -83
  76. package/dist/typography-heading.cjs +1 -1
  77. package/dist/typography-heading.d.ts +13 -0
  78. package/dist/typography-heading.d.ts.map +1 -1
  79. package/dist/typography-heading.js +32 -21
  80. package/dist/typography-text.cjs +1 -1
  81. package/dist/typography-text.d.ts +14 -0
  82. package/dist/typography-text.d.ts.map +1 -1
  83. package/dist/typography-text.js +35 -24
  84. package/package.json +1 -1
  85. package/src/blocks/empty-state.tsx +9 -21
  86. package/src/components/accordion.tsx +82 -27
  87. package/src/components/button-group.tsx +112 -0
  88. package/src/components/button.tsx +1 -1
  89. package/src/components/card.tsx +38 -3
  90. package/src/components/chart.tsx +63 -18
  91. package/src/components/chip.tsx +83 -10
  92. package/src/components/command.tsx +55 -3
  93. package/src/components/data-table.tsx +67 -7
  94. package/src/components/date-picker.tsx +18 -7
  95. package/src/components/field.tsx +81 -12
  96. package/src/components/global-layout.tsx +176 -38
  97. package/src/components/grid.tsx +2 -2
  98. package/src/components/input-password.tsx +23 -11
  99. package/src/components/pagination.tsx +10 -3
  100. package/src/components/scroll-area.tsx +23 -10
  101. package/src/components/select.tsx +30 -6
  102. package/src/components/typography-heading.tsx +24 -0
  103. package/src/components/typography-text.tsx +26 -1
  104. package/src/index.ts +1 -0
  105. package/src/lib/empty-chip.ts +24 -0
@@ -66,8 +66,10 @@ const ScrollArea = React.forwardRef<
66
66
  >
67
67
  {children}
68
68
  </ScrollAreaPrimitive.Viewport>
69
- <ScrollBar />
70
- {scrollOrientation === "both" && <ScrollBar orientation="horizontal" />}
69
+ <ScrollAreaScrollbar />
70
+ {scrollOrientation === "both" && (
71
+ <ScrollAreaScrollbar orientation="horizontal" />
72
+ )}
71
73
  <ScrollAreaPrimitive.Corner />
72
74
  </ScrollAreaPrimitive.Root>
73
75
  );
@@ -77,9 +79,9 @@ const ScrollArea = React.forwardRef<
77
79
  ScrollArea.displayName = "ScrollArea";
78
80
 
79
81
  /**
80
- * Props for the ScrollBar component.
82
+ * Props for the ScrollAreaScrollbar component.
81
83
  */
82
- interface ScrollBarProps extends React.ComponentProps<
84
+ interface ScrollAreaScrollbarProps extends React.ComponentProps<
83
85
  typeof ScrollAreaPrimitive.ScrollAreaScrollbar
84
86
  > {
85
87
  /**
@@ -102,11 +104,11 @@ interface ScrollBarProps extends React.ComponentProps<
102
104
  }
103
105
 
104
106
  /**
105
- * ScrollBar provides a styled scrollbar for ScrollArea.
107
+ * ScrollAreaScrollbar provides a styled scrollbar for ScrollArea.
106
108
  */
107
- const ScrollBar = React.forwardRef<
109
+ const ScrollAreaScrollbar = React.forwardRef<
108
110
  React.ComponentRef<typeof ScrollAreaPrimitive.ScrollAreaScrollbar>,
109
- ScrollBarProps
111
+ ScrollAreaScrollbarProps
110
112
  >(
111
113
  (
112
114
  {
@@ -146,8 +148,19 @@ const ScrollBar = React.forwardRef<
146
148
  }
147
149
  );
148
150
 
149
- ScrollBar.displayName = "ScrollBar";
151
+ ScrollAreaScrollbar.displayName = "ScrollAreaScrollbar";
152
+
153
+ /**
154
+ * @deprecated Use `ScrollAreaScrollbar` instead — family parts carry the
155
+ * `ScrollArea` family prefix (DS-853).
156
+ */
157
+ const ScrollBar = ScrollAreaScrollbar;
158
+
159
+ /**
160
+ * @deprecated Use `ScrollAreaScrollbarProps` instead (DS-853).
161
+ */
162
+ type ScrollBarProps = ScrollAreaScrollbarProps;
150
163
 
151
- export { ScrollArea, ScrollBar };
164
+ export { ScrollArea, ScrollAreaScrollbar, ScrollBar };
152
165
 
153
- export type { ScrollAreaProps, ScrollBarProps };
166
+ export type { ScrollAreaProps, ScrollAreaScrollbarProps, ScrollBarProps };
@@ -403,11 +403,21 @@ SelectLabel.displayName = "SelectLabel";
403
403
  * </div>
404
404
  * </SelectItem>
405
405
  */
406
- function SelectItem({
407
- className,
408
- children,
409
- ...props
410
- }: React.ComponentProps<typeof SelectPrimitive.Item>) {
406
+ /**
407
+ * Props for the SelectItem component.
408
+ */
409
+ interface SelectItemProps extends React.ComponentProps<
410
+ typeof SelectPrimitive.Item
411
+ > {
412
+ /**
413
+ * Secondary hint rendered after the item label (e.g. "Latest").
414
+ * Rendered outside the item's text value, so it shows in the open list
415
+ * but never leaks into the trigger's selected-value rendering.
416
+ */
417
+ hint?: React.ReactNode;
418
+ }
419
+
420
+ function SelectItem({ className, children, hint, ...props }: SelectItemProps) {
411
421
  const itemStyles = cn(
412
422
  // Base layout
413
423
  "relative flex w-full cursor-default select-none items-center gap-2",
@@ -441,6 +451,15 @@ function SelectItem({
441
451
  </span>
442
452
 
443
453
  <SelectPrimitive.ItemText>{children}</SelectPrimitive.ItemText>
454
+
455
+ {hint != null && (
456
+ <span
457
+ className="text-label-sm text-muted-foreground ml-auto"
458
+ data-slot="select-item-hint"
459
+ >
460
+ {hint}
461
+ </span>
462
+ )}
444
463
  </SelectPrimitive.Item>
445
464
  );
446
465
  }
@@ -524,4 +543,9 @@ export {
524
543
  SelectValue,
525
544
  };
526
545
 
527
- export type { SelectContentProps, SelectProps, SelectTriggerProps };
546
+ export type {
547
+ SelectContentProps,
548
+ SelectItemProps,
549
+ SelectProps,
550
+ SelectTriggerProps,
551
+ };
@@ -74,6 +74,15 @@ const typographyHeadingVariants = cva("", {
74
74
  true: "tabular-nums",
75
75
  false: "proportional-nums",
76
76
  },
77
+ // Boolean on purpose (no `false` class): unlike tabular there is no
78
+ // inherited context to undo — either the element clips or it doesn't.
79
+ // `block` is load-bearing: an inline asChild child (e.g. a `span`) cannot
80
+ // clip — overflow does not apply to non-replaced inlines — so the variant
81
+ // forces a block container. A no-op on the default h1–h6 (already block)
82
+ // and on flex/grid items (blockified by the layout).
83
+ truncate: {
84
+ true: "block truncate",
85
+ },
77
86
  },
78
87
  defaultVariants: {
79
88
  color: "default",
@@ -140,6 +149,19 @@ interface TypographyHeadingProps extends React.ComponentProps<"h1"> {
140
149
  * TypographyText `metric` (plus `tabular` if it must align), not a heading.
141
150
  */
142
151
  tabular?: boolean;
152
+ /**
153
+ * Clip overflowing text to a single line with an ellipsis — card titles in
154
+ * a fixed-width grid, panel headers beside actions; anywhere a title can
155
+ * outgrow its container. The surrounding layout must still allow the
156
+ * element to shrink: inside a flex row the element (or its wrapper) needs
157
+ * `min-w-0`, and in a grid column `minmax(0, …)` — otherwise the box grows
158
+ * instead of clipping. Forces `display: block` (an inline box cannot
159
+ * clip), so an inline `asChild` child becomes a block while truncating —
160
+ * a no-op on the default h1–h6. Single-line only by design; a multi-line
161
+ * clamp can follow if demand appears.
162
+ * @default false
163
+ */
164
+ truncate?: boolean;
143
165
  /**
144
166
  * Render as a different element using Radix Slot pattern.
145
167
  * When true, merges props onto the child element.
@@ -186,6 +208,7 @@ const TypographyHeading = React.forwardRef<
186
208
  color = "default",
187
209
  align,
188
210
  tabular,
211
+ truncate = false,
189
212
  asChild = false,
190
213
  dataHook,
191
214
  trackingEl,
@@ -205,6 +228,7 @@ const TypographyHeading = React.forwardRef<
205
228
  color,
206
229
  align,
207
230
  tabular,
231
+ truncate,
208
232
  }),
209
233
  className
210
234
  )}
@@ -67,6 +67,16 @@ const typographyTextVariants = cva("", {
67
67
  center: "text-center",
68
68
  right: "text-right",
69
69
  },
70
+ // Boolean on purpose (no `false` class): unlike tabular there is no
71
+ // inherited context to undo — either the element clips or it doesn't.
72
+ // `block` is load-bearing: an inline box (the default `span` for metric,
73
+ // `code` for code, or an inline asChild child) cannot clip — overflow
74
+ // does not apply to non-replaced inlines — so the variant forces a block
75
+ // container. A no-op on the body variants (`p` is already block) and on
76
+ // flex/grid items (blockified by the layout).
77
+ truncate: {
78
+ true: "block truncate",
79
+ },
70
80
  },
71
81
  defaultVariants: {
72
82
  variant: "body",
@@ -125,6 +135,20 @@ interface TypographyTextProps extends React.HTMLAttributes<HTMLElement> {
125
135
  * @example "center"
126
136
  */
127
137
  align?: TypographyTextAlign;
138
+ /**
139
+ * Clip overflowing text to a single line with an ellipsis — table cells,
140
+ * list rows, dropdown options; anywhere text can outgrow its container.
141
+ * The surrounding layout must still allow the element to shrink: inside a
142
+ * flex row the element (or its wrapper) needs `min-w-0`, and in a grid
143
+ * column `minmax(0, …)` — otherwise the box grows instead of clipping.
144
+ * Forces `display: block` (an inline box cannot clip), so an inline
145
+ * default element (`metric`'s span, `code`'s code) or an inline `asChild`
146
+ * child becomes a block while truncating.
147
+ * Single-line only by design; a multi-line clamp can follow if demand
148
+ * appears.
149
+ * @default false
150
+ */
151
+ truncate?: boolean;
128
152
  /**
129
153
  * Render as a different element using Radix Slot pattern.
130
154
  * When true, merges props onto the child element.
@@ -176,6 +200,7 @@ const TypographyText = React.forwardRef<HTMLElement, TypographyTextProps>(
176
200
  color = "default",
177
201
  tabular,
178
202
  align,
203
+ truncate = false,
179
204
  asChild = false,
180
205
  dataHook,
181
206
  trackingEl,
@@ -202,7 +227,7 @@ const TypographyText = React.forwardRef<HTMLElement, TypographyTextProps>(
202
227
  <Comp
203
228
  ref={ref}
204
229
  className={cn(
205
- typographyTextVariants({ variant, color, tabular, align }),
230
+ typographyTextVariants({ variant, color, tabular, align, truncate }),
206
231
  className
207
232
  )}
208
233
  data-hook={dataHook}
package/src/index.ts CHANGED
@@ -8,6 +8,7 @@ export * from "./components/badge";
8
8
  export * from "./components/brand-illustration-motif";
9
9
  export * from "./components/breadcrumb";
10
10
  export * from "./components/button";
11
+ export * from "./components/button-group";
11
12
  export * from "./components/calendar";
12
13
  export * from "./components/callout";
13
14
  export * from "./components/card";
@@ -0,0 +1,24 @@
1
+ import { cva } from "class-variance-authority";
2
+
3
+ /* -------------------------------------------------------------------------------------------------
4
+ * Empty chip (internal)
5
+ *
6
+ * The icon chip every "nothing here" moment shares — EmptyState at card
7
+ * scope, and CommandEmpty / ComboboxEmpty at popover scope. 40px of
8
+ * `bg-muted` around a 16px glyph. It lives once so the two cannot drift: the
9
+ * popover form used to be hand-rolled in consumer code with these classes
10
+ * copied in.
11
+ *
12
+ * A canvas drops the chip — but a canvas is a different component, so there
13
+ * is no variant for that here.
14
+ * -----------------------------------------------------------------------------------------------*/
15
+
16
+ export const emptyChipStyles = cva(
17
+ "bg-muted text-muted-foreground flex size-10 items-center justify-center rounded-full",
18
+ {
19
+ variants: {
20
+ align: { center: "", left: "shrink-0" },
21
+ },
22
+ defaultVariants: { align: "center" },
23
+ }
24
+ );