@boxcustodia/library 2.0.0-alpha.26 → 2.0.0-alpha.28
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/dist/components/combobox/combobox.cjs.js +1 -1
- package/dist/components/combobox/combobox.es.js +174 -157
- package/dist/src/components/combobox/combobox.d.ts +2 -0
- package/package.json +1 -1
- package/src/components/combobox/combobox.stories.tsx +30 -0
- package/src/components/combobox/combobox.tsx +32 -1
- package/src/components/menu/menu.stories.tsx +58 -30
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime"),r=require("@base-ui/react/combobox"),W=require("@base-ui/react/field"),h=require("lucide-react"),A=require("react"),_=require("../input/input.cjs.js"),H=require("../field/field.cjs.js"),B=require("../../hooks/internal/use-isomorphic-layout-effect.cjs.js"),b=require("../../lib/cn.cjs.js"),X=require("../scroll-area/scroll-area.cjs.js");function U(o){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(o){for(const s in o)if(s!=="default"){const n=Object.getOwnPropertyDescriptor(o,s);Object.defineProperty(e,s,n.get?n:{enumerable:!0,get:()=>o[s]})}}return e.default=o,Object.freeze(e)}const m=U(A),p=m.createContext({chipsRef:null,multiple:!1});function S({...o}){const e=m.useRef(null);return t.jsx(p.Provider,{value:{chipsRef:e,multiple:!!o.multiple},children:t.jsx(r.Combobox.Root,{...o})})}function R({className:o,...e}){return t.jsx(r.Combobox.Input,{className:b.cn("min-w-12 flex-1 text-base outline-none placeholder:text-muted-foreground sm:text-sm [[data-slot=combobox-chip]+&]:ps-0.5",o),"data-slot":"combobox-chips-input",...e})}function P({className:o,showTrigger:e=!0,showClear:s=!1,startAddon:n,triggerProps:a,clearProps:i,...l}){return t.jsxs(r.Combobox.InputGroup,{className:"relative not-has-[>*.w-full]:w-fit w-full text-foreground has-disabled:opacity-64","data-slot":"combobox-input-group",children:[n&&t.jsx("div",{"aria-hidden":"true",className:"pointer-events-none absolute inset-y-0 start-px z-10 flex items-center ps-[calc(--spacing(3)-1px)] opacity-80 [&_svg:not([class*='size-'])]:size-4.5 sm:[&_svg:not([class*='size-'])]:size-4 [&_svg]:-mx-0.5","data-slot":"combobox-start-addon",children:n}),t.jsx(r.Combobox.Input,{className:b.cn(n&&"*:data-[slot=combobox-input]:ps-[calc(--spacing(8.5)-1px)] sm:*:data-[slot=combobox-input]:ps-[calc(--spacing(8)-1px)]","pr-6",o),"data-slot":"combobox-input",render:c=>t.jsx(_.Input,{className:"has-disabled:opacity-100",nativeInput:!0,...c}),...l}),t.jsx(y,{showTrigger:e,showClear:s,triggerProps:a,clearProps:i})]})}function T({className:o,children:e,...s}){return t.jsx(r.Combobox.Trigger,{className:o,"data-slot":"combobox-trigger",...s,children:e})}function Q({className:o,placeholder:e,children:s,showClear:n,clearProps:a,...i}){const l=t.jsx(r.Combobox.Trigger,{className:b.cn("relative flex w-full items-center rounded-md border border-input bg-background px-3 py-2 pe-9 text-sm outline-none transition-shadow","focus-visible:border-ring","aria-invalid:border-error focus-visible:aria-invalid:ring-error/20","data-disabled:cursor-not-allowed data-disabled:opacity-50","data-placeholder:text-muted-foreground",o),"data-slot":"combobox-select-trigger",...i,children:s??t.jsx(r.Combobox.Value,{placeholder:e})});return n?t.jsxs("div",{className:"relative w-full text-foreground has-disabled:opacity-64","data-slot":"combobox-select-trigger-group",children:[l,t.jsx(y,{showTrigger:!0,showClear:!0,clearProps:a})]}):t.jsx(r.Combobox.Trigger,{className:b.cn("relative flex w-full items-center rounded-md border border-input bg-background px-3 py-2 pe-9 text-sm outline-none transition-shadow","focus-visible:border-ring","aria-invalid:border-error focus-visible:aria-invalid:ring-error/20","data-disabled:cursor-not-allowed data-disabled:opacity-50","data-placeholder:text-muted-foreground",o),"data-slot":"combobox-select-trigger",...i,children:s??t.jsxs(t.Fragment,{children:[t.jsx(r.Combobox.Value,{placeholder:e}),t.jsx("div",{"aria-hidden":"true",className:"pointer-events-none absolute end-0.5 top-1/2 inline-flex size-8 -translate-y-1/2 items-center justify-center text-muted-foreground opacity-80 sm:size-7 [&_svg:not([class*='size-'])]:size-4.5 sm:[&_svg:not([class*='size-'])]:size-4",children:t.jsx(h.ChevronsUpDownIcon,{})})]})})}function $({className:o,...e}){return t.jsx("div",{className:"border-b p-2","data-slot":"combobox-search-input-wrapper",children:t.jsx(r.Combobox.Input,{className:b.cn("flex h-9 w-full rounded-md bg-transparent text-base placeholder:text-muted-foreground outline-none disabled:cursor-not-allowed disabled:opacity-64 sm:h-8 sm:text-sm",o),autoComplete:"off","data-slot":"combobox-search-input",...e})})}function k({className:o,children:e,side:s="bottom",sideOffset:n=4,alignOffset:a,align:i="start",anchor:l,portalProps:c,...u}){const{chipsRef:d}=m.useContext(p),g=l??d;return t.jsx(r.Combobox.Portal,{...c,children:t.jsx(r.Combobox.Positioner,{align:i,alignOffset:a,anchor:g,className:"z-50 select-none","data-slot":"combobox-positioner",side:s,sideOffset:n,children:t.jsx(r.Combobox.Popup,{className:b.cn("relative flex max-h-[min(var(--available-height),23rem)] min-w-(--anchor-width) max-w-(--available-width) origin-(--transform-origin) flex-1 flex-col rounded-lg border bg-popover not-dark:bg-clip-padding text-foreground shadow-lg/5","before:pointer-events-none before:absolute before:inset-0 before:rounded-[calc(var(--radius-lg)-1px)] before:shadow-[0_1px_--theme(--color-black/4%)] dark:before:shadow-[0_-1px_--theme(--color-white/6%)]","duration-100 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95","data-[side=bottom]:slide-in-from-top-2 data-[side=top]:slide-in-from-bottom-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2",o),"data-slot":"combobox-popup",...u,children:e})})})}function L({className:o,children:e,...s}){return t.jsxs(r.Combobox.Item,{className:b.cn("flex justify-between min-h-8 in-data-[side=none]:min-w-[calc(var(--anchor-width)+1.25rem)] cursor-default grid-cols-[1rem_1fr] items-center gap-2 rounded-sm py-1 px-2 text-base outline-none data-disabled:pointer-events-none data-highlighted:bg-accent data-highlighted:text-accent-foreground data-disabled:opacity-64 sm:min-h-7 sm:text-sm [&_svg:not([class*='size-'])]:size-4.5 sm:[&_svg:not([class*='size-'])]:size-4 [&_svg]:pointer-events-none [&_svg]:shrink-0",o),"data-slot":"combobox-item",...s,children:[e,t.jsx(r.Combobox.ItemIndicator,{className:"col-end-1",children:t.jsx("svg",{"aria-hidden":"true",fill:"none",height:"24",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",viewBox:"0 0 24 24",width:"24",xmlns:"http://www.w3.org/2000/svg",children:t.jsx("path",{d:"M5.252 12.7 10.2 18.63 18.748 5.37"})})})]})}function J({className:o,...e}){return t.jsx(r.Combobox.Separator,{className:b.cn("mx-2 my-1 h-px bg-border last:hidden",o),"data-slot":"combobox-separator",...e})}function K({className:o,...e}){return t.jsx(r.Combobox.Group,{className:b.cn("[[role=group]+&]:mt-1.5",o),"data-slot":"combobox-group",...e})}function Y({className:o,...e}){return t.jsx(r.Combobox.GroupLabel,{className:b.cn("px-2 py-1.5 font-medium text-muted-foreground text-xs",o),"data-slot":"combobox-group-label",...e})}function O({className:o,...e}){return t.jsx(r.Combobox.Empty,{className:b.cn("not-empty:p-2 text-center text-base text-muted-foreground sm:text-sm",o),"data-slot":"combobox-empty",...e})}function Z({className:o,...e}){return t.jsx(r.Combobox.Row,{className:o,"data-slot":"combobox-row",...e})}function G({...o}){return t.jsx(r.Combobox.Value,{"data-slot":"combobox-value",...o})}function q({className:o,...e}){return t.jsx(X.ScrollArea,{scrollbarGutter:!0,scrollFade:!0,children:t.jsx(r.Combobox.List,{className:b.cn("not-empty:scroll-py-1 not-empty:px-1 not-empty:py-1 in-data-has-overflow-y:pe-3",o),"data-slot":"combobox-list",...e})})}function E({className:o,...e}){return t.jsx(r.Combobox.Clear,{className:o,"data-slot":"combobox-clear",...e})}const z="absolute end-0.5 top-1/2 inline-flex size-8 shrink-0 -translate-y-1/2 cursor-pointer items-center justify-center rounded-md border border-transparent opacity-80 outline-none transition-opacity pointer-coarse:after:absolute pointer-coarse:after:min-h-11 pointer-coarse:after:min-w-11 hover:opacity-100 sm:size-7 [&_svg:not([class*='size-'])]:size-4.5 sm:[&_svg:not([class*='size-'])]:size-4 [&_svg]:pointer-events-none [&_svg]:shrink-0";function y({showTrigger:o=!0,showClear:e=!1,triggerProps:s,clearProps:n}){return!o&&!e?null:t.jsxs("div",{className:"text-muted-foreground hover:text-foreground transition-colors",children:[o&&t.jsx(T,{className:b.cn(z,"text-muted-foreground has-[+[data-slot=combobox-clear]]:hidden"),...s,children:t.jsx(r.Combobox.Icon,{"data-slot":"combobox-icon",children:t.jsx(h.ChevronsUpDownIcon,{})})}),e&&t.jsx(E,{className:z,...n,children:t.jsx(h.XIcon,{})})]})}function oo({className:o,...e}){return t.jsx(r.Combobox.Status,{className:b.cn("px-3 py-2 font-medium text-muted-foreground text-xs empty:m-0 empty:p-0",o),"data-slot":"combobox-status",...e})}function eo(o){return t.jsx(r.Combobox.Collection,{"data-slot":"combobox-collection",...o})}function F({className:o,children:e,startAddon:s,...n}){const{chipsRef:a}=m.useContext(p),i=H.useIsInsideFieldRoot(),l=c=>t.jsxs(r.Combobox.Chips,{"aria-invalid":c,className:b.cn(_.inputBaseClasses,"relative inline-flex pr-6 w-full flex-wrap gap-1","placeholder:text-muted-foreground","focus-within:border-ring","aria-invalid:border-error focus-within:aria-invalid:ring-error/20","has-disabled:cursor-not-allowed has-disabled:opacity-50",o),"data-slot":"combobox-chips",ref:a,...n,children:[s&&t.jsx("div",{"aria-hidden":"true",className:"flex shrink-0 items-center ps-2 opacity-80 has-[+[data-slot=combobox-chip]]:pe-2 [&_svg:not([class*='size-'])]:size-4.5 sm:[&_svg:not([class*='size-'])]:size-4 [&_svg]:pointer-events-none [&_svg]:-ms-0.5 [&_svg]:-me-1.5","data-slot":"combobox-start-addon",children:s}),e]});return i?t.jsx(W.Field.Validity,{children:({validity:c})=>l(c.valid===!1?!0:void 0)}):l(void 0)}function V({children:o,removeProps:e,...s}){return t.jsxs(r.Combobox.Chip,{className:"flex my-auto items-center pl-1 rounded-[calc(var(--radius-md)-1px)] bg-accent font-medium text-accent-foreground text-sm outline-none sm:text-xs/(--text-xs--line-height) [&_svg:not([class*='size-'])]:size-4 sm:[&_svg:not([class*='size-'])]:size-3.5 h-6","data-slot":"combobox-chip",...s,children:[o,t.jsx(D,{...e})]})}function D(o){return t.jsx(r.Combobox.ChipRemove,{"aria-label":"Quitar",className:"h-full shrink-0 cursor-pointer px-1 opacity-80 hover:opacity-100 [&_svg:not([class*='size-'])]:size-4 sm:[&_svg:not([class*='size-'])]:size-3.5","data-slot":"combobox-chip-remove",...o,children:t.jsx(h.XIcon,{})})}const j=4,to=24,so=36,ro=68;function I(o,e){const s=o-to-so;let n=0,a=0;for(let i=0;i<e.length;i++){const l=e[i],c=i<e.length-1;if(n+(i>0?j:0)+l+(c?j+ro:0)>s)break;n+=(i>0?j:0)+l,a++}return a}function no(o,e){const[s,n]=m.useState(null),a=m.useRef([]),i=s===null||s.items!==o;return B.useIsomorphicLayoutEffect(()=>{if(!i)return;const l=e?.current;if(!l)return;const c=l.querySelectorAll('[data-slot="combobox-chip"]');a.current=Array.from(c).map(d=>d.offsetWidth);const u=I(l.clientWidth,a.current);n({items:o,visible:u})},[i,o,e]),m.useEffect(()=>{const l=e?.current;if(!l)return;const c=new ResizeObserver(()=>{if(!a.current.length)return;const u=I(l.clientWidth,a.current);n(d=>d?{...d,visible:u}:null)});return c.observe(l),()=>c.disconnect()},[e]),{visibleCount:s?.visible??o,isMeasuring:i}}function io({value:o,getLabel:e,getId:s}){const{chipsRef:n}=m.useContext(p),{visibleCount:a,isMeasuring:i}=no(o.length,n),l=i?o:o.slice(0,a),c=i?0:o.length-a;return t.jsxs(t.Fragment,{children:[l.map(u=>t.jsx(V,{"aria-label":e(u),children:e(u)},s(u))),c>0&&t.jsxs("span",{className:"flex items-center whitespace-nowrap px-1 text-sm text-muted-foreground",children:["+",c," más"]})]})}function ao(o){if(o==null)return"";if(typeof o=="string"||typeof o=="number")return String(o);if(typeof o=="object"){const e=o;if("label"in e)return String(e.label);if("name"in e)return String(e.name);if("title"in e)return String(e.title)}return String(o)}function lo(o){if(o==null)return"";if(typeof o=="string"||typeof o=="number")return String(o);if(typeof o=="object"){const e=o;if("id"in e)return String(e.id);if("value"in e)return String(e.value)}return String(o)}function co({placeholder:o,showClear:e,startAddon:s,className:n}){return t.jsx(P,{className:n,placeholder:o,showClear:e,startAddon:s})}function bo({getLabel:o,getId:e,showClear:s,startAddon:n,className:a}){return t.jsxs(F,{className:a,startAddon:n,children:[t.jsx(G,{children:i=>t.jsx(io,{value:i,getLabel:o,getId:e})}),t.jsx(y,{showTrigger:!s,showClear:s})]})}function uo(o){const{items:e,getLabel:s,getId:n,renderItem:a,placeholder:i,emptyText:l="Sin resultados.",multiple:c,onValueChange:u,value:d,defaultValue:g,startAddon:w,classNames:x,showClear:N=!0,...M}=o,C=s??ao,v=n??lo;return t.jsxs(S,{items:e,itemToStringLabel:C,itemToStringValue:v,multiple:c,onValueChange:u,value:d,defaultValue:g,autoHighlight:!0,loopFocus:!0,...M,children:[c?t.jsx(bo,{getLabel:C,getId:v,showClear:N,startAddon:w,className:x?.chips}):t.jsx(co,{placeholder:i,showClear:N,startAddon:w,className:x?.input}),t.jsxs(k,{className:x?.popup,children:[c&&t.jsx("div",{className:"border-b p-2","data-slot":"combobox-chips-input-wrapper",children:t.jsx(R,{className:x?.chipsInput,placeholder:i})}),t.jsx(O,{className:x?.empty,children:l}),t.jsx(q,{className:x?.list,children:f=>t.jsx(L,{value:f,className:x?.item,children:a?a(f):C(f)},v(f))})]})]})}const mo=r.Combobox.useFilter;Object.defineProperty(exports,"ComboboxPrimitive",{enumerable:!0,get:()=>r.Combobox});exports.Combobox=uo;exports.ComboboxChip=V;exports.ComboboxChipRemove=D;exports.ComboboxChips=F;exports.ComboboxChipsInput=R;exports.ComboboxClear=E;exports.ComboboxCollection=eo;exports.ComboboxContext=p;exports.ComboboxEmpty=O;exports.ComboboxGroup=K;exports.ComboboxGroupLabel=Y;exports.ComboboxInput=P;exports.ComboboxItem=L;exports.ComboboxList=q;exports.ComboboxPopup=k;exports.ComboboxRoot=S;exports.ComboboxRow=Z;exports.ComboboxSearchInput=$;exports.ComboboxSelectTrigger=Q;exports.ComboboxSeparator=J;exports.ComboboxStatus=oo;exports.ComboboxTrigger=T;exports.ComboboxValue=G;exports.useComboboxFilter=mo;
|
|
2
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime"),s=require("@base-ui/react/combobox"),A=require("@base-ui/react/field"),C=require("lucide-react"),H=require("react"),_=require("../input/input.cjs.js"),B=require("../field/field.cjs.js"),X=require("../../hooks/internal/use-isomorphic-layout-effect.cjs.js"),u=require("../../lib/cn.cjs.js"),U=require("../scroll-area/scroll-area.cjs.js");function Q(o){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(o){for(const r in o)if(r!=="default"){const n=Object.getOwnPropertyDescriptor(o,r);Object.defineProperty(e,r,n.get?n:{enumerable:!0,get:()=>o[r]})}}return e.default=o,Object.freeze(e)}const x=Q(H),h=x.createContext({chipsRef:null,multiple:!1});function S({...o}){const e=x.useRef(null);return t.jsx(h.Provider,{value:{chipsRef:e,multiple:!!o.multiple},children:t.jsx(s.Combobox.Root,{...o})})}function R({className:o,...e}){return t.jsx(s.Combobox.Input,{className:u.cn("min-w-12 flex-1 text-base outline-none placeholder:text-muted-foreground sm:text-sm [[data-slot=combobox-chip]+&]:ps-0.5",o),"data-slot":"combobox-chips-input",...e})}function P({className:o,showTrigger:e=!0,showClear:r=!1,startAddon:n,triggerProps:a,clearProps:i,...l}){return t.jsxs(s.Combobox.InputGroup,{className:"relative not-has-[>*.w-full]:w-fit w-full text-foreground has-disabled:opacity-64","data-slot":"combobox-input-group",children:[n&&t.jsx("div",{"aria-hidden":"true",className:"pointer-events-none absolute inset-y-0 start-px z-10 flex items-center ps-[calc(--spacing(3)-1px)] opacity-80 [&_svg:not([class*='size-'])]:size-4.5 sm:[&_svg:not([class*='size-'])]:size-4 [&_svg]:-mx-0.5","data-slot":"combobox-start-addon",children:n}),t.jsx(s.Combobox.Input,{className:u.cn(n&&"*:data-[slot=combobox-input]:ps-[calc(--spacing(8.5)-1px)] sm:*:data-[slot=combobox-input]:ps-[calc(--spacing(8)-1px)]","pr-6",o),"data-slot":"combobox-input",render:c=>t.jsx(_.Input,{className:"has-disabled:opacity-100",nativeInput:!0,...c}),...l}),t.jsx(N,{showTrigger:e,showClear:r,triggerProps:a,clearProps:i})]})}function T({className:o,children:e,...r}){return t.jsx(s.Combobox.Trigger,{className:o,"data-slot":"combobox-trigger",...r,children:e})}function $({className:o,placeholder:e,children:r,showClear:n,clearProps:a,...i}){const l=t.jsx(s.Combobox.Trigger,{className:u.cn("relative flex w-full items-center rounded-md border border-input bg-background px-3 py-2 pe-9 text-sm outline-none transition-shadow","focus-visible:border-ring","aria-invalid:border-error focus-visible:aria-invalid:ring-error/20","data-disabled:cursor-not-allowed data-disabled:opacity-50","data-placeholder:text-muted-foreground",o),"data-slot":"combobox-select-trigger",...i,children:r??t.jsx(s.Combobox.Value,{placeholder:e})});return n?t.jsxs("div",{className:"relative w-full text-foreground has-disabled:opacity-64","data-slot":"combobox-select-trigger-group",children:[l,t.jsx(N,{showTrigger:!0,showClear:!0,clearProps:a})]}):t.jsx(s.Combobox.Trigger,{className:u.cn("relative flex w-full items-center rounded-md border border-input bg-background px-3 py-2 pe-9 text-sm outline-none transition-shadow","focus-visible:border-ring","aria-invalid:border-error focus-visible:aria-invalid:ring-error/20","data-disabled:cursor-not-allowed data-disabled:opacity-50","data-placeholder:text-muted-foreground",o),"data-slot":"combobox-select-trigger",...i,children:r??t.jsxs(t.Fragment,{children:[t.jsx(s.Combobox.Value,{placeholder:e}),t.jsx("div",{"aria-hidden":"true",className:"pointer-events-none absolute end-0.5 top-1/2 inline-flex size-8 -translate-y-1/2 items-center justify-center text-muted-foreground opacity-80 sm:size-7 [&_svg:not([class*='size-'])]:size-4.5 sm:[&_svg:not([class*='size-'])]:size-4",children:t.jsx(C.ChevronsUpDownIcon,{})})]})})}function J({className:o,...e}){return t.jsx("div",{className:"border-b p-2","data-slot":"combobox-search-input-wrapper",children:t.jsx(s.Combobox.Input,{className:u.cn("flex h-9 w-full rounded-md bg-transparent text-base placeholder:text-muted-foreground outline-none disabled:cursor-not-allowed disabled:opacity-64 sm:h-8 sm:text-sm",o),autoComplete:"off","data-slot":"combobox-search-input",...e})})}function k({className:o,children:e,side:r="bottom",sideOffset:n=4,alignOffset:a,align:i="start",anchor:l,portalProps:c,...b}){const{chipsRef:d}=x.useContext(h),f=l??d;return t.jsx(s.Combobox.Portal,{...c,children:t.jsx(s.Combobox.Positioner,{align:i,alignOffset:a,anchor:f,className:"z-50 select-none","data-slot":"combobox-positioner",side:r,sideOffset:n,children:t.jsx(s.Combobox.Popup,{className:u.cn("relative flex max-h-[min(var(--available-height),23rem)] min-w-(--anchor-width) max-w-(--available-width) origin-(--transform-origin) flex-1 flex-col rounded-lg border bg-popover not-dark:bg-clip-padding text-foreground shadow-lg/5","before:pointer-events-none before:absolute before:inset-0 before:rounded-[calc(var(--radius-lg)-1px)] before:shadow-[0_1px_--theme(--color-black/4%)] dark:before:shadow-[0_-1px_--theme(--color-white/6%)]","duration-100 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95","data-[side=bottom]:slide-in-from-top-2 data-[side=top]:slide-in-from-bottom-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2",o),"data-slot":"combobox-popup",...b,children:e})})})}function L({className:o,children:e,...r}){return t.jsxs(s.Combobox.Item,{className:u.cn("flex justify-between min-h-8 in-data-[side=none]:min-w-[calc(var(--anchor-width)+1.25rem)] cursor-default grid-cols-[1rem_1fr] items-center gap-2 rounded-sm py-1 px-2 text-base outline-none data-disabled:pointer-events-none data-highlighted:bg-accent data-highlighted:text-accent-foreground data-disabled:opacity-64 sm:min-h-7 sm:text-sm [&_svg:not([class*='size-'])]:size-4.5 sm:[&_svg:not([class*='size-'])]:size-4 [&_svg]:pointer-events-none [&_svg]:shrink-0",o),"data-slot":"combobox-item",...r,children:[e,t.jsx(s.Combobox.ItemIndicator,{className:"col-end-1",children:t.jsx("svg",{"aria-hidden":"true",fill:"none",height:"24",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",viewBox:"0 0 24 24",width:"24",xmlns:"http://www.w3.org/2000/svg",children:t.jsx("path",{d:"M5.252 12.7 10.2 18.63 18.748 5.37"})})})]})}function K({className:o,...e}){return t.jsx(s.Combobox.Separator,{className:u.cn("mx-2 my-1 h-px bg-border last:hidden",o),"data-slot":"combobox-separator",...e})}function Y({className:o,...e}){return t.jsx(s.Combobox.Group,{className:u.cn("[[role=group]+&]:mt-1.5",o),"data-slot":"combobox-group",...e})}function Z({className:o,...e}){return t.jsx(s.Combobox.GroupLabel,{className:u.cn("px-2 py-1.5 font-medium text-muted-foreground text-xs",o),"data-slot":"combobox-group-label",...e})}function E({className:o,...e}){return t.jsx(s.Combobox.Empty,{className:u.cn("not-empty:p-2 text-center text-base text-muted-foreground sm:text-sm",o),"data-slot":"combobox-empty",...e})}function oo({className:o,...e}){return t.jsx(s.Combobox.Row,{className:o,"data-slot":"combobox-row",...e})}function O({...o}){return t.jsx(s.Combobox.Value,{"data-slot":"combobox-value",...o})}function q({className:o,...e}){return t.jsx(U.ScrollArea,{scrollbarGutter:!0,scrollFade:!0,children:t.jsx(s.Combobox.List,{className:u.cn("not-empty:scroll-py-1 not-empty:px-1 not-empty:py-1 in-data-has-overflow-y:pe-3",o),"data-slot":"combobox-list",...e})})}function G({className:o,...e}){return t.jsx(s.Combobox.Clear,{className:o,"data-slot":"combobox-clear",...e})}const I="absolute end-0.5 top-1/2 inline-flex size-8 shrink-0 -translate-y-1/2 cursor-pointer items-center justify-center rounded-md border border-transparent opacity-80 outline-none transition-opacity pointer-coarse:after:absolute pointer-coarse:after:min-h-11 pointer-coarse:after:min-w-11 hover:opacity-100 sm:size-7 [&_svg:not([class*='size-'])]:size-4.5 sm:[&_svg:not([class*='size-'])]:size-4 [&_svg]:pointer-events-none [&_svg]:shrink-0";function N({showTrigger:o=!0,showClear:e=!1,triggerProps:r,clearProps:n}){return!o&&!e?null:t.jsxs("div",{className:"text-muted-foreground hover:text-foreground transition-colors",children:[o&&t.jsx(T,{className:u.cn(I,"text-muted-foreground has-[+[data-slot=combobox-clear]]:hidden"),...r,children:t.jsx(s.Combobox.Icon,{"data-slot":"combobox-icon",children:t.jsx(C.ChevronsUpDownIcon,{})})}),e&&t.jsx(G,{className:I,...n,children:t.jsx(C.XIcon,{})})]})}function eo({className:o,...e}){return t.jsx(s.Combobox.Status,{className:u.cn("px-3 py-2 font-medium text-muted-foreground text-xs empty:m-0 empty:p-0",o),"data-slot":"combobox-status",...e})}function to(o){return t.jsx(s.Combobox.Collection,{"data-slot":"combobox-collection",...o})}function F({className:o,children:e,startAddon:r,...n}){const{chipsRef:a}=x.useContext(h),i=B.useIsInsideFieldRoot(),l=c=>t.jsxs(s.Combobox.Chips,{"aria-invalid":c,className:u.cn(_.inputBaseClasses,"relative inline-flex pr-6 w-full flex-wrap gap-1","placeholder:text-muted-foreground","focus-within:border-ring","aria-invalid:border-error focus-within:aria-invalid:ring-error/20","has-disabled:cursor-not-allowed has-disabled:opacity-50",o),"data-slot":"combobox-chips",ref:a,...n,children:[r&&t.jsx("div",{"aria-hidden":"true",className:"flex shrink-0 items-center ps-2 opacity-80 has-[+[data-slot=combobox-chip]]:pe-2 [&_svg:not([class*='size-'])]:size-4.5 sm:[&_svg:not([class*='size-'])]:size-4 [&_svg]:pointer-events-none [&_svg]:-ms-0.5 [&_svg]:-me-1.5","data-slot":"combobox-start-addon",children:r}),e]});return i?t.jsx(A.Field.Validity,{children:({validity:c})=>l(c.valid===!1?!0:void 0)}):l(void 0)}function V({children:o,removeProps:e,...r}){return t.jsxs(s.Combobox.Chip,{className:"flex my-auto items-center pl-1 rounded-[calc(var(--radius-md)-1px)] bg-accent font-medium text-accent-foreground text-sm outline-none sm:text-xs/(--text-xs--line-height) [&_svg:not([class*='size-'])]:size-4 sm:[&_svg:not([class*='size-'])]:size-3.5 h-6","data-slot":"combobox-chip",...r,children:[o,t.jsx(D,{...e})]})}function D(o){return t.jsx(s.Combobox.ChipRemove,{"aria-label":"Quitar",className:"h-full shrink-0 cursor-pointer px-1 opacity-80 hover:opacity-100 [&_svg:not([class*='size-'])]:size-4 sm:[&_svg:not([class*='size-'])]:size-3.5","data-slot":"combobox-chip-remove",...o,children:t.jsx(C.XIcon,{})})}const y=4,ro=24,so=36,no=68;function w(o,e){const r=o-ro-so;let n=0,a=0;for(let i=0;i<e.length;i++){const l=e[i],c=i<e.length-1;if(n+(i>0?y:0)+l+(c?y+no:0)>r)break;n+=(i>0?y:0)+l,a++}return a}function io(o,e){const[r,n]=x.useState(null),a=x.useRef([]),i=r===null||r.items!==o;return X.useIsomorphicLayoutEffect(()=>{if(!i)return;const l=e?.current;if(!l)return;const c=l.querySelectorAll('[data-slot="combobox-chip"]');a.current=Array.from(c).map(d=>d.offsetWidth);const b=w(l.clientWidth,a.current);n({items:o,visible:b})},[i,o,e]),x.useEffect(()=>{const l=a.current.length>0&&a.current.every(m=>m===0);if(!i&&!l)return;const c=e?.current;if(!c)return;const b=c.querySelectorAll('[data-slot="combobox-chip"]');if(!b.length)return;const d=Array.from(b).map(m=>m.offsetWidth);if(d.every(m=>m===0))return;a.current=d;const f=w(c.clientWidth,d);n(m=>m?{...m,visible:f}:{items:o,visible:f})},[i,o,e]),x.useEffect(()=>{const l=e?.current;if(!l)return;const c=new ResizeObserver(()=>{if(!a.current.length)return;const b=w(l.clientWidth,a.current);n(d=>d?{...d,visible:b}:null)});return c.observe(l),()=>c.disconnect()},[e]),{visibleCount:r?.visible??o,isMeasuring:i}}function ao({value:o,getLabel:e,getId:r}){const{chipsRef:n}=x.useContext(h),{visibleCount:a,isMeasuring:i}=io(o.length,n),l=i?o:o.slice(0,a),c=i?0:o.length-a;return t.jsxs(t.Fragment,{children:[l.map(b=>t.jsx(V,{"aria-label":e(b),children:e(b)},r(b))),c>0&&t.jsxs("span",{className:"flex items-center whitespace-nowrap px-1 text-sm text-muted-foreground",children:["+",c," más"]})]})}function lo(o){if(o==null)return"";if(typeof o=="string"||typeof o=="number")return String(o);if(typeof o=="object"){const e=o;if("label"in e)return String(e.label);if("name"in e)return String(e.name);if("title"in e)return String(e.title)}return String(o)}function co(o){if(o==null)return"";if(typeof o=="string"||typeof o=="number")return String(o);if(typeof o=="object"){const e=o;if("id"in e)return String(e.id);if("value"in e)return String(e.value)}return String(o)}function bo({placeholder:o,showClear:e,startAddon:r,className:n}){return t.jsx(P,{className:n,placeholder:o,showClear:e,startAddon:r})}function uo({getLabel:o,getId:e,showClear:r,startAddon:n,className:a}){return t.jsxs(F,{className:a,startAddon:n,children:[t.jsx(O,{children:i=>t.jsx(ao,{value:i,getLabel:o,getId:e})}),t.jsx(N,{showTrigger:!r,showClear:r})]})}function mo(o){const{items:e,getLabel:r,getId:n,renderItem:a,placeholder:i,emptyText:l="Sin resultados.",multiple:c,onValueChange:b,value:d,defaultValue:f,startAddon:m,classNames:p,showClear:z=!0,searchable:M=!0,...W}=o,v=r??lo,j=n??co;return t.jsxs(S,{items:e,itemToStringLabel:v,itemToStringValue:j,multiple:c,onValueChange:b,value:d,defaultValue:f,autoHighlight:!0,loopFocus:!0,...W,children:[c?t.jsx(uo,{getLabel:v,getId:j,showClear:z,startAddon:m,className:p?.chips}):t.jsx(bo,{placeholder:i,showClear:z,startAddon:m,className:p?.input}),t.jsxs(k,{className:p?.popup,children:[c&&M&&t.jsx("div",{className:"border-b p-2","data-slot":"combobox-chips-input-wrapper",children:t.jsx(R,{className:p?.chipsInput,placeholder:i})}),t.jsx(E,{className:p?.empty,children:l}),t.jsx(q,{className:p?.list,children:g=>t.jsx(L,{value:g,className:p?.item,children:a?a(g):v(g)},j(g))})]})]})}const xo=s.Combobox.useFilter;Object.defineProperty(exports,"ComboboxPrimitive",{enumerable:!0,get:()=>s.Combobox});exports.Combobox=mo;exports.ComboboxChip=V;exports.ComboboxChipRemove=D;exports.ComboboxChips=F;exports.ComboboxChipsInput=R;exports.ComboboxClear=G;exports.ComboboxCollection=to;exports.ComboboxContext=h;exports.ComboboxEmpty=E;exports.ComboboxGroup=Y;exports.ComboboxGroupLabel=Z;exports.ComboboxInput=P;exports.ComboboxItem=L;exports.ComboboxList=q;exports.ComboboxPopup=k;exports.ComboboxRoot=S;exports.ComboboxRow=oo;exports.ComboboxSearchInput=J;exports.ComboboxSelectTrigger=$;exports.ComboboxSeparator=K;exports.ComboboxStatus=eo;exports.ComboboxTrigger=T;exports.ComboboxValue=O;exports.useComboboxFilter=xo;
|
|
@@ -1,33 +1,33 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsx as t, jsxs as
|
|
2
|
+
import { jsx as t, jsxs as b, Fragment as S } from "react/jsx-runtime";
|
|
3
3
|
import { Combobox as n } from "@base-ui/react/combobox";
|
|
4
|
-
import { Combobox as
|
|
5
|
-
import { Field as
|
|
6
|
-
import { ChevronsUpDownIcon as
|
|
7
|
-
import * as
|
|
8
|
-
import { Input as
|
|
4
|
+
import { Combobox as Se } from "@base-ui/react/combobox";
|
|
5
|
+
import { Field as P } from "@base-ui/react/field";
|
|
6
|
+
import { ChevronsUpDownIcon as k, XIcon as R } from "lucide-react";
|
|
7
|
+
import * as f from "react";
|
|
8
|
+
import { Input as E, inputBaseClasses as j } from "../input/input.es.js";
|
|
9
9
|
import { useIsInsideFieldRoot as G } from "../field/field.es.js";
|
|
10
10
|
import { useIsomorphicLayoutEffect as V } from "../../hooks/internal/use-isomorphic-layout-effect.es.js";
|
|
11
|
-
import { cn as
|
|
12
|
-
import { ScrollArea as
|
|
13
|
-
const
|
|
11
|
+
import { cn as u } from "../../lib/cn.es.js";
|
|
12
|
+
import { ScrollArea as F } from "../scroll-area/scroll-area.es.js";
|
|
13
|
+
const v = f.createContext({
|
|
14
14
|
chipsRef: null,
|
|
15
15
|
multiple: !1
|
|
16
16
|
});
|
|
17
|
-
function
|
|
17
|
+
function W({
|
|
18
18
|
...e
|
|
19
19
|
}) {
|
|
20
|
-
const o =
|
|
21
|
-
return /* @__PURE__ */ t(
|
|
20
|
+
const o = f.useRef(null);
|
|
21
|
+
return /* @__PURE__ */ t(v.Provider, { value: { chipsRef: o, multiple: !!e.multiple }, children: /* @__PURE__ */ t(n.Root, { ...e }) });
|
|
22
22
|
}
|
|
23
|
-
function
|
|
23
|
+
function A({
|
|
24
24
|
className: e,
|
|
25
25
|
...o
|
|
26
26
|
}) {
|
|
27
27
|
return /* @__PURE__ */ t(
|
|
28
28
|
n.Input,
|
|
29
29
|
{
|
|
30
|
-
className:
|
|
30
|
+
className: u(
|
|
31
31
|
"min-w-12 flex-1 text-base outline-none placeholder:text-muted-foreground sm:text-sm [[data-slot=combobox-chip]+&]:ps-0.5",
|
|
32
32
|
e
|
|
33
33
|
),
|
|
@@ -36,7 +36,7 @@ function W({
|
|
|
36
36
|
}
|
|
37
37
|
);
|
|
38
38
|
}
|
|
39
|
-
function
|
|
39
|
+
function M({
|
|
40
40
|
className: e,
|
|
41
41
|
showTrigger: o = !0,
|
|
42
42
|
showClear: r = !1,
|
|
@@ -45,7 +45,7 @@ function D({
|
|
|
45
45
|
clearProps: s,
|
|
46
46
|
...l
|
|
47
47
|
}) {
|
|
48
|
-
return /* @__PURE__ */
|
|
48
|
+
return /* @__PURE__ */ b(
|
|
49
49
|
n.InputGroup,
|
|
50
50
|
{
|
|
51
51
|
className: "relative not-has-[>*.w-full]:w-fit w-full text-foreground has-disabled:opacity-64",
|
|
@@ -63,18 +63,18 @@ function D({
|
|
|
63
63
|
/* @__PURE__ */ t(
|
|
64
64
|
n.Input,
|
|
65
65
|
{
|
|
66
|
-
className:
|
|
66
|
+
className: u(
|
|
67
67
|
i && "*:data-[slot=combobox-input]:ps-[calc(--spacing(8.5)-1px)] sm:*:data-[slot=combobox-input]:ps-[calc(--spacing(8)-1px)]",
|
|
68
68
|
"pr-6",
|
|
69
69
|
e
|
|
70
70
|
),
|
|
71
71
|
"data-slot": "combobox-input",
|
|
72
|
-
render: (c) => /* @__PURE__ */ t(
|
|
72
|
+
render: (c) => /* @__PURE__ */ t(E, { className: "has-disabled:opacity-100", nativeInput: !0, ...c }),
|
|
73
73
|
...l
|
|
74
74
|
}
|
|
75
75
|
),
|
|
76
76
|
/* @__PURE__ */ t(
|
|
77
|
-
|
|
77
|
+
z,
|
|
78
78
|
{
|
|
79
79
|
showTrigger: o,
|
|
80
80
|
showClear: r,
|
|
@@ -86,7 +86,7 @@ function D({
|
|
|
86
86
|
}
|
|
87
87
|
);
|
|
88
88
|
}
|
|
89
|
-
function
|
|
89
|
+
function D({
|
|
90
90
|
className: e,
|
|
91
91
|
children: o,
|
|
92
92
|
...r
|
|
@@ -101,7 +101,7 @@ function M({
|
|
|
101
101
|
}
|
|
102
102
|
);
|
|
103
103
|
}
|
|
104
|
-
function
|
|
104
|
+
function fe({
|
|
105
105
|
className: e,
|
|
106
106
|
placeholder: o,
|
|
107
107
|
children: r,
|
|
@@ -112,7 +112,7 @@ function pe({
|
|
|
112
112
|
const l = /* @__PURE__ */ t(
|
|
113
113
|
n.Trigger,
|
|
114
114
|
{
|
|
115
|
-
className:
|
|
115
|
+
className: u(
|
|
116
116
|
"relative flex w-full items-center rounded-md border border-input bg-background px-3 py-2 pe-9 text-sm outline-none transition-shadow",
|
|
117
117
|
"focus-visible:border-ring",
|
|
118
118
|
"aria-invalid:border-error focus-visible:aria-invalid:ring-error/20",
|
|
@@ -125,20 +125,20 @@ function pe({
|
|
|
125
125
|
children: r ?? /* @__PURE__ */ t(n.Value, { placeholder: o })
|
|
126
126
|
}
|
|
127
127
|
);
|
|
128
|
-
return i ? /* @__PURE__ */
|
|
128
|
+
return i ? /* @__PURE__ */ b(
|
|
129
129
|
"div",
|
|
130
130
|
{
|
|
131
131
|
className: "relative w-full text-foreground has-disabled:opacity-64",
|
|
132
132
|
"data-slot": "combobox-select-trigger-group",
|
|
133
133
|
children: [
|
|
134
134
|
l,
|
|
135
|
-
/* @__PURE__ */ t(
|
|
135
|
+
/* @__PURE__ */ t(z, { showTrigger: !0, showClear: !0, clearProps: a })
|
|
136
136
|
]
|
|
137
137
|
}
|
|
138
138
|
) : /* @__PURE__ */ t(
|
|
139
139
|
n.Trigger,
|
|
140
140
|
{
|
|
141
|
-
className:
|
|
141
|
+
className: u(
|
|
142
142
|
"relative flex w-full items-center rounded-md border border-input bg-background px-3 py-2 pe-9 text-sm outline-none transition-shadow",
|
|
143
143
|
"focus-visible:border-ring",
|
|
144
144
|
"aria-invalid:border-error focus-visible:aria-invalid:ring-error/20",
|
|
@@ -148,28 +148,28 @@ function pe({
|
|
|
148
148
|
),
|
|
149
149
|
"data-slot": "combobox-select-trigger",
|
|
150
150
|
...s,
|
|
151
|
-
children: r ?? /* @__PURE__ */
|
|
151
|
+
children: r ?? /* @__PURE__ */ b(S, { children: [
|
|
152
152
|
/* @__PURE__ */ t(n.Value, { placeholder: o }),
|
|
153
153
|
/* @__PURE__ */ t(
|
|
154
154
|
"div",
|
|
155
155
|
{
|
|
156
156
|
"aria-hidden": "true",
|
|
157
157
|
className: "pointer-events-none absolute end-0.5 top-1/2 inline-flex size-8 -translate-y-1/2 items-center justify-center text-muted-foreground opacity-80 sm:size-7 [&_svg:not([class*='size-'])]:size-4.5 sm:[&_svg:not([class*='size-'])]:size-4",
|
|
158
|
-
children: /* @__PURE__ */ t(
|
|
158
|
+
children: /* @__PURE__ */ t(k, {})
|
|
159
159
|
}
|
|
160
160
|
)
|
|
161
161
|
] })
|
|
162
162
|
}
|
|
163
163
|
);
|
|
164
164
|
}
|
|
165
|
-
function
|
|
165
|
+
function he({
|
|
166
166
|
className: e,
|
|
167
167
|
...o
|
|
168
168
|
}) {
|
|
169
169
|
return /* @__PURE__ */ t("div", { className: "border-b p-2", "data-slot": "combobox-search-input-wrapper", children: /* @__PURE__ */ t(
|
|
170
170
|
n.Input,
|
|
171
171
|
{
|
|
172
|
-
className:
|
|
172
|
+
className: u(
|
|
173
173
|
"flex h-9 w-full rounded-md bg-transparent text-base placeholder:text-muted-foreground outline-none disabled:cursor-not-allowed disabled:opacity-64 sm:h-8 sm:text-sm",
|
|
174
174
|
e
|
|
175
175
|
),
|
|
@@ -188,15 +188,15 @@ function O({
|
|
|
188
188
|
align: s = "start",
|
|
189
189
|
anchor: l,
|
|
190
190
|
portalProps: c,
|
|
191
|
-
...
|
|
191
|
+
...d
|
|
192
192
|
}) {
|
|
193
|
-
const { chipsRef:
|
|
193
|
+
const { chipsRef: m } = f.useContext(v), x = l ?? m;
|
|
194
194
|
return /* @__PURE__ */ t(n.Portal, { ...c, children: /* @__PURE__ */ t(
|
|
195
195
|
n.Positioner,
|
|
196
196
|
{
|
|
197
197
|
align: s,
|
|
198
198
|
alignOffset: a,
|
|
199
|
-
anchor:
|
|
199
|
+
anchor: x,
|
|
200
200
|
className: "z-50 select-none",
|
|
201
201
|
"data-slot": "combobox-positioner",
|
|
202
202
|
side: r,
|
|
@@ -204,7 +204,7 @@ function O({
|
|
|
204
204
|
children: /* @__PURE__ */ t(
|
|
205
205
|
n.Popup,
|
|
206
206
|
{
|
|
207
|
-
className:
|
|
207
|
+
className: u(
|
|
208
208
|
"relative flex max-h-[min(var(--available-height),23rem)] min-w-(--anchor-width) max-w-(--available-width) origin-(--transform-origin) flex-1 flex-col rounded-lg border bg-popover not-dark:bg-clip-padding text-foreground shadow-lg/5",
|
|
209
209
|
"before:pointer-events-none before:absolute before:inset-0 before:rounded-[calc(var(--radius-lg)-1px)] before:shadow-[0_1px_--theme(--color-black/4%)] dark:before:shadow-[0_-1px_--theme(--color-white/6%)]",
|
|
210
210
|
"duration-100 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95",
|
|
@@ -212,22 +212,22 @@ function O({
|
|
|
212
212
|
e
|
|
213
213
|
),
|
|
214
214
|
"data-slot": "combobox-popup",
|
|
215
|
-
...
|
|
215
|
+
...d,
|
|
216
216
|
children: o
|
|
217
217
|
}
|
|
218
218
|
)
|
|
219
219
|
}
|
|
220
220
|
) });
|
|
221
221
|
}
|
|
222
|
-
function
|
|
222
|
+
function H({
|
|
223
223
|
className: e,
|
|
224
224
|
children: o,
|
|
225
225
|
...r
|
|
226
226
|
}) {
|
|
227
|
-
return /* @__PURE__ */
|
|
227
|
+
return /* @__PURE__ */ b(
|
|
228
228
|
n.Item,
|
|
229
229
|
{
|
|
230
|
-
className:
|
|
230
|
+
className: u(
|
|
231
231
|
"flex justify-between min-h-8 in-data-[side=none]:min-w-[calc(var(--anchor-width)+1.25rem)] cursor-default grid-cols-[1rem_1fr] items-center gap-2 rounded-sm py-1 px-2 text-base outline-none data-disabled:pointer-events-none data-highlighted:bg-accent data-highlighted:text-accent-foreground data-disabled:opacity-64 sm:min-h-7 sm:text-sm [&_svg:not([class*='size-'])]:size-4.5 sm:[&_svg:not([class*='size-'])]:size-4 [&_svg]:pointer-events-none [&_svg]:shrink-0",
|
|
232
232
|
e
|
|
233
233
|
),
|
|
@@ -262,33 +262,33 @@ function xe({
|
|
|
262
262
|
return /* @__PURE__ */ t(
|
|
263
263
|
n.Separator,
|
|
264
264
|
{
|
|
265
|
-
className:
|
|
265
|
+
className: u("mx-2 my-1 h-px bg-border last:hidden", e),
|
|
266
266
|
"data-slot": "combobox-separator",
|
|
267
267
|
...o
|
|
268
268
|
}
|
|
269
269
|
);
|
|
270
270
|
}
|
|
271
|
-
function
|
|
271
|
+
function ge({
|
|
272
272
|
className: e,
|
|
273
273
|
...o
|
|
274
274
|
}) {
|
|
275
275
|
return /* @__PURE__ */ t(
|
|
276
276
|
n.Group,
|
|
277
277
|
{
|
|
278
|
-
className:
|
|
278
|
+
className: u("[[role=group]+&]:mt-1.5", e),
|
|
279
279
|
"data-slot": "combobox-group",
|
|
280
280
|
...o
|
|
281
281
|
}
|
|
282
282
|
);
|
|
283
283
|
}
|
|
284
|
-
function
|
|
284
|
+
function ve({
|
|
285
285
|
className: e,
|
|
286
286
|
...o
|
|
287
287
|
}) {
|
|
288
288
|
return /* @__PURE__ */ t(
|
|
289
289
|
n.GroupLabel,
|
|
290
290
|
{
|
|
291
|
-
className:
|
|
291
|
+
className: u(
|
|
292
292
|
"px-2 py-1.5 font-medium text-muted-foreground text-xs",
|
|
293
293
|
e
|
|
294
294
|
),
|
|
@@ -297,14 +297,14 @@ function ge({
|
|
|
297
297
|
}
|
|
298
298
|
);
|
|
299
299
|
}
|
|
300
|
-
function
|
|
300
|
+
function B({
|
|
301
301
|
className: e,
|
|
302
302
|
...o
|
|
303
303
|
}) {
|
|
304
304
|
return /* @__PURE__ */ t(
|
|
305
305
|
n.Empty,
|
|
306
306
|
{
|
|
307
|
-
className:
|
|
307
|
+
className: u(
|
|
308
308
|
"not-empty:p-2 text-center text-base text-muted-foreground sm:text-sm",
|
|
309
309
|
e
|
|
310
310
|
),
|
|
@@ -313,7 +313,7 @@ function H({
|
|
|
313
313
|
}
|
|
314
314
|
);
|
|
315
315
|
}
|
|
316
|
-
function
|
|
316
|
+
function Ce({
|
|
317
317
|
className: e,
|
|
318
318
|
...o
|
|
319
319
|
}) {
|
|
@@ -326,7 +326,7 @@ function ve({
|
|
|
326
326
|
}
|
|
327
327
|
);
|
|
328
328
|
}
|
|
329
|
-
function
|
|
329
|
+
function q({
|
|
330
330
|
...e
|
|
331
331
|
}) {
|
|
332
332
|
return /* @__PURE__ */ t(n.Value, { "data-slot": "combobox-value", ...e });
|
|
@@ -335,10 +335,10 @@ function X({
|
|
|
335
335
|
className: e,
|
|
336
336
|
...o
|
|
337
337
|
}) {
|
|
338
|
-
return /* @__PURE__ */ t(
|
|
338
|
+
return /* @__PURE__ */ t(F, { scrollbarGutter: !0, scrollFade: !0, children: /* @__PURE__ */ t(
|
|
339
339
|
n.List,
|
|
340
340
|
{
|
|
341
|
-
className:
|
|
341
|
+
className: u(
|
|
342
342
|
"not-empty:scroll-py-1 not-empty:px-1 not-empty:py-1 in-data-has-overflow-y:pe-3",
|
|
343
343
|
e
|
|
344
344
|
),
|
|
@@ -347,7 +347,7 @@ function X({
|
|
|
347
347
|
}
|
|
348
348
|
) });
|
|
349
349
|
}
|
|
350
|
-
function
|
|
350
|
+
function Q({
|
|
351
351
|
className: e,
|
|
352
352
|
...o
|
|
353
353
|
}) {
|
|
@@ -360,36 +360,36 @@ function q({
|
|
|
360
360
|
}
|
|
361
361
|
);
|
|
362
362
|
}
|
|
363
|
-
const
|
|
364
|
-
function
|
|
363
|
+
const I = "absolute end-0.5 top-1/2 inline-flex size-8 shrink-0 -translate-y-1/2 cursor-pointer items-center justify-center rounded-md border border-transparent opacity-80 outline-none transition-opacity pointer-coarse:after:absolute pointer-coarse:after:min-h-11 pointer-coarse:after:min-w-11 hover:opacity-100 sm:size-7 [&_svg:not([class*='size-'])]:size-4.5 sm:[&_svg:not([class*='size-'])]:size-4 [&_svg]:pointer-events-none [&_svg]:shrink-0";
|
|
364
|
+
function z({
|
|
365
365
|
showTrigger: e = !0,
|
|
366
366
|
showClear: o = !1,
|
|
367
367
|
triggerProps: r,
|
|
368
368
|
clearProps: i
|
|
369
369
|
}) {
|
|
370
|
-
return !e && !o ? null : /* @__PURE__ */
|
|
370
|
+
return !e && !o ? null : /* @__PURE__ */ b("div", { className: "text-muted-foreground hover:text-foreground transition-colors", children: [
|
|
371
371
|
e && /* @__PURE__ */ t(
|
|
372
|
-
|
|
372
|
+
D,
|
|
373
373
|
{
|
|
374
|
-
className:
|
|
375
|
-
|
|
374
|
+
className: u(
|
|
375
|
+
I,
|
|
376
376
|
"text-muted-foreground has-[+[data-slot=combobox-clear]]:hidden"
|
|
377
377
|
),
|
|
378
378
|
...r,
|
|
379
|
-
children: /* @__PURE__ */ t(n.Icon, { "data-slot": "combobox-icon", children: /* @__PURE__ */ t(
|
|
379
|
+
children: /* @__PURE__ */ t(n.Icon, { "data-slot": "combobox-icon", children: /* @__PURE__ */ t(k, {}) })
|
|
380
380
|
}
|
|
381
381
|
),
|
|
382
|
-
o && /* @__PURE__ */ t(
|
|
382
|
+
o && /* @__PURE__ */ t(Q, { className: I, ...i, children: /* @__PURE__ */ t(R, {}) })
|
|
383
383
|
] });
|
|
384
384
|
}
|
|
385
|
-
function
|
|
385
|
+
function ye({
|
|
386
386
|
className: e,
|
|
387
387
|
...o
|
|
388
388
|
}) {
|
|
389
389
|
return /* @__PURE__ */ t(
|
|
390
390
|
n.Status,
|
|
391
391
|
{
|
|
392
|
-
className:
|
|
392
|
+
className: u(
|
|
393
393
|
"px-3 py-2 font-medium text-muted-foreground text-xs empty:m-0 empty:p-0",
|
|
394
394
|
e
|
|
395
395
|
),
|
|
@@ -398,20 +398,20 @@ function Ce({
|
|
|
398
398
|
}
|
|
399
399
|
);
|
|
400
400
|
}
|
|
401
|
-
function
|
|
401
|
+
function we(e) {
|
|
402
402
|
return /* @__PURE__ */ t(n.Collection, { "data-slot": "combobox-collection", ...e });
|
|
403
403
|
}
|
|
404
|
-
function
|
|
404
|
+
function U({
|
|
405
405
|
className: e,
|
|
406
406
|
children: o,
|
|
407
407
|
startAddon: r,
|
|
408
408
|
...i
|
|
409
409
|
}) {
|
|
410
|
-
const { chipsRef: a } =
|
|
410
|
+
const { chipsRef: a } = f.useContext(v), s = G(), l = (c) => /* @__PURE__ */ b(
|
|
411
411
|
n.Chips,
|
|
412
412
|
{
|
|
413
413
|
"aria-invalid": c,
|
|
414
|
-
className:
|
|
414
|
+
className: u(
|
|
415
415
|
j,
|
|
416
416
|
"relative inline-flex pr-6 w-full flex-wrap gap-1",
|
|
417
417
|
"placeholder:text-muted-foreground",
|
|
@@ -437,14 +437,14 @@ function Q({
|
|
|
437
437
|
]
|
|
438
438
|
}
|
|
439
439
|
);
|
|
440
|
-
return s ? /* @__PURE__ */ t(
|
|
440
|
+
return s ? /* @__PURE__ */ t(P.Validity, { children: ({ validity: c }) => l(c.valid === !1 ? !0 : void 0) }) : l(void 0);
|
|
441
441
|
}
|
|
442
|
-
function
|
|
442
|
+
function $({
|
|
443
443
|
children: e,
|
|
444
444
|
removeProps: o,
|
|
445
445
|
...r
|
|
446
446
|
}) {
|
|
447
|
-
return /* @__PURE__ */
|
|
447
|
+
return /* @__PURE__ */ b(
|
|
448
448
|
n.Chip,
|
|
449
449
|
{
|
|
450
450
|
className: "flex my-auto items-center pl-1 rounded-[calc(var(--radius-md)-1px)] bg-accent font-medium text-accent-foreground text-sm outline-none sm:text-xs/(--text-xs--line-height) [&_svg:not([class*='size-'])]:size-4 sm:[&_svg:not([class*='size-'])]:size-3.5 h-6",
|
|
@@ -452,12 +452,12 @@ function U({
|
|
|
452
452
|
...r,
|
|
453
453
|
children: [
|
|
454
454
|
e,
|
|
455
|
-
/* @__PURE__ */ t(
|
|
455
|
+
/* @__PURE__ */ t(J, { ...o })
|
|
456
456
|
]
|
|
457
457
|
}
|
|
458
458
|
);
|
|
459
459
|
}
|
|
460
|
-
function
|
|
460
|
+
function J(e) {
|
|
461
461
|
return /* @__PURE__ */ t(
|
|
462
462
|
n.ChipRemove,
|
|
463
463
|
{
|
|
@@ -465,66 +465,82 @@ function $(e) {
|
|
|
465
465
|
className: "h-full shrink-0 cursor-pointer px-1 opacity-80 hover:opacity-100 [&_svg:not([class*='size-'])]:size-4 sm:[&_svg:not([class*='size-'])]:size-3.5",
|
|
466
466
|
"data-slot": "combobox-chip-remove",
|
|
467
467
|
...e,
|
|
468
|
-
children: /* @__PURE__ */ t(
|
|
468
|
+
children: /* @__PURE__ */ t(R, {})
|
|
469
469
|
}
|
|
470
470
|
);
|
|
471
471
|
}
|
|
472
|
-
const
|
|
473
|
-
function
|
|
474
|
-
const r = e -
|
|
472
|
+
const w = 4, K = 24, Y = 36, Z = 68;
|
|
473
|
+
function N(e, o) {
|
|
474
|
+
const r = e - K - Y;
|
|
475
475
|
let i = 0, a = 0;
|
|
476
476
|
for (let s = 0; s < o.length; s++) {
|
|
477
477
|
const l = o[s], c = s < o.length - 1;
|
|
478
|
-
if (i + (s > 0 ?
|
|
479
|
-
i += (s > 0 ?
|
|
478
|
+
if (i + (s > 0 ? w : 0) + l + (c ? w + Z : 0) > r) break;
|
|
479
|
+
i += (s > 0 ? w : 0) + l, a++;
|
|
480
480
|
}
|
|
481
481
|
return a;
|
|
482
482
|
}
|
|
483
|
-
function
|
|
484
|
-
const [r, i] =
|
|
483
|
+
function ee(e, o) {
|
|
484
|
+
const [r, i] = f.useState(null), a = f.useRef([]), s = r === null || r.items !== e;
|
|
485
485
|
return V(() => {
|
|
486
486
|
if (!s) return;
|
|
487
487
|
const l = o?.current;
|
|
488
488
|
if (!l) return;
|
|
489
489
|
const c = l.querySelectorAll('[data-slot="combobox-chip"]');
|
|
490
490
|
a.current = Array.from(c).map(
|
|
491
|
-
(
|
|
491
|
+
(m) => m.offsetWidth
|
|
492
492
|
);
|
|
493
|
-
const
|
|
493
|
+
const d = N(
|
|
494
494
|
l.clientWidth,
|
|
495
495
|
a.current
|
|
496
496
|
);
|
|
497
|
-
i({ items: e, visible:
|
|
498
|
-
}, [s, e, o]),
|
|
497
|
+
i({ items: e, visible: d });
|
|
498
|
+
}, [s, e, o]), f.useEffect(() => {
|
|
499
|
+
const l = a.current.length > 0 && a.current.every((p) => p === 0);
|
|
500
|
+
if (!s && !l) return;
|
|
501
|
+
const c = o?.current;
|
|
502
|
+
if (!c) return;
|
|
503
|
+
const d = c.querySelectorAll('[data-slot="combobox-chip"]');
|
|
504
|
+
if (!d.length) return;
|
|
505
|
+
const m = Array.from(d).map(
|
|
506
|
+
(p) => p.offsetWidth
|
|
507
|
+
);
|
|
508
|
+
if (m.every((p) => p === 0)) return;
|
|
509
|
+
a.current = m;
|
|
510
|
+
const x = N(c.clientWidth, m);
|
|
511
|
+
i(
|
|
512
|
+
(p) => p ? { ...p, visible: x } : { items: e, visible: x }
|
|
513
|
+
);
|
|
514
|
+
}, [s, e, o]), f.useEffect(() => {
|
|
499
515
|
const l = o?.current;
|
|
500
516
|
if (!l) return;
|
|
501
517
|
const c = new ResizeObserver(() => {
|
|
502
518
|
if (!a.current.length) return;
|
|
503
|
-
const
|
|
519
|
+
const d = N(
|
|
504
520
|
l.clientWidth,
|
|
505
521
|
a.current
|
|
506
522
|
);
|
|
507
|
-
i((
|
|
523
|
+
i((m) => m ? { ...m, visible: d } : null);
|
|
508
524
|
});
|
|
509
525
|
return c.observe(l), () => c.disconnect();
|
|
510
526
|
}, [o]), { visibleCount: r?.visible ?? e, isMeasuring: s };
|
|
511
527
|
}
|
|
512
|
-
function
|
|
528
|
+
function oe({
|
|
513
529
|
value: e,
|
|
514
530
|
getLabel: o,
|
|
515
531
|
getId: r
|
|
516
532
|
}) {
|
|
517
|
-
const { chipsRef: i } =
|
|
518
|
-
return /* @__PURE__ */
|
|
519
|
-
l.map((
|
|
520
|
-
c > 0 && /* @__PURE__ */
|
|
533
|
+
const { chipsRef: i } = f.useContext(v), { visibleCount: a, isMeasuring: s } = ee(e.length, i), l = s ? e : e.slice(0, a), c = s ? 0 : e.length - a;
|
|
534
|
+
return /* @__PURE__ */ b(S, { children: [
|
|
535
|
+
l.map((d) => /* @__PURE__ */ t($, { "aria-label": o(d), children: o(d) }, r(d))),
|
|
536
|
+
c > 0 && /* @__PURE__ */ b("span", { className: "flex items-center whitespace-nowrap px-1 text-sm text-muted-foreground", children: [
|
|
521
537
|
"+",
|
|
522
538
|
c,
|
|
523
539
|
" más"
|
|
524
540
|
] })
|
|
525
541
|
] });
|
|
526
542
|
}
|
|
527
|
-
function
|
|
543
|
+
function te(e) {
|
|
528
544
|
if (e == null) return "";
|
|
529
545
|
if (typeof e == "string" || typeof e == "number") return String(e);
|
|
530
546
|
if (typeof e == "object") {
|
|
@@ -535,7 +551,7 @@ function oe(e) {
|
|
|
535
551
|
}
|
|
536
552
|
return String(e);
|
|
537
553
|
}
|
|
538
|
-
function
|
|
554
|
+
function re(e) {
|
|
539
555
|
if (e == null) return "";
|
|
540
556
|
if (typeof e == "string" || typeof e == "number") return String(e);
|
|
541
557
|
if (typeof e == "object") {
|
|
@@ -545,14 +561,14 @@ function te(e) {
|
|
|
545
561
|
}
|
|
546
562
|
return String(e);
|
|
547
563
|
}
|
|
548
|
-
function
|
|
564
|
+
function ne({
|
|
549
565
|
placeholder: e,
|
|
550
566
|
showClear: o,
|
|
551
567
|
startAddon: r,
|
|
552
568
|
className: i
|
|
553
569
|
}) {
|
|
554
570
|
return /* @__PURE__ */ t(
|
|
555
|
-
|
|
571
|
+
M,
|
|
556
572
|
{
|
|
557
573
|
className: i,
|
|
558
574
|
placeholder: e,
|
|
@@ -561,26 +577,26 @@ function re({
|
|
|
561
577
|
}
|
|
562
578
|
);
|
|
563
579
|
}
|
|
564
|
-
function
|
|
580
|
+
function se({
|
|
565
581
|
getLabel: e,
|
|
566
582
|
getId: o,
|
|
567
583
|
showClear: r,
|
|
568
584
|
startAddon: i,
|
|
569
585
|
className: a
|
|
570
586
|
}) {
|
|
571
|
-
return /* @__PURE__ */
|
|
572
|
-
/* @__PURE__ */ t(
|
|
573
|
-
|
|
587
|
+
return /* @__PURE__ */ b(U, { className: a, startAddon: i, children: [
|
|
588
|
+
/* @__PURE__ */ t(q, { children: (s) => /* @__PURE__ */ t(
|
|
589
|
+
oe,
|
|
574
590
|
{
|
|
575
591
|
value: s,
|
|
576
592
|
getLabel: e,
|
|
577
593
|
getId: o
|
|
578
594
|
}
|
|
579
595
|
) }),
|
|
580
|
-
/* @__PURE__ */ t(
|
|
596
|
+
/* @__PURE__ */ t(z, { showTrigger: !r, showClear: r })
|
|
581
597
|
] });
|
|
582
598
|
}
|
|
583
|
-
function
|
|
599
|
+
function Ne(e) {
|
|
584
600
|
const {
|
|
585
601
|
items: o,
|
|
586
602
|
getLabel: r,
|
|
@@ -589,101 +605,102 @@ function we(e) {
|
|
|
589
605
|
placeholder: s,
|
|
590
606
|
emptyText: l = "Sin resultados.",
|
|
591
607
|
multiple: c,
|
|
592
|
-
onValueChange:
|
|
593
|
-
value:
|
|
594
|
-
defaultValue:
|
|
595
|
-
startAddon:
|
|
596
|
-
classNames:
|
|
597
|
-
showClear:
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
608
|
+
onValueChange: d,
|
|
609
|
+
value: m,
|
|
610
|
+
defaultValue: x,
|
|
611
|
+
startAddon: p,
|
|
612
|
+
classNames: h,
|
|
613
|
+
showClear: _ = !0,
|
|
614
|
+
searchable: T = !0,
|
|
615
|
+
...L
|
|
616
|
+
} = e, C = r ?? te, y = i ?? re;
|
|
617
|
+
return /* @__PURE__ */ b(
|
|
618
|
+
W,
|
|
602
619
|
{
|
|
603
620
|
items: o,
|
|
604
|
-
itemToStringLabel:
|
|
605
|
-
itemToStringValue:
|
|
621
|
+
itemToStringLabel: C,
|
|
622
|
+
itemToStringValue: y,
|
|
606
623
|
multiple: c,
|
|
607
|
-
onValueChange:
|
|
608
|
-
value:
|
|
609
|
-
defaultValue:
|
|
624
|
+
onValueChange: d,
|
|
625
|
+
value: m,
|
|
626
|
+
defaultValue: x,
|
|
610
627
|
autoHighlight: !0,
|
|
611
628
|
loopFocus: !0,
|
|
612
|
-
...
|
|
629
|
+
...L,
|
|
613
630
|
children: [
|
|
614
631
|
c ? /* @__PURE__ */ t(
|
|
615
|
-
|
|
632
|
+
se,
|
|
616
633
|
{
|
|
617
|
-
getLabel:
|
|
618
|
-
getId:
|
|
619
|
-
showClear:
|
|
620
|
-
startAddon:
|
|
621
|
-
className:
|
|
634
|
+
getLabel: C,
|
|
635
|
+
getId: y,
|
|
636
|
+
showClear: _,
|
|
637
|
+
startAddon: p,
|
|
638
|
+
className: h?.chips
|
|
622
639
|
}
|
|
623
640
|
) : /* @__PURE__ */ t(
|
|
624
|
-
|
|
641
|
+
ne,
|
|
625
642
|
{
|
|
626
643
|
placeholder: s,
|
|
627
|
-
showClear:
|
|
628
|
-
startAddon:
|
|
629
|
-
className:
|
|
644
|
+
showClear: _,
|
|
645
|
+
startAddon: p,
|
|
646
|
+
className: h?.input
|
|
630
647
|
}
|
|
631
648
|
),
|
|
632
|
-
/* @__PURE__ */
|
|
633
|
-
c && /* @__PURE__ */ t(
|
|
649
|
+
/* @__PURE__ */ b(O, { className: h?.popup, children: [
|
|
650
|
+
c && T && /* @__PURE__ */ t(
|
|
634
651
|
"div",
|
|
635
652
|
{
|
|
636
653
|
className: "border-b p-2",
|
|
637
654
|
"data-slot": "combobox-chips-input-wrapper",
|
|
638
655
|
children: /* @__PURE__ */ t(
|
|
639
|
-
|
|
656
|
+
A,
|
|
640
657
|
{
|
|
641
|
-
className:
|
|
658
|
+
className: h?.chipsInput,
|
|
642
659
|
placeholder: s
|
|
643
660
|
}
|
|
644
661
|
)
|
|
645
662
|
}
|
|
646
663
|
),
|
|
647
|
-
/* @__PURE__ */ t(
|
|
648
|
-
/* @__PURE__ */ t(X, { className:
|
|
649
|
-
|
|
664
|
+
/* @__PURE__ */ t(B, { className: h?.empty, children: l }),
|
|
665
|
+
/* @__PURE__ */ t(X, { className: h?.list, children: (g) => /* @__PURE__ */ t(
|
|
666
|
+
H,
|
|
650
667
|
{
|
|
651
|
-
value:
|
|
652
|
-
className:
|
|
653
|
-
children: a ? a(
|
|
668
|
+
value: g,
|
|
669
|
+
className: h?.item,
|
|
670
|
+
children: a ? a(g) : C(g)
|
|
654
671
|
},
|
|
655
|
-
|
|
672
|
+
y(g)
|
|
656
673
|
) })
|
|
657
674
|
] })
|
|
658
675
|
]
|
|
659
676
|
}
|
|
660
677
|
);
|
|
661
678
|
}
|
|
662
|
-
const
|
|
679
|
+
const ze = n.useFilter;
|
|
663
680
|
export {
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
681
|
+
Ne as Combobox,
|
|
682
|
+
$ as ComboboxChip,
|
|
683
|
+
J as ComboboxChipRemove,
|
|
684
|
+
U as ComboboxChips,
|
|
685
|
+
A as ComboboxChipsInput,
|
|
686
|
+
Q as ComboboxClear,
|
|
687
|
+
we as ComboboxCollection,
|
|
688
|
+
v as ComboboxContext,
|
|
689
|
+
B as ComboboxEmpty,
|
|
690
|
+
ge as ComboboxGroup,
|
|
691
|
+
ve as ComboboxGroupLabel,
|
|
692
|
+
M as ComboboxInput,
|
|
693
|
+
H as ComboboxItem,
|
|
677
694
|
X as ComboboxList,
|
|
678
695
|
O as ComboboxPopup,
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
696
|
+
Se as ComboboxPrimitive,
|
|
697
|
+
W as ComboboxRoot,
|
|
698
|
+
Ce as ComboboxRow,
|
|
699
|
+
he as ComboboxSearchInput,
|
|
700
|
+
fe as ComboboxSelectTrigger,
|
|
684
701
|
xe as ComboboxSeparator,
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
702
|
+
ye as ComboboxStatus,
|
|
703
|
+
D as ComboboxTrigger,
|
|
704
|
+
q as ComboboxValue,
|
|
705
|
+
ze as useComboboxFilter
|
|
689
706
|
};
|
|
@@ -63,6 +63,8 @@ type ComboboxBaseProps<TItem = unknown> = Omit<ComboboxPrimitive.Root.Props<TIte
|
|
|
63
63
|
/** Icon or element displayed before the input text (single mode) or chips (multiple mode). */
|
|
64
64
|
startAddon?: React.ReactNode;
|
|
65
65
|
showClear?: boolean;
|
|
66
|
+
/** When false, hides the search input inside the popup in multiple-select mode. Default true. */
|
|
67
|
+
searchable?: boolean;
|
|
66
68
|
/** Styles applied to each internal slot. */
|
|
67
69
|
classNames?: {
|
|
68
70
|
/** Text input field in single-select mode. */
|
package/package.json
CHANGED
|
@@ -133,6 +133,36 @@ export const Multiple: Story = {
|
|
|
133
133
|
),
|
|
134
134
|
};
|
|
135
135
|
|
|
136
|
+
/**
|
|
137
|
+
* Chips overflow into "+N more" when selections exceed the container width.
|
|
138
|
+
* Resize the container to see the overflow recalculate.
|
|
139
|
+
*/
|
|
140
|
+
export const MultiplePreselected: Story = {
|
|
141
|
+
render: () => (
|
|
142
|
+
<Combobox<Item>
|
|
143
|
+
items={items}
|
|
144
|
+
multiple
|
|
145
|
+
defaultValue={items.slice(0, 7)}
|
|
146
|
+
placeholder="Select fruits…"
|
|
147
|
+
/>
|
|
148
|
+
),
|
|
149
|
+
};
|
|
150
|
+
|
|
151
|
+
/**
|
|
152
|
+
* `searchable={false}` hides the search input inside the popup. Use this when
|
|
153
|
+
* the list is short enough that filtering adds no value.
|
|
154
|
+
*/
|
|
155
|
+
export const MultipleWithoutSearch: Story = {
|
|
156
|
+
render: () => (
|
|
157
|
+
<Combobox<Item>
|
|
158
|
+
items={items.slice(0, 5)}
|
|
159
|
+
multiple
|
|
160
|
+
searchable={false}
|
|
161
|
+
placeholder="Select fruits…"
|
|
162
|
+
/>
|
|
163
|
+
),
|
|
164
|
+
};
|
|
165
|
+
|
|
136
166
|
interface TechItem {
|
|
137
167
|
label: string;
|
|
138
168
|
value: string;
|
|
@@ -621,6 +621,34 @@ function useChipOverflow(
|
|
|
621
621
|
setStableCount({ items: itemCount, visible });
|
|
622
622
|
}, [isMeasuring, itemCount, containerRef]);
|
|
623
623
|
|
|
624
|
+
// Fallback: fires after browser paint. Handles two failure modes of the layout effect:
|
|
625
|
+
// 1. container null on first commit (Base UI CompositeList chip registration races our effect)
|
|
626
|
+
// 2. chips measured with offsetWidth=0 before the browser has done a layout pass
|
|
627
|
+
React.useEffect(() => {
|
|
628
|
+
const hasBadMeasurement =
|
|
629
|
+
chipWidthsRef.current.length > 0 &&
|
|
630
|
+
chipWidthsRef.current.every((w) => w === 0);
|
|
631
|
+
|
|
632
|
+
if (!isMeasuring && !hasBadMeasurement) return;
|
|
633
|
+
|
|
634
|
+
const container = containerRef?.current as HTMLElement | null;
|
|
635
|
+
if (!container) return;
|
|
636
|
+
|
|
637
|
+
const chipEls = container.querySelectorAll('[data-slot="combobox-chip"]');
|
|
638
|
+
if (!chipEls.length) return;
|
|
639
|
+
|
|
640
|
+
const widths = Array.from(chipEls).map(
|
|
641
|
+
(el) => (el as HTMLElement).offsetWidth,
|
|
642
|
+
);
|
|
643
|
+
if (widths.every((w) => w === 0)) return;
|
|
644
|
+
|
|
645
|
+
chipWidthsRef.current = widths;
|
|
646
|
+
const visible = calculateChipVisible(container.clientWidth, widths);
|
|
647
|
+
setStableCount((prev) =>
|
|
648
|
+
prev ? { ...prev, visible } : { items: itemCount, visible },
|
|
649
|
+
);
|
|
650
|
+
}, [isMeasuring, itemCount, containerRef]);
|
|
651
|
+
|
|
624
652
|
React.useEffect(() => {
|
|
625
653
|
const container = containerRef?.current as HTMLElement | null;
|
|
626
654
|
if (!container) return;
|
|
@@ -771,6 +799,8 @@ type ComboboxBaseProps<TItem = unknown> = Omit<
|
|
|
771
799
|
/** Icon or element displayed before the input text (single mode) or chips (multiple mode). */
|
|
772
800
|
startAddon?: React.ReactNode;
|
|
773
801
|
showClear?: boolean;
|
|
802
|
+
/** When false, hides the search input inside the popup in multiple-select mode. Default true. */
|
|
803
|
+
searchable?: boolean;
|
|
774
804
|
/** Styles applied to each internal slot. */
|
|
775
805
|
classNames?: {
|
|
776
806
|
/** Text input field in single-select mode. */
|
|
@@ -839,6 +869,7 @@ export function Combobox<TItem = unknown>(
|
|
|
839
869
|
startAddon,
|
|
840
870
|
classNames,
|
|
841
871
|
showClear = true,
|
|
872
|
+
searchable = true,
|
|
842
873
|
...rest
|
|
843
874
|
} = allProps as ComboboxBaseProps<TItem> & {
|
|
844
875
|
multiple?: boolean;
|
|
@@ -880,7 +911,7 @@ export function Combobox<TItem = unknown>(
|
|
|
880
911
|
/>
|
|
881
912
|
)}
|
|
882
913
|
<ComboboxPopup className={classNames?.popup}>
|
|
883
|
-
{multiple && (
|
|
914
|
+
{multiple && searchable && (
|
|
884
915
|
<div
|
|
885
916
|
className="border-b p-2"
|
|
886
917
|
data-slot="combobox-chips-input-wrapper"
|
|
@@ -39,6 +39,34 @@ const meta: Meta<typeof Menu> = {
|
|
|
39
39
|
},
|
|
40
40
|
argTypes: {
|
|
41
41
|
classNames: { control: false },
|
|
42
|
+
items: {
|
|
43
|
+
control: false,
|
|
44
|
+
description: `Array of \`MenuItemType\`. Each entry is a discriminated union on \`type\`:
|
|
45
|
+
|
|
46
|
+
\`\`\`ts
|
|
47
|
+
// Action item
|
|
48
|
+
{ type: "item"; label: ReactNode; shortcut?: string; onClick?: () => void; disabled?: boolean; variant?: "default" | "error" }
|
|
49
|
+
|
|
50
|
+
// Checkbox item
|
|
51
|
+
{ type: "checkbox"; label: ReactNode; checked?: boolean; onCheckedChange?: (checked: boolean) => void; disabled?: boolean }
|
|
52
|
+
|
|
53
|
+
// Radio group — wraps radio items; controlled via value/onValueChange on the group
|
|
54
|
+
{ type: "radio-group"; value?: string; onValueChange?: (value: string) => void; items: RadioItem[] }
|
|
55
|
+
// RadioItem: { type: "radio"; label: ReactNode; value: string; disabled?: boolean }
|
|
56
|
+
|
|
57
|
+
// Group with optional label
|
|
58
|
+
{ type: "group"; label?: ReactNode; items: MenuItemType[] }
|
|
59
|
+
|
|
60
|
+
// Submenu
|
|
61
|
+
{ type: "submenu"; label: ReactNode; items: MenuItemType[] }
|
|
62
|
+
|
|
63
|
+
// Label (non-interactive heading)
|
|
64
|
+
{ type: "label"; label: ReactNode }
|
|
65
|
+
|
|
66
|
+
// Separator
|
|
67
|
+
{ type: "separator" }
|
|
68
|
+
\`\`\``,
|
|
69
|
+
},
|
|
42
70
|
},
|
|
43
71
|
};
|
|
44
72
|
|
|
@@ -50,10 +78,10 @@ export const Default: Story = {
|
|
|
50
78
|
<Menu
|
|
51
79
|
{...args}
|
|
52
80
|
items={[
|
|
53
|
-
{ type: "item", label: "Profile",
|
|
54
|
-
{ type: "item", label: "Settings",
|
|
81
|
+
{ type: "item", label: "Profile", onClick: action("profile") },
|
|
82
|
+
{ type: "item", label: "Settings", onClick: action("settings") },
|
|
55
83
|
{ type: "separator" },
|
|
56
|
-
{ type: "item", label: "Log out",
|
|
84
|
+
{ type: "item", label: "Log out", onClick: action("logout") },
|
|
57
85
|
]}
|
|
58
86
|
/>
|
|
59
87
|
),
|
|
@@ -69,8 +97,8 @@ export const WithClassNames: Story = {
|
|
|
69
97
|
{...args}
|
|
70
98
|
classNames={{ popup: "w-56" }}
|
|
71
99
|
items={[
|
|
72
|
-
{ type: "item", label: "Profile",
|
|
73
|
-
{ type: "item", label: "Settings",
|
|
100
|
+
{ type: "item", label: "Profile", onClick: action("profile") },
|
|
101
|
+
{ type: "item", label: "Settings", onClick: action("settings") },
|
|
74
102
|
]}
|
|
75
103
|
/>
|
|
76
104
|
),
|
|
@@ -88,26 +116,26 @@ export const Shortcuts: Story = {
|
|
|
88
116
|
type: "item",
|
|
89
117
|
label: "New",
|
|
90
118
|
shortcut: "Ctrl+N",
|
|
91
|
-
|
|
119
|
+
onClick: action("new"),
|
|
92
120
|
},
|
|
93
121
|
{
|
|
94
122
|
type: "item",
|
|
95
123
|
label: "Open",
|
|
96
124
|
shortcut: "Ctrl+O",
|
|
97
|
-
|
|
125
|
+
onClick: action("open"),
|
|
98
126
|
},
|
|
99
127
|
{
|
|
100
128
|
type: "item",
|
|
101
129
|
label: "Save",
|
|
102
130
|
shortcut: "Ctrl+S",
|
|
103
|
-
|
|
131
|
+
onClick: action("save"),
|
|
104
132
|
},
|
|
105
133
|
{ type: "separator" },
|
|
106
134
|
{
|
|
107
135
|
type: "item",
|
|
108
136
|
label: "Close",
|
|
109
137
|
shortcut: "Ctrl+W",
|
|
110
|
-
|
|
138
|
+
onClick: action("close"),
|
|
111
139
|
},
|
|
112
140
|
]}
|
|
113
141
|
/>
|
|
@@ -197,19 +225,19 @@ export const Groups: Story = {
|
|
|
197
225
|
type: "item",
|
|
198
226
|
label: "Cut",
|
|
199
227
|
shortcut: "Ctrl+X",
|
|
200
|
-
|
|
228
|
+
onClick: action("cut"),
|
|
201
229
|
},
|
|
202
230
|
{
|
|
203
231
|
type: "item",
|
|
204
232
|
label: "Copy",
|
|
205
233
|
shortcut: "Ctrl+C",
|
|
206
|
-
|
|
234
|
+
onClick: action("copy"),
|
|
207
235
|
},
|
|
208
236
|
{
|
|
209
237
|
type: "item",
|
|
210
238
|
label: "Paste",
|
|
211
239
|
shortcut: "Ctrl+V",
|
|
212
|
-
|
|
240
|
+
onClick: action("paste"),
|
|
213
241
|
},
|
|
214
242
|
],
|
|
215
243
|
},
|
|
@@ -222,9 +250,9 @@ export const Groups: Story = {
|
|
|
222
250
|
type: "item",
|
|
223
251
|
label: "Select All",
|
|
224
252
|
shortcut: "Ctrl+A",
|
|
225
|
-
|
|
253
|
+
onClick: action("select-all"),
|
|
226
254
|
},
|
|
227
|
-
{ type: "item", label: "Deselect",
|
|
255
|
+
{ type: "item", label: "Deselect", onClick: action("deselect") },
|
|
228
256
|
],
|
|
229
257
|
},
|
|
230
258
|
]}
|
|
@@ -237,14 +265,14 @@ export const Submenu: Story = {
|
|
|
237
265
|
<Menu
|
|
238
266
|
{...args}
|
|
239
267
|
items={[
|
|
240
|
-
{ type: "item", label: "Copy link",
|
|
268
|
+
{ type: "item", label: "Copy link", onClick: action("copy-link") },
|
|
241
269
|
{
|
|
242
270
|
type: "submenu",
|
|
243
271
|
label: "Export as",
|
|
244
272
|
items: [
|
|
245
|
-
{ type: "item", label: "PDF",
|
|
246
|
-
{ type: "item", label: "CSV",
|
|
247
|
-
{ type: "item", label: "JSON",
|
|
273
|
+
{ type: "item", label: "PDF", onClick: action("export-pdf") },
|
|
274
|
+
{ type: "item", label: "CSV", onClick: action("export-csv") },
|
|
275
|
+
{ type: "item", label: "JSON", onClick: action("export-json") },
|
|
248
276
|
],
|
|
249
277
|
},
|
|
250
278
|
]}
|
|
@@ -260,14 +288,14 @@ export const Error: Story = {
|
|
|
260
288
|
<Menu
|
|
261
289
|
{...args}
|
|
262
290
|
items={[
|
|
263
|
-
{ type: "item", label: "Profile",
|
|
264
|
-
{ type: "item", label: "Billing",
|
|
291
|
+
{ type: "item", label: "Profile", onClick: action("profile") },
|
|
292
|
+
{ type: "item", label: "Billing", onClick: action("billing") },
|
|
265
293
|
{ type: "separator" },
|
|
266
294
|
{
|
|
267
295
|
type: "item",
|
|
268
296
|
label: "Delete account",
|
|
269
297
|
variant: "error",
|
|
270
|
-
|
|
298
|
+
onClick: action("delete"),
|
|
271
299
|
},
|
|
272
300
|
]}
|
|
273
301
|
/>
|
|
@@ -283,7 +311,7 @@ export const Error: Story = {
|
|
|
283
311
|
* <MenuPopup>
|
|
284
312
|
* <MenuGroup>
|
|
285
313
|
* <MenuLabel>Section</MenuLabel>
|
|
286
|
-
* <MenuItem
|
|
314
|
+
* <MenuItem onClick={() => {}}>Item</MenuItem>
|
|
287
315
|
* </MenuGroup>
|
|
288
316
|
* </MenuPopup>
|
|
289
317
|
* </MenuRoot>
|
|
@@ -305,25 +333,25 @@ export const Primitive: Story = {
|
|
|
305
333
|
</MenuGroup>
|
|
306
334
|
<MenuSeparator />
|
|
307
335
|
<MenuGroup>
|
|
308
|
-
<MenuItem
|
|
309
|
-
<MenuItem
|
|
310
|
-
<MenuItem
|
|
336
|
+
<MenuItem onClick={action("tasks")}>All Tasks</MenuItem>
|
|
337
|
+
<MenuItem onClick={action("completed")}>Completed</MenuItem>
|
|
338
|
+
<MenuItem onClick={action("upcoming")}>Upcoming</MenuItem>
|
|
311
339
|
</MenuGroup>
|
|
312
340
|
<MenuSeparator />
|
|
313
341
|
<MenuSub>
|
|
314
342
|
<MenuSubTrigger>Categories</MenuSubTrigger>
|
|
315
343
|
<MenuSubContent>
|
|
316
|
-
<MenuItem
|
|
317
|
-
<MenuItem
|
|
318
|
-
<MenuItem
|
|
344
|
+
<MenuItem onClick={action("work")}>Work</MenuItem>
|
|
345
|
+
<MenuItem onClick={action("personal")}>Personal</MenuItem>
|
|
346
|
+
<MenuItem onClick={action("shopping")}>Shopping</MenuItem>
|
|
319
347
|
</MenuSubContent>
|
|
320
348
|
</MenuSub>
|
|
321
349
|
<MenuSeparator />
|
|
322
|
-
<MenuItem
|
|
350
|
+
<MenuItem onClick={action("settings")}>
|
|
323
351
|
Settings
|
|
324
352
|
<MenuShortcut>Ctrl+,</MenuShortcut>
|
|
325
353
|
</MenuItem>
|
|
326
|
-
<MenuItem disabled
|
|
354
|
+
<MenuItem disabled onClick={action("archived")}>
|
|
327
355
|
Archived
|
|
328
356
|
</MenuItem>
|
|
329
357
|
</MenuPopup>
|