@brightlocal/ui-components 2.19.0 → 2.21.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 (92) hide show
  1. package/AI_USAGE.md +2 -0
  2. package/README.md +27 -14
  3. package/component-meta.json +27 -11
  4. package/dist/alert-dialog.cjs +1 -1
  5. package/dist/alert-dialog.d.ts.map +1 -1
  6. package/dist/alert-dialog.js +34 -33
  7. package/dist/blocks/data-table.cjs +1 -1
  8. package/dist/blocks/data-table.d.ts.map +1 -1
  9. package/dist/blocks/data-table.js +14 -16
  10. package/dist/blocks/sidebar.cjs +1 -1
  11. package/dist/blocks/sidebar.d.ts +20 -2
  12. package/dist/blocks/sidebar.d.ts.map +1 -1
  13. package/dist/blocks/sidebar.js +99 -89
  14. package/dist/breadcrumb.cjs +1 -1
  15. package/dist/breadcrumb.d.ts +1 -1
  16. package/dist/breadcrumb.d.ts.map +1 -1
  17. package/dist/breadcrumb.js +9 -6
  18. package/dist/browser-entry.d.ts +2 -0
  19. package/dist/browser-entry.d.ts.map +1 -1
  20. package/dist/button.cjs +1 -1
  21. package/dist/button.d.ts.map +1 -1
  22. package/dist/button.js +12 -12
  23. package/dist/context-menu.cjs +1 -1
  24. package/dist/context-menu.d.ts.map +1 -1
  25. package/dist/context-menu.js +47 -46
  26. package/dist/dialog.cjs +1 -1
  27. package/dist/dialog.d.ts.map +1 -1
  28. package/dist/dialog.js +35 -34
  29. package/dist/dropdown-menu.cjs +1 -1
  30. package/dist/dropdown-menu.d.ts.map +1 -1
  31. package/dist/dropdown-menu.js +48 -47
  32. package/dist/hooks/use-overlay-pointer-lock.cjs +1 -0
  33. package/dist/hooks/use-overlay-pointer-lock.d.ts +20 -0
  34. package/dist/hooks/use-overlay-pointer-lock.d.ts.map +1 -0
  35. package/dist/hooks/use-overlay-pointer-lock.js +39 -0
  36. package/dist/index.cjs +1 -1
  37. package/dist/index.d.ts +1 -0
  38. package/dist/index.d.ts.map +1 -1
  39. package/dist/index.js +88 -86
  40. package/dist/logo.cjs +1 -1
  41. package/dist/logo.d.ts +1 -1
  42. package/dist/logo.js +2 -2
  43. package/dist/navigation-menu.cjs +1 -1
  44. package/dist/navigation-menu.d.ts +19 -0
  45. package/dist/navigation-menu.d.ts.map +1 -1
  46. package/dist/navigation-menu.js +134 -96
  47. package/dist/pagination.cjs +1 -1
  48. package/dist/pagination.d.ts +12 -8
  49. package/dist/pagination.d.ts.map +1 -1
  50. package/dist/pagination.js +117 -113
  51. package/dist/popover.cjs +1 -1
  52. package/dist/popover.d.ts.map +1 -1
  53. package/dist/popover.js +21 -20
  54. package/dist/progress.cjs +1 -1
  55. package/dist/progress.d.ts +28 -2
  56. package/dist/progress.d.ts.map +1 -1
  57. package/dist/progress.js +90 -49
  58. package/dist/select.cjs +1 -1
  59. package/dist/select.d.ts.map +1 -1
  60. package/dist/select.js +25 -23
  61. package/dist/separator.cjs +1 -1
  62. package/dist/separator.d.ts +14 -0
  63. package/dist/separator.d.ts.map +1 -1
  64. package/dist/separator.js +90 -44
  65. package/dist/sheet.cjs +1 -1
  66. package/dist/sheet.d.ts.map +1 -1
  67. package/dist/sheet.js +29 -28
  68. package/dist/skeleton.cjs +1 -1
  69. package/dist/skeleton.js +1 -1
  70. package/dist/sonner.d.ts +1 -1
  71. package/package.json +5 -1
  72. package/src/blocks/data-table.tsx +0 -2
  73. package/src/blocks/sidebar.tsx +40 -13
  74. package/src/browser-entry.ts +10 -0
  75. package/src/components/alert-dialog.tsx +20 -14
  76. package/src/components/breadcrumb.tsx +6 -3
  77. package/src/components/button.tsx +7 -1
  78. package/src/components/context-menu.tsx +19 -13
  79. package/src/components/dialog.tsx +4 -0
  80. package/src/components/dropdown-menu.tsx +4 -0
  81. package/src/components/logo.tsx +3 -3
  82. package/src/components/navigation-menu.tsx +134 -32
  83. package/src/components/pagination.tsx +47 -67
  84. package/src/components/popover.tsx +22 -16
  85. package/src/components/progress.tsx +118 -14
  86. package/src/components/select.tsx +4 -0
  87. package/src/components/separator.tsx +91 -23
  88. package/src/components/sheet.tsx +4 -0
  89. package/src/components/skeleton.tsx +1 -1
  90. package/src/components/sonner.tsx +1 -1
  91. package/src/hooks/use-overlay-pointer-lock.ts +128 -0
  92. package/src/index.ts +1 -0
@@ -1,48 +1,47 @@
1
- import { jsx as o, jsxs as h } from "react/jsx-runtime";
2
- import * as l from "react";
3
- import { MoreHorizontal as v, ChevronRight as x, ChevronLeft as b } from "@brightlocal/icons";
4
- import { cva as N } from "class-variance-authority";
5
- import { cn as f } from "@brightlocal/ui-components/lib/utils";
6
- function G({
7
- page: t,
8
- totalPages: i,
9
- siblingCount: n = 1,
10
- boundaryCount: a = 1
1
+ import { jsx as s, jsxs as h } from "react/jsx-runtime";
2
+ import * as c from "react";
3
+ import { MoreHorizontal as v, ChevronRight as b, ChevronLeft as x } from "@brightlocal/icons";
4
+ import { cva as y } from "class-variance-authority";
5
+ import { cn as d } from "@brightlocal/ui-components/lib/utils";
6
+ import { useIsBelowBreakpoint as N } from "@brightlocal/ui-components/hooks/use-breakpoint";
7
+ function I({
8
+ page: i,
9
+ totalPages: a
11
10
  }) {
12
- return l.useMemo(() => {
13
- const r = [];
14
- r.push("previous");
15
- const c = Math.max(t - n, a + 1), p = Math.min(
16
- t + n,
17
- i - a
18
- ), g = c > a + 2, m = p < i - a - 1;
19
- for (let e = 1; e <= Math.min(a, i); e++)
20
- r.push(e);
21
- if (g)
22
- r.push("ellipsis");
23
- else if (a + 1 < c)
24
- for (let e = a + 1; e < c; e++)
25
- r.push(e);
26
- for (let e = c; e <= p; e++)
27
- e > a && e <= i - a && r.push(e);
28
- if (m)
29
- r.push("ellipsis");
30
- else if (p < i - a)
31
- for (let e = p + 1; e < i - a + 1; e++)
32
- r.push(e);
33
- for (let e = Math.max(i - a + 1, a + 1); e <= i; e++)
34
- e > a && r.push(e);
11
+ const n = N("sm") ? 5 : 7;
12
+ return c.useMemo(() => {
13
+ const t = Math.max(5, n), r = [];
14
+ if (r.push("previous"), a <= t)
15
+ for (let u = 1; u <= a; u++)
16
+ r.push(u);
17
+ else {
18
+ const u = Math.floor((t - 5) / 2), f = t - 3, m = a - f;
19
+ if (i <= f) {
20
+ for (let o = 1; o <= t - 2; o++)
21
+ r.push(o);
22
+ r.push("ellipsis", a);
23
+ } else if (i >= m) {
24
+ r.push(1, "ellipsis");
25
+ for (let o = a - (t - 3); o <= a; o++)
26
+ r.push(o);
27
+ } else {
28
+ r.push(1, "ellipsis");
29
+ for (let o = i - u; o <= i + u; o++)
30
+ r.push(o);
31
+ r.push("ellipsis", a);
32
+ }
33
+ }
35
34
  return r.push("next"), r;
36
- }, [t, i, n, a]);
35
+ }, [i, a, n]);
37
36
  }
38
- const u = N(
37
+ const g = y(
39
38
  [
40
39
  // Base styles - circular button
41
40
  "inline-flex items-center justify-center",
42
41
  "h-9 w-9",
43
42
  "rounded-full",
44
43
  "text-sm font-medium",
45
- "transition-colors",
44
+ "transition-colors duration-200 ease-out",
46
45
  "focus-visible:outline-none focus-visible:shadow-default"
47
46
  ],
48
47
  {
@@ -71,7 +70,12 @@ const u = N(
71
70
  // Disabled state
72
71
  "aria-disabled:opacity-50 aria-disabled:cursor-default aria-disabled:pointer-events-none"
73
72
  ],
74
- ellipsis: ["cursor-default", "text-foreground", "pointer-events-none"]
73
+ ellipsis: [
74
+ "relative",
75
+ "cursor-default",
76
+ "text-foreground",
77
+ "pointer-events-none"
78
+ ]
75
79
  }
76
80
  },
77
81
  defaultVariants: {
@@ -80,130 +84,130 @@ const u = N(
80
84
  }
81
85
  );
82
86
  function k({
83
- className: t,
84
- dataHook: i,
85
- trackingEl: n,
86
- trackingLabel: a,
87
- ariaLabel: s,
88
- ...r
87
+ className: i,
88
+ dataHook: a,
89
+ trackingEl: e,
90
+ trackingLabel: n,
91
+ ariaLabel: l,
92
+ ...t
89
93
  }) {
90
- return /* @__PURE__ */ o(
94
+ return /* @__PURE__ */ s(
91
95
  "nav",
92
96
  {
93
- "aria-label": s ?? "Pagination",
94
- className: f("mx-auto flex w-full justify-center", t),
95
- "data-hook": i,
97
+ "aria-label": l ?? "Pagination",
98
+ className: d("mx-auto flex w-full justify-center", i),
99
+ "data-hook": a,
96
100
  "data-slot": "pagination",
97
- "data-tracking-el": n || "pagination",
98
- "data-tracking-label": a,
101
+ "data-tracking-el": e || "pagination",
102
+ "data-tracking-label": n,
99
103
  role: "navigation",
100
- ...r
104
+ ...t
101
105
  }
102
106
  );
103
107
  }
104
108
  k.displayName = "Pagination";
105
- function L({
106
- className: t,
107
- ...i
109
+ function V({
110
+ className: i,
111
+ ...a
108
112
  }) {
109
- return /* @__PURE__ */ o(
113
+ return /* @__PURE__ */ s(
110
114
  "ul",
111
115
  {
112
- className: f("flex flex-row items-center gap-2", t),
116
+ className: d("flex flex-row items-center gap-2", i),
113
117
  "data-slot": "pagination-content",
114
- ...i
118
+ ...a
115
119
  }
116
120
  );
117
121
  }
118
- function S(t) {
119
- return /* @__PURE__ */ o("li", { "data-slot": "pagination-item", ...t });
122
+ function L(i) {
123
+ return /* @__PURE__ */ s("li", { "data-slot": "pagination-item", ...i });
120
124
  }
121
- const d = l.forwardRef(({ className: t, variant: i, isActive: n, children: a, ...s }, r) => /* @__PURE__ */ o(
125
+ const p = c.forwardRef(({ className: i, variant: a, isActive: e, children: n, ...l }, t) => /* @__PURE__ */ s(
122
126
  "button",
123
127
  {
124
- ref: r,
125
- "aria-current": n ? "page" : void 0,
126
- className: f(u({ variant: i }), t),
127
- "data-active": n,
128
+ ref: t,
129
+ "aria-current": e ? "page" : void 0,
130
+ className: d(g({ variant: a }), i),
131
+ "data-active": e,
128
132
  "data-slot": "pagination-button",
129
133
  type: "button",
130
- ...s,
131
- children: a
134
+ ...l,
135
+ children: n
132
136
  }
133
137
  ));
134
- d.displayName = "PaginationButton";
135
- const w = l.forwardRef(({ className: t, disabled: i, ariaLabel: n, ...a }, s) => /* @__PURE__ */ o(
136
- d,
138
+ p.displayName = "PaginationButton";
139
+ const P = c.forwardRef(({ className: i, disabled: a, ariaLabel: e, ...n }, l) => /* @__PURE__ */ s(
140
+ p,
137
141
  {
138
- ref: s,
139
- "aria-disabled": i,
140
- "aria-label": n ?? "Go to previous page",
141
- className: t,
142
- disabled: i,
142
+ ref: l,
143
+ "aria-disabled": a,
144
+ "aria-label": e ?? "Go to previous page",
145
+ className: i,
146
+ disabled: a,
143
147
  variant: "previous",
144
- ...a,
145
- children: /* @__PURE__ */ o(b, {})
148
+ ...n,
149
+ children: /* @__PURE__ */ s(x, {})
146
150
  }
147
151
  ));
148
- w.displayName = "PaginationPrevious";
149
- const P = l.forwardRef(
150
- ({ className: t, disabled: i, ariaLabel: n, ...a }, s) => /* @__PURE__ */ o(
151
- d,
152
+ P.displayName = "PaginationPrevious";
153
+ const w = c.forwardRef(
154
+ ({ className: i, disabled: a, ariaLabel: e, ...n }, l) => /* @__PURE__ */ s(
155
+ p,
152
156
  {
153
- ref: s,
154
- "aria-disabled": i,
155
- "aria-label": n ?? "Go to next page",
156
- className: t,
157
- disabled: i,
157
+ ref: l,
158
+ "aria-disabled": a,
159
+ "aria-label": e ?? "Go to next page",
160
+ className: i,
161
+ disabled: a,
158
162
  variant: "next",
159
- ...a,
160
- children: /* @__PURE__ */ o(x, {})
163
+ ...n,
164
+ children: /* @__PURE__ */ s(b, {})
161
165
  }
162
166
  )
163
167
  );
164
- P.displayName = "PaginationNext";
165
- const M = l.forwardRef(
166
- ({ className: t, page: i, isActive: n, ariaLabel: a, ...s }, r) => /* @__PURE__ */ o(
167
- d,
168
+ w.displayName = "PaginationNext";
169
+ const R = c.forwardRef(
170
+ ({ className: i, page: a, isActive: e, ariaLabel: n, ...l }, t) => /* @__PURE__ */ s(
171
+ p,
168
172
  {
169
- ref: r,
170
- "aria-label": a ? a.replace("{page}", String(i)) : `Go to page ${i}`,
171
- className: t,
172
- isActive: n,
173
+ ref: t,
174
+ "aria-label": n ? n.replace("{page}", String(a)) : `Go to page ${a}`,
175
+ className: i,
176
+ isActive: e,
173
177
  variant: "link",
174
- ...s,
175
- children: i
178
+ ...l,
179
+ children: a
176
180
  }
177
181
  )
178
182
  );
179
- M.displayName = "PaginationLink";
180
- function B({
181
- className: t,
182
- srLabel: i = "More pages",
183
- ...n
183
+ R.displayName = "PaginationLink";
184
+ function T({
185
+ className: i,
186
+ srLabel: a = "More pages",
187
+ ...e
184
188
  }) {
185
189
  return /* @__PURE__ */ h(
186
190
  "span",
187
191
  {
188
192
  "aria-hidden": "true",
189
- className: f(u({ variant: "ellipsis" }), t),
193
+ className: d(g({ variant: "ellipsis" }), i),
190
194
  "data-slot": "pagination-ellipsis",
191
- ...n,
195
+ ...e,
192
196
  children: [
193
- /* @__PURE__ */ o(v, {}),
194
- /* @__PURE__ */ o("span", { className: "sr-only", children: i })
197
+ /* @__PURE__ */ s(v, {}),
198
+ /* @__PURE__ */ s("span", { className: "sr-only", children: a })
195
199
  ]
196
200
  }
197
201
  );
198
202
  }
199
203
  export {
200
204
  k as Pagination,
201
- d as PaginationButton,
202
- L as PaginationContent,
203
- B as PaginationEllipsis,
204
- S as PaginationItem,
205
- M as PaginationLink,
206
- P as PaginationNext,
207
- w as PaginationPrevious,
208
- G as usePagination
205
+ p as PaginationButton,
206
+ V as PaginationContent,
207
+ T as PaginationEllipsis,
208
+ L as PaginationItem,
209
+ R as PaginationLink,
210
+ w as PaginationNext,
211
+ P as PaginationPrevious,
212
+ I as usePagination
209
213
  };
package/dist/popover.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("react/jsx-runtime"),m=require("react"),v=require("@radix-ui/react-popover"),g=require("@brightlocal/ui-components/lib/utils");function d(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const o in e)if(o!=="default"){const n=Object.getOwnPropertyDescriptor(e,o);Object.defineProperty(t,o,n.get?n:{enumerable:!0,get:()=>e[o]})}}return t.default=e,Object.freeze(t)}const i=d(m),a=d(v);function s({...e}){return r.jsx(a.Root,{"data-slot":"popover",...e})}s.displayName="Popover";const p=i.forwardRef(({dataHook:e,...t},o)=>r.jsx(a.Trigger,{ref:o,"data-slot":"popover-trigger",...e!=null&&{"data-hook":e},...t}));p.displayName="PopoverTrigger";const c=i.forwardRef(({className:e,align:t="center",sideOffset:o=4,dataHook:n,...u},f)=>r.jsx(a.Portal,{children:r.jsx(a.Content,{ref:f,align:t,className:g.cn("bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 w-72 origin-(--radix-popover-content-transform-origin) rounded-md border p-4 shadow-md outline-hidden",e),"data-hook":n,"data-slot":"popover-content",sideOffset:o,...u})}));c.displayName="PopoverContent";const l=i.forwardRef(({dataHook:e,...t},o)=>r.jsx(a.Anchor,{ref:o,"data-hook":e,"data-slot":"popover-anchor",...t}));l.displayName="PopoverAnchor";exports.Popover=s;exports.PopoverAnchor=l;exports.PopoverContent=c;exports.PopoverTrigger=p;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("react/jsx-runtime"),m=require("react"),v=require("@radix-ui/react-popover"),g=require("@brightlocal/ui-components/lib/utils"),P=require("@brightlocal/ui-components/hooks/use-overlay-pointer-lock");function s(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const o in e)if(o!=="default"){const n=Object.getOwnPropertyDescriptor(e,o);Object.defineProperty(t,o,n.get?n:{enumerable:!0,get:()=>e[o]})}}return t.default=e,Object.freeze(t)}const i=s(m),a=s(v);function d({...e}){return r.jsx(a.Root,{"data-slot":"popover",...e})}d.displayName="Popover";const p=i.forwardRef(({dataHook:e,...t},o)=>r.jsx(a.Trigger,{ref:o,"data-slot":"popover-trigger",...e!=null&&{"data-hook":e},...t}));p.displayName="PopoverTrigger";const c=i.forwardRef(({className:e,align:t="center",sideOffset:o=4,dataHook:n,...u},f)=>(P.useOverlayPointerLock(),r.jsx(a.Portal,{children:r.jsx(a.Content,{ref:f,align:t,className:g.cn("bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 w-72 origin-(--radix-popover-content-transform-origin) rounded-md border p-4 shadow-md outline-hidden",e),"data-hook":n,"data-slot":"popover-content",sideOffset:o,...u})})));c.displayName="PopoverContent";const l=i.forwardRef(({dataHook:e,...t},o)=>r.jsx(a.Anchor,{ref:o,"data-hook":e,"data-slot":"popover-anchor",...t}));l.displayName="PopoverAnchor";exports.Popover=d;exports.PopoverAnchor=l;exports.PopoverContent=c;exports.PopoverTrigger=p;
@@ -1 +1 @@
1
- {"version":3,"file":"popover.d.ts","sourceRoot":"","sources":["../../src/components/popover.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,gBAAgB,MAAM,yBAAyB,CAAC;AAI5D,MAAM,WAAW,YAAa,SAAQ,KAAK,CAAC,cAAc,CACxD,OAAO,gBAAgB,CAAC,IAAI,CAC7B;IACC,kGAAkG;IAClG,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,gDAAgD;IAChD,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,uEAAuE;IACvE,YAAY,CAAC,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,CAAC;IACvC,sHAAsH;IACtH,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAED;;GAEG;AACH,iBAAS,OAAO,CAAC,EAAE,GAAG,KAAK,EAAE,EAAE,YAAY,2CA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E,MAAM,CAAC;IACrB,qFAAqF;IACrF,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,uIAAuI;IACvI,MAAM,CAAC,EAAE,SAAS,GAAG,QAAQ,CAAC;IAC9B,uEAAuE;IACvE,gBAAgB,CAAC,EAAE,OAAO,CAAC;CAC5B;AAED;;GAEG;AACH,QAAA,MAAM,cAAc,yGA4BnB,CAAC;AAGF,MAAM,WAAW,kBAAmB,SAAQ,KAAK,CAAC,cAAc,CAC9D,OAAO,gBAAgB,CAAC,MAAM,CAC/B;IACC,2GAA2G;IAC3G,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,iDAAiD;IACjD,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED;;GAEG;AACH,QAAA,MAAM,aAAa,wGAUjB,CAAC;AAGH,OAAO,EAAE,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,aAAa,EAAE,CAAC"}
package/dist/popover.js CHANGED
@@ -1,13 +1,14 @@
1
- import { jsx as a } from "react/jsx-runtime";
1
+ import { jsx as r } from "react/jsx-runtime";
2
2
  import * as d from "react";
3
- import * as r from "@radix-ui/react-popover";
3
+ import * as a from "@radix-ui/react-popover";
4
4
  import { cn as s } from "@brightlocal/ui-components/lib/utils";
5
- function m({ ...o }) {
6
- return /* @__PURE__ */ a(r.Root, { "data-slot": "popover", ...o });
5
+ import { useOverlayPointerLock as m } from "@brightlocal/ui-components/hooks/use-overlay-pointer-lock";
6
+ function l({ ...o }) {
7
+ return /* @__PURE__ */ r(a.Root, { "data-slot": "popover", ...o });
7
8
  }
8
- m.displayName = "Popover";
9
- const l = d.forwardRef(({ dataHook: o, ...t }, e) => /* @__PURE__ */ a(
10
- r.Trigger,
9
+ l.displayName = "Popover";
10
+ const f = d.forwardRef(({ dataHook: o, ...t }, e) => /* @__PURE__ */ r(
11
+ a.Trigger,
11
12
  {
12
13
  ref: e,
13
14
  "data-slot": "popover-trigger",
@@ -15,10 +16,10 @@ const l = d.forwardRef(({ dataHook: o, ...t }, e) => /* @__PURE__ */ a(
15
16
  ...t
16
17
  }
17
18
  ));
18
- l.displayName = "PopoverTrigger";
19
- const f = d.forwardRef(
20
- ({ className: o, align: t = "center", sideOffset: e = 4, dataHook: i, ...n }, p) => /* @__PURE__ */ a(r.Portal, { children: /* @__PURE__ */ a(
21
- r.Content,
19
+ f.displayName = "PopoverTrigger";
20
+ const c = d.forwardRef(
21
+ ({ className: o, align: t = "center", sideOffset: e = 4, dataHook: i, ...n }, p) => (m(), /* @__PURE__ */ r(a.Portal, { children: /* @__PURE__ */ r(
22
+ a.Content,
22
23
  {
23
24
  ref: p,
24
25
  align: t,
@@ -31,11 +32,11 @@ const f = d.forwardRef(
31
32
  sideOffset: e,
32
33
  ...n
33
34
  }
34
- ) })
35
+ ) }))
35
36
  );
36
- f.displayName = "PopoverContent";
37
- const c = d.forwardRef(({ dataHook: o, ...t }, e) => /* @__PURE__ */ a(
38
- r.Anchor,
37
+ c.displayName = "PopoverContent";
38
+ const v = d.forwardRef(({ dataHook: o, ...t }, e) => /* @__PURE__ */ r(
39
+ a.Anchor,
39
40
  {
40
41
  ref: e,
41
42
  "data-hook": o,
@@ -43,10 +44,10 @@ const c = d.forwardRef(({ dataHook: o, ...t }, e) => /* @__PURE__ */ a(
43
44
  ...t
44
45
  }
45
46
  ));
46
- c.displayName = "PopoverAnchor";
47
+ v.displayName = "PopoverAnchor";
47
48
  export {
48
- m as Popover,
49
- c as PopoverAnchor,
50
- f as PopoverContent,
51
- l as PopoverTrigger
49
+ l as Popover,
50
+ v as PopoverAnchor,
51
+ c as PopoverContent,
52
+ f as PopoverTrigger
52
53
  };
package/dist/progress.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("react/jsx-runtime"),v=require("react"),x=require("@radix-ui/react-progress"),R=require("framer-motion"),i=require("@brightlocal/ui-components/lib/utils"),w=require("@brightlocal/ui-components/hooks/use-prefers-reduced-motion");function g(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const r in e)if(r!=="default"){const a=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,a.get?a:{enumerable:!0,get:()=>e[r]})}}return t.default=e,Object.freeze(t)}const u=g(v),f=g(x),m=u.forwardRef(({className:e,value:t,dataHook:r,trackingEl:a,trackingLabel:p,ariaLabel:b="Progress",label:o,indicatorClassName:P,disabled:l,...j},y)=>{const c=u.useId(),n=!!o,h=w.usePrefersReducedMotion(),d=s.jsx(f.Root,{ref:y,"aria-label":n?void 0:b,"aria-labelledby":n?c:void 0,className:i.cn("relative h-2 w-full overflow-hidden rounded-full","bg-primary/20",!n&&l&&"opacity-50",e),"data-hook":r,"data-slot":"progress","data-tracking-el":a,"data-tracking-label":p,...j,children:s.jsx(f.Indicator,{asChild:!0,children:s.jsx(R.motion.div,{animate:{transform:`translateX(-${100-(t||0)}%)`},className:i.cn("h-full w-full flex-1 bg-green-400",P),"data-slot":"progress-indicator",initial:!1,transition:h?{duration:0}:{type:"spring",stiffness:80,damping:20,mass:1}})})});return o?s.jsxs("div",{className:i.cn("flex w-full items-center gap-2",l&&"opacity-50"),"data-slot":"progress-wrapper",children:[s.jsx("span",{className:"text-foreground text-sm leading-normal font-medium","data-slot":"progress-label",id:c,children:o}),d]}):d});m.displayName="Progress";exports.Progress=m;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("react/jsx-runtime"),N=require("react"),S=require("@radix-ui/react-progress"),q=require("framer-motion"),i=require("@brightlocal/ui-components/lib/utils"),v=require("@brightlocal/ui-components/hooks/use-prefers-reduced-motion");function h(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const r in e)if(r!=="default"){const n=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,n.get?n:{enumerable:!0,get:()=>e[r]})}}return t.default=e,Object.freeze(t)}const b=h(N),p=h(S),m={green:{track:"bg-brand-primary-foreground/20",indicator:"bg-green-400"},red:{track:"bg-brand-red/20",indicator:"bg-brand-red"},orange:{track:"bg-brand-orange/20",indicator:"bg-brand-orange"},yellow:{track:"bg-brand-yellow/20",indicator:"bg-brand-yellow"}};function _(e,t,r){if(e==null)return"–";if(r==="%")return`${t>0?Math.min(100,Math.max(0,Math.round(e/t*100))):0}%`;const n=r?` ${r}`:"";return t>0?`${e} / ${t}${n}`:`${e}${n}`}const y=b.forwardRef(({className:e,value:t,max:r=100,dataHook:n,trackingEl:c,trackingLabel:P,ariaLabel:j="Progress",label:d,color:x="green",showValue:o=!1,unit:M="%",indicatorClassName:k,disabled:l,...R},w)=>{const g=b.useId(),s=!!d,O=v.usePrefersReducedMotion(),u=m[x]??m.green,$=r>0?Math.min(100,Math.max(0,(t??0)/r*100)):0,f=a.jsx(p.Root,{ref:w,"aria-label":s?void 0:j,"aria-labelledby":s?g:void 0,className:i.cn("relative h-2 w-full overflow-hidden rounded-full",u.track,!s&&!o&&l&&"opacity-50",e),"data-hook":n,"data-slot":"progress","data-tracking-el":c,"data-tracking-label":P,max:r,value:t,...R,children:a.jsx(p.Indicator,{asChild:!0,children:a.jsx(q.motion.div,{animate:{transform:`translateX(-${100-$}%)`},className:i.cn("h-full w-full flex-1",u.indicator,k),"data-slot":"progress-indicator",initial:!1,transition:O?{duration:0}:{type:"spring",stiffness:80,damping:20,mass:1}})})});return!s&&!o?f:a.jsxs("div",{className:i.cn("flex w-full items-center gap-2",l&&"opacity-50"),"data-slot":"progress-wrapper",children:[s&&a.jsx("span",{className:"text-foreground text-xs leading-none font-medium","data-slot":"progress-label",id:g,children:d}),f,o&&a.jsx("span",{className:"text-muted-foreground shrink-0 text-xs leading-none tabular-nums","data-slot":"progress-value",children:_(t,r,M)})]})});y.displayName="Progress";exports.Progress=y;
@@ -1,5 +1,13 @@
1
1
  import * as React from "react";
2
2
  import * as ProgressPrimitive from "@radix-ui/react-progress";
3
+ /**
4
+ * Brand color for the progress indicator, drawn from the shared brand palette.
5
+ * - `green` — strong / healthy / complete
6
+ * - `yellow` — moderate / acceptable
7
+ * - `orange` — weak / needs attention
8
+ * - `red` — critical / urgent
9
+ */
10
+ type ProgressColor = "green" | "red" | "orange" | "yellow";
3
11
  /**
4
12
  * Props for the Progress component.
5
13
  */
@@ -22,9 +30,27 @@ interface ProgressProps extends React.ComponentProps<typeof ProgressPrimitive.Ro
22
30
  */
23
31
  ariaLabel?: string;
24
32
  /**
25
- * Optional visible label text displayed above the progress bar
33
+ * Optional visible label text displayed to the left of the progress bar
26
34
  */
27
35
  label?: string;
36
+ /**
37
+ * Brand color for the indicator.
38
+ * @default "green"
39
+ */
40
+ color?: ProgressColor;
41
+ /**
42
+ * Whether to render the numeric value to the right of the progress bar.
43
+ * Falls back to `–` when no value is provided so the layout stays consistent.
44
+ * @default false
45
+ */
46
+ showValue?: boolean;
47
+ /**
48
+ * Unit/suffix appended to the displayed value. Use `"%"` for percentage form
49
+ * (value as a percentage of `max`, e.g. `90%`); any other unit renders
50
+ * fraction form (`3 / 5 steps`).
51
+ * @default "%"
52
+ */
53
+ unit?: string;
28
54
  /**
29
55
  * Custom class name for the indicator (progress fill)
30
56
  * Use this to customize the color, e.g., "bg-red-500"
@@ -42,5 +68,5 @@ interface ProgressProps extends React.ComponentProps<typeof ProgressPrimitive.Ro
42
68
  */
43
69
  declare const Progress: React.ForwardRefExoticComponent<Omit<ProgressProps, "ref"> & React.RefAttributes<HTMLDivElement>>;
44
70
  export { Progress };
45
- export type { ProgressProps };
71
+ export type { ProgressProps, ProgressColor };
46
72
  //# sourceMappingURL=progress.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"progress.d.ts","sourceRoot":"","sources":["../../src/components/progress.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,iBAAiB,MAAM,0BAA0B,CAAC;AAM9D;;GAEG;AACH,UAAU,aAAc,SAAQ,KAAK,CAAC,cAAc,CAClD,OAAO,iBAAiB,CAAC,IA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G;IACH,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B;;;OAGG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED;;;GAGG;AACH,QAAA,MAAM,QAAQ,mGA8Gb,CAAC;AAIF,OAAO,EAAE,QAAQ,EAAE,CAAC;AACpB,YAAY,EAAE,aAAa,EAAE,aAAa,EAAE,CAAC"}
package/dist/progress.js CHANGED
@@ -1,52 +1,85 @@
1
- import { jsx as r, jsxs as x } from "react/jsx-runtime";
2
- import * as l from "react";
3
- import * as n from "@radix-ui/react-progress";
4
- import { motion as w } from "framer-motion";
5
- import { cn as s } from "@brightlocal/ui-components/lib/utils";
6
- import { usePrefersReducedMotion as y } from "@brightlocal/ui-components/hooks/use-prefers-reduced-motion";
7
- const P = l.forwardRef(
1
+ import { jsx as o, jsxs as R } from "react/jsx-runtime";
2
+ import * as p from "react";
3
+ import * as b from "@radix-ui/react-progress";
4
+ import { motion as v } from "framer-motion";
5
+ import { cn as i } from "@brightlocal/ui-components/lib/utils";
6
+ import { usePrefersReducedMotion as I } from "@brightlocal/ui-components/hooks/use-prefers-reduced-motion";
7
+ const u = {
8
+ green: {
9
+ track: "bg-brand-primary-foreground/20",
10
+ indicator: "bg-green-400"
11
+ },
12
+ red: {
13
+ track: "bg-brand-red/20",
14
+ indicator: "bg-brand-red"
15
+ },
16
+ orange: {
17
+ track: "bg-brand-orange/20",
18
+ indicator: "bg-brand-orange"
19
+ },
20
+ yellow: {
21
+ track: "bg-brand-yellow/20",
22
+ indicator: "bg-brand-yellow"
23
+ }
24
+ };
25
+ function L(t, r, e) {
26
+ if (t == null)
27
+ return "–";
28
+ if (e === "%")
29
+ return `${r > 0 ? Math.min(100, Math.max(0, Math.round(t / r * 100))) : 0}%`;
30
+ const n = e ? ` ${e}` : "";
31
+ return r > 0 ? `${t} / ${r}${n}` : `${t}${n}`;
32
+ }
33
+ const S = p.forwardRef(
8
34
  ({
9
- className: d,
10
- value: m,
11
- dataHook: f,
12
- trackingEl: c,
13
- trackingLabel: p,
14
- ariaLabel: g = "Progress",
15
- label: e,
16
- indicatorClassName: u,
17
- disabled: o,
18
- ...h
19
- }, b) => {
20
- const t = l.useId(), a = !!e, v = y(), i = /* @__PURE__ */ r(
21
- n.Root,
35
+ className: t,
36
+ value: r,
37
+ max: e = 100,
38
+ dataHook: n,
39
+ trackingEl: d,
40
+ trackingLabel: h,
41
+ ariaLabel: y = "Progress",
42
+ label: l,
43
+ color: k = "green",
44
+ showValue: s = !1,
45
+ unit: x = "%",
46
+ indicatorClassName: $,
47
+ disabled: c,
48
+ ...w
49
+ }, M) => {
50
+ const g = p.useId(), a = !!l, P = I(), f = u[k] ?? u.green, N = e > 0 ? Math.min(100, Math.max(0, (r ?? 0) / e * 100)) : 0, m = /* @__PURE__ */ o(
51
+ b.Root,
22
52
  {
23
- ref: b,
24
- "aria-label": a ? void 0 : g,
25
- "aria-labelledby": a ? t : void 0,
26
- className: s(
53
+ ref: M,
54
+ "aria-label": a ? void 0 : y,
55
+ "aria-labelledby": a ? g : void 0,
56
+ className: i(
27
57
  "relative h-2 w-full overflow-hidden rounded-full",
28
- "bg-primary/20",
29
- !a && o && "opacity-50",
30
- d
58
+ f.track,
59
+ !a && !s && c && "opacity-50",
60
+ t
31
61
  ),
32
- "data-hook": f,
62
+ "data-hook": n,
33
63
  "data-slot": "progress",
34
- "data-tracking-el": c,
35
- "data-tracking-label": p,
36
- ...h,
37
- children: /* @__PURE__ */ r(n.Indicator, { asChild: !0, children: /* @__PURE__ */ r(
38
- w.div,
64
+ "data-tracking-el": d,
65
+ "data-tracking-label": h,
66
+ max: e,
67
+ value: r,
68
+ ...w,
69
+ children: /* @__PURE__ */ o(b.Indicator, { asChild: !0, children: /* @__PURE__ */ o(
70
+ v.div,
39
71
  {
40
72
  animate: {
41
- transform: `translateX(-${100 - (m || 0)}%)`
73
+ transform: `translateX(-${100 - N}%)`
42
74
  },
43
- className: s(
44
- "h-full w-full flex-1 bg-green-400",
45
- u
75
+ className: i(
76
+ "h-full w-full flex-1",
77
+ f.indicator,
78
+ $
46
79
  ),
47
80
  "data-slot": "progress-indicator",
48
81
  initial: !1,
49
- transition: v ? { duration: 0 } : {
82
+ transition: P ? { duration: 0 } : {
50
83
  type: "spring",
51
84
  stiffness: 80,
52
85
  damping: 20,
@@ -56,31 +89,39 @@ const P = l.forwardRef(
56
89
  ) })
57
90
  }
58
91
  );
59
- return e ? /* @__PURE__ */ x(
92
+ return !a && !s ? m : /* @__PURE__ */ R(
60
93
  "div",
61
94
  {
62
- className: s(
95
+ className: i(
63
96
  "flex w-full items-center gap-2",
64
- o && "opacity-50"
97
+ c && "opacity-50"
65
98
  ),
66
99
  "data-slot": "progress-wrapper",
67
100
  children: [
68
- /* @__PURE__ */ r(
101
+ a && /* @__PURE__ */ o(
69
102
  "span",
70
103
  {
71
- className: "text-foreground text-sm leading-normal font-medium",
104
+ className: "text-foreground text-xs leading-none font-medium",
72
105
  "data-slot": "progress-label",
73
- id: t,
74
- children: e
106
+ id: g,
107
+ children: l
75
108
  }
76
109
  ),
77
- i
110
+ m,
111
+ s && /* @__PURE__ */ o(
112
+ "span",
113
+ {
114
+ className: "text-muted-foreground shrink-0 text-xs leading-none tabular-nums",
115
+ "data-slot": "progress-value",
116
+ children: L(r, e, x)
117
+ }
118
+ )
78
119
  ]
79
120
  }
80
- ) : i;
121
+ );
81
122
  }
82
123
  );
83
- P.displayName = "Progress";
124
+ S.displayName = "Progress";
84
125
  export {
85
- P as Progress
126
+ S as Progress
86
127
  };