@brightlocal/ui-components 1.4.2 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AI_USAGE.md +1 -1
- package/component-meta.json +1 -1
- package/dist/badge.cjs +1 -1
- package/dist/badge.d.ts +1 -1
- package/dist/badge.js +10 -10
- 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/button.cjs +1 -1
- package/dist/button.d.ts +5 -3
- package/dist/button.d.ts.map +1 -1
- package/dist/button.js +21 -21
- package/dist/card.cjs +1 -1
- package/dist/card.d.ts +2 -2
- package/dist/card.d.ts.map +1 -1
- package/dist/card.js +13 -13
- package/dist/combobox.cjs +1 -1
- package/dist/combobox.d.ts +1 -5
- package/dist/combobox.d.ts.map +1 -1
- package/dist/combobox.js +139 -152
- package/dist/hooks/use-debounce.cjs +1 -0
- package/dist/hooks/use-debounce.d.ts +16 -0
- package/dist/hooks/use-debounce.d.ts.map +1 -0
- package/dist/hooks/use-debounce.js +18 -0
- package/dist/hooks/use-mobile.cjs +1 -1
- package/dist/hooks/use-mobile.d.ts.map +1 -1
- package/dist/hooks/use-mobile.js +15 -10
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +44 -42
- package/dist/lib/use-dev-warning.d.ts +11 -0
- package/dist/lib/use-dev-warning.d.ts.map +1 -0
- package/dist/radio-group.cjs +1 -1
- package/dist/radio-group.d.ts +3 -3
- package/dist/radio-group.d.ts.map +1 -1
- package/dist/radio-group.js +46 -46
- package/dist/select.cjs +2 -1
- package/dist/select.d.ts.map +1 -1
- package/dist/select.js +71 -61
- package/dist/sonner.d.ts +7 -1
- package/dist/sonner.d.ts.map +1 -1
- package/dist/toggle-group.cjs +1 -1
- package/dist/toggle-group.d.ts +8 -8
- package/dist/toggle-group.d.ts.map +1 -1
- package/dist/toggle-group.js +19 -19
- package/dist/toggle.cjs +1 -1
- package/dist/toggle.d.ts +3 -3
- package/dist/toggle.d.ts.map +1 -1
- package/dist/toggle.js +12 -12
- package/package.json +2 -1
- package/src/blocks/input-list.tsx +5 -7
- package/src/components/badge.tsx +2 -2
- package/src/components/button.tsx +8 -5
- package/src/components/card.tsx +5 -5
- package/src/components/combobox.tsx +27 -43
- package/src/components/radio-group.tsx +13 -13
- package/src/components/select.tsx +17 -0
- package/src/components/sonner.tsx +8 -8
- package/src/components/toggle-group.tsx +6 -6
- package/src/components/toggle.tsx +4 -4
- package/src/hooks/use-debounce.ts +53 -0
- package/src/hooks/use-mobile.ts +17 -4
- package/src/index.ts +1 -0
- package/src/lib/use-dev-warning.ts +29 -0
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")
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("react/jsx-runtime"),U=require("react"),q=require("@brightlocal/icons"),$=require("class-variance-authority"),z=require("cmdk"),y=require("@brightlocal/ui-components/lib/utils"),T=require("@brightlocal/ui-components/popover"),k=require("@brightlocal/ui-components/command");function V(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=V(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:d=!1,itemToStringValue:s,children:C}){const[m,v]=t.useState(""),[x,h]=t.useState(!1),[g,i]=t.useState(()=>new Map),w=e!==void 0,f=a!==void 0,c=w?e:m,b=f?a:x,p=t.useCallback(l=>{f||h(l),r?.(l)},[f,r]),j=t.useCallback(l=>{w||v(l),o?.(l)},[w,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:b,setOpen:p,value:c,onValueChange:j,shouldFilter:u,disabled:d,itemLabels:g,registerItem:N,itemToStringValue:s}),[b,p,c,j,u,d,g,N,s]);return n.jsx(E.Provider,{value:S,children:n.jsx(T.Popover,{open:b,onOpenChange:p,children:C})})}const B=$.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"]),F=t.forwardRef(({className:e,dataHook:o,error:a,trackingEl:r,trackingLabel:u,children:d,...s},C)=>{const{open:m,disabled:v,value:x}=R(),h=t.useId(),g=!x,i=a||s["aria-invalid"]===!0||s["aria-invalid"]==="true";return n.jsx(T.PopoverTrigger,{asChild:!0,children:n.jsxs("button",{ref:C,"aria-controls":m?h:void 0,"aria-expanded":m,"aria-haspopup":"listbox","aria-invalid":i?"true":void 0,className:y.cn(B(),i&&"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":o,"data-placeholder":g,"data-slot":"combobox-trigger","data-state":m?"open":"closed","data-tracking-el":r||"combobox-trigger","data-tracking-label":u,disabled:v||s.disabled,role:"combobox",type:"button",...s,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:y.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:d,avoidCollisions:s,hideList:C=!1}){const{open:m,shouldFilter:v,itemToStringValue:x}=R(),[h,g]=t.useState(null),i=t.useRef(null),w=t.useCallback(c=>{if(i.current?.(),i.current=null,!c)return;let b=!1;const p=l=>{b||(l==="top"||l==="bottom")&&(b=!0,j.disconnect(),g(l))},j=new MutationObserver(()=>{p(c.getAttribute("data-side"))});j.observe(c,{attributes:!0,attributeFilter:["data-side"]});let N=0,S=0;N=requestAnimationFrame(()=>{S=requestAnimationFrame(()=>{p(c.getAttribute("data-side"))})}),i.current=()=>{b=!0,j.disconnect(),cancelAnimationFrame(N),cancelAnimationFrame(S)}},[]);t.useEffect(()=>{if(!m){i.current?.(),i.current=null;const c=setTimeout(()=>g(null),150);return()=>clearTimeout(c)}},[m]);const f=t.useMemo(()=>{if(x)return(c,b,p)=>z.defaultFilter(x(c),b,p)},[x]);return n.jsx(T.PopoverContent,{ref:w,align:r,"aria-label":"Options",avoidCollisions:s,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:h??u,sideOffset:d,children:n.jsx(k.Command,{className:y.cn("min-h-0 flex-1 border-0 shadow-none","[&_[data-slot='command-input-wrapper']]:shrink-0",C&&"[&_[data-slot='command-input-wrapper']]:border-b-0"),"data-slot":"combobox-command",dataHook:e||"combobox-command",filter:f,shouldFilter:v,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"),u=e.split(r);return n.jsx("span",{children:u.map((d,s)=>s%2===1?n.jsx("span",{className:a,children:d},s):n.jsx(t.Fragment,{children:d},s))})}const G=t.forwardRef(({value:e,label:o,dataHook:a,children:r,className:u,highlight:d,highlightClassName:s,keywords:C,...m},v)=>{const{value:x,onValueChange:h,setOpen:g,registerItem:i}=R(),w=x===e,f=t.useMemo(()=>o||(typeof r=="string"?r:typeof r=="number"?String(r):e),[o,r,e]),c=t.useRef(i);t.useEffect(()=>{c.current=i},[i]),t.useEffect(()=>{c.current(e,f)},[e,f]);const b=()=>{h(e===x?"":e),g(!1)},p=()=>d&&typeof r=="string"?Q(r,d,s||"text-sm leading-normal font-semibold"):r;return n.jsxs(k.CommandItem,{ref:v,className:y.cn("justify-between",u),"data-slot":"combobox-item",dataHook:a,keywords:C?[f,...C]:[f],value:e,onSelect:b,...m,children:[p(),w&&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
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { VariantProps } from 'class-variance-authority';
|
|
2
1
|
import { CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList, CommandSeparator } from './command';
|
|
3
2
|
import * as React from "react";
|
|
4
3
|
export interface ComboboxProps {
|
|
@@ -20,10 +19,7 @@ export interface ComboboxProps {
|
|
|
20
19
|
children: React.ReactNode;
|
|
21
20
|
}
|
|
22
21
|
declare function Combobox({ value: controlledValue, onValueChange: controlledOnValueChange, open: controlledOpen, onOpenChange: controlledOnOpenChange, shouldFilter, disabled, itemToStringValue, children, }: ComboboxProps): import("react/jsx-runtime").JSX.Element;
|
|
23
|
-
|
|
24
|
-
variant?: "default" | null | undefined;
|
|
25
|
-
} & import('class-variance-authority/types').ClassProp) | undefined) => string;
|
|
26
|
-
export interface ComboboxTriggerProps extends React.ButtonHTMLAttributes<HTMLButtonElement>, VariantProps<typeof comboboxTriggerVariants> {
|
|
22
|
+
export interface ComboboxTriggerProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {
|
|
27
23
|
/** Data hook for automated testing (REQUIRED) */
|
|
28
24
|
dataHook: string;
|
|
29
25
|
/** Accessible label for the combobox trigger. Use either aria-label or aria-labelledby for accessibility. */
|
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;
|
|
1
|
+
{"version":3,"file":"combobox.d.ts","sourceR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b,YAAY,EACZ,aAAa,EACb,aAAa,EACb,YAAY,EACZ,iBAAiB,EACjB,eAAe,GAChB,CAAC"}
|
package/dist/combobox.js
CHANGED
|
@@ -5,7 +5,7 @@ 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
7
|
import { Popover as _, PopoverContent as G, PopoverTrigger as U } from "@brightlocal/ui-components/popover";
|
|
8
|
-
import { Command as $, CommandEmpty as q, CommandGroup as z, CommandInput as D, CommandItem as H, CommandList as
|
|
8
|
+
import { Command as $, CommandEmpty as q, CommandGroup as z, CommandInput as D, CommandItem as H, CommandList as B, CommandSeparator as J } from "@brightlocal/ui-components/command";
|
|
9
9
|
const F = t.createContext(null);
|
|
10
10
|
function I() {
|
|
11
11
|
const e = t.useContext(F);
|
|
@@ -18,127 +18,114 @@ function ue({
|
|
|
18
18
|
onValueChange: o,
|
|
19
19
|
open: n,
|
|
20
20
|
onOpenChange: r,
|
|
21
|
-
shouldFilter:
|
|
22
|
-
disabled:
|
|
23
|
-
itemToStringValue:
|
|
24
|
-
children:
|
|
21
|
+
shouldFilter: u = !0,
|
|
22
|
+
disabled: c = !1,
|
|
23
|
+
itemToStringValue: s,
|
|
24
|
+
children: v
|
|
25
25
|
}) {
|
|
26
|
-
const [
|
|
26
|
+
const [b, C] = t.useState(""), [f, h] = t.useState(!1), [g, i] = t.useState(
|
|
27
27
|
() => /* @__PURE__ */ new Map()
|
|
28
|
-
),
|
|
29
|
-
(
|
|
30
|
-
|
|
28
|
+
), w = e !== void 0, p = n !== void 0, d = w ? e : b, m = p ? n : f, x = t.useCallback(
|
|
29
|
+
(l) => {
|
|
30
|
+
p || h(l), r?.(l);
|
|
31
31
|
},
|
|
32
|
-
[
|
|
32
|
+
[p, r]
|
|
33
33
|
), k = t.useCallback(
|
|
34
|
-
(
|
|
35
|
-
|
|
34
|
+
(l) => {
|
|
35
|
+
w || C(l), o?.(l);
|
|
36
36
|
},
|
|
37
|
-
[
|
|
38
|
-
), N = t.useCallback((
|
|
37
|
+
[w, o]
|
|
38
|
+
), N = t.useCallback((l, L) => {
|
|
39
39
|
i((S) => {
|
|
40
|
-
if (S.get(
|
|
40
|
+
if (S.get(l) === L) return S;
|
|
41
41
|
const T = new Map(S);
|
|
42
|
-
return T.set(
|
|
42
|
+
return T.set(l, L), T;
|
|
43
43
|
});
|
|
44
44
|
}, []), R = t.useMemo(
|
|
45
45
|
() => ({
|
|
46
|
-
open:
|
|
47
|
-
setOpen:
|
|
48
|
-
value:
|
|
46
|
+
open: m,
|
|
47
|
+
setOpen: x,
|
|
48
|
+
value: d,
|
|
49
49
|
onValueChange: k,
|
|
50
|
-
shouldFilter:
|
|
51
|
-
disabled:
|
|
52
|
-
itemLabels:
|
|
50
|
+
shouldFilter: u,
|
|
51
|
+
disabled: c,
|
|
52
|
+
itemLabels: g,
|
|
53
53
|
registerItem: N,
|
|
54
|
-
itemToStringValue:
|
|
54
|
+
itemToStringValue: s
|
|
55
55
|
}),
|
|
56
56
|
[
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
s,
|
|
60
|
-
k,
|
|
57
|
+
m,
|
|
58
|
+
x,
|
|
61
59
|
d,
|
|
60
|
+
k,
|
|
62
61
|
u,
|
|
63
|
-
|
|
62
|
+
c,
|
|
63
|
+
g,
|
|
64
64
|
N,
|
|
65
|
-
|
|
65
|
+
s
|
|
66
66
|
]
|
|
67
67
|
);
|
|
68
|
-
return /* @__PURE__ */ a(F.Provider, { value: R, children: /* @__PURE__ */ a(_, { open:
|
|
68
|
+
return /* @__PURE__ */ a(F.Provider, { value: R, children: /* @__PURE__ */ a(_, { open: m, onOpenChange: x, children: v }) });
|
|
69
69
|
}
|
|
70
|
-
const
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
],
|
|
95
|
-
{
|
|
96
|
-
variants: {
|
|
97
|
-
variant: {
|
|
98
|
-
default: []
|
|
99
|
-
}
|
|
100
|
-
},
|
|
101
|
-
defaultVariants: {
|
|
102
|
-
variant: "default"
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
), K = t.forwardRef(
|
|
70
|
+
const K = O([
|
|
71
|
+
// Base layout
|
|
72
|
+
"relative flex w-full items-center justify-between gap-2",
|
|
73
|
+
"px-4 py-2 h-9",
|
|
74
|
+
// Base appearance
|
|
75
|
+
"border border-input rounded-md outline-none",
|
|
76
|
+
"bg-neutral-50 shadow-xs",
|
|
77
|
+
"dark:bg-white/5 dark:border-white/15",
|
|
78
|
+
// Typography
|
|
79
|
+
"text-sm font-normal font-sans text-foreground",
|
|
80
|
+
// Placeholder state
|
|
81
|
+
"data-[placeholder=true]:text-muted-foreground",
|
|
82
|
+
// Focus state
|
|
83
|
+
"focus-visible:outline-none focus-visible:border-ring dark:focus-visible:border-neutral-500 focus-visible:bg-background",
|
|
84
|
+
"focus-visible:shadow-default",
|
|
85
|
+
// Open dropdown state
|
|
86
|
+
"data-[state=open]:border-ring",
|
|
87
|
+
// Disabled state
|
|
88
|
+
"disabled:cursor-not-allowed disabled:opacity-50",
|
|
89
|
+
// Transitions
|
|
90
|
+
"transition-[background-color,border-color,box-shadow] duration-200 ease-out",
|
|
91
|
+
// Icon styles
|
|
92
|
+
"[&_svg]:pointer-events-none [&_svg]:shrink-0"
|
|
93
|
+
]), Q = t.forwardRef(
|
|
106
94
|
({
|
|
107
95
|
className: e,
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
trackingEl: d,
|
|
96
|
+
dataHook: o,
|
|
97
|
+
error: n,
|
|
98
|
+
trackingEl: r,
|
|
112
99
|
trackingLabel: u,
|
|
113
|
-
children:
|
|
114
|
-
...
|
|
115
|
-
},
|
|
116
|
-
const { open:
|
|
100
|
+
children: c,
|
|
101
|
+
...s
|
|
102
|
+
}, v) => {
|
|
103
|
+
const { open: b, disabled: C, value: f } = I(), h = t.useId(), g = !f, i = n || s["aria-invalid"] === !0 || s["aria-invalid"] === "true";
|
|
117
104
|
return /* @__PURE__ */ a(U, { asChild: !0, children: /* @__PURE__ */ E(
|
|
118
105
|
"button",
|
|
119
106
|
{
|
|
120
|
-
ref:
|
|
121
|
-
"aria-controls":
|
|
122
|
-
"aria-expanded":
|
|
107
|
+
ref: v,
|
|
108
|
+
"aria-controls": b ? h : void 0,
|
|
109
|
+
"aria-expanded": b,
|
|
123
110
|
"aria-haspopup": "listbox",
|
|
124
|
-
"aria-invalid":
|
|
111
|
+
"aria-invalid": i ? "true" : void 0,
|
|
125
112
|
className: y(
|
|
126
|
-
|
|
127
|
-
|
|
113
|
+
K(),
|
|
114
|
+
i && "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",
|
|
128
115
|
e
|
|
129
116
|
),
|
|
130
|
-
"data-hook":
|
|
131
|
-
"data-placeholder":
|
|
117
|
+
"data-hook": o,
|
|
118
|
+
"data-placeholder": g,
|
|
132
119
|
"data-slot": "combobox-trigger",
|
|
133
|
-
"data-state":
|
|
134
|
-
"data-tracking-el":
|
|
120
|
+
"data-state": b ? "open" : "closed",
|
|
121
|
+
"data-tracking-el": r || "combobox-trigger",
|
|
135
122
|
"data-tracking-label": u,
|
|
136
|
-
disabled:
|
|
123
|
+
disabled: C || s.disabled,
|
|
137
124
|
role: "combobox",
|
|
138
125
|
type: "button",
|
|
139
|
-
...
|
|
126
|
+
...s,
|
|
140
127
|
children: [
|
|
141
|
-
|
|
128
|
+
c,
|
|
142
129
|
/* @__PURE__ */ a(
|
|
143
130
|
j,
|
|
144
131
|
{
|
|
@@ -151,9 +138,9 @@ const J = O(
|
|
|
151
138
|
) });
|
|
152
139
|
}
|
|
153
140
|
);
|
|
154
|
-
|
|
155
|
-
function
|
|
156
|
-
const { value: n, itemLabels: r } = I(),
|
|
141
|
+
Q.displayName = "ComboboxTrigger";
|
|
142
|
+
function ce({ placeholder: e, className: o }) {
|
|
143
|
+
const { value: n, itemLabels: r } = I(), u = n ? r.get(n) || n : e;
|
|
157
144
|
return /* @__PURE__ */ a(
|
|
158
145
|
"span",
|
|
159
146
|
{
|
|
@@ -162,90 +149,90 @@ function le({ placeholder: e, className: o }) {
|
|
|
162
149
|
o
|
|
163
150
|
),
|
|
164
151
|
"data-slot": "combobox-value",
|
|
165
|
-
children:
|
|
152
|
+
children: u
|
|
166
153
|
}
|
|
167
154
|
);
|
|
168
155
|
}
|
|
169
|
-
function
|
|
156
|
+
function le({
|
|
170
157
|
dataHook: e,
|
|
171
158
|
className: o,
|
|
172
159
|
children: n,
|
|
173
160
|
align: r = "start",
|
|
174
|
-
side:
|
|
175
|
-
sideOffset:
|
|
176
|
-
avoidCollisions:
|
|
177
|
-
hideList:
|
|
161
|
+
side: u = "bottom",
|
|
162
|
+
sideOffset: c,
|
|
163
|
+
avoidCollisions: s,
|
|
164
|
+
hideList: v = !1
|
|
178
165
|
}) {
|
|
179
|
-
const { open:
|
|
166
|
+
const { open: b, shouldFilter: C, itemToStringValue: f } = I(), [h, g] = t.useState(
|
|
180
167
|
null
|
|
181
|
-
), i = t.useRef(null),
|
|
182
|
-
if (i.current?.(), i.current = null, !
|
|
183
|
-
let
|
|
184
|
-
const
|
|
185
|
-
|
|
168
|
+
), i = t.useRef(null), w = t.useCallback((d) => {
|
|
169
|
+
if (i.current?.(), i.current = null, !d) return;
|
|
170
|
+
let m = !1;
|
|
171
|
+
const x = (l) => {
|
|
172
|
+
m || (l === "top" || l === "bottom") && (m = !0, k.disconnect(), g(l));
|
|
186
173
|
}, k = new MutationObserver(() => {
|
|
187
|
-
|
|
174
|
+
x(d.getAttribute("data-side"));
|
|
188
175
|
});
|
|
189
|
-
k.observe(
|
|
176
|
+
k.observe(d, {
|
|
190
177
|
attributes: !0,
|
|
191
178
|
attributeFilter: ["data-side"]
|
|
192
179
|
});
|
|
193
180
|
let N = 0, R = 0;
|
|
194
181
|
N = requestAnimationFrame(() => {
|
|
195
182
|
R = requestAnimationFrame(() => {
|
|
196
|
-
|
|
183
|
+
x(d.getAttribute("data-side"));
|
|
197
184
|
});
|
|
198
185
|
}), i.current = () => {
|
|
199
|
-
|
|
186
|
+
m = !0, k.disconnect(), cancelAnimationFrame(N), cancelAnimationFrame(R);
|
|
200
187
|
};
|
|
201
188
|
}, []);
|
|
202
189
|
t.useEffect(() => {
|
|
203
|
-
if (!
|
|
190
|
+
if (!b) {
|
|
204
191
|
i.current?.(), i.current = null;
|
|
205
|
-
const
|
|
206
|
-
return () => clearTimeout(
|
|
192
|
+
const d = setTimeout(() => g(null), 150);
|
|
193
|
+
return () => clearTimeout(d);
|
|
207
194
|
}
|
|
208
|
-
}, [
|
|
209
|
-
const
|
|
195
|
+
}, [b]);
|
|
196
|
+
const p = t.useMemo(() => {
|
|
210
197
|
if (f)
|
|
211
|
-
return (
|
|
198
|
+
return (d, m, x) => P(f(d), m, x);
|
|
212
199
|
}, [f]);
|
|
213
200
|
return /* @__PURE__ */ a(
|
|
214
201
|
G,
|
|
215
202
|
{
|
|
216
|
-
ref:
|
|
203
|
+
ref: w,
|
|
217
204
|
align: r,
|
|
218
205
|
"aria-label": "Options",
|
|
219
|
-
avoidCollisions:
|
|
206
|
+
avoidCollisions: s,
|
|
220
207
|
className: y(
|
|
221
208
|
"flex max-h-[var(--radix-popover-content-available-height)] w-[var(--radix-popover-trigger-width)] flex-col overflow-hidden p-0",
|
|
222
209
|
o
|
|
223
210
|
),
|
|
224
211
|
"data-slot": "combobox-popover",
|
|
225
|
-
side:
|
|
226
|
-
sideOffset:
|
|
212
|
+
side: h ?? u,
|
|
213
|
+
sideOffset: c,
|
|
227
214
|
children: /* @__PURE__ */ a(
|
|
228
215
|
$,
|
|
229
216
|
{
|
|
230
217
|
className: y(
|
|
231
218
|
"min-h-0 flex-1 border-0 shadow-none",
|
|
232
219
|
"[&_[data-slot='command-input-wrapper']]:shrink-0",
|
|
233
|
-
|
|
220
|
+
v && "[&_[data-slot='command-input-wrapper']]:border-b-0"
|
|
234
221
|
),
|
|
235
222
|
"data-slot": "combobox-command",
|
|
236
223
|
dataHook: e || "combobox-command",
|
|
237
|
-
filter:
|
|
238
|
-
shouldFilter:
|
|
224
|
+
filter: p,
|
|
225
|
+
shouldFilter: C,
|
|
239
226
|
children: n
|
|
240
227
|
}
|
|
241
228
|
)
|
|
242
229
|
}
|
|
243
230
|
);
|
|
244
231
|
}
|
|
245
|
-
const
|
|
246
|
-
|
|
232
|
+
const V = t.forwardRef((e, o) => /* @__PURE__ */ a(D, { ref: o, "data-slot": "combobox-input", ...e }));
|
|
233
|
+
V.displayName = "ComboboxInput";
|
|
247
234
|
const W = t.forwardRef(({ className: e, ...o }, n) => /* @__PURE__ */ a(
|
|
248
|
-
|
|
235
|
+
B,
|
|
249
236
|
{
|
|
250
237
|
ref: n,
|
|
251
238
|
className: y("min-h-0 flex-1", e),
|
|
@@ -264,9 +251,9 @@ function Z(e, o, n) {
|
|
|
264
251
|
const r = new RegExp(
|
|
265
252
|
`(${o.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")})`,
|
|
266
253
|
"gi"
|
|
267
|
-
),
|
|
268
|
-
return /* @__PURE__ */ a("span", { children:
|
|
269
|
-
(
|
|
254
|
+
), u = e.split(r);
|
|
255
|
+
return /* @__PURE__ */ a("span", { children: u.map(
|
|
256
|
+
(c, s) => s % 2 === 1 ? /* @__PURE__ */ a("span", { className: n, children: c }, s) : /* @__PURE__ */ a(t.Fragment, { children: c }, s)
|
|
270
257
|
) });
|
|
271
258
|
}
|
|
272
259
|
const ee = t.forwardRef(
|
|
@@ -275,39 +262,39 @@ const ee = t.forwardRef(
|
|
|
275
262
|
label: o,
|
|
276
263
|
dataHook: n,
|
|
277
264
|
children: r,
|
|
278
|
-
className:
|
|
279
|
-
highlight:
|
|
280
|
-
highlightClassName:
|
|
281
|
-
keywords:
|
|
282
|
-
...
|
|
283
|
-
},
|
|
284
|
-
const { value: f, onValueChange:
|
|
265
|
+
className: u,
|
|
266
|
+
highlight: c,
|
|
267
|
+
highlightClassName: s,
|
|
268
|
+
keywords: v,
|
|
269
|
+
...b
|
|
270
|
+
}, C) => {
|
|
271
|
+
const { value: f, onValueChange: h, setOpen: g, registerItem: i } = I(), w = f === e, p = t.useMemo(() => o || (typeof r == "string" ? r : typeof r == "number" ? String(r) : e), [o, r, e]), d = t.useRef(i);
|
|
285
272
|
t.useEffect(() => {
|
|
286
|
-
|
|
273
|
+
d.current = i;
|
|
287
274
|
}, [i]), t.useEffect(() => {
|
|
288
|
-
|
|
289
|
-
}, [e,
|
|
290
|
-
const
|
|
291
|
-
|
|
292
|
-
},
|
|
275
|
+
d.current(e, p);
|
|
276
|
+
}, [e, p]);
|
|
277
|
+
const m = () => {
|
|
278
|
+
h(e === f ? "" : e), g(!1);
|
|
279
|
+
}, x = () => c && typeof r == "string" ? Z(
|
|
293
280
|
r,
|
|
294
|
-
|
|
295
|
-
|
|
281
|
+
c,
|
|
282
|
+
s || "text-sm leading-normal font-semibold"
|
|
296
283
|
) : r;
|
|
297
284
|
return /* @__PURE__ */ E(
|
|
298
285
|
H,
|
|
299
286
|
{
|
|
300
|
-
ref:
|
|
301
|
-
className: y("justify-between",
|
|
287
|
+
ref: C,
|
|
288
|
+
className: y("justify-between", u),
|
|
302
289
|
"data-slot": "combobox-item",
|
|
303
290
|
dataHook: n,
|
|
304
|
-
keywords:
|
|
291
|
+
keywords: v ? [p, ...v] : [p],
|
|
305
292
|
value: e,
|
|
306
|
-
onSelect:
|
|
307
|
-
...
|
|
293
|
+
onSelect: m,
|
|
294
|
+
...b,
|
|
308
295
|
children: [
|
|
309
|
-
|
|
310
|
-
|
|
296
|
+
x(),
|
|
297
|
+
w && /* @__PURE__ */ a(
|
|
311
298
|
M,
|
|
312
299
|
{
|
|
313
300
|
"aria-hidden": "true",
|
|
@@ -320,7 +307,7 @@ const ee = t.forwardRef(
|
|
|
320
307
|
}
|
|
321
308
|
);
|
|
322
309
|
ee.displayName = "ComboboxItem";
|
|
323
|
-
const oe = t.forwardRef((e, o) => /* @__PURE__ */ a(
|
|
310
|
+
const oe = t.forwardRef((e, o) => /* @__PURE__ */ a(J, { ref: o, "data-slot": "combobox-separator", ...e }));
|
|
324
311
|
oe.displayName = "ComboboxSeparator";
|
|
325
312
|
function me({ className: e, children: o }) {
|
|
326
313
|
return /* @__PURE__ */ a(
|
|
@@ -349,14 +336,14 @@ function me({ className: e, children: o }) {
|
|
|
349
336
|
}
|
|
350
337
|
export {
|
|
351
338
|
ue as Combobox,
|
|
352
|
-
|
|
339
|
+
le as ComboboxContent,
|
|
353
340
|
X as ComboboxEmpty,
|
|
354
341
|
Y as ComboboxGroup,
|
|
355
|
-
|
|
342
|
+
V as ComboboxInput,
|
|
356
343
|
ee as ComboboxItem,
|
|
357
344
|
W as ComboboxList,
|
|
358
345
|
me as ComboboxLoading,
|
|
359
346
|
oe as ComboboxSeparator,
|
|
360
|
-
|
|
361
|
-
|
|
347
|
+
Q as ComboboxTrigger,
|
|
348
|
+
ce as ComboboxValue
|
|
362
349
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("react");function l(t,r=300){const[s,n]=u.useState(t),e=u.useRef(null),c=u.useRef(t);u.useEffect(()=>{c.current=t},[t]),u.useEffect(()=>(e.current=setTimeout(()=>{e.current=null,n(t)},r),()=>{e.current&&(clearTimeout(e.current),e.current=null)}),[t,r]);const o=u.useCallback(()=>{e.current&&(clearTimeout(e.current),e.current=null),n(c.current)},[]);return{debouncedValue:s,flush:o}}exports.useDebounce=l;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export interface UseDebounceResult<T> {
|
|
2
|
+
/** The debounced value — updates after `delay` ms of inactivity. */
|
|
3
|
+
debouncedValue: T;
|
|
4
|
+
/** Flush the pending value immediately, bypassing the delay. */
|
|
5
|
+
flush: () => void;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Debounces a value by the given delay.
|
|
9
|
+
* Returns the latest value only after `delay` ms of inactivity,
|
|
10
|
+
* plus a `flush` function to skip the wait and update immediately.
|
|
11
|
+
*
|
|
12
|
+
* @param value - The value to debounce.
|
|
13
|
+
* @param delay - Debounce delay in milliseconds (default 300).
|
|
14
|
+
*/
|
|
15
|
+
export declare function useDebounce<T>(value: T, delay?: number): UseDebounceResult<T>;
|
|
16
|
+
//# sourceMappingURL=use-debounce.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-debounce.d.ts","sourceRoot":"","sources":["../../src/hooks/use-debounce.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,iBAAiB,CAAC,CAAC;IAClC,oEAAoE;IACpE,cAAc,EAAE,CAAC,CAAC;IAClB,gEAAgE;IAChE,KAAK,EAAE,MAAM,IAAI,CAAC;CACnB;AAED;;;;;;;GAOG;AACH,wBAAgB,WAAW,CAAC,CAAC,EAC3B,KAAK,EAAE,CAAC,EACR,KAAK,GAAE,MAAY,GAClB,iBAAiB,CAAC,CAAC,CAAC,CAgCtB"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { useState as f, useRef as c, useEffect as o, useCallback as i } from "react";
|
|
2
|
+
function b(r, t = 300) {
|
|
3
|
+
const [s, u] = f(r), e = c(null), n = c(r);
|
|
4
|
+
o(() => {
|
|
5
|
+
n.current = r;
|
|
6
|
+
}, [r]), o(() => (e.current = setTimeout(() => {
|
|
7
|
+
e.current = null, u(r);
|
|
8
|
+
}, t), () => {
|
|
9
|
+
e.current && (clearTimeout(e.current), e.current = null);
|
|
10
|
+
}), [r, t]);
|
|
11
|
+
const l = i(() => {
|
|
12
|
+
e.current && (clearTimeout(e.current), e.current = null), u(n.current);
|
|
13
|
+
}, []);
|
|
14
|
+
return { debouncedValue: s, flush: l };
|
|
15
|
+
}
|
|
16
|
+
export {
|
|
17
|
+
b as useDebounce
|
|
18
|
+
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("react");function a(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const n in e)if(n!=="default"){const o=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,o.get?o:{enumerable:!0,get:()=>e[n]})}}return t.default=e,Object.freeze(t)}const i=a(s),c=640;function u(){if(typeof document>"u")return c;const e=getComputedStyle(document.documentElement).getPropertyValue("--ds-breakpoint-sm").trim(),t=parseInt(e,10);return Number.isNaN(t)?c:t}function d(){const[e,t]=i.useState(void 0);return i.useEffect(()=>{const n=u(),o=window.matchMedia(`(max-width: ${n-1}px)`),r=()=>{t(window.innerWidth<n)};return o.addEventListener("change",r),t(window.innerWidth<n),()=>o.removeEventListener("change",r)},[]),!!e}exports.useIsMobile=d;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-mobile.d.ts","sourceRoot":"","sources":["../../src/hooks/use-mobile.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"use-mobile.d.ts","sourceRoot":"","sources":["../../src/hooks/use-mobile.ts"],"names":[],"mappings":"AAgBA,wBAAgB,WAAW,YAiB1B"}
|
package/dist/hooks/use-mobile.js
CHANGED
|
@@ -1,16 +1,21 @@
|
|
|
1
|
-
import * as
|
|
2
|
-
const
|
|
3
|
-
function
|
|
4
|
-
|
|
1
|
+
import * as r from "react";
|
|
2
|
+
const s = 640;
|
|
3
|
+
function a() {
|
|
4
|
+
if (typeof document > "u") return s;
|
|
5
|
+
const t = getComputedStyle(document.documentElement).getPropertyValue("--ds-breakpoint-sm").trim(), e = parseInt(t, 10);
|
|
6
|
+
return Number.isNaN(e) ? s : e;
|
|
7
|
+
}
|
|
8
|
+
function d() {
|
|
9
|
+
const [t, e] = r.useState(
|
|
5
10
|
void 0
|
|
6
11
|
);
|
|
7
|
-
return
|
|
8
|
-
const
|
|
9
|
-
|
|
12
|
+
return r.useEffect(() => {
|
|
13
|
+
const n = a(), o = window.matchMedia(`(max-width: ${n - 1}px)`), i = () => {
|
|
14
|
+
e(window.innerWidth < n);
|
|
10
15
|
};
|
|
11
|
-
return
|
|
12
|
-
}, []), !!
|
|
16
|
+
return o.addEventListener("change", i), e(window.innerWidth < n), () => o.removeEventListener("change", i);
|
|
17
|
+
}, []), !!t;
|
|
13
18
|
}
|
|
14
19
|
export {
|
|
15
|
-
|
|
20
|
+
d as useIsMobile
|
|
16
21
|
};
|