@brightlocal/ui-components 2.16.0 → 2.17.1
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.
- package/component-meta.json +2 -1
- package/deprecations.json +189 -0
- package/dist/badge.d.ts +1 -1
- package/dist/button.d.ts +1 -1
- package/dist/chart.cjs +4 -4
- package/dist/chart.d.ts +26 -0
- package/dist/chart.d.ts.map +1 -1
- package/dist/chart.js +75 -59
- package/dist/field.cjs +1 -1
- package/dist/field.d.ts.map +1 -1
- package/dist/field.js +2 -0
- package/dist/global-layout.cjs +1 -1
- package/dist/global-layout.d.ts +17 -2
- package/dist/global-layout.d.ts.map +1 -1
- package/dist/global-layout.js +34 -10
- package/dist/index.cjs +1 -1
- package/dist/index.js +346 -345
- package/dist/rating.cjs +1 -1
- package/dist/rating.d.ts +10 -0
- package/dist/rating.d.ts.map +1 -1
- package/dist/rating.js +39 -28
- package/dist/sheet.cjs +1 -1
- package/dist/sheet.d.ts +13 -2
- package/dist/sheet.d.ts.map +1 -1
- package/dist/sheet.js +38 -30
- package/package.json +8 -5
- package/src/components/chart.tsx +39 -1
- package/src/components/field.tsx +2 -0
- package/src/components/global-layout.tsx +56 -6
- package/src/components/rating.tsx +23 -1
- package/src/components/sheet.tsx +30 -5
package/dist/rating.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("react/jsx-runtime"),R=require("react"),d=require("@brightlocal/icons"),h=require("@brightlocal/ui-components/lib/utils");function S(t){const a=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const e in t)if(e!=="default"){const s=Object.getOwnPropertyDescriptor(t,e);Object.defineProperty(a,e,s.get?s:{enumerable:!0,get:()=>t[e]})}}return a.default=t,Object.freeze(a)}const v=S(R),N={sm:16,md:24},u=v.forwardRef(({value:t,dataHook:a,size:e="sm",ariaLabel:s,trackingEl:g,trackingLabel:m,className:f,...p},b)=>{const r=Math.max(0,Math.min(5,t)),o=N[e];return l.jsx("div",{ref:b,"aria-label":s?s.replace("{value}",String(r)):`Rating: ${r} out of 5 stars`,className:h.cn("flex items-center gap-0.5",f),"data-hook":a,"data-slot":"rating","data-tracking-el":g,"data-tracking-label":m,role:"img",...p,children:[...Array(5)].map((k,i)=>{const j=i+1,n=r>=j,c=!n&&r>i,y=c?((r-i)*100).toFixed(0):n?"100":"0";return l.jsxs("div",{className:"relative","data-slot":"rating-star",children:[l.jsx(d.StarRating,{className:"fill-muted stroke-muted","data-slot":"rating-star-base",size:o}),(n||c)&&l.jsx("div",{"aria-hidden":"true",className:"absolute inset-0 overflow-hidden","data-slot":"rating-star-fill",style:{width:`${y}%`},children:l.jsx(d.StarRating,{className:"fill-yellow-400 stroke-yellow-400",size:o})})]},i)})})});u.displayName="Rating";exports.Rating=u;
|
package/dist/rating.d.ts
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
+
/**
|
|
3
|
+
* Available size variants for the Rating component.
|
|
4
|
+
*/
|
|
5
|
+
type RatingSize = "sm" | "md";
|
|
2
6
|
/**
|
|
3
7
|
* Rating component displays a star-based rating indicator.
|
|
4
8
|
* Supports full and half-star values for precise rating display.
|
|
@@ -12,6 +16,11 @@ export interface RatingProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
|
12
16
|
* Data hook for testing
|
|
13
17
|
*/
|
|
14
18
|
dataHook: string;
|
|
19
|
+
/**
|
|
20
|
+
* Size of the star icons.
|
|
21
|
+
* @default "sm"
|
|
22
|
+
*/
|
|
23
|
+
size?: RatingSize;
|
|
15
24
|
/**
|
|
16
25
|
* Accessible label for the rating.
|
|
17
26
|
* Supports `{value}` placeholder for interpolation.
|
|
@@ -29,4 +38,5 @@ export interface RatingProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
|
29
38
|
}
|
|
30
39
|
declare const Rating: React.ForwardRefExoticComponent<RatingProps & React.RefAttributes<HTMLDivElement>>;
|
|
31
40
|
export { Rating };
|
|
41
|
+
export type { RatingSize };
|
|
32
42
|
//# sourceMappingURL=rating.d.ts.map
|
package/dist/rating.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rating.d.ts","sourceRoot":"","sources":["../../src/components/rating.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAK/B;;;GAGG;AACH,MAAM,WAAW,WAAY,SAAQ,KAAK,CAAC,cAAc,CAAC,cAAc,CAAC;IACvE;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;IACd;;OAEG;IACH,QAAQ,EAAE,MAAM,CAAC;IACjB;;;;OAIG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;OAEG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;OAEG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED,QAAA,MAAM,MAAM,
|
|
1
|
+
{"version":3,"file":"rating.d.ts","sourceRoot":"","sources":["../../src/components/rating.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAK/B;;GAEG;AACH,KAAK,UAAU,GAAG,IAAI,GAAG,IAAI,CAAC;AAO9B;;;GAGG;AACH,MAAM,WAAW,WAAY,SAAQ,KAAK,CAAC,cAAc,CAAC,cAAc,CAAC;IACvE;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;IACd;;OAEG;IACH,QAAQ,EAAE,MAAM,CAAC;IACjB;;;OAGG;IACH,IAAI,CAAC,EAAE,UAAU,CAAC;IAClB;;;;OAIG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;OAEG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;OAEG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED,QAAA,MAAM,MAAM,oFA2EX,CAAC;AAIF,OAAO,EAAE,MAAM,EAAE,CAAC;AAClB,YAAY,EAAE,UAAU,EAAE,CAAC"}
|
package/dist/rating.js
CHANGED
|
@@ -1,50 +1,61 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import * as
|
|
3
|
-
import { StarRating as
|
|
1
|
+
import { jsx as e, jsxs as y } from "react/jsx-runtime";
|
|
2
|
+
import * as N from "react";
|
|
3
|
+
import { StarRating as o } from "@brightlocal/icons";
|
|
4
4
|
import { cn as R } from "@brightlocal/ui-components/lib/utils";
|
|
5
|
-
const
|
|
5
|
+
const k = {
|
|
6
|
+
sm: 16,
|
|
7
|
+
md: 24
|
|
8
|
+
}, w = N.forwardRef(
|
|
6
9
|
({
|
|
7
|
-
value:
|
|
8
|
-
dataHook:
|
|
10
|
+
value: n,
|
|
11
|
+
dataHook: m,
|
|
12
|
+
size: c = "sm",
|
|
9
13
|
ariaLabel: l,
|
|
10
14
|
trackingEl: d,
|
|
11
|
-
trackingLabel:
|
|
12
|
-
className:
|
|
13
|
-
...
|
|
14
|
-
},
|
|
15
|
-
const a = Math.max(0, Math.min(5,
|
|
16
|
-
return /* @__PURE__ */
|
|
15
|
+
trackingLabel: g,
|
|
16
|
+
className: f,
|
|
17
|
+
...p
|
|
18
|
+
}, u) => {
|
|
19
|
+
const a = Math.max(0, Math.min(5, n)), r = k[c];
|
|
20
|
+
return /* @__PURE__ */ e(
|
|
17
21
|
"div",
|
|
18
22
|
{
|
|
19
|
-
ref:
|
|
23
|
+
ref: u,
|
|
20
24
|
"aria-label": l ? l.replace("{value}", String(a)) : `Rating: ${a} out of 5 stars`,
|
|
21
|
-
className: R("flex items-center gap-0.5",
|
|
22
|
-
"data-hook":
|
|
25
|
+
className: R("flex items-center gap-0.5", f),
|
|
26
|
+
"data-hook": m,
|
|
23
27
|
"data-slot": "rating",
|
|
24
28
|
"data-tracking-el": d,
|
|
25
|
-
"data-tracking-label":
|
|
29
|
+
"data-tracking-label": g,
|
|
26
30
|
role: "img",
|
|
27
|
-
...
|
|
28
|
-
children: [...Array(5)].map((
|
|
29
|
-
const
|
|
30
|
-
return /* @__PURE__ */
|
|
31
|
-
/* @__PURE__ */
|
|
32
|
-
|
|
31
|
+
...p,
|
|
32
|
+
children: [...Array(5)].map((z, t) => {
|
|
33
|
+
const h = t + 1, s = a >= h, i = !s && a > t, v = i ? ((a - t) * 100).toFixed(0) : s ? "100" : "0";
|
|
34
|
+
return /* @__PURE__ */ y("div", { className: "relative", "data-slot": "rating-star", children: [
|
|
35
|
+
/* @__PURE__ */ e(
|
|
36
|
+
o,
|
|
33
37
|
{
|
|
34
38
|
className: "fill-muted stroke-muted",
|
|
35
|
-
"data-slot": "rating-star-base"
|
|
39
|
+
"data-slot": "rating-star-base",
|
|
40
|
+
size: r
|
|
36
41
|
}
|
|
37
42
|
),
|
|
38
|
-
(
|
|
43
|
+
(s || i) && /* @__PURE__ */ e(
|
|
39
44
|
"div",
|
|
40
45
|
{
|
|
41
46
|
"aria-hidden": "true",
|
|
42
47
|
className: "absolute inset-0 overflow-hidden",
|
|
43
48
|
"data-slot": "rating-star-fill",
|
|
44
49
|
style: {
|
|
45
|
-
width: `${
|
|
50
|
+
width: `${v}%`
|
|
46
51
|
},
|
|
47
|
-
children: /* @__PURE__ */
|
|
52
|
+
children: /* @__PURE__ */ e(
|
|
53
|
+
o,
|
|
54
|
+
{
|
|
55
|
+
className: "fill-yellow-400 stroke-yellow-400",
|
|
56
|
+
size: r
|
|
57
|
+
}
|
|
58
|
+
)
|
|
48
59
|
}
|
|
49
60
|
)
|
|
50
61
|
] }, t);
|
|
@@ -53,7 +64,7 @@ const N = v.forwardRef(
|
|
|
53
64
|
);
|
|
54
65
|
}
|
|
55
66
|
);
|
|
56
|
-
|
|
67
|
+
w.displayName = "Rating";
|
|
57
68
|
export {
|
|
58
|
-
|
|
69
|
+
w as Rating
|
|
59
70
|
};
|
package/dist/sheet.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("react/jsx-runtime"),w=require("react"),R=require("@radix-ui/react-dialog"),C=require("class-variance-authority"),k=require("@brightlocal/icons"),i=require("@brightlocal/ui-components/lib/utils");function h(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const a in e)if(a!=="default"){const n=Object.getOwnPropertyDescriptor(e,a);Object.defineProperty(t,a,n.get?n:{enumerable:!0,get:()=>e[a]})}}return t.default=e,Object.freeze(t)}const r=h(w),o=h(R),O=C.cva(["bg-background","data-[state=open]:animate-in","data-[state=closed]:animate-out","fixed","z-50","flex","flex-col","gap-4","p-6","shadow-lg","transition","ease-in-out","data-[state=closed]:duration-300","data-[state=open]:duration-500"],{variants:{side:{top:["data-[state=closed]:slide-out-to-top","data-[state=open]:slide-in-from-top","inset-x-0","top-0","h-auto","border-b"],right:["data-[state=closed]:slide-out-to-right","data-[state=open]:slide-in-from-right","inset-y-0","right-0","h-full","w-3/4","border-l","sm:max-w-sm"],bottom:["data-[state=closed]:slide-out-to-bottom","data-[state=open]:slide-in-from-bottom","inset-x-0","bottom-0","h-auto","border-t"],left:["data-[state=closed]:slide-out-to-left","data-[state=open]:slide-in-from-left","inset-y-0","left-0","h-full","w-3/4","border-r","sm:max-w-sm"]}},defaultVariants:{side:"right"}});function f({...e}){return s.jsx(o.Root,{"data-slot":"sheet",modal:!0,...e})}f.displayName="Sheet";const u=r.forwardRef(({dataHook:e,...t},a)=>s.jsx(o.Trigger,{ref:a,"data-hook":e,"data-slot":"sheet-trigger",...t}));u.displayName="SheetTrigger";const m=r.forwardRef(({...e},t)=>s.jsx(o.Close,{ref:t,"data-slot":"sheet-close",...e}));m.displayName="SheetClose";function d({...e}){return s.jsx(o.Portal,{"data-slot":"sheet-portal",...e})}d.displayName="SheetPortal";const c=r.forwardRef(({className:e,...t},a)=>s.jsx(o.Overlay,{ref:a,className:i.cn("data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-black/50",e),"data-slot":"sheet-overlay",...t}));c.displayName="SheetOverlay";const p=r.forwardRef(({className:e,children:t,side:a,dataHook:n,trackingEl:l,trackingLabel:b,closeLabel:j,...N},v)=>s.jsxs(d,{children:[s.jsx(c,{}),s.jsxs(o.Content,{ref:v,className:i.cn(O({side:a}),e),"data-hook":n,"data-slot":"sheet-content","data-tracking-el":l,"data-tracking-label":b,...N,children:[t,s.jsxs(o.Close,{className:"ring-offset-background focus:ring-ring data-[state=open]:bg-accent data-[state=open]:text-muted-foreground absolute top-4 right-4 rounded-xs opacity-70 transition-opacity hover:opacity-100 focus:ring-2 focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none [&_svg]:pointer-events-none [&_svg]:shrink-0",children:[s.jsx(k.X,{}),s.jsx("span",{className:"sr-only",children:j??"Close"})]})]})]}));p.displayName="SheetContent";const g=r.forwardRef(({className:e,...t},a)=>s.jsx("div",{ref:a,className:i.cn("flex flex-col gap-2 text-center sm:text-left",e),"data-slot":"sheet-header",...t}));g.displayName="SheetHeader";const x=r.forwardRef(({className:e,...t},a)=>s.jsx("div",{ref:a,className:i.cn("mt-auto flex flex-col gap-2 sm:flex-row sm:justify-end",e),"data-slot":"sheet-footer",...t}));x.displayName="SheetFooter";const S=r.forwardRef(({className:e,icon:t,children:a,...n},l)=>s.jsxs(o.Title,{ref:l,className:i.cn("text-foreground text-lg font-semibold",t&&"flex items-center gap-2",e),"data-slot":"sheet-title",...n,children:[t&&s.jsx("span",{className:"shrink-0 [&_svg]:size-5","data-slot":"sheet-title-icon",children:t}),a]}));S.displayName="SheetTitle";const y=r.forwardRef(({className:e,...t},a)=>s.jsx(o.Description,{ref:a,className:i.cn("text-muted-foreground text-sm",e),"data-slot":"sheet-description",...t}));y.displayName="SheetDescription";exports.Sheet=f;exports.SheetClose=m;exports.SheetContent=p;exports.SheetDescription=y;exports.SheetFooter=x;exports.SheetHeader=g;exports.SheetOverlay=c;exports.SheetPortal=d;exports.SheetTitle=S;exports.SheetTrigger=u;
|
package/dist/sheet.d.ts
CHANGED
|
@@ -94,16 +94,27 @@ declare const SheetHeader: React.ForwardRefExoticComponent<Omit<React.DetailedHT
|
|
|
94
94
|
* Stacks buttons on mobile, aligns to end on larger screens.
|
|
95
95
|
*/
|
|
96
96
|
declare const SheetFooter: React.ForwardRefExoticComponent<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & React.RefAttributes<HTMLDivElement>>;
|
|
97
|
+
/**
|
|
98
|
+
* Props for the SheetTitle component
|
|
99
|
+
*/
|
|
100
|
+
interface SheetTitleProps extends React.ComponentProps<typeof SheetPrimitive.Title> {
|
|
101
|
+
/**
|
|
102
|
+
* Optional icon rendered before the title text.
|
|
103
|
+
* Pass any React node (typically a DS icon component).
|
|
104
|
+
* @example <SheetTitle icon={<Heart />}>Title</SheetTitle>
|
|
105
|
+
*/
|
|
106
|
+
icon?: React.ReactNode;
|
|
107
|
+
}
|
|
97
108
|
/**
|
|
98
109
|
* Sheet title component for the main heading.
|
|
99
110
|
* Should be used within SheetHeader.
|
|
100
111
|
*/
|
|
101
|
-
declare const SheetTitle: React.ForwardRefExoticComponent<Omit<
|
|
112
|
+
declare const SheetTitle: React.ForwardRefExoticComponent<Omit<SheetTitleProps, "ref"> & React.RefAttributes<HTMLHeadingElement>>;
|
|
102
113
|
/**
|
|
103
114
|
* Sheet description component for additional context.
|
|
104
115
|
* Should be used within SheetHeader below SheetTitle.
|
|
105
116
|
*/
|
|
106
117
|
declare const SheetDescription: React.ForwardRefExoticComponent<Omit<SheetPrimitive.DialogDescriptionProps & React.RefAttributes<HTMLParagraphElement>, "ref"> & React.RefAttributes<HTMLParagraphElement>>;
|
|
107
118
|
export { Sheet, SheetClose, SheetContent, SheetDescription, SheetFooter, SheetHeader, SheetOverlay, SheetPortal, SheetTitle, SheetTrigger, };
|
|
108
|
-
export type { SheetContentProps, SheetTriggerProps };
|
|
119
|
+
export type { SheetContentProps, SheetTitleProps, SheetTriggerProps };
|
|
109
120
|
//# sourceMappingURL=sheet.d.ts.map
|
package/dist/sheet.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sheet.d.ts","sourceRoot":"","sources":["../../src/components/sheet.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,cAAc,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAO,KAAK,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAKlE;;;;;;GAMG;AACH,MAAM,MAAM,SAAS,GAAG,KAAK,GAAG,OAAO,GAAG,QAAQ,GAAG,MAAM,CAAC;AAE5D,QAAA,MAAM,oBAAoB;;8EA8DzB,CAAC;AAEF;;;GAGG;AACH,iBAAS,KAAK,CAAC,EAAE,GAAG,KAAK,EAAE,EAAE,KAAK,CAAC,cAAc,CAAC,OAAO,cAAc,CAAC,IAAI,CAAC,2CAE5E;kBAFQ,KAAK;;;AAKd;;GAEG;AACH,UAAU,iBAAkB,SAAQ,KAAK,CAAC,cAAc,CACtD,OAAO,cAAc,CAAC,OAAO,CAC9B;IACC;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED;;;GAGG;AACH,QAAA,MAAM,YAAY,0GAUhB,CAAC;AAGH;;;GAGG;AACH,QAAA,MAAM,UAAU,iKAKd,CAAC;AAGH;;;GAGG;AACH,iBAAS,WAAW,CAAC,EACnB,GAAG,KAAK,EACT,EAAE,KAAK,CAAC,cAAc,CAAC,OAAO,cAAc,CAAC,MAAM,CAAC,2CAEpD;kBAJQ,WAAW;;;AAOpB;;;GAGG;AACH,QAAA,MAAM,YAAY,6JAahB,CAAC;AAGH;;GAEG;AACH,UAAU,iBACR,SACE,KAAK,CAAC,cAAc,CAAC,OAAO,cAAc,CAAC,OAAO,CAAC,EACnD,YAAY,CAAC,OAAO,oBAAoB,CAAC;IAC3C;;;OAGG;IACH,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;OAEG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;OAEG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB;;;OAGG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED;;;GAGG;AACH,QAAA,MAAM,YAAY,uGAsCjB,CAAC;AAGF;;;GAGG;AACH,QAAA,MAAM,WAAW,mKAUf,CAAC;AAGH;;;GAGG;AACH,QAAA,MAAM,WAAW,mKAaf,CAAC;AAGH;;;GAGG;AACH,QAAA,MAAM,UAAU,
|
|
1
|
+
{"version":3,"file":"sheet.d.ts","sourceRoot":"","sources":["../../src/components/sheet.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,cAAc,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAO,KAAK,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAKlE;;;;;;GAMG;AACH,MAAM,MAAM,SAAS,GAAG,KAAK,GAAG,OAAO,GAAG,QAAQ,GAAG,MAAM,CAAC;AAE5D,QAAA,MAAM,oBAAoB;;8EA8DzB,CAAC;AAEF;;;GAGG;AACH,iBAAS,KAAK,CAAC,EAAE,GAAG,KAAK,EAAE,EAAE,KAAK,CAAC,cAAc,CAAC,OAAO,cAAc,CAAC,IAAI,CAAC,2CAE5E;kBAFQ,KAAK;;;AAKd;;GAEG;AACH,UAAU,iBAAkB,SAAQ,KAAK,CAAC,cAAc,CACtD,OAAO,cAAc,CAAC,OAAO,CAC9B;IACC;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED;;;GAGG;AACH,QAAA,MAAM,YAAY,0GAUhB,CAAC;AAGH;;;GAGG;AACH,QAAA,MAAM,UAAU,iKAKd,CAAC;AAGH;;;GAGG;AACH,iBAAS,WAAW,CAAC,EACnB,GAAG,KAAK,EACT,EAAE,KAAK,CAAC,cAAc,CAAC,OAAO,cAAc,CAAC,MAAM,CAAC,2CAEpD;kBAJQ,WAAW;;;AAOpB;;;GAGG;AACH,QAAA,MAAM,YAAY,6JAahB,CAAC;AAGH;;GAEG;AACH,UAAU,iBACR,SACE,KAAK,CAAC,cAAc,CAAC,OAAO,cAAc,CAAC,OAAO,CAAC,EACnD,YAAY,CAAC,OAAO,oBAAoB,CAAC;IAC3C;;;OAGG;IACH,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;OAEG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;OAEG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB;;;OAGG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED;;;GAGG;AACH,QAAA,MAAM,YAAY,uGAsCjB,CAAC;AAGF;;;GAGG;AACH,QAAA,MAAM,WAAW,mKAUf,CAAC;AAGH;;;GAGG;AACH,QAAA,MAAM,WAAW,mKAaf,CAAC;AAGH;;GAEG;AACH,UAAU,eAAgB,SAAQ,KAAK,CAAC,cAAc,CACpD,OAAO,cAAc,CAAC,KAAK,CAC5B;IACC;;;;OAIG;IACH,IAAI,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;CACxB;AAED;;;GAGG;AACH,QAAA,MAAM,UAAU,yGAqBd,CAAC;AAGH;;;GAGG;AACH,QAAA,MAAM,gBAAgB,6KAUpB,CAAC;AAGH,OAAO,EACL,KAAK,EACL,UAAU,EACV,YAAY,EACZ,gBAAgB,EAChB,WAAW,EACX,WAAW,EACX,YAAY,EACZ,WAAW,EACX,UAAU,EACV,YAAY,GACb,CAAC;AAEF,YAAY,EAAE,iBAAiB,EAAE,eAAe,EAAE,iBAAiB,EAAE,CAAC"}
|
package/dist/sheet.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { jsx as o, jsxs as
|
|
1
|
+
import { jsx as o, jsxs as d } from "react/jsx-runtime";
|
|
2
2
|
import * as r from "react";
|
|
3
3
|
import * as s from "@radix-ui/react-dialog";
|
|
4
4
|
import { cva as u } from "class-variance-authority";
|
|
5
5
|
import { X as x } from "@brightlocal/icons";
|
|
6
|
-
import { cn as
|
|
6
|
+
import { cn as i } from "@brightlocal/ui-components/lib/utils";
|
|
7
7
|
const y = u(
|
|
8
8
|
[
|
|
9
9
|
"bg-background",
|
|
@@ -83,17 +83,17 @@ const b = r.forwardRef(({ dataHook: t, ...e }, a) => /* @__PURE__ */ o(
|
|
|
83
83
|
b.displayName = "SheetTrigger";
|
|
84
84
|
const N = r.forwardRef(({ ...t }, e) => /* @__PURE__ */ o(s.Close, { ref: e, "data-slot": "sheet-close", ...t }));
|
|
85
85
|
N.displayName = "SheetClose";
|
|
86
|
-
function
|
|
86
|
+
function f({
|
|
87
87
|
...t
|
|
88
88
|
}) {
|
|
89
89
|
return /* @__PURE__ */ o(s.Portal, { "data-slot": "sheet-portal", ...t });
|
|
90
90
|
}
|
|
91
|
-
|
|
92
|
-
const
|
|
91
|
+
f.displayName = "SheetPortal";
|
|
92
|
+
const c = r.forwardRef(({ className: t, ...e }, a) => /* @__PURE__ */ o(
|
|
93
93
|
s.Overlay,
|
|
94
94
|
{
|
|
95
95
|
ref: a,
|
|
96
|
-
className:
|
|
96
|
+
className: i(
|
|
97
97
|
"data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-black/50",
|
|
98
98
|
t
|
|
99
99
|
),
|
|
@@ -101,32 +101,32 @@ const l = r.forwardRef(({ className: t, ...e }, a) => /* @__PURE__ */ o(
|
|
|
101
101
|
...e
|
|
102
102
|
}
|
|
103
103
|
));
|
|
104
|
-
|
|
104
|
+
c.displayName = "SheetOverlay";
|
|
105
105
|
const v = r.forwardRef(
|
|
106
106
|
({
|
|
107
107
|
className: t,
|
|
108
108
|
children: e,
|
|
109
109
|
side: a,
|
|
110
|
-
dataHook:
|
|
111
|
-
trackingEl:
|
|
110
|
+
dataHook: l,
|
|
111
|
+
trackingEl: n,
|
|
112
112
|
trackingLabel: m,
|
|
113
113
|
closeLabel: h,
|
|
114
114
|
...p
|
|
115
|
-
}, g) => /* @__PURE__ */
|
|
116
|
-
/* @__PURE__ */ o(
|
|
117
|
-
/* @__PURE__ */
|
|
115
|
+
}, g) => /* @__PURE__ */ d(f, { children: [
|
|
116
|
+
/* @__PURE__ */ o(c, {}),
|
|
117
|
+
/* @__PURE__ */ d(
|
|
118
118
|
s.Content,
|
|
119
119
|
{
|
|
120
120
|
ref: g,
|
|
121
|
-
className:
|
|
122
|
-
"data-hook":
|
|
121
|
+
className: i(y({ side: a }), t),
|
|
122
|
+
"data-hook": l,
|
|
123
123
|
"data-slot": "sheet-content",
|
|
124
|
-
"data-tracking-el":
|
|
124
|
+
"data-tracking-el": n,
|
|
125
125
|
"data-tracking-label": m,
|
|
126
126
|
...p,
|
|
127
127
|
children: [
|
|
128
128
|
e,
|
|
129
|
-
/* @__PURE__ */
|
|
129
|
+
/* @__PURE__ */ d(s.Close, { className: "ring-offset-background focus:ring-ring data-[state=open]:bg-accent data-[state=open]:text-muted-foreground absolute top-4 right-4 rounded-xs opacity-70 transition-opacity hover:opacity-100 focus:ring-2 focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none [&_svg]:pointer-events-none [&_svg]:shrink-0", children: [
|
|
130
130
|
/* @__PURE__ */ o(x, {}),
|
|
131
131
|
/* @__PURE__ */ o("span", { className: "sr-only", children: h ?? "Close" })
|
|
132
132
|
] })
|
|
@@ -140,7 +140,7 @@ const w = r.forwardRef(({ className: t, ...e }, a) => /* @__PURE__ */ o(
|
|
|
140
140
|
"div",
|
|
141
141
|
{
|
|
142
142
|
ref: a,
|
|
143
|
-
className:
|
|
143
|
+
className: i("flex flex-col gap-2 text-center sm:text-left", t),
|
|
144
144
|
"data-slot": "sheet-header",
|
|
145
145
|
...e
|
|
146
146
|
}
|
|
@@ -150,7 +150,7 @@ const R = r.forwardRef(({ className: t, ...e }, a) => /* @__PURE__ */ o(
|
|
|
150
150
|
"div",
|
|
151
151
|
{
|
|
152
152
|
ref: a,
|
|
153
|
-
className:
|
|
153
|
+
className: i(
|
|
154
154
|
"mt-auto flex flex-col gap-2 sm:flex-row sm:justify-end",
|
|
155
155
|
t
|
|
156
156
|
),
|
|
@@ -159,35 +159,43 @@ const R = r.forwardRef(({ className: t, ...e }, a) => /* @__PURE__ */ o(
|
|
|
159
159
|
}
|
|
160
160
|
));
|
|
161
161
|
R.displayName = "SheetFooter";
|
|
162
|
-
const
|
|
162
|
+
const k = r.forwardRef(({ className: t, icon: e, children: a, ...l }, n) => /* @__PURE__ */ d(
|
|
163
163
|
s.Title,
|
|
164
164
|
{
|
|
165
|
-
ref:
|
|
166
|
-
className:
|
|
165
|
+
ref: n,
|
|
166
|
+
className: i(
|
|
167
|
+
"text-foreground text-lg font-semibold",
|
|
168
|
+
e && "flex items-center gap-2",
|
|
169
|
+
t
|
|
170
|
+
),
|
|
167
171
|
"data-slot": "sheet-title",
|
|
168
|
-
...
|
|
172
|
+
...l,
|
|
173
|
+
children: [
|
|
174
|
+
e && /* @__PURE__ */ o("span", { className: "shrink-0 [&_svg]:size-5", "data-slot": "sheet-title-icon", children: e }),
|
|
175
|
+
a
|
|
176
|
+
]
|
|
169
177
|
}
|
|
170
178
|
));
|
|
171
|
-
|
|
172
|
-
const
|
|
179
|
+
k.displayName = "SheetTitle";
|
|
180
|
+
const C = r.forwardRef(({ className: t, ...e }, a) => /* @__PURE__ */ o(
|
|
173
181
|
s.Description,
|
|
174
182
|
{
|
|
175
183
|
ref: a,
|
|
176
|
-
className:
|
|
184
|
+
className: i("text-muted-foreground text-sm", t),
|
|
177
185
|
"data-slot": "sheet-description",
|
|
178
186
|
...e
|
|
179
187
|
}
|
|
180
188
|
));
|
|
181
|
-
|
|
189
|
+
C.displayName = "SheetDescription";
|
|
182
190
|
export {
|
|
183
191
|
S as Sheet,
|
|
184
192
|
N as SheetClose,
|
|
185
193
|
v as SheetContent,
|
|
186
|
-
|
|
194
|
+
C as SheetDescription,
|
|
187
195
|
R as SheetFooter,
|
|
188
196
|
w as SheetHeader,
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
197
|
+
c as SheetOverlay,
|
|
198
|
+
f as SheetPortal,
|
|
199
|
+
k as SheetTitle,
|
|
192
200
|
b as SheetTrigger
|
|
193
201
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@brightlocal/ui-components",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.17.1",
|
|
4
4
|
"description": "BrightLocal Design System UI Components",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"private": false,
|
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
"README.md",
|
|
17
17
|
"AI_USAGE.md",
|
|
18
18
|
"component-meta.json",
|
|
19
|
+
"deprecations.json",
|
|
19
20
|
"LICENSE",
|
|
20
21
|
"package.json"
|
|
21
22
|
],
|
|
@@ -153,13 +154,13 @@
|
|
|
153
154
|
},
|
|
154
155
|
"dependencies": {
|
|
155
156
|
"@radix-ui/react-accordion": "^1.2.12",
|
|
156
|
-
"@radix-ui/react-alert-dialog": "^1.1.
|
|
157
|
+
"@radix-ui/react-alert-dialog": "^1.1.17",
|
|
157
158
|
"@radix-ui/react-aspect-ratio": "^1.1.8",
|
|
158
159
|
"@radix-ui/react-avatar": "^1.1.11",
|
|
159
160
|
"@radix-ui/react-checkbox": "^1.3.3",
|
|
160
161
|
"@radix-ui/react-collapsible": "^1.1.12",
|
|
161
162
|
"@radix-ui/react-context-menu": "^2.2.16",
|
|
162
|
-
"@radix-ui/react-dialog": "^1.1.
|
|
163
|
+
"@radix-ui/react-dialog": "^1.1.17",
|
|
163
164
|
"@radix-ui/react-dropdown-menu": "^2.1.16",
|
|
164
165
|
"@radix-ui/react-hover-card": "^1.1.15",
|
|
165
166
|
"@radix-ui/react-label": "^2.1.8",
|
|
@@ -194,8 +195,8 @@
|
|
|
194
195
|
"sonner": "^2.0.7",
|
|
195
196
|
"tailwind-merge": "^3.4.0",
|
|
196
197
|
"vaul": "^1.1.2",
|
|
197
|
-
"@brightlocal/
|
|
198
|
-
"@brightlocal/
|
|
198
|
+
"@brightlocal/illustrations": "0.5.0",
|
|
199
|
+
"@brightlocal/icons": "2.3.1"
|
|
199
200
|
},
|
|
200
201
|
"size-limit": [
|
|
201
202
|
{
|
|
@@ -223,6 +224,8 @@
|
|
|
223
224
|
"build:browser": "vite build --config vite.config.browser.ts && node scripts/audit-browser-demos.mjs",
|
|
224
225
|
"size": "size-limit",
|
|
225
226
|
"analyze": "vite-bundle-visualizer",
|
|
227
|
+
"deprecations:list": "node scripts/deprecations-list.mjs",
|
|
228
|
+
"deprecations:clear": "node scripts/deprecations-clear.mjs",
|
|
226
229
|
"sync-meta": "node scripts/sync-component-meta.mjs",
|
|
227
230
|
"sync-meta:check": "node scripts/sync-component-meta.mjs --check",
|
|
228
231
|
"audit-demos": "node scripts/audit-browser-demos.mjs",
|
package/src/components/chart.tsx
CHANGED
|
@@ -57,6 +57,32 @@ interface ChartContainerProps
|
|
|
57
57
|
* Data hook for automated testing (required)
|
|
58
58
|
*/
|
|
59
59
|
dataHook: string;
|
|
60
|
+
/**
|
|
61
|
+
* Width of the chart's ResponsiveContainer.
|
|
62
|
+
* A number (px) skips responsive measurement and avoids the initial -1 warning.
|
|
63
|
+
* A percent string (e.g. "50%") keeps responsive behaviour within that fraction.
|
|
64
|
+
* @default "100%"
|
|
65
|
+
*/
|
|
66
|
+
width?: number | `${number}%`;
|
|
67
|
+
/**
|
|
68
|
+
* Height of the chart's ResponsiveContainer.
|
|
69
|
+
* A number (px) skips responsive measurement and avoids the initial -1 warning.
|
|
70
|
+
* A percent string (e.g. "50%") keeps responsive behaviour within that fraction.
|
|
71
|
+
* @default "100%"
|
|
72
|
+
*/
|
|
73
|
+
height?: number | `${number}%`;
|
|
74
|
+
/**
|
|
75
|
+
* Minimum width for the chart's ResponsiveContainer.
|
|
76
|
+
*/
|
|
77
|
+
minWidth?: number | string;
|
|
78
|
+
/**
|
|
79
|
+
* Minimum height for the chart's ResponsiveContainer.
|
|
80
|
+
*/
|
|
81
|
+
minHeight?: number | string;
|
|
82
|
+
/**
|
|
83
|
+
* Maximum height for the chart's ResponsiveContainer.
|
|
84
|
+
*/
|
|
85
|
+
maxHeight?: number;
|
|
60
86
|
/**
|
|
61
87
|
* Tracking element identifier for analytics
|
|
62
88
|
*/
|
|
@@ -79,6 +105,11 @@ const ChartContainer = React.forwardRef<HTMLDivElement, ChartContainerProps>(
|
|
|
79
105
|
children,
|
|
80
106
|
config,
|
|
81
107
|
dataHook,
|
|
108
|
+
width,
|
|
109
|
+
height,
|
|
110
|
+
minWidth,
|
|
111
|
+
minHeight,
|
|
112
|
+
maxHeight,
|
|
82
113
|
trackingEl,
|
|
83
114
|
trackingLabel,
|
|
84
115
|
...props
|
|
@@ -104,7 +135,14 @@ const ChartContainer = React.forwardRef<HTMLDivElement, ChartContainerProps>(
|
|
|
104
135
|
{...props}
|
|
105
136
|
>
|
|
106
137
|
<ChartStyle config={config} id={chartId} />
|
|
107
|
-
<RechartsPrimitive.ResponsiveContainer
|
|
138
|
+
<RechartsPrimitive.ResponsiveContainer
|
|
139
|
+
height={height ?? "100%"}
|
|
140
|
+
initialDimension={{ width: 1, height: 1 }}
|
|
141
|
+
maxHeight={maxHeight}
|
|
142
|
+
minHeight={minHeight}
|
|
143
|
+
minWidth={minWidth ?? 0}
|
|
144
|
+
width={width ?? "100%"}
|
|
145
|
+
>
|
|
108
146
|
{children}
|
|
109
147
|
</RechartsPrimitive.ResponsiveContainer>
|
|
110
148
|
</div>
|
package/src/components/field.tsx
CHANGED
|
@@ -71,6 +71,8 @@ const fieldVariants = cva(
|
|
|
71
71
|
"[[data-slot=radio-group]_&]:relative [[data-slot=radio-group]_&]:cursor-pointer [[data-slot=radio-group]_&]:gap-3 [[data-slot=radio-group]_&]:has-[[data-disabled]]:cursor-not-allowed",
|
|
72
72
|
// RadioGroup context: label overlay spans the full Field for clickable row
|
|
73
73
|
"[[data-slot=radio-group]_&_[data-slot=field-label]]:after:absolute [[data-slot=radio-group]_&_[data-slot=field-label]]:after:inset-0 [[data-slot=radio-group]_&_[data-slot=field-label]]:after:cursor-pointer [[data-slot=radio-group]_&:has([data-disabled])_[data-slot=field-label]]:after:cursor-not-allowed",
|
|
74
|
+
// Checkbox context: match RadioGroup gap-3 spacing
|
|
75
|
+
"has-[>[role=checkbox]]:gap-3",
|
|
74
76
|
// Label leading overrides: use leading-normal for wrap-capable labels (checkbox)
|
|
75
77
|
"has-[>[role=checkbox]]:[&_[data-slot=field-label]]:leading-normal",
|
|
76
78
|
],
|
|
@@ -146,7 +146,10 @@ const GlobalLayoutContent = React.forwardRef<
|
|
|
146
146
|
return (
|
|
147
147
|
<div
|
|
148
148
|
ref={ref}
|
|
149
|
-
className={cn(
|
|
149
|
+
className={cn(
|
|
150
|
+
"px-section-xs flex min-w-0 flex-1 flex-col gap-6",
|
|
151
|
+
className
|
|
152
|
+
)}
|
|
150
153
|
data-hook={dataHook}
|
|
151
154
|
data-slot="content-wrapper"
|
|
152
155
|
style={
|
|
@@ -188,7 +191,10 @@ const GlobalLayoutContentHeader = React.forwardRef<
|
|
|
188
191
|
return (
|
|
189
192
|
<Header
|
|
190
193
|
ref={ref}
|
|
191
|
-
className={cn(
|
|
194
|
+
className={cn(
|
|
195
|
+
"mx-auto w-full flex-wrap justify-between gap-4",
|
|
196
|
+
className
|
|
197
|
+
)}
|
|
192
198
|
data-slot="content-header"
|
|
193
199
|
dataHook={dataHook}
|
|
194
200
|
style={{ maxWidth: "var(--ds-breakpoint-lg)" }}
|
|
@@ -204,6 +210,51 @@ const GlobalLayoutContentHeader = React.forwardRef<
|
|
|
204
210
|
|
|
205
211
|
GlobalLayoutContentHeader.displayName = "GlobalLayoutContentHeader";
|
|
206
212
|
|
|
213
|
+
interface GlobalLayoutContentActionsProps extends React.ComponentProps<"div"> {
|
|
214
|
+
/**
|
|
215
|
+
* Data hook for automated testing (required)
|
|
216
|
+
*/
|
|
217
|
+
dataHook: string;
|
|
218
|
+
/**
|
|
219
|
+
* Tracking element identifier for analytics
|
|
220
|
+
*/
|
|
221
|
+
trackingEl?: string;
|
|
222
|
+
/**
|
|
223
|
+
* Tracking label for analytics context
|
|
224
|
+
*/
|
|
225
|
+
trackingLabel?: string;
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
const GlobalLayoutContentActions = React.forwardRef<
|
|
229
|
+
HTMLDivElement,
|
|
230
|
+
GlobalLayoutContentActionsProps
|
|
231
|
+
>(
|
|
232
|
+
(
|
|
233
|
+
{ className, dataHook, trackingEl, trackingLabel, children, ...props },
|
|
234
|
+
ref
|
|
235
|
+
) => {
|
|
236
|
+
return (
|
|
237
|
+
<div
|
|
238
|
+
ref={ref}
|
|
239
|
+
className={cn(
|
|
240
|
+
"mx-auto hidden w-full items-center justify-end gap-2 lg:flex",
|
|
241
|
+
className
|
|
242
|
+
)}
|
|
243
|
+
data-hook={dataHook}
|
|
244
|
+
data-slot="content-actions"
|
|
245
|
+
data-tracking-el={trackingEl}
|
|
246
|
+
data-tracking-label={trackingLabel}
|
|
247
|
+
style={{ maxWidth: "var(--ds-breakpoint-lg)" }}
|
|
248
|
+
{...props}
|
|
249
|
+
>
|
|
250
|
+
{children}
|
|
251
|
+
</div>
|
|
252
|
+
);
|
|
253
|
+
}
|
|
254
|
+
);
|
|
255
|
+
|
|
256
|
+
GlobalLayoutContentActions.displayName = "GlobalLayoutContentActions";
|
|
257
|
+
|
|
207
258
|
interface GlobalLayoutContentBodyProps extends React.ComponentProps<"div"> {
|
|
208
259
|
/**
|
|
209
260
|
* Data hook for automated testing
|
|
@@ -230,10 +281,7 @@ const GlobalLayoutContentBody = React.forwardRef<
|
|
|
230
281
|
return (
|
|
231
282
|
<div
|
|
232
283
|
ref={ref}
|
|
233
|
-
className={cn(
|
|
234
|
-
"mx-auto mt-6 flex w-full flex-1 flex-col gap-6",
|
|
235
|
-
className
|
|
236
|
-
)}
|
|
284
|
+
className={cn("mx-auto flex w-full flex-1 flex-col gap-6", className)}
|
|
237
285
|
data-hook={dataHook}
|
|
238
286
|
data-slot="content-body"
|
|
239
287
|
data-tracking-el={trackingEl}
|
|
@@ -312,6 +360,7 @@ export {
|
|
|
312
360
|
GlobalLayout,
|
|
313
361
|
GlobalLayoutSidebar,
|
|
314
362
|
GlobalLayoutContent,
|
|
363
|
+
GlobalLayoutContentActions,
|
|
315
364
|
GlobalLayoutContentHeader,
|
|
316
365
|
GlobalLayoutContentBody,
|
|
317
366
|
GlobalLayoutMobileHeader,
|
|
@@ -321,6 +370,7 @@ export type {
|
|
|
321
370
|
GlobalLayoutProps,
|
|
322
371
|
GlobalLayoutSidebarProps,
|
|
323
372
|
GlobalLayoutContentProps,
|
|
373
|
+
GlobalLayoutContentActionsProps,
|
|
324
374
|
GlobalLayoutContentHeaderProps,
|
|
325
375
|
GlobalLayoutContentBodyProps,
|
|
326
376
|
GlobalLayoutMobileHeaderProps,
|
|
@@ -3,6 +3,16 @@ import { StarRating } from "@brightlocal/icons";
|
|
|
3
3
|
|
|
4
4
|
import { cn } from "@brightlocal/ui-components/lib/utils";
|
|
5
5
|
|
|
6
|
+
/**
|
|
7
|
+
* Available size variants for the Rating component.
|
|
8
|
+
*/
|
|
9
|
+
type RatingSize = "sm" | "md";
|
|
10
|
+
|
|
11
|
+
const starSizeMap: Record<RatingSize, number> = {
|
|
12
|
+
sm: 16,
|
|
13
|
+
md: 24,
|
|
14
|
+
};
|
|
15
|
+
|
|
6
16
|
/**
|
|
7
17
|
* Rating component displays a star-based rating indicator.
|
|
8
18
|
* Supports full and half-star values for precise rating display.
|
|
@@ -16,6 +26,11 @@ export interface RatingProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
|
16
26
|
* Data hook for testing
|
|
17
27
|
*/
|
|
18
28
|
dataHook: string;
|
|
29
|
+
/**
|
|
30
|
+
* Size of the star icons.
|
|
31
|
+
* @default "sm"
|
|
32
|
+
*/
|
|
33
|
+
size?: RatingSize;
|
|
19
34
|
/**
|
|
20
35
|
* Accessible label for the rating.
|
|
21
36
|
* Supports `{value}` placeholder for interpolation.
|
|
@@ -37,6 +52,7 @@ const Rating = React.forwardRef<HTMLDivElement, RatingProps>(
|
|
|
37
52
|
{
|
|
38
53
|
value,
|
|
39
54
|
dataHook,
|
|
55
|
+
size = "sm",
|
|
40
56
|
ariaLabel,
|
|
41
57
|
trackingEl,
|
|
42
58
|
trackingLabel,
|
|
@@ -47,6 +63,7 @@ const Rating = React.forwardRef<HTMLDivElement, RatingProps>(
|
|
|
47
63
|
) => {
|
|
48
64
|
// Clamp value between 0 and 5
|
|
49
65
|
const clampedValue = Math.max(0, Math.min(5, value));
|
|
66
|
+
const starSize = starSizeMap[size];
|
|
50
67
|
|
|
51
68
|
return (
|
|
52
69
|
<div
|
|
@@ -80,6 +97,7 @@ const Rating = React.forwardRef<HTMLDivElement, RatingProps>(
|
|
|
80
97
|
<StarRating
|
|
81
98
|
className="fill-muted stroke-muted"
|
|
82
99
|
data-slot="rating-star-base"
|
|
100
|
+
size={starSize}
|
|
83
101
|
/>
|
|
84
102
|
|
|
85
103
|
{/* Filled overlay */}
|
|
@@ -92,7 +110,10 @@ const Rating = React.forwardRef<HTMLDivElement, RatingProps>(
|
|
|
92
110
|
width: `${fillPercentage}%`,
|
|
93
111
|
}}
|
|
94
112
|
>
|
|
95
|
-
<StarRating
|
|
113
|
+
<StarRating
|
|
114
|
+
className="fill-yellow-400 stroke-yellow-400"
|
|
115
|
+
size={starSize}
|
|
116
|
+
/>
|
|
96
117
|
</div>
|
|
97
118
|
)}
|
|
98
119
|
</div>
|
|
@@ -106,3 +127,4 @@ const Rating = React.forwardRef<HTMLDivElement, RatingProps>(
|
|
|
106
127
|
Rating.displayName = "Rating";
|
|
107
128
|
|
|
108
129
|
export { Rating };
|
|
130
|
+
export type { RatingSize };
|