@brightlocal/ui-components 1.4.0 → 1.4.2
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 +7 -1
- package/component-meta.json +10 -11
- package/dist/blocks/input-list.cjs +2 -2
- package/dist/blocks/input-list.d.ts +104 -56
- package/dist/blocks/input-list.d.ts.map +1 -1
- package/dist/blocks/input-list.js +182 -173
- package/dist/combobox.cjs +1 -1
- package/dist/combobox.d.ts.map +1 -1
- package/dist/combobox.js +59 -48
- package/dist/index.cjs +1 -1
- package/dist/index.js +128 -124
- package/dist/list.cjs +1 -1
- package/dist/list.d.ts +5 -0
- package/dist/list.d.ts.map +1 -1
- package/dist/list.js +62 -60
- package/dist/select.cjs +1 -1
- package/dist/select.js +1 -1
- package/package.json +2 -2
- package/src/blocks/input-list.tsx +341 -233
- package/src/components/combobox.tsx +15 -5
- package/src/components/list.tsx +32 -21
- package/src/components/select.tsx +1 -1
|
@@ -1,190 +1,199 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { jsx as n, jsxs as D } from "react/jsx-runtime";
|
|
2
2
|
import * as s from "react";
|
|
3
|
-
import { AnimatePresence as
|
|
4
|
-
import { X as
|
|
5
|
-
import { cn as
|
|
6
|
-
import { Button as
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
3
|
+
import { AnimatePresence as K, motion as $ } from "framer-motion";
|
|
4
|
+
import { X as P } from "@brightlocal/icons";
|
|
5
|
+
import { cn as g } from "@brightlocal/ui-components/lib/utils";
|
|
6
|
+
import { Button as B } from "../button.js";
|
|
7
|
+
import { Input as S } from "../input.js";
|
|
8
|
+
import { Item as k, ItemContent as V, ItemTitle as _, ItemActions as j } from "../list.js";
|
|
9
|
+
const A = s.createContext(
|
|
10
|
+
null
|
|
11
|
+
);
|
|
12
|
+
function x() {
|
|
13
|
+
const t = s.useContext(A);
|
|
14
|
+
if (!t)
|
|
15
|
+
throw new Error("InputList components must be used within an <InputList>");
|
|
16
|
+
return t;
|
|
17
|
+
}
|
|
18
|
+
function E({
|
|
19
|
+
value: t,
|
|
20
|
+
onValueChange: a,
|
|
21
|
+
children: f,
|
|
22
|
+
className: r,
|
|
23
|
+
dataHook: l,
|
|
24
|
+
trackingEl: c,
|
|
25
|
+
trackingLabel: I
|
|
26
26
|
}) {
|
|
27
|
-
const [
|
|
28
|
-
|
|
29
|
-
),
|
|
30
|
-
() => n.map((t, e) => e)
|
|
31
|
-
);
|
|
27
|
+
const [p, u] = s.useState(""), o = s.useRef(t.length), i = s.useRef(t.length), [y, h] = s.useState(
|
|
28
|
+
() => t.map((d, e) => e)
|
|
29
|
+
), [w, C] = s.useState(0);
|
|
32
30
|
s.useEffect(() => {
|
|
33
|
-
|
|
34
|
-
|
|
31
|
+
const d = o.current;
|
|
32
|
+
o.current = t.length, t.length > d && u(""), h((e) => e.length === t.length ? e : t.length > e.length ? [
|
|
33
|
+
...e,
|
|
35
34
|
...Array.from(
|
|
36
|
-
{ length:
|
|
37
|
-
() =>
|
|
35
|
+
{ length: t.length - e.length },
|
|
36
|
+
() => i.current++
|
|
38
37
|
)
|
|
39
|
-
] :
|
|
40
|
-
}, [
|
|
41
|
-
const
|
|
42
|
-
(
|
|
43
|
-
const e =
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
u(l);
|
|
49
|
-
return;
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
u(null), g((l) => [
|
|
53
|
-
...l,
|
|
54
|
-
...e.map(() => h.current++)
|
|
55
|
-
]), r([...n, ...e]), N("");
|
|
56
|
-
}
|
|
38
|
+
] : t.length === d ? e.slice(0, t.length) : t.map(() => i.current++));
|
|
39
|
+
}, [t, w]);
|
|
40
|
+
const b = s.useCallback(
|
|
41
|
+
(d) => {
|
|
42
|
+
const e = d.map((m) => m.trim()).filter(Boolean);
|
|
43
|
+
e.length && (h((m) => [
|
|
44
|
+
...m,
|
|
45
|
+
...e.map(() => i.current++)
|
|
46
|
+
]), a([...t, ...e]), C((m) => m + 1));
|
|
57
47
|
},
|
|
58
|
-
[
|
|
59
|
-
),
|
|
60
|
-
(
|
|
61
|
-
|
|
48
|
+
[t, a]
|
|
49
|
+
), L = s.useCallback(
|
|
50
|
+
(d) => {
|
|
51
|
+
h((e) => e.filter((m, R) => R !== d)), a(t.filter((e, m) => m !== d));
|
|
62
52
|
},
|
|
63
|
-
[
|
|
64
|
-
),
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
53
|
+
[t, a]
|
|
54
|
+
), N = s.useMemo(
|
|
55
|
+
() => ({
|
|
56
|
+
value: t,
|
|
57
|
+
inputValue: p,
|
|
58
|
+
setInputValue: u,
|
|
59
|
+
addItems: b,
|
|
60
|
+
removeItem: L,
|
|
61
|
+
stableKeys: y
|
|
62
|
+
}),
|
|
63
|
+
[t, p, b, L, y]
|
|
64
|
+
);
|
|
65
|
+
return /* @__PURE__ */ n(A.Provider, { value: N, children: /* @__PURE__ */ n(
|
|
72
66
|
"div",
|
|
73
67
|
{
|
|
74
|
-
className:
|
|
75
|
-
"data-hook":
|
|
68
|
+
className: g("flex flex-col gap-4", r),
|
|
69
|
+
"data-hook": l,
|
|
76
70
|
"data-slot": "input-list",
|
|
77
|
-
"data-tracking-el":
|
|
78
|
-
"data-tracking-label":
|
|
79
|
-
children:
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
className: $(
|
|
118
|
-
"inline-flex size-9 cursor-pointer items-center justify-center rounded-full",
|
|
119
|
-
"text-muted-foreground",
|
|
120
|
-
"focus-visible:shadow-default outline-none",
|
|
121
|
-
"transition-colors duration-150 ease-in-out",
|
|
122
|
-
"disabled:pointer-events-none disabled:opacity-50"
|
|
123
|
-
),
|
|
124
|
-
"data-hook": `${a}-remove-${e}`,
|
|
125
|
-
disabled: m,
|
|
126
|
-
type: "button",
|
|
127
|
-
onClick: () => w(e),
|
|
128
|
-
children: /* @__PURE__ */ i(T, {})
|
|
129
|
-
}
|
|
130
|
-
) })
|
|
131
|
-
] })
|
|
132
|
-
},
|
|
133
|
-
S[e]
|
|
134
|
-
)) })
|
|
135
|
-
}
|
|
136
|
-
),
|
|
137
|
-
/* @__PURE__ */ c("div", { className: "flex flex-col gap-2", "data-slot": "input-list-input-area", children: [
|
|
138
|
-
/* @__PURE__ */ c("div", { className: "flex gap-2", children: [
|
|
139
|
-
/* @__PURE__ */ i(
|
|
140
|
-
G,
|
|
141
|
-
{
|
|
142
|
-
className: "flex-1",
|
|
143
|
-
dataHook: `${a}-input`,
|
|
144
|
-
disabled: _,
|
|
145
|
-
error: x || !!o,
|
|
146
|
-
placeholder: k,
|
|
147
|
-
value: f,
|
|
148
|
-
onChange: (t) => {
|
|
149
|
-
N(t.target.value), o && u(null);
|
|
150
|
-
},
|
|
151
|
-
onKeyDown: C,
|
|
152
|
-
onPaste: P
|
|
153
|
-
}
|
|
154
|
-
),
|
|
155
|
-
/* @__PURE__ */ i(
|
|
156
|
-
X,
|
|
157
|
-
{
|
|
158
|
-
dataHook: `${a}-add`,
|
|
159
|
-
disabled: j,
|
|
160
|
-
onClick: () => y([f]),
|
|
161
|
-
children: D
|
|
162
|
-
}
|
|
163
|
-
)
|
|
164
|
-
] }),
|
|
165
|
-
x && b || o ? /* @__PURE__ */ i(
|
|
166
|
-
q,
|
|
167
|
-
{
|
|
168
|
-
className: "text-left",
|
|
169
|
-
"data-slot": "input-list-error",
|
|
170
|
-
dataHook: `${a}-error`,
|
|
171
|
-
children: o ?? b
|
|
71
|
+
"data-tracking-el": c,
|
|
72
|
+
"data-tracking-label": I,
|
|
73
|
+
children: f
|
|
74
|
+
}
|
|
75
|
+
) });
|
|
76
|
+
}
|
|
77
|
+
E.displayName = "InputList";
|
|
78
|
+
function z({
|
|
79
|
+
dataHook: t = "input-list",
|
|
80
|
+
loading: a = !1,
|
|
81
|
+
skeletonCount: f = 5,
|
|
82
|
+
disabled: r = !1,
|
|
83
|
+
className: l
|
|
84
|
+
}) {
|
|
85
|
+
const { value: c, removeItem: I, stableKeys: p } = x();
|
|
86
|
+
return a ? /* @__PURE__ */ n(
|
|
87
|
+
"ul",
|
|
88
|
+
{
|
|
89
|
+
className: g("flex flex-col gap-2", l),
|
|
90
|
+
"data-slot": "input-list-skeleton",
|
|
91
|
+
children: Array.from({ length: f }).map((u, o) => /* @__PURE__ */ n(k, { variant: "loading" }, o))
|
|
92
|
+
}
|
|
93
|
+
) : /* @__PURE__ */ n(
|
|
94
|
+
"ul",
|
|
95
|
+
{
|
|
96
|
+
className: g("flex flex-col gap-2", l),
|
|
97
|
+
"data-hook": `${t}-list`,
|
|
98
|
+
"data-slot": "list",
|
|
99
|
+
children: /* @__PURE__ */ n(K, { initial: !1, children: c.map((u, o) => /* @__PURE__ */ n(
|
|
100
|
+
$.li,
|
|
101
|
+
{
|
|
102
|
+
layout: !0,
|
|
103
|
+
animate: { opacity: 1, scale: 1 },
|
|
104
|
+
"data-hook": `${t}-item-${o}`,
|
|
105
|
+
exit: {
|
|
106
|
+
opacity: 0,
|
|
107
|
+
scale: 0.8,
|
|
108
|
+
transition: {
|
|
109
|
+
opacity: { duration: 0.15 },
|
|
110
|
+
scale: { duration: 0.12 }
|
|
172
111
|
}
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
112
|
+
},
|
|
113
|
+
initial: { opacity: 0, scale: 0.8 },
|
|
114
|
+
transition: {
|
|
115
|
+
opacity: { duration: 0.15 },
|
|
116
|
+
scale: { duration: 0.15 },
|
|
117
|
+
layout: {
|
|
118
|
+
type: "spring",
|
|
119
|
+
stiffness: 500,
|
|
120
|
+
damping: 35
|
|
180
121
|
}
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
122
|
+
},
|
|
123
|
+
children: /* @__PURE__ */ n(k, { asChild: !0, variant: "filled", children: /* @__PURE__ */ D("div", { children: [
|
|
124
|
+
/* @__PURE__ */ n(V, { children: /* @__PURE__ */ n(_, { children: u }) }),
|
|
125
|
+
/* @__PURE__ */ n(j, { children: /* @__PURE__ */ n(
|
|
126
|
+
"button",
|
|
127
|
+
{
|
|
128
|
+
"aria-label": `Remove ${u}`,
|
|
129
|
+
className: g(
|
|
130
|
+
"inline-flex size-9 cursor-pointer items-center justify-center rounded-full",
|
|
131
|
+
"text-muted-foreground",
|
|
132
|
+
"focus-visible:shadow-default outline-none",
|
|
133
|
+
"transition-colors duration-150 ease-in-out",
|
|
134
|
+
"disabled:pointer-events-none disabled:opacity-50"
|
|
135
|
+
),
|
|
136
|
+
"data-hook": `${t}-remove-${o}`,
|
|
137
|
+
disabled: r,
|
|
138
|
+
type: "button",
|
|
139
|
+
onClick: () => I(o),
|
|
140
|
+
children: /* @__PURE__ */ n(P, {})
|
|
141
|
+
}
|
|
142
|
+
) })
|
|
143
|
+
] }) })
|
|
144
|
+
},
|
|
145
|
+
p[o]
|
|
146
|
+
)) })
|
|
184
147
|
}
|
|
185
148
|
);
|
|
186
149
|
}
|
|
187
|
-
|
|
150
|
+
z.displayName = "InputListItems";
|
|
151
|
+
const M = s.forwardRef(
|
|
152
|
+
({ dataHook: t, error: a = !1, className: f, ...r }, l) => {
|
|
153
|
+
const { inputValue: c, setInputValue: I, addItems: p } = x(), u = (i) => {
|
|
154
|
+
i.key === "Enter" && (i.preventDefault(), p([c])), r.onKeyDown?.(i);
|
|
155
|
+
}, o = (i) => {
|
|
156
|
+
const h = i.clipboardData.getData("text").split(`
|
|
157
|
+
`);
|
|
158
|
+
h.length > 1 && (i.preventDefault(), p(h)), r.onPaste?.(i);
|
|
159
|
+
};
|
|
160
|
+
return /* @__PURE__ */ n(
|
|
161
|
+
S,
|
|
162
|
+
{
|
|
163
|
+
ref: l,
|
|
164
|
+
...r,
|
|
165
|
+
className: g("flex-1", f),
|
|
166
|
+
dataHook: t,
|
|
167
|
+
error: a,
|
|
168
|
+
value: c,
|
|
169
|
+
onChange: (i) => {
|
|
170
|
+
I(i.target.value), r.onChange?.(i);
|
|
171
|
+
},
|
|
172
|
+
onKeyDown: u,
|
|
173
|
+
onPaste: o
|
|
174
|
+
}
|
|
175
|
+
);
|
|
176
|
+
}
|
|
177
|
+
);
|
|
178
|
+
M.displayName = "InputListInput";
|
|
179
|
+
const T = s.forwardRef(({ dataHook: t, children: a, ...f }, r) => {
|
|
180
|
+
const { inputValue: l, addItems: c } = x();
|
|
181
|
+
return /* @__PURE__ */ n(
|
|
182
|
+
B,
|
|
183
|
+
{
|
|
184
|
+
ref: r,
|
|
185
|
+
...f,
|
|
186
|
+
dataHook: t,
|
|
187
|
+
onClick: () => c([l]),
|
|
188
|
+
children: a
|
|
189
|
+
}
|
|
190
|
+
);
|
|
191
|
+
});
|
|
192
|
+
T.displayName = "InputListAddButton";
|
|
188
193
|
export {
|
|
189
|
-
|
|
194
|
+
E as InputList,
|
|
195
|
+
T as InputListAddButton,
|
|
196
|
+
M as InputListInput,
|
|
197
|
+
z as InputListItems,
|
|
198
|
+
x as useInputListContext
|
|
190
199
|
};
|
package/dist/combobox.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("react/jsx-runtime"),U=require("react"),q=require("@brightlocal/icons"),V=require("class-variance-authority"),$=require("cmdk"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("react/jsx-runtime"),U=require("react"),q=require("@brightlocal/icons"),V=require("class-variance-authority"),$=require("cmdk"),y=require("@brightlocal/ui-components/lib/utils"),T=require("@brightlocal/ui-components/popover"),k=require("@brightlocal/ui-components/command");function z(e){const o=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const a in e)if(a!=="default"){const r=Object.getOwnPropertyDescriptor(e,a);Object.defineProperty(o,a,r.get?r:{enumerable:!0,get:()=>e[a]})}}return o.default=e,Object.freeze(o)}const t=z(U),E=t.createContext(null);function R(){const e=t.useContext(E);if(!e)throw new Error("Combobox components must be used within a <Combobox>");return e}function H({value:e,onValueChange:o,open:a,onOpenChange:r,shouldFilter:c=!0,disabled:u=!1,itemToStringValue:d,children:b}){const[h,C]=t.useState(""),[x,w]=t.useState(!1),[v,i]=t.useState(()=>new Map),f=e!==void 0,p=a!==void 0,s=f?e:h,m=p?a:x,g=t.useCallback(l=>{p||w(l),r?.(l)},[p,r]),j=t.useCallback(l=>{f||C(l),o?.(l)},[f,o]),N=t.useCallback((l,L)=>{i(I=>{if(I.get(l)===L)return I;const O=new Map(I);return O.set(l,L),O})},[]),S=t.useMemo(()=>({open:m,setOpen:g,value:s,onValueChange:j,shouldFilter:c,disabled:u,itemLabels:v,registerItem:N,itemToStringValue:d}),[m,g,s,j,c,u,v,N,d]);return n.jsx(E.Provider,{value:S,children:n.jsx(T.Popover,{open:m,onOpenChange:g,children:b})})}const B=V.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-sm 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"],{variants:{variant:{default:[]}},defaultVariants:{variant:"default"}}),F=t.forwardRef(({className:e,variant:o,dataHook:a,error:r,trackingEl:c,trackingLabel:u,children:d,...b},h)=>{const{open:C,disabled:x,value:w}=R(),v=t.useId(),i=!w,f=r||b["aria-invalid"]===!0||b["aria-invalid"]==="true";return n.jsx(T.PopoverTrigger,{asChild:!0,children:n.jsxs("button",{ref:h,"aria-controls":C?v:void 0,"aria-expanded":C,"aria-haspopup":"listbox","aria-invalid":f?"true":void 0,className:y.cn(B({variant:o}),f&&"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":a,"data-placeholder":i,"data-slot":"combobox-trigger","data-state":C?"open":"closed","data-tracking-el":c||"combobox-trigger","data-tracking-label":u,disabled:x||b.disabled,role:"combobox",type:"button",...b,children:[d,n.jsx(q.ChevronsUpDown,{"aria-hidden":"true",className:"text-muted-foreground ml-auto shrink-0"})]})})});F.displayName="ComboboxTrigger";function J({placeholder:e,className:o}){const{value:a,itemLabels:r}=R(),c=a?r.get(a)||a:e;return n.jsx("span",{className:y.cn("text-foreground overflow-hidden text-sm leading-normal font-medium text-ellipsis whitespace-nowrap",o),"data-slot":"combobox-value",children:c})}function K({dataHook:e,className:o,children:a,align:r="start",side:c="bottom",sideOffset:u,avoidCollisions:d,hideList:b=!1}){const{open:h,shouldFilter:C,itemToStringValue:x}=R(),[w,v]=t.useState(null),i=t.useRef(null),f=t.useCallback(s=>{if(i.current?.(),i.current=null,!s)return;let m=!1;const g=l=>{m||(l==="top"||l==="bottom")&&(m=!0,j.disconnect(),v(l))},j=new MutationObserver(()=>{g(s.getAttribute("data-side"))});j.observe(s,{attributes:!0,attributeFilter:["data-side"]});let N=0,S=0;N=requestAnimationFrame(()=>{S=requestAnimationFrame(()=>{g(s.getAttribute("data-side"))})}),i.current=()=>{m=!0,j.disconnect(),cancelAnimationFrame(N),cancelAnimationFrame(S)}},[]);t.useEffect(()=>{if(!h){i.current?.(),i.current=null;const s=setTimeout(()=>v(null),150);return()=>clearTimeout(s)}},[h]);const p=t.useMemo(()=>{if(x)return(s,m,g)=>$.defaultFilter(x(s),m,g)},[x]);return n.jsx(T.PopoverContent,{ref:f,align:r,"aria-label":"Options",avoidCollisions:d,className:y.cn("flex max-h-[var(--radix-popover-content-available-height)] w-[var(--radix-popover-trigger-width)] flex-col overflow-hidden p-0",o),"data-slot":"combobox-popover",side:w??c,sideOffset:u,children:n.jsx(k.Command,{className:y.cn("min-h-0 flex-1 border-0 shadow-none","[&_[data-slot='command-input-wrapper']]:shrink-0",b&&"[&_[data-slot='command-input-wrapper']]:border-b-0"),"data-slot":"combobox-command",dataHook:e||"combobox-command",filter:p,shouldFilter:C,children:a})})}const M=t.forwardRef((e,o)=>n.jsx(k.CommandInput,{ref:o,"data-slot":"combobox-input",...e}));M.displayName="ComboboxInput";const P=t.forwardRef(({className:e,...o},a)=>n.jsx(k.CommandList,{ref:a,className:y.cn("min-h-0 flex-1",e),"data-slot":"combobox-list",...o}));P.displayName="ComboboxList";const A=t.forwardRef((e,o)=>n.jsx(k.CommandEmpty,{ref:o,"data-slot":"combobox-empty",...e}));A.displayName="ComboboxEmpty";const _=t.forwardRef((e,o)=>n.jsx(k.CommandGroup,{ref:o,"data-slot":"combobox-group",...e}));_.displayName="ComboboxGroup";function Q(e,o,a){if(!o||!o.trim())return e;const r=new RegExp(`(${o.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")})`,"gi"),c=e.split(r);return n.jsx("span",{children:c.map((u,d)=>d%2===1?n.jsx("span",{className:a,children:u},d):n.jsx(t.Fragment,{children:u},d))})}const G=t.forwardRef(({value:e,label:o,dataHook:a,children:r,className:c,highlight:u,highlightClassName:d,keywords:b,...h},C)=>{const{value:x,onValueChange:w,setOpen:v,registerItem:i}=R(),f=x===e,p=t.useMemo(()=>o||(typeof r=="string"?r:typeof r=="number"?String(r):e),[o,r,e]),s=t.useRef(i);t.useEffect(()=>{s.current=i},[i]),t.useEffect(()=>{s.current(e,p)},[e,p]);const m=()=>{w(e===x?"":e),v(!1)},g=()=>u&&typeof r=="string"?Q(r,u,d||"text-sm leading-normal font-semibold"):r;return n.jsxs(k.CommandItem,{ref:C,className:y.cn("justify-between",c),"data-slot":"combobox-item",dataHook:a,keywords:b?[p,...b]:[p],value:e,onSelect:m,...h,children:[g(),f&&n.jsx(q.Check,{"aria-hidden":"true",className:"text-muted-foreground shrink-0"})]})});G.displayName="ComboboxItem";const D=t.forwardRef((e,o)=>n.jsx(k.CommandSeparator,{ref:o,"data-slot":"combobox-separator",...e}));D.displayName="ComboboxSeparator";function W({className:e,children:o}){return n.jsx("div",{"aria-disabled":"true","aria-selected":"false",className:y.cn("text-muted-foreground flex items-center justify-center gap-2 py-6 text-sm",e),"data-slot":"combobox-loading",role:"option",children:o||n.jsxs(n.Fragment,{children:[n.jsx("div",{"aria-hidden":"true",className:"size-4 animate-spin rounded-full border-2 border-current border-t-transparent [animation-duration:0.6s]"}),"Loading..."]})})}exports.Combobox=H;exports.ComboboxContent=K;exports.ComboboxEmpty=A;exports.ComboboxGroup=_;exports.ComboboxInput=M;exports.ComboboxItem=G;exports.ComboboxList=P;exports.ComboboxLoading=W;exports.ComboboxSeparator=D;exports.ComboboxTrigger=F;exports.ComboboxValue=J;
|
package/dist/combobox.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"combobox.d.ts","sourceRoot":"","sources":["../../src/components/combobox.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAO,KAAK,YAAY,EAAE,MAAM,0BAA0B,CAAC;AASlE,OAAO,EAEL,YAAY,EACZ,YAAY,EACZ,YAAY,EACZ,WAAW,EACX,WAAW,EACX,gBAAgB,EACjB,MAAM,oCAAoC,CAAC;AAkC5C,MAAM,WAAW,aAAa;IAC5B,gCAAgC;IAChC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,kCAAkC;IAClC,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACxC,4BAA4B;IAC5B,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,uCAAuC;IACvC,YAAY,CAAC,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,CAAC;IACvC,+EAA+E;IAC/E,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,qBAAqB;IACrB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,kHAAkH;IAClH,iBAAiB,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,MAAM,CAAC;IAC9C,eAAe;IACf,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;CAC3B;AAED,iBAAS,QAAQ,CAAC,EAChB,KAAK,EAAE,eAAe,EACtB,aAAa,EAAE,uBAAuB,EACtC,IAAI,EAAE,cAAc,EACpB,YAAY,EAAE,sBAAsB,EACpC,YAAmB,EACnB,QAAgB,EAChB,iBAAiB,EACjB,QAAQ,GACT,EAAE,aAAa,2CA0Ef;AAMD,QAAA,MAAM,uBAAuB;;
|
|
1
|
+
{"version":3,"file":"combobox.d.ts","sourceRoot":"","sources":["../../src/components/combobox.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAO,KAAK,YAAY,EAAE,MAAM,0BAA0B,CAAC;AASlE,OAAO,EAEL,YAAY,EACZ,YAAY,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