@brightlocal/ui-components 2.15.0 → 2.17.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/component-meta.json +10 -9
- package/deprecations.json +189 -0
- package/dist/badge.d.ts +1 -1
- package/dist/button.d.ts +1 -1
- package/dist/card.cjs +1 -1
- package/dist/card.d.ts +20 -4
- package/dist/card.d.ts.map +1 -1
- package/dist/card.js +95 -72
- 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/combobox.cjs +3 -3
- package/dist/combobox.js +33 -33
- package/dist/field.cjs +1 -1
- package/dist/field.d.ts.map +1 -1
- package/dist/field.js +10 -2
- 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 +53 -26
- package/dist/index.cjs +1 -1
- package/dist/index.js +366 -360
- package/dist/map.cjs +1 -1
- package/dist/map.d.ts +147 -4
- package/dist/map.d.ts.map +1 -1
- package/dist/map.js +375 -219
- 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 +38 -33
- 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 +18 -6
- package/src/components/card.tsx +62 -8
- package/src/components/chart.tsx +39 -1
- package/src/components/combobox.tsx +1 -1
- package/src/components/field.tsx +9 -1
- package/src/components/global-layout.tsx +60 -7
- package/src/components/map.tsx +414 -28
- package/src/components/rating.tsx +20 -1
- package/src/components/sheet.tsx +30 -5
package/dist/chart.cjs
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
2
|
-
[data-chart=${
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime"),B=require("react"),e=require("recharts"),h=require("@brightlocal/ui-components/lib/utils");function k(r){const o=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(r){for(const s in r)if(s!=="default"){const n=Object.getOwnPropertyDescriptor(r,s);Object.defineProperty(o,s,n.get?n:{enumerable:!0,get:()=>r[s]})}}return o.default=r,Object.freeze(o)}const m=k(B),O=k(e),L=m.createContext(null);function R(){const r=m.useContext(L);if(!r)throw new Error("useChart must be used within a <ChartContainer />");return r}const N=m.forwardRef(({id:r,className:o,children:s,config:n,dataHook:l,width:i,height:c,minWidth:u,minHeight:d,maxHeight:j,trackingEl:y,trackingLabel:P,...p},b)=>{const C=m.useId(),g=`chart-${r||C.replace(/:/g,"")}`;return t.jsx(L.Provider,{value:{config:n},children:t.jsxs("div",{ref:b,className:h.cn("[&_.recharts-cartesian-axis-tick_text]:fill-muted-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 flex aspect-video justify-center text-xs [&_.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",o),"data-chart":g,"data-hook":l,"data-slot":"chart-container","data-tracking-el":y,"data-tracking-label":P,...p,children:[t.jsx(w,{config:n,id:g}),t.jsx(O.ResponsiveContainer,{height:c??"100%",initialDimension:{width:1,height:1},maxHeight:j,minHeight:d,minWidth:u??0,width:i??"100%",children:s})]})})});N.displayName="ChartContainer";function w({id:r,config:o}){const s=Object.entries(o).filter(([,n])=>n.theme||n.color);return s.length?t.jsx("style",{dangerouslySetInnerHTML:{__html:s.map(([n,l])=>{const i=typeof l.color=="string"?l.color.replace(/^hsl\((.*)\)$/,"$1"):null;return i?`
|
|
2
|
+
[data-chart=${r}] {
|
|
3
3
|
--color-${n}: ${i};
|
|
4
4
|
}
|
|
5
5
|
`:l.theme?Object.entries(l.theme).map(([c,u])=>`
|
|
6
|
-
.${c} [data-chart=${
|
|
6
|
+
.${c} [data-chart=${r}] {
|
|
7
7
|
--color-${n}: ${u.replace(/^hsl\((.*)\)$/,"$1")};
|
|
8
8
|
}
|
|
9
9
|
`).join(""):""}).join(`
|
|
10
|
-
`)}}):null}function $({...
|
|
10
|
+
`)}}):null}function $({...r}){return t.jsx(O.Tooltip,{...r})}$.displayName="ChartTooltip";function A({active:r,payload:o,className:s,indicator:n="dot",hideLabel:l=!1,hideIndicator:i=!1,label:c,labelFormatter:u,labelClassName:d,formatter:j,color:y,nameKey:P,labelKey:p}){const{config:b}=R(),C=m.useMemo(()=>{if(l||!o?.length)return null;const[a]=o;if(!a)return null;const v=`${p||a.dataKey||a.name||"value"}`,x=b[v],f=!p&&typeof c=="string"?b[c]?.label||c:x?.label;return u?t.jsx("div",{className:h.cn("font-medium",d),children:u(f,o)}):f?t.jsx("div",{className:h.cn("font-medium",d),children:f}):null},[c,u,o,l,d,b,p]);if(!r||!o?.length)return null;const g=o.length===1&&n!=="dot";return t.jsxs("div",{className:h.cn("border-border/50 bg-background grid min-w-[8rem] items-start gap-1.5 rounded-lg border px-2.5 py-1.5 text-xs shadow-xl",s),"data-slot":"chart-tooltip-content",children:[g?null:C,t.jsx("div",{className:"grid gap-1.5",children:o.map((a,v)=>{const x=`${P||a.name||a.dataKey||"value"}`,f=b[x],_=y||a.color||a.payload.fill||`var(--color-${x})`;return t.jsx("div",{className:h.cn("[&>svg]:text-muted-foreground flex w-full flex-wrap items-stretch gap-2",n==="dot"&&"items-center"),children:j&&a?.value!==void 0&&a.name?j(a.value,a.name,a,v,o):t.jsxs(t.Fragment,{children:[f?.icon&&!i?t.jsx(f.icon,{size:10}):!i&&t.jsx("div",{className:h.cn("shrink-0 rounded-[2px]",{"h-2.5 w-2.5":n==="dot","w-1":n==="line","w-0 border-[1.5px] border-dashed bg-transparent":n==="dashed","my-0.5":g&&n==="dashed"}),style:{backgroundColor:n==="dashed"?"transparent":_,borderColor:_}}),t.jsxs("div",{className:h.cn("flex flex-1 justify-between leading-none",g?"items-end":"items-center"),children:[t.jsxs("div",{className:"grid gap-1.5",children:[g?C:null,t.jsx("span",{className:"text-muted-foreground",children:f?.label||a.name})]}),a.value&&t.jsx("span",{className:"text-foreground font-mono font-medium tabular-nums",children:typeof a.value=="number"?a.value.toLocaleString():a.value})]})]})},a.dataKey)})})]})}A.displayName="ChartTooltipContent";function T({...r}){return t.jsx(O.Legend,{...r})}T.displayName="ChartLegend";function S({className:r,hideIcon:o=!1,payload:s,verticalAlign:n="bottom",nameKey:l}){const{config:i}=R();return s?.length?t.jsx("div",{className:h.cn("flex items-center justify-center gap-4",n==="top"?"pb-4":"pt-4",r),"data-slot":"chart-legend-content",children:s.map(c=>{const u=`${l||c.dataKey||"value"}`,d=i[u];return t.jsxs("div",{className:h.cn("[&>svg]:text-muted-foreground flex items-center gap-1.5"),children:[d?.icon&&!o?t.jsx(d.icon,{size:12}):t.jsx("div",{className:"h-2 w-2 shrink-0 rounded-[2px]",style:{backgroundColor:c.color}}),d?.label||c.value]},c.value)})}):null}S.displayName="ChartLegendContent";Object.defineProperty(exports,"Area",{enumerable:!0,get:()=>e.Area});Object.defineProperty(exports,"AreaChart",{enumerable:!0,get:()=>e.AreaChart});Object.defineProperty(exports,"Bar",{enumerable:!0,get:()=>e.Bar});Object.defineProperty(exports,"BarChart",{enumerable:!0,get:()=>e.BarChart});Object.defineProperty(exports,"CartesianGrid",{enumerable:!0,get:()=>e.CartesianGrid});Object.defineProperty(exports,"Cell",{enumerable:!0,get:()=>e.Cell});Object.defineProperty(exports,"ChartLabel",{enumerable:!0,get:()=>e.Label});Object.defineProperty(exports,"ChartsLegend",{enumerable:!0,get:()=>e.Legend});Object.defineProperty(exports,"ChartsTooltip",{enumerable:!0,get:()=>e.Tooltip});Object.defineProperty(exports,"Customized",{enumerable:!0,get:()=>e.Customized});Object.defineProperty(exports,"LabelList",{enumerable:!0,get:()=>e.LabelList});Object.defineProperty(exports,"Line",{enumerable:!0,get:()=>e.Line});Object.defineProperty(exports,"LineChart",{enumerable:!0,get:()=>e.LineChart});Object.defineProperty(exports,"Pie",{enumerable:!0,get:()=>e.Pie});Object.defineProperty(exports,"PieChart",{enumerable:!0,get:()=>e.PieChart});Object.defineProperty(exports,"PolarAngleAxis",{enumerable:!0,get:()=>e.PolarAngleAxis});Object.defineProperty(exports,"PolarGrid",{enumerable:!0,get:()=>e.PolarGrid});Object.defineProperty(exports,"PolarRadiusAxis",{enumerable:!0,get:()=>e.PolarRadiusAxis});Object.defineProperty(exports,"Radar",{enumerable:!0,get:()=>e.Radar});Object.defineProperty(exports,"RadarChart",{enumerable:!0,get:()=>e.RadarChart});Object.defineProperty(exports,"RadialBar",{enumerable:!0,get:()=>e.RadialBar});Object.defineProperty(exports,"RadialBarChart",{enumerable:!0,get:()=>e.RadialBarChart});Object.defineProperty(exports,"Rectangle",{enumerable:!0,get:()=>e.Rectangle});Object.defineProperty(exports,"ReferenceLine",{enumerable:!0,get:()=>e.ReferenceLine});Object.defineProperty(exports,"ResponsiveContainer",{enumerable:!0,get:()=>e.ResponsiveContainer});Object.defineProperty(exports,"Sector",{enumerable:!0,get:()=>e.Sector});Object.defineProperty(exports,"XAxis",{enumerable:!0,get:()=>e.XAxis});Object.defineProperty(exports,"YAxis",{enumerable:!0,get:()=>e.YAxis});exports.ChartContainer=N;exports.ChartLegend=T;exports.ChartLegendContent=S;exports.ChartStyle=w;exports.ChartTooltip=$;exports.ChartTooltipContent=A;
|
package/dist/chart.d.ts
CHANGED
|
@@ -33,6 +33,32 @@ interface ChartContainerProps extends React.ComponentProps<"div">, ChartContextP
|
|
|
33
33
|
* Data hook for automated testing (required)
|
|
34
34
|
*/
|
|
35
35
|
dataHook: string;
|
|
36
|
+
/**
|
|
37
|
+
* Width of the chart's ResponsiveContainer.
|
|
38
|
+
* A number (px) skips responsive measurement and avoids the initial -1 warning.
|
|
39
|
+
* A percent string (e.g. "50%") keeps responsive behaviour within that fraction.
|
|
40
|
+
* @default "100%"
|
|
41
|
+
*/
|
|
42
|
+
width?: number | `${number}%`;
|
|
43
|
+
/**
|
|
44
|
+
* Height of the chart's ResponsiveContainer.
|
|
45
|
+
* A number (px) skips responsive measurement and avoids the initial -1 warning.
|
|
46
|
+
* A percent string (e.g. "50%") keeps responsive behaviour within that fraction.
|
|
47
|
+
* @default "100%"
|
|
48
|
+
*/
|
|
49
|
+
height?: number | `${number}%`;
|
|
50
|
+
/**
|
|
51
|
+
* Minimum width for the chart's ResponsiveContainer.
|
|
52
|
+
*/
|
|
53
|
+
minWidth?: number | string;
|
|
54
|
+
/**
|
|
55
|
+
* Minimum height for the chart's ResponsiveContainer.
|
|
56
|
+
*/
|
|
57
|
+
minHeight?: number | string;
|
|
58
|
+
/**
|
|
59
|
+
* Maximum height for the chart's ResponsiveContainer.
|
|
60
|
+
*/
|
|
61
|
+
maxHeight?: number;
|
|
36
62
|
/**
|
|
37
63
|
* Tracking element identifier for analytics
|
|
38
64
|
*/
|
package/dist/chart.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chart.d.ts","sourceRoot":"","sources":["../../src/components/chart.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,iBAAiB,MAAM,UAAU,CAAC;AAO9C,MAAM,WAAW,WAAW;IAC1B,CAAC,GAAG,EAAE,MAAM,GAAG;QACb,KAAK,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;QACxB,IAAI,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC;YAAE,IA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AAEF,YAAY,EACV,mBAAmB,EACnB,iBAAiB,EACjB,wBAAwB,EACxB,gBAAgB,EAChB,uBAAuB,GACxB,CAAC;AAGF,OAAO,EACL,IAAI,EACJ,SAAS,EACT,GAAG,EACH,QAAQ,EACR,aAAa,EACb,IAAI,EACJ,UAAU,EACV,KAAK,IAAI,UAAU,EACnB,SAAS,EACT,MAAM,IAAI,YAAY,EACtB,IAAI,EACJ,SAAS,EACT,GAAG,EACH,QAAQ,EACR,cAAc,EACd,SAAS,EACT,eAAe,EACf,KAAK,EACL,UAAU,EACV,SAAS,EACT,cAAc,EACd,SAAS,EACT,aAAa,EACb,mBAAmB,EACnB,MAAM,EACN,OAAO,IAAI,aAAa,EACxB,KAAK,EACL,KAAK,GACN,MAAM,UAAU,CAAC"}
|
package/dist/chart.js
CHANGED
|
@@ -1,44 +1,60 @@
|
|
|
1
|
-
import { jsx as t, jsxs as
|
|
2
|
-
import * as
|
|
3
|
-
import * as
|
|
4
|
-
import { Area as M, AreaChart as O, Bar as q, BarChart as
|
|
1
|
+
import { jsx as t, jsxs as m, Fragment as R } from "react/jsx-runtime";
|
|
2
|
+
import * as C from "react";
|
|
3
|
+
import * as N from "recharts";
|
|
4
|
+
import { Area as M, AreaChart as O, Bar as q, BarChart as D, CartesianGrid as E, Cell as H, Label as W, Legend as X, Tooltip as Y, Customized as J, LabelList as Q, Line as U, LineChart as V, Pie as Z, PieChart as F, PolarAngleAxis as ee, PolarGrid as re, PolarRadiusAxis as te, Radar as ne, RadarChart as ae, RadialBar as oe, RadialBarChart as se, Rectangle as le, ReferenceLine as ce, ResponsiveContainer as ie, Sector as de, XAxis as ue, YAxis as he } from "recharts";
|
|
5
5
|
import { cn as u } from "@brightlocal/ui-components/lib/utils";
|
|
6
|
-
const
|
|
7
|
-
function
|
|
8
|
-
const n =
|
|
6
|
+
const $ = C.createContext(null);
|
|
7
|
+
function w() {
|
|
8
|
+
const n = C.useContext($);
|
|
9
9
|
if (!n)
|
|
10
10
|
throw new Error("useChart must be used within a <ChartContainer />");
|
|
11
11
|
return n;
|
|
12
12
|
}
|
|
13
|
-
const j =
|
|
13
|
+
const j = C.forwardRef(
|
|
14
14
|
({
|
|
15
15
|
id: n,
|
|
16
16
|
className: a,
|
|
17
17
|
children: l,
|
|
18
18
|
config: r,
|
|
19
19
|
dataHook: s,
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
20
|
+
width: c,
|
|
21
|
+
height: o,
|
|
22
|
+
minWidth: i,
|
|
23
|
+
minHeight: d,
|
|
24
|
+
maxHeight: v,
|
|
25
|
+
trackingEl: k,
|
|
26
|
+
trackingLabel: _,
|
|
27
|
+
...p
|
|
28
|
+
}, g) => {
|
|
29
|
+
const x = C.useId(), h = `chart-${n || x.replace(/:/g, "")}`;
|
|
30
|
+
return /* @__PURE__ */ t($.Provider, { value: { config: r }, children: /* @__PURE__ */ m(
|
|
26
31
|
"div",
|
|
27
32
|
{
|
|
28
|
-
ref:
|
|
33
|
+
ref: g,
|
|
29
34
|
className: u(
|
|
30
35
|
"[&_.recharts-cartesian-axis-tick_text]:fill-muted-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 flex aspect-video justify-center text-xs [&_.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",
|
|
31
36
|
a
|
|
32
37
|
),
|
|
33
|
-
"data-chart":
|
|
38
|
+
"data-chart": h,
|
|
34
39
|
"data-hook": s,
|
|
35
40
|
"data-slot": "chart-container",
|
|
36
|
-
"data-tracking-el":
|
|
37
|
-
"data-tracking-label":
|
|
38
|
-
...
|
|
41
|
+
"data-tracking-el": k,
|
|
42
|
+
"data-tracking-label": _,
|
|
43
|
+
...p,
|
|
39
44
|
children: [
|
|
40
|
-
/* @__PURE__ */ t(T, { config: r, id:
|
|
41
|
-
/* @__PURE__ */ t(
|
|
45
|
+
/* @__PURE__ */ t(T, { config: r, id: h }),
|
|
46
|
+
/* @__PURE__ */ t(
|
|
47
|
+
N.ResponsiveContainer,
|
|
48
|
+
{
|
|
49
|
+
height: o ?? "100%",
|
|
50
|
+
initialDimension: { width: 1, height: 1 },
|
|
51
|
+
maxHeight: v,
|
|
52
|
+
minHeight: d,
|
|
53
|
+
minWidth: i ?? 0,
|
|
54
|
+
width: c ?? "100%",
|
|
55
|
+
children: l
|
|
56
|
+
}
|
|
57
|
+
)
|
|
42
58
|
]
|
|
43
59
|
}
|
|
44
60
|
) });
|
|
@@ -73,7 +89,7 @@ function T({ id: n, config: a }) {
|
|
|
73
89
|
) : null;
|
|
74
90
|
}
|
|
75
91
|
function A({ ...n }) {
|
|
76
|
-
return /* @__PURE__ */ t(
|
|
92
|
+
return /* @__PURE__ */ t(N.Tooltip, { ...n });
|
|
77
93
|
}
|
|
78
94
|
A.displayName = "ChartTooltip";
|
|
79
95
|
function P({
|
|
@@ -86,32 +102,32 @@ function P({
|
|
|
86
102
|
label: o,
|
|
87
103
|
labelFormatter: i,
|
|
88
104
|
labelClassName: d,
|
|
89
|
-
formatter:
|
|
90
|
-
color:
|
|
91
|
-
nameKey:
|
|
92
|
-
labelKey:
|
|
105
|
+
formatter: v,
|
|
106
|
+
color: k,
|
|
107
|
+
nameKey: _,
|
|
108
|
+
labelKey: p
|
|
93
109
|
}) {
|
|
94
|
-
const { config:
|
|
110
|
+
const { config: g } = w(), x = C.useMemo(() => {
|
|
95
111
|
if (s || !a?.length)
|
|
96
112
|
return null;
|
|
97
113
|
const [e] = a;
|
|
98
114
|
if (!e)
|
|
99
115
|
return null;
|
|
100
|
-
const
|
|
101
|
-
return i ? /* @__PURE__ */ t("div", { className: u("font-medium", d), children: i(
|
|
116
|
+
const L = `${p || e.dataKey || e.name || "value"}`, b = g[L], f = !p && typeof o == "string" ? g[o]?.label || o : b?.label;
|
|
117
|
+
return i ? /* @__PURE__ */ t("div", { className: u("font-medium", d), children: i(f, a) }) : f ? /* @__PURE__ */ t("div", { className: u("font-medium", d), children: f }) : null;
|
|
102
118
|
}, [
|
|
103
119
|
o,
|
|
104
120
|
i,
|
|
105
121
|
a,
|
|
106
122
|
s,
|
|
107
123
|
d,
|
|
108
|
-
|
|
109
|
-
|
|
124
|
+
g,
|
|
125
|
+
p
|
|
110
126
|
]);
|
|
111
127
|
if (!n || !a?.length)
|
|
112
128
|
return null;
|
|
113
|
-
const
|
|
114
|
-
return /* @__PURE__ */
|
|
129
|
+
const h = a.length === 1 && r !== "dot";
|
|
130
|
+
return /* @__PURE__ */ m(
|
|
115
131
|
"div",
|
|
116
132
|
{
|
|
117
133
|
className: u(
|
|
@@ -120,9 +136,9 @@ function P({
|
|
|
120
136
|
),
|
|
121
137
|
"data-slot": "chart-tooltip-content",
|
|
122
138
|
children: [
|
|
123
|
-
|
|
124
|
-
/* @__PURE__ */ t("div", { className: "grid gap-1.5", children: a.map((e,
|
|
125
|
-
const
|
|
139
|
+
h ? null : x,
|
|
140
|
+
/* @__PURE__ */ t("div", { className: "grid gap-1.5", children: a.map((e, L) => {
|
|
141
|
+
const b = `${_ || e.name || e.dataKey || "value"}`, f = g[b], y = k || e.color || e.payload.fill || `var(--color-${b})`;
|
|
126
142
|
return /* @__PURE__ */ t(
|
|
127
143
|
"div",
|
|
128
144
|
{
|
|
@@ -130,33 +146,33 @@ function P({
|
|
|
130
146
|
"[&>svg]:text-muted-foreground flex w-full flex-wrap items-stretch gap-2",
|
|
131
147
|
r === "dot" && "items-center"
|
|
132
148
|
),
|
|
133
|
-
children:
|
|
134
|
-
|
|
149
|
+
children: v && e?.value !== void 0 && e.name ? v(e.value, e.name, e, L, a) : /* @__PURE__ */ m(R, { children: [
|
|
150
|
+
f?.icon && !c ? /* @__PURE__ */ t(f.icon, { size: 10 }) : !c && /* @__PURE__ */ t(
|
|
135
151
|
"div",
|
|
136
152
|
{
|
|
137
153
|
className: u("shrink-0 rounded-[2px]", {
|
|
138
154
|
"h-2.5 w-2.5": r === "dot",
|
|
139
155
|
"w-1": r === "line",
|
|
140
156
|
"w-0 border-[1.5px] border-dashed bg-transparent": r === "dashed",
|
|
141
|
-
"my-0.5":
|
|
157
|
+
"my-0.5": h && r === "dashed"
|
|
142
158
|
}),
|
|
143
159
|
style: {
|
|
144
|
-
backgroundColor: r === "dashed" ? "transparent" :
|
|
145
|
-
borderColor:
|
|
160
|
+
backgroundColor: r === "dashed" ? "transparent" : y,
|
|
161
|
+
borderColor: y
|
|
146
162
|
}
|
|
147
163
|
}
|
|
148
164
|
),
|
|
149
|
-
/* @__PURE__ */
|
|
165
|
+
/* @__PURE__ */ m(
|
|
150
166
|
"div",
|
|
151
167
|
{
|
|
152
168
|
className: u(
|
|
153
169
|
"flex flex-1 justify-between leading-none",
|
|
154
|
-
|
|
170
|
+
h ? "items-end" : "items-center"
|
|
155
171
|
),
|
|
156
172
|
children: [
|
|
157
|
-
/* @__PURE__ */
|
|
158
|
-
|
|
159
|
-
/* @__PURE__ */ t("span", { className: "text-muted-foreground", children:
|
|
173
|
+
/* @__PURE__ */ m("div", { className: "grid gap-1.5", children: [
|
|
174
|
+
h ? x : null,
|
|
175
|
+
/* @__PURE__ */ t("span", { className: "text-muted-foreground", children: f?.label || e.name })
|
|
160
176
|
] }),
|
|
161
177
|
e.value && /* @__PURE__ */ t("span", { className: "text-foreground font-mono font-medium tabular-nums", children: typeof e.value == "number" ? e.value.toLocaleString() : e.value })
|
|
162
178
|
]
|
|
@@ -173,7 +189,7 @@ function P({
|
|
|
173
189
|
}
|
|
174
190
|
P.displayName = "ChartTooltipContent";
|
|
175
191
|
function B({ ...n }) {
|
|
176
|
-
return /* @__PURE__ */ t(
|
|
192
|
+
return /* @__PURE__ */ t(N.Legend, { ...n });
|
|
177
193
|
}
|
|
178
194
|
B.displayName = "ChartLegend";
|
|
179
195
|
function S({
|
|
@@ -183,7 +199,7 @@ function S({
|
|
|
183
199
|
verticalAlign: r = "bottom",
|
|
184
200
|
nameKey: s
|
|
185
201
|
}) {
|
|
186
|
-
const { config: c } =
|
|
202
|
+
const { config: c } = w();
|
|
187
203
|
return l?.length ? /* @__PURE__ */ t(
|
|
188
204
|
"div",
|
|
189
205
|
{
|
|
@@ -195,7 +211,7 @@ function S({
|
|
|
195
211
|
"data-slot": "chart-legend-content",
|
|
196
212
|
children: l.map((o) => {
|
|
197
213
|
const i = `${s || o.dataKey || "value"}`, d = c[i];
|
|
198
|
-
return /* @__PURE__ */
|
|
214
|
+
return /* @__PURE__ */ m(
|
|
199
215
|
"div",
|
|
200
216
|
{
|
|
201
217
|
className: u(
|
|
@@ -225,22 +241,22 @@ export {
|
|
|
225
241
|
M as Area,
|
|
226
242
|
O as AreaChart,
|
|
227
243
|
q as Bar,
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
244
|
+
D as BarChart,
|
|
245
|
+
E as CartesianGrid,
|
|
246
|
+
H as Cell,
|
|
231
247
|
j as ChartContainer,
|
|
232
|
-
|
|
248
|
+
W as ChartLabel,
|
|
233
249
|
B as ChartLegend,
|
|
234
250
|
S as ChartLegendContent,
|
|
235
251
|
T as ChartStyle,
|
|
236
252
|
A as ChartTooltip,
|
|
237
253
|
P as ChartTooltipContent,
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
254
|
+
X as ChartsLegend,
|
|
255
|
+
Y as ChartsTooltip,
|
|
256
|
+
J as Customized,
|
|
257
|
+
Q as LabelList,
|
|
258
|
+
U as Line,
|
|
259
|
+
V as LineChart,
|
|
244
260
|
Z as Pie,
|
|
245
261
|
F as PieChart,
|
|
246
262
|
ee as PolarAngleAxis,
|
package/dist/combobox.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("react/jsx-runtime"),ie=require("react"),K=require("@brightlocal/icons"),le=require("@tanstack/react-virtual"),ce=require("class-variance-authority"),B=require("cmdk"),F=require("@brightlocal/ui-components/lib/utils"),U=require("@brightlocal/ui-components/lib/use-dev-warning"),Y=require("@brightlocal/ui-components/popover"),$=require("@brightlocal/ui-components/command");function ue(e){const r=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const n in e)if(n!=="default"){const o=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(r,n,o.get?o:{enumerable:!0,get:()=>e[n]})}}return r.default=e,Object.freeze(r)}const t=ue(ie),Q=t.createContext(null),X=t.createContext(null);function z(){const e=t.useContext(Q);if(!e)throw new Error("Combobox components must be used within a <Combobox>");return e}function de({value:e,onValueChange:r,open:n,onOpenChange:o,shouldFilter:l=!0,disabled:u=!1,itemToStringValue:a,children:m}){const[
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("react/jsx-runtime"),ie=require("react"),K=require("@brightlocal/icons"),le=require("@tanstack/react-virtual"),ce=require("class-variance-authority"),B=require("cmdk"),F=require("@brightlocal/ui-components/lib/utils"),U=require("@brightlocal/ui-components/lib/use-dev-warning"),Y=require("@brightlocal/ui-components/popover"),$=require("@brightlocal/ui-components/command");function ue(e){const r=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const n in e)if(n!=="default"){const o=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(r,n,o.get?o:{enumerable:!0,get:()=>e[n]})}}return r.default=e,Object.freeze(r)}const t=ue(ie),Q=t.createContext(null),X=t.createContext(null);function z(){const e=t.useContext(Q);if(!e)throw new Error("Combobox components must be used within a <Combobox>");return e}function de({value:e,onValueChange:r,open:n,onOpenChange:o,shouldFilter:l=!0,disabled:u=!1,itemToStringValue:a,children:m}){const[p,v]=t.useState(""),[E,x]=t.useState(!1),[d,R]=t.useState(()=>new Map),[I,C]=t.useState(""),[j,N]=t.useState(void 0),y=e!==void 0,w=n!==void 0,L=y?e:p,S=w?n:E,D=t.useCallback(g=>{g||C(""),w||x(g),o?.(g)},[w,o]),V=t.useCallback(g=>{y||v(g),r?.(g)},[y,r]),c=t.useRef(new Map),k=t.useRef(!1),T=t.useRef(!0);t.useEffect(()=>()=>{T.current=!1},[]);const b=t.useCallback(()=>{k.current||(k.current=!0,queueMicrotask(()=>{k.current=!1,T.current&&R(new Map(c.current))}))},[]),P=t.useCallback((g,A)=>{c.current.get(g)!==A&&(c.current.set(g,A),b())},[b]),O=t.useCallback(g=>{for(const[A,G]of g)c.current.set(A,G);R(new Map(c.current))},[]),W=t.useRef(L);t.useLayoutEffect(()=>{W.current=L},[L]);const q=t.useCallback(g=>{g!==W.current&&c.current.has(g)&&(c.current.delete(g),b())},[b]),_=t.useMemo(()=>a?(g,A,G)=>B.defaultFilter(a(g),A,G):B.defaultFilter,[a]),H=t.useMemo(()=>({open:S,setOpen:D,value:L,onValueChange:V,shouldFilter:l,disabled:u,itemLabels:d,registerItem:P,registerItemsSync:O,unregisterItem:q,itemToStringValue:a,filterFn:_,searchValue:I,setSearchValue:C,activeDescendantId:j,setActiveDescendantId:N}),[S,D,L,V,l,u,d,P,O,q,a,_,I,j,N]);return i.jsx(Q.Provider,{value:H,children:i.jsx(Y.Popover,{open:S,onOpenChange:D,children:m})})}const be=ce.cva(["relative flex w-full items-center justify-between gap-2","px-4 py-2 h-9","border border-input rounded-md outline-none","bg-neutral-50 shadow-xs","dark:bg-white/5 dark:border-white/15","text-base font-normal font-sans text-foreground","data-[placeholder=true]:text-muted-foreground","focus-visible:outline-none focus-visible:border-ring dark:focus-visible:border-neutral-500 focus-visible:bg-background","focus-visible:shadow-default","data-[state=open]:border-ring","disabled:cursor-not-allowed disabled:opacity-50","transition-[background-color,border-color,box-shadow] duration-200 ease-out","[&_svg]:pointer-events-none [&_svg]:shrink-0"]),Z=t.forwardRef(({className:e,dataHook:r,error:n,trackingEl:o,trackingLabel:l,children:u,...a},m)=>{const{open:p,disabled:v,value:E}=z(),x=t.useId(),d=!E,R=n||a["aria-invalid"]===!0||a["aria-invalid"]==="true";return i.jsx(Y.PopoverTrigger,{asChild:!0,children:i.jsxs("button",{ref:m,"aria-controls":p?x:void 0,"aria-expanded":p,"aria-haspopup":"listbox","aria-invalid":R?"true":void 0,className:F.cn(be(),R&&"border-destructive-40 dark:border-destructive-40 focus-visible:border-destructive-40 dark:focus-visible:border-destructive-40 focus-visible:shadow-destructive data-[state=open]:border-destructive-40 dark:data-[state=open]:border-destructive-40 data-[state=open]:shadow-destructive",e),"data-hook":r,"data-placeholder":d,"data-slot":"combobox-trigger","data-state":p?"open":"closed","data-tracking-el":o||"combobox-trigger","data-tracking-label":l,disabled:v||a.disabled,role:"combobox",type:"button",...a,children:[u,i.jsx(K.ChevronsUpDown,{"aria-hidden":"true",className:"text-muted-foreground ml-auto shrink-0"})]})})});Z.displayName="ComboboxTrigger";function fe(e){return e!=null&&typeof e=="object"&&"value"in e&&typeof e.value=="string"}function ee(e,r,n){if(r)return{getValue:r,getLabel:n??r,hasDistinctLabel:!!n};const o=e[0];if(!fe(o))return null;const l=m=>m.value,u="label"in o&&typeof o.label=="string";return{getValue:l,getLabel:n??(u?m=>String(m.label):l),hasDistinctLabel:u||!!n}}function me({placeholder:e,className:r,displayValue:n,items:o,getItemValue:l,getItemLabel:u}){const{value:a,itemLabels:m}=z(),p=t.useMemo(()=>o?ee(o,l,u):null,[o,l,u]);U.useDevWarning(()=>!!o&&o.length>0&&!p,"ComboboxValue: could not infer `getItemValue` from item shape. Pass `getItemValue` explicitly, or use items with a `value` string property.",[o,p]);const v=t.useMemo(()=>!o||!p?null:new Map(o.map(x=>[p.getValue(x),p.getLabel(x)])),[o,p]),E=a?v?.get(a)||m.get(a)||n?.(a)||a:e;return i.jsx("span",{className:F.cn("overflow-hidden text-base leading-normal font-medium text-ellipsis whitespace-nowrap",r),"data-slot":"combobox-value",children:E})}function pe({dataHook:e,className:r,children:n,align:o="start",side:l="bottom",sideOffset:u,avoidCollisions:a,hideList:m=!1,ariaLabel:p}){const{open:v,shouldFilter:E,filterFn:x,itemToStringValue:d}=z(),[R,I]=t.useState(null),C=t.useRef(null),j=t.useCallback(y=>{if(C.current?.(),C.current=null,!y)return;let w=!1;const L=c=>{w||(c==="top"||c==="bottom")&&(w=!0,S.disconnect(),I(c))},S=new MutationObserver(()=>{L(y.getAttribute("data-side"))});S.observe(y,{attributes:!0,attributeFilter:["data-side"]});let D=0,V=0;D=requestAnimationFrame(()=>{V=requestAnimationFrame(()=>{L(y.getAttribute("data-side"))})}),C.current=()=>{w=!0,S.disconnect(),cancelAnimationFrame(D),cancelAnimationFrame(V)}},[]);t.useEffect(()=>{if(!v){C.current?.(),C.current=null;const y=setTimeout(()=>I(null),150);return()=>clearTimeout(y)}},[v]);const N=d?x:void 0;return i.jsx(Y.PopoverContent,{ref:j,align:o,"aria-label":p??"Options",avoidCollisions:a,className:F.cn("flex max-h-[var(--radix-popover-content-available-height)] w-[var(--radix-popover-trigger-width)] flex-col overflow-hidden p-0",r),collisionPadding:4,"data-slot":"combobox-popover",side:R??l,sideOffset:u,children:i.jsx($.Command,{className:F.cn("min-h-0 flex-1 border-0 shadow-none","[&_[data-slot='command-input-wrapper']]:shrink-0",m&&"[&_[data-slot='command-input-wrapper']]:border-b-0"),"data-slot":"combobox-command",dataHook:e||"combobox-command",filter:N,shouldFilter:E,children:n})})}const te=t.forwardRef(({debounceMs:e,onValueChange:r,...n},o)=>{const{setSearchValue:l,shouldFilter:u,activeDescendantId:a}=z(),m=t.useRef(void 0);U.useDevWarning(()=>!!(e&&e>0&&u),`debounceMs is set on <ComboboxInput> but shouldFilter is true (default).
|
|
2
2
|
Debounce is designed for async/server-driven search where the consumer controls the items list.
|
|
3
|
-
Set shouldFilter={false} on <Combobox> for async search, or remove debounceMs for client-side filtering.`,[e,u]),U.useDevWarning(()=>!!(e&&e>0&&n.value!==void 0),"debounceMs is set on <ComboboxInput> together with a controlled `value` prop.\nThe debounced onValueChange callback cannot update the controlled value synchronously, so the input will appear to lag behind typing.\nRemove `value` to let the input manage its own display, or remove debounceMs if you need a controlled input.",[e,n.value]),t.useEffect(()=>()=>{m.current&&clearTimeout(m.current)},[]);const
|
|
4
|
-
Import: import { ComboboxVirtualList } from "@brightlocal/ui-components/combobox"`,[e]),i.jsx($.CommandGroup,{ref:l=>{o.current=l,typeof n=="function"?n(l):n&&(n.current=l)},"data-slot":"combobox-group",...r,children:e})});ne.displayName="ComboboxGroup";function he(e,r,n){if(!r||!r.trim())return e;const o=new RegExp(`(${r.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")})`,"gi"),l=e.split(o);return i.jsx("span",{children:l.map((u,a)=>a%2===1?i.jsx("span",{className:n,children:u},a):i.jsx(t.Fragment,{children:u},a))})}const se=t.forwardRef(({value:e,label:r,dataHook:n,children:o,className:l,highlight:u,highlightClassName:a,keywords:m,onSelect:
|
|
3
|
+
Set shouldFilter={false} on <Combobox> for async search, or remove debounceMs for client-side filtering.`,[e,u]),U.useDevWarning(()=>!!(e&&e>0&&n.value!==void 0),"debounceMs is set on <ComboboxInput> together with a controlled `value` prop.\nThe debounced onValueChange callback cannot update the controlled value synchronously, so the input will appear to lag behind typing.\nRemove `value` to let the input manage its own display, or remove debounceMs if you need a controlled input.",[e,n.value]),t.useEffect(()=>()=>{m.current&&clearTimeout(m.current)},[]);const p=t.useCallback(v=>{l(v),e&&e>0?(clearTimeout(m.current),m.current=setTimeout(()=>{r?.(v)},e)):r?.(v)},[e,r,l]);return i.jsx($.CommandInput,{ref:o,"aria-activedescendant":a,"data-slot":"combobox-input",onValueChange:p,...n})});te.displayName="ComboboxInput";const oe=t.forwardRef(({className:e,...r},n)=>i.jsx($.CommandList,{ref:n,className:F.cn("scrollbar min-h-0 flex-1",e),"data-slot":"combobox-list",...r}));oe.displayName="ComboboxList";function xe({items:e,getItemValue:r,getItemLabel:n,getItemKeywords:o,estimateSize:l=36,overscan:u=5,children:a,renderEmpty:m,className:p,dataHook:v},E){const x=t.useMemo(()=>ee(e,r,n),[e,r,n]),d=t.useMemo(()=>x?.getValue??(s=>{if(typeof s=="string"||typeof s=="number")return String(s);throw new Error("[BrightLocal DS] ComboboxVirtualList: `getItemValue` is required for non-primitive items without a `value` property.")}),[x]),R=t.useMemo(()=>x?.getLabel??d,[x,d]);U.useDevWarning(()=>!x&&e.length>0,"ComboboxVirtualList: could not infer `getItemValue` from item shape. Pass `getItemValue` explicitly, or use items with a `value` string property.",[x,e.length]);const I=t.useRef(null),{value:C,onValueChange:j,setOpen:N,shouldFilter:y,searchValue:w,filterFn:L,setActiveDescendantId:S,registerItemsSync:D,unregisterItem:V}=z(),[c,k]=t.useState(0),T=t.useId();t.useImperativeHandle(E,()=>I.current,[]),t.useLayoutEffect(()=>{const s=e.map(f=>[d(f),R(f)]);return D(s),()=>{for(const f of e)V(d(f))}},[e,d,R,D,V]);const b=t.useMemo(()=>{if(!y||!w.trim())return e;const s=[];for(const f of e){let h=x?.hasDistinctLabel?B.defaultFilter(R(f),w):L(d(f),w);if(o)for(const M of o(f))h=Math.max(h,B.defaultFilter(M,w));h>0&&s.push({item:f,score:h})}return s.sort((f,h)=>h.score-f.score),s.map(f=>f.item)},[e,y,w,d,R,o,L,x?.hasDistinctLabel]),P=le.useVirtualizer({count:b.length,getScrollElement:()=>I.current,estimateSize:()=>l,overscan:u}),O=c>=0&&c<b.length?d(b[c]):null;t.useEffect(()=>{k(0)},[w,b.length]);const W=t.useRef(!1);t.useEffect(()=>{if(W.current||!C)return;const s=b.findIndex(f=>d(f)===C);s>=0&&(k(s),P.scrollToIndex(s,{align:"center"}),W.current=!0)},[C,b,d,P]);const q=t.useRef(!1);t.useEffect(()=>{q.current&&c>=0&&c<b.length&&P.scrollToIndex(c,{align:"auto"}),q.current=!1},[c,b.length,P]),t.useEffect(()=>{const s=I.current?.closest('[data-slot="combobox-command"]');if(!s)return;const f=h=>{switch(h.key){case"ArrowDown":h.preventDefault(),h.stopPropagation(),q.current=!0,k(M=>M<b.length-1?M+1:M);break;case"ArrowUp":h.preventDefault(),h.stopPropagation(),q.current=!0,k(M=>M>0?M-1:M);break;case"Enter":if(h.preventDefault(),h.stopPropagation(),c>=0&&c<b.length){const M=d(b[c]);j(M===C?"":M),N(!1)}break;case"Home":h.preventDefault(),h.stopPropagation(),q.current=!0,k(0);break;case"End":h.preventDefault(),h.stopPropagation(),q.current=!0,k(b.length-1);break}};return s.addEventListener("keydown",f,{capture:!0}),()=>s.removeEventListener("keydown",f,{capture:!0})},[b,c,C,j,N,d]);const _=t.useMemo(()=>{const s=new Map;return b.forEach((f,h)=>{s.set(d(f),h)}),s},[b,d]),H=t.useCallback(s=>{const f=_.get(s);f!==void 0&&k(f)},[_]),g=t.useCallback(s=>(_.get(s)??0)+1,[_]),A=b.length,G=t.useMemo(()=>({activeValue:O,onItemPointerMove:H,idPrefix:T,filteredCount:A,getItemPosition:g}),[O,H,T,A,g]),J=O!=null?`${T}item-${O}`:void 0;return t.useEffect(()=>(S(J),()=>S(void 0)),[J,S]),b.length===0?i.jsx("div",{ref:I,className:F.cn("scrollbar max-h-[300px] min-h-0 flex-1 scroll-py-1 overflow-x-hidden overflow-y-auto py-1",p),"data-hook":v,"data-slot":"combobox-virtual-list",role:"listbox",children:m}):i.jsx(X.Provider,{value:G,children:i.jsx("div",{ref:I,className:F.cn("scrollbar max-h-[300px] min-h-0 flex-1 scroll-py-1 overflow-x-hidden overflow-y-auto py-1",p),"data-hook":v,"data-slot":"combobox-virtual-list",role:"listbox",children:i.jsx("div",{className:"relative w-full",style:{height:`${P.getTotalSize()}px`},children:P.getVirtualItems().map(s=>i.jsx("div",{ref:P.measureElement,className:"absolute top-0 left-0 w-full px-2","data-index":s.index,style:{transform:`translateY(${s.start}px)`},children:a(b[s.index],s.index,w)},s.key))})})})}const ge=t.forwardRef(xe),re=t.forwardRef((e,r)=>i.jsx($.CommandEmpty,{ref:r,"data-slot":"combobox-empty",...e}));re.displayName="ComboboxEmpty";const ne=t.forwardRef(({children:e,...r},n)=>{const o=t.useRef(null);return U.useDevWarning(()=>o.current?o.current.querySelectorAll('[data-slot="combobox-item"]').length>=100:!1,`ComboboxGroup contains 100+ items. Use <ComboboxVirtualList> for large datasets to avoid DOM bloat and slow renders.
|
|
4
|
+
Import: import { ComboboxVirtualList } from "@brightlocal/ui-components/combobox"`,[e]),i.jsx($.CommandGroup,{ref:l=>{o.current=l,typeof n=="function"?n(l):n&&(n.current=l)},"data-slot":"combobox-group",...r,children:e})});ne.displayName="ComboboxGroup";function he(e,r,n){if(!r||!r.trim())return e;const o=new RegExp(`(${r.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")})`,"gi"),l=e.split(o);return i.jsx("span",{children:l.map((u,a)=>a%2===1?i.jsx("span",{className:n,children:u},a):i.jsx(t.Fragment,{children:u},a))})}const se=t.forwardRef(({value:e,label:r,dataHook:n,children:o,className:l,highlight:u,highlightClassName:a,keywords:m,onSelect:p,...v},E)=>{const{value:x,onValueChange:d,setOpen:R,registerItem:I,unregisterItem:C}=z(),j=t.useContext(X),N=x===e,y=t.useMemo(()=>r||(typeof o=="string"?o:typeof o=="number"?String(o):e),[r,o,e]),w=t.useRef(I),L=t.useRef(C);t.useEffect(()=>{w.current=I,L.current=C},[I,C]);const S=!!j;t.useEffect(()=>{if(!S)return w.current(e,y),()=>L.current(e)},[e,y,S]);const D=()=>{d(e===x?"":e),R(!1),p?.(e)},V=()=>u&&typeof o=="string"?he(o,u,a||"text-sm leading-normal font-semibold"):o;if(j){const c=j.activeValue===e,k=!!v.disabled;return i.jsxs("div",{ref:E,"aria-disabled":k||void 0,"aria-posinset":j.getItemPosition(e),"aria-selected":N,"aria-setsize":j.filteredCount,className:F.cn("data-[highlighted=true]:bg-accent data-[highlighted=true]:text-accent-foreground relative flex cursor-default items-center justify-between gap-2 rounded-sm px-2 py-3 text-sm outline-hidden select-none","[&_svg]:pointer-events-none [&_svg]:shrink-0",k&&"pointer-events-none opacity-50",l),"data-highlighted":c||void 0,"data-hook":n,"data-slot":"combobox-item",id:`${j.idPrefix}item-${e}`,role:"option",tabIndex:-1,onClick:k?void 0:D,onKeyDown:k?void 0:T=>{(T.key==="Enter"||T.key===" ")&&D()},onPointerMove:k?void 0:()=>j.onItemPointerMove(e),children:[V(),N&&i.jsx(K.Check,{"aria-hidden":"true",className:"text-muted-foreground shrink-0"})]})}return i.jsxs($.CommandItem,{ref:E,className:F.cn("justify-between",l),"data-slot":"combobox-item",dataHook:n,keywords:m?[y,...m]:[y],value:e,onSelect:D,...v,children:[V(),N&&i.jsx(K.Check,{"aria-hidden":"true",className:"text-muted-foreground shrink-0"})]})});se.displayName="ComboboxItem";const ae=t.forwardRef((e,r)=>i.jsx($.CommandSeparator,{ref:r,"data-slot":"combobox-separator",...e}));ae.displayName="ComboboxSeparator";function ve({className:e,children:r,loadingText:n}){return i.jsx("div",{"aria-live":"polite",className:F.cn("text-muted-foreground flex items-center justify-center gap-2 py-6 text-sm",e),"data-slot":"combobox-loading",role:"status",children:r||i.jsxs(i.Fragment,{children:[i.jsx("div",{"aria-hidden":"true",className:"size-4 animate-spin rounded-full border-2 border-current border-t-transparent [animation-duration:0.6s]"}),n??"Loading..."]})})}exports.Combobox=de;exports.ComboboxContent=pe;exports.ComboboxEmpty=re;exports.ComboboxGroup=ne;exports.ComboboxInput=te;exports.ComboboxItem=se;exports.ComboboxList=oe;exports.ComboboxLoading=ve;exports.ComboboxSeparator=ae;exports.ComboboxTrigger=Z;exports.ComboboxValue=me;exports.ComboboxVirtualList=ge;
|
package/dist/combobox.js
CHANGED
|
@@ -28,13 +28,13 @@ function Fe({
|
|
|
28
28
|
const [p, v] = t.useState(""), [M, x] = t.useState(!1), [d, L] = t.useState(
|
|
29
29
|
() => /* @__PURE__ */ new Map()
|
|
30
30
|
), [I, C] = t.useState(""), [R, P] = t.useState(void 0), w = e !== void 0, y = n !== void 0, E = w ? e : p, S = y ? n : M, D = t.useCallback(
|
|
31
|
-
(
|
|
32
|
-
|
|
31
|
+
(h) => {
|
|
32
|
+
h || C(""), y || x(h), o?.(h);
|
|
33
33
|
},
|
|
34
34
|
[y, o]
|
|
35
35
|
), V = t.useCallback(
|
|
36
|
-
(
|
|
37
|
-
w || v(
|
|
36
|
+
(h) => {
|
|
37
|
+
w || v(h), r?.(h);
|
|
38
38
|
},
|
|
39
39
|
[w, r]
|
|
40
40
|
), l = t.useRef(/* @__PURE__ */ new Map()), k = t.useRef(!1), T = t.useRef(!0);
|
|
@@ -46,13 +46,13 @@ function Fe({
|
|
|
46
46
|
k.current = !1, T.current && L(new Map(l.current));
|
|
47
47
|
}));
|
|
48
48
|
}, []), F = t.useCallback(
|
|
49
|
-
(
|
|
50
|
-
l.current.get(
|
|
49
|
+
(h, j) => {
|
|
50
|
+
l.current.get(h) !== j && (l.current.set(h, j), f());
|
|
51
51
|
},
|
|
52
52
|
[f]
|
|
53
53
|
), O = t.useCallback(
|
|
54
|
-
(
|
|
55
|
-
for (const [j, U] of
|
|
54
|
+
(h) => {
|
|
55
|
+
for (const [j, U] of h)
|
|
56
56
|
l.current.set(j, U);
|
|
57
57
|
L(new Map(l.current));
|
|
58
58
|
},
|
|
@@ -62,12 +62,12 @@ function Fe({
|
|
|
62
62
|
q.current = E;
|
|
63
63
|
}, [E]);
|
|
64
64
|
const $ = t.useCallback(
|
|
65
|
-
(
|
|
66
|
-
|
|
65
|
+
(h) => {
|
|
66
|
+
h !== q.current && l.current.has(h) && (l.current.delete(h), f());
|
|
67
67
|
},
|
|
68
68
|
[f]
|
|
69
69
|
), z = t.useMemo(
|
|
70
|
-
() => s ? (
|
|
70
|
+
() => s ? (h, j, U) => K(s(h), j, U) : K,
|
|
71
71
|
[s]
|
|
72
72
|
), H = t.useMemo(
|
|
73
73
|
() => ({
|
|
@@ -223,7 +223,7 @@ function Ae({
|
|
|
223
223
|
"span",
|
|
224
224
|
{
|
|
225
225
|
className: A(
|
|
226
|
-
"
|
|
226
|
+
"overflow-hidden text-base leading-normal font-medium text-ellipsis whitespace-nowrap",
|
|
227
227
|
r
|
|
228
228
|
),
|
|
229
229
|
"data-slot": "combobox-value",
|
|
@@ -343,7 +343,7 @@ Set shouldFilter={false} on <Combobox> for async search, or remove debounceMs fo
|
|
|
343
343
|
);
|
|
344
344
|
});
|
|
345
345
|
xe.displayName = "ComboboxInput";
|
|
346
|
-
const
|
|
346
|
+
const he = t.forwardRef(({ className: e, ...r }, n) => /* @__PURE__ */ u(
|
|
347
347
|
de,
|
|
348
348
|
{
|
|
349
349
|
ref: n,
|
|
@@ -352,8 +352,8 @@ const ge = t.forwardRef(({ className: e, ...r }, n) => /* @__PURE__ */ u(
|
|
|
352
352
|
...r
|
|
353
353
|
}
|
|
354
354
|
));
|
|
355
|
-
|
|
356
|
-
function
|
|
355
|
+
he.displayName = "ComboboxList";
|
|
356
|
+
function ge({
|
|
357
357
|
items: e,
|
|
358
358
|
getItemValue: r,
|
|
359
359
|
getItemLabel: n,
|
|
@@ -411,13 +411,13 @@ function he({
|
|
|
411
411
|
if (!w || !y.trim()) return e;
|
|
412
412
|
const a = [];
|
|
413
413
|
for (const b of e) {
|
|
414
|
-
let
|
|
414
|
+
let g = x?.hasDistinctLabel ? K(L(b), y) : E(d(b), y);
|
|
415
415
|
if (o)
|
|
416
416
|
for (const N of o(b))
|
|
417
|
-
|
|
418
|
-
|
|
417
|
+
g = Math.max(g, K(N, y));
|
|
418
|
+
g > 0 && a.push({ item: b, score: g });
|
|
419
419
|
}
|
|
420
|
-
return a.sort((b,
|
|
420
|
+
return a.sort((b, g) => g.score - b.score), a.map((b) => b.item);
|
|
421
421
|
}, [
|
|
422
422
|
e,
|
|
423
423
|
w,
|
|
@@ -450,27 +450,27 @@ function he({
|
|
|
450
450
|
'[data-slot="combobox-command"]'
|
|
451
451
|
);
|
|
452
452
|
if (!a) return;
|
|
453
|
-
const b = (
|
|
454
|
-
switch (
|
|
453
|
+
const b = (g) => {
|
|
454
|
+
switch (g.key) {
|
|
455
455
|
case "ArrowDown":
|
|
456
|
-
|
|
456
|
+
g.preventDefault(), g.stopPropagation(), $.current = !0, k(
|
|
457
457
|
(N) => N < f.length - 1 ? N + 1 : N
|
|
458
458
|
);
|
|
459
459
|
break;
|
|
460
460
|
case "ArrowUp":
|
|
461
|
-
|
|
461
|
+
g.preventDefault(), g.stopPropagation(), $.current = !0, k((N) => N > 0 ? N - 1 : N);
|
|
462
462
|
break;
|
|
463
463
|
case "Enter":
|
|
464
|
-
if (
|
|
464
|
+
if (g.preventDefault(), g.stopPropagation(), l >= 0 && l < f.length) {
|
|
465
465
|
const N = d(f[l]);
|
|
466
466
|
R(N === C ? "" : N), P(!1);
|
|
467
467
|
}
|
|
468
468
|
break;
|
|
469
469
|
case "Home":
|
|
470
|
-
|
|
470
|
+
g.preventDefault(), g.stopPropagation(), $.current = !0, k(0);
|
|
471
471
|
break;
|
|
472
472
|
case "End":
|
|
473
|
-
|
|
473
|
+
g.preventDefault(), g.stopPropagation(), $.current = !0, k(f.length - 1);
|
|
474
474
|
break;
|
|
475
475
|
}
|
|
476
476
|
};
|
|
@@ -478,8 +478,8 @@ function he({
|
|
|
478
478
|
}, [f, l, C, R, P, d]);
|
|
479
479
|
const z = t.useMemo(() => {
|
|
480
480
|
const a = /* @__PURE__ */ new Map();
|
|
481
|
-
return f.forEach((b,
|
|
482
|
-
a.set(d(b),
|
|
481
|
+
return f.forEach((b, g) => {
|
|
482
|
+
a.set(d(b), g);
|
|
483
483
|
}), a;
|
|
484
484
|
}, [f, d]), H = t.useCallback(
|
|
485
485
|
(a) => {
|
|
@@ -487,7 +487,7 @@ function he({
|
|
|
487
487
|
b !== void 0 && k(b);
|
|
488
488
|
},
|
|
489
489
|
[z]
|
|
490
|
-
),
|
|
490
|
+
), h = t.useCallback(
|
|
491
491
|
(a) => (z.get(a) ?? 0) + 1,
|
|
492
492
|
[z]
|
|
493
493
|
), j = f.length, U = t.useMemo(
|
|
@@ -496,9 +496,9 @@ function he({
|
|
|
496
496
|
onItemPointerMove: H,
|
|
497
497
|
idPrefix: T,
|
|
498
498
|
filteredCount: j,
|
|
499
|
-
getItemPosition:
|
|
499
|
+
getItemPosition: h
|
|
500
500
|
}),
|
|
501
|
-
[O, H, T, j,
|
|
501
|
+
[O, H, T, j, h]
|
|
502
502
|
), W = O != null ? `${T}item-${O}` : void 0;
|
|
503
503
|
return t.useEffect(() => (S(W), () => S(void 0)), [W, S]), f.length === 0 ? /* @__PURE__ */ u(
|
|
504
504
|
"div",
|
|
@@ -551,7 +551,7 @@ function he({
|
|
|
551
551
|
}
|
|
552
552
|
) });
|
|
553
553
|
}
|
|
554
|
-
const $e = t.forwardRef(
|
|
554
|
+
const $e = t.forwardRef(ge), ve = t.forwardRef((e, r) => /* @__PURE__ */ u(ie, { ref: r, "data-slot": "combobox-empty", ...e }));
|
|
555
555
|
ve.displayName = "ComboboxEmpty";
|
|
556
556
|
const Ce = t.forwardRef(({ children: e, ...r }, n) => {
|
|
557
557
|
const o = t.useRef(null);
|
|
@@ -716,7 +716,7 @@ export {
|
|
|
716
716
|
Ce as ComboboxGroup,
|
|
717
717
|
xe as ComboboxInput,
|
|
718
718
|
ye as ComboboxItem,
|
|
719
|
-
|
|
719
|
+
he as ComboboxList,
|
|
720
720
|
je as ComboboxLoading,
|
|
721
721
|
ke as ComboboxSeparator,
|
|
722
722
|
me as ComboboxTrigger,
|