@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
@@ -1,9 +1,9 @@
1
1
  import { jsx as m } from "react/jsx-runtime";
2
- import * as f from "react";
3
- import { Slot as h } from "@radix-ui/react-slot";
4
- import { cva as y } from "class-variance-authority";
5
- import { cn as x } from "@brightlocal/ui-components/lib/utils";
6
- const b = y("", {
2
+ import * as h from "react";
3
+ import { Slot as y } from "@radix-ui/react-slot";
4
+ import { cva as x } from "class-variance-authority";
5
+ import { cn as b } from "@brightlocal/ui-components/lib/utils";
6
+ const v = x("", {
7
7
  variants: {
8
8
  variant: {
9
9
  display: "text-display",
@@ -29,19 +29,28 @@ const b = y("", {
29
29
  tabular: {
30
30
  true: "tabular-nums",
31
31
  false: "proportional-nums"
32
+ },
33
+ // Boolean on purpose (no `false` class): unlike tabular there is no
34
+ // inherited context to undo — either the element clips or it doesn't.
35
+ // `block` is load-bearing: an inline asChild child (e.g. a `span`) cannot
36
+ // clip — overflow does not apply to non-replaced inlines — so the variant
37
+ // forces a block container. A no-op on the default h1–h6 (already block)
38
+ // and on flex/grid items (blockified by the layout).
39
+ truncate: {
40
+ true: "block truncate"
32
41
  }
33
42
  },
34
43
  defaultVariants: {
35
44
  color: "default"
36
45
  }
37
- }), v = {
46
+ }), k = {
38
47
  1: "page",
39
48
  2: "section",
40
49
  3: "subsection",
41
50
  4: "subsection",
42
51
  5: "subsection",
43
52
  6: "subsection"
44
- }, V = f.forwardRef(
53
+ }, V = h.forwardRef(
45
54
  ({
46
55
  className: e,
47
56
  level: t,
@@ -49,30 +58,32 @@ const b = y("", {
49
58
  color: r = "default",
50
59
  align: n,
51
60
  tabular: i,
52
- asChild: s = !1,
53
- dataHook: c,
54
- trackingEl: d,
55
- trackingLabel: p,
61
+ truncate: s = !1,
62
+ asChild: c = !1,
63
+ dataHook: d,
64
+ trackingEl: p,
65
+ trackingLabel: l,
56
66
  ...g
57
- }, l) => {
58
- const a = o ?? v[t], u = s ? h : `h${t}`;
67
+ }, u) => {
68
+ const a = o ?? k[t], f = c ? y : `h${t}`;
59
69
  return /* @__PURE__ */ m(
60
- u,
70
+ f,
61
71
  {
62
- ref: l,
63
- className: x(
64
- b({
72
+ ref: u,
73
+ className: b(
74
+ v({
65
75
  variant: a,
66
76
  color: r,
67
77
  align: n,
68
- tabular: i
78
+ tabular: i,
79
+ truncate: s
69
80
  }),
70
81
  e
71
82
  ),
72
- "data-hook": c,
83
+ "data-hook": d,
73
84
  "data-slot": "typography-heading",
74
- "data-tracking-el": d || `typography-heading-${a}`,
75
- "data-tracking-label": p,
85
+ "data-tracking-el": p || `typography-heading-${a}`,
86
+ "data-tracking-label": l,
76
87
  ...g
77
88
  }
78
89
  );
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const p=require("react/jsx-runtime"),f=require("react"),b=require("@radix-ui/react-slot"),x=require("class-variance-authority"),g=require("@brightlocal/ui-components/lib/utils");function m(t){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const r in t)if(r!=="default"){const o=Object.getOwnPropertyDescriptor(t,r);Object.defineProperty(e,r,o.get?o:{enumerable:!0,get:()=>t[r]})}}return e.default=t,Object.freeze(e)}const h=m(f),T=x.cva("",{variants:{variant:{body:"text-body","body-sm":"text-body-sm","body-xs":"text-body-xs",metric:"text-metric",code:"text-code"},color:{default:"text-foreground",muted:"text-muted-foreground",destructive:"text-destructive-foreground"},tabular:{true:"tabular-nums",false:"proportional-nums"},align:{left:"text-left",center:"text-center",right:"text-right"}},defaultVariants:{variant:"body",color:"default"}}),j={body:"p","body-sm":"p","body-xs":"p",metric:"span",code:"code"},a=h.forwardRef(({className:t,variant:e="body",color:r="default",tabular:o,align:n,asChild:c=!1,dataHook:s,trackingEl:d,trackingLabel:u,...l},i)=>{const y=c?b.Slot:j[e];return p.jsx(y,{ref:i,className:g.cn(T({variant:e,color:r,tabular:o,align:n}),t),"data-hook":s,"data-slot":"typography-text","data-tracking-el":d||`typography-text-${e}`,"data-tracking-label":u,...l})});a.displayName="TypographyText";exports.TypographyText=a;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const f=require("react/jsx-runtime"),b=require("react"),x=require("@radix-ui/react-slot"),g=require("class-variance-authority"),m=require("@brightlocal/ui-components/lib/utils");function h(t){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const r in t)if(r!=="default"){const o=Object.getOwnPropertyDescriptor(t,r);Object.defineProperty(e,r,o.get?o:{enumerable:!0,get:()=>t[r]})}}return e.default=t,Object.freeze(e)}const T=h(b),j=g.cva("",{variants:{variant:{body:"text-body","body-sm":"text-body-sm","body-xs":"text-body-xs",metric:"text-metric",code:"text-code"},color:{default:"text-foreground",muted:"text-muted-foreground",destructive:"text-destructive-foreground"},tabular:{true:"tabular-nums",false:"proportional-nums"},align:{left:"text-left",center:"text-center",right:"text-right"},truncate:{true:"block truncate"}},defaultVariants:{variant:"body",color:"default"}}),v={body:"p","body-sm":"p","body-xs":"p",metric:"span",code:"code"},a=T.forwardRef(({className:t,variant:e="body",color:r="default",tabular:o,align:c,truncate:n=!1,asChild:s=!1,dataHook:u,trackingEl:d,trackingLabel:l,...i},y)=>{const p=s?x.Slot:v[e];return f.jsx(p,{ref:y,className:m.cn(j({variant:e,color:r,tabular:o,align:c,truncate:n}),t),"data-hook":u,"data-slot":"typography-text","data-tracking-el":d||`typography-text-${e}`,"data-tracking-label":l,...i})});a.displayName="TypographyText";exports.TypographyText=a;
@@ -65,6 +65,20 @@ interface TypographyTextProps extends React.HTMLAttributes<HTMLElement> {
65
65
  * @example "center"
66
66
  */
67
67
  align?: TypographyTextAlign;
68
+ /**
69
+ * Clip overflowing text to a single line with an ellipsis — table cells,
70
+ * list rows, dropdown options; anywhere text can outgrow its container.
71
+ * The surrounding layout must still allow the element to shrink: inside a
72
+ * flex row the element (or its wrapper) needs `min-w-0`, and in a grid
73
+ * column `minmax(0, …)` — otherwise the box grows instead of clipping.
74
+ * Forces `display: block` (an inline box cannot clip), so an inline
75
+ * default element (`metric`'s span, `code`'s code) or an inline `asChild`
76
+ * child becomes a block while truncating.
77
+ * Single-line only by design; a multi-line clamp can follow if demand
78
+ * appears.
79
+ * @default false
80
+ */
81
+ truncate?: boolean;
68
82
  /**
69
83
  * Render as a different element using Radix Slot pattern.
70
84
  * When true, merges props onto the child element.
@@ -1 +1 @@
1
- {"version":3,"file":"typography-text.d.ts","sourceRoot":"","sources":["../../src/components/typography-text.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAM/B;;;;;;;;;;;;;;;;GAgBG;AACH,KAAK,qBAAqB,GAAG,MAAM,GAAG,SAAS,GAAG,SAAS,GAAG,QAAQ,GAAG,MAAM,CAAC;AAEhF;;GAEG;AACH,KAAK,mBAAmB,GAAG,MAAM,GAAG,QAAQ,GAAG,OAAO,CAAC;AAEvD;;;;;;GAMG;AACH,KAAK,mBAAmB,GAAG,SAAS,GAAG,OAAO,GAAG,aAAa,CAAC;AAsD/D;;;GAGG;AACH,UAAU,mBAAoB,SAAQ,KAAK,CAAC,cAAc,CAAC,WAAW,CAAC;IACrE;;;;OAIG;IACH,OAAO,CAAC,EAAE,qBAAqB,CAAC;IAChC;;;;;;OAMG;IACH,KAAK,CAAC,EAAE,mBAAmB,CAAC;IAC5B;;;;;;;;;OASG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB;;;;OAIG;IACH,KAAK,CAAC,EAAE,mBAAmB,CAAC;IAC5B;;;;OAIG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB;;;;OAIG;IACH,QAAQ,EAAE,MAAM,CAAC;IACjB;;;OAGG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;OAEG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,QAAA,MAAM,cAAc,yFA6CnB,CAAC;AAGF,OAAO,EAAE,cAAc,EAAE,CAAC;AAC1B,YAAY,EACV,mBAAmB,EACnB,qBAAqB,EACrB,mBAAmB,EACnB,mBAAmB,GACpB,CAAC"}
1
+ {"version":3,"file":"typography-text.d.ts","sourceRoot":"","sources":["../../src/components/typography-text.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAM/B;;;;;;;;;;;;;;;;GAgBG;AACH,KAAK,qBAAqB,GAAG,MAAM,GAAG,SAAS,GAAG,SAAS,GAAG,QAAQ,GAAG,MAAM,CAAC;AAEhF;;GAEG;AACH,KAAK,mBAAmB,GAAG,MAAM,GAAG,QAAQ,GAAG,OAAO,CAAC;AAEvD;;;;;;GAMG;AACH,KAAK,mBAAmB,GAAG,SAAS,GAAG,OAAO,GAAG,aAAa,CAAC;AAgE/D;;;GAGG;AACH,UAAU,mBAAoB,SAAQ,KAAK,CAAC,cAAc,CAAC,WAAW,CAAC;IACrE;;;;OAIG;IACH,OAAO,CAAC,EAAE,qBAAqB,CAAC;IAChC;;;;;;OAMG;IACH,KAAK,CAAC,EAAE,mBAAmB,CAAC;IAC5B;;;;;;;;;OASG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB;;;;OAIG;IACH,KAAK,CAAC,EAAE,mBAAmB,CAAC;IAC5B;;;;;;;;;;;;OAYG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB;;;;OAIG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB;;;;OAIG;IACH,QAAQ,EAAE,MAAM,CAAC;IACjB;;;OAGG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;OAEG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,QAAA,MAAM,cAAc,yFA8CnB,CAAC;AAGF,OAAO,EAAE,cAAc,EAAE,CAAC;AAC1B,YAAY,EACV,mBAAmB,EACnB,qBAAqB,EACrB,mBAAmB,EACnB,mBAAmB,GACpB,CAAC"}
@@ -1,9 +1,9 @@
1
- import { jsx as y } from "react/jsx-runtime";
2
- import * as i from "react";
1
+ import { jsx as i } from "react/jsx-runtime";
2
+ import * as u from "react";
3
3
  import { Slot as x } from "@radix-ui/react-slot";
4
4
  import { cva as f } from "class-variance-authority";
5
- import { cn as u } from "@brightlocal/ui-components/lib/utils";
6
- const b = f("", {
5
+ import { cn as b } from "@brightlocal/ui-components/lib/utils";
6
+ const g = f("", {
7
7
  variants: {
8
8
  variant: {
9
9
  body: "text-body",
@@ -32,50 +32,61 @@ const b = f("", {
32
32
  left: "text-left",
33
33
  center: "text-center",
34
34
  right: "text-right"
35
+ },
36
+ // Boolean on purpose (no `false` class): unlike tabular there is no
37
+ // inherited context to undo — either the element clips or it doesn't.
38
+ // `block` is load-bearing: an inline box (the default `span` for metric,
39
+ // `code` for code, or an inline asChild child) cannot clip — overflow
40
+ // does not apply to non-replaced inlines — so the variant forces a block
41
+ // container. A no-op on the body variants (`p` is already block) and on
42
+ // flex/grid items (blockified by the layout).
43
+ truncate: {
44
+ true: "block truncate"
35
45
  }
36
46
  },
37
47
  defaultVariants: {
38
48
  variant: "body",
39
49
  color: "default"
40
50
  }
41
- }), g = {
51
+ }), h = {
42
52
  body: "p",
43
53
  "body-sm": "p",
44
54
  "body-xs": "p",
45
55
  metric: "span",
46
56
  code: "code"
47
- }, h = i.forwardRef(
57
+ }, T = u.forwardRef(
48
58
  ({
49
59
  className: e,
50
60
  variant: t = "body",
51
61
  color: o = "default",
52
62
  tabular: r,
53
63
  align: a,
54
- asChild: d = !1,
55
- dataHook: s,
56
- trackingEl: m,
57
- trackingLabel: p,
58
- ...c
59
- }, l) => {
60
- const n = d ? x : g[t];
61
- return /* @__PURE__ */ y(
62
- n,
64
+ truncate: d = !1,
65
+ asChild: s = !1,
66
+ dataHook: c,
67
+ trackingEl: l,
68
+ trackingLabel: n,
69
+ ...m
70
+ }, p) => {
71
+ const y = s ? x : h[t];
72
+ return /* @__PURE__ */ i(
73
+ y,
63
74
  {
64
- ref: l,
65
- className: u(
66
- b({ variant: t, color: o, tabular: r, align: a }),
75
+ ref: p,
76
+ className: b(
77
+ g({ variant: t, color: o, tabular: r, align: a, truncate: d }),
67
78
  e
68
79
  ),
69
- "data-hook": s,
80
+ "data-hook": c,
70
81
  "data-slot": "typography-text",
71
- "data-tracking-el": m || `typography-text-${t}`,
72
- "data-tracking-label": p,
73
- ...c
82
+ "data-tracking-el": l || `typography-text-${t}`,
83
+ "data-tracking-label": n,
84
+ ...m
74
85
  }
75
86
  );
76
87
  }
77
88
  );
78
- h.displayName = "TypographyText";
89
+ T.displayName = "TypographyText";
79
90
  export {
80
- h as TypographyText
91
+ T as TypographyText
81
92
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@brightlocal/ui-components",
3
- "version": "3.0.0",
3
+ "version": "3.1.0",
4
4
  "description": "BrightLocal Design System UI Components",
5
5
  "type": "module",
6
6
  "private": false,
@@ -1,5 +1,4 @@
1
1
  import * as React from "react";
2
- import { cva } from "class-variance-authority";
3
2
 
4
3
  import { cn } from "@brightlocal/ui-components/lib/utils";
5
4
  import {
@@ -11,6 +10,7 @@ import {
11
10
  BLOCK_ILLUSTRATION_SIZE,
12
11
  BlockIllustration,
13
12
  } from "../lib/block-illustration";
13
+ import { emptyChipStyles } from "../lib/empty-chip";
14
14
 
15
15
  /* -------------------------------------------------------------------------------------------------
16
16
  * EmptyState
@@ -26,9 +26,9 @@ import {
26
26
  * for a section):
27
27
  *
28
28
  * md (default) — for the box a working page gives it: a card, a panel, a
29
- * zero-row table. An icon in a muted chip, and a 20/28 title.
29
+ * zero-row table. An icon in a muted chip, and a 16/24 title.
30
30
  * lg — for the moment the whole page has nothing to show: a full
31
- * illustration at 130 and a 24/32 title. Sits at the page
31
+ * illustration at 130 and a 20/28 title. Sits at the page
32
32
  * body's optical centre via `<Grid variant="centered">`.
33
33
  *
34
34
  * (`sm` is reserved: a compact row-level tier is not designed yet, and until
@@ -68,10 +68,12 @@ type EmptyStateSize = "md" | "lg";
68
68
  */
69
69
  type EmptyStateAlign = "center" | "left";
70
70
 
71
- /** The title's type role per size — Inter 20/28, or Poppins 24/32. */
71
+ /** The title's type role per size — Inter 16/24, or Inter 20/28. One step
72
+ * under the heading of the page or card the block sits inside, so the empty
73
+ * message never competes with it (DS-997). */
72
74
  const SIZE_HEADING_VARIANT = {
73
- md: "section",
74
- lg: "page",
75
+ md: "subsection",
76
+ lg: "section",
75
77
  } as const;
76
78
 
77
79
  /** The outline level each size defaults to, if the consumer names none. */
@@ -82,20 +84,6 @@ const SIZE_TITLE_LEVEL: Record<EmptyStateSize, TypographyHeadingLevel> = {
82
84
  md: 3,
83
85
  };
84
86
 
85
- /**
86
- * The visual's chip: 40px of `bg-muted` around a 16px glyph. A canvas drops it
87
- * — but a canvas is a different component, so there is no variant for that here.
88
- */
89
- const chipStyles = cva(
90
- "bg-muted text-muted-foreground flex size-10 items-center justify-center rounded-full",
91
- {
92
- variants: {
93
- align: { center: "", left: "shrink-0" },
94
- },
95
- defaultVariants: { align: "center" },
96
- }
97
- );
98
-
99
87
  /**
100
88
  * The parts every empty state has, at either size.
101
89
  */
@@ -313,7 +301,7 @@ const EmptyState = React.forwardRef<HTMLDivElement, EmptyStateProps>(
313
301
  <span
314
302
  aria-hidden="true"
315
303
  className={cn(
316
- chipStyles({ align }),
304
+ emptyChipStyles({ align }),
317
305
  /* The chip's 4px of extra breathing room belongs to the title
318
306
  under it — the lg column sets its own 16px rhythm instead. */
319
307
  size === "md" && align === "center" && "mb-1"
@@ -125,6 +125,18 @@ export interface AccordionItemProps extends React.ComponentProps<
125
125
  * A unique value for the item (REQUIRED)
126
126
  */
127
127
  value: string;
128
+ /**
129
+ * Data hook for automated testing
130
+ */
131
+ dataHook?: string;
132
+ /**
133
+ * Tracking element identifier for analytics
134
+ */
135
+ trackingEl?: string;
136
+ /**
137
+ * Tracking label for analytics context
138
+ */
139
+ trackingLabel?: string;
128
140
  /**
129
141
  * Whether the accordion item is disabled
130
142
  */
@@ -142,11 +154,14 @@ export interface AccordionItemProps extends React.ComponentProps<
142
154
  const AccordionItem = React.forwardRef<
143
155
  React.ComponentRef<typeof AccordionPrimitive.Item>,
144
156
  AccordionItemProps
145
- >(({ className, ...props }, ref) => (
157
+ >(({ className, dataHook, trackingEl, trackingLabel, ...props }, ref) => (
146
158
  <AccordionPrimitive.Item
147
159
  ref={ref}
148
160
  className={cn("border-b last:border-b-0", className)}
161
+ data-hook={dataHook}
149
162
  data-slot="accordion-item"
163
+ data-tracking-el={trackingEl}
164
+ data-tracking-label={trackingLabel}
150
165
  {...props}
151
166
  />
152
167
  ));
@@ -168,27 +183,47 @@ export interface AccordionTriggerProps extends React.ComponentProps<
168
183
  * Whether the trigger is disabled
169
184
  */
170
185
  disabled?: boolean;
186
+ /**
187
+ * Data hook for automated testing
188
+ */
189
+ dataHook?: string;
190
+ /**
191
+ * Tracking element identifier for analytics
192
+ */
193
+ trackingEl?: string;
194
+ /**
195
+ * Tracking label for analytics context
196
+ */
197
+ trackingLabel?: string;
171
198
  }
172
199
 
173
200
  const AccordionTrigger = React.forwardRef<
174
201
  React.ComponentRef<typeof AccordionPrimitive.Trigger>,
175
202
  AccordionTriggerProps
176
- >(({ className, children, ...props }, ref) => (
177
- <AccordionPrimitive.Header className="flex">
178
- <AccordionPrimitive.Trigger
179
- ref={ref}
180
- className={cn(
181
- "focus-visible:border-ring focus-visible:shadow-default duration-fast text-label flex flex-1 items-start justify-between gap-4 rounded-md py-4 text-left transition-shadow ease-out outline-none hover:underline disabled:pointer-events-none disabled:opacity-50 [&[data-state=open]>svg]:rotate-180",
182
- className
183
- )}
184
- data-slot="accordion-trigger"
185
- {...props}
186
- >
187
- {children}
188
- <ChevronDown className="text-muted-foreground duration-base pointer-events-none shrink-0 translate-y-0.5 transition-transform ease-in-out" />
189
- </AccordionPrimitive.Trigger>
190
- </AccordionPrimitive.Header>
191
- ));
203
+ >(
204
+ (
205
+ { className, children, dataHook, trackingEl, trackingLabel, ...props },
206
+ ref
207
+ ) => (
208
+ <AccordionPrimitive.Header className="flex">
209
+ <AccordionPrimitive.Trigger
210
+ ref={ref}
211
+ className={cn(
212
+ "focus-visible:border-ring focus-visible:shadow-default duration-fast text-label flex flex-1 items-start justify-between gap-4 rounded-md py-4 text-left transition-shadow ease-out outline-none hover:underline disabled:pointer-events-none disabled:opacity-50 [&[data-state=open]>svg]:rotate-180",
213
+ className
214
+ )}
215
+ data-hook={dataHook}
216
+ data-slot="accordion-trigger"
217
+ data-tracking-el={trackingEl}
218
+ data-tracking-label={trackingLabel}
219
+ {...props}
220
+ >
221
+ {children}
222
+ <ChevronDown className="text-muted-foreground duration-base pointer-events-none shrink-0 translate-y-0.5 transition-transform ease-in-out" />
223
+ </AccordionPrimitive.Trigger>
224
+ </AccordionPrimitive.Header>
225
+ )
226
+ );
192
227
 
193
228
  AccordionTrigger.displayName = "AccordionTrigger";
194
229
 
@@ -207,21 +242,41 @@ export interface AccordionContentProps extends React.ComponentProps<
207
242
  * Force mounting of the content when true
208
243
  */
209
244
  forceMount?: true;
245
+ /**
246
+ * Data hook for automated testing
247
+ */
248
+ dataHook?: string;
249
+ /**
250
+ * Tracking element identifier for analytics
251
+ */
252
+ trackingEl?: string;
253
+ /**
254
+ * Tracking label for analytics context
255
+ */
256
+ trackingLabel?: string;
210
257
  }
211
258
 
212
259
  const AccordionContent = React.forwardRef<
213
260
  React.ComponentRef<typeof AccordionPrimitive.Content>,
214
261
  AccordionContentProps
215
- >(({ className, children, ...props }, ref) => (
216
- <AccordionPrimitive.Content
217
- ref={ref}
218
- className="text-body-sm data-[state=closed]:animate-accordion-up data-[state=open]:animate-accordion-down overflow-hidden"
219
- data-slot="accordion-content"
220
- {...props}
221
- >
222
- <div className={cn("pt-0 pb-4", className)}>{children}</div>
223
- </AccordionPrimitive.Content>
224
- ));
262
+ >(
263
+ (
264
+ { className, children, dataHook, trackingEl, trackingLabel, ...props },
265
+ ref
266
+ ) => (
267
+ <AccordionPrimitive.Content
268
+ ref={ref}
269
+ className="text-body-sm data-[state=closed]:animate-accordion-up data-[state=open]:animate-accordion-down overflow-hidden"
270
+ data-hook={dataHook}
271
+ data-slot="accordion-content"
272
+ data-tracking-el={trackingEl}
273
+ data-tracking-label={trackingLabel}
274
+ {...props}
275
+ >
276
+ <div className={cn("pt-0 pb-4", className)}>{children}</div>
277
+ </AccordionPrimitive.Content>
278
+ )
279
+ );
225
280
 
226
281
  AccordionContent.displayName = "AccordionContent";
227
282
 
@@ -0,0 +1,112 @@
1
+ import * as React from "react";
2
+ import { cva } from "class-variance-authority";
3
+
4
+ import { cn } from "@brightlocal/ui-components/lib/utils";
5
+
6
+ /* The group owns only the joining: it zeroes the radii on the shared edges,
7
+ collapses the doubled border between bordered neighbours, and raises the
8
+ focused/open child above its siblings so the focus shadow paints over the
9
+ joined edge. Children keep their own outer-edge shape — a Button end stays
10
+ a pill, a SelectTrigger end stays rounded-sm — because the child's variant,
11
+ not the group, owns its identity.
12
+
13
+ A joined SelectTrigger keeps BOTH its side borders and the neighbour
14
+ touching it gives up its own: Button borders are border (neutral-200) while
15
+ the trigger's are input (neutral-300), so letting each seam fall to "the
16
+ child on the left" would draw the trigger's two seams in different colours.
17
+
18
+ Base order: layout, the corner/border joins, the z-raise that lets a
19
+ focused/open child paint its shadow over the joined neighbour's edge, then
20
+ the SelectTrigger width fix: a joined trigger hugs its value instead of
21
+ stretching. The `.w-full` guard is the discriminator — SelectTrigger runs
22
+ className through twMerge, so its default `w-full` survives only when the
23
+ consumer set no width; an explicit width (e.g. `w-44`) replaces it and
24
+ this rule stops matching. */
25
+ const buttonGroupVariants = cva([
26
+ "flex w-fit items-stretch",
27
+ "[&>*:not(:first-child)]:rounded-l-none",
28
+ "[&>*:not(:last-child)]:rounded-r-none",
29
+ "[&>*:not(:first-child):not([data-slot=select-trigger])]:border-l-0",
30
+ "[&>*:has(+[data-slot=select-trigger])]:border-r-0",
31
+ "[&>*]:focus-visible:relative [&>*]:focus-visible:z-10",
32
+ "[&>*]:data-[state=open]:relative [&>*]:data-[state=open]:z-10",
33
+ "[&>[data-slot=select-trigger].w-full]:w-fit",
34
+ ]);
35
+
36
+ /**
37
+ * Props for the ButtonGroup component.
38
+ * Joins Buttons and a Select trigger into one attached row with merged
39
+ * borders. Children must be direct children of the group.
40
+ */
41
+ interface ButtonGroupProps extends React.ComponentPropsWithoutRef<"div"> {
42
+ /**
43
+ * Data hook for automated testing (REQUIRED)
44
+ * @example "run-navigator"
45
+ */
46
+ dataHook: string;
47
+ /**
48
+ * Tracking element identifier for analytics
49
+ */
50
+ trackingEl?: string;
51
+ /**
52
+ * Tracking label for analytics context
53
+ */
54
+ trackingLabel?: string;
55
+ }
56
+
57
+ const ButtonGroup = React.forwardRef<HTMLDivElement, ButtonGroupProps>(
58
+ ({ className, dataHook, trackingEl, trackingLabel, ...props }, ref) => {
59
+ return (
60
+ <div
61
+ ref={ref}
62
+ className={cn(buttonGroupVariants(), className)}
63
+ data-hook={dataHook}
64
+ data-slot="button-group"
65
+ data-tracking-el={trackingEl || "button-group"}
66
+ data-tracking-label={trackingLabel}
67
+ role="group"
68
+ {...props}
69
+ />
70
+ );
71
+ }
72
+ );
73
+
74
+ ButtonGroup.displayName = "ButtonGroup";
75
+
76
+ /**
77
+ * Props for the ButtonGroupSeparator component.
78
+ */
79
+ interface ButtonGroupSeparatorProps extends React.ComponentPropsWithoutRef<"div"> {
80
+ /**
81
+ * Data hook for automated testing
82
+ */
83
+ dataHook?: string;
84
+ }
85
+
86
+ /* A black scrim darkens whatever fill it sits on, so one default works on a
87
+ primary green split, a destructive red one, and an outline group alike —
88
+ no per-variant separator colour and nothing to redefine in dark mode.
89
+ -ml-px pulls the line over the previous segment's edge (net width 0), so it
90
+ reads as a darker shade of the fill, not a gap showing the page behind. */
91
+ const ButtonGroupSeparator = React.forwardRef<
92
+ HTMLDivElement,
93
+ ButtonGroupSeparatorProps
94
+ >(({ className, dataHook, ...props }, ref) => {
95
+ return (
96
+ <div
97
+ ref={ref}
98
+ aria-orientation="vertical"
99
+ className={cn("-ml-px w-px shrink-0 self-stretch bg-black/15", className)}
100
+ data-hook={dataHook}
101
+ data-slot="button-group-separator"
102
+ role="separator"
103
+ {...props}
104
+ />
105
+ );
106
+ });
107
+
108
+ ButtonGroupSeparator.displayName = "ButtonGroupSeparator";
109
+
110
+ export { ButtonGroup, ButtonGroupSeparator, buttonGroupVariants };
111
+
112
+ export type { ButtonGroupProps, ButtonGroupSeparatorProps };
@@ -89,7 +89,7 @@ const ButtonVariants = cva(
89
89
  ],
90
90
  outline: [
91
91
  "border",
92
- "border-border",
92
+ "border-input",
93
93
  "border-solid",
94
94
  "bg-background",
95
95
  "hover:bg-accent",
@@ -316,14 +316,47 @@ const CardTitle = React.forwardRef<HTMLElement, CardTitleProps>(
316
316
  );
317
317
  CardTitle.displayName = "CardTitle";
318
318
 
319
+ /**
320
+ * Text alignment for the CardDescription.
321
+ */
322
+ type CardDescriptionAlign = "left" | "center" | "right";
323
+
324
+ // No defaultVariants on purpose: when `align` is omitted the description
325
+ // keeps inheriting alignment from its parent (e.g. `CardHeader align`),
326
+ // so existing cards render exactly as before.
327
+ const cardDescriptionVariants = cva("text-body-sm text-muted-foreground", {
328
+ variants: {
329
+ align: {
330
+ left: "text-left",
331
+ center: "text-center",
332
+ right: "text-right",
333
+ },
334
+ },
335
+ });
336
+
337
+ /**
338
+ * Props for the CardDescription component.
339
+ */
340
+ type CardDescriptionProps = CardSubComponentProps & {
341
+ /**
342
+ * Text alignment of the description itself. When omitted, the description
343
+ * inherits alignment from its parent — e.g. `CardHeader align`, or the
344
+ * centring a browser applies inside a `button`. Set it to pin the
345
+ * description's alignment regardless of context (matches `CardHeader`
346
+ * and Typography alignment values).
347
+ * @example <CardDescription align="left">…</CardDescription>
348
+ */
349
+ align?: CardDescriptionAlign;
350
+ };
351
+
319
352
  /**
320
353
  * Description text within the Card header.
321
354
  */
322
- const CardDescription = React.forwardRef<HTMLDivElement, CardSubComponentProps>(
323
- ({ className, dataHook, ...props }, ref) => (
355
+ const CardDescription = React.forwardRef<HTMLDivElement, CardDescriptionProps>(
356
+ ({ className, align, dataHook, ...props }, ref) => (
324
357
  <div
325
358
  ref={ref}
326
- className={cn("text-body-sm text-muted-foreground", className)}
359
+ className={cn(cardDescriptionVariants({ align }), className)}
327
360
  data-hook={dataHook}
328
361
  data-slot="card-description"
329
362
  {...props}
@@ -432,6 +465,8 @@ export type {
432
465
  CardSubComponentProps,
433
466
  CardHeaderProps,
434
467
  CardHeaderAlign,
468
+ CardDescriptionProps,
469
+ CardDescriptionAlign,
435
470
  CardTitleProps,
436
471
  CardTitleSize,
437
472
  CardTitleLevel,