@brightlocal/ui-components 1.4.1 → 1.4.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/component-meta.json +1 -1
- package/dist/blocks/input-list.cjs +2 -2
- package/dist/blocks/input-list.d.ts.map +1 -1
- package/dist/blocks/input-list.js +47 -47
- package/dist/combobox.cjs +1 -1
- package/dist/combobox.d.ts.map +1 -1
- package/dist/combobox.js +59 -48
- package/dist/select.cjs +1 -1
- package/dist/select.js +1 -1
- package/package.json +2 -2
- package/src/blocks/input-list.tsx +5 -7
- package/src/components/combobox.tsx +15 -5
- package/src/components/select.tsx +1 -1
package/component-meta.json
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),_=require("react"),k=require("framer-motion"),K=require("@brightlocal/icons"),x=require("@brightlocal/ui-components/lib/utils"),O=require("../button.cjs"),$=require("../input.cjs"),g=require("../list.cjs");function B(t){const s=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const
|
|
2
|
-
`);h.length>1&&(
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),_=require("react"),k=require("framer-motion"),K=require("@brightlocal/icons"),x=require("@brightlocal/ui-components/lib/utils"),O=require("../button.cjs"),$=require("../input.cjs"),g=require("../list.cjs");function B(t){const s=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const r in t)if(r!=="default"){const i=Object.getOwnPropertyDescriptor(t,r);Object.defineProperty(s,r,i.get?i:{enumerable:!0,get:()=>t[r]})}}return s.default=t,Object.freeze(s)}const a=B(_),A=a.createContext(null);function y(){const t=a.useContext(A);if(!t)throw new Error("InputList components must be used within an <InputList>");return t}function w({value:t,onValueChange:s,children:r,className:i,dataHook:u,trackingEl:c,trackingLabel:I}){const[f,d]=a.useState(""),l=a.useRef(t.length),o=a.useRef(t.length),[b,h]=a.useState(()=>t.map((m,n)=>n)),[N,q]=a.useState(0);a.useEffect(()=>{const m=l.current;l.current=t.length,t.length>m&&d(""),h(n=>n.length===t.length?n:t.length>n.length?[...n,...Array.from({length:t.length-n.length},()=>o.current++)]:n.slice(0,t.length))},[t,N]);const j=a.useCallback(m=>{const n=m.map(p=>p.trim()).filter(Boolean);n.length&&(h(p=>[...p,...n.map(()=>o.current++)]),s([...t,...n]),q(p=>p+1))},[t,s]),L=a.useCallback(m=>{h(n=>n.filter((p,S)=>S!==m)),s(t.filter((n,p)=>p!==m))},[t,s]),P=a.useMemo(()=>({value:t,inputValue:f,setInputValue:d,addItems:j,removeItem:L,stableKeys:b}),[t,f,j,L,b]);return e.jsx(A.Provider,{value:P,children:e.jsx("div",{className:x.cn("flex flex-col gap-4",i),"data-hook":u,"data-slot":"input-list","data-tracking-el":c,"data-tracking-label":I,children:r})})}w.displayName="InputList";function C({dataHook:t="input-list",loading:s=!1,skeletonCount:r=5,disabled:i=!1,className:u}){const{value:c,removeItem:I,stableKeys:f}=y();return s?e.jsx("ul",{className:x.cn("flex flex-col gap-2",u),"data-slot":"input-list-skeleton",children:Array.from({length:r}).map((d,l)=>e.jsx(g.Item,{variant:"loading"},l))}):e.jsx("ul",{className:x.cn("flex flex-col gap-2",u),"data-hook":`${t}-list`,"data-slot":"list",children:e.jsx(k.AnimatePresence,{initial:!1,mode:"popLayout",children:c.map((d,l)=>e.jsx(k.motion.li,{layout:!0,animate:{opacity:1,scale:1},"data-hook":`${t}-item-${l}`,exit:{opacity:0,scale:.8,transition:{opacity:{duration:.15},scale:{duration:.12}}},initial:{opacity:0,scale:.8},transition:{opacity:{duration:.15},scale:{duration:.15},layout:{type:"spring",stiffness:500,damping:35}},children:e.jsx(g.Item,{asChild:!0,variant:"filled",children:e.jsxs("div",{children:[e.jsx(g.ItemContent,{children:e.jsx(g.ItemTitle,{children:d})}),e.jsx(g.ItemActions,{children:e.jsx("button",{"aria-label":`Remove ${d}`,className:x.cn("inline-flex size-9 cursor-pointer items-center justify-center rounded-full","text-muted-foreground","focus-visible:shadow-default outline-none","transition-colors duration-150 ease-in-out","disabled:pointer-events-none disabled:opacity-50"),"data-hook":`${t}-remove-${l}`,disabled:i,type:"button",onClick:()=>I(l),children:e.jsx(K.X,{})})})]})})},f[l]))})})}C.displayName="InputListItems";const R=a.forwardRef(({dataHook:t,error:s=!1,className:r,...i},u)=>{const{inputValue:c,setInputValue:I,addItems:f}=y(),d=o=>{o.key==="Enter"&&(o.preventDefault(),f([c])),i.onKeyDown?.(o)},l=o=>{const h=o.clipboardData.getData("text").split(`
|
|
2
|
+
`);h.length>1&&(o.preventDefault(),f(h)),i.onPaste?.(o)};return e.jsx($.Input,{ref:u,...i,className:x.cn("flex-1",r),dataHook:t,error:s,value:c,onChange:o=>{I(o.target.value),i.onChange?.(o)},onKeyDown:d,onPaste:l})});R.displayName="InputListInput";const D=a.forwardRef(({dataHook:t,children:s,...r},i)=>{const{inputValue:u,addItems:c}=y();return e.jsx(O.Button,{ref:i,...r,dataHook:t,onClick:()=>c([u]),children:s})});D.displayName="InputListAddButton";exports.InputList=w;exports.InputListAddButton=D;exports.InputListInput=R;exports.InputListItems=C;exports.useInputListContext=y;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"input-list.d.ts","sourceRoot":"","sources":["../../src/blocks/input-list.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAK/B,OAAO,EAAU,KAAK,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAQhE,UAAU,qBAAqB;IAC7B,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,UAAU,EAAE,MAAM,CAAC;IACnB,aAAa,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACvC,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,IAAI,CAAC;IACpC,UAAU,EAAE,CAAC,KAAK,EAAE,MA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,OAAO,CAAC;CACjB;AAED;;;;;;;;GAQG;AACH,QAAA,MAAM,cAAc,8FAuCnB,CAAC;AAOF;;;GAGG;AACH,MAAM,MAAM,uBAAuB,GAAG,IAAI,CAAC,WAAW,EAAE,SAAS,CAAC,CAAC;AAEnE;;;;;;;;GAQG;AACH,QAAA,MAAM,kBAAkB,gHAgBtB,CAAC;AAOH,OAAO,EACL,SAAS,EACT,cAAc,EACd,cAAc,EACd,kBAAkB,EAClB,mBAAmB,GACpB,CAAC"}
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import { jsx as n, jsxs as D } from "react/jsx-runtime";
|
|
2
|
-
import * as
|
|
2
|
+
import * as i from "react";
|
|
3
3
|
import { AnimatePresence as K, motion as $ } from "framer-motion";
|
|
4
4
|
import { X as P } from "@brightlocal/icons";
|
|
5
5
|
import { cn as g } from "@brightlocal/ui-components/lib/utils";
|
|
6
6
|
import { Button as B } from "../button.js";
|
|
7
7
|
import { Input as S } from "../input.js";
|
|
8
8
|
import { Item as k, ItemContent as V, ItemTitle as _, ItemActions as j } from "../list.js";
|
|
9
|
-
const A =
|
|
9
|
+
const A = i.createContext(
|
|
10
10
|
null
|
|
11
11
|
);
|
|
12
12
|
function x() {
|
|
13
|
-
const t =
|
|
13
|
+
const t = i.useContext(A);
|
|
14
14
|
if (!t)
|
|
15
15
|
throw new Error("InputList components must be used within an <InputList>");
|
|
16
16
|
return t;
|
|
@@ -18,49 +18,49 @@ function x() {
|
|
|
18
18
|
function E({
|
|
19
19
|
value: t,
|
|
20
20
|
onValueChange: a,
|
|
21
|
-
children:
|
|
21
|
+
children: m,
|
|
22
22
|
className: r,
|
|
23
23
|
dataHook: l,
|
|
24
24
|
trackingEl: c,
|
|
25
25
|
trackingLabel: I
|
|
26
26
|
}) {
|
|
27
|
-
const [p, u] =
|
|
28
|
-
() => t.map((
|
|
29
|
-
), [w, C] =
|
|
30
|
-
|
|
31
|
-
const
|
|
32
|
-
|
|
27
|
+
const [p, u] = i.useState(""), s = i.useRef(t.length), o = i.useRef(t.length), [y, h] = i.useState(
|
|
28
|
+
() => t.map((f, e) => e)
|
|
29
|
+
), [w, C] = i.useState(0);
|
|
30
|
+
i.useEffect(() => {
|
|
31
|
+
const f = s.current;
|
|
32
|
+
s.current = t.length, t.length > f && u(""), h((e) => e.length === t.length ? e : t.length > e.length ? [
|
|
33
33
|
...e,
|
|
34
34
|
...Array.from(
|
|
35
35
|
{ length: t.length - e.length },
|
|
36
|
-
() =>
|
|
36
|
+
() => o.current++
|
|
37
37
|
)
|
|
38
|
-
] :
|
|
38
|
+
] : e.slice(0, t.length));
|
|
39
39
|
}, [t, w]);
|
|
40
|
-
const
|
|
41
|
-
(
|
|
42
|
-
const e =
|
|
43
|
-
e.length && (h((
|
|
44
|
-
...
|
|
45
|
-
...e.map(() =>
|
|
46
|
-
]), a([...t, ...e]), C((
|
|
40
|
+
const L = i.useCallback(
|
|
41
|
+
(f) => {
|
|
42
|
+
const e = f.map((d) => d.trim()).filter(Boolean);
|
|
43
|
+
e.length && (h((d) => [
|
|
44
|
+
...d,
|
|
45
|
+
...e.map(() => o.current++)
|
|
46
|
+
]), a([...t, ...e]), C((d) => d + 1));
|
|
47
47
|
},
|
|
48
48
|
[t, a]
|
|
49
|
-
),
|
|
50
|
-
(
|
|
51
|
-
h((e) => e.filter((
|
|
49
|
+
), b = i.useCallback(
|
|
50
|
+
(f) => {
|
|
51
|
+
h((e) => e.filter((d, R) => R !== f)), a(t.filter((e, d) => d !== f));
|
|
52
52
|
},
|
|
53
53
|
[t, a]
|
|
54
|
-
), N =
|
|
54
|
+
), N = i.useMemo(
|
|
55
55
|
() => ({
|
|
56
56
|
value: t,
|
|
57
57
|
inputValue: p,
|
|
58
58
|
setInputValue: u,
|
|
59
|
-
addItems:
|
|
60
|
-
removeItem:
|
|
59
|
+
addItems: L,
|
|
60
|
+
removeItem: b,
|
|
61
61
|
stableKeys: y
|
|
62
62
|
}),
|
|
63
|
-
[t, p,
|
|
63
|
+
[t, p, L, b, y]
|
|
64
64
|
);
|
|
65
65
|
return /* @__PURE__ */ n(A.Provider, { value: N, children: /* @__PURE__ */ n(
|
|
66
66
|
"div",
|
|
@@ -70,7 +70,7 @@ function E({
|
|
|
70
70
|
"data-slot": "input-list",
|
|
71
71
|
"data-tracking-el": c,
|
|
72
72
|
"data-tracking-label": I,
|
|
73
|
-
children:
|
|
73
|
+
children: m
|
|
74
74
|
}
|
|
75
75
|
) });
|
|
76
76
|
}
|
|
@@ -78,7 +78,7 @@ E.displayName = "InputList";
|
|
|
78
78
|
function z({
|
|
79
79
|
dataHook: t = "input-list",
|
|
80
80
|
loading: a = !1,
|
|
81
|
-
skeletonCount:
|
|
81
|
+
skeletonCount: m = 5,
|
|
82
82
|
disabled: r = !1,
|
|
83
83
|
className: l
|
|
84
84
|
}) {
|
|
@@ -88,7 +88,7 @@ function z({
|
|
|
88
88
|
{
|
|
89
89
|
className: g("flex flex-col gap-2", l),
|
|
90
90
|
"data-slot": "input-list-skeleton",
|
|
91
|
-
children: Array.from({ length:
|
|
91
|
+
children: Array.from({ length: m }).map((u, s) => /* @__PURE__ */ n(k, { variant: "loading" }, s))
|
|
92
92
|
}
|
|
93
93
|
) : /* @__PURE__ */ n(
|
|
94
94
|
"ul",
|
|
@@ -96,12 +96,12 @@ function z({
|
|
|
96
96
|
className: g("flex flex-col gap-2", l),
|
|
97
97
|
"data-hook": `${t}-list`,
|
|
98
98
|
"data-slot": "list",
|
|
99
|
-
children: /* @__PURE__ */ n(K, { initial: !1, children: c.map((u,
|
|
99
|
+
children: /* @__PURE__ */ n(K, { initial: !1, mode: "popLayout", children: c.map((u, s) => /* @__PURE__ */ n(
|
|
100
100
|
$.li,
|
|
101
101
|
{
|
|
102
102
|
layout: !0,
|
|
103
103
|
animate: { opacity: 1, scale: 1 },
|
|
104
|
-
"data-hook": `${t}-item-${
|
|
104
|
+
"data-hook": `${t}-item-${s}`,
|
|
105
105
|
exit: {
|
|
106
106
|
opacity: 0,
|
|
107
107
|
scale: 0.8,
|
|
@@ -133,56 +133,56 @@ function z({
|
|
|
133
133
|
"transition-colors duration-150 ease-in-out",
|
|
134
134
|
"disabled:pointer-events-none disabled:opacity-50"
|
|
135
135
|
),
|
|
136
|
-
"data-hook": `${t}-remove-${
|
|
136
|
+
"data-hook": `${t}-remove-${s}`,
|
|
137
137
|
disabled: r,
|
|
138
138
|
type: "button",
|
|
139
|
-
onClick: () => I(
|
|
139
|
+
onClick: () => I(s),
|
|
140
140
|
children: /* @__PURE__ */ n(P, {})
|
|
141
141
|
}
|
|
142
142
|
) })
|
|
143
143
|
] }) })
|
|
144
144
|
},
|
|
145
|
-
p[
|
|
145
|
+
p[s]
|
|
146
146
|
)) })
|
|
147
147
|
}
|
|
148
148
|
);
|
|
149
149
|
}
|
|
150
150
|
z.displayName = "InputListItems";
|
|
151
|
-
const M =
|
|
152
|
-
({ dataHook: t, error: a = !1, className:
|
|
153
|
-
const { inputValue: c, setInputValue: I, addItems: p } = x(), u = (
|
|
154
|
-
|
|
155
|
-
},
|
|
156
|
-
const h =
|
|
151
|
+
const M = i.forwardRef(
|
|
152
|
+
({ dataHook: t, error: a = !1, className: m, ...r }, l) => {
|
|
153
|
+
const { inputValue: c, setInputValue: I, addItems: p } = x(), u = (o) => {
|
|
154
|
+
o.key === "Enter" && (o.preventDefault(), p([c])), r.onKeyDown?.(o);
|
|
155
|
+
}, s = (o) => {
|
|
156
|
+
const h = o.clipboardData.getData("text").split(`
|
|
157
157
|
`);
|
|
158
|
-
h.length > 1 && (
|
|
158
|
+
h.length > 1 && (o.preventDefault(), p(h)), r.onPaste?.(o);
|
|
159
159
|
};
|
|
160
160
|
return /* @__PURE__ */ n(
|
|
161
161
|
S,
|
|
162
162
|
{
|
|
163
163
|
ref: l,
|
|
164
164
|
...r,
|
|
165
|
-
className: g("flex-1",
|
|
165
|
+
className: g("flex-1", m),
|
|
166
166
|
dataHook: t,
|
|
167
167
|
error: a,
|
|
168
168
|
value: c,
|
|
169
|
-
onChange: (
|
|
170
|
-
I(
|
|
169
|
+
onChange: (o) => {
|
|
170
|
+
I(o.target.value), r.onChange?.(o);
|
|
171
171
|
},
|
|
172
172
|
onKeyDown: u,
|
|
173
|
-
onPaste:
|
|
173
|
+
onPaste: s
|
|
174
174
|
}
|
|
175
175
|
);
|
|
176
176
|
}
|
|
177
177
|
);
|
|
178
178
|
M.displayName = "InputListInput";
|
|
179
|
-
const T =
|
|
179
|
+
const T = i.forwardRef(({ dataHook: t, children: a, ...m }, r) => {
|
|
180
180
|
const { inputValue: l, addItems: c } = x();
|
|
181
181
|
return /* @__PURE__ */ n(
|
|
182
182
|
B,
|
|
183
183
|
{
|
|
184
184
|
ref: r,
|
|
185
|
-
...
|
|
185
|
+
...m,
|
|
186
186
|
dataHook: t,
|
|
187
187
|
onClick: () => c([l]),
|
|
188
188
|
children: a
|
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,SAA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AAC;AAOF,MAAM,MAAM,sBAAsB,GAAG,KAAK,CAAC,cAAc,CACvD,OAAO,gBAAgB,CACxB,CAAC;AAEF,QAAA,MAAM,iBAAiB,2MAOrB,CAAC;AAOH,MAAM,WAAW,oBAAoB;IACnC,uBAAuB;IACvB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,wCAAwC;IACxC,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;CAC5B;AAED,iBAAS,eAAe,CAAC,EAAE,SAAS,EAAE,QAAQ,EAAE,EAAE,oBAAoB,2CAuBrE;AAMD,OAAO,EACL,QAAQ,EACR,eAAe,EACf,aAAa,EACb,eAAe,EACf,aAAa,EACb,YAAY,EACZ,aAAa,EACb,aAAa,EACb,YAAY,EACZ,iBAAiB,EACjB,eAAe,GAChB,CAAC"}
|
package/dist/combobox.js
CHANGED
|
@@ -4,7 +4,7 @@ import { Check as M, ChevronsUpDown as j } from "@brightlocal/icons";
|
|
|
4
4
|
import { cva as O } from "class-variance-authority";
|
|
5
5
|
import { defaultFilter as P } from "cmdk";
|
|
6
6
|
import { cn as y } from "@brightlocal/ui-components/lib/utils";
|
|
7
|
-
import { Popover as
|
|
7
|
+
import { Popover as _, PopoverContent as G, PopoverTrigger as U } from "@brightlocal/ui-components/popover";
|
|
8
8
|
import { Command as $, CommandEmpty as q, CommandGroup as z, CommandInput as D, CommandItem as H, CommandList as V, CommandSeparator as B } from "@brightlocal/ui-components/command";
|
|
9
9
|
const F = t.createContext(null);
|
|
10
10
|
function I() {
|
|
@@ -20,52 +20,52 @@ function ue({
|
|
|
20
20
|
onOpenChange: r,
|
|
21
21
|
shouldFilter: d = !0,
|
|
22
22
|
disabled: u = !1,
|
|
23
|
-
itemToStringValue:
|
|
23
|
+
itemToStringValue: l,
|
|
24
24
|
children: m
|
|
25
25
|
}) {
|
|
26
|
-
const [h,
|
|
26
|
+
const [h, g] = t.useState(""), [f, w] = t.useState(!1), [C, i] = t.useState(
|
|
27
27
|
() => /* @__PURE__ */ new Map()
|
|
28
|
-
), p = e !== void 0, x = n !== void 0, s = p ? e : h, b = x ? n : f,
|
|
29
|
-
(
|
|
30
|
-
x || w(
|
|
28
|
+
), p = e !== void 0, x = n !== void 0, s = p ? e : h, b = x ? n : f, v = t.useCallback(
|
|
29
|
+
(c) => {
|
|
30
|
+
x || w(c), r?.(c);
|
|
31
31
|
},
|
|
32
32
|
[x, r]
|
|
33
33
|
), k = t.useCallback(
|
|
34
|
-
(
|
|
35
|
-
p ||
|
|
34
|
+
(c) => {
|
|
35
|
+
p || g(c), o?.(c);
|
|
36
36
|
},
|
|
37
37
|
[p, o]
|
|
38
|
-
), N = t.useCallback((
|
|
38
|
+
), N = t.useCallback((c, L) => {
|
|
39
39
|
i((S) => {
|
|
40
|
-
if (S.get(
|
|
40
|
+
if (S.get(c) === L) return S;
|
|
41
41
|
const T = new Map(S);
|
|
42
|
-
return T.set(
|
|
42
|
+
return T.set(c, L), T;
|
|
43
43
|
});
|
|
44
44
|
}, []), R = t.useMemo(
|
|
45
45
|
() => ({
|
|
46
46
|
open: b,
|
|
47
|
-
setOpen:
|
|
47
|
+
setOpen: v,
|
|
48
48
|
value: s,
|
|
49
49
|
onValueChange: k,
|
|
50
50
|
shouldFilter: d,
|
|
51
51
|
disabled: u,
|
|
52
52
|
itemLabels: C,
|
|
53
53
|
registerItem: N,
|
|
54
|
-
itemToStringValue:
|
|
54
|
+
itemToStringValue: l
|
|
55
55
|
}),
|
|
56
56
|
[
|
|
57
57
|
b,
|
|
58
|
-
|
|
58
|
+
v,
|
|
59
59
|
s,
|
|
60
60
|
k,
|
|
61
61
|
d,
|
|
62
62
|
u,
|
|
63
63
|
C,
|
|
64
64
|
N,
|
|
65
|
-
|
|
65
|
+
l
|
|
66
66
|
]
|
|
67
67
|
);
|
|
68
|
-
return /* @__PURE__ */ a(F.Provider, { value: R, children: /* @__PURE__ */ a(
|
|
68
|
+
return /* @__PURE__ */ a(F.Provider, { value: R, children: /* @__PURE__ */ a(_, { open: b, onOpenChange: v, children: m }) });
|
|
69
69
|
}
|
|
70
70
|
const J = O(
|
|
71
71
|
[
|
|
@@ -87,7 +87,6 @@ const J = O(
|
|
|
87
87
|
"data-[state=open]:border-ring",
|
|
88
88
|
// Disabled state
|
|
89
89
|
"disabled:cursor-not-allowed disabled:opacity-50",
|
|
90
|
-
"disabled:hover:bg-neutral-50",
|
|
91
90
|
// Transitions
|
|
92
91
|
"transition-[background-color,border-color,box-shadow] duration-200 ease-out",
|
|
93
92
|
// Icon styles
|
|
@@ -111,16 +110,16 @@ const J = O(
|
|
|
111
110
|
error: r,
|
|
112
111
|
trackingEl: d,
|
|
113
112
|
trackingLabel: u,
|
|
114
|
-
children:
|
|
113
|
+
children: l,
|
|
115
114
|
...m
|
|
116
115
|
}, h) => {
|
|
117
|
-
const { open:
|
|
118
|
-
return /* @__PURE__ */ a(
|
|
116
|
+
const { open: g, disabled: f, value: w } = I(), C = t.useId(), i = !w, p = r || m["aria-invalid"] === !0 || m["aria-invalid"] === "true";
|
|
117
|
+
return /* @__PURE__ */ a(U, { asChild: !0, children: /* @__PURE__ */ E(
|
|
119
118
|
"button",
|
|
120
119
|
{
|
|
121
120
|
ref: h,
|
|
122
|
-
"aria-controls":
|
|
123
|
-
"aria-expanded":
|
|
121
|
+
"aria-controls": g ? C : void 0,
|
|
122
|
+
"aria-expanded": g,
|
|
124
123
|
"aria-haspopup": "listbox",
|
|
125
124
|
"aria-invalid": p ? "true" : void 0,
|
|
126
125
|
className: y(
|
|
@@ -131,7 +130,7 @@ const J = O(
|
|
|
131
130
|
"data-hook": n,
|
|
132
131
|
"data-placeholder": i,
|
|
133
132
|
"data-slot": "combobox-trigger",
|
|
134
|
-
"data-state":
|
|
133
|
+
"data-state": g ? "open" : "closed",
|
|
135
134
|
"data-tracking-el": d || "combobox-trigger",
|
|
136
135
|
"data-tracking-label": u,
|
|
137
136
|
disabled: f || m.disabled,
|
|
@@ -139,7 +138,7 @@ const J = O(
|
|
|
139
138
|
type: "button",
|
|
140
139
|
...m,
|
|
141
140
|
children: [
|
|
142
|
-
|
|
141
|
+
l,
|
|
143
142
|
/* @__PURE__ */ a(
|
|
144
143
|
j,
|
|
145
144
|
{
|
|
@@ -153,7 +152,7 @@ const J = O(
|
|
|
153
152
|
}
|
|
154
153
|
);
|
|
155
154
|
K.displayName = "ComboboxTrigger";
|
|
156
|
-
function
|
|
155
|
+
function le({ placeholder: e, className: o }) {
|
|
157
156
|
const { value: n, itemLabels: r } = I(), d = n ? r.get(n) || n : e;
|
|
158
157
|
return /* @__PURE__ */ a(
|
|
159
158
|
"span",
|
|
@@ -167,25 +166,25 @@ function ce({ placeholder: e, className: o }) {
|
|
|
167
166
|
}
|
|
168
167
|
);
|
|
169
168
|
}
|
|
170
|
-
function
|
|
169
|
+
function ce({
|
|
171
170
|
dataHook: e,
|
|
172
171
|
className: o,
|
|
173
172
|
children: n,
|
|
174
173
|
align: r = "start",
|
|
175
174
|
side: d = "bottom",
|
|
176
175
|
sideOffset: u,
|
|
177
|
-
avoidCollisions:
|
|
176
|
+
avoidCollisions: l,
|
|
178
177
|
hideList: m = !1
|
|
179
178
|
}) {
|
|
180
|
-
const { open: h, shouldFilter:
|
|
179
|
+
const { open: h, shouldFilter: g, itemToStringValue: f } = I(), [w, C] = t.useState(
|
|
181
180
|
null
|
|
182
181
|
), i = t.useRef(null), p = t.useCallback((s) => {
|
|
183
182
|
if (i.current?.(), i.current = null, !s) return;
|
|
184
183
|
let b = !1;
|
|
185
|
-
const
|
|
186
|
-
b || (
|
|
184
|
+
const v = (c) => {
|
|
185
|
+
b || (c === "top" || c === "bottom") && (b = !0, k.disconnect(), C(c));
|
|
187
186
|
}, k = new MutationObserver(() => {
|
|
188
|
-
|
|
187
|
+
v(s.getAttribute("data-side"));
|
|
189
188
|
});
|
|
190
189
|
k.observe(s, {
|
|
191
190
|
attributes: !0,
|
|
@@ -194,7 +193,7 @@ function le({
|
|
|
194
193
|
let N = 0, R = 0;
|
|
195
194
|
N = requestAnimationFrame(() => {
|
|
196
195
|
R = requestAnimationFrame(() => {
|
|
197
|
-
|
|
196
|
+
v(s.getAttribute("data-side"));
|
|
198
197
|
});
|
|
199
198
|
}), i.current = () => {
|
|
200
199
|
b = !0, k.disconnect(), cancelAnimationFrame(N), cancelAnimationFrame(R);
|
|
@@ -209,16 +208,19 @@ function le({
|
|
|
209
208
|
}, [h]);
|
|
210
209
|
const x = t.useMemo(() => {
|
|
211
210
|
if (f)
|
|
212
|
-
return (s, b,
|
|
211
|
+
return (s, b, v) => P(f(s), b, v);
|
|
213
212
|
}, [f]);
|
|
214
213
|
return /* @__PURE__ */ a(
|
|
215
|
-
|
|
214
|
+
G,
|
|
216
215
|
{
|
|
217
216
|
ref: p,
|
|
218
217
|
align: r,
|
|
219
218
|
"aria-label": "Options",
|
|
220
|
-
avoidCollisions:
|
|
221
|
-
className: y(
|
|
219
|
+
avoidCollisions: l,
|
|
220
|
+
className: y(
|
|
221
|
+
"flex max-h-[var(--radix-popover-content-available-height)] w-[var(--radix-popover-trigger-width)] flex-col overflow-hidden p-0",
|
|
222
|
+
o
|
|
223
|
+
),
|
|
222
224
|
"data-slot": "combobox-popover",
|
|
223
225
|
side: w ?? d,
|
|
224
226
|
sideOffset: u,
|
|
@@ -226,13 +228,14 @@ function le({
|
|
|
226
228
|
$,
|
|
227
229
|
{
|
|
228
230
|
className: y(
|
|
229
|
-
"border-0 shadow-none",
|
|
231
|
+
"min-h-0 flex-1 border-0 shadow-none",
|
|
232
|
+
"[&_[data-slot='command-input-wrapper']]:shrink-0",
|
|
230
233
|
m && "[&_[data-slot='command-input-wrapper']]:border-b-0"
|
|
231
234
|
),
|
|
232
235
|
"data-slot": "combobox-command",
|
|
233
236
|
dataHook: e || "combobox-command",
|
|
234
237
|
filter: x,
|
|
235
|
-
shouldFilter:
|
|
238
|
+
shouldFilter: g,
|
|
236
239
|
children: n
|
|
237
240
|
}
|
|
238
241
|
)
|
|
@@ -241,7 +244,15 @@ function le({
|
|
|
241
244
|
}
|
|
242
245
|
const Q = t.forwardRef((e, o) => /* @__PURE__ */ a(D, { ref: o, "data-slot": "combobox-input", ...e }));
|
|
243
246
|
Q.displayName = "ComboboxInput";
|
|
244
|
-
const W = t.forwardRef((e, o) => /* @__PURE__ */ a(
|
|
247
|
+
const W = t.forwardRef(({ className: e, ...o }, n) => /* @__PURE__ */ a(
|
|
248
|
+
V,
|
|
249
|
+
{
|
|
250
|
+
ref: n,
|
|
251
|
+
className: y("min-h-0 flex-1", e),
|
|
252
|
+
"data-slot": "combobox-list",
|
|
253
|
+
...o
|
|
254
|
+
}
|
|
255
|
+
));
|
|
245
256
|
W.displayName = "ComboboxList";
|
|
246
257
|
const X = t.forwardRef((e, o) => /* @__PURE__ */ a(q, { ref: o, "data-slot": "combobox-empty", ...e }));
|
|
247
258
|
X.displayName = "ComboboxEmpty";
|
|
@@ -255,7 +266,7 @@ function Z(e, o, n) {
|
|
|
255
266
|
"gi"
|
|
256
267
|
), d = e.split(r);
|
|
257
268
|
return /* @__PURE__ */ a("span", { children: d.map(
|
|
258
|
-
(u,
|
|
269
|
+
(u, l) => l % 2 === 1 ? /* @__PURE__ */ a("span", { className: n, children: u }, l) : /* @__PURE__ */ a(t.Fragment, { children: u }, l)
|
|
259
270
|
) });
|
|
260
271
|
}
|
|
261
272
|
const ee = t.forwardRef(
|
|
@@ -266,10 +277,10 @@ const ee = t.forwardRef(
|
|
|
266
277
|
children: r,
|
|
267
278
|
className: d,
|
|
268
279
|
highlight: u,
|
|
269
|
-
highlightClassName:
|
|
280
|
+
highlightClassName: l,
|
|
270
281
|
keywords: m,
|
|
271
282
|
...h
|
|
272
|
-
},
|
|
283
|
+
}, g) => {
|
|
273
284
|
const { value: f, onValueChange: w, setOpen: C, registerItem: i } = I(), p = f === e, x = t.useMemo(() => o || (typeof r == "string" ? r : typeof r == "number" ? String(r) : e), [o, r, e]), s = t.useRef(i);
|
|
274
285
|
t.useEffect(() => {
|
|
275
286
|
s.current = i;
|
|
@@ -278,15 +289,15 @@ const ee = t.forwardRef(
|
|
|
278
289
|
}, [e, x]);
|
|
279
290
|
const b = () => {
|
|
280
291
|
w(e === f ? "" : e), C(!1);
|
|
281
|
-
},
|
|
292
|
+
}, v = () => u && typeof r == "string" ? Z(
|
|
282
293
|
r,
|
|
283
294
|
u,
|
|
284
|
-
|
|
295
|
+
l || "text-sm leading-normal font-semibold"
|
|
285
296
|
) : r;
|
|
286
297
|
return /* @__PURE__ */ E(
|
|
287
298
|
H,
|
|
288
299
|
{
|
|
289
|
-
ref:
|
|
300
|
+
ref: g,
|
|
290
301
|
className: y("justify-between", d),
|
|
291
302
|
"data-slot": "combobox-item",
|
|
292
303
|
dataHook: n,
|
|
@@ -295,7 +306,7 @@ const ee = t.forwardRef(
|
|
|
295
306
|
onSelect: b,
|
|
296
307
|
...h,
|
|
297
308
|
children: [
|
|
298
|
-
|
|
309
|
+
v(),
|
|
299
310
|
p && /* @__PURE__ */ a(
|
|
300
311
|
M,
|
|
301
312
|
{
|
|
@@ -338,7 +349,7 @@ function me({ className: e, children: o }) {
|
|
|
338
349
|
}
|
|
339
350
|
export {
|
|
340
351
|
ue as Combobox,
|
|
341
|
-
|
|
352
|
+
ce as ComboboxContent,
|
|
342
353
|
X as ComboboxEmpty,
|
|
343
354
|
Y as ComboboxGroup,
|
|
344
355
|
Q as ComboboxInput,
|
|
@@ -347,5 +358,5 @@ export {
|
|
|
347
358
|
me as ComboboxLoading,
|
|
348
359
|
oe as ComboboxSeparator,
|
|
349
360
|
K as ComboboxTrigger,
|
|
350
|
-
|
|
361
|
+
le as ComboboxValue
|
|
351
362
|
};
|
package/dist/select.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime"),N=require("@radix-ui/react-select"),i=require("@brightlocal/icons"),k=require("class-variance-authority"),n=require("@brightlocal/ui-components/lib/utils");function q(e){const r=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const o in e)if(o!=="default"){const l=Object.getOwnPropertyDescriptor(e,o);Object.defineProperty(r,o,l.get?l:{enumerable:!0,get:()=>e[o]})}}return r.default=e,Object.freeze(r)}const a=q(N);function m({children:e,...r}){return t.jsx(a.Root,{"data-slot":"select",...r,children:e})}m.displayName="Select";function f(e){return t.jsx(a.Group,{"data-slot":"select-group",...e})}f.displayName="SelectGroup";function b(e){return t.jsx(a.Value,{"data-slot":"select-value",...e})}b.displayName="SelectValue";const C=k.cva(["relative flex w-full h-9 items-center justify-between gap-2","px-3 py-2","border border-border rounded-sm outline-none transition-[border-color,box-shadow,background-color]","bg-neutral-50 border-neutral-300","dark:bg-white/5 dark:border-white/15","text-sm font-normal font-sans text-foreground","[&>span]:block [&>span]:truncate","data-[placeholder]: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","[&_svg]:pointer-events-none [&_svg]:shrink-0"]);function g({className:e,children:r,placeholder:o,dataHook:l,error:c,...s}){const p=c||s["aria-invalid"]===!0||s["aria-invalid"]==="true",y=s["aria-required"]===!0||s["aria-required"]==="true",j=s["aria-label"]||o||"Select an option",w=p?"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":"";return t.jsxs(a.Trigger,{...s,"aria-invalid":p?"true":void 0,"aria-label":j,"aria-required":y?"true":void 0,className:n.cn(C(),w,e),"data-hook":l,"data-slot":"select-trigger",children:[r,t.jsx(a.Icon,{asChild:!0,children:t.jsx(i.ChevronDown,{className:"text-muted-foreground"})})]})}g.displayName="SelectTrigger";function x({className:e,children:r,position:o="popper",...l}){const c=n.cn("relative z-50 overflow-hidden","min-w-[8rem]","rounded-md border border-border bg-popover shadow-md","text-popover-foreground","max-h-[var(--radix-select-content-available-height)]","origin-[var(--radix-select-content-transform-origin)]","data-[state=open]:animate-in data-[state=closed]:animate-out","data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0","data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95","data-[side=bottom]:slide-in-from-top-2","data-[side=left]:slide-in-from-right-2","data-[side=right]:slide-in-from-left-2","data-[side=top]:slide-in-from-bottom-2"),s=o==="popper"&&n.cn("data-[side=bottom]:translate-y-1","data-[side=left]:-translate-x-1","data-[side=right]:translate-x-1","data-[side=top]:-translate-y-1");return t.jsx(a.Portal,{children:t.jsxs(a.Content,{className:n.cn(c,s,e),"data-slot":"select-content",position:o,...l,children:[t.jsx(d,{}),t.jsx(a.Viewport,{className:n.cn("p-1",o==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)] scroll-my-1"),children:r}),t.jsx(u,{})]})})}x.displayName="SelectContent";function S({className:e,...r}){return t.jsx(a.Label,{className:n.cn("text-muted-foreground px-2 py-1.5 text-xs font-medium",e),"data-slot":"select-label",...r})}S.displayName="SelectLabel";function v({className:e,children:r,...o}){const l=n.cn("relative flex w-full cursor-default select-none items-center gap-2","rounded py-1.5 pl-2 pr-8","text-sm font-normal leading-5 text-popover-foreground","focus:bg-accent focus:text-accent-foreground","hover:bg-accent/50 hover:text-accent-foreground","outline-none focus:outline-none","data-[disabled]:pointer-events-none data-[disabled]:opacity-50","[&_svg]:pointer-events-none [&_svg]:shrink-0");return t.jsxs(a.Item,{className:n.cn(l,e),"data-slot":"select-item",...o,children:[t.jsx("span",{className:"absolute right-2 flex size-4 items-center justify-center",children:t.jsx(a.ItemIndicator,{children:t.jsx(i.Check,{})})}),t.jsx(a.ItemText,{children:r})]})}v.displayName="SelectItem";function h({className:e,...r}){return t.jsx(a.Separator,{className:n.cn("bg-border pointer-events-none -mx-1 my-1 h-px",e),"data-slot":"select-separator",...r})}h.displayName="SelectSeparator";function d({className:e,...r}){return t.jsx(a.ScrollUpButton,{className:n.cn("flex cursor-default items-center justify-center py-1",e),"data-slot":"select-scroll-up-button",...r,children:t.jsx(i.ChevronUp,{})})}d.displayName="SelectScrollUpButton";function u({className:e,...r}){return t.jsx(a.ScrollDownButton,{className:n.cn("flex cursor-default items-center justify-center py-1",e),"data-slot":"select-scroll-down-button",...r,children:t.jsx(i.ChevronDown,{})})}u.displayName="SelectScrollDownButton";exports.Select=m;exports.SelectContent=x;exports.SelectGroup=f;exports.SelectItem=v;exports.SelectLabel=S;exports.SelectScrollDownButton=u;exports.SelectScrollUpButton=d;exports.SelectSeparator=h;exports.SelectTrigger=g;exports.SelectValue=b;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime"),N=require("@radix-ui/react-select"),i=require("@brightlocal/icons"),k=require("class-variance-authority"),n=require("@brightlocal/ui-components/lib/utils");function q(e){const r=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const o in e)if(o!=="default"){const l=Object.getOwnPropertyDescriptor(e,o);Object.defineProperty(r,o,l.get?l:{enumerable:!0,get:()=>e[o]})}}return r.default=e,Object.freeze(r)}const a=q(N);function m({children:e,...r}){return t.jsx(a.Root,{"data-slot":"select",...r,children:e})}m.displayName="Select";function f(e){return t.jsx(a.Group,{"data-slot":"select-group",...e})}f.displayName="SelectGroup";function b(e){return t.jsx(a.Value,{"data-slot":"select-value",...e})}b.displayName="SelectValue";const C=k.cva(["relative flex w-full h-9 items-center justify-between gap-2","px-3 py-2","border border-border rounded-sm outline-none transition-[border-color,box-shadow,background-color]","bg-neutral-50 border-neutral-300","dark:bg-white/5 dark:border-white/15","text-sm font-normal font-sans text-foreground","[&>span]:block [&>span]:truncate","data-[placeholder]: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","[&_svg]:pointer-events-none [&_svg]:shrink-0"]);function g({className:e,children:r,placeholder:o,dataHook:l,error:c,...s}){const p=c||s["aria-invalid"]===!0||s["aria-invalid"]==="true",y=s["aria-required"]===!0||s["aria-required"]==="true",j=s["aria-label"]||o||"Select an option",w=p?"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":"";return t.jsxs(a.Trigger,{...s,"aria-invalid":p?"true":void 0,"aria-label":j,"aria-required":y?"true":void 0,className:n.cn(C(),w,e),"data-hook":l,"data-slot":"select-trigger",children:[r,t.jsx(a.Icon,{asChild:!0,children:t.jsx(i.ChevronDown,{className:"text-muted-foreground"})})]})}g.displayName="SelectTrigger";function x({className:e,children:r,position:o="popper",...l}){const c=n.cn("relative z-50 overflow-hidden","min-w-[8rem]","rounded-md border border-border bg-popover shadow-md","text-popover-foreground","max-h-[var(--radix-select-content-available-height)]","origin-[var(--radix-select-content-transform-origin)]","data-[state=open]:animate-in data-[state=closed]:animate-out","data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0","data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95","data-[side=bottom]:slide-in-from-top-2","data-[side=left]:slide-in-from-right-2","data-[side=right]:slide-in-from-left-2","data-[side=top]:slide-in-from-bottom-2"),s=o==="popper"&&n.cn("data-[side=bottom]:translate-y-1","data-[side=left]:-translate-x-1","data-[side=right]:translate-x-1","data-[side=top]:-translate-y-1");return t.jsx(a.Portal,{children:t.jsxs(a.Content,{className:n.cn(c,s,e),"data-slot":"select-content",position:o,...l,children:[t.jsx(d,{}),t.jsx(a.Viewport,{className:n.cn("p-1",o==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)] scroll-my-1"),children:r}),t.jsx(u,{})]})})}x.displayName="SelectContent";function S({className:e,...r}){return t.jsx(a.Label,{className:n.cn("text-muted-foreground px-2 py-1.5 text-xs font-medium",e),"data-slot":"select-label",...r})}S.displayName="SelectLabel";function v({className:e,children:r,...o}){const l=n.cn("relative flex w-full cursor-default select-none items-center gap-2","rounded py-1.5 pl-2 pr-8","text-sm font-normal leading-5 text-popover-foreground","focus:bg-accent focus:text-accent-foreground","hover:bg-accent/50 hover:text-accent-foreground","outline-none focus:outline-none","data-[disabled]:pointer-events-none data-[disabled]:opacity-50","[&_svg]:pointer-events-none [&_svg]:shrink-0");return t.jsxs(a.Item,{className:n.cn(l,e),"data-slot":"select-item",...o,children:[t.jsx("span",{className:"absolute right-2 flex size-4 items-center justify-center",children:t.jsx(a.ItemIndicator,{children:t.jsx(i.Check,{})})}),t.jsx(a.ItemText,{children:r})]})}v.displayName="SelectItem";function h({className:e,...r}){return t.jsx(a.Separator,{className:n.cn("bg-border pointer-events-none -mx-1 my-1 h-px",e),"data-slot":"select-separator",...r})}h.displayName="SelectSeparator";function d({className:e,...r}){return t.jsx(a.ScrollUpButton,{className:n.cn("flex cursor-default items-center justify-center py-1",e),"data-slot":"select-scroll-up-button",...r,children:t.jsx(i.ChevronUp,{})})}d.displayName="SelectScrollUpButton";function u({className:e,...r}){return t.jsx(a.ScrollDownButton,{className:n.cn("flex cursor-default items-center justify-center py-1",e),"data-slot":"select-scroll-down-button",...r,children:t.jsx(i.ChevronDown,{})})}u.displayName="SelectScrollDownButton";exports.Select=m;exports.SelectContent=x;exports.SelectGroup=f;exports.SelectItem=v;exports.SelectLabel=S;exports.SelectScrollDownButton=u;exports.SelectScrollUpButton=d;exports.SelectSeparator=h;exports.SelectTrigger=g;exports.SelectValue=b;
|
package/dist/select.js
CHANGED
|
@@ -47,7 +47,7 @@ function k({
|
|
|
47
47
|
error: i,
|
|
48
48
|
...n
|
|
49
49
|
}) {
|
|
50
|
-
const c = i || n["aria-invalid"] === !0 || n["aria-invalid"] === "true", f = n["aria-required"] === !0 || n["aria-required"] === "true", b = n["aria-label"] || l || "Select an option", g = c ? "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" : "";
|
|
50
|
+
const c = i || n["aria-invalid"] === !0 || n["aria-invalid"] === "true", f = n["aria-required"] === !0 || n["aria-required"] === "true", b = n["aria-label"] || l || "Select an option", g = c ? "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" : "";
|
|
51
51
|
return /* @__PURE__ */ d(
|
|
52
52
|
a.Trigger,
|
|
53
53
|
{
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@brightlocal/ui-components",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.3",
|
|
4
4
|
"description": "BrightLocal Design System UI Components",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"private": false,
|
|
@@ -161,7 +161,7 @@
|
|
|
161
161
|
"sonner": "^2.0.7",
|
|
162
162
|
"tailwind-merge": "^3.4.0",
|
|
163
163
|
"vaul": "^1.1.2",
|
|
164
|
-
"@brightlocal/icons": "2.
|
|
164
|
+
"@brightlocal/icons": "2.1.0"
|
|
165
165
|
},
|
|
166
166
|
"size-limit": [
|
|
167
167
|
{
|
|
@@ -130,12 +130,10 @@ function InputList({
|
|
|
130
130
|
),
|
|
131
131
|
];
|
|
132
132
|
}
|
|
133
|
-
//
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
// Removal or reorder: regenerate all keys
|
|
138
|
-
return value.map(() => nextIdRef.current++);
|
|
133
|
+
// Trim excess keys (rejected add, partial acceptance, or external shrink).
|
|
134
|
+
// removeItem already eagerly filters keys, so removals hit the
|
|
135
|
+
// prev.length === value.length check above and never reach here.
|
|
136
|
+
return prev.slice(0, value.length);
|
|
139
137
|
});
|
|
140
138
|
}, [value, addAttempt]);
|
|
141
139
|
|
|
@@ -264,7 +262,7 @@ function InputListItems({
|
|
|
264
262
|
data-hook={`${dataHook}-list`}
|
|
265
263
|
data-slot="list"
|
|
266
264
|
>
|
|
267
|
-
<AnimatePresence initial={false}>
|
|
265
|
+
<AnimatePresence initial={false} mode="popLayout">
|
|
268
266
|
{value.map((item, index) => (
|
|
269
267
|
<motion.li
|
|
270
268
|
key={stableKeys[index]}
|
|
@@ -187,7 +187,6 @@ const comboboxTriggerVariants = cva(
|
|
|
187
187
|
|
|
188
188
|
// Disabled state
|
|
189
189
|
"disabled:cursor-not-allowed disabled:opacity-50",
|
|
190
|
-
"disabled:hover:bg-neutral-50",
|
|
191
190
|
|
|
192
191
|
// Transitions
|
|
193
192
|
"transition-[background-color,border-color,box-shadow] duration-200 ease-out",
|
|
@@ -468,14 +467,18 @@ function ComboboxContent({
|
|
|
468
467
|
align={align}
|
|
469
468
|
aria-label="Options"
|
|
470
469
|
avoidCollisions={avoidCollisions}
|
|
471
|
-
className={cn(
|
|
470
|
+
className={cn(
|
|
471
|
+
"flex max-h-[var(--radix-popover-content-available-height)] w-[var(--radix-popover-trigger-width)] flex-col overflow-hidden p-0",
|
|
472
|
+
className
|
|
473
|
+
)}
|
|
472
474
|
data-slot="combobox-popover"
|
|
473
475
|
side={lockedSide ?? side}
|
|
474
476
|
sideOffset={sideOffset}
|
|
475
477
|
>
|
|
476
478
|
<Command
|
|
477
479
|
className={cn(
|
|
478
|
-
"border-0 shadow-none",
|
|
480
|
+
"min-h-0 flex-1 border-0 shadow-none",
|
|
481
|
+
"[&_[data-slot='command-input-wrapper']]:shrink-0",
|
|
479
482
|
hideList && "[&_[data-slot='command-input-wrapper']]:border-b-0"
|
|
480
483
|
)}
|
|
481
484
|
data-slot="combobox-command"
|
|
@@ -519,8 +522,15 @@ export type ComboboxListProps = React.ComponentProps<typeof CommandList>;
|
|
|
519
522
|
const ComboboxList = React.forwardRef<
|
|
520
523
|
React.ComponentRef<typeof CommandList>,
|
|
521
524
|
ComboboxListProps
|
|
522
|
-
>((props, ref) => {
|
|
523
|
-
return
|
|
525
|
+
>(({ className, ...props }, ref) => {
|
|
526
|
+
return (
|
|
527
|
+
<CommandList
|
|
528
|
+
ref={ref}
|
|
529
|
+
className={cn("min-h-0 flex-1", className)}
|
|
530
|
+
data-slot="combobox-list"
|
|
531
|
+
{...props}
|
|
532
|
+
/>
|
|
533
|
+
);
|
|
524
534
|
});
|
|
525
535
|
ComboboxList.displayName = "ComboboxList";
|
|
526
536
|
|
|
@@ -147,7 +147,7 @@ function SelectTrigger({
|
|
|
147
147
|
const ariaLabel = props["aria-label"] || placeholder || "Select an option";
|
|
148
148
|
|
|
149
149
|
const errorStyles = isError
|
|
150
|
-
? "border-destructive-40 " +
|
|
150
|
+
? "border-destructive-40 dark:border-destructive-40 " +
|
|
151
151
|
"focus-visible:border-destructive-40 dark:focus-visible:border-destructive-40 focus-visible:shadow-destructive " +
|
|
152
152
|
"data-[state=open]:border-destructive-40 dark:data-[state=open]:border-destructive-40 data-[state=open]:shadow-destructive"
|
|
153
153
|
: "";
|