@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.
Files changed (65) hide show
  1. package/AI_USAGE.md +1 -1
  2. package/component-meta.json +1 -1
  3. package/dist/badge.cjs +1 -1
  4. package/dist/badge.d.ts +1 -1
  5. package/dist/badge.js +10 -10
  6. package/dist/blocks/input-list.cjs +2 -2
  7. package/dist/blocks/input-list.d.ts.map +1 -1
  8. package/dist/blocks/input-list.js +47 -47
  9. package/dist/button.cjs +1 -1
  10. package/dist/button.d.ts +5 -3
  11. package/dist/button.d.ts.map +1 -1
  12. package/dist/button.js +21 -21
  13. package/dist/card.cjs +1 -1
  14. package/dist/card.d.ts +2 -2
  15. package/dist/card.d.ts.map +1 -1
  16. package/dist/card.js +13 -13
  17. package/dist/combobox.cjs +1 -1
  18. package/dist/combobox.d.ts +1 -5
  19. package/dist/combobox.d.ts.map +1 -1
  20. package/dist/combobox.js +139 -152
  21. package/dist/hooks/use-debounce.cjs +1 -0
  22. package/dist/hooks/use-debounce.d.ts +16 -0
  23. package/dist/hooks/use-debounce.d.ts.map +1 -0
  24. package/dist/hooks/use-debounce.js +18 -0
  25. package/dist/hooks/use-mobile.cjs +1 -1
  26. package/dist/hooks/use-mobile.d.ts.map +1 -1
  27. package/dist/hooks/use-mobile.js +15 -10
  28. package/dist/index.cjs +1 -1
  29. package/dist/index.d.ts +1 -0
  30. package/dist/index.d.ts.map +1 -1
  31. package/dist/index.js +44 -42
  32. package/dist/lib/use-dev-warning.d.ts +11 -0
  33. package/dist/lib/use-dev-warning.d.ts.map +1 -0
  34. package/dist/radio-group.cjs +1 -1
  35. package/dist/radio-group.d.ts +3 -3
  36. package/dist/radio-group.d.ts.map +1 -1
  37. package/dist/radio-group.js +46 -46
  38. package/dist/select.cjs +2 -1
  39. package/dist/select.d.ts.map +1 -1
  40. package/dist/select.js +71 -61
  41. package/dist/sonner.d.ts +7 -1
  42. package/dist/sonner.d.ts.map +1 -1
  43. package/dist/toggle-group.cjs +1 -1
  44. package/dist/toggle-group.d.ts +8 -8
  45. package/dist/toggle-group.d.ts.map +1 -1
  46. package/dist/toggle-group.js +19 -19
  47. package/dist/toggle.cjs +1 -1
  48. package/dist/toggle.d.ts +3 -3
  49. package/dist/toggle.d.ts.map +1 -1
  50. package/dist/toggle.js +12 -12
  51. package/package.json +2 -1
  52. package/src/blocks/input-list.tsx +5 -7
  53. package/src/components/badge.tsx +2 -2
  54. package/src/components/button.tsx +8 -5
  55. package/src/components/card.tsx +5 -5
  56. package/src/components/combobox.tsx +27 -43
  57. package/src/components/radio-group.tsx +13 -13
  58. package/src/components/select.tsx +17 -0
  59. package/src/components/sonner.tsx +8 -8
  60. package/src/components/toggle-group.tsx +6 -6
  61. package/src/components/toggle.tsx +4 -4
  62. package/src/hooks/use-debounce.ts +53 -0
  63. package/src/hooks/use-mobile.ts +17 -4
  64. package/src/index.ts +1 -0
  65. 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"),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;
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;
@@ -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
- declare const comboboxTriggerVariants: (props?: ({
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. */
@@ -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,Y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AE3E,QAAA,MAAM,aAAa,uMAKjB,CAAC;AAwCH,MAAM,WAAW,iBAAkB,SAAQ,IAAI,CAC7C,KAAK,CAAC,cAAc,CAAC,OAAO,WAAW,CAAC,EACxC,UAAU,CACX;IACC,uCAAuC;IACvC,KAAK,EAAE,MAAM,CAAC;IACd,yLAAyL;IACzL,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,sCAAsC;IACtC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,iEAAiE;IACjE,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,sCAAsC;IACtC,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,4GAA4G;IAC5G,QAAQ,CAAC,EAAE,MAAM,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
@@ -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 V, CommandSeparator as B } from "@brightlocal/ui-components/command";
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: d = !0,
22
- disabled: u = !1,
23
- itemToStringValue: l,
24
- children: m
21
+ shouldFilter: u = !0,
22
+ disabled: c = !1,
23
+ itemToStringValue: s,
24
+ children: v
25
25
  }) {
26
- const [h, g] = t.useState(""), [f, w] = t.useState(!1), [C, i] = t.useState(
26
+ const [b, C] = t.useState(""), [f, h] = t.useState(!1), [g, 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, v = t.useCallback(
29
- (c) => {
30
- x || w(c), r?.(c);
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
- [x, r]
32
+ [p, r]
33
33
  ), k = t.useCallback(
34
- (c) => {
35
- p || g(c), o?.(c);
34
+ (l) => {
35
+ w || C(l), o?.(l);
36
36
  },
37
- [p, o]
38
- ), N = t.useCallback((c, L) => {
37
+ [w, o]
38
+ ), N = t.useCallback((l, L) => {
39
39
  i((S) => {
40
- if (S.get(c) === L) return S;
40
+ if (S.get(l) === L) return S;
41
41
  const T = new Map(S);
42
- return T.set(c, L), T;
42
+ return T.set(l, L), T;
43
43
  });
44
44
  }, []), R = t.useMemo(
45
45
  () => ({
46
- open: b,
47
- setOpen: v,
48
- value: s,
46
+ open: m,
47
+ setOpen: x,
48
+ value: d,
49
49
  onValueChange: k,
50
- shouldFilter: d,
51
- disabled: u,
52
- itemLabels: C,
50
+ shouldFilter: u,
51
+ disabled: c,
52
+ itemLabels: g,
53
53
  registerItem: N,
54
- itemToStringValue: l
54
+ itemToStringValue: s
55
55
  }),
56
56
  [
57
- b,
58
- v,
59
- s,
60
- k,
57
+ m,
58
+ x,
61
59
  d,
60
+ k,
62
61
  u,
63
- C,
62
+ c,
63
+ g,
64
64
  N,
65
- l
65
+ s
66
66
  ]
67
67
  );
68
- return /* @__PURE__ */ a(F.Provider, { value: R, children: /* @__PURE__ */ a(_, { open: b, onOpenChange: v, children: m }) });
68
+ return /* @__PURE__ */ a(F.Provider, { value: R, children: /* @__PURE__ */ a(_, { open: m, onOpenChange: x, children: v }) });
69
69
  }
70
- const J = O(
71
- [
72
- // Base layout
73
- "relative flex w-full items-center justify-between gap-2",
74
- "px-4 py-2 h-9",
75
- // Base appearance
76
- "border border-input rounded-md outline-none",
77
- "bg-neutral-50 shadow-xs",
78
- "dark:bg-white/5 dark:border-white/15",
79
- // Typography
80
- "text-sm font-normal font-sans text-foreground",
81
- // Placeholder state
82
- "data-[placeholder=true]:text-muted-foreground",
83
- // Focus state
84
- "focus-visible:outline-none focus-visible:border-ring dark:focus-visible:border-neutral-500 focus-visible:bg-background",
85
- "focus-visible:shadow-default",
86
- // Open dropdown state
87
- "data-[state=open]:border-ring",
88
- // Disabled state
89
- "disabled:cursor-not-allowed disabled:opacity-50",
90
- // Transitions
91
- "transition-[background-color,border-color,box-shadow] duration-200 ease-out",
92
- // Icon styles
93
- "[&_svg]:pointer-events-none [&_svg]:shrink-0"
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
- variant: o,
109
- dataHook: n,
110
- error: r,
111
- trackingEl: d,
96
+ dataHook: o,
97
+ error: n,
98
+ trackingEl: r,
112
99
  trackingLabel: u,
113
- children: l,
114
- ...m
115
- }, h) => {
116
- const { open: g, disabled: f, value: w } = I(), C = t.useId(), i = !w, p = r || m["aria-invalid"] === !0 || m["aria-invalid"] === "true";
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: h,
121
- "aria-controls": g ? C : void 0,
122
- "aria-expanded": g,
107
+ ref: v,
108
+ "aria-controls": b ? h : void 0,
109
+ "aria-expanded": b,
123
110
  "aria-haspopup": "listbox",
124
- "aria-invalid": p ? "true" : void 0,
111
+ "aria-invalid": i ? "true" : void 0,
125
112
  className: y(
126
- J({ variant: o }),
127
- 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",
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": n,
131
- "data-placeholder": i,
117
+ "data-hook": o,
118
+ "data-placeholder": g,
132
119
  "data-slot": "combobox-trigger",
133
- "data-state": g ? "open" : "closed",
134
- "data-tracking-el": d || "combobox-trigger",
120
+ "data-state": b ? "open" : "closed",
121
+ "data-tracking-el": r || "combobox-trigger",
135
122
  "data-tracking-label": u,
136
- disabled: f || m.disabled,
123
+ disabled: C || s.disabled,
137
124
  role: "combobox",
138
125
  type: "button",
139
- ...m,
126
+ ...s,
140
127
  children: [
141
- l,
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
- K.displayName = "ComboboxTrigger";
155
- function le({ placeholder: e, className: o }) {
156
- const { value: n, itemLabels: r } = I(), d = n ? r.get(n) || n : e;
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: d
152
+ children: u
166
153
  }
167
154
  );
168
155
  }
169
- function ce({
156
+ function le({
170
157
  dataHook: e,
171
158
  className: o,
172
159
  children: n,
173
160
  align: r = "start",
174
- side: d = "bottom",
175
- sideOffset: u,
176
- avoidCollisions: l,
177
- hideList: m = !1
161
+ side: u = "bottom",
162
+ sideOffset: c,
163
+ avoidCollisions: s,
164
+ hideList: v = !1
178
165
  }) {
179
- const { open: h, shouldFilter: g, itemToStringValue: f } = I(), [w, C] = t.useState(
166
+ const { open: b, shouldFilter: C, itemToStringValue: f } = I(), [h, g] = t.useState(
180
167
  null
181
- ), i = t.useRef(null), p = t.useCallback((s) => {
182
- if (i.current?.(), i.current = null, !s) return;
183
- let b = !1;
184
- const v = (c) => {
185
- b || (c === "top" || c === "bottom") && (b = !0, k.disconnect(), C(c));
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
- v(s.getAttribute("data-side"));
174
+ x(d.getAttribute("data-side"));
188
175
  });
189
- k.observe(s, {
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
- v(s.getAttribute("data-side"));
183
+ x(d.getAttribute("data-side"));
197
184
  });
198
185
  }), i.current = () => {
199
- b = !0, k.disconnect(), cancelAnimationFrame(N), cancelAnimationFrame(R);
186
+ m = !0, k.disconnect(), cancelAnimationFrame(N), cancelAnimationFrame(R);
200
187
  };
201
188
  }, []);
202
189
  t.useEffect(() => {
203
- if (!h) {
190
+ if (!b) {
204
191
  i.current?.(), i.current = null;
205
- const s = setTimeout(() => C(null), 150);
206
- return () => clearTimeout(s);
192
+ const d = setTimeout(() => g(null), 150);
193
+ return () => clearTimeout(d);
207
194
  }
208
- }, [h]);
209
- const x = t.useMemo(() => {
195
+ }, [b]);
196
+ const p = t.useMemo(() => {
210
197
  if (f)
211
- return (s, b, v) => P(f(s), b, v);
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: p,
203
+ ref: w,
217
204
  align: r,
218
205
  "aria-label": "Options",
219
- avoidCollisions: l,
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: w ?? d,
226
- sideOffset: u,
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
- m && "[&_[data-slot='command-input-wrapper']]:border-b-0"
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: x,
238
- shouldFilter: g,
224
+ filter: p,
225
+ shouldFilter: C,
239
226
  children: n
240
227
  }
241
228
  )
242
229
  }
243
230
  );
244
231
  }
245
- const Q = t.forwardRef((e, o) => /* @__PURE__ */ a(D, { ref: o, "data-slot": "combobox-input", ...e }));
246
- Q.displayName = "ComboboxInput";
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
- V,
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
- ), d = e.split(r);
268
- return /* @__PURE__ */ a("span", { children: d.map(
269
- (u, l) => l % 2 === 1 ? /* @__PURE__ */ a("span", { className: n, children: u }, l) : /* @__PURE__ */ a(t.Fragment, { children: u }, l)
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: d,
279
- highlight: u,
280
- highlightClassName: l,
281
- keywords: m,
282
- ...h
283
- }, g) => {
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);
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
- s.current = i;
273
+ d.current = i;
287
274
  }, [i]), t.useEffect(() => {
288
- s.current(e, x);
289
- }, [e, x]);
290
- const b = () => {
291
- w(e === f ? "" : e), C(!1);
292
- }, v = () => u && typeof r == "string" ? Z(
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
- u,
295
- l || "text-sm leading-normal font-semibold"
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: g,
301
- className: y("justify-between", d),
287
+ ref: C,
288
+ className: y("justify-between", u),
302
289
  "data-slot": "combobox-item",
303
290
  dataHook: n,
304
- keywords: m ? [x, ...m] : [x],
291
+ keywords: v ? [p, ...v] : [p],
305
292
  value: e,
306
- onSelect: b,
307
- ...h,
293
+ onSelect: m,
294
+ ...b,
308
295
  children: [
309
- v(),
310
- p && /* @__PURE__ */ a(
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(B, { ref: o, "data-slot": "combobox-separator", ...e }));
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
- ce as ComboboxContent,
339
+ le as ComboboxContent,
353
340
  X as ComboboxEmpty,
354
341
  Y as ComboboxGroup,
355
- Q as ComboboxInput,
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
- K as ComboboxTrigger,
361
- le as ComboboxValue
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 c=require("react");function s(e){const n=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const t in e)if(t!=="default"){const o=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(n,t,o.get?o:{enumerable:!0,get:()=>e[t]})}}return n.default=e,Object.freeze(n)}const r=s(c),i=768;function a(){const[e,n]=r.useState(void 0);return r.useEffect(()=>{const t=window.matchMedia(`(max-width: ${i-1}px)`),o=()=>{n(window.innerWidth<i)};return t.addEventListener("change",o),n(window.innerWidth<i),()=>t.removeEventListener("change",o)},[]),!!e}exports.useIsMobile=a;
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":"AAIA,wBAAgB,WAAW,YAgB1B"}
1
+ {"version":3,"file":"use-mobile.d.ts","sourceRoot":"","sources":["../../src/hooks/use-mobile.ts"],"names":[],"mappings":"AAgBA,wBAAgB,WAAW,YAiB1B"}
@@ -1,16 +1,21 @@
1
- import * as o from "react";
2
- const e = 768;
3
- function r() {
4
- const [s, n] = o.useState(
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 o.useEffect(() => {
8
- const t = window.matchMedia(`(max-width: ${e - 1}px)`), i = () => {
9
- n(window.innerWidth < e);
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 t.addEventListener("change", i), n(window.innerWidth < e), () => t.removeEventListener("change", i);
12
- }, []), !!s;
16
+ return o.addEventListener("change", i), e(window.innerWidth < n), () => o.removeEventListener("change", i);
17
+ }, []), !!t;
13
18
  }
14
19
  export {
15
- r as useIsMobile
20
+ d as useIsMobile
16
21
  };