@brightlocal/ui-components 0.1.4 → 0.2.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 (55) hide show
  1. package/README.md +2 -1
  2. package/dist/checkbox.cjs +1 -1
  3. package/dist/checkbox.d.ts.map +1 -1
  4. package/dist/checkbox.js +19 -19
  5. package/dist/combobox.cjs +1 -1
  6. package/dist/combobox.d.ts +75 -59
  7. package/dist/combobox.d.ts.map +1 -1
  8. package/dist/combobox.js +241 -191
  9. package/dist/index.cjs +1 -1
  10. package/dist/index.js +354 -344
  11. package/dist/input-group.cjs +1 -1
  12. package/dist/input-group.d.ts +5 -0
  13. package/dist/input-group.d.ts.map +1 -1
  14. package/dist/input-group.js +47 -39
  15. package/dist/input-otp.cjs +1 -1
  16. package/dist/input-otp.d.ts +6 -0
  17. package/dist/input-otp.d.ts.map +1 -1
  18. package/dist/input-otp.js +79 -76
  19. package/dist/input-password.cjs +1 -1
  20. package/dist/input-password.d.ts +4 -0
  21. package/dist/input-password.d.ts.map +1 -1
  22. package/dist/input-password.js +32 -31
  23. package/dist/input.cjs +1 -1
  24. package/dist/input.d.ts +4 -0
  25. package/dist/input.d.ts.map +1 -1
  26. package/dist/input.js +26 -24
  27. package/dist/logo.cjs +1 -1
  28. package/dist/logo.js +13 -13
  29. package/dist/radio-group.cjs +1 -1
  30. package/dist/radio-group.d.ts +4 -0
  31. package/dist/radio-group.d.ts.map +1 -1
  32. package/dist/radio-group.js +49 -47
  33. package/dist/select.cjs +1 -1
  34. package/dist/select.d.ts +3 -1
  35. package/dist/select.d.ts.map +1 -1
  36. package/dist/select.js +57 -56
  37. package/dist/textarea.cjs +1 -1
  38. package/dist/textarea.d.ts +4 -0
  39. package/dist/textarea.d.ts.map +1 -1
  40. package/dist/textarea.js +19 -18
  41. package/dist/toggle.cjs +1 -1
  42. package/dist/toggle.d.ts.map +1 -1
  43. package/dist/toggle.js +17 -17
  44. package/package.json +1 -1
  45. package/src/components/checkbox.tsx +4 -5
  46. package/src/components/combobox.tsx +482 -294
  47. package/src/components/input-group.tsx +14 -2
  48. package/src/components/input-otp.tsx +16 -1
  49. package/src/components/input-password.tsx +6 -1
  50. package/src/components/input.tsx +11 -3
  51. package/src/components/logo.tsx +1 -1
  52. package/src/components/radio-group.tsx +11 -0
  53. package/src/components/select.tsx +7 -2
  54. package/src/components/textarea.tsx +12 -5
  55. package/src/components/toggle.tsx +13 -15
package/README.md CHANGED
@@ -277,10 +277,11 @@ When using these components:
277
277
  <Field>
278
278
  <Label htmlFor="email">Email Address</Label>
279
279
  <Input
280
+ dataHook="email-input"
280
281
  id="email"
281
282
  type="email"
282
283
  aria-describedby="email-error"
283
- aria-invalid={hasError}
284
+ error={hasError}
284
285
  />
285
286
  {hasError && (
286
287
  <span id="email-error" role="alert">
package/dist/checkbox.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("react/jsx-runtime"),g=require("react"),m=require("@radix-ui/react-checkbox"),x=require("@brightlocal/icons"),p=require("class-variance-authority"),v=require("@brightlocal/ui-components/lib/utils");function s(e){const r=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const t in e)if(t!=="default"){const a=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(r,t,a.get?a:{enumerable:!0,get:()=>e[t]})}}return r.default=e,Object.freeze(r)}const o=s(g),i=s(m),y=p.cva(["size-4 shrink-0 self-start","bg-background peer border border-ring dark:bg-input/30 rounded-xs transition-colors outline-none","data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground dark:data-[state=checked]:bg-primary data-[state=checked]:border-primary","focus-visible:border-ring focus-visible:shadow-default","disabled:cursor-not-allowed disabled:opacity-50"],{variants:{error:{true:["border-destructive/40 dark:border-destructive/60","focus-visible:border-destructive focus-visible:shadow-destructive"]}},defaultVariants:{error:!1}}),n=o.forwardRef(({className:e,disabled:r=!1,error:t,dataHook:a,trackingEl:d,trackingLabel:u,id:l,...b},f)=>{const k=o.useId(),h=l||k;return c.jsx(i.Root,{ref:f,"aria-invalid":t?"true":void 0,className:v.cn(y({error:t}),e),"data-hook":a,"data-slot":"checkbox","data-tracking-el":d,"data-tracking-label":u,disabled:r,id:h,...b,children:c.jsx(i.Indicator,{className:"flex items-center justify-center text-current transition-none","data-slot":"checkbox-indicator",children:c.jsx(x.CheckIcon,{className:"size-3.5"})})})});n.displayName="Checkbox";exports.Checkbox=n;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("react/jsx-runtime"),g=require("react"),m=require("@radix-ui/react-checkbox"),x=require("@brightlocal/icons"),p=require("class-variance-authority"),v=require("@brightlocal/ui-components/lib/utils");function s(e){const r=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const t in e)if(t!=="default"){const a=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(r,t,a.get?a:{enumerable:!0,get:()=>e[t]})}}return r.default=e,Object.freeze(r)}const o=s(g),i=s(m),y=p.cva(["size-4 shrink-0 self-start","bg-background peer border border-ring dark:bg-input/30 rounded-xs transition-colors outline-none","data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground dark:data-[state=checked]:bg-primary data-[state=checked]:border-primary","focus-visible:border-ring focus-visible:shadow-default","disabled:cursor-not-allowed disabled:opacity-50"],{variants:{error:{true:["border-red-600/40 dark:border-red-400/60","focus-visible:border-destructive focus-visible:shadow-destructive"]}},defaultVariants:{error:!1}}),n=o.forwardRef(({className:e,disabled:r=!1,error:t,dataHook:a,trackingEl:d,trackingLabel:l,id:u,...b},f)=>{const k=o.useId(),h=u||k;return c.jsx(i.Root,{ref:f,"aria-invalid":t?"true":void 0,className:v.cn(y({error:t}),e),"data-hook":a,"data-slot":"checkbox","data-tracking-el":d,"data-tracking-label":l,disabled:r,id:h,...b,children:c.jsx(i.Indicator,{className:"flex items-center justify-center text-current transition-none","data-slot":"checkbox-indicator",children:c.jsx(x.CheckIcon,{className:"size-3.5"})})})});n.displayName="Checkbox";exports.Checkbox=n;
@@ -1 +1 @@
1
- {"version":3,"file":"checkbox.d.ts","sourceRoot":"","sources":["../../src/components/checkbox.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,iBAAiB,MAAM,0BAA0B,CAAC;AAE9D,OAAO,EAAO,KAAK,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAIlE,QAAA,MAAM,gBAAgB;;8EA4BrB,CAAC;AAEF,MAAM,WAAW,aACf,SACE,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,OAAO,iBAAiB,CAAC,IAAI,CAAC,EAAE,UAAU,CAAC,EACrE,YAAY,CAAC,OAAO,gBAAgB,CAAC;IACvC,uCAAuC;IACvC,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,iDAAiD;IACjD,QAAQ,EAAE,MAAM,CAAC;IACjB,gDAAgD;IAChD,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,2CAA2C;IAC3C,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED,QAAA,MAAM,QAAQ,sGAuCb,CAAC;AAIF,OAAO,EAAE,QAAQ,EAAE,CAAC"}
1
+ {"version":3,"file":"checkbox.d.ts","sourceRoot":"","sources":["../../src/components/checkbox.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,iBAAiB,MAAM,0BAA0B,CAAC;AAE9D,OAAO,EAAO,KAAK,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAGlE,QAAA,MAAM,gBAAgB;;8EA4BrB,CAAC;AAEF,MAAM,WAAW,aACf,SACA,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,OAAO,iBAAiB,CAAC,IAAI,CAAC,EAAE,UAAU,CAAC,EACrE,YAAY,CAAC,OAAO,gBAAgB,CAAC;IACrC,uCAAuC;IACvC,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,iDAAiD;IACjD,QAAQ,EAAE,MAAM,CAAC;IACjB,gDAAgD;IAChD,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,2CAA2C;IAC3C,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED,QAAA,MAAM,QAAQ,sGAuCb,CAAC;AAIF,OAAO,EAAE,QAAQ,EAAE,CAAC"}
package/dist/checkbox.js CHANGED
@@ -1,10 +1,10 @@
1
1
  import { jsx as e } from "react/jsx-runtime";
2
- import * as t from "react";
3
- import * as a from "@radix-ui/react-checkbox";
4
- import { CheckIcon as f } from "@brightlocal/icons";
5
- import { cva as k } from "class-variance-authority";
2
+ import * as a from "react";
3
+ import * as t from "@radix-ui/react-checkbox";
4
+ import { CheckIcon as k } from "@brightlocal/icons";
5
+ import { cva as u } from "class-variance-authority";
6
6
  import { cn as h } from "@brightlocal/ui-components/lib/utils";
7
- const p = k(
7
+ const p = u(
8
8
  [
9
9
  // Layout & Size
10
10
  "size-4 shrink-0 self-start",
@@ -21,8 +21,8 @@ const p = k(
21
21
  variants: {
22
22
  error: {
23
23
  true: [
24
- // Error state - red border with 40% opacity
25
- "border-destructive/40 dark:border-destructive/60",
24
+ // Error state - red-600 border with 40% opacity (light) / red-400 with 60% opacity (dark)
25
+ "border-red-600/40 dark:border-red-400/60",
26
26
  // Error focus state - solid red border with destructive shadow
27
27
  "focus-visible:border-destructive focus-visible:shadow-destructive"
28
28
  ]
@@ -32,44 +32,44 @@ const p = k(
32
32
  error: !1
33
33
  }
34
34
  }
35
- ), v = t.forwardRef(
35
+ ), x = a.forwardRef(
36
36
  ({
37
37
  className: o,
38
38
  disabled: i = !1,
39
39
  error: r,
40
- dataHook: s,
41
- trackingEl: d,
40
+ dataHook: d,
41
+ trackingEl: s,
42
42
  trackingLabel: c,
43
43
  id: n,
44
44
  ...l
45
45
  }, b) => {
46
- const m = t.useId(), u = n || m;
46
+ const m = a.useId(), f = n || m;
47
47
  return /* @__PURE__ */ e(
48
- a.Root,
48
+ t.Root,
49
49
  {
50
50
  ref: b,
51
51
  "aria-invalid": r ? "true" : void 0,
52
52
  className: h(p({ error: r }), o),
53
- "data-hook": s,
53
+ "data-hook": d,
54
54
  "data-slot": "checkbox",
55
- "data-tracking-el": d,
55
+ "data-tracking-el": s,
56
56
  "data-tracking-label": c,
57
57
  disabled: i,
58
- id: u,
58
+ id: f,
59
59
  ...l,
60
60
  children: /* @__PURE__ */ e(
61
- a.Indicator,
61
+ t.Indicator,
62
62
  {
63
63
  className: "flex items-center justify-center text-current transition-none",
64
64
  "data-slot": "checkbox-indicator",
65
- children: /* @__PURE__ */ e(f, { className: "size-3.5" })
65
+ children: /* @__PURE__ */ e(k, { className: "size-3.5" })
66
66
  }
67
67
  )
68
68
  }
69
69
  );
70
70
  }
71
71
  );
72
- v.displayName = "Checkbox";
72
+ x.displayName = "Checkbox";
73
73
  export {
74
- v as Checkbox
74
+ x as Checkbox
75
75
  };
package/dist/combobox.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),R=require("react"),p=require("@brightlocal/icons"),E=require("@brightlocal/ui-components/checkbox"),V=require("class-variance-authority"),D=require("@brightlocal/ui-components/lib/utils"),f=require("@brightlocal/ui-components/popover"),l=require("@brightlocal/ui-components/command");function U(n){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(n){for(const a in n)if(a!=="default"){const c=Object.getOwnPropertyDescriptor(n,a);Object.defineProperty(t,a,c.get?c:{enumerable:!0,get:()=>n[a]})}}return t.default=n,Object.freeze(t)}const m=U(R),x="font-sans text-sm leading-normal font-normal text-foreground",B="bg-accent flex size-5 shrink-0 items-center justify-center rounded-full text-xs font-medium",H="size-5 rounded-full object-cover",J=V.cva(["relative flex w-full items-center justify-start gap-2","px-4 py-2","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","hover:bg-accent","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","[&_svg:not([class*='size-'])]:size-4","[&_svg:not([class*='text-'])]:text-muted-foreground"],{variants:{variant:{default:["h-9"],withGroupLabel:["self-stretch"]}},defaultVariants:{variant:"default"}});function S({src:n,fallback:t,alt:a,dataSlot:c}){return e.jsx("span",{className:B,"data-slot":c,children:n?e.jsx("img",{alt:a||"",className:H,src:n}):t||"?"})}const I=m.forwardRef(({id:n,variant:t="default",dataHook:a,trackingEl:c,trackingLabel:y,items:i,value:u,onValueChange:A,placeholder:g="Select an option...",groupLabel:j,disabled:_,emptyMessage:O="No results found.",searchPlaceholder:z="Search",showAvatar:L=!1,avatarSrc:$,avatarFallback:q,className:T,menuItemType:F="simple","aria-label":G},M)=>{const[b,v]=m.useState(!1),w=m.useId(),d=i.find(o=>o.value===u),P=!d,k=m.useMemo(()=>t!=="withGroupLabel"?{"":i}:i.reduce((o,r)=>{const s=r.group||"";return o[s]||(o[s]=[]),o[s].push(r),o},{}),[i,t]),N=o=>{A?.(o===u?"":o),v(!1)},C=(o,r)=>{const s=o.icon,h=r?e.jsx(p.CheckIcon,{className:"text-muted-foreground ml-auto size-4 shrink-0"}):null;switch(F){case"checkbox":return e.jsxs(e.Fragment,{children:[e.jsx(E.Checkbox,{checked:r,className:"pointer-events-none self-center",dataHook:`${a}-checkbox-${o.value}`}),e.jsx("span",{className:x,children:o.label})]});case"icon":return e.jsxs(e.Fragment,{children:[s&&e.jsx(s,{className:"text-muted-foreground size-4 shrink-0"}),e.jsx("span",{className:x,children:o.label}),h]});case"avatar":return e.jsxs(e.Fragment,{children:[e.jsx(S,{alt:o.label,dataSlot:"menu-item-avatar",fallback:o.avatarFallback,src:o.avatarSrc}),e.jsx("span",{className:x,children:o.label}),h]});case"simple":default:return e.jsxs(e.Fragment,{children:[e.jsx("span",{className:x,children:o.label}),h]})}};return e.jsxs(f.Popover,{open:b,onOpenChange:v,children:[e.jsx(f.PopoverTrigger,{asChild:!0,children:e.jsx("button",{ref:M,"aria-controls":b?w:void 0,"aria-expanded":b,"aria-haspopup":"listbox","aria-label":G,className:D.cn(J({variant:t}),T),"data-hook":a,"data-placeholder":P,"data-slot":"combobox-trigger","data-tracking-el":c||`combobox-${t}`,"data-tracking-label":y,disabled:_,id:n,role:"combobox",type:"button",children:t==="withGroupLabel"?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex w-full flex-col items-start pr-6",children:[j&&e.jsx("span",{className:"text-muted-foreground overflow-hidden font-sans text-xs leading-4 font-normal text-ellipsis",children:j}),e.jsx("span",{className:"text-foreground overflow-hidden font-sans text-sm leading-5 font-medium text-ellipsis whitespace-nowrap",children:d?d.label:g})]}),e.jsx(p.ChevronDownIcon,{className:"text-muted-foreground absolute top-1/2 right-4 size-4 shrink-0 -translate-y-1/2"})]}):e.jsxs(e.Fragment,{children:[L&&e.jsx(S,{alt:d?.label,dataSlot:"combobox-avatar",fallback:q,src:$}),e.jsx("span",{className:"text-foreground overflow-hidden text-sm leading-normal font-medium text-ellipsis whitespace-nowrap",children:d?d.label:g}),e.jsx(p.ChevronsUpDownIcon,{className:"text-muted-foreground ml-auto size-4 shrink-0"})]})})}),e.jsx(f.PopoverContent,{align:"start",className:"w-[var(--radix-popover-trigger-width)] p-0","data-slot":"combobox-popover",children:e.jsxs(l.Command,{className:"border-0 shadow-none","data-slot":"combobox-command",dataHook:`${a}-command`,id:w,children:[e.jsx(l.CommandInput,{dataHook:`${a}-search`,placeholder:z}),e.jsxs(l.CommandList,{children:[e.jsx(l.CommandEmpty,{children:O}),t==="withGroupLabel"&&Object.keys(k).length>1?Object.entries(k).map(([o,r])=>e.jsx(l.CommandGroup,{heading:o,children:r.map(s=>e.jsx(l.CommandItem,{dataHook:`${a}-item-${s.value}`,value:s.value,onSelect:N,children:C(s,u===s.value)},s.value))},o)):e.jsx(l.CommandGroup,{children:i.map(o=>e.jsx(l.CommandItem,{dataHook:`${a}-item-${o.value}`,value:o.value,onSelect:N,children:C(o,u===o.value)},o.value))})]})]})})]})});I.displayName="Combobox";exports.Combobox=I;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("react/jsx-runtime"),U=require("react"),I=require("@brightlocal/icons"),V=require("class-variance-authority"),w=require("@brightlocal/ui-components/lib/utils"),S=require("@brightlocal/ui-components/popover"),l=require("@brightlocal/ui-components/command");function $(o){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(o){for(const a in o)if(a!=="default"){const t=Object.getOwnPropertyDescriptor(o,a);Object.defineProperty(e,a,t.get?t:{enumerable:!0,get:()=>o[a]})}}return e.default=o,Object.freeze(e)}const n=$(U),E=n.createContext(null);function y(){const o=n.useContext(E);if(!o)throw new Error("Combobox components must be used within a <Combobox>");return o}function F({value:o,onValueChange:e,open:a,onOpenChange:t,shouldFilter:s=!0,disabled:c=!1,children:i}){const[f,d]=n.useState(""),[m,g]=n.useState(!1),[x,u]=n.useState(()=>new Map),C=o!==void 0,p=a!==void 0,v=C?o:f,h=p?a:m,j=n.useCallback(b=>{p||g(b),t?.(b)},[p,t]),N=n.useCallback(b=>{C||d(b),e?.(b)},[C,e]),R=n.useCallback((b,L)=>{u(k=>{if(k.get(b)===L)return k;const T=new Map(k);return T.set(b,L),T})},[]),D=n.useMemo(()=>({open:h,setOpen:j,value:v,onValueChange:N,shouldFilter:s,disabled:c,itemLabels:x,registerItem:R}),[h,j,v,N,s,c,x,R]);return r.jsx(E.Provider,{value:D,children:r.jsx(S.Popover,{open:h,onOpenChange:j,children:i})})}const A=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","hover:bg-accent","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","[&_svg:not([class*='size-'])]:size-4"],{variants:{variant:{default:[]}},defaultVariants:{variant:"default"}}),O=n.forwardRef(({className:o,variant:e,dataHook:a,trackingEl:t,trackingLabel:s,children:c,...i},f)=>{const{open:d,disabled:m,value:g}=y(),x=n.useId(),u=!g;return r.jsx(S.PopoverTrigger,{asChild:!0,children:r.jsxs("button",{ref:f,"aria-controls":d?x:void 0,"aria-expanded":d,"aria-haspopup":"listbox",className:w.cn(A({variant:e}),o),"data-hook":a,"data-placeholder":u,"data-slot":"combobox-trigger","data-state":d?"open":"closed","data-tracking-el":t||"combobox-trigger","data-tracking-label":s,disabled:m||i.disabled,role:"combobox",type:"button",...i,children:[c,r.jsx(I.ChevronsUpDownIcon,{"aria-hidden":"true",className:"text-muted-foreground ml-auto size-4 shrink-0"})]})})});O.displayName="ComboboxTrigger";function H({placeholder:o,className:e}){const{value:a,itemLabels:t}=y(),s=a?t.get(a)||a:o;return r.jsx("span",{className:w.cn("text-foreground overflow-hidden text-sm leading-normal font-medium text-ellipsis whitespace-nowrap",e),"data-slot":"combobox-value",children:s})}function B({dataHook:o,className:e,children:a,align:t="start"}){const{shouldFilter:s}=y();return r.jsx(S.PopoverContent,{align:t,className:w.cn("w-[var(--radix-popover-trigger-width)] p-0",e),"data-slot":"combobox-popover",children:r.jsx(l.Command,{className:"border-0 shadow-none","data-slot":"combobox-command",dataHook:o||"combobox-command",shouldFilter:s,children:a})})}const P=n.forwardRef((o,e)=>r.jsx(l.CommandInput,{ref:e,"data-slot":"combobox-input",...o}));P.displayName="ComboboxInput";const q=n.forwardRef((o,e)=>r.jsx(l.CommandList,{ref:e,"data-slot":"combobox-list",...o}));q.displayName="ComboboxList";const z=n.forwardRef((o,e)=>r.jsx(l.CommandEmpty,{ref:e,"data-slot":"combobox-empty",...o}));z.displayName="ComboboxEmpty";const M=n.forwardRef((o,e)=>r.jsx(l.CommandGroup,{ref:e,"data-slot":"combobox-group",...o}));M.displayName="ComboboxGroup";function J(o,e,a){if(!e||!e.trim())return o;const t=new RegExp(`(${e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")})`,"gi"),s=o.split(t);return r.jsx("span",{children:s.map((c,i)=>i%2===1?r.jsx("span",{className:a,children:c},i):r.jsx(n.Fragment,{children:c},i))})}const _=n.forwardRef(({value:o,label:e,dataHook:a,children:t,className:s,highlight:c,highlightClassName:i,...f},d)=>{const{value:m,onValueChange:g,setOpen:x,registerItem:u}=y(),C=m===o,p=n.useMemo(()=>e||(typeof t=="string"?t:typeof t=="number"?String(t):o),[e,t,o]),v=n.useRef(u);n.useEffect(()=>{v.current=u},[u]),n.useEffect(()=>{v.current(o,p)},[o,p]);const h=()=>{g(o===m?"":o),x(!1)},j=()=>c&&typeof t=="string"?J(t,c,i||"text-sm leading-normal font-semibold"):t;return r.jsxs(l.CommandItem,{ref:d,className:w.cn("justify-between",s),"data-slot":"combobox-item",dataHook:a,value:o,onSelect:h,...f,children:[j(),C&&r.jsx(I.CheckIcon,{"aria-hidden":"true",className:"text-muted-foreground size-4 shrink-0"})]})});_.displayName="ComboboxItem";const G=n.forwardRef((o,e)=>r.jsx(l.CommandSeparator,{ref:e,"data-slot":"combobox-separator",...o}));G.displayName="ComboboxSeparator";function K({className:o,children:e}){return r.jsx("div",{className:w.cn("flex items-center justify-center gap-2 py-6 text-sm text-muted-foreground",o),"data-slot":"combobox-loading",children:e||r.jsxs(r.Fragment,{children:[r.jsx(I.LoaderIcon,{"aria-hidden":"true",className:"size-4 animate-spin"}),"Loading..."]})})}exports.Combobox=F;exports.ComboboxContent=B;exports.ComboboxEmpty=z;exports.ComboboxGroup=M;exports.ComboboxInput=P;exports.ComboboxItem=_;exports.ComboboxList=q;exports.ComboboxLoading=K;exports.ComboboxSeparator=G;exports.ComboboxTrigger=O;exports.ComboboxValue=H;
@@ -1,75 +1,91 @@
1
- import { LucideIcon } from '@brightlocal/icons';
2
1
  import { VariantProps } from 'class-variance-authority';
2
+ import { CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList, CommandSeparator } from '../command';
3
3
  import * as React from "react";
4
- /**
5
- * Visual style variants for Combobox
6
- * - `default`: Default variant with standard combobox styling
7
- * - `withGroupLabel`: Variant with group label showing category above selection
8
- */
9
- export type ComboboxVariant = "default" | "withGroupLabel";
10
- /**
11
- * Menu item type variants for Combobox dropdown items
12
- * - `simple`: Simple text-only menu item
13
- * - `checkbox`: Menu item with checkbox
14
- * - `icon`: Menu item with icon
15
- * - `avatar`: Menu item with avatar
16
- */
17
- export type ComboboxMenuItemType = "simple" | "checkbox" | "icon" | "avatar";
18
- export interface ComboboxItem {
19
- /** Unique value for the item */
20
- value: string;
21
- /** Display label for the item */
22
- label: string;
23
- /** Optional group/category for the item */
24
- group?: string;
25
- /** Icon component for icon menu item type */
26
- icon?: LucideIcon;
27
- /** Avatar image source URL for avatar menu item type */
28
- avatarSrc?: string;
29
- /** Avatar fallback text/initials for avatar menu item type */
30
- avatarFallback?: string;
4
+ export interface ComboboxProps {
5
+ /** Controlled selected value */
6
+ value?: string;
7
+ /** Callback when value changes */
8
+ onValueChange?: (value: string) => void;
9
+ /** Controlled open state */
10
+ open?: boolean;
11
+ /** Callback when open state changes */
12
+ onOpenChange?: (open: boolean) => void;
13
+ /** Whether to use cmdk's built-in filtering. Set to false for async search. */
14
+ shouldFilter?: boolean;
15
+ /** Disabled state */
16
+ disabled?: boolean;
17
+ /** Children */
18
+ children: React.ReactNode;
31
19
  }
20
+ declare function Combobox({ value: controlledValue, onValueChange: controlledOnValueChange, open: controlledOpen, onOpenChange: controlledOnOpenChange, shouldFilter, disabled, children, }: ComboboxProps): import("react/jsx-runtime").JSX.Element;
32
21
  declare const comboboxTriggerVariants: (props?: ({
33
- variant?: "default" | "withGroupLabel" | null | undefined;
22
+ variant?: "default" | null | undefined;
34
23
  } & import('class-variance-authority/types').ClassProp) | undefined) => string;
35
- interface ComboboxProps extends VariantProps<typeof comboboxTriggerVariants> {
36
- /** Optional id for the combobox trigger, used with FieldLabel htmlFor */
37
- id?: string;
24
+ export interface ComboboxTriggerProps extends React.ButtonHTMLAttributes<HTMLButtonElement>, VariantProps<typeof comboboxTriggerVariants> {
38
25
  /** Data hook for automated testing (REQUIRED) */
39
26
  dataHook: string;
27
+ /** Accessible label for the combobox trigger. Use either aria-label or aria-labelledby for accessibility. */
28
+ "aria-label"?: string;
29
+ /** ID reference to a label element that provides the accessible name */
30
+ "aria-labelledby"?: string;
40
31
  /** Tracking element identifier for analytics */
41
32
  trackingEl?: string;
42
33
  /** Tracking label for analytics context */
43
34
  trackingLabel?: string;
44
- /** Array of items to display in the combobox */
45
- items: ComboboxItem[];
46
- /** Currently selected value */
47
- value?: string;
48
- /** Callback when selection changes */
49
- onValueChange?: (value: string) => void;
35
+ }
36
+ declare const ComboboxTrigger: React.ForwardRefExoticComponent<ComboboxTriggerProps & React.RefAttributes<HTMLButtonElement>>;
37
+ export interface ComboboxValueProps {
50
38
  /** Placeholder text when no value is selected */
51
39
  placeholder?: string;
52
- /** Group label text (only for withGroupLabel variant) */
53
- groupLabel?: string;
54
- /** Disabled state */
55
- disabled?: boolean;
56
- /** Empty state message when no results found */
57
- emptyMessage?: string;
58
- /** Search placeholder text */
59
- searchPlaceholder?: string;
60
- /** Whether to show the avatar */
61
- showAvatar?: boolean;
62
- /** Avatar image source URL */
63
- avatarSrc?: string;
64
- /** Avatar fallback text/initials */
65
- avatarFallback?: string;
66
- /** Custom className for the trigger button */
40
+ /** Custom className */
67
41
  className?: string;
68
- /** Menu item type for dropdown items */
69
- menuItemType?: ComboboxMenuItemType;
70
- /** Accessible label for the combobox (used when no visible label is provided) */
71
- "aria-label"?: string;
72
42
  }
73
- declare const Combobox: React.ForwardRefExoticComponent<ComboboxProps & React.RefAttributes<HTMLButtonElement>>;
74
- export { Combobox, type ComboboxProps };
43
+ declare function ComboboxValue({ placeholder, className }: ComboboxValueProps): import("react/jsx-runtime").JSX.Element;
44
+ export interface ComboboxContentProps {
45
+ /** Data hook for automated testing */
46
+ dataHook?: string;
47
+ /** Custom className */
48
+ className?: string;
49
+ /** Children */
50
+ children: React.ReactNode;
51
+ /** Alignment of the popover relative to trigger */
52
+ align?: "start" | "center" | "end";
53
+ }
54
+ declare function ComboboxContent({ dataHook, className, children, align, }: ComboboxContentProps): import("react/jsx-runtime").JSX.Element;
55
+ export interface ComboboxInputProps extends React.ComponentProps<typeof CommandInput> {
56
+ /** Current input value. Use for controlled/async search. */
57
+ value?: string;
58
+ /** Called when input value changes. Use to trigger async search requests. */
59
+ onValueChange?: (value: string) => void;
60
+ }
61
+ declare const ComboboxInput: React.ForwardRefExoticComponent<ComboboxInputProps & React.RefAttributes<any>>;
62
+ export type ComboboxListProps = React.ComponentProps<typeof CommandList>;
63
+ declare const ComboboxList: React.ForwardRefExoticComponent<any>;
64
+ export type ComboboxEmptyProps = React.ComponentProps<typeof CommandEmpty>;
65
+ declare const ComboboxEmpty: React.ForwardRefExoticComponent<any>;
66
+ export type ComboboxGroupProps = React.ComponentProps<typeof CommandGroup>;
67
+ declare const ComboboxGroup: React.ForwardRefExoticComponent<any>;
68
+ export interface ComboboxItemProps extends Omit<React.ComponentProps<typeof CommandItem>, "onSelect"> {
69
+ /** The value of the item (required) */
70
+ value: string;
71
+ /** Display label - if not provided, uses children text content */
72
+ label?: string;
73
+ /** Data hook for automated testing */
74
+ dataHook?: string;
75
+ /** Text to highlight in the item (typically the search query) */
76
+ highlight?: string;
77
+ /** Class name for highlighted text */
78
+ highlightClassName?: string;
79
+ }
80
+ declare const ComboboxItem: React.ForwardRefExoticComponent<Omit<ComboboxItemProps, "ref"> & React.RefAttributes<any>>;
81
+ export type ComboboxSeparatorProps = React.ComponentProps<typeof CommandSeparator>;
82
+ declare const ComboboxSeparator: React.ForwardRefExoticComponent<any>;
83
+ export interface ComboboxLoadingProps {
84
+ /** Custom className */
85
+ className?: string;
86
+ /** Children - custom loading content */
87
+ children?: React.ReactNode;
88
+ }
89
+ declare function ComboboxLoading({ className, children }: ComboboxLoadingProps): import("react/jsx-runtime").JSX.Element;
90
+ export { Combobox, ComboboxTrigger, ComboboxValue, ComboboxContent, ComboboxInput, ComboboxList, ComboboxEmpty, ComboboxGroup, ComboboxItem, ComboboxSeparator, ComboboxLoading, };
75
91
  //# sourceMappingURL=combobox.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"combobox.d.ts","sourceRoot":"","sources":["../../src/components/combobox.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAIL,KAAK,UAAU,EAChB,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EAAO,KAAK,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAiBlE;;;;GAIG;AACH,MAAM,MAAM,eAAe,GAAG,SAAS,GAAG,gBAAgB,CAAC;AAE3D;;;;;;GAMG;AACH,MAAM,MAAM,oBAAoB,GAAG,QAAQ,GAAG,UAAU,GAAG,MAAM,GAAG,QAAQ,CAAC;AAE7E,MAAM,WAAW,YAAY;IAC3B,gCAAgC;IAChC,KAAK,EAAE,MAAM,CAAC;IACd,iCAAiC;IACjC,KAAK,EAAE,MAAM,CAAC;IACd,2CAA2C;IAC3C,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,6CAA6C;IAC7C,IAAI,CAAC,EAAE,UAAU,CAAC;IAClB,wDAAwD;IACxD,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,8DAA8D;IAC9D,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAYD,QAAA,MAAM,uBAAuB;;8EAqD5B,CAAC;AAEF,UAAU,aAAc,SAAQ,YAAY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