@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.
- package/README.md +2 -1
- package/component-meta.json +90 -19
- package/deprecations.json +113 -3
- package/dist/accordion.cjs +1 -1
- package/dist/accordion.d.ts +36 -0
- package/dist/accordion.d.ts.map +1 -1
- package/dist/accordion.js +74 -61
- package/dist/blocks/empty-state.cjs +1 -1
- package/dist/blocks/empty-state.d.ts.map +1 -1
- package/dist/blocks/empty-state.js +41 -49
- package/dist/button-group.cjs +1 -0
- package/dist/button-group.d.ts +36 -0
- package/dist/button-group.d.ts.map +1 -0
- package/dist/button-group.js +47 -0
- package/dist/button.cjs +1 -1
- package/dist/button.js +1 -1
- package/dist/card.cjs +1 -1
- package/dist/card.d.ts +20 -2
- package/dist/card.d.ts.map +1 -1
- package/dist/card.js +83 -75
- package/dist/chart.cjs +2 -2
- package/dist/chart.d.ts +40 -12
- package/dist/chart.d.ts.map +1 -1
- package/dist/chart.js +86 -71
- package/dist/chip.cjs +1 -1
- package/dist/chip.d.ts +38 -4
- package/dist/chip.d.ts.map +1 -1
- package/dist/chip.js +95 -81
- package/dist/command.cjs +1 -1
- package/dist/command.d.ts +23 -1
- package/dist/command.d.ts.map +1 -1
- package/dist/command.js +250 -224
- package/dist/data-table.cjs +1 -1
- package/dist/data-table.d.ts +32 -1
- package/dist/data-table.d.ts.map +1 -1
- package/dist/data-table.js +340 -330
- package/dist/date-picker.cjs +1 -1
- package/dist/date-picker.d.ts +13 -5
- package/dist/date-picker.d.ts.map +1 -1
- package/dist/date-picker.js +54 -53
- package/dist/field.cjs +1 -1
- package/dist/field.d.ts +8 -1
- package/dist/field.d.ts.map +1 -1
- package/dist/field.js +79 -52
- package/dist/global-layout.cjs +1 -1
- package/dist/global-layout.d.ts +105 -13
- package/dist/global-layout.d.ts.map +1 -1
- package/dist/global-layout.js +146 -129
- package/dist/grid.d.ts +2 -2
- package/dist/hooks/use-mobile.cjs +1 -0
- package/dist/hooks/use-mobile.js +8 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +547 -538
- package/dist/input-password.cjs +1 -1
- package/dist/input-password.d.ts +17 -9
- package/dist/input-password.d.ts.map +1 -1
- package/dist/input-password.js +26 -25
- package/dist/lib/empty-chip.cjs +1 -0
- package/dist/lib/empty-chip.d.ts +4 -0
- package/dist/lib/empty-chip.d.ts.map +1 -0
- package/dist/lib/empty-chip.js +13 -0
- package/dist/pagination.cjs +1 -1
- package/dist/pagination.d.ts +3 -0
- package/dist/pagination.d.ts.map +1 -1
- package/dist/pagination.js +57 -57
- package/dist/scroll-area.cjs +1 -1
- package/dist/scroll-area.d.ts +15 -6
- package/dist/scroll-area.d.ts.map +1 -1
- package/dist/scroll-area.js +38 -36
- package/dist/select.cjs +2 -2
- package/dist/select.d.ts +13 -2
- package/dist/select.d.ts.map +1 -1
- package/dist/select.js +87 -83
- package/dist/typography-heading.cjs +1 -1
- package/dist/typography-heading.d.ts +13 -0
- package/dist/typography-heading.d.ts.map +1 -1
- package/dist/typography-heading.js +32 -21
- package/dist/typography-text.cjs +1 -1
- package/dist/typography-text.d.ts +14 -0
- package/dist/typography-text.d.ts.map +1 -1
- package/dist/typography-text.js +35 -24
- package/package.json +1 -1
- package/src/blocks/empty-state.tsx +9 -21
- package/src/components/accordion.tsx +82 -27
- package/src/components/button-group.tsx +112 -0
- package/src/components/button.tsx +1 -1
- package/src/components/card.tsx +38 -3
- package/src/components/chart.tsx +63 -18
- package/src/components/chip.tsx +83 -10
- package/src/components/command.tsx +55 -3
- package/src/components/data-table.tsx +67 -7
- package/src/components/date-picker.tsx +18 -7
- package/src/components/field.tsx +81 -12
- package/src/components/global-layout.tsx +176 -38
- package/src/components/grid.tsx +2 -2
- package/src/components/input-password.tsx +23 -11
- package/src/components/pagination.tsx +10 -3
- package/src/components/scroll-area.tsx +23 -10
- package/src/components/select.tsx +30 -6
- package/src/components/typography-heading.tsx +24 -0
- package/src/components/typography-text.tsx +26 -1
- package/src/index.ts +1 -0
- package/src/lib/empty-chip.ts +24 -0
package/dist/chart.js
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
import { jsxs as b, jsx as s, Fragment as S } from "react/jsx-runtime";
|
|
2
2
|
import * as k from "react";
|
|
3
3
|
import * as N from "recharts";
|
|
4
|
-
import { Area as J, AreaChart as Q, Bar as U, BarChart as Z, CartesianGrid as K, Cell as ee, Label as
|
|
4
|
+
import { Area as J, AreaChart as Q, Bar as U, BarChart as Z, CartesianGrid as K, Cell as ee, Label as te, Legend as re, Tooltip as ne, Customized as ae, LabelList as le, Line as oe, LineChart as se, Pie as ie, PieChart as ce, PolarAngleAxis as de, PolarGrid as ue, PolarRadiusAxis as he, Radar as fe, RadarChart as pe, RadialBar as me, RadialBarChart as ge, Rectangle as Ce, ReferenceLine as be, ResponsiveContainer as xe, Sector as ve, XAxis as ke, YAxis as Ne } from "recharts";
|
|
5
5
|
import { cn as p } from "@brightlocal/ui-components/lib/utils";
|
|
6
6
|
const R = k.createContext(null);
|
|
7
7
|
function P() {
|
|
8
|
-
const
|
|
9
|
-
if (!
|
|
8
|
+
const t = k.useContext(R);
|
|
9
|
+
if (!t)
|
|
10
10
|
throw new Error("useChart must be used within a <ChartContainer />");
|
|
11
|
-
return
|
|
11
|
+
return t;
|
|
12
12
|
}
|
|
13
13
|
const j = k.forwardRef(
|
|
14
14
|
({
|
|
15
|
-
id:
|
|
16
|
-
className:
|
|
15
|
+
id: t,
|
|
16
|
+
className: r,
|
|
17
17
|
children: l,
|
|
18
18
|
config: e,
|
|
19
19
|
dataHook: n,
|
|
@@ -26,14 +26,14 @@ const j = k.forwardRef(
|
|
|
26
26
|
trackingLabel: g,
|
|
27
27
|
...m
|
|
28
28
|
}, C) => {
|
|
29
|
-
const x = k.useId(), f = `chart-${
|
|
29
|
+
const x = k.useId(), f = `chart-${t || x.replace(/:/g, "")}`;
|
|
30
30
|
return /* @__PURE__ */ s(R.Provider, { value: { config: e }, children: /* @__PURE__ */ b(
|
|
31
31
|
"div",
|
|
32
32
|
{
|
|
33
33
|
ref: C,
|
|
34
34
|
className: p(
|
|
35
35
|
"[&_.recharts-cartesian-axis-tick_text]:fill-muted-foreground [&_.recharts-polar-radius-axis-tick-value]:fill-foreground [&_.recharts-cartesian-grid_line[stroke='#ccc']]:stroke-border/50 [&_.recharts-curve.recharts-tooltip-cursor]:stroke-border [&_.recharts-polar-grid_[stroke='#ccc']]:stroke-border [&_.recharts-radial-bar-background-sector]:fill-muted [&_.recharts-rectangle.recharts-tooltip-cursor]:fill-muted [&_.recharts-reference-line_[stroke='#ccc']]:stroke-border [&_.recharts-pie-sector]:stroke-background text-body-xs flex aspect-video justify-center [&_.recharts-dot[stroke='#fff']]:stroke-transparent [&_.recharts-layer]:outline-none [&_.recharts-pie-sector]:stroke-2 [&_.recharts-sector]:outline-none [&_.recharts-surface]:outline-none [&_svg_g]:outline-none [&_svg_g]:focus:outline-none",
|
|
36
|
-
|
|
36
|
+
r
|
|
37
37
|
),
|
|
38
38
|
"data-chart": f,
|
|
39
39
|
"data-hook": n,
|
|
@@ -61,8 +61,8 @@ const j = k.forwardRef(
|
|
|
61
61
|
}
|
|
62
62
|
);
|
|
63
63
|
j.displayName = "ChartContainer";
|
|
64
|
-
function T({ id:
|
|
65
|
-
const l = Object.entries(
|
|
64
|
+
function T({ id: t, config: r }) {
|
|
65
|
+
const l = Object.entries(r).filter(
|
|
66
66
|
([, e]) => e.theme || e.color
|
|
67
67
|
);
|
|
68
68
|
return l.length ? /* @__PURE__ */ s(
|
|
@@ -72,12 +72,12 @@ function T({ id: r, config: t }) {
|
|
|
72
72
|
__html: l.map(([e, n]) => {
|
|
73
73
|
const a = typeof n.color == "string" ? n.color.replace(/^hsl\((.*)\)$/, "$1") : null;
|
|
74
74
|
return a ? `
|
|
75
|
-
[data-chart=${
|
|
75
|
+
[data-chart=${t}] {
|
|
76
76
|
--color-${e}: ${a};
|
|
77
77
|
}
|
|
78
78
|
` : n.theme ? Object.entries(n.theme).map(
|
|
79
79
|
([o, d]) => `
|
|
80
|
-
.${o} [data-chart=${
|
|
80
|
+
.${o} [data-chart=${t}] {
|
|
81
81
|
--color-${e}: ${d.replace(/^hsl\((.*)\)$/, "$1")};
|
|
82
82
|
}
|
|
83
83
|
`
|
|
@@ -88,16 +88,16 @@ function T({ id: r, config: t }) {
|
|
|
88
88
|
}
|
|
89
89
|
) : null;
|
|
90
90
|
}
|
|
91
|
-
function $(
|
|
92
|
-
return
|
|
91
|
+
function $(t) {
|
|
92
|
+
return t == null || t === "" ? !1 : typeof t == "number" ? Number.isFinite(t) : !0;
|
|
93
93
|
}
|
|
94
|
-
function A({ ...
|
|
95
|
-
return /* @__PURE__ */ s(N.Tooltip, { ...
|
|
94
|
+
function A({ ...t }) {
|
|
95
|
+
return /* @__PURE__ */ s(N.Tooltip, { ...t });
|
|
96
96
|
}
|
|
97
97
|
A.displayName = "ChartTooltip";
|
|
98
98
|
function W({
|
|
99
|
-
active:
|
|
100
|
-
payload:
|
|
99
|
+
active: t,
|
|
100
|
+
payload: r,
|
|
101
101
|
className: l,
|
|
102
102
|
indicator: e = "dot",
|
|
103
103
|
hideLabel: n = !1,
|
|
@@ -111,25 +111,25 @@ function W({
|
|
|
111
111
|
labelKey: m
|
|
112
112
|
}) {
|
|
113
113
|
const { config: C } = P(), x = k.useMemo(() => {
|
|
114
|
-
if (n || !
|
|
114
|
+
if (n || !r?.length)
|
|
115
115
|
return null;
|
|
116
|
-
const [c] =
|
|
116
|
+
const [c] = r;
|
|
117
117
|
if (!c)
|
|
118
118
|
return null;
|
|
119
119
|
const L = `${m || c.dataKey || c.name || "value"}`, y = C[L], v = !m && typeof o == "string" ? C[o]?.label || o : y?.label;
|
|
120
|
-
return d ? /* @__PURE__ */ s("div", { className: p("font-medium", i), children: d(v,
|
|
120
|
+
return d ? /* @__PURE__ */ s("div", { className: p("font-medium", i), children: d(v, r) }) : v ? /* @__PURE__ */ s("div", { className: p("font-medium", i), children: v }) : null;
|
|
121
121
|
}, [
|
|
122
122
|
o,
|
|
123
123
|
d,
|
|
124
|
-
|
|
124
|
+
r,
|
|
125
125
|
n,
|
|
126
126
|
i,
|
|
127
127
|
C,
|
|
128
128
|
m
|
|
129
129
|
]);
|
|
130
|
-
if (!
|
|
130
|
+
if (!t || !r?.length)
|
|
131
131
|
return null;
|
|
132
|
-
const f =
|
|
132
|
+
const f = r.length === 1 && e !== "dot";
|
|
133
133
|
return /* @__PURE__ */ b(
|
|
134
134
|
"div",
|
|
135
135
|
{
|
|
@@ -140,7 +140,7 @@ function W({
|
|
|
140
140
|
"data-slot": "chart-tooltip-content",
|
|
141
141
|
children: [
|
|
142
142
|
f ? null : x,
|
|
143
|
-
/* @__PURE__ */ s("div", { className: "grid gap-1.5", children:
|
|
143
|
+
/* @__PURE__ */ s("div", { className: "grid gap-1.5", children: r.map((c, L) => {
|
|
144
144
|
const y = `${g || c.name || c.dataKey || "value"}`, v = C[y], _ = h || c.color || c.payload.fill || `var(--color-${y})`;
|
|
145
145
|
return /* @__PURE__ */ s(
|
|
146
146
|
"div",
|
|
@@ -149,7 +149,8 @@ function W({
|
|
|
149
149
|
"[&>svg]:text-muted-foreground flex w-full flex-wrap items-stretch gap-2",
|
|
150
150
|
e === "dot" && "items-center"
|
|
151
151
|
),
|
|
152
|
-
|
|
152
|
+
"data-slot": "chart-tooltip-item",
|
|
153
|
+
children: u && $(c.value) && c.name ? u(c.value, c.name, c, L, r) : /* @__PURE__ */ b(S, { children: [
|
|
153
154
|
v?.icon && !a ? /* @__PURE__ */ s(v.icon, { size: 10 }) : !a && /* @__PURE__ */ s(
|
|
154
155
|
"div",
|
|
155
156
|
{
|
|
@@ -169,15 +170,29 @@ function W({
|
|
|
169
170
|
"div",
|
|
170
171
|
{
|
|
171
172
|
className: p(
|
|
172
|
-
"flex flex-1 justify-between leading-none",
|
|
173
|
+
"flex flex-1 justify-between gap-2 leading-none",
|
|
173
174
|
f ? "items-end" : "items-center"
|
|
174
175
|
),
|
|
175
176
|
children: [
|
|
176
177
|
/* @__PURE__ */ b("div", { className: "grid gap-1.5", children: [
|
|
177
178
|
f ? x : null,
|
|
178
|
-
/* @__PURE__ */ s(
|
|
179
|
+
/* @__PURE__ */ s(
|
|
180
|
+
"span",
|
|
181
|
+
{
|
|
182
|
+
className: "text-muted-foreground",
|
|
183
|
+
"data-slot": "chart-tooltip-item-name",
|
|
184
|
+
children: v?.label || c.name
|
|
185
|
+
}
|
|
186
|
+
)
|
|
179
187
|
] }),
|
|
180
|
-
$(c.value) && /* @__PURE__ */ s(
|
|
188
|
+
$(c.value) && /* @__PURE__ */ s(
|
|
189
|
+
"span",
|
|
190
|
+
{
|
|
191
|
+
className: "text-foreground tabular-nums",
|
|
192
|
+
"data-slot": "chart-tooltip-item-value",
|
|
193
|
+
children: typeof c.value == "number" ? c.value.toLocaleString() : c.value
|
|
194
|
+
}
|
|
195
|
+
)
|
|
181
196
|
]
|
|
182
197
|
}
|
|
183
198
|
)
|
|
@@ -191,13 +206,13 @@ function W({
|
|
|
191
206
|
);
|
|
192
207
|
}
|
|
193
208
|
W.displayName = "ChartTooltipContent";
|
|
194
|
-
function D({ ...
|
|
195
|
-
return /* @__PURE__ */ s(N.Legend, { ...
|
|
209
|
+
function D({ ...t }) {
|
|
210
|
+
return /* @__PURE__ */ s(N.Legend, { ...t });
|
|
196
211
|
}
|
|
197
212
|
D.displayName = "ChartLegend";
|
|
198
213
|
function G({
|
|
199
|
-
className:
|
|
200
|
-
hideIcon:
|
|
214
|
+
className: t,
|
|
215
|
+
hideIcon: r = !1,
|
|
201
216
|
payload: l,
|
|
202
217
|
verticalAlign: e = "bottom",
|
|
203
218
|
nameKey: n
|
|
@@ -209,7 +224,7 @@ function G({
|
|
|
209
224
|
className: p(
|
|
210
225
|
"flex items-center justify-center gap-4",
|
|
211
226
|
e === "top" ? "pb-4" : "pt-4",
|
|
212
|
-
|
|
227
|
+
t
|
|
213
228
|
),
|
|
214
229
|
"data-slot": "chart-legend-content",
|
|
215
230
|
children: l.map((o) => {
|
|
@@ -221,7 +236,7 @@ function G({
|
|
|
221
236
|
"[&>svg]:text-muted-foreground flex items-center gap-1.5"
|
|
222
237
|
),
|
|
223
238
|
children: [
|
|
224
|
-
i?.icon && !
|
|
239
|
+
i?.icon && !r ? /* @__PURE__ */ s(i.icon, { size: 12 }) : /* @__PURE__ */ s(
|
|
225
240
|
"div",
|
|
226
241
|
{
|
|
227
242
|
className: "h-2 w-2 shrink-0 rounded-[2px]",
|
|
@@ -241,17 +256,17 @@ function G({
|
|
|
241
256
|
}
|
|
242
257
|
G.displayName = "ChartLegendContent";
|
|
243
258
|
function w({
|
|
244
|
-
colorKey:
|
|
245
|
-
color:
|
|
259
|
+
colorKey: t,
|
|
260
|
+
color: r,
|
|
246
261
|
fill: l,
|
|
247
262
|
stroke: e,
|
|
248
263
|
payload: n
|
|
249
264
|
}) {
|
|
250
|
-
return (
|
|
265
|
+
return (t && typeof n?.[t] == "string" ? n[t] : void 0) ?? r ?? l ?? e ?? "currentColor";
|
|
251
266
|
}
|
|
252
267
|
function M({
|
|
253
|
-
size:
|
|
254
|
-
custom:
|
|
268
|
+
size: t = 8,
|
|
269
|
+
custom: r = !1,
|
|
255
270
|
color: l,
|
|
256
271
|
colorKey: e,
|
|
257
272
|
cx: n,
|
|
@@ -272,21 +287,21 @@ function M({
|
|
|
272
287
|
return /* @__PURE__ */ s(
|
|
273
288
|
"circle",
|
|
274
289
|
{
|
|
275
|
-
className:
|
|
290
|
+
className: r ? "fill-background" : void 0,
|
|
276
291
|
cx: n,
|
|
277
292
|
cy: a,
|
|
278
293
|
"data-slot": "chart-dot",
|
|
279
|
-
fill:
|
|
280
|
-
r:
|
|
281
|
-
stroke:
|
|
282
|
-
strokeWidth:
|
|
294
|
+
fill: r ? void 0 : u,
|
|
295
|
+
r: t / 2,
|
|
296
|
+
stroke: r ? u : "none",
|
|
297
|
+
strokeWidth: r ? 2 : void 0
|
|
283
298
|
}
|
|
284
299
|
);
|
|
285
300
|
}
|
|
286
301
|
M.displayName = "ChartDot";
|
|
287
302
|
function z({
|
|
288
|
-
size:
|
|
289
|
-
color:
|
|
303
|
+
size: t = 6,
|
|
304
|
+
color: r,
|
|
290
305
|
colorKey: l,
|
|
291
306
|
cx: e,
|
|
292
307
|
cy: n,
|
|
@@ -298,7 +313,7 @@ function z({
|
|
|
298
313
|
return null;
|
|
299
314
|
const i = w({
|
|
300
315
|
colorKey: l,
|
|
301
|
-
color:
|
|
316
|
+
color: r,
|
|
302
317
|
fill: o,
|
|
303
318
|
stroke: a,
|
|
304
319
|
payload: d
|
|
@@ -311,15 +326,15 @@ function z({
|
|
|
311
326
|
cy: n,
|
|
312
327
|
"data-slot": "chart-dot-on-stroke",
|
|
313
328
|
fill: i,
|
|
314
|
-
r:
|
|
329
|
+
r: t / 2,
|
|
315
330
|
strokeWidth: 2
|
|
316
331
|
}
|
|
317
332
|
);
|
|
318
333
|
}
|
|
319
334
|
z.displayName = "ChartDotOnStroke";
|
|
320
335
|
function I({
|
|
321
|
-
type:
|
|
322
|
-
filled:
|
|
336
|
+
type: t = "default",
|
|
337
|
+
filled: r = !1,
|
|
323
338
|
fillColor: l = "var(--chart-teal)",
|
|
324
339
|
fillOpacity: e = 0.2,
|
|
325
340
|
boundaryOnly: n = !1,
|
|
@@ -327,8 +342,8 @@ function I({
|
|
|
327
342
|
className: o,
|
|
328
343
|
...d
|
|
329
344
|
}) {
|
|
330
|
-
const i =
|
|
331
|
-
return
|
|
345
|
+
const i = t === "circle" ? "circle" : "polygon", h = n ? `[&_.${i === "circle" ? "recharts-polar-grid-concentric-circle" : "recharts-polar-grid-concentric-polygon"}:not(:last-of-type)]:stroke-transparent` : void 0;
|
|
346
|
+
return r ? /* @__PURE__ */ s(
|
|
332
347
|
N.PolarGrid,
|
|
333
348
|
{
|
|
334
349
|
className: p(h, o),
|
|
@@ -351,8 +366,8 @@ function I({
|
|
|
351
366
|
}
|
|
352
367
|
I.displayName = "ChartRadarGrid";
|
|
353
368
|
function O({
|
|
354
|
-
type:
|
|
355
|
-
data:
|
|
369
|
+
type: t = "default",
|
|
370
|
+
data: r,
|
|
356
371
|
primaryKey: l,
|
|
357
372
|
secondaryKey: e,
|
|
358
373
|
x: n,
|
|
@@ -361,7 +376,7 @@ function O({
|
|
|
361
376
|
payload: d,
|
|
362
377
|
index: i
|
|
363
378
|
}) {
|
|
364
|
-
const u =
|
|
379
|
+
const u = r != null && i != null ? r[i] : void 0, h = u && l != null ? u[l] : void 0, g = u && e != null ? u[e] : void 0, m = t === "default" && h != null ? g != null ? `${String(h)}/${String(g)}` : String(h) : null;
|
|
365
380
|
return /* @__PURE__ */ b(
|
|
366
381
|
"text",
|
|
367
382
|
{
|
|
@@ -387,8 +402,8 @@ function O({
|
|
|
387
402
|
}
|
|
388
403
|
O.displayName = "ChartRadarLabelWrapper";
|
|
389
404
|
function B({
|
|
390
|
-
nameKey:
|
|
391
|
-
config:
|
|
405
|
+
nameKey: t,
|
|
406
|
+
config: r,
|
|
392
407
|
radiusRatio: l = 0.5,
|
|
393
408
|
cx: e,
|
|
394
409
|
cy: n,
|
|
@@ -400,7 +415,7 @@ function B({
|
|
|
400
415
|
}) {
|
|
401
416
|
if (e == null || n == null)
|
|
402
417
|
return null;
|
|
403
|
-
const h = Math.PI / 180, g = o + (d - o) * l, m = e + g * Math.cos(-a * h), C = n + g * Math.sin(-a * h), x =
|
|
418
|
+
const h = Math.PI / 180, g = o + (d - o) * l, m = e + g * Math.cos(-a * h), C = n + g * Math.sin(-a * h), x = t != null && i != null ? i[t] : void 0, f = x != null ? String(x) : u, c = f != null ? r?.[f]?.label ?? f : f;
|
|
404
419
|
return /* @__PURE__ */ s(
|
|
405
420
|
"text",
|
|
406
421
|
{
|
|
@@ -416,16 +431,16 @@ function B({
|
|
|
416
431
|
}
|
|
417
432
|
B.displayName = "ChartPieLabelList";
|
|
418
433
|
function V({
|
|
419
|
-
valueKey:
|
|
420
|
-
x:
|
|
434
|
+
valueKey: t,
|
|
435
|
+
x: r,
|
|
421
436
|
y: l,
|
|
422
437
|
textAnchor: e,
|
|
423
438
|
payload: n,
|
|
424
439
|
value: a
|
|
425
440
|
}) {
|
|
426
|
-
if (
|
|
441
|
+
if (r == null || l == null)
|
|
427
442
|
return null;
|
|
428
|
-
const o =
|
|
443
|
+
const o = t != null && n != null ? n[t] : a;
|
|
429
444
|
return /* @__PURE__ */ s(
|
|
430
445
|
"text",
|
|
431
446
|
{
|
|
@@ -433,7 +448,7 @@ function V({
|
|
|
433
448
|
"data-slot": "chart-pie-label-wrapper",
|
|
434
449
|
dominantBaseline: "middle",
|
|
435
450
|
textAnchor: e,
|
|
436
|
-
x:
|
|
451
|
+
x: r,
|
|
437
452
|
y: l,
|
|
438
453
|
children: o
|
|
439
454
|
}
|
|
@@ -446,8 +461,8 @@ const q = {
|
|
|
446
461
|
"4xl": "font-sans text-4xl font-semibold"
|
|
447
462
|
};
|
|
448
463
|
function E({
|
|
449
|
-
primary:
|
|
450
|
-
secondary:
|
|
464
|
+
primary: t,
|
|
465
|
+
secondary: r,
|
|
451
466
|
size: l = "3xl",
|
|
452
467
|
viewBox: e
|
|
453
468
|
}) {
|
|
@@ -469,16 +484,16 @@ function E({
|
|
|
469
484
|
className: p("fill-foreground", q[l]),
|
|
470
485
|
x: n,
|
|
471
486
|
y: a,
|
|
472
|
-
children:
|
|
487
|
+
children: t
|
|
473
488
|
}
|
|
474
489
|
),
|
|
475
|
-
|
|
490
|
+
r != null && /* @__PURE__ */ s(
|
|
476
491
|
"tspan",
|
|
477
492
|
{
|
|
478
493
|
className: "fill-muted-foreground text-body-xs",
|
|
479
494
|
x: n,
|
|
480
495
|
y: a + 24,
|
|
481
|
-
children:
|
|
496
|
+
children: r
|
|
482
497
|
}
|
|
483
498
|
)
|
|
484
499
|
]
|
|
@@ -497,7 +512,7 @@ export {
|
|
|
497
512
|
j as ChartContainer,
|
|
498
513
|
M as ChartDot,
|
|
499
514
|
z as ChartDotOnStroke,
|
|
500
|
-
|
|
515
|
+
te as ChartLabel,
|
|
501
516
|
D as ChartLegend,
|
|
502
517
|
G as ChartLegendContent,
|
|
503
518
|
B as ChartPieLabelList,
|
|
@@ -507,7 +522,7 @@ export {
|
|
|
507
522
|
T as ChartStyle,
|
|
508
523
|
A as ChartTooltip,
|
|
509
524
|
W as ChartTooltipContent,
|
|
510
|
-
|
|
525
|
+
re as ChartsLegend,
|
|
511
526
|
ne as ChartsTooltip,
|
|
512
527
|
ae as Customized,
|
|
513
528
|
le as LabelList,
|
package/dist/chip.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 a=require("react/jsx-runtime"),R=require("react"),y=require("class-variance-authority"),I=require("@brightlocal/icons"),b=require("@brightlocal/ui-components/lib/utils"),_=require("@brightlocal/ui-components/spinner"),l=require("@brightlocal/ui-components/tooltip");function $(s){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(s){for(const t in s)if(t!=="default"){const i=Object.getOwnPropertyDescriptor(s,t);Object.defineProperty(e,t,i.get?i:{enumerable:!0,get:()=>s[t]})}}return e.default=s,Object.freeze(e)}const c=$(R),v=y.cva(["inline-flex","items-center","justify-center","gap-0.5","rounded-full","whitespace-nowrap","shrink-0","select-none","bg-secondary","text-foreground","transition-[color,background-color,box-shadow]","duration-fast","ease-out","hover:bg-secondary/80","outline-none","focus-visible:shadow-default","disabled:pointer-events-none","disabled:opacity-50","aria-disabled:pointer-events-none","aria-disabled:opacity-50"],{variants:{size:{md:["h-7","pl-2.5","pr-1","text-label-sm"],lg:["h-8","pl-4","pr-2","text-label"]}},defaultVariants:{size:"md"}}),x=y.cva(["inline-flex","items-center","justify-center","rounded-full","cursor-pointer","text-muted-foreground","hover:text-foreground","outline-none","focus-visible:text-foreground","disabled:pointer-events-none","disabled:opacity-50"],{variants:{size:{md:["size-6"],lg:["size-6"]}},defaultVariants:{size:"md"}}),j=c.forwardRef(({className:s,children:e,size:t="md",loading:i=!1,disabled:w=!1,onRemove:d,dataHook:h,trackingEl:u,trackingLabel:k,maxWidth:T=200,loadingLabel:D,removeAriaLabel:m,removableAriaLabel:z,onKeyDown:S,...q},C)=>{const p=w||i,N=t==="lg"?16:14,f=typeof e=="string"||typeof e=="number"?String(e):"chip",o=d!==void 0&&!p,O=n=>{S?.(n),!(n.defaultPrevented||!o)&&(n.key==="Backspace"||n.key==="Delete")&&(n.preventDefault(),d(n))},r=c.useRef(null),[V,P]=c.useState(!1);c.useEffect(()=>{const n=()=>{r.current&&P(r.current.scrollWidth>r.current.clientWidth)};return n(),window.addEventListener("resize",n),()=>window.removeEventListener("resize",n)},[e]);const g=a.jsx("span",{ref:r,className:"truncate","data-slot":"chip-label",style:{maxWidth:T},children:e});return a.jsxs("div",{ref:C,"aria-disabled":p?"true":void 0,"aria-label":o?(z??"{name}, press Delete to remove").replace("{name}",f):void 0,className:b.cn(v({size:t}),s),"data-hook":h,"data-slot":"chip","data-tracking-el":u,"data-tracking-label":k,role:o?"group":void 0,tabIndex:o?0:void 0,onKeyDown:O,...q,children:[V?a.jsx(l.TooltipProvider,{children:a.jsxs(l.Tooltip,{children:[a.jsx(l.TooltipTrigger,{asChild:!0,children:g}),a.jsx(l.TooltipContent,{dataHook:`${h}-tooltip`,sideOffset:8,children:e})]})}):g,i?a.jsx("span",{"aria-label":D??"Loading",className:b.cn(x({size:t})),"data-slot":"chip-loading",role:"status",children:a.jsx(_.Spinner,{size:t==="lg"?"md":"sm"})}):a.jsx("button",{"aria-label":m?m.replace("{name}",f):`Remove ${f}`,className:b.cn(x({size:t})),"data-slot":"chip-delete","data-tracking-el":u?`${u}-delete`:void 0,disabled:p,tabIndex:-1,type:"button",onClick:d,children:a.jsx(I.X,{size:N})})]})});j.displayName="Chip";exports.Chip=j;exports.chipVariants=v;
|
package/dist/chip.d.ts
CHANGED
|
@@ -3,6 +3,21 @@ import * as React from "react";
|
|
|
3
3
|
* Chip size options
|
|
4
4
|
*/
|
|
5
5
|
type ChipSize = "md" | "lg";
|
|
6
|
+
/**
|
|
7
|
+
* The event a chip removal hands to `onRemove`: a mouse event from the
|
|
8
|
+
* delete button, or a keyboard event from Backspace/Delete on the chip root.
|
|
9
|
+
*/
|
|
10
|
+
type ChipRemoveEvent = React.MouseEvent<HTMLButtonElement> | React.KeyboardEvent<HTMLDivElement>;
|
|
11
|
+
/**
|
|
12
|
+
* Removal callback. Declared with the bivariance hack — the same shape React
|
|
13
|
+
* uses for its own event handlers — so handlers annotated against the
|
|
14
|
+
* pre-keyboard, mouse-only contract
|
|
15
|
+
* (`(event: React.MouseEvent<HTMLButtonElement>) => void`) stay assignable
|
|
16
|
+
* under strict function-parameter checking (DS-949).
|
|
17
|
+
*/
|
|
18
|
+
type ChipRemoveHandler = {
|
|
19
|
+
bivarianceHack(event: ChipRemoveEvent): void;
|
|
20
|
+
}["bivarianceHack"];
|
|
6
21
|
declare const chipVariants: (props?: ({
|
|
7
22
|
size?: "md" | "lg" | null | undefined;
|
|
8
23
|
} & import('class-variance-authority/types').ClassProp) | undefined) => string;
|
|
@@ -30,9 +45,10 @@ interface ChipProps extends Omit<React.ComponentProps<"div">, "children"> {
|
|
|
30
45
|
*/
|
|
31
46
|
disabled?: boolean;
|
|
32
47
|
/**
|
|
33
|
-
* Callback when delete button
|
|
48
|
+
* Callback when the chip is removed — via the delete button (click) or
|
|
49
|
+
* the keyboard (Backspace/Delete while the chip is focused).
|
|
34
50
|
*/
|
|
35
|
-
onRemove?:
|
|
51
|
+
onRemove?: ChipRemoveHandler;
|
|
36
52
|
/**
|
|
37
53
|
* Data hook for automated testing (required)
|
|
38
54
|
*/
|
|
@@ -57,16 +73,34 @@ interface ChipProps extends Omit<React.ComponentProps<"div">, "children"> {
|
|
|
57
73
|
loadingLabel?: string;
|
|
58
74
|
/**
|
|
59
75
|
* Accessible label for the remove button.
|
|
60
|
-
* Supports `{name}` placeholder for interpolation.
|
|
76
|
+
* Supports `{name}` placeholder for interpolation. The default `{name}` is
|
|
77
|
+
* derived from string or number children; for a JSX label, pass this prop
|
|
78
|
+
* with the resolved name.
|
|
61
79
|
* @default "Remove {name}"
|
|
62
80
|
*/
|
|
63
81
|
removeAriaLabel?: string;
|
|
82
|
+
/**
|
|
83
|
+
* Accessible label for the chip itself while it is keyboard-removable
|
|
84
|
+
* (focusable, with the Backspace/Delete removal hint).
|
|
85
|
+
* Supports `{name}` placeholder for interpolation. The default `{name}` is
|
|
86
|
+
* derived from string or number children; for a JSX label, pass this prop
|
|
87
|
+
* with the resolved name.
|
|
88
|
+
* @default "{name}, press Delete to remove"
|
|
89
|
+
*/
|
|
90
|
+
removableAriaLabel?: string;
|
|
64
91
|
}
|
|
65
92
|
/**
|
|
66
93
|
* Chip component for displaying removable tags or selections.
|
|
67
94
|
* Used for filter selections, tag lists, and multi-select values.
|
|
95
|
+
*
|
|
96
|
+
* A removable chip is a single tab stop: the chip itself takes focus and
|
|
97
|
+
* Backspace/Delete removes it (DS-949). The delete button stays mouse-only
|
|
98
|
+
* (`tabIndex={-1}`) so each chip costs one tab stop, not two. When a removal
|
|
99
|
+
* unmounts the focused chip, the consumer hands focus onward per the
|
|
100
|
+
* Filtering pattern's cascade: source control → filter trigger → results
|
|
101
|
+
* region — never `<body>`.
|
|
68
102
|
*/
|
|
69
103
|
declare const Chip: React.ForwardRefExoticComponent<Omit<ChipProps, "ref"> & React.RefAttributes<HTMLDivElement>>;
|
|
70
104
|
export { Chip, chipVariants };
|
|
71
|
-
export type { ChipProps, ChipSize };
|
|
105
|
+
export type { ChipProps, ChipRemoveEvent, ChipRemoveHandler, ChipSize };
|
|
72
106
|
//# sourceMappingURL=chip.d.ts.map
|
package/dist/chip.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chip.d.ts","sourceRoot":"","sources":["../../src/components/chip.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAa/B;;GAEG;AACH,KAAK,QAAQ,GAAG,IAAI,GAAG,IAAI,CAAC;AAE5B,QAAA,MAAM,YAAY;;8EA2CjB,CAAC;AAkCF;;GAEG;AACH,UAAU,SAAU,SAAQ,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,KAAK,CAAC,EAAE,UAAU,CAAC;IACvE;;OAEG;IACH,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B;;;OAGG;IACH,IAAI,CAAC,EAAE,QAAQ,CAAC;IAChB;;;OAGG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB;;;OAGG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB
|
|
1
|
+
{"version":3,"file":"chip.d.ts","sourceRoot":"","sources":["../../src/components/chip.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAa/B;;GAEG;AACH,KAAK,QAAQ,GAAG,IAAI,GAAG,IAAI,CAAC;AAE5B;;;GAGG;AACH,KAAK,eAAe,GAChB,KAAK,CAAC,UAAU,CAAC,iBAAiB,CAAC,GACnC,KAAK,CAAC,aAAa,CAAC,cAAc,CAAC,CAAC;AAExC;;;;;;GAMG;AACH,KAAK,iBAAiB,GAAG;IACvB,cAAc,CAAC,KAAK,EAAE,eAAe,GAAG,IAAI,CAAC;CAC9C,CAAC,gBAAgB,CAAC,CAAC;AAEpB,QAAA,MAAM,YAAY;;8EA2CjB,CAAC;AAkCF;;GAEG;AACH,UAAU,SAAU,SAAQ,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,KAAK,CAAC,EAAE,UAAU,CAAC;IACvE;;OAEG;IACH,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B;;;OAGG;IACH,IAAI,CAAC,EAAE,QAAQ,CAAC;IAChB;;;OAGG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB;;;OAGG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB;;;OAGG;IACH,QAAQ,CAAC,EAAE,iBAAiB,CAAC;IAC7B;;OAEG;IACH,QAAQ,EAAE,MAAM,CAAC;IACjB;;OAEG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;OAEG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB;;;OAGG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;;OAGG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB;;;;;;OAMG;IACH,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB;;;;;;;OAOG;IACH,kBAAkB,CAAC,EAAE,MAAM,CAAC;CAC7B;AAED;;;;;;;;;;GAUG;AACH,QAAA,MAAM,IAAI,+FA4IT,CAAC;AAIF,OAAO,EAAE,IAAI,EAAE,YAAY,EAAE,CAAC;AAC9B,YAAY,EAAE,SAAS,EAAE,eAAe,EAAE,iBAAiB,EAAE,QAAQ,EAAE,CAAC"}
|