@xploreu/components 0.4.14 → 0.4.16
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/chunk-2XZRLJCN.js +2 -0
- package/dist/chunk-2XZRLJCN.js.map +1 -0
- package/dist/{chunk-7WQRDDWL.js → chunk-6AKSAK5F.js} +2 -2
- package/dist/{chunk-7WQRDDWL.js.map → chunk-6AKSAK5F.js.map} +1 -1
- package/dist/chunk-AVJU2H5V.js +2 -0
- package/dist/{chunk-ITR3T6UB.js.map → chunk-AVJU2H5V.js.map} +1 -1
- package/dist/chunk-BTVE2DOC.js +2 -0
- package/dist/chunk-BTVE2DOC.js.map +1 -0
- package/dist/chunk-CPRMLK2G.js +2 -0
- package/dist/chunk-CPRMLK2G.js.map +1 -0
- package/dist/{chunk-ZZWSZRER.js → chunk-EL7P7FN5.js} +2 -2
- package/dist/{chunk-ZZWSZRER.js.map → chunk-EL7P7FN5.js.map} +1 -1
- package/dist/{chunk-WCAQIMAH.js → chunk-FE2732UW.js} +2 -2
- package/dist/{chunk-WCAQIMAH.js.map → chunk-FE2732UW.js.map} +1 -1
- package/dist/{chunk-C3FYXQCF.js → chunk-JILBFCPY.js} +2 -2
- package/dist/{chunk-C3FYXQCF.js.map → chunk-JILBFCPY.js.map} +1 -1
- package/dist/chunk-JLZNZFOO.js +2 -0
- package/dist/chunk-JLZNZFOO.js.map +1 -0
- package/dist/{chunk-DNO5M44I.js → chunk-KYVYO45Y.js} +2 -2
- package/dist/{chunk-DNO5M44I.js.map → chunk-KYVYO45Y.js.map} +1 -1
- package/dist/chunk-PU426AFH.js +2 -0
- package/dist/chunk-PU426AFH.js.map +1 -0
- package/dist/{chunk-KKE76CHJ.js → chunk-R4WEEB5H.js} +2 -2
- package/dist/{chunk-KKE76CHJ.js.map → chunk-R4WEEB5H.js.map} +1 -1
- package/dist/{chunk-MMCL4HWD.js → chunk-RJ2SAHLO.js} +2 -2
- package/dist/{chunk-MMCL4HWD.js.map → chunk-RJ2SAHLO.js.map} +1 -1
- package/dist/{chunk-SFMNEY3D.js → chunk-RVQZK2AK.js} +2 -2
- package/dist/{chunk-SFMNEY3D.js.map → chunk-RVQZK2AK.js.map} +1 -1
- package/dist/{chunk-RCA6JRHN.js → chunk-V2D72N26.js} +2 -2
- package/dist/{chunk-RCA6JRHN.js.map → chunk-V2D72N26.js.map} +1 -1
- package/dist/{chunk-FDXCGFD2.js → chunk-VHXY2BUM.js} +2 -2
- package/dist/{chunk-FDXCGFD2.js.map → chunk-VHXY2BUM.js.map} +1 -1
- package/dist/{chunk-JP737TCG.js → chunk-VNU37GJC.js} +2 -2
- package/dist/{chunk-JP737TCG.js.map → chunk-VNU37GJC.js.map} +1 -1
- package/dist/{chunk-7YSKM6DP.js → chunk-ZWZMXZGN.js} +2 -2
- package/dist/{chunk-7YSKM6DP.js.map → chunk-ZWZMXZGN.js.map} +1 -1
- package/dist/composites/combobox-chip-outside.js +1 -1
- package/dist/composites/combobox-chip.js +1 -1
- package/dist/composites/combobox-simple.js +1 -1
- package/dist/composites/filter-combobox.js +1 -1
- package/dist/composites/index.js +1 -1
- package/dist/composites/phone-input.js +1 -1
- package/dist/composites/profile-avatar.d.ts +1 -1
- package/dist/composites/profile-avatar.js +1 -1
- package/dist/effects/highlight.js +1 -1
- package/dist/effects/index.js +1 -1
- package/dist/primitives/combobox.js +1 -1
- package/dist/primitives/index.js +1 -1
- package/dist/primitives/menu.js +1 -1
- package/dist/primitives/tabs.js +1 -1
- package/dist/ui/badge.d.ts +18 -8
- package/dist/ui/badge.js +1 -1
- package/dist/ui/button.d.ts +1 -1
- package/dist/ui/combobox.js +1 -1
- package/dist/ui/date-multiple-picker.js +1 -1
- package/dist/ui/dialog.d.ts +10 -1
- package/dist/ui/dialog.js +1 -1
- package/dist/ui/index.d.ts +30 -6
- package/dist/ui/index.js +1 -1
- package/dist/ui/menu.js +1 -1
- package/dist/ui/pagination.js +1 -1
- package/dist/ui/tabs.d.ts +1 -1
- package/dist/ui/tabs.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-AGTMOMFO.js +0 -2
- package/dist/chunk-AGTMOMFO.js.map +0 -1
- package/dist/chunk-AKTRVGKT.js +0 -2
- package/dist/chunk-AKTRVGKT.js.map +0 -1
- package/dist/chunk-DZKJRP4J.js +0 -2
- package/dist/chunk-DZKJRP4J.js.map +0 -1
- package/dist/chunk-ITR3T6UB.js +0 -2
- package/dist/chunk-KYD4ATTG.js +0 -2
- package/dist/chunk-KYD4ATTG.js.map +0 -1
- package/dist/chunk-ZP4ZPH65.js +0 -2
- package/dist/chunk-ZP4ZPH65.js.map +0 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {a,j,i,k,l,m,q,s,w,F}from'./chunk-
|
|
2
|
-
//# sourceMappingURL=chunk-
|
|
1
|
+
import {a,j,i,k,l,m,q,s,w,F}from'./chunk-EL7P7FN5.js';import {a as a$1}from'./chunk-JH6RZ3QH.js';import {f,g}from'./chunk-JILBFCPY.js';import*as u from'react';import {cn}from'@xploreu/lib/cn';import {useControlledState}from'@xploreu/hooks/use-controlled-state';import {jsxs,jsx,Fragment}from'react/jsx-runtime';function Z({multiple:z=true,inputPlaceholder:E="Search...",container:G,items:s$1,infiniteScroll:T,isPending:j$1,taggable:c=false,maxVisible:i$1,...m$1}){let[q$1,O]=useControlledState({value:m$1?.inputValue?.toString(),defaultValue:m$1?.defaultInputValue?.toString(),onChange:m$1?.onInputValueChange}),[b,g$1]=useControlledState({value:m$1?.value??[],defaultValue:m$1?.defaultValue??[],onChange:m$1?.onValueChange}),[h,V]=u.useState([]),C=u.useRef(new Set);u.useEffect(()=>{let e=new Set(b.map(n=>n.value));V(n=>{let l=n.filter(o=>e.has(o.value));return l.length===n.length?n:(C.current=new Set(l.map(o=>o.value)),l)});},[b]);let a$2=q$1?.toString().trim()??"",A=u.useMemo(()=>a$2?b.some(e=>e.value.toLowerCase()===a$2.toLowerCase()):false,[a$2,b]),p=u.useMemo(()=>!c||!a$2?false:!s$1?.some(e=>e.label.toLowerCase()===a$2.toLowerCase()),[c,a$2,s$1]),B=u.useMemo(()=>{let e=[...s$1??[],...h];return p?[...e,{label:a$2,value:a$2,tag:true}]:e},[s$1,h,p,a$2]);return jsxs(a,{...m$1,behavior:"chip-outside",multiple:true,items:c?B:s$1,isItemEqualToValue:(e,n)=>e.value===n.value,onValueChange:(e,n)=>{if(c){let l=e.filter(o=>o?.tag===true&&!C.current.has(o.value));if(l.length>0){for(let o of l)C.current.add(o.value);V(o=>[...o,...l]);}}g$1(z?e:[e[e.length-1]],n);},onInputValueChange:O,children:[jsx(f,{className:cn(a$1(),"h-auto min-h-13 flex flex-wrap items-center gap-1.5 px-3 py-1.5 cursor-text"),children:jsxs(j,{className:cn("contents",i$1!==void 0&&"flex-nowrap overflow-hidden"),children:[jsx(i,{children:e=>{let n=i$1!==void 0?e.slice(0,i$1):e,l$1=i$1!==void 0?e.length-i$1:0;return jsxs(Fragment,{children:[n?.map(o=>jsxs(k,{className:cn(i$1!==void 0&&"min-w-0 shrink"),children:[o?.image&&jsx("img",{src:o.image,alt:o?.label||"",className:"size-4 rounded-full object-cover shrink-0 mr-1"}),i$1!==void 0?jsx("span",{className:"truncate",children:o?.label||""}):o?.label||"",jsx(l,{})]},o?.value||"")),l$1>0&&jsxs(k,{className:"shrink-0",children:["+",l$1]})]})}}),jsx(g,{render:jsx("input",{className:"flex-1 min-w-[80px] bg-transparent outline-none text-body-regular-1 text-text-primary placeholder:text-text-placeholder",placeholder:b.length===0?E:void 0})})]})}),jsxs(m,{container:G,children:[jsx(q,{status:j$1||s$1===void 0?"pending":s$1?.length===0&&!p?"empty":null}),jsxs(s,{children:[s$1?.map(e=>jsx(w,{value:e,children:jsxs("div",{className:"flex items-center gap-2 w-full min-w-0",children:[e.image&&jsx("img",{src:e.image,alt:e.label,className:"size-6 rounded-full object-cover shrink-0"}),jsx("span",{className:"truncate",children:e.label})]})},e.value)),p&&jsx(w,{value:{label:a$2,value:a$2,tag:true},children:jsxs("div",{className:"flex items-center gap-1.5 w-full min-w-0",children:[!A&&jsx("span",{className:"text-text-secondary",children:"Create:"}),jsx("span",{className:"font-medium text-text-primary truncate",children:a$2})]})}),jsx(F,{...T})]})]})]})}export{Z as a};//# sourceMappingURL=chunk-FE2732UW.js.map
|
|
2
|
+
//# sourceMappingURL=chunk-FE2732UW.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/composites/combobox-chip.tsx"],"names":["ComboboxChip","multiple","inputPlaceholder","container","items","infiniteScroll","isPending","taggable","maxVisible","props","inputValue","setInputValue","useControlledState","value","setValue","createdItems","setCreatedItems","createdValuesRef","currentValues","v","prev","next","item","trimmedInput","isInputSelected","isCreatingItem","combinedItems","base","jsxs","Combobox","a","b","eventDetails","newTags","tag","jsx","ComboboxInputGroup","cn","inputVariants","ComboboxChips","ComboboxValue","visible","overflow","Fragment","ComboboxChipRemove","ComboboxInput","ComboboxPopup","ComboboxStatus","ComboboxList","ComboboxItem","ComboboxInfiniteScroll"],"mappings":"uTA6CA,SAASA,CAAAA,CAAyF,CAChG,QAAA,CAAAC,EAAW,IAAA,CACX,gBAAA,CAAAC,CAAAA,CAAmB,WAAA,CACnB,SAAA,CAAAC,CAAAA,CACA,KAAA,CAAAC,GAAAA,CACA,eAAAC,CAAAA,CACA,SAAA,CAAAC,GAAAA,CACA,QAAA,CAAAC,CAAAA,CAAW,KAAA,CACX,UAAA,CAAAC,GAAAA,CACA,GAAGC,GACL,CAAA,CAA6B,CAC3B,GAAM,CAACC,GAAAA,CAAYC,CAAa,CAAA,CAAIC,mBAAmB,CACrD,KAAA,CAAOH,GAAAA,EAAO,UAAA,EAAY,QAAA,EAAS,CACnC,YAAA,CAAcA,GAAAA,EAAO,mBAAmB,QAAA,EAAS,CACjD,QAAA,CAAUA,GAAAA,EAAO,kBACnB,CAAC,CAAA,CAEK,CAACI,EAAOC,GAAQ,CAAA,CAAIF,kBAAAA,CAAmB,CAC3C,KAAA,C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AAU,2CAAA,CACZ,CAAA,CAEFa,GAAAA,CAAC,QAAK,SAAA,CAAU,UAAA,CAAY,QAAA,CAAAb,CAAAA,CAAK,KAAA,CAAM,CAAA,CAAA,CACzC,CAAA,CAAA,CAZKA,CAAAA,CAAK,KAaZ,CACD,CAAA,CACAG,CAAAA,EACCU,GAAAA,CAACc,CAAAA,CAAA,CACC,KAAA,CAAO,CAAE,MAAO1B,GAAAA,CAAc,KAAA,CAAOA,GAAAA,CAAc,GAAA,CAAK,IAAK,CAAA,CAE7D,QAAA,CAAAK,IAAAA,CAAC,OAAI,SAAA,CAAU,0CAAA,CACZ,QAAA,CAAA,CAAA,CAACJ,CAAAA,EACAW,GAAAA,CAAC,MAAA,CAAA,CAAK,SAAA,CAAU,qBAAA,CAAsB,mBAAO,CAAA,CAE/CA,GAAAA,CAAC,MAAA,CAAA,CAAK,SAAA,CAAU,wCAAA,CACb,QAAA,CAAAZ,GAAAA,CACH,CAAA,CAAA,CACF,EACF,CAAA,CAEFY,GAAAA,CAACe,CAAAA,CAAA,CAAwB,GAAG7C,CAAAA,CAAgB,CAAA,CAAA,CAC9C,CAAA,CAAA,CACF,GACF,CAEJ","file":"chunk-WCAQIMAH.js","sourcesContent":["import * as React from \"react\"\r\n\r\nimport { cn } from \"@xploreu/lib/cn\"\r\nimport {\r\n ComboboxInput as ComboboxInputPrimitive,\r\n ComboboxInputGroup,\r\n} from \"../primitives/combobox\"\r\nimport {\r\n Combobox,\r\n ComboboxChip as ComboboxChipUI,\r\n ComboboxChipRemove,\r\n ComboboxChips,\r\n ComboboxInfiniteScroll,\r\n ComboboxItem,\r\n ComboboxList,\r\n ComboboxPortal,\r\n ComboboxPopup,\r\n ComboboxStatus,\r\n ComboboxValue,\r\n type ComboboxProps\r\n} from \"../ui/combobox\"\r\nimport { useControlledState } from \"@xploreu/hooks/use-controlled-state\"\r\nimport { inputVariants } from \"../ui/input\"\r\n\r\ntype ComboboxChipProps<Value> = Omit<ComboboxProps<Value, true>, \"multiple\"> & {\r\n multiple?: boolean\r\n inputPlaceholder?: string\r\n container?: React.ComponentProps<typeof ComboboxPortal>[\"container\"]\r\n items: ({ label: string; value: string; image?: string }[]) | undefined\r\n infiniteScroll?: React.ComponentProps<typeof ComboboxInfiniteScroll>\r\n isPending?: boolean\r\n /**\r\n * When true, enables creatable / taggable mode.\r\n * If the typed value has no exact match in the current item list,\r\n * a \"Create \\\"…\\\"\" option is shown at the top of the dropdown.\r\n * Created items are appended to the value with `{ label, value, tag: true }`.\r\n */\r\n taggable?: boolean\r\n /**\r\n * Maximum number of chips to show before collapsing the rest into a \"+N\" chip.\r\n * When undefined, all chips are shown.\r\n */\r\n maxVisible?: number\r\n}\r\n\r\nfunction ComboboxChip<Value extends { label: string; value: string; image?: string; tag?: true }>({\r\n multiple = true,\r\n inputPlaceholder = \"Search...\",\r\n container,\r\n items,\r\n infiniteScroll,\r\n isPending,\r\n taggable = false,\r\n maxVisible,\r\n ...props\r\n}: ComboboxChipProps<Value>) {\r\n const [inputValue, setInputValue] = useControlledState({\r\n value: props?.inputValue?.toString(),\r\n defaultValue: props?.defaultInputValue?.toString(),\r\n onChange: props?.onInputValueChange,\r\n })\r\n\r\n const [value, setValue] = useControlledState({\r\n value: props?.value ?? [],\r\n defaultValue: props?.defaultValue ?? [],\r\n onChange: props?.onValueChange,\r\n })\r\n\r\n // Track items created via taggable mode\r\n // Sync with value to avoid stale tags when controlled value is reset from outside\r\n const [createdItems, setCreatedItems] = React.useState<Value[]>([])\r\n const createdValuesRef = React.useRef<Set<string>>(new Set())\r\n\r\n React.useEffect(() => {\r\n const currentValues = new Set(value.map((v) => v.value))\r\n setCreatedItems((prev) => {\r\n const next = prev.filter((item) => currentValues.has(item.value))\r\n if (next.length === prev.length) return prev\r\n createdValuesRef.current = new Set(next.map((v) => v.value))\r\n return next\r\n })\r\n }, [value])\r\n\r\n const trimmedInput = inputValue?.toString().trim() ?? \"\"\r\n const isInputSelected = React.useMemo(() => {\r\n if (!trimmedInput) return false\r\n return value.some(\r\n (item) => item.value.toLowerCase() === trimmedInput.toLowerCase()\r\n )\r\n }, [trimmedInput, value])\r\n\r\n // true = show the taggable item in dropdown (either as \"Create:\" or as checked item)\r\n const isCreatingItem = React.useMemo(() => {\r\n if (!taggable || !trimmedInput) return false\r\n return !items?.some(\r\n (item) => item.label.toLowerCase() === trimmedInput.toLowerCase()\r\n )\r\n }, [taggable, trimmedInput, items])\r\n\r\n // Merge server items with locally created tags + the \"Create\" placeholder\r\n const combinedItems = React.useMemo(() => {\r\n const base: Value[] = [\r\n ...items ?? [],\r\n ...createdItems,\r\n ]\r\n\r\n if (isCreatingItem) {\r\n return [...base, { label: trimmedInput, value: trimmedInput, tag: true } as unknown as Value]\r\n }\r\n\r\n return base\r\n }, [items, createdItems, isCreatingItem, trimmedInput])\r\n\r\n const handleValueChange: ComboboxProps<Value, true>[\"onValueChange\"] = (value, eventDetails) => {\r\n if (taggable) {\r\n const newTags = value.filter(\r\n (v) => v?.tag === true && !createdValuesRef.current.has(v.value)\r\n )\r\n if (newTags.length > 0) {\r\n for (const tag of newTags) {\r\n createdValuesRef.current.add(tag.value)\r\n }\r\n setCreatedItems((prev) => [...prev, ...newTags])\r\n }\r\n }\r\n\r\n if (!multiple) {\r\n setValue([value[value.length - 1]], eventDetails)\r\n } else {\r\n setValue(value, eventDetails)\r\n }\r\n }\r\n\r\n return (\r\n <Combobox\r\n {...props}\r\n behavior=\"chip-outside\"\r\n multiple\r\n items={taggable ? combinedItems : items}\r\n isItemEqualToValue={(a, b) => a.value === b.value}\r\n onValueChange={handleValueChange}\r\n onInputValueChange={setInputValue}\r\n >\r\n {/* Input box with chips inside */}\r\n <ComboboxInputGroup\r\n className={cn(\r\n inputVariants(),\r\n \"h-auto min-h-13 flex flex-wrap items-center gap-1.5 px-3 py-1.5 cursor-text\"\r\n )}\r\n >\r\n {/* Chips inside the input box */}\r\n <ComboboxChips\r\n className={cn(\r\n \"contents\",\r\n maxVisible !== undefined && \"flex-nowrap overflow-hidden\"\r\n )}\r\n >\r\n <ComboboxValue>\r\n {(value: Value[]) => {\r\n const visible = maxVisible !== undefined ? value.slice(0, maxVisible) : value\r\n const overflow = maxVisible !== undefined ? value.length - maxVisible : 0\r\n return (\r\n <>\r\n {visible?.map((item) => (\r\n <ComboboxChipUI\r\n key={item?.value || \"\"}\r\n className={cn(maxVisible !== undefined && \"min-w-0 shrink\")}\r\n >\r\n {item?.image && (\r\n <img\r\n src={item.image}\r\n alt={item?.label || \"\"}\r\n className=\"size-4 rounded-full object-cover shrink-0 mr-1\"\r\n />\r\n )}\r\n {maxVisible !== undefined\r\n ? <span className=\"truncate\">{item?.label || \"\"}</span>\r\n : (item?.label || \"\")\r\n }\r\n <ComboboxChipRemove />\r\n </ComboboxChipUI>\r\n ))}\r\n {overflow > 0 && (\r\n <ComboboxChipUI className=\"shrink-0\">\r\n +{overflow}\r\n </ComboboxChipUI>\r\n )}\r\n </>\r\n )\r\n }}\r\n </ComboboxValue>\r\n {/* Text input — shrinks to fit remaining space (inside Chips so backspace works) */}\r\n <ComboboxInputPrimitive\r\n render={\r\n <input\r\n className=\"flex-1 min-w-[80px] bg-transparent outline-none text-body-regular-1 text-text-primary placeholder:text-text-placeholder\"\r\n placeholder={value.length === 0 ? inputPlaceholder : undefined}\r\n />\r\n }\r\n />\r\n </ComboboxChips>\r\n </ComboboxInputGroup>\r\n\r\n <ComboboxPopup container={container}>\r\n <ComboboxStatus\r\n status={\r\n isPending || items === undefined\r\n ? \"pending\"\r\n : items?.length === 0 && !isCreatingItem\r\n ? \"empty\"\r\n : null\r\n }\r\n />\r\n <ComboboxList>\r\n {items?.map((item) => (\r\n <ComboboxItem\r\n key={item.value}\r\n value={item as Value}\r\n >\r\n <div className=\"flex items-center gap-2 w-full min-w-0\">\r\n {item.image && (\r\n <img\r\n src={item.image}\r\n alt={item.label}\r\n className=\"size-6 rounded-full object-cover shrink-0\"\r\n />\r\n )}\r\n <span className=\"truncate\">{item.label}</span>\r\n </div>\r\n </ComboboxItem>\r\n ))}\r\n {isCreatingItem && (\r\n <ComboboxItem\r\n value={{ label: trimmedInput, value: trimmedInput, tag: true }}\r\n >\r\n <div className=\"flex items-center gap-1.5 w-full min-w-0\">\r\n {!isInputSelected && (\r\n <span className=\"text-text-secondary\">Create:</span>\r\n )}\r\n <span className=\"font-medium text-text-primary truncate\">\r\n {trimmedInput}\r\n </span>\r\n </div>\r\n </ComboboxItem>\r\n )}\r\n <ComboboxInfiniteScroll {...infiniteScroll} />\r\n </ComboboxList>\r\n </ComboboxPopup>\r\n </Combobox>\r\n )\r\n}\r\n\r\nexport { ComboboxChip }\r\nexport type { ComboboxChipProps }\r\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/composites/combobox-chip.tsx"],"names":["ComboboxChip","multiple","inputPlaceholder","container","items","infiniteScroll","isPending","taggable","maxVisible","props","inputValue","setInputValue","useControlledState","value","setValue","createdItems","setCreatedItems","createdValuesRef","currentValues","v","prev","next","item","trimmedInput","isInputSelected","isCreatingItem","combinedItems","base","jsxs","Combobox","a","b","eventDetails","newTags","tag","jsx","ComboboxInputGroup","cn","inputVariants","ComboboxChips","ComboboxValue","visible","overflow","Fragment","ComboboxChipRemove","ComboboxInput","ComboboxPopup","ComboboxStatus","ComboboxList","ComboboxItem","ComboboxInfiniteScroll"],"mappings":"uTA6CA,SAASA,CAAAA,CAAyF,CAChG,QAAA,CAAAC,EAAW,IAAA,CACX,gBAAA,CAAAC,CAAAA,CAAmB,WAAA,CACnB,SAAA,CAAAC,CAAAA,CACA,KAAA,CAAAC,GAAAA,CACA,eAAAC,CAAAA,CACA,SAAA,CAAAC,GAAAA,CACA,QAAA,CAAAC,CAAAA,CAAW,KAAA,CACX,UAAA,CAAAC,GAAAA,CACA,GAAGC,GACL,CAAA,CAA6B,CAC3B,GAAM,CAACC,GAAAA,CAAYC,CAAa,CAAA,CAAIC,mBAAmB,CACrD,KAAA,CAAOH,GAAAA,EAAO,UAAA,EAAY,QAAA,EAAS,CACnC,YAAA,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wCAAA,CACZ,QAAA,CAAA,CAAAN,CAAAA,CAAK,KAAA,EACJa,GAAAA,CAAC,KAAA,CAAA,CACC,GAAA,CAAKb,EAAK,KAAA,CACV,GAAA,CAAKA,CAAAA,CAAK,KAAA,CACV,SAAA,CAAU,2CAAA,CACZ,CAAA,CAEFa,GAAAA,CAAC,QAAK,SAAA,CAAU,UAAA,CAAY,QAAA,CAAAb,CAAAA,CAAK,KAAA,CAAM,CAAA,CAAA,CACzC,CAAA,CAAA,CAZKA,CAAAA,CAAK,KAaZ,CACD,CAAA,CACAG,CAAAA,EACCU,GAAAA,CAACc,CAAAA,CAAA,CACC,KAAA,CAAO,CAAE,MAAO1B,GAAAA,CAAc,KAAA,CAAOA,GAAAA,CAAc,GAAA,CAAK,IAAK,CAAA,CAE7D,QAAA,CAAAK,IAAAA,CAAC,OAAI,SAAA,CAAU,0CAAA,CACZ,QAAA,CAAA,CAAA,CAACJ,CAAAA,EACAW,GAAAA,CAAC,MAAA,CAAA,CAAK,SAAA,CAAU,qBAAA,CAAsB,mBAAO,CAAA,CAE/CA,GAAAA,CAAC,MAAA,CAAA,CAAK,SAAA,CAAU,wCAAA,CACb,QAAA,CAAAZ,GAAAA,CACH,CAAA,CAAA,CACF,EACF,CAAA,CAEFY,GAAAA,CAACe,CAAAA,CAAA,CAAwB,GAAG7C,CAAAA,CAAgB,CAAA,CAAA,CAC9C,CAAA,CAAA,CACF,GACF,CAEJ","file":"chunk-FE2732UW.js","sourcesContent":["import * as React from \"react\"\r\n\r\nimport { cn } from \"@xploreu/lib/cn\"\r\nimport {\r\n ComboboxInput as ComboboxInputPrimitive,\r\n ComboboxInputGroup,\r\n} from \"../primitives/combobox\"\r\nimport {\r\n Combobox,\r\n ComboboxChip as ComboboxChipUI,\r\n ComboboxChipRemove,\r\n ComboboxChips,\r\n ComboboxInfiniteScroll,\r\n ComboboxItem,\r\n ComboboxList,\r\n ComboboxPortal,\r\n ComboboxPopup,\r\n ComboboxStatus,\r\n ComboboxValue,\r\n type ComboboxProps\r\n} from \"../ui/combobox\"\r\nimport { useControlledState } from \"@xploreu/hooks/use-controlled-state\"\r\nimport { inputVariants } from \"../ui/input\"\r\n\r\ntype ComboboxChipProps<Value> = Omit<ComboboxProps<Value, true>, \"multiple\"> & {\r\n multiple?: boolean\r\n inputPlaceholder?: string\r\n container?: React.ComponentProps<typeof ComboboxPortal>[\"container\"]\r\n items: ({ label: string; value: string; image?: string }[]) | undefined\r\n infiniteScroll?: React.ComponentProps<typeof ComboboxInfiniteScroll>\r\n isPending?: boolean\r\n /**\r\n * When true, enables creatable / taggable mode.\r\n * If the typed value has no exact match in the current item list,\r\n * a \"Create \\\"…\\\"\" option is shown at the top of the dropdown.\r\n * Created items are appended to the value with `{ label, value, tag: true }`.\r\n */\r\n taggable?: boolean\r\n /**\r\n * Maximum number of chips to show before collapsing the rest into a \"+N\" chip.\r\n * When undefined, all chips are shown.\r\n */\r\n maxVisible?: number\r\n}\r\n\r\nfunction ComboboxChip<Value extends { label: string; value: string; image?: string; tag?: true }>({\r\n multiple = true,\r\n inputPlaceholder = \"Search...\",\r\n container,\r\n items,\r\n infiniteScroll,\r\n isPending,\r\n taggable = false,\r\n maxVisible,\r\n ...props\r\n}: ComboboxChipProps<Value>) {\r\n const [inputValue, setInputValue] = useControlledState({\r\n value: props?.inputValue?.toString(),\r\n defaultValue: props?.defaultInputValue?.toString(),\r\n onChange: props?.onInputValueChange,\r\n })\r\n\r\n const [value, setValue] = useControlledState({\r\n value: props?.value ?? [],\r\n defaultValue: props?.defaultValue ?? [],\r\n onChange: props?.onValueChange,\r\n })\r\n\r\n // Track items created via taggable mode\r\n // Sync with value to avoid stale tags when controlled value is reset from outside\r\n const [createdItems, setCreatedItems] = React.useState<Value[]>([])\r\n const createdValuesRef = React.useRef<Set<string>>(new Set())\r\n\r\n React.useEffect(() => {\r\n const currentValues = new Set(value.map((v) => v.value))\r\n setCreatedItems((prev) => {\r\n const next = prev.filter((item) => currentValues.has(item.value))\r\n if (next.length === prev.length) return prev\r\n createdValuesRef.current = new Set(next.map((v) => v.value))\r\n return next\r\n })\r\n }, [value])\r\n\r\n const trimmedInput = inputValue?.toString().trim() ?? \"\"\r\n const isInputSelected = React.useMemo(() => {\r\n if (!trimmedInput) return false\r\n return value.some(\r\n (item) => item.value.toLowerCase() === trimmedInput.toLowerCase()\r\n )\r\n }, [trimmedInput, value])\r\n\r\n // true = show the taggable item in dropdown (either as \"Create:\" or as checked item)\r\n const isCreatingItem = React.useMemo(() => {\r\n if (!taggable || !trimmedInput) return false\r\n return !items?.some(\r\n (item) => item.label.toLowerCase() === trimmedInput.toLowerCase()\r\n )\r\n }, [taggable, trimmedInput, items])\r\n\r\n // Merge server items with locally created tags + the \"Create\" placeholder\r\n const combinedItems = React.useMemo(() => {\r\n const base: Value[] = [\r\n ...items ?? [],\r\n ...createdItems,\r\n ]\r\n\r\n if (isCreatingItem) {\r\n return [...base, { label: trimmedInput, value: trimmedInput, tag: true } as unknown as Value]\r\n }\r\n\r\n return base\r\n }, [items, createdItems, isCreatingItem, trimmedInput])\r\n\r\n const handleValueChange: ComboboxProps<Value, true>[\"onValueChange\"] = (value, eventDetails) => {\r\n if (taggable) {\r\n const newTags = value.filter(\r\n (v) => v?.tag === true && !createdValuesRef.current.has(v.value)\r\n )\r\n if (newTags.length > 0) {\r\n for (const tag of newTags) {\r\n createdValuesRef.current.add(tag.value)\r\n }\r\n setCreatedItems((prev) => [...prev, ...newTags])\r\n }\r\n }\r\n\r\n if (!multiple) {\r\n setValue([value[value.length - 1]], eventDetails)\r\n } else {\r\n setValue(value, eventDetails)\r\n }\r\n }\r\n\r\n return (\r\n <Combobox\r\n {...props}\r\n behavior=\"chip-outside\"\r\n multiple\r\n items={taggable ? combinedItems : items}\r\n isItemEqualToValue={(a, b) => a.value === b.value}\r\n onValueChange={handleValueChange}\r\n onInputValueChange={setInputValue}\r\n >\r\n {/* Input box with chips inside */}\r\n <ComboboxInputGroup\r\n className={cn(\r\n inputVariants(),\r\n \"h-auto min-h-13 flex flex-wrap items-center gap-1.5 px-3 py-1.5 cursor-text\"\r\n )}\r\n >\r\n {/* Chips inside the input box */}\r\n <ComboboxChips\r\n className={cn(\r\n \"contents\",\r\n maxVisible !== undefined && \"flex-nowrap overflow-hidden\"\r\n )}\r\n >\r\n <ComboboxValue>\r\n {(value: Value[]) => {\r\n const visible = maxVisible !== undefined ? value.slice(0, maxVisible) : value\r\n const overflow = maxVisible !== undefined ? value.length - maxVisible : 0\r\n return (\r\n <>\r\n {visible?.map((item) => (\r\n <ComboboxChipUI\r\n key={item?.value || \"\"}\r\n className={cn(maxVisible !== undefined && \"min-w-0 shrink\")}\r\n >\r\n {item?.image && (\r\n <img\r\n src={item.image}\r\n alt={item?.label || \"\"}\r\n className=\"size-4 rounded-full object-cover shrink-0 mr-1\"\r\n />\r\n )}\r\n {maxVisible !== undefined\r\n ? <span className=\"truncate\">{item?.label || \"\"}</span>\r\n : (item?.label || \"\")\r\n }\r\n <ComboboxChipRemove />\r\n </ComboboxChipUI>\r\n ))}\r\n {overflow > 0 && (\r\n <ComboboxChipUI className=\"shrink-0\">\r\n +{overflow}\r\n </ComboboxChipUI>\r\n )}\r\n </>\r\n )\r\n }}\r\n </ComboboxValue>\r\n {/* Text input — shrinks to fit remaining space (inside Chips so backspace works) */}\r\n <ComboboxInputPrimitive\r\n render={\r\n <input\r\n className=\"flex-1 min-w-[80px] bg-transparent outline-none text-body-regular-1 text-text-primary placeholder:text-text-placeholder\"\r\n placeholder={value.length === 0 ? inputPlaceholder : undefined}\r\n />\r\n }\r\n />\r\n </ComboboxChips>\r\n </ComboboxInputGroup>\r\n\r\n <ComboboxPopup container={container}>\r\n <ComboboxStatus\r\n status={\r\n isPending || items === undefined\r\n ? \"pending\"\r\n : items?.length === 0 && !isCreatingItem\r\n ? \"empty\"\r\n : null\r\n }\r\n />\r\n <ComboboxList>\r\n {items?.map((item) => (\r\n <ComboboxItem\r\n key={item.value}\r\n value={item as Value}\r\n >\r\n <div className=\"flex items-center gap-2 w-full min-w-0\">\r\n {item.image && (\r\n <img\r\n src={item.image}\r\n alt={item.label}\r\n className=\"size-6 rounded-full object-cover shrink-0\"\r\n />\r\n )}\r\n <span className=\"truncate\">{item.label}</span>\r\n </div>\r\n </ComboboxItem>\r\n ))}\r\n {isCreatingItem && (\r\n <ComboboxItem\r\n value={{ label: trimmedInput, value: trimmedInput, tag: true }}\r\n >\r\n <div className=\"flex items-center gap-1.5 w-full min-w-0\">\r\n {!isInputSelected && (\r\n <span className=\"text-text-secondary\">Create:</span>\r\n )}\r\n <span className=\"font-medium text-text-primary truncate\">\r\n {trimmedInput}\r\n </span>\r\n </div>\r\n </ComboboxItem>\r\n )}\r\n <ComboboxInfiniteScroll {...infiniteScroll} />\r\n </ComboboxList>\r\n </ComboboxPopup>\r\n </Combobox>\r\n )\r\n}\r\n\r\nexport { ComboboxChip }\r\nexport type { ComboboxChipProps }\r\n"]}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {b,c as c$1}from'./chunk-
|
|
2
|
-
//# sourceMappingURL=chunk-
|
|
1
|
+
import {b,c as c$1}from'./chunk-2XZRLJCN.js';import*as x from'react';import {Combobox}from'@base-ui/react/combobox';import {AnimatePresence,motion}from'motion/react';import {useControlledState}from'@xploreu/hooks/use-controlled-state';import {useDataState}from'@xploreu/hooks/use-data-state';import {getStrictContext}from'@xploreu/lib/get-strict-context';import {jsx}from'react/jsx-runtime';var [V,L]=getStrictContext("ComboboxContext"),[H,c]=getStrictContext("ComboboxActiveValueContext");function M({behavior:o="default",...b}){let[p,i]=useControlledState({value:b?.open,defaultValue:b?.defaultOpen,onChange:b?.onOpenChange}),[a,m]=useControlledState({value:b?.inputValue?.toString(),defaultValue:b?.defaultInputValue?.toString(),onChange:b?.onInputValueChange}),[n,h]=x.useState(null),g=(s,r)=>{if(r.reason==="input-clear")return r.cancel();m(s,r);},d=(s,r)=>{let y=r.trigger?.dataset;if(o==="chip-outside"&&(r.reason==="trigger-press"&&y?.slot==="combobox-clear-input"&&!s||r.reason==="item-press"))return r.cancel();i(s,r);};return jsx(H,{value:{highlightedValue:n,setHighlightedValue:h},children:jsx(V,{value:{open:p,setOpen:i,inputValue:a,setInputValue:m},children:jsx(Combobox.Root,{"data-slot":"combobox",...b,onInputValueChange:g,onOpenChange:d})})})}function k(o){return jsx(Combobox.Trigger,{"data-slot":"combobox-trigger",...o})}function E(o){return jsx(Combobox.Label,{"data-slot":"combobox-label",...o})}function O(o){return jsx(Combobox.InputGroup,{"data-slot":"combobox-input-group",...o})}function B(o){return jsx(Combobox.Input,{"data-slot":"combobox-input",...o})}function F(o){return jsx(Combobox.Icon,{"data-slot":"combobox-icon",...o})}function q(o){return jsx(Combobox.Clear,{"data-slot":"combobox-clear",...o})}function z(o){return jsx(Combobox.Value,{"data-slot":"combobox-value",...o})}function J(o){return jsx(Combobox.Chips,{"data-slot":"combobox-chips",...o})}function K(o){return jsx(Combobox.Chip,{"data-slot":"combobox-chip",...o})}function N(o){return jsx(Combobox.ChipRemove,{"data-slot":"combobox-chip-remove",...o})}function Q(o){let{open:b}=L();return jsx(AnimatePresence,{children:b&&jsx(Combobox.Portal,{"data-slot":"combobox-portal",keepMounted:true,...o})})}function U(o){return jsx(Combobox.Positioner,{"data-slot":"combobox-positioner",...o})}function W({initialFocus:o,finalFocus:b,transition:p={type:"spring",stiffness:300,damping:25},...i}){return jsx(Combobox.Popup,{finalFocus:b,initialFocus:o,render:jsx(motion.div,{animate:{opacity:1,scale:1},"data-slot":"combobox-popup",exit:{opacity:0,scale:.5},initial:{opacity:0,scale:.5},transition:p,...i},"combobox-popup")})}function X(o){return jsx(Combobox.Backdrop,{"data-slot":"combobox-backdrop",...o})}function Y(o){return jsx(Combobox.Status,{"data-slot":"combobox-status",...o})}function Z(o){return jsx(Combobox.Empty,{"data-slot":"combobox-empty",...o})}function _(o){return jsx(Combobox.List,{"data-slot":"combobox-list",...o})}function $({transition:o={type:"spring",stiffness:350,damping:35},...b$1}){let{highlightedValue:p}=c();return jsx(b,{click:false,controlledItems:true,"data-slot":"combobox-highlight",transition:o,value:p,...b$1})}function j(o){return jsx(c$1,{"data-slot":"combobox-highlight-item",...o})}function D(o){return jsx(Combobox.Row,{"data-slot":"combobox-row",...o})}function oo(o){let{setHighlightedValue:b}=c(),[,p]=useDataState("highlighted",void 0,(i,a)=>{if(i===true){let m=a.current,n=m?.dataset.value||m?.id||null;n&&b(n);}});return jsx(Combobox.Item,{ref:p,"data-slot":"combobox-item",...o})}function to(o){return jsx(Combobox.ItemIndicator,{"data-slot":"combobox-item-indicator",...o})}function eo(o){return jsx(Combobox.Separator,{"data-slot":"combobox-separator",...o})}function bo(o){return jsx(Combobox.Group,{"data-slot":"combobox-group",...o})}function ro(o){return jsx(Combobox.GroupLabel,{"data-slot":"combobox-group-label",...o})}function po(o){return jsx(Combobox.Collection,{"data-slot":"combobox-collection",...o})}function io(o){return jsx(Combobox.Arrow,{"data-slot":"combobox-arrow",...o})}export{bo as A,ro as B,po as C,io as D,L as a,c as b,M as c,k as d,E as e,O as f,B as g,F as h,q as i,z as j,J as k,K as l,N as m,Q as n,U as o,W as p,X as q,Y as r,Z as s,_ as t,$ as u,j as v,D as w,oo as x,to as y,eo as z};//# sourceMappingURL=chunk-JILBFCPY.js.map
|
|
2
|
+
//# sourceMappingURL=chunk-JILBFCPY.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/primitives/combobox.tsx"],"names":["ComboboxProvider","useCombobox","getStrictContext","ComboboxActiveValueProvider","useComboboxActiveValue","Combobox","behavior","props","open","setOpen","useControlledState","inputValue","setInputValue","highlightedValue","setHighlightedValue","handleInputValueChange","eventDetails","handleOpenChange","dataSet","jsx","ComboboxPrimitive","ComboboxTrigger","ComboboxLabel","ComboboxInputGroup","ComboboxInput","ComboboxIcon","ComboboxClear","ComboboxValue","ComboboxChips","ComboboxChip","ComboboxChipRemove","ComboboxPortal","AnimatePresence","ComboboxPositioner","ComboboxPopup","initialFocus","finalFocus","transition","motion","ComboboxBackdrop","ComboboxStatus","ComboboxEmpty","ComboboxList","ComboboxHighlight","Highlight","ComboboxHighlightItem","HighlightItem","ComboboxRow","ComboboxItem","highlightedRef","useDataState","value","ref","el","v","ComboboxItemIndicator","ComboboxSeparator","ComboboxGroup","ComboboxGroupLabel","ComboboxCollection","ComboboxArrow"],"mappings":"uYAiCA,IAAM,CAACA,CAAAA,CAAkBC,CAAW,EAClCC,gBAAAA,CAAsC,iBAAiB,EAEnD,CAACC,CAAAA,CAA6BC,CAAsB,CAAA,CACxDF,gBAAAA,CAAiD,4BAA4B,EAM/E,SAASG,CAAAA,CAA8D,CACrE,SAAAC,CAAAA,CAAW,SAAA,CACX,GAAGC,CACL,CAAA,CAAmC,CACjC,GAAM,CAACC,EAAMC,CAAO,CAAA,CAAIC,mBAAmB,CACzC,KAAA,CAAOH,GAAO,IAAA,CACd,YAAA,CAAcA,GAAO,WAAA,CACrB,QAAA,CAAUA,CAAAA,EAAO,YACnB,CAAC,CAAA,CAEK,CAACI,EAAYC,CAAa,CAAA,CAAIF,mBAAmB,CACrD,KAAA,CAAOH,GAAO,UAAA,EAAY,QAAA,GAC1B,YAAA,CAAcA,CAAAA,EAAO,mBAAmB,QAAA,EAAS,CACjD,SAAUA,CAAAA,EAAO,kBACnB,CAAC,CAAA,CAEK,CAACM,CAAAA,CAAkBC,CAAmB,EAAU,CAAA,CAAA,QAAA,CAAwB,IAAI,EAE5EC,CAAAA,CAA+E,CAACJ,EAAYK,CAAAA,GAAiB,CAEjH,GAAIA,CAAAA,CAAa,MAAA,GAAW,cAAe,OAAOA,CAAAA,CAAa,QAAO,CAEtEJ,CAAAA,CAAcD,CAAAA,CAAYK,CAAY,EACxC,CAAA,CAEMC,CAAAA,CAAmE,CAACT,CAAAA,CAAMQ,CAAAA,GAAiB,CAC/F,IAAME,CAAAA,CAAWF,EAAa,OAAA,EAAyB,OAAA,CAGvD,GAAIV,CAAAA,GAAa,cAAA,GAEbU,EAAa,MAAA,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AAA,CACT,GAAGb,CAAAA,CACN,CACF,CAIA,SAASkD,EAAAA,CAAclD,EAA2B,CAChD,OAAOY,IAACC,QAAAA,CAAkB,KAAA,CAAlB,CACN,WAAA,CAAU,gBAAA,CACT,GAAGb,CAAAA,CACN,CACF,CAIA,SAASmD,GAAmBnD,CAAAA,CAAgC,CAC1D,OAAOY,GAAAA,CAACC,QAAAA,CAAkB,WAAlB,CACN,WAAA,CAAU,uBACT,GAAGb,CAAAA,CACN,CACF,CAIA,SAASoD,GAAmBpD,CAAAA,CAAgC,CAC1D,OAAOY,GAAAA,CAACC,QAAAA,CAAkB,UAAA,CAAlB,CACN,YAAU,qBAAA,CACT,GAAGb,EACN,CACF,CAIA,SAASqD,EAAAA,CAAcrD,CAAAA,CAA2B,CAChD,OAAOY,GAAAA,CAACC,SAAkB,KAAA,CAAlB,CACN,YAAU,gBAAA,CACT,GAAGb,EACN,CACF","file":"chunk-C3FYXQCF.js","sourcesContent":["\"use client\"\r\n\r\nimport * as React from \"react\"\r\n\r\nimport { Combobox as ComboboxPrimitive } from \"@base-ui/react/combobox\"\r\nimport {\r\n AnimatePresence,\r\n type HTMLMotionProps,\r\n motion\r\n} from \"motion/react\"\r\n\r\nimport {\r\n Highlight,\r\n HighlightItem,\r\n type HighlightItemProps,\r\n type HighlightProps,\r\n} from \"../effects/highlight\"\r\nimport { useControlledState } from \"@xploreu/hooks/use-controlled-state\"\r\nimport { useDataState } from \"@xploreu/hooks/use-data-state\"\r\nimport { getStrictContext } from \"@xploreu/lib/get-strict-context\"\r\n\r\ntype ComboboxContextType = {\r\n open: boolean;\r\n setOpen: (open: boolean, eventDetails: ComboboxPrimitive.Root.ChangeEventDetails) => void;\r\n inputValue: string;\r\n setInputValue: (inputValue: string, eventDetails: ComboboxPrimitive.Root.ChangeEventDetails) => void;\r\n}\r\n\r\ntype ComboboxActiveValueContextType = {\r\n highlightedValue: string | null;\r\n setHighlightedValue: (value: string | null) => void;\r\n}\r\n\r\nconst [ComboboxProvider, useCombobox] =\r\n getStrictContext<ComboboxContextType>(\"ComboboxContext\")\r\n\r\nconst [ComboboxActiveValueProvider, useComboboxActiveValue] =\r\n getStrictContext<ComboboxActiveValueContextType>(\"ComboboxActiveValueContext\")\r\n\r\ntype ComboboxProps<Value, Multiple extends boolean | undefined = false> = ComboboxPrimitive.Root.Props<Value, Multiple> & {\r\n behavior?: \"default\" | \"chip-outside\";\r\n}\r\n\r\nfunction Combobox<Value, Multiple extends boolean | undefined = false>({\r\n behavior = \"default\",\r\n ...props\r\n}: ComboboxProps<Value, Multiple>) {\r\n const [open, setOpen] = useControlledState({\r\n value: props?.open,\r\n defaultValue: props?.defaultOpen,\r\n onChange: props?.onOpenChange,\r\n })\r\n\r\n const [inputValue, setInputValue] = useControlledState({\r\n value: props?.inputValue?.toString(),\r\n defaultValue: props?.defaultInputValue?.toString(),\r\n onChange: props?.onInputValueChange,\r\n })\r\n\r\n const [highlightedValue, setHighlightedValue] = React.useState<string | null>(null)\r\n\r\n const handleInputValueChange: ComboboxProps<Value, Multiple>[\"onInputValueChange\"] = (inputValue, eventDetails) => {\r\n // if the input is cleared, we want to cancel the event to prevent resetting the input value.\r\n if (eventDetails.reason === \"input-clear\") return eventDetails.cancel()\r\n\r\n setInputValue(inputValue, eventDetails)\r\n }\r\n\r\n const handleOpenChange: ComboboxProps<Value, Multiple>[\"onOpenChange\"] = (open, eventDetails) => {\r\n const dataSet = (eventDetails.trigger as HTMLElement)?.dataset\r\n\r\n\r\n if (behavior === \"chip-outside\") {\r\n if (\r\n eventDetails.reason === \"trigger-press\" &&\r\n dataSet?.slot === \"combobox-clear-input\" &&\r\n !open\r\n ) {\r\n return eventDetails.cancel()\r\n }\r\n\r\n if (eventDetails.reason === \"item-press\") {\r\n return eventDetails.cancel()\r\n }\r\n }\r\n\r\n setOpen(open, eventDetails)\r\n }\r\n\r\n return (\r\n <ComboboxActiveValueProvider value={{ highlightedValue, setHighlightedValue }}>\r\n <ComboboxProvider value={{ open, setOpen, inputValue, setInputValue }}>\r\n <ComboboxPrimitive.Root\r\n data-slot=\"combobox\"\r\n {...props}\r\n onInputValueChange={handleInputValueChange}\r\n onOpenChange={handleOpenChange}\r\n />\r\n </ComboboxProvider>\r\n </ComboboxActiveValueProvider>\r\n )\r\n}\r\n\r\ntype ComboboxTriggerProps = ComboboxPrimitive.Trigger.Props\r\n\r\nfunction ComboboxTrigger(props: ComboboxTriggerProps) {\r\n return <ComboboxPrimitive.Trigger\r\n data-slot=\"combobox-trigger\"\r\n {...props}\r\n />\r\n}\r\n\r\ntype ComboboxLabelProps = ComboboxPrimitive.Label.Props\r\n\r\nfunction ComboboxLabel(props: ComboboxLabelProps) {\r\n return <ComboboxPrimitive.Label\r\n data-slot=\"combobox-label\"\r\n {...props}\r\n />\r\n}\r\n\r\ntype ComboboxInputGroupProps = ComboboxPrimitive.InputGroup.Props\r\n\r\nfunction ComboboxInputGroup(props: ComboboxInputGroupProps) {\r\n return <ComboboxPrimitive.InputGroup\r\n data-slot=\"combobox-input-group\"\r\n {...props}\r\n />\r\n}\r\n\r\ntype ComboboxInputProps = ComboboxPrimitive.Input.Props\r\n\r\nfunction ComboboxInput(props: ComboboxInputProps) {\r\n return <ComboboxPrimitive.Input\r\n data-slot=\"combobox-input\"\r\n {...props}\r\n />\r\n}\r\n\r\ntype ComboboxIconProps = ComboboxPrimitive.Icon.Props\r\n\r\nfunction ComboboxIcon(props: ComboboxIconProps) {\r\n return <ComboboxPrimitive.Icon\r\n data-slot=\"combobox-icon\"\r\n {...props}\r\n />\r\n}\r\n\r\ntype ComboboxClearProps = ComboboxPrimitive.Clear.Props\r\n\r\nfunction ComboboxClear(props: ComboboxClearProps) {\r\n return <ComboboxPrimitive.Clear\r\n data-slot=\"combobox-clear\"\r\n {...props}\r\n />\r\n}\r\n\r\ntype ComboboxValueProps = ComboboxPrimitive.Value.Props\r\n\r\nfunction ComboboxValue(props: ComboboxValueProps) {\r\n return <ComboboxPrimitive.Value\r\n data-slot=\"combobox-value\"\r\n {...props}\r\n />\r\n}\r\n\r\ntype ComboboxChipsProps = ComboboxPrimitive.Chips.Props\r\n\r\nfunction ComboboxChips(props: ComboboxChipsProps) {\r\n return <ComboboxPrimitive.Chips\r\n data-slot=\"combobox-chips\"\r\n {...props}\r\n />\r\n}\r\n\r\ntype ComboboxChipProps = ComboboxPrimitive.Chip.Props\r\n\r\nfunction ComboboxChip(props: ComboboxChipProps) {\r\n return <ComboboxPrimitive.Chip\r\n data-slot=\"combobox-chip\"\r\n {...props}\r\n />\r\n}\r\n\r\ntype ComboboxChipRemoveProps = ComboboxPrimitive.ChipRemove.Props\r\n\r\nfunction ComboboxChipRemove(props: ComboboxChipRemoveProps) {\r\n return <ComboboxPrimitive.ChipRemove\r\n data-slot=\"combobox-chip-remove\"\r\n {...props}\r\n />\r\n}\r\n\r\ntype ComboboxPortalProps = Omit<\r\n ComboboxPrimitive.Portal.Props,\r\n \"keepMounted\"\r\n>\r\n\r\nfunction ComboboxPortal(props: ComboboxPortalProps) {\r\n const { open } = useCombobox()\r\n\r\n return (\r\n <AnimatePresence>\r\n {open && (\r\n <ComboboxPrimitive.Portal\r\n data-slot=\"combobox-portal\"\r\n keepMounted\r\n {...props}\r\n />\r\n )}\r\n </AnimatePresence>\r\n )\r\n}\r\n\r\ntype ComboboxPositionerProps = ComboboxPrimitive.Positioner.Props\r\n\r\nfunction ComboboxPositioner(props: ComboboxPositionerProps) {\r\n return (\r\n <ComboboxPrimitive.Positioner\r\n data-slot=\"combobox-positioner\"\r\n {...props}\r\n />\r\n )\r\n}\r\n\r\ntype ComboboxPopupProps = Omit<\r\n ComboboxPrimitive.Popup.Props,\r\n \"render\"\r\n> &\r\n HTMLMotionProps<\"div\">\r\n\r\nfunction ComboboxPopup({\r\n initialFocus,\r\n finalFocus,\r\n transition = { type: \"spring\", stiffness: 300, damping: 25 },\r\n ...props\r\n}: ComboboxPopupProps) {\r\n return (\r\n <ComboboxPrimitive.Popup\r\n finalFocus={finalFocus}\r\n initialFocus={initialFocus}\r\n render={\r\n <motion.div\r\n key=\"combobox-popup\"\r\n animate={{ opacity: 1, scale: 1 }}\r\n data-slot=\"combobox-popup\"\r\n exit={{ opacity: 0, scale: 0.5 }}\r\n initial={{ opacity: 0, scale: 0.5 }}\r\n transition={transition}\r\n {...props}\r\n />\r\n }\r\n />\r\n )\r\n}\r\n\r\ntype ComboboxBackdropProps = ComboboxPrimitive.Backdrop.Props\r\n\r\nfunction ComboboxBackdrop(props: ComboboxBackdropProps) {\r\n return <ComboboxPrimitive.Backdrop\r\n data-slot=\"combobox-backdrop\"\r\n {...props}\r\n />\r\n}\r\n\r\ntype ComboboxStatusProps = ComboboxPrimitive.Status.Props\r\n\r\nfunction ComboboxStatus(props: ComboboxStatusProps) {\r\n return <ComboboxPrimitive.Status\r\n data-slot=\"combobox-status\"\r\n {...props}\r\n />\r\n}\r\n\r\ntype ComboboxEmptyProps = ComboboxPrimitive.Empty.Props\r\n\r\nfunction ComboboxEmpty(props: ComboboxEmptyProps) {\r\n return <ComboboxPrimitive.Empty\r\n data-slot=\"combobox-empty\"\r\n {...props}\r\n />\r\n}\r\n\r\ntype ComboboxListProps = ComboboxPrimitive.List.Props\r\n\r\nfunction ComboboxList(props: ComboboxListProps) {\r\n return <ComboboxPrimitive.List\r\n data-slot=\"combobox-list\"\r\n {...props}\r\n />\r\n}\r\n\r\ntype ComboboxHighlightProps = Omit<\r\n HighlightProps,\r\n \"controlledItems\" | \"enabled\" | \"hover\"\r\n>\r\n\r\nfunction ComboboxHighlight({\r\n transition = { type: \"spring\", stiffness: 350, damping: 35 },\r\n ...props\r\n}: ComboboxHighlightProps) {\r\n const { highlightedValue } = useComboboxActiveValue()\r\n\r\n return (\r\n <Highlight\r\n click={false}\r\n controlledItems\r\n data-slot=\"combobox-highlight\"\r\n transition={transition}\r\n value={highlightedValue}\r\n {...props}\r\n />\r\n )\r\n}\r\n\r\ntype ComboboxHighlightItemProps = HighlightItemProps\r\n\r\nfunction ComboboxHighlightItem(props: ComboboxHighlightItemProps) {\r\n return (\r\n <HighlightItem\r\n data-slot=\"combobox-highlight-item\"\r\n {...props}\r\n />\r\n )\r\n}\r\n\r\ntype ComboboxRowProps = ComboboxPrimitive.Row.Props\r\n\r\nfunction ComboboxRow(props: ComboboxRowProps) {\r\n return <ComboboxPrimitive.Row\r\n data-slot=\"combobox-row\"\r\n {...props}\r\n />\r\n}\r\n\r\ntype ComboboxItemProps = ComboboxPrimitive.Item.Props\r\n\r\nfunction ComboboxItem(props: ComboboxItemProps) {\r\n const { setHighlightedValue } = useComboboxActiveValue()\r\n const [, highlightedRef] = useDataState<HTMLDivElement>(\r\n \"highlighted\",\r\n undefined,\r\n (value, ref) => {\r\n if (value === true) {\r\n const el = ref.current\r\n const v = el?.dataset.value || el?.id || null\r\n if (v) setHighlightedValue(v)\r\n }\r\n },\r\n )\r\n\r\n return <ComboboxPrimitive.Item\r\n ref={highlightedRef}\r\n data-slot=\"combobox-item\"\r\n {...props}\r\n />\r\n}\r\n\r\ntype ComboboxItemIndicatorProps = ComboboxPrimitive.ItemIndicator.Props\r\n\r\nfunction ComboboxItemIndicator(props: ComboboxItemIndicatorProps) {\r\n return <ComboboxPrimitive.ItemIndicator\r\n data-slot=\"combobox-item-indicator\"\r\n {...props}\r\n />\r\n}\r\n\r\ntype ComboboxSeparatorProps = ComboboxPrimitive.Separator.Props\r\n\r\nfunction ComboboxSeparator(props: ComboboxSeparatorProps) {\r\n return <ComboboxPrimitive.Separator\r\n data-slot=\"combobox-separator\"\r\n {...props}\r\n />\r\n}\r\n\r\ntype ComboboxGroupProps = ComboboxPrimitive.Group.Props\r\n\r\nfunction ComboboxGroup(props: ComboboxGroupProps) {\r\n return <ComboboxPrimitive.Group\r\n data-slot=\"combobox-group\"\r\n {...props}\r\n />\r\n}\r\n\r\ntype ComboboxGroupLabelProps = ComboboxPrimitive.GroupLabel.Props\r\n\r\nfunction ComboboxGroupLabel(props: ComboboxGroupLabelProps) {\r\n return <ComboboxPrimitive.GroupLabel\r\n data-slot=\"combobox-group-label\"\r\n {...props}\r\n />\r\n}\r\n\r\ntype ComboboxCollectionProps = ComboboxPrimitive.Collection.Props\r\n\r\nfunction ComboboxCollection(props: ComboboxCollectionProps) {\r\n return <ComboboxPrimitive.Collection\r\n data-slot=\"combobox-collection\"\r\n {...props}\r\n />\r\n}\r\n\r\ntype ComboboxArrowProps = ComboboxPrimitive.Arrow.Props\r\n\r\nfunction ComboboxArrow(props: ComboboxArrowProps) {\r\n return <ComboboxPrimitive.Arrow\r\n data-slot=\"combobox-arrow\"\r\n {...props}\r\n />\r\n}\r\n\r\nexport {\r\n Combobox,\r\n type ComboboxActiveValueContextType,\r\n ComboboxArrow,\r\n type ComboboxArrowProps,\r\n ComboboxBackdrop,\r\n type ComboboxBackdropProps,\r\n ComboboxChip,\r\n type ComboboxChipProps,\r\n ComboboxChipRemove,\r\n type ComboboxChipRemoveProps,\r\n ComboboxChips,\r\n type ComboboxChipsProps,\r\n ComboboxClear,\r\n type ComboboxClearProps,\r\n ComboboxCollection,\r\n type ComboboxCollectionProps,\r\n type ComboboxContextType,\r\n ComboboxEmpty,\r\n type ComboboxEmptyProps,\r\n ComboboxGroup,\r\n ComboboxGroupLabel,\r\n type ComboboxGroupLabelProps,\r\n type ComboboxGroupProps,\r\n ComboboxHighlight,\r\n ComboboxHighlightItem,\r\n type ComboboxHighlightItemProps,\r\n type ComboboxHighlightProps,\r\n ComboboxIcon,\r\n type ComboboxIconProps,\r\n ComboboxInput,\r\n ComboboxInputGroup,\r\n type ComboboxInputGroupProps,\r\n type ComboboxInputProps,\r\n ComboboxItem,\r\n ComboboxItemIndicator,\r\n type ComboboxItemIndicatorProps,\r\n type ComboboxItemProps,\r\n ComboboxLabel,\r\n type ComboboxLabelProps,\r\n ComboboxList,\r\n type ComboboxListProps,\r\n ComboboxPopup,\r\n type ComboboxPopupProps,\r\n ComboboxPortal,\r\n type ComboboxPortalProps,\r\n ComboboxPositioner,\r\n type ComboboxPositionerProps,\r\n type ComboboxProps,\r\n ComboboxRow,\r\n type ComboboxRowProps,\r\n ComboboxSeparator,\r\n type ComboboxSeparatorProps,\r\n ComboboxStatus,\r\n type ComboboxStatusProps,\r\n ComboboxTrigger,\r\n type ComboboxTriggerProps,\r\n ComboboxValue,\r\n type ComboboxValueProps,\r\n useCombobox,\r\n useComboboxActiveValue,\r\n}"]}
|
|
1
|
+
{"version":3,"sources":["../src/primitives/combobox.tsx"],"names":["ComboboxProvider","useCombobox","getStrictContext","ComboboxActiveValueProvider","useComboboxActiveValue","Combobox","behavior","props","open","setOpen","useControlledState","inputValue","setInputValue","highlightedValue","setHighlightedValue","handleInputValueChange","eventDetails","handleOpenChange","dataSet","jsx","ComboboxPrimitive","ComboboxTrigger","ComboboxLabel","ComboboxInputGroup","ComboboxInput","ComboboxIcon","ComboboxClear","ComboboxValue","ComboboxChips","ComboboxChip","ComboboxChipRemove","ComboboxPortal","AnimatePresence","ComboboxPositioner","ComboboxPopup","initialFocus","finalFocus","transition","motion","ComboboxBackdrop","ComboboxStatus","ComboboxEmpty","ComboboxList","ComboboxHighlight","Highlight","ComboboxHighlightItem","HighlightItem","ComboboxRow","ComboboxItem","highlightedRef","useDataState","value","ref","el","v","ComboboxItemIndicator","ComboboxSeparator","ComboboxGroup","ComboboxGroupLabel","ComboboxCollection","ComboboxArrow"],"mappings":"uYAiCA,IAAM,CAACA,CAAAA,CAAkBC,CAAW,EAClCC,gBAAAA,CAAsC,iBAAiB,EAEnD,CAACC,CAAAA,CAA6BC,CAAsB,CAAA,CACxDF,gBAAAA,CAAiD,4BAA4B,EAM/E,SAASG,CAAAA,CAA8D,CACrE,SAAAC,CAAAA,CAAW,SAAA,CACX,GAAGC,CACL,CAAA,CAAmC,CACjC,GAAM,CAACC,EAAMC,CAAO,CAAA,CAAIC,mBAAmB,CACzC,KAAA,CAAOH,GAAO,IAAA,CACd,YAAA,CAAcA,GAAO,WAAA,CACrB,QAAA,CAAUA,CAAAA,EAAO,YACnB,CAAC,CAAA,CAE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ACA,CAACC,CAAAA,CAAOC,IAAQ,CACd,GAAID,IAAU,IAAA,CAAM,CAClB,IAAME,CAAAA,CAAKD,CAAAA,CAAI,QACTE,CAAAA,CAAID,CAAAA,EAAI,OAAA,CAAQ,KAAA,EAASA,GAAI,EAAA,EAAM,IAAA,CACrCC,GAAGxC,CAAAA,CAAoBwC,CAAC,EAC9B,CACF,CACF,EAEA,OAAOnC,GAAAA,CAACC,SAAkB,IAAA,CAAlB,CACN,IAAK6B,CAAAA,CACL,WAAA,CAAU,gBACT,GAAG1C,CAAAA,CACN,CACF,CAIA,SAASgD,EAAAA,CAAsBhD,CAAAA,CAAmC,CAChE,OAAOY,GAAAA,CAACC,SAAkB,aAAA,CAAlB,CACN,YAAU,yBAAA,CACT,GAAGb,EACN,CACF,CAIA,SAASiD,EAAAA,CAAkBjD,CAAAA,CAA+B,CACxD,OAAOY,GAAAA,CAACC,QAAAA,CAAkB,SAAA,CAAlB,CACN,WAAA,CAAU,oBAAA,CACT,GAAGb,CAAAA,CACN,CACF,CAIA,SAASkD,EAAAA,CAAclD,EAA2B,CAChD,OAAOY,IAACC,QAAAA,CAAkB,KAAA,CAAlB,CACN,WAAA,CAAU,gBAAA,CACT,GAAGb,CAAAA,CACN,CACF,CAIA,SAASmD,GAAmBnD,CAAAA,CAAgC,CAC1D,OAAOY,GAAAA,CAACC,QAAAA,CAAkB,WAAlB,CACN,WAAA,CAAU,uBACT,GAAGb,CAAAA,CACN,CACF,CAIA,SAASoD,GAAmBpD,CAAAA,CAAgC,CAC1D,OAAOY,GAAAA,CAACC,QAAAA,CAAkB,UAAA,CAAlB,CACN,YAAU,qBAAA,CACT,GAAGb,EACN,CACF,CAIA,SAASqD,EAAAA,CAAcrD,CAAAA,CAA2B,CAChD,OAAOY,GAAAA,CAACC,SAAkB,KAAA,CAAlB,CACN,YAAU,gBAAA,CACT,GAAGb,EACN,CACF","file":"chunk-JILBFCPY.js","sourcesContent":["\"use client\"\r\n\r\nimport * as React from \"react\"\r\n\r\nimport { Combobox as ComboboxPrimitive } from \"@base-ui/react/combobox\"\r\nimport {\r\n AnimatePresence,\r\n type HTMLMotionProps,\r\n motion\r\n} from \"motion/react\"\r\n\r\nimport {\r\n Highlight,\r\n HighlightItem,\r\n type HighlightItemProps,\r\n type HighlightProps,\r\n} from \"../effects/highlight\"\r\nimport { useControlledState } from \"@xploreu/hooks/use-controlled-state\"\r\nimport { useDataState } from \"@xploreu/hooks/use-data-state\"\r\nimport { getStrictContext } from \"@xploreu/lib/get-strict-context\"\r\n\r\ntype ComboboxContextType = {\r\n open: boolean;\r\n setOpen: (open: boolean, eventDetails: ComboboxPrimitive.Root.ChangeEventDetails) => void;\r\n inputValue: string;\r\n setInputValue: (inputValue: string, eventDetails: ComboboxPrimitive.Root.ChangeEventDetails) => void;\r\n}\r\n\r\ntype ComboboxActiveValueContextType = {\r\n highlightedValue: string | null;\r\n setHighlightedValue: (value: string | null) => void;\r\n}\r\n\r\nconst [ComboboxProvider, useCombobox] =\r\n getStrictContext<ComboboxContextType>(\"ComboboxContext\")\r\n\r\nconst [ComboboxActiveValueProvider, useComboboxActiveValue] =\r\n getStrictContext<ComboboxActiveValueContextType>(\"ComboboxActiveValueContext\")\r\n\r\ntype ComboboxProps<Value, Multiple extends boolean | undefined = false> = ComboboxPrimitive.Root.Props<Value, Multiple> & {\r\n behavior?: \"default\" | \"chip-outside\";\r\n}\r\n\r\nfunction Combobox<Value, Multiple extends boolean | undefined = false>({\r\n behavior = \"default\",\r\n ...props\r\n}: ComboboxProps<Value, Multiple>) {\r\n const [open, setOpen] = useControlledState({\r\n value: props?.open,\r\n defaultValue: props?.defaultOpen,\r\n onChange: props?.onOpenChange,\r\n })\r\n\r\n const [inputValue, setInputValue] = useControlledState({\r\n value: props?.inputValue?.toString(),\r\n defaultValue: props?.defaultInputValue?.toString(),\r\n onChange: props?.onInputValueChange,\r\n })\r\n\r\n const [highlightedValue, setHighlightedValue] = React.useState<string | null>(null)\r\n\r\n const handleInputValueChange: ComboboxProps<Value, Multiple>[\"onInputValueChange\"] = (inputValue, eventDetails) => {\r\n // if the input is cleared, we want to cancel the event to prevent resetting the input value.\r\n if (eventDetails.reason === \"input-clear\") return eventDetails.cancel()\r\n\r\n setInputValue(inputValue, eventDetails)\r\n }\r\n\r\n const handleOpenChange: ComboboxProps<Value, Multiple>[\"onOpenChange\"] = (open, eventDetails) => {\r\n const dataSet = (eventDetails.trigger as HTMLElement)?.dataset\r\n\r\n\r\n if (behavior === \"chip-outside\") {\r\n if (\r\n eventDetails.reason === \"trigger-press\" &&\r\n dataSet?.slot === \"combobox-clear-input\" &&\r\n !open\r\n ) {\r\n return eventDetails.cancel()\r\n }\r\n\r\n if (eventDetails.reason === \"item-press\") {\r\n return eventDetails.cancel()\r\n }\r\n }\r\n\r\n setOpen(open, eventDetails)\r\n }\r\n\r\n return (\r\n <ComboboxActiveValueProvider value={{ highlightedValue, setHighlightedValue }}>\r\n <ComboboxProvider value={{ open, setOpen, inputValue, setInputValue }}>\r\n <ComboboxPrimitive.Root\r\n data-slot=\"combobox\"\r\n {...props}\r\n onInputValueChange={handleInputValueChange}\r\n onOpenChange={handleOpenChange}\r\n />\r\n </ComboboxProvider>\r\n </ComboboxActiveValueProvider>\r\n )\r\n}\r\n\r\ntype ComboboxTriggerProps = ComboboxPrimitive.Trigger.Props\r\n\r\nfunction ComboboxTrigger(props: ComboboxTriggerProps) {\r\n return <ComboboxPrimitive.Trigger\r\n data-slot=\"combobox-trigger\"\r\n {...props}\r\n />\r\n}\r\n\r\ntype ComboboxLabelProps = ComboboxPrimitive.Label.Props\r\n\r\nfunction ComboboxLabel(props: ComboboxLabelProps) {\r\n return <ComboboxPrimitive.Label\r\n data-slot=\"combobox-label\"\r\n {...props}\r\n />\r\n}\r\n\r\ntype ComboboxInputGroupProps = ComboboxPrimitive.InputGroup.Props\r\n\r\nfunction ComboboxInputGroup(props: ComboboxInputGroupProps) {\r\n return <ComboboxPrimitive.InputGroup\r\n data-slot=\"combobox-input-group\"\r\n {...props}\r\n />\r\n}\r\n\r\ntype ComboboxInputProps = ComboboxPrimitive.Input.Props\r\n\r\nfunction ComboboxInput(props: ComboboxInputProps) {\r\n return <ComboboxPrimitive.Input\r\n data-slot=\"combobox-input\"\r\n {...props}\r\n />\r\n}\r\n\r\ntype ComboboxIconProps = ComboboxPrimitive.Icon.Props\r\n\r\nfunction ComboboxIcon(props: ComboboxIconProps) {\r\n return <ComboboxPrimitive.Icon\r\n data-slot=\"combobox-icon\"\r\n {...props}\r\n />\r\n}\r\n\r\ntype ComboboxClearProps = ComboboxPrimitive.Clear.Props\r\n\r\nfunction ComboboxClear(props: ComboboxClearProps) {\r\n return <ComboboxPrimitive.Clear\r\n data-slot=\"combobox-clear\"\r\n {...props}\r\n />\r\n}\r\n\r\ntype ComboboxValueProps = ComboboxPrimitive.Value.Props\r\n\r\nfunction ComboboxValue(props: ComboboxValueProps) {\r\n return <ComboboxPrimitive.Value\r\n data-slot=\"combobox-value\"\r\n {...props}\r\n />\r\n}\r\n\r\ntype ComboboxChipsProps = ComboboxPrimitive.Chips.Props\r\n\r\nfunction ComboboxChips(props: ComboboxChipsProps) {\r\n return <ComboboxPrimitive.Chips\r\n data-slot=\"combobox-chips\"\r\n {...props}\r\n />\r\n}\r\n\r\ntype ComboboxChipProps = ComboboxPrimitive.Chip.Props\r\n\r\nfunction ComboboxChip(props: ComboboxChipProps) {\r\n return <ComboboxPrimitive.Chip\r\n data-slot=\"combobox-chip\"\r\n {...props}\r\n />\r\n}\r\n\r\ntype ComboboxChipRemoveProps = ComboboxPrimitive.ChipRemove.Props\r\n\r\nfunction ComboboxChipRemove(props: ComboboxChipRemoveProps) {\r\n return <ComboboxPrimitive.ChipRemove\r\n data-slot=\"combobox-chip-remove\"\r\n {...props}\r\n />\r\n}\r\n\r\ntype ComboboxPortalProps = Omit<\r\n ComboboxPrimitive.Portal.Props,\r\n \"keepMounted\"\r\n>\r\n\r\nfunction ComboboxPortal(props: ComboboxPortalProps) {\r\n const { open } = useCombobox()\r\n\r\n return (\r\n <AnimatePresence>\r\n {open && (\r\n <ComboboxPrimitive.Portal\r\n data-slot=\"combobox-portal\"\r\n keepMounted\r\n {...props}\r\n />\r\n )}\r\n </AnimatePresence>\r\n )\r\n}\r\n\r\ntype ComboboxPositionerProps = ComboboxPrimitive.Positioner.Props\r\n\r\nfunction ComboboxPositioner(props: ComboboxPositionerProps) {\r\n return (\r\n <ComboboxPrimitive.Positioner\r\n data-slot=\"combobox-positioner\"\r\n {...props}\r\n />\r\n )\r\n}\r\n\r\ntype ComboboxPopupProps = Omit<\r\n ComboboxPrimitive.Popup.Props,\r\n \"render\"\r\n> &\r\n HTMLMotionProps<\"div\">\r\n\r\nfunction ComboboxPopup({\r\n initialFocus,\r\n finalFocus,\r\n transition = { type: \"spring\", stiffness: 300, damping: 25 },\r\n ...props\r\n}: ComboboxPopupProps) {\r\n return (\r\n <ComboboxPrimitive.Popup\r\n finalFocus={finalFocus}\r\n initialFocus={initialFocus}\r\n render={\r\n <motion.div\r\n key=\"combobox-popup\"\r\n animate={{ opacity: 1, scale: 1 }}\r\n data-slot=\"combobox-popup\"\r\n exit={{ opacity: 0, scale: 0.5 }}\r\n initial={{ opacity: 0, scale: 0.5 }}\r\n transition={transition}\r\n {...props}\r\n />\r\n }\r\n />\r\n )\r\n}\r\n\r\ntype ComboboxBackdropProps = ComboboxPrimitive.Backdrop.Props\r\n\r\nfunction ComboboxBackdrop(props: ComboboxBackdropProps) {\r\n return <ComboboxPrimitive.Backdrop\r\n data-slot=\"combobox-backdrop\"\r\n {...props}\r\n />\r\n}\r\n\r\ntype ComboboxStatusProps = ComboboxPrimitive.Status.Props\r\n\r\nfunction ComboboxStatus(props: ComboboxStatusProps) {\r\n return <ComboboxPrimitive.Status\r\n data-slot=\"combobox-status\"\r\n {...props}\r\n />\r\n}\r\n\r\ntype ComboboxEmptyProps = ComboboxPrimitive.Empty.Props\r\n\r\nfunction ComboboxEmpty(props: ComboboxEmptyProps) {\r\n return <ComboboxPrimitive.Empty\r\n data-slot=\"combobox-empty\"\r\n {...props}\r\n />\r\n}\r\n\r\ntype ComboboxListProps = ComboboxPrimitive.List.Props\r\n\r\nfunction ComboboxList(props: ComboboxListProps) {\r\n return <ComboboxPrimitive.List\r\n data-slot=\"combobox-list\"\r\n {...props}\r\n />\r\n}\r\n\r\ntype ComboboxHighlightProps = Omit<\r\n HighlightProps,\r\n \"controlledItems\" | \"enabled\" | \"hover\"\r\n>\r\n\r\nfunction ComboboxHighlight({\r\n transition = { type: \"spring\", stiffness: 350, damping: 35 },\r\n ...props\r\n}: ComboboxHighlightProps) {\r\n const { highlightedValue } = useComboboxActiveValue()\r\n\r\n return (\r\n <Highlight\r\n click={false}\r\n controlledItems\r\n data-slot=\"combobox-highlight\"\r\n transition={transition}\r\n value={highlightedValue}\r\n {...props}\r\n />\r\n )\r\n}\r\n\r\ntype ComboboxHighlightItemProps = HighlightItemProps\r\n\r\nfunction ComboboxHighlightItem(props: ComboboxHighlightItemProps) {\r\n return (\r\n <HighlightItem\r\n data-slot=\"combobox-highlight-item\"\r\n {...props}\r\n />\r\n )\r\n}\r\n\r\ntype ComboboxRowProps = ComboboxPrimitive.Row.Props\r\n\r\nfunction ComboboxRow(props: ComboboxRowProps) {\r\n return <ComboboxPrimitive.Row\r\n data-slot=\"combobox-row\"\r\n {...props}\r\n />\r\n}\r\n\r\ntype ComboboxItemProps = ComboboxPrimitive.Item.Props\r\n\r\nfunction ComboboxItem(props: ComboboxItemProps) {\r\n const { setHighlightedValue } = useComboboxActiveValue()\r\n const [, highlightedRef] = useDataState<HTMLDivElement>(\r\n \"highlighted\",\r\n undefined,\r\n (value, ref) => {\r\n if (value === true) {\r\n const el = ref.current\r\n const v = el?.dataset.value || el?.id || null\r\n if (v) setHighlightedValue(v)\r\n }\r\n },\r\n )\r\n\r\n return <ComboboxPrimitive.Item\r\n ref={highlightedRef}\r\n data-slot=\"combobox-item\"\r\n {...props}\r\n />\r\n}\r\n\r\ntype ComboboxItemIndicatorProps = ComboboxPrimitive.ItemIndicator.Props\r\n\r\nfunction ComboboxItemIndicator(props: ComboboxItemIndicatorProps) {\r\n return <ComboboxPrimitive.ItemIndicator\r\n data-slot=\"combobox-item-indicator\"\r\n {...props}\r\n />\r\n}\r\n\r\ntype ComboboxSeparatorProps = ComboboxPrimitive.Separator.Props\r\n\r\nfunction ComboboxSeparator(props: ComboboxSeparatorProps) {\r\n return <ComboboxPrimitive.Separator\r\n data-slot=\"combobox-separator\"\r\n {...props}\r\n />\r\n}\r\n\r\ntype ComboboxGroupProps = ComboboxPrimitive.Group.Props\r\n\r\nfunction ComboboxGroup(props: ComboboxGroupProps) {\r\n return <ComboboxPrimitive.Group\r\n data-slot=\"combobox-group\"\r\n {...props}\r\n />\r\n}\r\n\r\ntype ComboboxGroupLabelProps = ComboboxPrimitive.GroupLabel.Props\r\n\r\nfunction ComboboxGroupLabel(props: ComboboxGroupLabelProps) {\r\n return <ComboboxPrimitive.GroupLabel\r\n data-slot=\"combobox-group-label\"\r\n {...props}\r\n />\r\n}\r\n\r\ntype ComboboxCollectionProps = ComboboxPrimitive.Collection.Props\r\n\r\nfunction ComboboxCollection(props: ComboboxCollectionProps) {\r\n return <ComboboxPrimitive.Collection\r\n data-slot=\"combobox-collection\"\r\n {...props}\r\n />\r\n}\r\n\r\ntype ComboboxArrowProps = ComboboxPrimitive.Arrow.Props\r\n\r\nfunction ComboboxArrow(props: ComboboxArrowProps) {\r\n return <ComboboxPrimitive.Arrow\r\n data-slot=\"combobox-arrow\"\r\n {...props}\r\n />\r\n}\r\n\r\nexport {\r\n Combobox,\r\n type ComboboxActiveValueContextType,\r\n ComboboxArrow,\r\n type ComboboxArrowProps,\r\n ComboboxBackdrop,\r\n type ComboboxBackdropProps,\r\n ComboboxChip,\r\n type ComboboxChipProps,\r\n ComboboxChipRemove,\r\n type ComboboxChipRemoveProps,\r\n ComboboxChips,\r\n type ComboboxChipsProps,\r\n ComboboxClear,\r\n type ComboboxClearProps,\r\n ComboboxCollection,\r\n type ComboboxCollectionProps,\r\n type ComboboxContextType,\r\n ComboboxEmpty,\r\n type ComboboxEmptyProps,\r\n ComboboxGroup,\r\n ComboboxGroupLabel,\r\n type ComboboxGroupLabelProps,\r\n type ComboboxGroupProps,\r\n ComboboxHighlight,\r\n ComboboxHighlightItem,\r\n type ComboboxHighlightItemProps,\r\n type ComboboxHighlightProps,\r\n ComboboxIcon,\r\n type ComboboxIconProps,\r\n ComboboxInput,\r\n ComboboxInputGroup,\r\n type ComboboxInputGroupProps,\r\n type ComboboxInputProps,\r\n ComboboxItem,\r\n ComboboxItemIndicator,\r\n type ComboboxItemIndicatorProps,\r\n type ComboboxItemProps,\r\n ComboboxLabel,\r\n type ComboboxLabelProps,\r\n ComboboxList,\r\n type ComboboxListProps,\r\n ComboboxPopup,\r\n type ComboboxPopupProps,\r\n ComboboxPortal,\r\n type ComboboxPortalProps,\r\n ComboboxPositioner,\r\n type ComboboxPositionerProps,\r\n type ComboboxProps,\r\n ComboboxRow,\r\n type ComboboxRowProps,\r\n ComboboxSeparator,\r\n type ComboboxSeparatorProps,\r\n ComboboxStatus,\r\n type ComboboxStatusProps,\r\n ComboboxTrigger,\r\n type ComboboxTriggerProps,\r\n ComboboxValue,\r\n type ComboboxValueProps,\r\n useCombobox,\r\n useComboboxActiveValue,\r\n}"]}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import'react';import {mergeProps}from'@base-ui/react/merge-props';import {useRender}from'@base-ui/react/use-render';import {cva}from'class-variance-authority';import {XIcon}from'lucide-react';import {cn}from'@xploreu/lib/cn';import {jsx}from'react/jsx-runtime';var c=cva("inline-flex items-center justify-center size-max whitespace-nowrap shrink-0 overflow-hidden transition-colors ring-1 ring-inset",{variants:{type:{rounded:"rounded-xp-full",square:"rounded-xp-card-base-sm",modern:"rounded-xp-card-base-sm shadow-xp-xs"},color:{gray:"bg-utility-gray-50 text-utility-gray-700 ring-utility-gray-200",brand:"bg-utility-brand-50 text-utility-brand-700 ring-utility-brand-200",error:"bg-utility-error-50 text-utility-error-700 ring-utility-error-200",warning:"bg-utility-warning-50 text-utility-warning-700 ring-utility-warning-200",success:"bg-utility-success-50 text-utility-success-700 ring-utility-success-200","gray-blue":"bg-utility-gray-blue-50 text-utility-gray-blue-700 ring-utility-gray-blue-200","blue-light":"bg-utility-blue-light-50 text-utility-blue-light-700 ring-utility-blue-light-200",blue:"bg-utility-blue-50 text-utility-blue-700 ring-utility-blue-200",indigo:"bg-utility-indigo-50 text-utility-indigo-700 ring-utility-indigo-200",purple:"bg-utility-purple-50 text-utility-purple-700 ring-utility-purple-200",pink:"bg-utility-pink-50 text-utility-pink-700 ring-utility-pink-200",orange:"bg-utility-orange-50 text-utility-orange-700 ring-utility-orange-200"},size:{xs:["text-tiny-medium py-0.5 gap-1","[&_[data-slot=badge-icon]]:size-2.5 [&_[data-slot=badge-avatar]]:size-3"],sm:["text-body-medium-3 py-0.5 gap-1","[&_[data-slot=badge-icon]]:size-3 [&_[data-slot=badge-avatar]]:size-4"],md:["text-body-medium-2 py-0.5 gap-1.5","[&_[data-slot=badge-icon]]:size-3.5 [&_[data-slot=badge-avatar]]:size-4"],lg:["text-body-medium-2 py-1 gap-1.5","[&_[data-slot=badge-icon]]:size-3.5 [&_[data-slot=badge-avatar]]:size-4.5"]}},compoundVariants:[{type:"modern",className:"bg-bg-primary text-text-secondary ring-border-primary"},{type:"rounded",size:"xs",className:["px-1.5","has-[[data-slot=badge-icon]:not([data-position=trailing])]:pl-1","has-[[data-slot=badge-dot]]:pl-1","has-[[data-slot=badge-avatar]]:pl-0.5","has-[[data-slot=badge-icon][data-position=trailing]]:pr-1","has-[[data-slot=badge-close]]:pr-0.5"]},{type:"rounded",size:"sm",className:["px-2","has-[[data-slot=badge-icon]:not([data-position=trailing])]:pl-1.5","has-[[data-slot=badge-dot]]:pl-1.5","has-[[data-slot=badge-avatar]]:pl-0.75","has-[[data-slot=badge-icon][data-position=trailing]]:pr-1.5","has-[[data-slot=badge-close]]:pr-0.75"]},{type:"rounded",size:"md",className:["px-2.5","has-[[data-slot=badge-icon]:not([data-position=trailing])]:pl-2","has-[[data-slot=badge-dot]]:pl-2","has-[[data-slot=badge-avatar]]:pl-1","has-[[data-slot=badge-icon][data-position=trailing]]:pr-2","has-[[data-slot=badge-close]]:pr-1"]},{type:"rounded",size:"lg",className:["px-3","has-[[data-slot=badge-icon]:not([data-position=trailing])]:pl-2.5","has-[[data-slot=badge-dot]]:pl-2.5","has-[[data-slot=badge-avatar]]:pl-1.5","has-[[data-slot=badge-icon][data-position=trailing]]:pr-2.5","has-[[data-slot=badge-close]]:pr-1.5"]},{type:"square",size:"xs",className:["px-1","has-[[data-slot=badge-icon]:not([data-position=trailing])]:pl-0.75","has-[[data-slot=badge-dot]]:pl-0.75","has-[[data-slot=badge-avatar]]:pl-0.5","has-[[data-slot=badge-icon][data-position=trailing]]:pr-0.75","has-[[data-slot=badge-close]]:pr-0.5"]},{type:"square",size:"sm",className:["px-1.5","has-[[data-slot=badge-icon]:not([data-position=trailing])]:pl-1","has-[[data-slot=badge-dot]]:pl-1","has-[[data-slot=badge-avatar]]:pl-1","has-[[data-slot=badge-icon][data-position=trailing]]:pr-1","has-[[data-slot=badge-close]]:pr-0.5"]},{type:"square",size:"md",className:["px-2","has-[[data-slot=badge-icon]:not([data-position=trailing])]:pl-1.5","has-[[data-slot=badge-dot]]:pl-1.5","has-[[data-slot=badge-avatar]]:pl-1.5","has-[[data-slot=badge-icon][data-position=trailing]]:pr-1.5","has-[[data-slot=badge-close]]:pr-0.75"]},{type:"square",size:"lg",className:["px-2.5","has-[[data-slot=badge-icon]:not([data-position=trailing])]:pl-2","has-[[data-slot=badge-dot]]:pl-2","has-[[data-slot=badge-avatar]]:pl-2","has-[[data-slot=badge-icon][data-position=trailing]]:pr-2","has-[[data-slot=badge-close]]:pr-1"]},{type:"modern",size:"xs",className:["px-1","has-[[data-slot=badge-icon]:not([data-position=trailing])]:pl-0.75","has-[[data-slot=badge-dot]]:pl-0.75","has-[[data-slot=badge-avatar]]:pl-0.5","has-[[data-slot=badge-icon][data-position=trailing]]:pr-0.75","has-[[data-slot=badge-close]]:pr-0.5"]},{type:"modern",size:"sm",className:["px-1.5","has-[[data-slot=badge-icon]:not([data-position=trailing])]:pl-1","has-[[data-slot=badge-dot]]:pl-1","has-[[data-slot=badge-avatar]]:pl-1","has-[[data-slot=badge-icon][data-position=trailing]]:pr-1","has-[[data-slot=badge-close]]:pr-0.5"]},{type:"modern",size:"md",className:["px-2","has-[[data-slot=badge-icon]:not([data-position=trailing])]:pl-1.5","has-[[data-slot=badge-dot]]:pl-1.5","has-[[data-slot=badge-avatar]]:pl-1.5","has-[[data-slot=badge-icon][data-position=trailing]]:pr-1.5","has-[[data-slot=badge-close]]:pr-0.75"]},{type:"modern",size:"lg",className:["px-2.5","has-[[data-slot=badge-icon]:not([data-position=trailing])]:pl-2","has-[[data-slot=badge-dot]]:pl-2","has-[[data-slot=badge-avatar]]:pl-2","has-[[data-slot=badge-icon][data-position=trailing]]:pr-2","has-[[data-slot=badge-close]]:pr-1"]}],defaultVariants:{type:"square",color:"gray",size:"md"}});function v({className:t,type:a,color:e,size:s,render:d,...r}){let p={"data-slot":"badge",className:cn(c({type:a,color:e,size:s}),t)};return useRender({defaultTagName:"span",props:mergeProps(p,r),render:d,state:{slot:"badge",type:a,color:e,size:s}})}function z({className:t,position:a="leading",children:e,...s}){return jsx("span",{"data-slot":"badge-icon","data-position":a,className:cn("inline-flex shrink-0 items-center justify-center pointer-events-none [&>svg]:size-full",t),...s,children:e})}function N({className:t,alt:a="",...e}){return jsx("img",{"data-slot":"badge-avatar",alt:a,className:cn("shrink-0 rounded-xp-full object-cover",t),...e})}function P({className:t,render:a,align:e="inline-end",...s}){let d={"data-slot":"badge-close","data-align":e,className:cn("p-0.5 inline-flex items-center justify-center rounded-xp-full hover:opacity-75 focus-visible:outline-none shrink-0 [&>svg]:size-2.5",t),type:"button",children:jsx(XIcon,{})};return useRender({defaultTagName:"button",render:a,props:mergeProps(d,s),state:{slot:"badge-close",align:e}})}function B({className:t,...a}){return jsx("span",{"data-slot":"badge-dot",className:cn("size-1.5 shrink-0 rounded-xp-full bg-current",t),...a})}export{c as a,v as b,z as c,N as d,P as e,B as f};//# sourceMappingURL=chunk-JLZNZFOO.js.map
|
|
2
|
+
//# sourceMappingURL=chunk-JLZNZFOO.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/ui/badge.tsx"],"names":["badgeVariants","cva","Badge","className","type","color","size","render","props","defaultProps","cn","useRender","mergeProps","BadgeIcon","position","children","jsx","BadgeAvatar","alt","BadgeButton","align","XIcon","BadgeDot"],"mappings":"qQASA,IAAMA,CAAAA,CAAgBC,GAAAA,CACpB,iIAAA,CACA,CACE,QAAA,CAAU,CACR,IAAA,CAAM,CACJ,OAAA,CAAW,iBAAA,CACX,MAAA,CAAU,yBAAA,CACV,MAAA,CAAU,sCACZ,CAAA,CACA,KAAA,CAAO,CACL,IAAA,CAAM,gEAAA,CACN,KAAA,CAAO,mEAAA,CACP,KAAA,CAAO,mEAAA,CACP,OAAA,CAAS,yEAAA,CACT,OAAA,CAAS,yEAAA,CACT,WAAA,CAAa,+EAAA,CACb,YAAA,CAAc,kFAAA,CACd,IAAA,CAAM,gEAAA,CACN,MAAA,CAAQ,uEACR,MAAA,CAAQ,sEAAA,CACR,IAAA,CAAM,gEAAA,CACN,MAAA,CAAQ,sEACV,CAAA,CACA,IAAA,CAAM,CACJ,EAAA,CAAI,CACF,+BAAA,CACA,yEACF,CAAA,CACA,EAAA,CAAI,CACF,iCAAA,CACA,uEACF,CAAA,CACA,EAAA,CAAI,CACF,mCAAA,CACA,yEACF,CAAA,CACA,EAAA,CAAI,CACF,iCAAA,CACA,2EACF,CACF,CACF,EACA,gBAAA,CAAkB,CAChB,CACE,IAAA,CAAM,QAAA,CACN,SAAA,CAAW,uDACb,CAAA,CAEA,CACE,IAAA,CAAM,SAAA,CACN,IAAA,CAAM,IAAA,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AnB,CAAAA,CACA,GAAGK,CACL,CAAA,CAAiC,CAC/B,OACEQ,GAAAA,CAAC,MAAA,CAAA,CACC,WAAA,CAAU,WAAA,CACV,SAAA,CAAWN,EAAAA,CAAG,8CAAA,CAAgDP,CAAS,CAAA,CACtE,GAAGK,CAAAA,CACN,CAEJ","file":"chunk-JLZNZFOO.js","sourcesContent":["import * as React from \"react\"\r\n\r\nimport { mergeProps } from \"@base-ui/react/merge-props\"\r\nimport { useRender } from \"@base-ui/react/use-render\"\r\nimport { cva, type VariantProps } from \"class-variance-authority\"\r\nimport { XIcon } from \"lucide-react\"\r\n\r\nimport { cn } from \"@xploreu/lib/cn\"\r\n\r\nconst badgeVariants = cva(\r\n \"inline-flex items-center justify-center size-max whitespace-nowrap shrink-0 overflow-hidden transition-colors ring-1 ring-inset\",\r\n {\r\n variants: {\r\n type: {\r\n \"rounded\": \"rounded-xp-full\",\r\n \"square\": \"rounded-xp-card-base-sm\",\r\n \"modern\": \"rounded-xp-card-base-sm shadow-xp-xs\",\r\n },\r\n color: {\r\n gray: \"bg-utility-gray-50 text-utility-gray-700 ring-utility-gray-200\",\r\n brand: \"bg-utility-brand-50 text-utility-brand-700 ring-utility-brand-200\",\r\n error: \"bg-utility-error-50 text-utility-error-700 ring-utility-error-200\",\r\n warning: \"bg-utility-warning-50 text-utility-warning-700 ring-utility-warning-200\",\r\n success: \"bg-utility-success-50 text-utility-success-700 ring-utility-success-200\",\r\n \"gray-blue\": \"bg-utility-gray-blue-50 text-utility-gray-blue-700 ring-utility-gray-blue-200\",\r\n \"blue-light\": \"bg-utility-blue-light-50 text-utility-blue-light-700 ring-utility-blue-light-200\",\r\n blue: \"bg-utility-blue-50 text-utility-blue-700 ring-utility-blue-200\",\r\n indigo: \"bg-utility-indigo-50 text-utility-indigo-700 ring-utility-indigo-200\",\r\n purple: \"bg-utility-purple-50 text-utility-purple-700 ring-utility-purple-200\",\r\n pink: \"bg-utility-pink-50 text-utility-pink-700 ring-utility-pink-200\",\r\n orange: \"bg-utility-orange-50 text-utility-orange-700 ring-utility-orange-200\",\r\n },\r\n size: {\r\n xs: [\r\n \"text-tiny-medium py-0.5 gap-1\",\r\n \"[&_[data-slot=badge-icon]]:size-2.5 [&_[data-slot=badge-avatar]]:size-3\",\r\n ],\r\n sm: [\r\n \"text-body-medium-3 py-0.5 gap-1\",\r\n \"[&_[data-slot=badge-icon]]:size-3 [&_[data-slot=badge-avatar]]:size-4\",\r\n ],\r\n md: [\r\n \"text-body-medium-2 py-0.5 gap-1.5\",\r\n \"[&_[data-slot=badge-icon]]:size-3.5 [&_[data-slot=badge-avatar]]:size-4\",\r\n ],\r\n lg: [\r\n \"text-body-medium-2 py-1 gap-1.5\",\r\n \"[&_[data-slot=badge-icon]]:size-3.5 [&_[data-slot=badge-avatar]]:size-4.5\",\r\n ],\r\n },\r\n },\r\n compoundVariants: [\r\n {\r\n type: \"modern\",\r\n className: \"bg-bg-primary text-text-secondary ring-border-primary\",\r\n },\r\n // Rounded (Pill) Variants - Untitled UI exact paddings\r\n {\r\n type: \"rounded\",\r\n size: \"xs\",\r\n className: [\r\n \"px-1.5\",\r\n \"has-[[data-slot=badge-icon]:not([data-position=trailing])]:pl-1\",\r\n \"has-[[data-slot=badge-dot]]:pl-1\",\r\n \"has-[[data-slot=badge-avatar]]:pl-0.5\",\r\n \"has-[[data-slot=badge-icon][data-position=trailing]]:pr-1\",\r\n \"has-[[data-slot=badge-close]]:pr-0.5\",\r\n ],\r\n },\r\n {\r\n type: \"rounded\",\r\n size: \"sm\",\r\n className: [\r\n \"px-2\",\r\n \"has-[[data-slot=badge-icon]:not([data-position=trailing])]:pl-1.5\",\r\n \"has-[[data-slot=badge-dot]]:pl-1.5\",\r\n \"has-[[data-slot=badge-avatar]]:pl-0.75\",\r\n \"has-[[data-slot=badge-icon][data-position=trailing]]:pr-1.5\",\r\n \"has-[[data-slot=badge-close]]:pr-0.75\",\r\n ],\r\n },\r\n {\r\n type: \"rounded\",\r\n size: \"md\",\r\n className: [\r\n \"px-2.5\",\r\n \"has-[[data-slot=badge-icon]:not([data-position=trailing])]:pl-2\",\r\n \"has-[[data-slot=badge-dot]]:pl-2\",\r\n \"has-[[data-slot=badge-avatar]]:pl-1\",\r\n \"has-[[data-slot=badge-icon][data-position=trailing]]:pr-2\",\r\n \"has-[[data-slot=badge-close]]:pr-1\",\r\n ],\r\n },\r\n {\r\n type: \"rounded\",\r\n size: \"lg\",\r\n className: [\r\n \"px-3\",\r\n \"has-[[data-slot=badge-icon]:not([data-position=trailing])]:pl-2.5\",\r\n \"has-[[data-slot=badge-dot]]:pl-2.5\",\r\n \"has-[[data-slot=badge-avatar]]:pl-1.5\",\r\n \"has-[[data-slot=badge-icon][data-position=trailing]]:pr-2.5\",\r\n \"has-[[data-slot=badge-close]]:pr-1.5\",\r\n ],\r\n },\r\n // Square & Modern Variants - Untitled UI exact paddings\r\n {\r\n type: \"square\",\r\n size: \"xs\",\r\n className: [\r\n \"px-1\",\r\n \"has-[[data-slot=badge-icon]:not([data-position=trailing])]:pl-0.75\",\r\n \"has-[[data-slot=badge-dot]]:pl-0.75\",\r\n \"has-[[data-slot=badge-avatar]]:pl-0.5\",\r\n \"has-[[data-slot=badge-icon][data-position=trailing]]:pr-0.75\",\r\n \"has-[[data-slot=badge-close]]:pr-0.5\",\r\n ],\r\n },\r\n {\r\n type: \"square\",\r\n size: \"sm\",\r\n className: [\r\n \"px-1.5\",\r\n \"has-[[data-slot=badge-icon]:not([data-position=trailing])]:pl-1\",\r\n \"has-[[data-slot=badge-dot]]:pl-1\",\r\n \"has-[[data-slot=badge-avatar]]:pl-1\",\r\n \"has-[[data-slot=badge-icon][data-position=trailing]]:pr-1\",\r\n \"has-[[data-slot=badge-close]]:pr-0.5\",\r\n ],\r\n },\r\n {\r\n type: \"square\",\r\n size: \"md\",\r\n className: [\r\n \"px-2\",\r\n \"has-[[data-slot=badge-icon]:not([data-position=trailing])]:pl-1.5\",\r\n \"has-[[data-slot=badge-dot]]:pl-1.5\",\r\n \"has-[[data-slot=badge-avatar]]:pl-1.5\",\r\n \"has-[[data-slot=badge-icon][data-position=trailing]]:pr-1.5\",\r\n \"has-[[data-slot=badge-close]]:pr-0.75\",\r\n ],\r\n },\r\n {\r\n type: \"square\",\r\n size: \"lg\",\r\n className: [\r\n \"px-2.5\",\r\n \"has-[[data-slot=badge-icon]:not([data-position=trailing])]:pl-2\",\r\n \"has-[[data-slot=badge-dot]]:pl-2\",\r\n \"has-[[data-slot=badge-avatar]]:pl-2\",\r\n \"has-[[data-slot=badge-icon][data-position=trailing]]:pr-2\",\r\n \"has-[[data-slot=badge-close]]:pr-1\",\r\n ],\r\n },\r\n {\r\n type: \"modern\",\r\n size: \"xs\",\r\n className: [\r\n \"px-1\",\r\n \"has-[[data-slot=badge-icon]:not([data-position=trailing])]:pl-0.75\",\r\n \"has-[[data-slot=badge-dot]]:pl-0.75\",\r\n \"has-[[data-slot=badge-avatar]]:pl-0.5\",\r\n \"has-[[data-slot=badge-icon][data-position=trailing]]:pr-0.75\",\r\n \"has-[[data-slot=badge-close]]:pr-0.5\",\r\n ],\r\n },\r\n {\r\n type: \"modern\",\r\n size: \"sm\",\r\n className: [\r\n \"px-1.5\",\r\n \"has-[[data-slot=badge-icon]:not([data-position=trailing])]:pl-1\",\r\n \"has-[[data-slot=badge-dot]]:pl-1\",\r\n \"has-[[data-slot=badge-avatar]]:pl-1\",\r\n \"has-[[data-slot=badge-icon][data-position=trailing]]:pr-1\",\r\n \"has-[[data-slot=badge-close]]:pr-0.5\",\r\n ],\r\n },\r\n {\r\n type: \"modern\",\r\n size: \"md\",\r\n className: [\r\n \"px-2\",\r\n \"has-[[data-slot=badge-icon]:not([data-position=trailing])]:pl-1.5\",\r\n \"has-[[data-slot=badge-dot]]:pl-1.5\",\r\n \"has-[[data-slot=badge-avatar]]:pl-1.5\",\r\n \"has-[[data-slot=badge-icon][data-position=trailing]]:pr-1.5\",\r\n \"has-[[data-slot=badge-close]]:pr-0.75\",\r\n ],\r\n },\r\n {\r\n type: \"modern\",\r\n size: \"lg\",\r\n className: [\r\n \"px-2.5\",\r\n \"has-[[data-slot=badge-icon]:not([data-position=trailing])]:pl-2\",\r\n \"has-[[data-slot=badge-dot]]:pl-2\",\r\n \"has-[[data-slot=badge-avatar]]:pl-2\",\r\n \"has-[[data-slot=badge-icon][data-position=trailing]]:pr-2\",\r\n \"has-[[data-slot=badge-close]]:pr-1\",\r\n ],\r\n },\r\n ],\r\n defaultVariants: {\r\n type: \"square\",\r\n color: \"gray\",\r\n size: \"md\",\r\n },\r\n }\r\n)\r\n\r\nexport interface BadgeProps\r\n extends Omit<React.ComponentProps<\"span\">, \"color\">,\r\n VariantProps<typeof badgeVariants> {\r\n}\r\n\r\nfunction Badge({\r\n className,\r\n type,\r\n color,\r\n size,\r\n render,\r\n ...props\r\n}: BadgeProps & useRender.ComponentProps<\"span\">) {\r\n const defaultProps = {\r\n \"data-slot\": \"badge\",\r\n className: cn(badgeVariants({ type, color, size }), className),\r\n }\r\n\r\n return useRender({\r\n defaultTagName: \"span\",\r\n props: mergeProps(defaultProps, props),\r\n render,\r\n state: {\r\n slot: \"badge\",\r\n type,\r\n color,\r\n size,\r\n },\r\n })\r\n}\r\n\r\nexport interface BadgeIconProps extends React.ComponentProps<\"span\"> {\r\n children?: React.ReactNode\r\n position?: \"leading\" | \"trailing\"\r\n}\r\n\r\nfunction BadgeIcon({\r\n className,\r\n position = \"leading\",\r\n children,\r\n ...props\r\n}: BadgeIconProps) {\r\n return (\r\n <span\r\n data-slot=\"badge-icon\"\r\n data-position={position}\r\n className={cn(\"inline-flex shrink-0 items-center justify-center pointer-events-none [&>svg]:size-full\", className)}\r\n {...props}\r\n >\r\n {children}\r\n </span>\r\n )\r\n}\r\n\r\nexport interface BadgeAvatarProps extends React.ComponentProps<\"img\"> {\r\n src?: string\r\n alt?: string\r\n}\r\n\r\nfunction BadgeAvatar({\r\n className,\r\n alt = \"\",\r\n ...props\r\n}: BadgeAvatarProps) {\r\n return (\r\n <img\r\n data-slot=\"badge-avatar\"\r\n alt={alt}\r\n className={cn(\"shrink-0 rounded-xp-full object-cover\", className)}\r\n {...props}\r\n />\r\n )\r\n}\r\n\r\nexport interface BadgeButtonProps extends useRender.ComponentProps<\"button\"> {\r\n align?: \"inline-end\" | \"inline-start\"\r\n}\r\n\r\nfunction BadgeButton({\r\n className,\r\n render,\r\n align = \"inline-end\",\r\n ...props\r\n}: BadgeButtonProps) {\r\n const defaultProps = {\r\n \"data-slot\": \"badge-close\",\r\n \"data-align\": align,\r\n className: cn(\"p-0.5 inline-flex items-center justify-center rounded-xp-full hover:opacity-75 focus-visible:outline-none shrink-0 [&>svg]:size-2.5\", className),\r\n type: \"button\" as const,\r\n children: (\r\n <XIcon />\r\n ),\r\n }\r\n\r\n return useRender({\r\n defaultTagName: \"button\",\r\n render,\r\n props: mergeProps(defaultProps, props),\r\n state: {\r\n slot: \"badge-close\",\r\n align,\r\n }\r\n })\r\n}\r\n\r\nfunction BadgeDot({\r\n className,\r\n ...props\r\n}: React.ComponentProps<\"span\">) {\r\n return (\r\n <span\r\n data-slot=\"badge-dot\"\r\n className={cn(\"size-1.5 shrink-0 rounded-xp-full bg-current\", className)}\r\n {...props}\r\n />\r\n )\r\n}\r\n\r\nexport { Badge, BadgeIcon, BadgeAvatar, BadgeButton, BadgeDot, badgeVariants }\r\n"]}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {a,b as b$1,j as j$1,i,k,l,m,q,s,w,F}from'./chunk-
|
|
2
|
-
//# sourceMappingURL=chunk-
|
|
1
|
+
import {a,b as b$1,j as j$1,i,k,l,m,q,s,w,F}from'./chunk-EL7P7FN5.js';import {b}from'./chunk-JH6RZ3QH.js';import {g}from'./chunk-JILBFCPY.js';import*as r from'react';import {cn}from'@xploreu/lib/cn';import {SearchIcon,XIcon}from'lucide-react';import {useControlledState}from'@xploreu/hooks/use-controlled-state';import {jsxs,jsx,Fragment}from'react/jsx-runtime';function j({multiple:z=true,inputPlaceholder:B="Search...",container:q$1,items:u,infiniteScroll:A,isPending:H,taggable:c=false,maxVisible:i$1,...m$1}){let[h,g$1]=useControlledState({value:m$1?.inputValue?.toString(),defaultValue:m$1?.defaultInputValue?.toString(),onChange:m$1?.onInputValueChange}),[b$2,x]=useControlledState({value:m$1?.value??[],defaultValue:m$1?.defaultValue??[],onChange:m$1?.onValueChange}),[v,I]=r.useState([]),d=r.useRef(new Set);r.useEffect(()=>{let e=new Set(b$2.map(t=>t.value));I(t=>{let l=t.filter(a=>e.has(a.value));return l.length===t.length?t:(d.current=new Set(l.map(a=>a.value)),l)});},[b$2]);let n=h?.toString().trim()??"",U=r.useMemo(()=>n?b$2.some(e=>e.value.toLowerCase()===n.toLowerCase()):false,[n,b$2]),p=r.useMemo(()=>!c||!n?false:!u?.some(e=>e.label.toLowerCase()===n.toLowerCase()),[c,n,u]),X=r.useMemo(()=>{let e=[...u??[],...v];if(p){let t={label:n,value:n,tag:true};return [...e,t]}return e},[u,v,p,n]);return jsxs(a,{...m$1,behavior:"chip-outside",multiple:true,items:c?X:u,isItemEqualToValue:(e,t)=>e.value===t.value,onValueChange:(e,t)=>{if(c){let l=e.filter(a=>a?.tag===true&&!d.current.has(a.value));if(l.length>0){for(let a of l)d.current.add(a.value);I(a=>[...a,...l]);}}x(z?e:[e[e.length-1]],t);},onInputValueChange:g$1,children:[jsxs("div",{className:"flex flex-col gap-2",children:[jsx(g,{render:jsx(b,{className:"h-9 text-body-regular-3 pl-9 pr-7",endContent:jsx(b$1,{nativeButton:false,render:jsx(XIcon,{className:"!size-5 !right-1.5 data-[hidden=true]:opacity-0 opacity-100 transition-opacity duration-300 cursor-pointer","data-hidden":!h,"data-slot":"combobox-clear-input",onClick:e=>{g$1("",{reason:"none",event:e.nativeEvent,cancel:()=>{},allowPropagation:()=>{},isCanceled:false,isPropagationAllowed:true,trigger:void 0});}})}),placeholder:B,startContent:jsx(SearchIcon,{className:"!size-4 !text-fg-tertiary-hover"}),wrapperClassName:"w-full"})}),jsx(j$1,{className:cn(i$1!==void 0&&"flex-nowrap overflow-hidden"),onMouseDown:e=>e.preventBaseUIHandler(),children:jsx(i,{children:e=>{let t=i$1!==void 0?e.slice(0,i$1):e,l$1=i$1!==void 0?e.length-i$1:0;return jsxs(Fragment,{children:[t?.map(a=>jsxs(k,{className:cn(i$1!==void 0&&"min-w-0 shrink"),children:[i$1!==void 0?jsx("span",{className:"truncate",children:a?.label||""}):a?.label||"",jsx(l,{})]},a?.value||"")),l$1>0&&jsxs(k,{className:"shrink-0",children:["+",l$1]})]})}})})]}),jsxs(m,{container:q$1,children:[jsx(q,{status:H||u===void 0?"pending":u?.length===0&&!p?"empty":null}),jsxs(s,{children:[u?.map(e=>jsx(w,{value:{label:e.label,value:e.value},children:jsx("div",{className:"flex items-center gap-2 w-full min-w-0",children:jsx("span",{className:"truncate",children:e.label})})},e.value)),p&&jsx(w,{value:{label:n,value:n,tag:true},children:jsxs("div",{className:"flex items-center gap-1.5 w-full min-w-0",children:[!U&&jsx("span",{className:"text-text-secondary",children:"Create:"}),jsx("span",{className:"font-medium text-text-primary truncate",children:n})]})}),jsx(F,{...A})]})]})]})}export{j as a};//# sourceMappingURL=chunk-KYVYO45Y.js.map
|
|
2
|
+
//# sourceMappingURL=chunk-KYVYO45Y.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/composites/combobox-chip-outside.tsx"],"names":["ComboboxChipOutside","multiple","inputPlaceholder","container","items","infiniteScroll","isPending","taggable","maxVisible","props","inputValue","setInputValue","useControlledState","value","setValue","createdItems","setCreatedItems","createdValuesRef","currentValues","v","prev","next","item","trimmedInput","isInputSelected","isCreatingItem","combinedItems","base","createItem","jsxs","Combobox","a","b","eventDetails","newTags","tag","jsx","ComboboxInput","Input","ComboboxTrigger","XIcon","event","SearchIcon","ComboboxChips","cn","ComboboxValue","visible","overflow","Fragment","ComboboxChip","ComboboxChipRemove","ComboboxPopup","ComboboxStatus","ComboboxList","ComboboxItem","ComboboxInfi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AA,CAAA,SAAA,CAAO,CAAA,CAE/CA,GAAAA,CAAC,QAAK,SAAA,CAAU,wCAAA,CACb,QAAA,CAAAb,CAAAA,CACH,GACF,CAAA,CACF,CAAA,CAEFa,GAAAA,CAACmB,CAAAA,CAAA,CAAwB,GAAGlD,CAAAA,CAAgB,CAAA,CAAA,CAC9C,CAAA,CAAA,CACF,GACF,CAEJ","file":"chunk-DNO5M44I.js","sourcesContent":["import * as React from \"react\"\r\n\r\nimport { cn } from \"@xploreu/lib/cn\"\r\nimport { ComboboxInput as ComboboxInputPrimitive } from \"../primitives/combobox\"\r\nimport { Input } from \"../ui\"\r\nimport {\r\n Combobox,\r\n ComboboxChip,\r\n ComboboxChipRemove,\r\n ComboboxChips,\r\n ComboboxInfiniteScroll,\r\n ComboboxItem,\r\n ComboboxList,\r\n ComboboxPortal,\r\n ComboboxPopup,\r\n ComboboxStatus,\r\n ComboboxTrigger,\r\n ComboboxValue,\r\n type ComboboxProps\r\n} from \"../ui/combobox\"\r\nimport { SearchIcon, XIcon } from \"lucide-react\"\r\nimport { useControlledState } from \"@xploreu/hooks/use-controlled-state\"\r\n\r\ntype ComboboxChipOutsideProps<Value> = Omit<ComboboxProps<Value, true>, \"multiple\"> & {\r\n multiple?: boolean\r\n inputPlaceholder?: string\r\n container?: React.ComponentProps<typeof ComboboxPortal>[\"container\"]\r\n items: ({ label: string; value: string }[]) | undefined\r\n infiniteScroll?: React.ComponentProps<typeof ComboboxInfiniteScroll>\r\n isPending?: boolean\r\n /**\r\n * When true, enables creatable / taggable mode.\r\n * If the typed value has no exact match in the current item list,\r\n * a \"Create \\\"…\\\"\" option is shown at the top of the dropdown.\r\n * Created items are appended to the value with `{ label, value, tag: true }`.\r\n */\r\n taggable?: boolean\r\n /**\r\n * Maximum number of chips to show before collapsing the rest into a \"+N\" chip.\r\n * When undefined, all chips are shown.\r\n */\r\n maxVisible?: number\r\n}\r\n\r\nfunction ComboboxChipOutside<Value extends { label: string; value: string; tag?: true }>({\r\n multiple = true,\r\n inputPlaceholder = \"Search...\",\r\n container,\r\n items,\r\n infiniteScroll,\r\n isPending,\r\n taggable = false,\r\n maxVisible,\r\n ...props\r\n}: ComboboxChipOutsideProps<Value>) {\r\n const [inputValue, setInputValue] = useControlledState({\r\n value: props?.inputValue?.toString(),\r\n defaultValue: props?.defaultInputValue?.toString(),\r\n onChange: props?.onInputValueChange,\r\n })\r\n\r\n const [value, setValue] = useControlledState({\r\n value: props?.value ?? [],\r\n defaultValue: props?.defaultValue ?? [],\r\n onChange: props?.onValueChange,\r\n })\r\n\r\n // Track items created via taggable mode\r\n // Sync with value to avoid stale tags when controlled value is reset from outside\r\n const [createdItems, setCreatedItems] = React.useState<Value[]>([])\r\n const createdValuesRef = React.useRef<Set<string>>(new Set())\r\n\r\n React.useEffect(() => {\r\n const currentValues = new Set(value.map((v) => v.value))\r\n setCreatedItems((prev) => {\r\n const next = prev.filter((item) => currentValues.has(item.value))\r\n if (next.length === prev.length) return prev\r\n createdValuesRef.current = new Set(next.map((v) => v.value))\r\n return next\r\n })\r\n }, [value])\r\n\r\n // Determine if the current input has no exact match in existing items\r\n const trimmedInput = inputValue?.toString().trim() ?? \"\"\r\n const isInputSelected = React.useMemo(() => {\r\n if (!trimmedInput) return false\r\n return value.some(\r\n (item) => item.value.toLowerCase() === trimmedInput.toLowerCase()\r\n )\r\n }, [trimmedInput, value])\r\n // true = show the taggable item in dropdown (either as \"Create:\" or as checked item)\r\n const isCreatingItem = React.useMemo(() => {\r\n if (!taggable || !trimmedInput) return false\r\n return !items?.some(\r\n (item) => item.label.toLowerCase() === trimmedInput.toLowerCase()\r\n )\r\n }, [taggable, trimmedInput, items])\r\n\r\n // Merge server items with locally created tags + the \"Create\" placeholder\r\n const combinedItems = React.useMemo(() => {\r\n const base: Value[] = [\r\n ...items ?? [],\r\n ...createdItems,\r\n ]\r\n\r\n if (isCreatingItem) {\r\n const createItem = {\r\n label: trimmedInput,\r\n value: trimmedInput,\r\n tag: true,\r\n }\r\n return [...base, createItem]\r\n }\r\n\r\n return base\r\n }, [items, createdItems, isCreatingItem, trimmedInput])\r\n\r\n const handleValueChange: ComboboxProps<Value, true>[\"onValueChange\"] = (value, eventDetails) => {\r\n // Capture newly created taggable items internally\r\n if (taggable) {\r\n const newTags = value.filter(\r\n (v) => v?.tag === true\r\n && !createdValuesRef.current.has(v.value)\r\n )\r\n if (newTags.length > 0) {\r\n for (const tag of newTags) {\r\n createdValuesRef.current.add(tag.value)\r\n }\r\n setCreatedItems((prev) => [...prev, ...newTags])\r\n }\r\n }\r\n\r\n // if multiple is false, we need to replace the value with the new value instead of adding to it\r\n if (!multiple) {\r\n setValue([value[value.length - 1]], eventDetails)\r\n } else {\r\n setValue(value, eventDetails)\r\n }\r\n }\r\n\r\n return (\r\n <Combobox\r\n {...props}\r\n behavior=\"chip-outside\"\r\n multiple\r\n items={taggable ? combinedItems : items}\r\n isItemEqualToValue={(a, b) => a.value === b.value}\r\n onValueChange={handleValueChange}\r\n onInputValueChange={setInputValue}\r\n >\r\n <div className=\"flex flex-col gap-2\">\r\n <ComboboxInputPrimitive\r\n render={\r\n <Input\r\n className=\"h-9 text-body-regular-3 pl-9 pr-7\"\r\n endContent={\r\n <ComboboxTrigger\r\n nativeButton={false}\r\n render={(\r\n <XIcon\r\n className=\"!size-5 !right-1.5 data-[hidden=true]:opacity-0 opacity-100 transition-opacity duration-300 cursor-pointer\"\r\n data-hidden={!inputValue}\r\n data-slot=\"combobox-clear-input\"\r\n onClick={(event) => {\r\n setInputValue(\"\", {\r\n reason: \"none\",\r\n event: event.nativeEvent,\r\n cancel: () => { },\r\n allowPropagation: () => { },\r\n isCanceled: false,\r\n isPropagationAllowed: true,\r\n trigger: undefined,\r\n })\r\n }}\r\n />\r\n )}\r\n />\r\n }\r\n placeholder={inputPlaceholder}\r\n startContent={<SearchIcon className=\"!size-4 !text-fg-tertiary-hover\" />}\r\n wrapperClassName=\"w-full\"\r\n />\r\n }\r\n />\r\n <ComboboxChips\r\n className={cn(maxVisible !== undefined && \"flex-nowrap overflow-hidden\")}\r\n onMouseDown={(e) => e.preventBaseUIHandler()}\r\n >\r\n <ComboboxValue>\r\n {(value: Value[]) => {\r\n const visible = maxVisible !== undefined ? value.slice(0, maxVisible) : value\r\n const overflow = maxVisible !== undefined ? value.length - maxVisible : 0\r\n return (\r\n <>\r\n {visible?.map((item) => (\r\n <ComboboxChip\r\n key={item?.value || \"\"}\r\n className={cn(maxVisible !== undefined && \"min-w-0 shrink\")}\r\n >\r\n {maxVisible !== undefined\r\n ? <span className=\"truncate\">{item?.label || \"\"}</span>\r\n : (item?.label || \"\")\r\n }\r\n <ComboboxChipRemove />\r\n </ComboboxChip>\r\n ))}\r\n {overflow > 0 && (\r\n <ComboboxChip className=\"shrink-0\">\r\n +{overflow}\r\n </ComboboxChip>\r\n )}\r\n </>\r\n )\r\n }}\r\n </ComboboxValue>\r\n </ComboboxChips>\r\n </div>\r\n <ComboboxPopup container={container}>\r\n <ComboboxStatus\r\n status={\r\n isPending || items === undefined\r\n ? \"pending\"\r\n : items?.length === 0 && !isCreatingItem\r\n ? \"empty\"\r\n : null\r\n }\r\n />\r\n <ComboboxList>\r\n {items?.map((item) => (\r\n <ComboboxItem\r\n key={item.value}\r\n value={{ label: item.label, value: item.value }}\r\n >\r\n <div className=\"flex items-center gap-2 w-full min-w-0\">\r\n <span className=\"truncate\">\r\n {item.label}\r\n </span>\r\n </div>\r\n </ComboboxItem>\r\n ))}\r\n {isCreatingItem && (\r\n <ComboboxItem\r\n value={{ label: trimmedInput, value: trimmedInput, tag: true }}\r\n >\r\n <div className=\"flex items-center gap-1.5 w-full min-w-0\">\r\n {!isInputSelected && (\r\n <span className=\"text-text-secondary\">Create:</span>\r\n )}\r\n <span className=\"font-medium text-text-primary truncate\">\r\n {trimmedInput}\r\n </span>\r\n </div>\r\n </ComboboxItem>\r\n )}\r\n <ComboboxInfiniteScroll {...infiniteScroll} />\r\n </ComboboxList>\r\n </ComboboxPopup>\r\n </Combobox>\r\n )\r\n}\r\n\r\nexport { ComboboxChipOutside }"]}
|
|
1
|
+
{"version":3,"sources":["../src/composites/combobox-chip-outside.tsx"],"names":["ComboboxChipOutside","multiple","inputPlaceholder","container","items","infiniteScroll","isPending","taggable","maxVisible","props","inputValue","setInputValue","useControlledState","value","setValue","createdItems","setCreatedItems","createdValuesRef","currentValues","v","prev","next","item","trimmedInput","isInputSelected","isCreatingItem","combinedItems","base","createItem","jsxs","Combobox","a","b","eventDetails","newTags","tag","jsx","ComboboxInput","Input","ComboboxTrigger","XIcon","event","SearchIcon","ComboboxChips","cn","ComboboxValue","visible","overflow","Fragment","ComboboxChip","ComboboxChipRemove","ComboboxPopup","ComboboxStatus","ComboboxList","ComboboxItem","ComboboxInfiniteScroll"],"mappings":"0WA4CA,SAASA,CAAAA,CAAgF,CACvF,QAAA,CAAAC,EAAW,IAAA,CACX,gBAAA,CAAAC,CAAAA,CAAmB,WAAA,CACnB,UAAAC,GAAAA,CACA,KAAA,CAAAC,CAAAA,CACA,cAAA,CAAAC,CAAAA,CACA,SAAA,CAAAC,CAAAA,CACA,QAAA,CAAAC,EAAW,KAAA,CACX,UAAA,CAAAC,GAAAA,CACA,GAAGC,GACL,CAAA,CAAoC,CAClC,GAAM,CAACC,EAAYC,GAAa,CAAA,CAAIC,kBAAAA,CAAmB,CACrD,MAAOH,GAAAA,EAAO,UAAA,EAAY,QAAA,EAAS,CACnC,aAAcA,GAAAA,EAAO,iBAAA,EAAmB,QAAA,EAAS,CACjD,SAAUA,GAAAA,EAAO,kBACnB,CAAC,CAAA,CAEK,CAACI,GAAAA,CAAOC,CAAQ,CAAA,CAAIF,kBAAAA,CAAmB,CAC3C,KAAA,CAAOH,GAAAA,EAAO,KAAA,EAAS,EAAC,CACxB,YAAA,CAAcA,GAAAA,EAAO,YAAA,EAAgB,EAAC,CACtC,QAAA,CAAUA,GAAAA,EAAO,aACnB,CAAC,CAAA,CAIK,CAACM,CAAAA,CAAcC,CAAe,EAAU,CAAA,CAAA,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,CACb,QAAA,CAAAA,GAAAA,CAAC,QAAK,SAAA,CAAU,UAAA,CACb,QAAA,CAAAd,CAAAA,CAAK,MACR,CAAA,CACF,CAAA,CAAA,CAPKA,CAAAA,CAAK,KAQZ,CACD,CAAA,CACAG,CAAAA,EACCW,GAAAA,CAACkB,CAAAA,CAAA,CACC,KAAA,CAAO,CAAE,KAAA,CAAO/B,CAAAA,CAAc,KAAA,CAAOA,CAAAA,CAAc,GAAA,CAAK,IAAK,EAE7D,QAAA,CAAAM,IAAAA,CAAC,KAAA,CAAA,CAAI,SAAA,CAAU,2CACZ,QAAA,CAAA,CAAA,CAACL,CAAAA,EACAY,GAAAA,CAAC,MAAA,CAAA,CAAK,UAAU,qBAAA,CAAsB,QAAA,CAAA,SAAA,CAAO,CAAA,CAE/CA,GAAAA,CAAC,QAAK,SAAA,CAAU,wCAAA,CACb,QAAA,CAAAb,CAAAA,CACH,GACF,CAAA,CACF,CAAA,CAEFa,GAAAA,CAACmB,CAAAA,CAAA,CAAwB,GAAGlD,CAAAA,CAAgB,CAAA,CAAA,CAC9C,CAAA,CAAA,CACF,GACF,CAEJ","file":"chunk-KYVYO45Y.js","sourcesContent":["import * as React from \"react\"\r\n\r\nimport { cn } from \"@xploreu/lib/cn\"\r\nimport { ComboboxInput as ComboboxInputPrimitive } from \"../primitives/combobox\"\r\nimport { Input } from \"../ui\"\r\nimport {\r\n Combobox,\r\n ComboboxChip,\r\n ComboboxChipRemove,\r\n ComboboxChips,\r\n ComboboxInfiniteScroll,\r\n ComboboxItem,\r\n ComboboxList,\r\n ComboboxPortal,\r\n ComboboxPopup,\r\n ComboboxStatus,\r\n ComboboxTrigger,\r\n ComboboxValue,\r\n type ComboboxProps\r\n} from \"../ui/combobox\"\r\nimport { SearchIcon, XIcon } from \"lucide-react\"\r\nimport { useControlledState } from \"@xploreu/hooks/use-controlled-state\"\r\n\r\ntype ComboboxChipOutsideProps<Value> = Omit<ComboboxProps<Value, true>, \"multiple\"> & {\r\n multiple?: boolean\r\n inputPlaceholder?: string\r\n container?: React.ComponentProps<typeof ComboboxPortal>[\"container\"]\r\n items: ({ label: string; value: string }[]) | undefined\r\n infiniteScroll?: React.ComponentProps<typeof ComboboxInfiniteScroll>\r\n isPending?: boolean\r\n /**\r\n * When true, enables creatable / taggable mode.\r\n * If the typed value has no exact match in the current item list,\r\n * a \"Create \\\"…\\\"\" option is shown at the top of the dropdown.\r\n * Created items are appended to the value with `{ label, value, tag: true }`.\r\n */\r\n taggable?: boolean\r\n /**\r\n * Maximum number of chips to show before collapsing the rest into a \"+N\" chip.\r\n * When undefined, all chips are shown.\r\n */\r\n maxVisible?: number\r\n}\r\n\r\nfunction ComboboxChipOutside<Value extends { label: string; value: string; tag?: true }>({\r\n multiple = true,\r\n inputPlaceholder = \"Search...\",\r\n container,\r\n items,\r\n infiniteScroll,\r\n isPending,\r\n taggable = false,\r\n maxVisible,\r\n ...props\r\n}: ComboboxChipOutsideProps<Value>) {\r\n const [inputValue, setInputValue] = useControlledState({\r\n value: props?.inputValue?.toString(),\r\n defaultValue: props?.defaultInputValue?.toString(),\r\n onChange: props?.onInputValueChange,\r\n })\r\n\r\n const [value, setValue] = useControlledState({\r\n value: props?.value ?? [],\r\n defaultValue: props?.defaultValue ?? [],\r\n onChange: props?.onValueChange,\r\n })\r\n\r\n // Track items created via taggable mode\r\n // Sync with value to avoid stale tags when controlled value is reset from outside\r\n const [createdItems, setCreatedItems] = React.useState<Value[]>([])\r\n const createdValuesRef = React.useRef<Set<string>>(new Set())\r\n\r\n React.useEffect(() => {\r\n const currentValues = new Set(value.map((v) => v.value))\r\n setCreatedItems((prev) => {\r\n const next = prev.filter((item) => currentValues.has(item.value))\r\n if (next.length === prev.length) return prev\r\n createdValuesRef.current = new Set(next.map((v) => v.value))\r\n return next\r\n })\r\n }, [value])\r\n\r\n // Determine if the current input has no exact match in existing items\r\n const trimmedInput = inputValue?.toString().trim() ?? \"\"\r\n const isInputSelected = React.useMemo(() => {\r\n if (!trimmedInput) return false\r\n return value.some(\r\n (item) => item.value.toLowerCase() === trimmedInput.toLowerCase()\r\n )\r\n }, [trimmedInput, value])\r\n // true = show the taggable item in dropdown (either as \"Create:\" or as checked item)\r\n const isCreatingItem = React.useMemo(() => {\r\n if (!taggable || !trimmedInput) return false\r\n return !items?.some(\r\n (item) => item.label.toLowerCase() === trimmedInput.toLowerCase()\r\n )\r\n }, [taggable, trimmedInput, items])\r\n\r\n // Merge server items with locally created tags + the \"Create\" placeholder\r\n const combinedItems = React.useMemo(() => {\r\n const base: Value[] = [\r\n ...items ?? [],\r\n ...createdItems,\r\n ]\r\n\r\n if (isCreatingItem) {\r\n const createItem = {\r\n label: trimmedInput,\r\n value: trimmedInput,\r\n tag: true,\r\n }\r\n return [...base, createItem]\r\n }\r\n\r\n return base\r\n }, [items, createdItems, isCreatingItem, trimmedInput])\r\n\r\n const handleValueChange: ComboboxProps<Value, true>[\"onValueChange\"] = (value, eventDetails) => {\r\n // Capture newly created taggable items internally\r\n if (taggable) {\r\n const newTags = value.filter(\r\n (v) => v?.tag === true\r\n && !createdValuesRef.current.has(v.value)\r\n )\r\n if (newTags.length > 0) {\r\n for (const tag of newTags) {\r\n createdValuesRef.current.add(tag.value)\r\n }\r\n setCreatedItems((prev) => [...prev, ...newTags])\r\n }\r\n }\r\n\r\n // if multiple is false, we need to replace the value with the new value instead of adding to it\r\n if (!multiple) {\r\n setValue([value[value.length - 1]], eventDetails)\r\n } else {\r\n setValue(value, eventDetails)\r\n }\r\n }\r\n\r\n return (\r\n <Combobox\r\n {...props}\r\n behavior=\"chip-outside\"\r\n multiple\r\n items={taggable ? combinedItems : items}\r\n isItemEqualToValue={(a, b) => a.value === b.value}\r\n onValueChange={handleValueChange}\r\n onInputValueChange={setInputValue}\r\n >\r\n <div className=\"flex flex-col gap-2\">\r\n <ComboboxInputPrimitive\r\n render={\r\n <Input\r\n className=\"h-9 text-body-regular-3 pl-9 pr-7\"\r\n endContent={\r\n <ComboboxTrigger\r\n nativeButton={false}\r\n render={(\r\n <XIcon\r\n className=\"!size-5 !right-1.5 data-[hidden=true]:opacity-0 opacity-100 transition-opacity duration-300 cursor-pointer\"\r\n data-hidden={!inputValue}\r\n data-slot=\"combobox-clear-input\"\r\n onClick={(event) => {\r\n setInputValue(\"\", {\r\n reason: \"none\",\r\n event: event.nativeEvent,\r\n cancel: () => { },\r\n allowPropagation: () => { },\r\n isCanceled: false,\r\n isPropagationAllowed: true,\r\n trigger: undefined,\r\n })\r\n }}\r\n />\r\n )}\r\n />\r\n }\r\n placeholder={inputPlaceholder}\r\n startContent={<SearchIcon className=\"!size-4 !text-fg-tertiary-hover\" />}\r\n wrapperClassName=\"w-full\"\r\n />\r\n }\r\n />\r\n <ComboboxChips\r\n className={cn(maxVisible !== undefined && \"flex-nowrap overflow-hidden\")}\r\n onMouseDown={(e) => e.preventBaseUIHandler()}\r\n >\r\n <ComboboxValue>\r\n {(value: Value[]) => {\r\n const visible = maxVisible !== undefined ? value.slice(0, maxVisible) : value\r\n const overflow = maxVisible !== undefined ? value.length - maxVisible : 0\r\n return (\r\n <>\r\n {visible?.map((item) => (\r\n <ComboboxChip\r\n key={item?.value || \"\"}\r\n className={cn(maxVisible !== undefined && \"min-w-0 shrink\")}\r\n >\r\n {maxVisible !== undefined\r\n ? <span className=\"truncate\">{item?.label || \"\"}</span>\r\n : (item?.label || \"\")\r\n }\r\n <ComboboxChipRemove />\r\n </ComboboxChip>\r\n ))}\r\n {overflow > 0 && (\r\n <ComboboxChip className=\"shrink-0\">\r\n +{overflow}\r\n </ComboboxChip>\r\n )}\r\n </>\r\n )\r\n }}\r\n </ComboboxValue>\r\n </ComboboxChips>\r\n </div>\r\n <ComboboxPopup container={container}>\r\n <ComboboxStatus\r\n status={\r\n isPending || items === undefined\r\n ? \"pending\"\r\n : items?.length === 0 && !isCreatingItem\r\n ? \"empty\"\r\n : null\r\n }\r\n />\r\n <ComboboxList>\r\n {items?.map((item) => (\r\n <ComboboxItem\r\n key={item.value}\r\n value={{ label: item.label, value: item.value }}\r\n >\r\n <div className=\"flex items-center gap-2 w-full min-w-0\">\r\n <span className=\"truncate\">\r\n {item.label}\r\n </span>\r\n </div>\r\n </ComboboxItem>\r\n ))}\r\n {isCreatingItem && (\r\n <ComboboxItem\r\n value={{ label: trimmedInput, value: trimmedInput, tag: true }}\r\n >\r\n <div className=\"flex items-center gap-1.5 w-full min-w-0\">\r\n {!isInputSelected && (\r\n <span className=\"text-text-secondary\">Create:</span>\r\n )}\r\n <span className=\"font-medium text-text-primary truncate\">\r\n {trimmedInput}\r\n </span>\r\n </div>\r\n </ComboboxItem>\r\n )}\r\n <ComboboxInfiniteScroll {...infiniteScroll} />\r\n </ComboboxList>\r\n </ComboboxPopup>\r\n </Combobox>\r\n )\r\n}\r\n\r\nexport { ComboboxChipOutside }"]}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import*as i from'react';import {mergeProps}from'@base-ui/react/merge-props';import {useRender}from'@base-ui/react/use-render';import {cva}from'class-variance-authority';import {ArrowRightIcon}from'lucide-react';import {cn}from'@xploreu/lib/cn';import {jsx}from'react/jsx-runtime';var u=cva("inline-flex items-center size-max whitespace-nowrap shrink-0 overflow-hidden transition-colors cursor-pointer group/badge-group gap-2",{variants:{theme:{light:"rounded-xp-full ring-1 ring-inset",modern:"rounded-xp-card-base-md bg-bg-primary text-text-secondary ring-1 ring-inset ring-border-primary shadow-xp-xs hover:bg-bg-secondary"},color:{brand:"",gray:"",error:"",warning:"",success:""},size:{md:"text-body-medium-3",lg:"text-body-medium-2"},align:{leading:"",trailing:""}},compoundVariants:[{theme:"light",color:"brand",className:"bg-utility-brand-50 text-utility-brand-700 ring-utility-brand-200 hover:bg-utility-brand-100"},{theme:"light",color:"gray",className:"bg-utility-gray-50 text-utility-gray-700 ring-utility-gray-200 hover:bg-utility-gray-100"},{theme:"light",color:"error",className:"bg-utility-error-50 text-utility-error-700 ring-utility-error-200 hover:bg-utility-error-100"},{theme:"light",color:"warning",className:"bg-utility-warning-50 text-utility-warning-700 ring-utility-warning-200 hover:bg-utility-warning-100"},{theme:"light",color:"success",className:"bg-utility-success-50 text-utility-success-700 ring-utility-success-200 hover:bg-utility-success-100"},{align:"leading",size:"md",className:"py-1 pl-1 pr-2"},{align:"leading",size:"lg",className:"py-1 pl-1 pr-2.5"},{align:"trailing",size:"md",className:"py-1 pl-2 pr-1"},{align:"trailing",size:"lg",className:"py-1 pl-2.5 pr-1"}],defaultVariants:{theme:"light",color:"brand",size:"md",align:"leading"}}),d=i.createContext({theme:"light",color:"brand",size:"md"});function f({className:a,theme:e="light",color:t="brand",size:r="md",align:o="leading",render:s,children:p,...l}){let c={"data-slot":"badge-group","data-theme":e,"data-color":t,"data-size":r,"data-align":o,className:cn(u({theme:e,color:t,size:r,align:o}),a),children:p};return jsx(d.Provider,{value:{theme:e??"light",color:t??"brand",size:r??"md"},children:useRender({defaultTagName:"div",props:mergeProps(c,l),render:s,state:{slot:"badge-group",theme:e,color:t,size:r,align:o}})})}function h({className:a,children:e,...t}){let{theme:r,color:o,size:s}=i.useContext(d),p={brand:"ring-utility-brand-200 text-utility-brand-700",gray:"ring-utility-gray-200 text-utility-gray-700",error:"ring-utility-error-200 text-utility-error-700",warning:"ring-utility-warning-200 text-utility-warning-700",success:"ring-utility-success-200 text-utility-success-700"},l=cn("inline-flex items-center justify-center font-medium shrink-0",r==="light"&&["rounded-xp-full bg-bg-primary ring-1 ring-inset",p[o]||p.brand,s==="md"?"px-2 py-0.5":"px-2.5 py-0.5"],r==="modern"&&["rounded-xp-card-base-sm bg-bg-primary shadow-xp-xs ring-1 ring-inset ring-border-primary text-text-secondary",s==="md"?"gap-1 px-1.5 py-0.5":"gap-1.5 px-2 py-0.5"],a);return jsx("span",{"data-slot":"badge-group-addon",className:l,...t,children:e})}function P({className:a,children:e=jsx(ArrowRightIcon,{}),...t}){let{color:r}=i.useContext(d),o={brand:"text-utility-brand-500",gray:"text-utility-gray-500",error:"text-utility-error-500",warning:"text-utility-warning-500",success:"text-utility-success-500"};return jsx("span",{"data-slot":"badge-group-icon",className:cn("inline-flex items-center justify-center shrink-0 [&>svg]:size-4 [&>svg]:stroke-[2px] pointer-events-none transition-transform group-hover/badge-group:translate-x-0.5",o[r]||o.brand,a),...t,children:e})}function B({className:a,...e}){let{color:t}=i.useContext(d),r={brand:"bg-utility-brand-500 outline-utility-brand-100",gray:"bg-utility-gray-500 outline-utility-gray-100",error:"bg-utility-error-500 outline-utility-error-100",warning:"bg-utility-warning-500 outline-utility-warning-100",success:"bg-utility-success-500 outline-utility-success-100"};return jsx("span",{"data-slot":"badge-group-dot",className:cn("inline-block size-1.5 shrink-0 rounded-xp-full outline-2 -outline-offset-1",r[t]||r.brand,a),...e})}export{u as a,f as b,h as c,P as d,B as e};//# sourceMappingURL=chunk-PU426AFH.js.map
|
|
2
|
+
//# sourceMappingURL=chunk-PU426AFH.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/ui/badge-group.tsx"],"names":["badgeGroupVariants","cva","badgeGroupContext","BadgeGroup","className","theme","color","size","align","render","children","props","defaultProps","cn","jsx","useRender","mergeProps","BadgeGroupAddon","colorAddonMap","addonClasses","BadgeGroupIcon","ArrowRightIcon","iconColorMap","BadgeGroupDot","dotColorMap"],"mappings":"wRASA,IAAMA,EAAqBC,GAAAA,CACzB,uIAAA,CACA,CACE,QAAA,CAAU,CACR,KAAA,CAAO,CACL,KAAA,CAAO,mCAAA,CACP,MAAA,CAAQ,oIACV,CAAA,CACA,KAAA,CAAO,CACL,KAAA,CAAO,EAAA,CACP,IAAA,CAAM,EAAA,CACN,KAAA,CAAO,EAAA,CACP,QAAS,EAAA,CACT,OAAA,CAAS,EACX,CAAA,CACA,IAAA,CAAM,CACJ,GAAI,oBAAA,CACJ,EAAA,CAAI,oBACN,CAAA,CACA,KAAA,CAAO,CACL,QAAS,EAAA,CACT,QAAA,CAAU,EACZ,CACF,CAAA,CACA,gBAAA,CAAkB,CAEhB,CACE,KAAA,CAAO,O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,CACT,QAAS,oDACX,CAAA,CAEA,OACEV,GAAAA,CAAC,MAAA,CAAA,CACC,WAAA,CAAU,kBACV,SAAA,CAAWD,EAAAA,CACT,4EAAA,CACAW,CAAAA,CAAYlB,CAAK,CAAA,EAAKkB,CAAAA,CAAY,KAAA,CAClCpB,CACF,CAAA,CACC,GAAGO,CAAAA,CACN,CAEJ","file":"chunk-PU426AFH.js","sourcesContent":["import * as React from \"react\"\r\n\r\nimport { mergeProps } from \"@base-ui/react/merge-props\"\r\nimport { useRender } from \"@base-ui/react/use-render\"\r\nimport { cva, type VariantProps } from \"class-variance-authority\"\r\nimport { ArrowRightIcon } from \"lucide-react\"\r\n\r\nimport { cn } from \"@xploreu/lib/cn\"\r\n\r\nconst badgeGroupVariants = cva(\r\n \"inline-flex items-center size-max whitespace-nowrap shrink-0 overflow-hidden transition-colors cursor-pointer group/badge-group gap-2\",\r\n {\r\n variants: {\r\n theme: {\r\n light: \"rounded-xp-full ring-1 ring-inset\",\r\n modern: \"rounded-xp-card-base-md bg-bg-primary text-text-secondary ring-1 ring-inset ring-border-primary shadow-xp-xs hover:bg-bg-secondary\",\r\n },\r\n color: {\r\n brand: \"\",\r\n gray: \"\",\r\n error: \"\",\r\n warning: \"\",\r\n success: \"\",\r\n },\r\n size: {\r\n md: \"text-body-medium-3\",\r\n lg: \"text-body-medium-2\",\r\n },\r\n align: {\r\n leading: \"\",\r\n trailing: \"\",\r\n },\r\n },\r\n compoundVariants: [\r\n // Light theme colors\r\n {\r\n theme: \"light\",\r\n color: \"brand\",\r\n className: \"bg-utility-brand-50 text-utility-brand-700 ring-utility-brand-200 hover:bg-utility-brand-100\",\r\n },\r\n {\r\n theme: \"light\",\r\n color: \"gray\",\r\n className: \"bg-utility-gray-50 text-utility-gray-700 ring-utility-gray-200 hover:bg-utility-gray-100\",\r\n },\r\n {\r\n theme: \"light\",\r\n color: \"error\",\r\n className: \"bg-utility-error-50 text-utility-error-700 ring-utility-error-200 hover:bg-utility-error-100\",\r\n },\r\n {\r\n theme: \"light\",\r\n color: \"warning\",\r\n className: \"bg-utility-warning-50 text-utility-warning-700 ring-utility-warning-200 hover:bg-utility-warning-100\",\r\n },\r\n {\r\n theme: \"light\",\r\n color: \"success\",\r\n className: \"bg-utility-success-50 text-utility-success-700 ring-utility-success-200 hover:bg-utility-success-100\",\r\n },\r\n\r\n // Size & Align combinations (Root padding matching exact Figma values)\r\n // Leading: Addon on the left\r\n {\r\n align: \"leading\",\r\n size: \"md\",\r\n className: \"py-1 pl-1 pr-2\",\r\n },\r\n {\r\n align: \"leading\",\r\n size: \"lg\",\r\n className: \"py-1 pl-1 pr-2.5\",\r\n },\r\n // Trailing: Addon on the right\r\n {\r\n align: \"trailing\",\r\n size: \"md\",\r\n className: \"py-1 pl-2 pr-1\",\r\n },\r\n {\r\n align: \"trailing\",\r\n size: \"lg\",\r\n className: \"py-1 pl-2.5 pr-1\",\r\n },\r\n ],\r\n defaultVariants: {\r\n theme: \"light\",\r\n color: \"brand\",\r\n size: \"md\",\r\n align: \"leading\",\r\n },\r\n }\r\n)\r\n\r\nconst badgeGroupContext = React.createContext<{\r\n theme: \"light\" | \"modern\"\r\n color: \"brand\" | \"gray\" | \"error\" | \"warning\" | \"success\"\r\n size: \"md\" | \"lg\"\r\n}>({\r\n theme: \"light\",\r\n color: \"brand\",\r\n size: \"md\",\r\n})\r\n\r\nexport interface BadgeGroupProps\r\n extends Omit<React.ComponentProps<\"div\">, \"color\">,\r\n VariantProps<typeof badgeGroupVariants> {\r\n}\r\n\r\nfunction BadgeGroup({\r\n className,\r\n theme = \"light\",\r\n color = \"brand\",\r\n size = \"md\",\r\n align = \"leading\",\r\n render,\r\n children,\r\n ...props\r\n}: BadgeGroupProps & useRender.ComponentProps<\"div\">) {\r\n const defaultProps = {\r\n \"data-slot\": \"badge-group\",\r\n \"data-theme\": theme,\r\n \"data-color\": color,\r\n \"data-size\": size,\r\n \"data-align\": align,\r\n className: cn(badgeGroupVariants({ theme, color, size, align }), className),\r\n children,\r\n }\r\n\r\n return (\r\n <badgeGroupContext.Provider value={{ theme: theme ?? \"light\", color: color ?? \"brand\", size: size ?? \"md\" }}>\r\n {useRender({\r\n defaultTagName: \"div\",\r\n props: mergeProps(defaultProps, props),\r\n render,\r\n state: {\r\n slot: \"badge-group\",\r\n theme,\r\n color,\r\n size,\r\n align,\r\n },\r\n })}\r\n </badgeGroupContext.Provider>\r\n )\r\n}\r\n\r\nexport interface BadgeGroupAddonProps extends React.ComponentProps<\"span\"> {\r\n children?: React.ReactNode\r\n}\r\n\r\nfunction BadgeGroupAddon({\r\n className,\r\n children,\r\n ...props\r\n}: BadgeGroupAddonProps) {\r\n const { theme, color, size } = React.useContext(badgeGroupContext)\r\n\r\n const colorAddonMap: Record<string, string> = {\r\n brand: \"ring-utility-brand-200 text-utility-brand-700\",\r\n gray: \"ring-utility-gray-200 text-utility-gray-700\",\r\n error: \"ring-utility-error-200 text-utility-error-700\",\r\n warning: \"ring-utility-warning-200 text-utility-warning-700\",\r\n success: \"ring-utility-success-200 text-utility-success-700\",\r\n }\r\n\r\n const addonClasses = cn(\r\n \"inline-flex items-center justify-center font-medium shrink-0\",\r\n theme === \"light\" && [\r\n \"rounded-xp-full bg-bg-primary ring-1 ring-inset\",\r\n colorAddonMap[color] || colorAddonMap.brand,\r\n size === \"md\" ? \"px-2 py-0.5\" : \"px-2.5 py-0.5\",\r\n ],\r\n theme === \"modern\" && [\r\n \"rounded-xp-card-base-sm bg-bg-primary shadow-xp-xs ring-1 ring-inset ring-border-primary text-text-secondary\",\r\n size === \"md\" ? \"gap-1 px-1.5 py-0.5\" : \"gap-1.5 px-2 py-0.5\",\r\n ],\r\n className\r\n )\r\n\r\n return (\r\n <span data-slot=\"badge-group-addon\" className={addonClasses} {...props}>\r\n {children}\r\n </span>\r\n )\r\n}\r\n\r\nexport interface BadgeGroupIconProps extends React.ComponentProps<\"span\"> {\r\n children?: React.ReactNode\r\n}\r\n\r\nfunction BadgeGroupIcon({\r\n className,\r\n children = <ArrowRightIcon />,\r\n ...props\r\n}: BadgeGroupIconProps) {\r\n const { color } = React.useContext(badgeGroupContext)\r\n\r\n const iconColorMap: Record<string, string> = {\r\n brand: \"text-utility-brand-500\",\r\n gray: \"text-utility-gray-500\",\r\n error: \"text-utility-error-500\",\r\n warning: \"text-utility-warning-500\",\r\n success: \"text-utility-success-500\",\r\n }\r\n\r\n return (\r\n <span\r\n data-slot=\"badge-group-icon\"\r\n className={cn(\r\n \"inline-flex items-center justify-center shrink-0 [&>svg]:size-4 [&>svg]:stroke-[2px] pointer-events-none transition-transform group-hover/badge-group:translate-x-0.5\",\r\n iconColorMap[color] || iconColorMap.brand,\r\n className\r\n )}\r\n {...props}\r\n >\r\n {children}\r\n </span>\r\n )\r\n}\r\n\r\nexport interface BadgeGroupDotProps extends React.ComponentProps<\"span\"> {\r\n}\r\n\r\nfunction BadgeGroupDot({\r\n className,\r\n ...props\r\n}: BadgeGroupDotProps) {\r\n const { color } = React.useContext(badgeGroupContext)\r\n\r\n const dotColorMap: Record<string, string> = {\r\n brand: \"bg-utility-brand-500 outline-utility-brand-100\",\r\n gray: \"bg-utility-gray-500 outline-utility-gray-100\",\r\n error: \"bg-utility-error-500 outline-utility-error-100\",\r\n warning: \"bg-utility-warning-500 outline-utility-warning-100\",\r\n success: \"bg-utility-success-500 outline-utility-success-100\",\r\n }\r\n\r\n return (\r\n <span\r\n data-slot=\"badge-group-dot\"\r\n className={cn(\r\n \"inline-block size-1.5 shrink-0 rounded-xp-full outline-2 -outline-offset-1\",\r\n dotColorMap[color] || dotColorMap.brand,\r\n className\r\n )}\r\n {...props}\r\n />\r\n )\r\n}\r\n\r\nexport {\r\n BadgeGroup,\r\n BadgeGroupAddon,\r\n BadgeGroupIcon,\r\n BadgeGroupDot,\r\n badgeGroupVariants,\r\n}\r\n"]}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {a,b,i,m,s,w}from'./chunk-
|
|
2
|
-
//# sourceMappingURL=chunk-
|
|
1
|
+
import {a,b,i,m,s,w}from'./chunk-EL7P7FN5.js';import*as l from'react';import {ChevronDownIcon,ChevronLeftIcon,ChevronRightIcon}from'lucide-react';import {cn}from'@xploreu/lib/cn';import {jsxs,Fragment,jsx}from'react/jsx-runtime';function j({page:r,pageSize:a$1,total:i$1,onPageChange:b$1,onPageSizeChange:n,pageSizeOptions:m$1=[10,20,50,100],showPageSize:c=true,showRange:d=true,className:C,...N}){let u=Math.max(1,Math.ceil(i$1/a$1)),h=i$1===0?0:(r-1)*a$1+1,P=Math.min(r*a$1,i$1),s$1=l.useMemo(()=>m$1.map(e=>({label:String(e),value:e})),[m$1]),I=l.useMemo(()=>s$1.find(e=>e.value===a$1)??s$1[0],[s$1,a$1]);return jsxs("div",{className:cn("flex w-full flex-col-reverse gap-3 mt-4 sm:flex-row sm:items-center sm:justify-between border-t border-border-primary pt-3 text-body-regular-2 text-text-secondary",C),"data-slot":"pagination",...N,children:[jsxs("div",{className:"flex items-center gap-2",children:[c&&n&&jsxs(Fragment,{children:[jsx("span",{className:"text-label-regular-3 text-text-tertiary",children:"Rows per page"}),jsxs(a,{items:s$1,value:I,onValueChange:e=>{e&&n&&n(e.value);},isItemEqualToValue:(e,w)=>e.value===w.value,children:[jsxs(b,{className:"h-8 gap-2 rounded-lg border border-border-primary bg-bg-primary px-3 text-label-semibold-3 text-text-primary hover:bg-bg-secondary focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-border-brand-primary","aria-label":"Rows per page",children:[jsx(i,{children:e=>e?e.label:String(a$1)}),jsx(ChevronDownIcon,{className:"size-3.5 text-text-tertiary"})]}),jsx(m,{className:"w-24",children:jsx(s,{children:s$1.map(e=>jsx(w,{value:e,children:e.label},e.value))})})]})]}),c&&d&&jsx("span",{className:"text-text-tertiary",children:"\xB7"}),d&&jsxs("span",{className:"text-label-regular-3 text-text-tertiary",children:[h,"\u2013",P," of ",i$1]})]}),jsxs("div",{className:"flex items-center gap-1",children:[jsx("button",{type:"button",disabled:r<=1,onClick:()=>b$1(r-1),className:"inline-flex size-8 cursor-pointer items-center justify-center rounded-lg border border-border-primary bg-bg-primary text-text-secondary transition-colors hover:bg-bg-secondary hover:text-text-primary disabled:cursor-not-allowed disabled:opacity-40","aria-label":"Previous page",children:jsx(ChevronLeftIcon,{className:"size-4"})}),jsxs("span",{className:"px-2 text-label-semibold-3 text-text-primary",children:["Page ",r," / ",u]}),jsx("button",{type:"button",disabled:r>=u,onClick:()=>b$1(r+1),className:"inline-flex size-8 cursor-pointer items-center justify-center rounded-lg border border-border-primary bg-bg-primary text-text-secondary transition-colors hover:bg-bg-secondary hover:text-text-primary disabled:cursor-not-allowed disabled:opacity-40","aria-label":"Next page",children:jsx(ChevronRightIcon,{className:"size-4"})})]})]})}export{j as a};//# sourceMappingURL=chunk-R4WEEB5H.js.map
|
|
2
|
+
//# sourceMappingURL=chunk-R4WEEB5H.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/ui/pagination.tsx"],"names":["Pagination","page","pageSize","total","onPageChange","onPageSizeChange","pageSizeOptions","showPageSize","showRange","className","props","totalPages","startItem","endItem","items","opt","selectedItem","item","jsxs","cn","Fragment","jsx","Combobox","a","b","ComboboxTrigger","ComboboxValue","val","ChevronDownIcon","ComboboxPopup","ComboboxList","ComboboxItem","ChevronLeftIcon","ChevronRightIcon"],"mappings":"qOA6BO,SAASA,CAAAA,CAAW,CACzB,KAAAC,CAAAA,CACA,QAAA,CAAAC,GAAAA,CACA,KAAA,CAAAC,IACA,YAAA,CAAAC,GAAAA,CACA,gBAAA,CAAAC,CAAAA,CACA,gBAAAC,GAAAA,CAAkB,CAAC,EAAA,CAAI,EAAA,CAAI,GAAI,GAAG,CAAA,CAClC,YAAA,CAAAC,CAAAA,CAAe,KACf,SAAA,CAAAC,CAAAA,CAAY,IAAA,CACZ,SAAA,CAAAC,EACA,GAAGC,CACL,CAAA,CAAoB,CAClB,IAAMC,CAAAA,CAAa,IAAA,CAAK,GAAA,CAAI,CAAA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A,CAACW,gBAAA,CAAgB,SAAA,CAAU,QAAA,CAAS,CAAA,CACtC,EAEAd,IAAAA,CAAC,MAAA,CAAA,CAAK,SAAA,CAAU,8CAAA,CAA+C,kBACvDjB,CAAAA,CAAK,KAAA,CAAIU,CAAAA,CAAAA,CACjB,CAAA,CAEAU,IAAC,QAAA,CAAA,CACC,IAAA,CAAK,QAAA,CACL,QAAA,CAAUpB,GAAQU,CAAAA,CAClB,OAAA,CAAS,IAAMP,GAAAA,CAAaH,EAAO,CAAC,CAAA,CACpC,SAAA,CAAU,yPAAA,CACV,aAAW,WAAA,CAEX,QAAA,CAAAoB,GAAAA,CAACY,gBAAAA,CAAA,CAAiB,SAAA,CAAU,QAAA,CAAS,CAAA,CACvC,CAAA,CAAA,CACF,GACF,CAEJ","file":"chunk-
|
|
1
|
+
{"version":3,"sources":["../src/ui/pagination.tsx"],"names":["Pagination","page","pageSize","total","onPageChange","onPageSizeChange","pageSizeOptions","showPageSize","showRange","className","props","totalPages","startItem","endItem","items","opt","selectedItem","item","jsxs","cn","Fragment","jsx","Combobox","a","b","ComboboxTrigger","ComboboxValue","val","ChevronDownIcon","ComboboxPopup","ComboboxList","ComboboxItem","ChevronLeftIcon","ChevronRightIcon"],"mappings":"qOA6BO,SAASA,CAAAA,CAAW,CACzB,KAAAC,CAAAA,CACA,QAAA,CAAAC,GAAAA,CACA,KAAA,CAAAC,IACA,YAAA,CAAAC,GAAAA,CACA,gBAAA,CAAAC,CAAAA,CACA,gBAAAC,GAAAA,CAAkB,CAAC,EAAA,CAAI,EAAA,CAAI,GAAI,GAAG,CAAA,CAClC,YAAA,CAAAC,CAAAA,CAAe,KACf,SAAA,CAAAC,CAAAA,CAAY,IAAA,CACZ,SAAA,CAAAC,EACA,GAAGC,CACL,CAAA,CAAoB,CAClB,IAAMC,CAAAA,CAAa,IAAA,CAAK,GAAA,CAAI,CAAA,CAAG,KAAK,IAAA,CAAKR,GAAAA,CAAQD,GAAQ,CAAC,EACpDU,CAAAA,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AAA,CAAC,MAAA,CAAA,CAAK,SAAA,CAAU,8CAAA,CAA+C,kBACvDjB,CAAAA,CAAK,KAAA,CAAIU,CAAAA,CAAAA,CACjB,CAAA,CAEAU,IAAC,QAAA,CAAA,CACC,IAAA,CAAK,QAAA,CACL,QAAA,CAAUpB,GAAQU,CAAAA,CAClB,OAAA,CAAS,IAAMP,GAAAA,CAAaH,EAAO,CAAC,CAAA,CACpC,SAAA,CAAU,yPAAA,CACV,aAAW,WAAA,CAEX,QAAA,CAAAoB,GAAAA,CAACY,gBAAAA,CAAA,CAAiB,SAAA,CAAU,QAAA,CAAS,CAAA,CACvC,CAAA,CAAA,CACF,GACF,CAEJ","file":"chunk-R4WEEB5H.js","sourcesContent":["import * as React from \"react\"\r\nimport { ChevronDownIcon, ChevronLeftIcon, ChevronRightIcon } from \"lucide-react\"\r\n\r\nimport { cn } from \"@xploreu/lib/cn\"\r\nimport {\r\n Combobox,\r\n ComboboxItem,\r\n ComboboxList,\r\n ComboboxPopup,\r\n ComboboxTrigger,\r\n ComboboxValue,\r\n} from \"./combobox\"\r\n\r\nexport interface PaginationProps extends React.ComponentProps<\"div\"> {\r\n page: number\r\n pageSize: number\r\n total: number\r\n onPageChange: (page: number) => void\r\n onPageSizeChange?: (pageSize: number) => void\r\n pageSizeOptions?: number[]\r\n showPageSize?: boolean\r\n showRange?: boolean\r\n}\r\n\r\ntype PageSizeOptionItem = {\r\n label: string\r\n value: number\r\n}\r\n\r\nexport function Pagination({\r\n page,\r\n pageSize,\r\n total,\r\n onPageChange,\r\n onPageSizeChange,\r\n pageSizeOptions = [10, 20, 50, 100],\r\n showPageSize = true,\r\n showRange = true,\r\n className,\r\n ...props\r\n}: PaginationProps) {\r\n const totalPages = Math.max(1, Math.ceil(total / pageSize))\r\n const startItem = total === 0 ? 0 : (page - 1) * pageSize + 1\r\n const endItem = Math.min(page * pageSize, total)\r\n\r\n const items: PageSizeOptionItem[] = React.useMemo(\r\n () => pageSizeOptions.map((opt) => ({ label: String(opt), value: opt })),\r\n [pageSizeOptions]\r\n )\r\n\r\n const selectedItem = React.useMemo(\r\n () => items.find((item) => item.value === pageSize) ?? items[0],\r\n [items, pageSize]\r\n )\r\n\r\n return (\r\n <div\r\n className={cn(\r\n \"flex w-full flex-col-reverse gap-3 mt-4 sm:flex-row sm:items-center sm:justify-between border-t border-border-primary pt-3 text-body-regular-2 text-text-secondary\",\r\n className\r\n )}\r\n data-slot=\"pagination\"\r\n {...props}\r\n >\r\n {/* Left: Rows per page & range */}\r\n <div className=\"flex items-center gap-2\">\r\n {showPageSize && onPageSizeChange && (\r\n <>\r\n <span className=\"text-label-regular-3 text-text-tertiary\">\r\n Rows per page\r\n </span>\r\n <Combobox<PageSizeOptionItem>\r\n items={items}\r\n value={selectedItem}\r\n onValueChange={(item) => {\r\n if (item && onPageSizeChange) {\r\n onPageSizeChange(item.value)\r\n }\r\n }}\r\n isItemEqualToValue={(a, b) => a.value === b.value}\r\n >\r\n <ComboboxTrigger\r\n className=\"h-8 gap-2 rounded-lg border border-border-primary bg-bg-primary px-3 text-label-semibold-3 text-text-primary hover:bg-bg-secondary focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-border-brand-primary\"\r\n aria-label=\"Rows per page\"\r\n >\r\n <ComboboxValue>\r\n {(val) => (val ? val.label : String(pageSize))}\r\n </ComboboxValue>\r\n <ChevronDownIcon className=\"size-3.5 text-text-tertiary\" />\r\n </ComboboxTrigger>\r\n\r\n <ComboboxPopup className=\"w-24\">\r\n <ComboboxList>\r\n {items.map((item) => (\r\n <ComboboxItem\r\n key={item.value}\r\n value={item}\r\n >\r\n {item.label}\r\n </ComboboxItem>\r\n ))}\r\n </ComboboxList>\r\n </ComboboxPopup>\r\n </Combobox>\r\n </>\r\n )}\r\n\r\n {showPageSize && showRange && (\r\n <span className=\"text-text-tertiary\">·</span>\r\n )}\r\n\r\n {showRange && (\r\n <span className=\"text-label-regular-3 text-text-tertiary\">\r\n {startItem}–{endItem} of {total}\r\n </span>\r\n )}\r\n </div>\r\n\r\n {/* Right: Page controls */}\r\n <div className=\"flex items-center gap-1\">\r\n <button\r\n type=\"button\"\r\n disabled={page <= 1}\r\n onClick={() => onPageChange(page - 1)}\r\n className=\"inline-flex size-8 cursor-pointer items-center justify-center rounded-lg border border-border-primary bg-bg-primary text-text-secondary transition-colors hover:bg-bg-secondary hover:text-text-primary disabled:cursor-not-allowed disabled:opacity-40\"\r\n aria-label=\"Previous page\"\r\n >\r\n <ChevronLeftIcon className=\"size-4\" />\r\n </button>\r\n\r\n <span className=\"px-2 text-label-semibold-3 text-text-primary\">\r\n Page {page} / {totalPages}\r\n </span>\r\n\r\n <button\r\n type=\"button\"\r\n disabled={page >= totalPages}\r\n onClick={() => onPageChange(page + 1)}\r\n className=\"inline-flex size-8 cursor-pointer items-center justify-center rounded-lg border border-border-primary bg-bg-primary text-text-secondary transition-colors hover:bg-bg-secondary hover:text-text-primary disabled:cursor-not-allowed disabled:opacity-40\"\r\n aria-label=\"Next page\"\r\n >\r\n <ChevronRightIcon className=\"size-4\" />\r\n </button>\r\n </div>\r\n </div>\r\n )\r\n}\r\n"]}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {a}from'./chunk-ZVME3JB3.js';import {b as b$1,c}from'./chunk-
|
|
2
|
-
//# sourceMappingURL=chunk-
|
|
1
|
+
import {a}from'./chunk-ZVME3JB3.js';import {b as b$1,c}from'./chunk-2XZRLJCN.js';import*as n from'react';import {Tabs}from'@base-ui/react/tabs';import {AnimatePresence,motion}from'motion/react';import {getStrictContext}from'@xploreu/lib/get-strict-context';import {useControlledState}from'@xploreu/hooks/use-controlled-state';import {jsx}from'react/jsx-runtime';var[v,b]=getStrictContext("TabsContext");function M(t){let[a,s]=useControlledState({value:t.value,defaultValue:t.defaultValue,onChange:t.onValueChange});return jsx(v,{value:{value:a,setValue:s},children:jsx(Tabs.Root,{"data-slot":"tabs",...t,onValueChange:s})})}function V({transition:t={type:"spring",stiffness:200,damping:25},...a}){let{value:s}=b();return jsx(b$1,{"data-slot":"tabs-highlight",controlledItems:true,value:s,transition:t,click:false,...a})}function k(t){return jsx(Tabs.List,{"data-slot":"tabs-list",...t})}function F(t){return jsx(c,{"data-slot":"tabs-highlight-item",...t})}function O(t){return jsx(Tabs.Tab,{"data-slot":"tabs-tab",...t})}function w({value:t,keepMounted:a,transition:s={duration:.5,ease:"easeInOut"},...i}){return jsx(AnimatePresence,{mode:"wait",children:jsx(Tabs.Panel,{render:jsx(motion.div,{"data-slot":"tabs-panel",layout:true,layoutDependency:t,initial:{opacity:0,filter:"blur(4px)"},animate:{opacity:1,filter:"blur(0px)"},exit:{opacity:0,filter:"blur(4px)"},transition:s,...i}),keepMounted:a,value:t})})}var P={type:"spring",stiffness:200,damping:30};function H(t){return !t.mode||t.mode==="auto-height"}function D(t){let{value:a$1}=b();if(H(t)){let{children:h,transition:m=P,...y}=t;return jsx(a,{"data-slot":"tabs-panels",deps:[a$1],transition:m,...y,children:jsx(n.Fragment,{children:h},a$1)})}let{children:s,style:i,transition:T=P,...g}=t;return jsx(motion.div,{"data-slot":"tabs-panels",layout:"size",layoutDependency:a$1,transition:{layout:T},style:{overflow:"hidden",...i},...g,children:jsx(n.Fragment,{children:s},a$1)})}export{M as a,V as b,k as c,F as d,O as e,w as f,D as g};//# sourceMappingURL=chunk-RJ2SAHLO.js.map
|
|
2
|
+
//# sourceMappingURL=chunk-RJ2SAHLO.js.map
|