@brightlocal/ui-components 2.17.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 +1 -1
- package/dist/rating.cjs +1 -1
- package/dist/rating.d.ts.map +1 -1
- package/dist/rating.js +27 -21
- package/package.json +3 -3
- package/src/components/rating.tsx +4 -1
package/component-meta.json
CHANGED
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.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;;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,
|
|
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,46 +1,46 @@
|
|
|
1
|
-
import { jsx as e, jsxs as
|
|
1
|
+
import { jsx as e, jsxs as y } from "react/jsx-runtime";
|
|
2
2
|
import * as N from "react";
|
|
3
3
|
import { StarRating as o } from "@brightlocal/icons";
|
|
4
|
-
import { cn as
|
|
5
|
-
const
|
|
4
|
+
import { cn as R } from "@brightlocal/ui-components/lib/utils";
|
|
5
|
+
const k = {
|
|
6
6
|
sm: 16,
|
|
7
7
|
md: 24
|
|
8
|
-
},
|
|
8
|
+
}, w = N.forwardRef(
|
|
9
9
|
({
|
|
10
10
|
value: n,
|
|
11
|
-
dataHook:
|
|
12
|
-
size:
|
|
13
|
-
ariaLabel:
|
|
14
|
-
trackingEl:
|
|
11
|
+
dataHook: m,
|
|
12
|
+
size: c = "sm",
|
|
13
|
+
ariaLabel: l,
|
|
14
|
+
trackingEl: d,
|
|
15
15
|
trackingLabel: g,
|
|
16
16
|
className: f,
|
|
17
17
|
...p
|
|
18
18
|
}, u) => {
|
|
19
|
-
const a = Math.max(0, Math.min(5, n)),
|
|
19
|
+
const a = Math.max(0, Math.min(5, n)), r = k[c];
|
|
20
20
|
return /* @__PURE__ */ e(
|
|
21
21
|
"div",
|
|
22
22
|
{
|
|
23
23
|
ref: u,
|
|
24
|
-
"aria-label":
|
|
25
|
-
className:
|
|
26
|
-
"data-hook":
|
|
24
|
+
"aria-label": l ? l.replace("{value}", String(a)) : `Rating: ${a} out of 5 stars`,
|
|
25
|
+
className: R("flex items-center gap-0.5", f),
|
|
26
|
+
"data-hook": m,
|
|
27
27
|
"data-slot": "rating",
|
|
28
|
-
"data-tracking-el":
|
|
28
|
+
"data-tracking-el": d,
|
|
29
29
|
"data-tracking-label": g,
|
|
30
30
|
role: "img",
|
|
31
31
|
...p,
|
|
32
|
-
children: [...Array(5)].map((
|
|
33
|
-
const h = t + 1,
|
|
34
|
-
return /* @__PURE__ */
|
|
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
35
|
/* @__PURE__ */ e(
|
|
36
36
|
o,
|
|
37
37
|
{
|
|
38
38
|
className: "fill-muted stroke-muted",
|
|
39
39
|
"data-slot": "rating-star-base",
|
|
40
|
-
size:
|
|
40
|
+
size: r
|
|
41
41
|
}
|
|
42
42
|
),
|
|
43
|
-
(
|
|
43
|
+
(s || i) && /* @__PURE__ */ e(
|
|
44
44
|
"div",
|
|
45
45
|
{
|
|
46
46
|
"aria-hidden": "true",
|
|
@@ -49,7 +49,13 @@ const y = {
|
|
|
49
49
|
style: {
|
|
50
50
|
width: `${v}%`
|
|
51
51
|
},
|
|
52
|
-
children: /* @__PURE__ */ e(
|
|
52
|
+
children: /* @__PURE__ */ e(
|
|
53
|
+
o,
|
|
54
|
+
{
|
|
55
|
+
className: "fill-yellow-400 stroke-yellow-400",
|
|
56
|
+
size: r
|
|
57
|
+
}
|
|
58
|
+
)
|
|
53
59
|
}
|
|
54
60
|
)
|
|
55
61
|
] }, t);
|
|
@@ -58,7 +64,7 @@ const y = {
|
|
|
58
64
|
);
|
|
59
65
|
}
|
|
60
66
|
);
|
|
61
|
-
|
|
67
|
+
w.displayName = "Rating";
|
|
62
68
|
export {
|
|
63
|
-
|
|
69
|
+
w as Rating
|
|
64
70
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@brightlocal/ui-components",
|
|
3
|
-
"version": "2.17.
|
|
3
|
+
"version": "2.17.1",
|
|
4
4
|
"description": "BrightLocal Design System UI Components",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"private": false,
|
|
@@ -195,8 +195,8 @@
|
|
|
195
195
|
"sonner": "^2.0.7",
|
|
196
196
|
"tailwind-merge": "^3.4.0",
|
|
197
197
|
"vaul": "^1.1.2",
|
|
198
|
-
"@brightlocal/
|
|
199
|
-
"@brightlocal/
|
|
198
|
+
"@brightlocal/illustrations": "0.5.0",
|
|
199
|
+
"@brightlocal/icons": "2.3.1"
|
|
200
200
|
},
|
|
201
201
|
"size-limit": [
|
|
202
202
|
{
|
|
@@ -110,7 +110,10 @@ const Rating = React.forwardRef<HTMLDivElement, RatingProps>(
|
|
|
110
110
|
width: `${fillPercentage}%`,
|
|
111
111
|
}}
|
|
112
112
|
>
|
|
113
|
-
<StarRating
|
|
113
|
+
<StarRating
|
|
114
|
+
className="fill-yellow-400 stroke-yellow-400"
|
|
115
|
+
size={starSize}
|
|
116
|
+
/>
|
|
114
117
|
</div>
|
|
115
118
|
)}
|
|
116
119
|
</div>
|