@brightlocal/ui-components 1.2.1 → 1.2.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 +112 -474
- package/dist/centred-layout.d.ts +1 -1
- package/dist/combobox.cjs +1 -1
- package/dist/combobox.d.ts +2 -2
- package/dist/combobox.d.ts.map +1 -1
- package/dist/combobox.js +189 -158
- package/package.json +3 -3
- package/src/components/centred-layout.tsx +1 -1
- package/src/components/combobox.tsx +101 -4
package/dist/centred-layout.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import * as React from "react";
|
|
|
3
3
|
* CentredLayout provides a full-page centered container.
|
|
4
4
|
*
|
|
5
5
|
* Spacing tokens used:
|
|
6
|
-
* - Padding: section-
|
|
6
|
+
* - Padding: p-section-sm utility (16px mobile/tablet, 24px desktop)
|
|
7
7
|
* - Header to content gap: gap-4 (spacing.4 = 16px)
|
|
8
8
|
*
|
|
9
9
|
* The component takes full page width/height and centers content horizontally and vertically.
|
package/dist/combobox.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("react/jsx-runtime"),U=require("react"),q=require("@brightlocal/icons"),V=require("class-variance-authority"),$=require("cmdk"),k=require("@brightlocal/ui-components/lib/utils"),T=require("@brightlocal/ui-components/popover"),y=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:u=!0,disabled:c=!1,itemToStringValue:d,children:b}){const[h,C]=t.useState(""),[f,w]=t.useState(!1),[v,i]=t.useState(()=>new Map),x=e!==void 0,p=a!==void 0,s=x?e:h,m=p?a:f,g=t.useCallback(l=>{p||w(l),r?.(l)},[p,r]),j=t.useCallback(l=>{x||C(l),o?.(l)},[x,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:u,disabled:c,itemLabels:v,registerItem:N,itemToStringValue:d}),[m,g,s,j,u,c,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","disabled:hover:bg-neutral-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:u,trackingLabel:c,children:d,...b},h)=>{const{open:C,disabled:f,value:w}=R(),v=t.useId(),i=!w,x=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":x?"true":void 0,className:k.cn(B({variant:o}),x&&"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":u||"combobox-trigger","data-tracking-label":c,disabled:f||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(),u=a?r.get(a)||a:e;return n.jsx("span",{className:k.cn("text-foreground overflow-hidden text-sm leading-normal font-medium text-ellipsis whitespace-nowrap",o),"data-slot":"combobox-value",children:u})}function K({dataHook:e,className:o,children:a,align:r="start",side:u="bottom",sideOffset:c,avoidCollisions:d,hideList:b=!1}){const{open:h,shouldFilter:C,itemToStringValue:f}=R(),[w,v]=t.useState(null),i=t.useRef(null),x=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(f)return(s,m,g)=>$.defaultFilter(f(s),m,g)},[f]);return n.jsx(T.PopoverContent,{ref:x,align:r,"aria-label":"Options",avoidCollisions:d,className:k.cn("w-[var(--radix-popover-trigger-width)] p-0",o),"data-slot":"combobox-popover",side:w??u,sideOffset:c,children:n.jsx(y.Command,{className:k.cn("border-0 shadow-none",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(y.CommandInput,{ref:o,"data-slot":"combobox-input",...e}));M.displayName="ComboboxInput";const P=t.forwardRef((e,o)=>n.jsx(y.CommandList,{ref:o,"data-slot":"combobox-list",...e}));P.displayName="ComboboxList";const A=t.forwardRef((e,o)=>n.jsx(y.CommandEmpty,{ref:o,"data-slot":"combobox-empty",...e}));A.displayName="ComboboxEmpty";const _=t.forwardRef((e,o)=>n.jsx(y.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"),u=e.split(r);return n.jsx("span",{children:u.map((c,d)=>d%2===1?n.jsx("span",{className:a,children:c},d):n.jsx(t.Fragment,{children:c},d))})}const G=t.forwardRef(({value:e,label:o,dataHook:a,children:r,className:u,highlight:c,highlightClassName:d,keywords:b,...h},C)=>{const{value:f,onValueChange:w,setOpen:v,registerItem:i}=R(),x=f===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===f?"":e),v(!1)},g=()=>c&&typeof r=="string"?Q(r,c,d||"text-sm leading-normal font-semibold"):r;return n.jsxs(y.CommandItem,{ref:C,className:k.cn("justify-between",u),"data-slot":"combobox-item",dataHook:a,keywords:b?[p,...b]:[p],value:e,onSelect:m,...h,children:[g(),x&&n.jsx(q.Check,{"aria-hidden":"true",className:"text-muted-foreground shrink-0"})]})});G.displayName="ComboboxItem";const D=t.forwardRef((e,o)=>n.jsx(y.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:k.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
CHANGED
|
@@ -54,8 +54,8 @@ export interface ComboboxContentProps {
|
|
|
54
54
|
children: React.ReactNode;
|
|
55
55
|
/** Alignment of the popover relative to trigger */
|
|
56
56
|
align?: "start" | "center" | "end";
|
|
57
|
-
/** Which side of the trigger to render the popover. @default "bottom" */
|
|
58
|
-
side?: "top" | "
|
|
57
|
+
/** Which side of the trigger to render the popover. Only vertical positioning is supported — the dropdown spans the full trigger width. @default "bottom" */
|
|
58
|
+
side?: "top" | "bottom";
|
|
59
59
|
/** Distance in px between the trigger and the popover. @default 4 */
|
|
60
60
|
sideOffset?: number;
|
|
61
61
|
/**
|
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,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AM,EAAE,CAAC;CACrB;AAED,QAAA,MAAM,YAAY,uGAgFjB,CAAC;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
|
@@ -1,73 +1,73 @@
|
|
|
1
|
-
import { jsx as a, jsxs as
|
|
1
|
+
import { jsx as a, jsxs as E, Fragment as A } from "react/jsx-runtime";
|
|
2
2
|
import * as t from "react";
|
|
3
|
-
import { Check as
|
|
4
|
-
import { cva as
|
|
5
|
-
import { defaultFilter as
|
|
6
|
-
import { cn as
|
|
7
|
-
import { Popover as
|
|
8
|
-
import { Command as
|
|
9
|
-
const
|
|
10
|
-
function
|
|
11
|
-
const
|
|
12
|
-
if (!
|
|
3
|
+
import { Check as M, ChevronsUpDown as j } from "@brightlocal/icons";
|
|
4
|
+
import { cva as O } from "class-variance-authority";
|
|
5
|
+
import { defaultFilter as P } from "cmdk";
|
|
6
|
+
import { cn as y } from "@brightlocal/ui-components/lib/utils";
|
|
7
|
+
import { Popover as G, PopoverContent as U, PopoverTrigger as _ } from "@brightlocal/ui-components/popover";
|
|
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
|
+
const F = t.createContext(null);
|
|
10
|
+
function I() {
|
|
11
|
+
const e = t.useContext(F);
|
|
12
|
+
if (!e)
|
|
13
13
|
throw new Error("Combobox components must be used within a <Combobox>");
|
|
14
|
-
return
|
|
14
|
+
return e;
|
|
15
15
|
}
|
|
16
|
-
function
|
|
17
|
-
value:
|
|
18
|
-
onValueChange:
|
|
16
|
+
function ue({
|
|
17
|
+
value: e,
|
|
18
|
+
onValueChange: o,
|
|
19
19
|
open: n,
|
|
20
20
|
onOpenChange: r,
|
|
21
|
-
shouldFilter:
|
|
22
|
-
disabled:
|
|
23
|
-
itemToStringValue:
|
|
24
|
-
children:
|
|
21
|
+
shouldFilter: d = !0,
|
|
22
|
+
disabled: u = !1,
|
|
23
|
+
itemToStringValue: c,
|
|
24
|
+
children: m
|
|
25
25
|
}) {
|
|
26
|
-
const [
|
|
26
|
+
const [h, v] = t.useState(""), [f, w] = t.useState(!1), [C, i] = t.useState(
|
|
27
27
|
() => /* @__PURE__ */ new Map()
|
|
28
|
-
),
|
|
29
|
-
(
|
|
30
|
-
|
|
28
|
+
), p = e !== void 0, x = n !== void 0, s = p ? e : h, b = x ? n : f, g = t.useCallback(
|
|
29
|
+
(l) => {
|
|
30
|
+
x || w(l), r?.(l);
|
|
31
31
|
},
|
|
32
|
-
[
|
|
33
|
-
),
|
|
34
|
-
(
|
|
35
|
-
|
|
32
|
+
[x, r]
|
|
33
|
+
), k = t.useCallback(
|
|
34
|
+
(l) => {
|
|
35
|
+
p || v(l), o?.(l);
|
|
36
36
|
},
|
|
37
|
-
[
|
|
38
|
-
),
|
|
39
|
-
|
|
40
|
-
if (
|
|
41
|
-
const
|
|
42
|
-
return
|
|
37
|
+
[p, o]
|
|
38
|
+
), N = t.useCallback((l, L) => {
|
|
39
|
+
i((S) => {
|
|
40
|
+
if (S.get(l) === L) return S;
|
|
41
|
+
const T = new Map(S);
|
|
42
|
+
return T.set(l, L), T;
|
|
43
43
|
});
|
|
44
|
-
}, []),
|
|
44
|
+
}, []), R = t.useMemo(
|
|
45
45
|
() => ({
|
|
46
|
-
open:
|
|
47
|
-
setOpen:
|
|
48
|
-
value:
|
|
49
|
-
onValueChange:
|
|
50
|
-
shouldFilter:
|
|
51
|
-
disabled:
|
|
52
|
-
itemLabels:
|
|
53
|
-
registerItem:
|
|
54
|
-
itemToStringValue:
|
|
46
|
+
open: b,
|
|
47
|
+
setOpen: g,
|
|
48
|
+
value: s,
|
|
49
|
+
onValueChange: k,
|
|
50
|
+
shouldFilter: d,
|
|
51
|
+
disabled: u,
|
|
52
|
+
itemLabels: C,
|
|
53
|
+
registerItem: N,
|
|
54
|
+
itemToStringValue: c
|
|
55
55
|
}),
|
|
56
56
|
[
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
h,
|
|
60
|
-
N,
|
|
57
|
+
b,
|
|
58
|
+
g,
|
|
61
59
|
s,
|
|
60
|
+
k,
|
|
62
61
|
d,
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
62
|
+
u,
|
|
63
|
+
C,
|
|
64
|
+
N,
|
|
65
|
+
c
|
|
66
66
|
]
|
|
67
67
|
);
|
|
68
|
-
return /* @__PURE__ */ a(
|
|
68
|
+
return /* @__PURE__ */ a(F.Provider, { value: R, children: /* @__PURE__ */ a(G, { open: b, onOpenChange: g, children: m }) });
|
|
69
69
|
}
|
|
70
|
-
const J =
|
|
70
|
+
const J = O(
|
|
71
71
|
[
|
|
72
72
|
// Base layout
|
|
73
73
|
"relative flex w-full items-center justify-between gap-2",
|
|
@@ -105,43 +105,43 @@ const J = G(
|
|
|
105
105
|
}
|
|
106
106
|
), K = t.forwardRef(
|
|
107
107
|
({
|
|
108
|
-
className:
|
|
109
|
-
variant:
|
|
108
|
+
className: e,
|
|
109
|
+
variant: o,
|
|
110
110
|
dataHook: n,
|
|
111
111
|
error: r,
|
|
112
|
-
trackingEl:
|
|
113
|
-
trackingLabel:
|
|
114
|
-
children:
|
|
115
|
-
...
|
|
116
|
-
},
|
|
117
|
-
const { open:
|
|
118
|
-
return /* @__PURE__ */ a(
|
|
112
|
+
trackingEl: d,
|
|
113
|
+
trackingLabel: u,
|
|
114
|
+
children: c,
|
|
115
|
+
...m
|
|
116
|
+
}, h) => {
|
|
117
|
+
const { open: v, disabled: f, value: w } = I(), C = t.useId(), i = !w, p = r || m["aria-invalid"] === !0 || m["aria-invalid"] === "true";
|
|
118
|
+
return /* @__PURE__ */ a(_, { asChild: !0, children: /* @__PURE__ */ E(
|
|
119
119
|
"button",
|
|
120
120
|
{
|
|
121
|
-
ref:
|
|
122
|
-
"aria-controls":
|
|
123
|
-
"aria-expanded":
|
|
121
|
+
ref: h,
|
|
122
|
+
"aria-controls": v ? C : void 0,
|
|
123
|
+
"aria-expanded": v,
|
|
124
124
|
"aria-haspopup": "listbox",
|
|
125
|
-
"aria-invalid":
|
|
126
|
-
className:
|
|
127
|
-
J({ variant:
|
|
128
|
-
|
|
129
|
-
|
|
125
|
+
"aria-invalid": p ? "true" : void 0,
|
|
126
|
+
className: y(
|
|
127
|
+
J({ variant: o }),
|
|
128
|
+
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",
|
|
129
|
+
e
|
|
130
130
|
),
|
|
131
131
|
"data-hook": n,
|
|
132
|
-
"data-placeholder":
|
|
132
|
+
"data-placeholder": i,
|
|
133
133
|
"data-slot": "combobox-trigger",
|
|
134
|
-
"data-state":
|
|
135
|
-
"data-tracking-el":
|
|
136
|
-
"data-tracking-label":
|
|
137
|
-
disabled:
|
|
134
|
+
"data-state": v ? "open" : "closed",
|
|
135
|
+
"data-tracking-el": d || "combobox-trigger",
|
|
136
|
+
"data-tracking-label": u,
|
|
137
|
+
disabled: f || m.disabled,
|
|
138
138
|
role: "combobox",
|
|
139
139
|
type: "button",
|
|
140
|
-
...
|
|
140
|
+
...m,
|
|
141
141
|
children: [
|
|
142
|
-
|
|
142
|
+
c,
|
|
143
143
|
/* @__PURE__ */ a(
|
|
144
|
-
|
|
144
|
+
j,
|
|
145
145
|
{
|
|
146
146
|
"aria-hidden": "true",
|
|
147
147
|
className: "text-muted-foreground ml-auto shrink-0"
|
|
@@ -153,120 +153,151 @@ const J = G(
|
|
|
153
153
|
}
|
|
154
154
|
);
|
|
155
155
|
K.displayName = "ComboboxTrigger";
|
|
156
|
-
function
|
|
157
|
-
const { value: n, itemLabels: r } =
|
|
156
|
+
function ce({ placeholder: e, className: o }) {
|
|
157
|
+
const { value: n, itemLabels: r } = I(), d = n ? r.get(n) || n : e;
|
|
158
158
|
return /* @__PURE__ */ a(
|
|
159
159
|
"span",
|
|
160
160
|
{
|
|
161
|
-
className:
|
|
161
|
+
className: y(
|
|
162
162
|
"text-foreground overflow-hidden text-sm leading-normal font-medium text-ellipsis whitespace-nowrap",
|
|
163
|
-
|
|
163
|
+
o
|
|
164
164
|
),
|
|
165
165
|
"data-slot": "combobox-value",
|
|
166
|
-
children:
|
|
166
|
+
children: d
|
|
167
167
|
}
|
|
168
168
|
);
|
|
169
169
|
}
|
|
170
|
-
function
|
|
171
|
-
dataHook:
|
|
172
|
-
className:
|
|
170
|
+
function le({
|
|
171
|
+
dataHook: e,
|
|
172
|
+
className: o,
|
|
173
173
|
children: n,
|
|
174
174
|
align: r = "start",
|
|
175
|
-
side:
|
|
176
|
-
sideOffset:
|
|
177
|
-
avoidCollisions:
|
|
178
|
-
hideList:
|
|
175
|
+
side: d = "bottom",
|
|
176
|
+
sideOffset: u,
|
|
177
|
+
avoidCollisions: c,
|
|
178
|
+
hideList: m = !1
|
|
179
179
|
}) {
|
|
180
|
-
const { shouldFilter:
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
180
|
+
const { open: h, shouldFilter: v, itemToStringValue: f } = I(), [w, C] = t.useState(
|
|
181
|
+
null
|
|
182
|
+
), i = t.useRef(null), p = t.useCallback((s) => {
|
|
183
|
+
if (i.current?.(), i.current = null, !s) return;
|
|
184
|
+
let b = !1;
|
|
185
|
+
const g = (l) => {
|
|
186
|
+
b || (l === "top" || l === "bottom") && (b = !0, k.disconnect(), C(l));
|
|
187
|
+
}, k = new MutationObserver(() => {
|
|
188
|
+
g(s.getAttribute("data-side"));
|
|
189
|
+
});
|
|
190
|
+
k.observe(s, {
|
|
191
|
+
attributes: !0,
|
|
192
|
+
attributeFilter: ["data-side"]
|
|
193
|
+
});
|
|
194
|
+
let N = 0, R = 0;
|
|
195
|
+
N = requestAnimationFrame(() => {
|
|
196
|
+
R = requestAnimationFrame(() => {
|
|
197
|
+
g(s.getAttribute("data-side"));
|
|
198
|
+
});
|
|
199
|
+
}), i.current = () => {
|
|
200
|
+
b = !0, k.disconnect(), cancelAnimationFrame(N), cancelAnimationFrame(R);
|
|
201
|
+
};
|
|
202
|
+
}, []);
|
|
203
|
+
t.useEffect(() => {
|
|
204
|
+
if (!h) {
|
|
205
|
+
i.current?.(), i.current = null;
|
|
206
|
+
const s = setTimeout(() => C(null), 150);
|
|
207
|
+
return () => clearTimeout(s);
|
|
208
|
+
}
|
|
209
|
+
}, [h]);
|
|
210
|
+
const x = t.useMemo(() => {
|
|
211
|
+
if (f)
|
|
212
|
+
return (s, b, g) => P(f(s), b, g);
|
|
213
|
+
}, [f]);
|
|
184
214
|
return /* @__PURE__ */ a(
|
|
185
|
-
|
|
215
|
+
U,
|
|
186
216
|
{
|
|
217
|
+
ref: p,
|
|
187
218
|
align: r,
|
|
188
219
|
"aria-label": "Options",
|
|
189
|
-
avoidCollisions:
|
|
190
|
-
className:
|
|
220
|
+
avoidCollisions: c,
|
|
221
|
+
className: y("w-[var(--radix-popover-trigger-width)] p-0", o),
|
|
191
222
|
"data-slot": "combobox-popover",
|
|
192
|
-
side:
|
|
193
|
-
sideOffset:
|
|
223
|
+
side: w ?? d,
|
|
224
|
+
sideOffset: u,
|
|
194
225
|
children: /* @__PURE__ */ a(
|
|
195
|
-
|
|
226
|
+
$,
|
|
196
227
|
{
|
|
197
|
-
className:
|
|
228
|
+
className: y(
|
|
198
229
|
"border-0 shadow-none",
|
|
199
|
-
|
|
230
|
+
m && "[&_[data-slot='command-input-wrapper']]:border-b-0"
|
|
200
231
|
),
|
|
201
232
|
"data-slot": "combobox-command",
|
|
202
|
-
dataHook:
|
|
203
|
-
filter:
|
|
204
|
-
shouldFilter:
|
|
233
|
+
dataHook: e || "combobox-command",
|
|
234
|
+
filter: x,
|
|
235
|
+
shouldFilter: v,
|
|
205
236
|
children: n
|
|
206
237
|
}
|
|
207
238
|
)
|
|
208
239
|
}
|
|
209
240
|
);
|
|
210
241
|
}
|
|
211
|
-
const Q = t.forwardRef((
|
|
242
|
+
const Q = t.forwardRef((e, o) => /* @__PURE__ */ a(D, { ref: o, "data-slot": "combobox-input", ...e }));
|
|
212
243
|
Q.displayName = "ComboboxInput";
|
|
213
|
-
const W = t.forwardRef((
|
|
244
|
+
const W = t.forwardRef((e, o) => /* @__PURE__ */ a(V, { ref: o, "data-slot": "combobox-list", ...e }));
|
|
214
245
|
W.displayName = "ComboboxList";
|
|
215
|
-
const X = t.forwardRef((
|
|
246
|
+
const X = t.forwardRef((e, o) => /* @__PURE__ */ a(q, { ref: o, "data-slot": "combobox-empty", ...e }));
|
|
216
247
|
X.displayName = "ComboboxEmpty";
|
|
217
|
-
const Y = t.forwardRef((
|
|
248
|
+
const Y = t.forwardRef((e, o) => /* @__PURE__ */ a(z, { ref: o, "data-slot": "combobox-group", ...e }));
|
|
218
249
|
Y.displayName = "ComboboxGroup";
|
|
219
|
-
function Z(
|
|
220
|
-
if (!
|
|
221
|
-
return
|
|
250
|
+
function Z(e, o, n) {
|
|
251
|
+
if (!o || !o.trim())
|
|
252
|
+
return e;
|
|
222
253
|
const r = new RegExp(
|
|
223
|
-
`(${
|
|
254
|
+
`(${o.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")})`,
|
|
224
255
|
"gi"
|
|
225
|
-
),
|
|
226
|
-
return /* @__PURE__ */ a("span", { children:
|
|
227
|
-
(
|
|
256
|
+
), d = e.split(r);
|
|
257
|
+
return /* @__PURE__ */ a("span", { children: d.map(
|
|
258
|
+
(u, c) => c % 2 === 1 ? /* @__PURE__ */ a("span", { className: n, children: u }, c) : /* @__PURE__ */ a(t.Fragment, { children: u }, c)
|
|
228
259
|
) });
|
|
229
260
|
}
|
|
230
|
-
const
|
|
261
|
+
const ee = t.forwardRef(
|
|
231
262
|
({
|
|
232
|
-
value:
|
|
233
|
-
label:
|
|
263
|
+
value: e,
|
|
264
|
+
label: o,
|
|
234
265
|
dataHook: n,
|
|
235
266
|
children: r,
|
|
236
|
-
className:
|
|
237
|
-
highlight:
|
|
238
|
-
highlightClassName:
|
|
239
|
-
keywords:
|
|
240
|
-
...
|
|
241
|
-
},
|
|
242
|
-
const { value:
|
|
267
|
+
className: d,
|
|
268
|
+
highlight: u,
|
|
269
|
+
highlightClassName: c,
|
|
270
|
+
keywords: m,
|
|
271
|
+
...h
|
|
272
|
+
}, v) => {
|
|
273
|
+
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);
|
|
243
274
|
t.useEffect(() => {
|
|
244
|
-
|
|
245
|
-
}, [
|
|
246
|
-
|
|
247
|
-
}, [
|
|
248
|
-
const
|
|
249
|
-
|
|
250
|
-
},
|
|
275
|
+
s.current = i;
|
|
276
|
+
}, [i]), t.useEffect(() => {
|
|
277
|
+
s.current(e, x);
|
|
278
|
+
}, [e, x]);
|
|
279
|
+
const b = () => {
|
|
280
|
+
w(e === f ? "" : e), C(!1);
|
|
281
|
+
}, g = () => u && typeof r == "string" ? Z(
|
|
251
282
|
r,
|
|
252
|
-
|
|
253
|
-
|
|
283
|
+
u,
|
|
284
|
+
c || "text-sm leading-normal font-semibold"
|
|
254
285
|
) : r;
|
|
255
|
-
return /* @__PURE__ */
|
|
256
|
-
|
|
286
|
+
return /* @__PURE__ */ E(
|
|
287
|
+
H,
|
|
257
288
|
{
|
|
258
|
-
ref:
|
|
259
|
-
className:
|
|
289
|
+
ref: v,
|
|
290
|
+
className: y("justify-between", d),
|
|
260
291
|
"data-slot": "combobox-item",
|
|
261
292
|
dataHook: n,
|
|
262
|
-
keywords:
|
|
263
|
-
value:
|
|
264
|
-
onSelect:
|
|
265
|
-
...
|
|
293
|
+
keywords: m ? [x, ...m] : [x],
|
|
294
|
+
value: e,
|
|
295
|
+
onSelect: b,
|
|
296
|
+
...h,
|
|
266
297
|
children: [
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
298
|
+
g(),
|
|
299
|
+
p && /* @__PURE__ */ a(
|
|
300
|
+
M,
|
|
270
301
|
{
|
|
271
302
|
"aria-hidden": "true",
|
|
272
303
|
className: "text-muted-foreground shrink-0"
|
|
@@ -277,22 +308,22 @@ const oo = t.forwardRef(
|
|
|
277
308
|
);
|
|
278
309
|
}
|
|
279
310
|
);
|
|
280
|
-
|
|
281
|
-
const
|
|
282
|
-
|
|
283
|
-
function
|
|
311
|
+
ee.displayName = "ComboboxItem";
|
|
312
|
+
const oe = t.forwardRef((e, o) => /* @__PURE__ */ a(B, { ref: o, "data-slot": "combobox-separator", ...e }));
|
|
313
|
+
oe.displayName = "ComboboxSeparator";
|
|
314
|
+
function me({ className: e, children: o }) {
|
|
284
315
|
return /* @__PURE__ */ a(
|
|
285
316
|
"div",
|
|
286
317
|
{
|
|
287
318
|
"aria-disabled": "true",
|
|
288
319
|
"aria-selected": "false",
|
|
289
|
-
className:
|
|
320
|
+
className: y(
|
|
290
321
|
"text-muted-foreground flex items-center justify-center gap-2 py-6 text-sm",
|
|
291
|
-
|
|
322
|
+
e
|
|
292
323
|
),
|
|
293
324
|
"data-slot": "combobox-loading",
|
|
294
325
|
role: "option",
|
|
295
|
-
children:
|
|
326
|
+
children: o || /* @__PURE__ */ E(A, { children: [
|
|
296
327
|
/* @__PURE__ */ a(
|
|
297
328
|
"div",
|
|
298
329
|
{
|
|
@@ -306,15 +337,15 @@ function mo({ className: o, children: e }) {
|
|
|
306
337
|
);
|
|
307
338
|
}
|
|
308
339
|
export {
|
|
309
|
-
|
|
310
|
-
|
|
340
|
+
ue as Combobox,
|
|
341
|
+
le as ComboboxContent,
|
|
311
342
|
X as ComboboxEmpty,
|
|
312
343
|
Y as ComboboxGroup,
|
|
313
344
|
Q as ComboboxInput,
|
|
314
|
-
|
|
345
|
+
ee as ComboboxItem,
|
|
315
346
|
W as ComboboxList,
|
|
316
|
-
|
|
317
|
-
|
|
347
|
+
me as ComboboxLoading,
|
|
348
|
+
oe as ComboboxSeparator,
|
|
318
349
|
K as ComboboxTrigger,
|
|
319
|
-
|
|
350
|
+
ce as ComboboxValue
|
|
320
351
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@brightlocal/ui-components",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.3",
|
|
4
4
|
"description": "BrightLocal Design System UI Components",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"private": false,
|
|
@@ -105,8 +105,8 @@
|
|
|
105
105
|
"vite-bundle-visualizer": "^1.2.1",
|
|
106
106
|
"vite-plugin-dts": "^4.5.4",
|
|
107
107
|
"vite-plugin-lib-inject-css": "^2.2.2",
|
|
108
|
-
"@workspace/
|
|
109
|
-
"@workspace/
|
|
108
|
+
"@workspace/typescript-config": "0.0.0",
|
|
109
|
+
"@workspace/eslint-config": "0.0.0"
|
|
110
110
|
},
|
|
111
111
|
"publishConfig": {
|
|
112
112
|
"access": "public",
|
|
@@ -10,7 +10,7 @@ import { cn } from "@brightlocal/ui-components/lib/utils";
|
|
|
10
10
|
* CentredLayout provides a full-page centered container.
|
|
11
11
|
*
|
|
12
12
|
* Spacing tokens used:
|
|
13
|
-
* - Padding: section-
|
|
13
|
+
* - Padding: p-section-sm utility (16px mobile/tablet, 24px desktop)
|
|
14
14
|
* - Header to content gap: gap-4 (spacing.4 = 16px)
|
|
15
15
|
*
|
|
16
16
|
* The component takes full page width/height and centers content horizontally and vertically.
|