@xploreu/components 0.4.13 → 0.4.15
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-ZZWSZRER.js → chunk-3VMZENNL.js} +2 -2
- package/dist/{chunk-ZZWSZRER.js.map → chunk-3VMZENNL.js.map} +1 -1
- 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-COJ4DWGS.js +2 -0
- package/dist/chunk-COJ4DWGS.js.map +1 -0
- package/dist/{chunk-SFMNEY3D.js → chunk-FB6VMMUL.js} +2 -2
- package/dist/{chunk-SFMNEY3D.js.map → chunk-FB6VMMUL.js.map} +1 -1
- package/dist/{chunk-7YSKM6DP.js → chunk-GJZZ55GE.js} +2 -2
- package/dist/{chunk-7YSKM6DP.js.map → chunk-GJZZ55GE.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-FDXCGFD2.js → chunk-M73NAM5U.js} +2 -2
- package/dist/{chunk-FDXCGFD2.js.map → chunk-M73NAM5U.js.map} +1 -1
- package/dist/{chunk-RSLKHDFJ.js → chunk-NBRMYO6B.js} +2 -2
- package/dist/{chunk-RSLKHDFJ.js.map → chunk-NBRMYO6B.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-QX6F73UK.js} +2 -2
- package/dist/{chunk-KKE76CHJ.js.map → chunk-QX6F73UK.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-DNO5M44I.js → chunk-TG3TM7XY.js} +2 -2
- package/dist/{chunk-DNO5M44I.js.map → chunk-TG3TM7XY.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-WCAQIMAH.js → chunk-VE5SIEG4.js} +2 -2
- package/dist/{chunk-WCAQIMAH.js.map → chunk-VE5SIEG4.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/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 +16 -6
- package/dist/ui/badge.js +1 -1
- package/dist/ui/combobox.js +1 -1
- package/dist/ui/date-multiple-picker.js +1 -1
- package/dist/ui/index.d.ts +28 -5
- package/dist/ui/index.js +1 -1
- package/dist/ui/menu.js +1 -1
- package/dist/ui/pagination.js +1 -1
- package/dist/ui/table.js +1 -1
- package/dist/ui/tabs.d.ts +1 -1
- package/dist/ui/tabs.js +1 -1
- package/dist/ui/tooltip.d.ts +1 -1
- package/dist/ui/tooltip.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-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-P2DJG2OD.js +0 -2
- package/dist/chunk-P2DJG2OD.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,b,i,m,s,w}from'./chunk-
|
|
2
|
-
//# sourceMappingURL=chunk-
|
|
1
|
+
import {a,b,i,m,s,w}from'./chunk-3VMZENNL.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-QX6F73UK.js.map
|
|
2
|
+
//# sourceMappingURL=chunk-QX6F73UK.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,CAAG,KAAK,IAAA,CAAKR,GAAAA,CAAQD,GAAQ,CAAC,EACpDU,CAAAA,CAAYT,GAAAA,GAAU,CAAA,CAAI,CAAA,CAAA,CAAKF,EAAO,CAAA,EAAKC,GAAAA,CAAW,CAAA,CACtDW,CAAAA,CAAU,KAAK,GAAA,CAAIZ,CAAAA,CAAOC,GAAAA,CAAUC,GAAK,EAEzCW,GAAAA,CAAoC,CAAA,CAAA,OAAA,CACxC,IAAMR,GAAAA,CAAgB,IAAKS,CAAAA,GAAS,CAAE,KAAA,CAAO,MAAA,CAAOA,CAAG,CAAA,CAAG,KAAA,CAAOA,CAAI,CAAA,CAAE,EACvE,CAACT,GAAe,CAClB,CAAA,CAEMU,EAAqB,CAAA,CAAA,OAAA,CACzB,IAAMF,GAAAA,CAAM,IAAA,CAAMG,GAASA,CAAAA,CAAK,KAAA,GAAUf,GAAQ,CAAA,EAAKY,IAAM,CAAC,CAAA,CAC9D,CAACA,GAAAA,CAAOZ,GAAQ,CAClB,CAAA,CAEA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,CAAA,CAAA,CACF,CAAA,CAAA,CACF,CAAA,CAGDV,GAAgBC,CAAAA,EACfa,GAAAA,CAAC,MAAA,CAAA,CAAK,SAAA,CAAU,qBAAqB,QAAA,CAAA,MAAA,CAAC,CAAA,CAGvCb,CAAAA,EACCU,IAAAA,CAAC,QAAK,SAAA,CAAU,yCAAA,CACb,QAAA,CAAA,CAAAN,CAAAA,CAAU,SAAEC,CAAAA,CAAQ,MAAA,CAAKV,GAAAA,CAAAA,CAC5B,CAAA,CAAA,CAEJ,EAGAe,IAAAA,CAAC,KAAA,CAAA,CAAI,SAAA,CAAU,yBAAA,CACb,UAAAG,GAAAA,CAAC,QAAA,CAAA,CACC,IAAA,CAAK,QAAA,CACL,SAAUpB,CAAAA,EAAQ,CAAA,CAClB,OAAA,CAAS,IAAMG,IAAaH,CAAAA,CAAO,CAAC,CAAA,CACpC,SAAA,CAAU,0PACV,YAAA,CAAW,eAAA,CAEX,QAAA,CAAAoB,GAAAA,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,CAAYT,GAAAA,GAAU,CAAA,CAAI,CAAA,CAAA,CAAKF,EAAO,CAAA,EAAKC,GAAAA,CAAW,CAAA,CACtDW,CAAAA,CAAU,KAAK,GAAA,CAAIZ,CAAAA,CAAOC,GAAAA,CAAUC,GAAK,EAEzCW,GAAAA,CAAoC,CAAA,CAAA,OAAA,CACxC,IAAMR,GAAAA,CAAgB,IAAKS,CAAAA,GAAS,CAAE,KAAA,CAAO,MAAA,CAAOA,CAAG,CAAA,CAAG,KAAA,CAAOA,CAAI,CAAA,CAAE,EACvE,CAACT,GAAe,CAClB,CAAA,CAEMU,EAAqB,CAAA,CAAA,OAAA,CACzB,IAAMF,GAAAA,CAAM,IAAA,CAAMG,GAASA,CAAAA,CAAK,KAAA,GAAUf,GAAQ,CAAA,EAAKY,IAAM,CAAC,CAAA,CAC9D,CAACA,GAAAA,CAAOZ,GAAQ,CAClB,CAAA,CAEA,OACEgB,IAAAA,CAAC,OACC,SAAA,CAAWC,EAAAA,CACT,oKAAA,CACAV,CACF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,GAAAA,CAAC,MAAA,CAAA,CAAK,SAAA,CAAU,qBAAqB,QAAA,CAAA,MAAA,CAAC,CAAA,CAGvCb,CAAAA,EACCU,IAAAA,CAAC,QAAK,SAAA,CAAU,yCAAA,CACb,QAAA,CAAA,CAAAN,CAAAA,CAAU,SAAEC,CAAAA,CAAQ,MAAA,CAAKV,GAAAA,CAAAA,CAC5B,CAAA,CAAA,CAEJ,EAGAe,IAAAA,CAAC,KAAA,CAAA,CAAI,SAAA,CAAU,yBAAA,CACb,UAAAG,GAAAA,CAAC,QAAA,CAAA,CACC,IAAA,CAAK,QAAA,CACL,SAAUpB,CAAAA,EAAQ,CAAA,CAClB,OAAA,CAAS,IAAMG,IAAaH,CAAAA,CAAO,CAAC,CAAA,CACpC,SAAA,CAAU,0PACV,YAAA,CAAW,eAAA,CAEX,QAAA,CAAAoB,GAAAA,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-QX6F73UK.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
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/primitives/tabs.tsx"],"names":["TabsProvider","useTabs","getStrictContext","Tabs","props","value","setValue","useControlledState","jsx","TabsPrimitive","TabsHighlight","transition","Highlight","TabsList","TabsHighlightItem","HighlightItem","TabsTab","TabsPanel","keepMounted","AnimatePresence","motion","defaultTransition","isAutoMode","TabsPanels","children","autoProps","AutoHeight","style","layoutProps"],"mappings":"0WA6BA,GAAM,CAACA,EAAcC,CAAO,CAAA,CAC1BC,iBAAkC,aAAa,CAAA,CAIjD,SAASC,CAAAA,CAAKC,CAAAA,CAAkB,CAC9B,GAAM,CAACC,EAAOC,CAAQ,CAAA,CAAIC,mBAAmB,CAC3C,KAAA,CAAOH,CAAAA,CAAM,KAAA,CACb,aAAcA,CAAAA,CAAM,YAAA,CACpB,SAAUA,CAAAA,CAAM,aAClB,CAAC,CAAA,CAED,OACEI,GAAAA,CAACR,CAAAA,CAAA,CAAa,KAAA,CAAO,CAAE,MAAAK,CAAAA,CAAO,QAAA,CAAAC,CAAS,CAAA,CACrC,QAAA,CAAAE,GAAAA,CAACC,IAAAA,CAAc,KAAd,CACC,WAAA,CAAU,OACT,GAAGL,CAAAA,CACJ,cAAeE,CAAAA,CACjB,CAAA,CACF,CAEJ,CAIA,SAASI,EAAc,CACrB,UAAA,CAAAC,EAAa,CAAE,IAAA,CAAM,SAAU,SAAA,CAAW,GAAA,CAAK,OAAA,CAAS,EAAG,EAC3D,GAAGP,CACL,EAAuB,CACrB,GAAM,CAAE,KAAA,CAAAC,CAAM,CAAA,CAAIJ,CAA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GAAiB,EACxC,CAEJ","file":"chunk-
|
|
1
|
+
{"version":3,"sources":["../src/primitives/tabs.tsx"],"names":["TabsProvider","useTabs","getStrictContext","Tabs","props","value","setValue","useControlledState","jsx","TabsPrimitive","TabsHighlight","transition","Highlight","TabsList","TabsHighlightItem","HighlightItem","TabsTab","TabsPanel","keepMounted","AnimatePresence","motion","defaultTransition","isAutoMode","TabsPanels","children","autoProps","AutoHeight","style","layoutProps"],"mappings":"0WA6BA,GAAM,CAACA,EAAcC,CAAO,CAAA,CAC1BC,iBAAkC,aAAa,CAAA,CAIjD,SAASC,CAAAA,CAAKC,CAAAA,CAAkB,CAC9B,GAAM,CAACC,EAAOC,CAAQ,CAAA,CAAIC,mBAAmB,CAC3C,KAAA,CAAOH,CAAAA,CAAM,KAAA,CACb,aAAcA,CAAAA,CAAM,YAAA,CACpB,SAAUA,CAAAA,CAAM,aAClB,CAAC,CAAA,CAED,OACEI,GAAAA,CAACR,CAAAA,CAAA,CAAa,KAAA,CAAO,CAAE,MAAAK,CAAAA,CAAO,QAAA,CAAAC,CAAS,CAAA,CACrC,QAAA,CAAAE,GAAAA,CAACC,IAAAA,CAAc,KAAd,CACC,WAAA,CAAU,OACT,GAAGL,CAAAA,CACJ,cAAeE,CAAAA,CACjB,CAAA,CACF,CAEJ,CAIA,SAASI,EAAc,CACrB,UAAA,CAAAC,EAAa,CAAE,IAAA,CAAM,SAAU,SAAA,CAAW,GAAA,CAAK,OAAA,CAAS,EAAG,EAC3D,GAAGP,CACL,EAAuB,CACrB,GAAM,CAAE,KAAA,CAAAC,CAAM,CAAA,CAAIJ,CAAAA,GAElB,OACEO,GAAAA,CAACI,IAAA,CACC,WAAA,CAAU,iBACV,eAAA,CAAe,IAAA,CACf,KAAA,CAAOP,CAAAA,CACP,WAAYM,CAAAA,CACZ,KAAA,CAAO,MACN,GAAGP,CAAAA,CACN,CAEJ,CAIA,SAASS,EAAST,CAAAA,CAAsB,CACtC,OAAOI,GAAAA,CAACC,IAAAA,C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AA,GAAS,aACvC,CAEA,SAASmB,CAAAA,CAAWnB,EAAwB,CAC1C,GAAM,CAAE,KAAA,CAAAC,GAAM,CAAA,CAAIJ,CAAAA,GAElB,GAAIqB,CAAAA,CAAWlB,CAAK,CAAA,CAAG,CACrB,GAAM,CAAE,QAAA,CAAAoB,CAAAA,CAAU,UAAA,CAAAb,EAAaU,CAAAA,CAAmB,GAAGI,CAAU,CAAA,CAAIrB,CAAAA,CAEnE,OACEI,GAAAA,CAACkB,CAAAA,CAAA,CACC,WAAA,CAAU,cACV,IAAA,CAAM,CAACrB,GAAK,CAAA,CACZ,UAAA,CAAYM,EACX,GAAGc,CAAAA,CAEJ,SAAAjB,GAAAA,CAAO,CAAA,CAAA,QAAA,CAAN,CAA4B,QAAA,CAAAgB,CAAAA,CAAAA,CAARnB,GAAiB,CAAA,CACxC,CAEJ,CAEA,GAAM,CACJ,QAAA,CAAAmB,CAAAA,CACA,MAAAG,CAAAA,CACA,UAAA,CAAAhB,EAAaU,CAAAA,CACb,GAAGO,CACL,CAAA,CAAIxB,CAAAA,CAEJ,OACEI,GAAAA,CAACY,MAAAA,CAAO,IAAP,CACC,WAAA,CAAU,cACV,MAAA,CAAO,MAAA,CACP,iBAAkBf,GAAAA,CAClB,UAAA,CAAY,CAAE,MAAA,CAAQM,CAAW,CAAA,CACjC,KAAA,CAAO,CAAE,QAAA,CAAU,QAAA,CAAU,GAAGgB,CAAM,CAAA,CACrC,GAAGC,CAAAA,CAEJ,QAAA,CAAApB,IAAO,CAAA,CAAA,QAAA,CAAN,CAA4B,SAAAgB,CAAAA,CAAAA,CAARnB,GAAiB,EACxC,CAEJ","file":"chunk-RJ2SAHLO.js","sourcesContent":["'use client';\r\n\r\nimport * as React from 'react';\r\nimport { Tabs as TabsPrimitive } from '@base-ui/react/tabs';\r\nimport {\r\n motion,\r\n AnimatePresence,\r\n type HTMLMotionProps,\r\n type Transition,\r\n} from 'motion/react';\r\n\r\nimport {\r\n Highlight,\r\n HighlightItem,\r\n type HighlightProps,\r\n type HighlightItemProps,\r\n} from \"../effects/highlight\"\r\nimport { getStrictContext } from \"@xploreu/lib/get-strict-context\";\r\nimport { useControlledState } from '@xploreu/hooks/use-controlled-state';\r\nimport {\r\n AutoHeight,\r\n type AutoHeightProps,\r\n} from '../effects/auto-height';\r\n\r\ntype TabsContextType = {\r\n value: string | undefined;\r\n setValue: TabsProps['onValueChange'];\r\n};\r\n\r\nconst [TabsProvider, useTabs] =\r\n getStrictContext<TabsContextType>('TabsContext');\r\n\r\ntype TabsProps = React.ComponentProps<typeof TabsPrimitive.Root>;\r\n\r\nfunction Tabs(props: TabsProps) {\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 return (\r\n <TabsProvider value={{ value, setValue }}>\r\n <TabsPrimitive.Root\r\n data-slot=\"tabs\"\r\n {...props}\r\n onValueChange={setValue}\r\n />\r\n </TabsProvider>\r\n );\r\n}\r\n\r\ntype TabsHighlightProps = Omit<HighlightProps, 'controlledItems' | 'value'>;\r\n\r\nfunction TabsHighlight({\r\n transition = { type: 'spring', stiffness: 200, damping: 25 },\r\n ...props\r\n}: TabsHighlightProps) {\r\n const { value } = useTabs();\r\n\r\n return (\r\n <Highlight\r\n data-slot=\"tabs-highlight\"\r\n controlledItems\r\n value={value}\r\n transition={transition}\r\n click={false}\r\n {...props}\r\n />\r\n );\r\n}\r\n\r\ntype TabsListProps = React.ComponentProps<typeof TabsPrimitive.List>;\r\n\r\nfunction TabsList(props: TabsListProps) {\r\n return <TabsPrimitive.List data-slot=\"tabs-list\" {...props} />;\r\n}\r\n\r\ntype TabsHighlightItemProps = HighlightItemProps & {\r\n value: string;\r\n};\r\n\r\nfunction TabsHighlightItem(props: TabsHighlightItemProps) {\r\n return <HighlightItem data-slot=\"tabs-highlight-item\" {...props} />;\r\n}\r\n\r\ntype TabsTabProps = React.ComponentProps<typeof TabsPrimitive.Tab>;\r\n\r\nfunction TabsTab(props: TabsTabProps) {\r\n return <TabsPrimitive.Tab data-slot=\"tabs-tab\" {...props} />;\r\n}\r\n\r\ntype TabsPanelProps = React.ComponentProps<typeof TabsPrimitive.Panel> &\r\n HTMLMotionProps<'div'>;\r\n\r\nfunction TabsPanel({\r\n value,\r\n keepMounted,\r\n transition = { duration: 0.5, ease: 'easeInOut' },\r\n ...props\r\n}: TabsPanelProps) {\r\n return (\r\n <AnimatePresence mode=\"wait\">\r\n <TabsPrimitive.Panel\r\n render={\r\n <motion.div\r\n data-slot=\"tabs-panel\"\r\n layout\r\n layoutDependency={value}\r\n initial={{ opacity: 0, filter: 'blur(4px)' }}\r\n animate={{ opacity: 1, filter: 'blur(0px)' }}\r\n exit={{ opacity: 0, filter: 'blur(4px)' }}\r\n transition={transition}\r\n {...props}\r\n />\r\n }\r\n keepMounted={keepMounted}\r\n value={value}\r\n />\r\n </AnimatePresence>\r\n );\r\n}\r\n\r\ntype TabsPanelsAutoProps = Omit<AutoHeightProps, 'children'> & {\r\n mode?: 'auto-height';\r\n children: React.ReactNode;\r\n transition?: Transition;\r\n};\r\n\r\ntype TabsPanelsLayoutProps = Omit<HTMLMotionProps<'div'>, 'children'> & {\r\n mode: 'layout';\r\n children: React.ReactNode;\r\n transition?: Transition;\r\n};\r\n\r\ntype TabsPanelsProps = TabsPanelsAutoProps | TabsPanelsLayoutProps;\r\n\r\nconst defaultTransition: Transition = {\r\n type: 'spring',\r\n stiffness: 200,\r\n damping: 30,\r\n};\r\n\r\nfunction isAutoMode(props: TabsPanelsProps): props is TabsPanelsAutoProps {\r\n return !props.mode || props.mode === 'auto-height';\r\n}\r\n\r\nfunction TabsPanels(props: TabsPanelsProps) {\r\n const { value } = useTabs();\r\n\r\n if (isAutoMode(props)) {\r\n const { children, transition = defaultTransition, ...autoProps } = props;\r\n\r\n return (\r\n <AutoHeight\r\n data-slot=\"tabs-panels\"\r\n deps={[value]}\r\n transition={transition}\r\n {...autoProps}\r\n >\r\n <React.Fragment key={value}>{children}</React.Fragment>\r\n </AutoHeight>\r\n );\r\n }\r\n\r\n const {\r\n children,\r\n style,\r\n transition = defaultTransition,\r\n ...layoutProps\r\n } = props;\r\n\r\n return (\r\n <motion.div\r\n data-slot=\"tabs-panels\"\r\n layout=\"size\"\r\n layoutDependency={value}\r\n transition={{ layout: transition }}\r\n style={{ overflow: 'hidden', ...style }}\r\n {...layoutProps}\r\n >\r\n <React.Fragment key={value}>{children}</React.Fragment>\r\n </motion.div>\r\n );\r\n}\r\n\r\nexport {\r\n Tabs,\r\n TabsHighlight,\r\n TabsHighlightItem,\r\n TabsList,\r\n TabsTab,\r\n TabsPanel,\r\n TabsPanels,\r\n type TabsProps,\r\n type TabsHighlightProps,\r\n type TabsHighlightItemProps,\r\n type TabsListProps,\r\n type TabsTabProps,\r\n type TabsPanelProps,\r\n type TabsPanelsProps,\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-3VMZENNL.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-TG3TM7XY.js.map
|
|
2
|
+
//# sourceMappingURL=chunk-TG3TM7XY.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","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,C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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,QAAA,CAAkB,EAAE,CAAA,CAC5DC,EAAyB,CAAA,CAAA,MAAA,CAAoB,IAAI,GAAK,CAAA,CAEtD,YAAU,IAAM,CACpB,IAAMC,CAAAA,CAAgB,IAAI,GAAA,CAAIL,GAAAA,CAAM,GAAA,CAAKM,CAAAA,EAAMA,CAAAA,CAAE,KAAK,CAAC,CAAA,CACvDH,EAAiBI,CAAAA,EAAS,CACxB,IAAMC,CAAAA,CAAOD,EAAK,MAAA,CAAQE,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E7D,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-TG3TM7XY.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,2 +1,2 @@
|
|
|
1
|
-
import {c,d,e,f,g,m,h,i,n,o,p,q as q$1,r,s,t,j as j$1,k,l,u,v}from'./chunk-
|
|
2
|
-
//# sourceMappingURL=chunk-
|
|
1
|
+
import {c,d,e,f,g,m,h,i,n,o,p,q as q$1,r,s,t,j as j$1,k,l,u,v}from'./chunk-VNU37GJC.js';import'react';import {cn}from'@xploreu/lib/cn';import {CheckIcon,CircleIcon,ChevronRightIcon}from'lucide-react';import {jsx,jsxs}from'react/jsx-runtime';function O(e){return jsx(c,{...e})}function j(e){return jsx(d,{...e})}function T(e$1){return jsx(e,{...e$1})}function q({className:e,finalFocus:t,id:i,children:n,sideOffset:o=4,transition:a={duration:.2},...p}){return jsx(T,{children:jsx(f,{className:"z-50",sideOffset:o,...p,children:jsx(g,{finalFocus:t,id:i,transition:a,className:cn("bg-bg-primary text-text-primary max-h-(--available-height) min-w-[8rem] origin-(--transform-origin) overflow-x-hidden overflow-y-auto rounded-md border border-border-primary p-1 shadow-xp-lg outline-hidden",e),children:jsx(m,{className:"absolute inset-0 z-0 rounded-sm bg-bg-primary-hover",children:n})})})})}function B(e){return jsx(h,{...e})}function D({className:e,inset:t,...i$1}){return jsx(i,{"data-inset":t,className:cn("px-2 py-1.5 text-label-semibold-4 text-text-secondary data-[inset]:pl-8",e),...i$1})}function E({className:e,inset:t,variant:i="default",disabled:n$1,...o$1}){return jsx(n,{activeClassName:i==="destructive"?"bg-bg-error-primary":"",disabled:n$1,children:jsx(o,{disabled:n$1,"data-inset":t,"data-variant":i,className:cn("focus:text-text-primary data-[variant=destructive]:text-text-error-primary data-[variant=destructive]:focus:text-text-error-primary data-[variant=destructive]:*:[svg]:!text-fg-error-primary [&_svg:not([class*='text-'])]:text-fg-secondary relative flex cursor-default items-center gap-2 rounded-sm px-2 py-1.5 text-body-regular-sm outline-hidden select-none data-[disabled=true]:pointer-events-none data-[disabled=true]:opacity-50 data-[inset]:pl-8 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",e),...o$1})})}function J({className:e,children:t,checked:i,disabled:n$1,...o}){return jsx(n,{disabled:n$1,children:jsxs(p,{disabled:n$1,className:cn("focus:text-text-primary relative flex cursor-default items-center gap-2 rounded-sm py-1.5 pr-2 pl-8 text-body-regular outline-hidden select-none data-[disabled=true]:pointer-events-none data-[disabled=true]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",e),checked:i,...o,children:[jsx("span",{className:"pointer-events-none absolute left-2 flex size-3.5 items-center justify-center",children:jsx(q$1,{animate:{opacity:1,scale:1},initial:{opacity:0,scale:.5},children:jsx(CheckIcon,{className:"size-4"})})}),t]})})}function K(e){return jsx(r,{...e})}function Q({className:e,children:t$1,disabled:i,...n$1}){return jsx(n,{disabled:i,children:jsxs(s,{disabled:i,className:cn("focus:text-text-primary relative flex cursor-default items-center gap-2 rounded-sm py-1.5 pr-2 pl-8 text-body-regular outline-hidden select-none disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",e),...n$1,children:[jsx("span",{className:"pointer-events-none absolute left-2 flex size-3.5 items-center justify-center",children:jsx(t,{layoutId:"menu-item-indicator-radio",children:jsx(CircleIcon,{className:"size-2 fill-current"})})}),t$1]})})}function U({className:e,...t}){return jsx(j$1,{className:cn("-mx-1 my-1 h-px bg-border-primary",e),...t})}function V({className:e,...t}){return jsx(k,{className:cn("text-text-quaternary ml-auto text-body-regular-xs tracking-widest",e),...t})}function W(e){return jsx(l,{...e})}function X(e){return jsx(u,{...e})}function Y({disabled:e,className:t,inset:i,children:n$1,...o}){return jsx(n,{disabled:e,children:jsxs(v,{disabled:e,"data-inset":i,className:cn("focus:text-text-primary data-[state=open]:text-text-primary flex cursor-default items-center rounded-sm px-2 py-1.5 text-body-regular outline-hidden select-none data-[inset]:pl-8","aria-[expanded=true]:[&_[data-slot=chevron]]:rotate-90 [&_[data-slot=chevron]]:transition-transform [&_[data-slot=chevron]]:duration-300 [&_[data-slot=chevron]]:ease-in-out",t),...o,children:[n$1,jsx(ChevronRightIcon,{"data-slot":"chevron",className:"ml-auto size-4"})]})})}function Z({className:e,finalFocus:t,id:i,children:n,sideOffset:o=4,transition:a={duration:.2},...p}){return jsx(T,{children:jsx(f,{className:"z-50",sideOffset:o,...p,children:jsx(g,{finalFocus:t,id:i,transition:a,className:cn("bg-bg-primary text-text-primary max-h-(--available-height) min-w-[8rem] origin-(--transform-origin) overflow-x-hidden overflow-y-auto rounded-md border border-border-primary p-1 shadow-xp-lg",e),children:n})})})}export{O as a,j as b,T as c,q as d,B as e,D as f,E as g,J as h,K as i,Q as j,U as k,V as l,W as m,X as n,Y as o,Z as p};//# sourceMappingURL=chunk-V2D72N26.js.map
|
|
2
|
+
//# sourceMappingURL=chunk-V2D72N26.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/ui/menu.tsx"],"names":["Menu","props","jsx","MenuTrigger","MenuPortal","MenuPanel","className","finalFocus","id","children","sideOffset","transition","MenuPositioner","MenuPopup","cn","MenuHighlight","MenuGroup","MenuGroupLabel","inset","MenuItem","variant","disabled","MenuHighlightItem","MenuCheckboxItem","checked","jsxs","MenuCheckboxItemIndicator","CheckIcon","MenuRadioGroup","MenuRadioItem","MenuRadioItemIndicator","CircleIcon","MenuSeparator","MenuShortcut","MenuArrow","MenuSubmenu","MenuSubmenuTrigger","ChevronRightIcon","MenuSubmenuPanel"],"mappings":"iPAmDA,SAASA,CAAAA,CAAKC,CAAAA,CAAkB,CAC9B,OAAOC,GAAAA,CAACF,CAAAA,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AAGV,CACL,CAAA,CAA0B,CACxB,OACEC,GAAAA,CAACE,CAAAA,CAAA,CACC,QAAA,CAAAF,GAAAA,CAACU,CAAAA,CAAA,CACC,SAAA,CAAU,MAAA,CACV,UAAA,CAAYF,CAAAA,CACX,GAAGT,CAAAA,CAEJ,QAAA,CAAAC,GAAAA,CAACW,CAAAA,CAAA,CACC,UAAA,CAAYN,CAAAA,CACZ,EAAA,CAAIC,CAAAA,CACJ,UAAA,CAAYG,CAAAA,CACZ,SAAA,CAAWG,EAAAA,CACT,gMAAA,CACAR,CACF,CAAA,CAEC,QAAA,CAAAG,CAAAA,CACH,CAAA,CACF,EACF,CAEJ","file":"chunk-RCA6JRHN.js","sourcesContent":["\"use client\"\r\n\r\nimport * as React from \"react\"\r\n\r\nimport {\r\n Menu as MenuPrimitive,\r\n MenuArrow as MenuArrowPrimitive,\r\n MenuCheckboxItem as MenuCheckboxItemPrimitive,\r\n MenuCheckboxItemIndicator as MenuCheckboxItemIndicatorPrimitive,\r\n MenuGroup as MenuGroupPrimitive,\r\n MenuGroupLabel as MenuGroupLabelPrimitive,\r\n MenuHighlight as MenuHighlightPrimitive,\r\n MenuHighlightItem as MenuHighlightItemPrimitive,\r\n MenuItem as MenuItemPrimitive,\r\n MenuPortal as MenuPortalPrimitive,\r\n MenuPopup as MenuPopupPrimitive,\r\n MenuPositioner as MenuPositionerPrimitive,\r\n MenuRadioGroup as MenuRadioGroupPrimitive,\r\n MenuRadioItem as MenuRadioItemPrimitive,\r\n MenuRadioItemIndicator as MenuRadioItemIndicatorPrimitive,\r\n MenuSeparator as MenuSeparatorPrimitive,\r\n MenuShortcut as MenuShortcutPrimitive,\r\n MenuSubmenu as MenuSubmenuPrimitive,\r\n MenuSubmenuTrigger as MenuSubmenuTriggerPrimitive,\r\n MenuTrigger as MenuTriggerPrimitive,\r\n type MenuArrowProps as MenuArrowPrimitiveProps,\r\n type MenuCheckboxItemIndicatorProps as MenuCheckboxItemIndicatorPrimitiveProps,\r\n type MenuCheckboxItemProps as MenuCheckboxItemPrimitiveProps,\r\n type MenuGroupLabelProps as MenuGroupLabelPrimitiveProps,\r\n type MenuGroupProps as MenuGroupPrimitiveProps,\r\n type MenuHighlightItemProps as MenuHighlightItemPrimitiveProps,\r\n type MenuHighlightProps as MenuHighlightPrimitiveProps,\r\n type MenuItemProps as MenuItemPrimitiveProps,\r\n type MenuPopupProps as MenuPopupPrimitiveProps,\r\n type MenuPortalProps as MenuPortalPrimitiveProps,\r\n type MenuPositionerProps as MenuPositionerPrimitiveProps,\r\n type MenuProps as MenuPrimitiveProps,\r\n type MenuRadioGroupProps as MenuRadioGroupPrimitiveProps,\r\n type MenuRadioItemProps as MenuRadioItemPrimitiveProps,\r\n type MenuRadioItemIndicatorProps as MenuRadioItemIndicatorPrimitiveProps,\r\n type MenuSeparatorProps as MenuSeparatorPrimitiveProps,\r\n type MenuShortcutProps as MenuShortcutPrimitiveProps,\r\n type MenuSubmenuProps as MenuSubmenuPrimitiveProps,\r\n type MenuSubmenuTriggerProps as MenuSubmenuTriggerPrimitiveProps,\r\n type MenuTriggerProps as MenuTriggerPrimitiveProps,\r\n} from \"../primitives/menu\"\r\nimport { cn } from \"@xploreu/lib/cn\"\r\nimport { CheckIcon, ChevronRightIcon, CircleIcon } from \"lucide-react\"\r\n\r\ntype MenuProps = MenuPrimitiveProps\r\n\r\nfunction Menu(props: MenuProps) {\r\n return <MenuPrimitive {...props} />\r\n}\r\n\r\ntype MenuTriggerProps = MenuTriggerPrimitiveProps\r\n\r\nfunction MenuTrigger(props: MenuTriggerProps) {\r\n return <MenuTriggerPrimitive {...props} />\r\n}\r\n\r\ntype MenuPortalProps = MenuPortalPrimitiveProps\r\n\r\nfunction MenuPortal(props: MenuPortalProps) {\r\n return <MenuPortalPrimitive {...props} />\r\n}\r\n\r\ntype MenuPanelProps = MenuPopupPrimitiveProps & MenuPositionerPrimitiveProps\r\n\r\nfunction MenuPanel({\r\n className,\r\n finalFocus,\r\n id,\r\n children,\r\n sideOffset = 4,\r\n transition = { duration: 0.2 },\r\n ...props\r\n}: MenuPanelProps) {\r\n return (\r\n <MenuPortal>\r\n <MenuPositionerPrimitive\r\n className=\"z-50\"\r\n sideOffset={sideOffset}\r\n {...props}\r\n >\r\n <MenuPopupPrimitive\r\n finalFocus={finalFocus}\r\n id={id}\r\n transition={transition}\r\n className={cn(\r\n \"bg-bg-primary text-text-primary max-h-(--available-height) min-w-[8rem] origin-(--transform-origin) overflow-x-hidden overflow-y-auto rounded-md border border-border-primary p-1 shadow-xp-lg outline-hidden\",\r\n className,\r\n )}\r\n >\r\n <MenuHighlightPrimitive className=\"absolute inset-0 z-0 rounded-sm bg-bg-primary-hover\">\r\n {children}\r\n </MenuHighlightPrimitive>\r\n </MenuPopupPrimitive>\r\n </MenuPositionerPrimitive>\r\n </MenuPortal>\r\n )\r\n}\r\n\r\ntype MenuGroupProps = MenuGroupPrimitiveProps\r\n\r\nfunction MenuGroup(props: MenuGroupProps) {\r\n return <MenuGroupPrimitive {...props} />\r\n}\r\n\r\ntype MenuGroupLabelProps = MenuGroupLabelPrimitiveProps & {\r\n inset?: boolean;\r\n}\r\n\r\nfunction MenuGroupLabel({ className, inset, ...props }: MenuGroupLabelProps) {\r\n return (\r\n <MenuGroupLabelPrimitive\r\n data-inset={inset}\r\n className={cn(\r\n \"px-2 py-1.5 text-label-semibold-4 text-text-secondary data-[inset]:pl-8\",\r\n className,\r\n )}\r\n {...props}\r\n />\r\n )\r\n}\r\n\r\ntype MenuItemProps = MenuItemPrimitiveProps & {\r\n inset?: boolean;\r\n variant?: \"default\" | \"destructive\";\r\n}\r\n\r\nfunction MenuItem({\r\n className,\r\n inset,\r\n variant = \"default\",\r\n disabled,\r\n ...props\r\n}: MenuItemProps) {\r\n return (\r\n <MenuHighlightItemPrimitive\r\n activeClassName={\r\n variant === \"destructive\" ? \"bg-bg-error-primary\" : \"\"\r\n }\r\n disabled={disabled}\r\n >\r\n <MenuItemPrimitive\r\n disabled={disabled}\r\n data-inset={inset}\r\n data-variant={variant}\r\n className={cn(\r\n \"focus:text-text-primary data-[variant=destructive]:text-text-error-primary data-[variant=destructive]:focus:text-text-error-primary data-[variant=destructive]:*:[svg]:!text-fg-error-primary [&_svg:not([class*='text-'])]:text-fg-secondary relative flex cursor-default items-center gap-2 rounded-sm px-2 py-1.5 text-body-regular-sm outline-hidden select-none data-[disabled=true]:pointer-events-none data-[disabled=true]:opacity-50 data-[inset]:pl-8 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4\",\r\n className,\r\n )}\r\n {...props}\r\n />\r\n </MenuHighlightItemPrimitive>\r\n )\r\n}\r\n\r\ntype MenuCheckboxItemProps = MenuCheckboxItemPrimitiveProps\r\n\r\nfunction MenuCheckboxItem({\r\n className,\r\n children,\r\n checked,\r\n disabled,\r\n ...props\r\n}: MenuCheckboxItemProps) {\r\n return (\r\n <MenuHighlightItemPrimitive disabled={disabled}>\r\n <MenuCheckboxItemPrimitive\r\n disabled={disabled}\r\n className={cn(\r\n \"focus:text-text-primary relative flex cursor-default items-center gap-2 rounded-sm py-1.5 pr-2 pl-8 text-body-regular outline-hidden select-none data-[disabled=true]:pointer-events-none data-[disabled=true]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4\",\r\n className,\r\n )}\r\n checked={checked}\r\n {...props}\r\n >\r\n <span className=\"pointer-events-none absolute left-2 flex size-3.5 items-center justify-center\">\r\n <MenuCheckboxItemIndicatorPrimitive\r\n animate={{ opacity: 1, scale: 1 }}\r\n initial={{ opacity: 0, scale: 0.5 }}\r\n >\r\n <CheckIcon className=\"size-4\" />\r\n </MenuCheckboxItemIndicatorPrimitive>\r\n </span>\r\n {children}\r\n </MenuCheckboxItemPrimitive>\r\n </MenuHighlightItemPrimitive>\r\n )\r\n}\r\n\r\ntype MenuRadioGroupProps = MenuRadioGroupPrimitiveProps\r\n\r\nfunction MenuRadioGroup(props: MenuRadioGroupProps) {\r\n return <MenuRadioGroupPrimitive {...props} />\r\n}\r\n\r\ntype MenuRadioItemProps = MenuRadioItemPrimitiveProps\r\n\r\nfunction MenuRadioItem({\r\n className,\r\n children,\r\n disabled,\r\n ...props\r\n}: MenuRadioItemProps) {\r\n return (\r\n <MenuHighlightItemPrimitive disabled={disabled}>\r\n <MenuRadioItemPrimitive\r\n disabled={disabled}\r\n className={cn(\r\n \"focus:text-text-primary relative flex cursor-default items-center gap-2 rounded-sm py-1.5 pr-2 pl-8 text-body-regular outline-hidden select-none disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4\",\r\n className,\r\n )}\r\n {...props}\r\n >\r\n <span className=\"pointer-events-none absolute left-2 flex size-3.5 items-center justify-center\">\r\n <MenuRadioItemIndicatorPrimitive layoutId=\"menu-item-indicator-radio\">\r\n <CircleIcon className=\"size-2 fill-current\" />\r\n </MenuRadioItemIndicatorPrimitive>\r\n </span>\r\n {children}\r\n </MenuRadioItemPrimitive>\r\n </MenuHighlightItemPrimitive>\r\n )\r\n}\r\n\r\ntype MenuSeparatorProps = MenuSeparatorPrimitiveProps\r\n\r\nfunction MenuSeparator({ className, ...props }: MenuSeparatorProps) {\r\n return (\r\n <MenuSeparatorPrimitive\r\n className={cn(\"-mx-1 my-1 h-px bg-border-primary\", className)}\r\n {...props}\r\n />\r\n )\r\n}\r\n\r\ntype MenuShortcutProps = MenuShortcutPrimitiveProps\r\n\r\nfunction MenuShortcut({ className, ...props }: MenuShortcutProps) {\r\n return (\r\n <MenuShortcutPrimitive\r\n className={cn(\r\n \"text-text-quaternary ml-auto text-body-regular-xs tracking-widest\",\r\n className,\r\n )}\r\n {...props}\r\n />\r\n )\r\n}\r\n\r\ntype MenuArrowProps = MenuArrowPrimitiveProps\r\n\r\nfunction MenuArrow(props: MenuArrowProps) {\r\n return <MenuArrowPrimitive {...props} />\r\n}\r\n\r\ntype MenuSubmenuProps = MenuSubmenuPrimitiveProps\r\n\r\nfunction MenuSubmenu(props: MenuSubmenuProps) {\r\n return <MenuSubmenuPrimitive {...props} />\r\n}\r\n\r\ntype MenuSubmenuTriggerProps = MenuSubmenuTriggerPrimitiveProps & {\r\n inset?: boolean;\r\n children?: React.ReactNode;\r\n}\r\n\r\nfunction MenuSubmenuTrigger({\r\n disabled,\r\n className,\r\n inset,\r\n children,\r\n ...props\r\n}: MenuSubmenuTriggerProps) {\r\n return (\r\n <MenuHighlightItemPrimitive disabled={disabled}>\r\n <MenuSubmenuTriggerPrimitive\r\n disabled={disabled}\r\n data-inset={inset}\r\n className={cn(\r\n \"focus:text-text-primary data-[state=open]:text-text-primary flex cursor-default items-center rounded-sm px-2 py-1.5 text-body-regular outline-hidden select-none data-[inset]:pl-8\",\r\n \"aria-[expanded=true]:[&_[data-slot=chevron]]:rotate-90 [&_[data-slot=chevron]]:transition-transform [&_[data-slot=chevron]]:duration-300 [&_[data-slot=chevron]]:ease-in-out\",\r\n className,\r\n )}\r\n {...props}\r\n >\r\n {children}\r\n <ChevronRightIcon\r\n data-slot=\"chevron\"\r\n className=\"ml-auto size-4\"\r\n />\r\n </MenuSubmenuTriggerPrimitive>\r\n </MenuHighlightItemPrimitive>\r\n )\r\n}\r\n\r\ntype MenuSubmenuPanelProps = MenuPopupPrimitiveProps &\r\n MenuPositionerPrimitiveProps\r\n\r\nfunction MenuSubmenuPanel({\r\n className,\r\n finalFocus,\r\n id,\r\n children,\r\n sideOffset = 4,\r\n transition = { duration: 0.2 },\r\n ...props\r\n}: MenuSubmenuPanelProps) {\r\n return (\r\n <MenuPortal>\r\n <MenuPositionerPrimitive\r\n className=\"z-50\"\r\n sideOffset={sideOffset}\r\n {...props}\r\n >\r\n <MenuPopupPrimitive\r\n finalFocus={finalFocus}\r\n id={id}\r\n transition={transition}\r\n className={cn(\r\n \"bg-bg-primary text-text-primary max-h-(--available-height) min-w-[8rem] origin-(--transform-origin) overflow-x-hidden overflow-y-auto rounded-md border border-border-primary p-1 shadow-xp-lg\",\r\n className,\r\n )}\r\n >\r\n {children}\r\n </MenuPopupPrimitive>\r\n </MenuPositionerPrimitive>\r\n </MenuPortal>\r\n )\r\n}\r\n\r\nexport {\r\n Menu,\r\n MenuTrigger,\r\n MenuPortal,\r\n MenuPanel,\r\n MenuGroup,\r\n MenuGroupLabel,\r\n MenuItem,\r\n MenuCheckboxItem,\r\n MenuRadioGroup,\r\n MenuRadioItem,\r\n MenuSeparator,\r\n MenuShortcut,\r\n MenuArrow,\r\n MenuSubmenu,\r\n MenuSubmenuTrigger,\r\n MenuSubmenuPanel,\r\n type MenuProps,\r\n type MenuTriggerProps,\r\n type MenuPortalProps,\r\n type MenuPanelProps,\r\n type MenuGroupProps,\r\n type MenuGroupLabelProps,\r\n type MenuItemProps,\r\n type MenuCheckboxItemProps,\r\n type MenuRadioGroupProps,\r\n type MenuRadioItemProps,\r\n type MenuSeparatorProps,\r\n type MenuShortcutProps,\r\n type MenuArrowProps,\r\n type MenuSubmenuProps,\r\n type MenuSubmenuTriggerProps,\r\n type MenuSubmenuPanelProps,\r\n}"]}
|
|
1
|
+
{"version":3,"sources":["../src/ui/menu.tsx"],"names":["Menu","props","jsx","MenuTrigger","MenuPortal","MenuPanel","className","finalFocus","id","children","sideOffset","transition","MenuPositioner","MenuPopup","cn","MenuHighlight","MenuGroup","MenuGroupLabel","inset","MenuItem","variant","disabled","MenuHighlightItem","MenuCheckboxItem","checked","jsxs","MenuCheckboxItemIndicator","CheckIcon","MenuRadioGroup","MenuRadioItem","MenuRadioItemIndicator","CircleIcon","MenuSeparator","MenuShortcut","MenuArrow","MenuSubmenu","MenuSubmenuTrigger","ChevronRightIcon","MenuSubmenuPanel"],"mappings":"iPAmDA,SAASA,CAAAA,CAAKC,CAAAA,CAAkB,CAC9B,OAAOC,GAAAA,CAACF,CAAAA,CAAA,CAAe,GAAGC,CAAAA,CAAO,CACnC,CAIA,SAASE,CAAAA,CAAYF,CAAAA,CAAyB,CAC5C,OAAOC,GAAAA,CAACC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,CACC,SAAA,CAAU,MAAA,CACV,UAAA,CAAYF,CAAAA,CACX,GAAGT,CAAAA,CAEJ,QAAA,CAAAC,GAAAA,CAACW,CAAAA,CAAA,CACC,UAAA,CAAYN,CAAAA,CACZ,EAAA,CAAIC,CAAAA,CACJ,UAAA,CAAYG,CAAAA,CACZ,SAAA,CAAWG,EAAAA,CACT,gMAAA,CACAR,CACF,CAAA,CAEC,QAAA,CAAAG,CAAAA,CACH,CAAA,CACF,EACF,CAEJ","file":"chunk-V2D72N26.js","sourcesContent":["\"use client\"\r\n\r\nimport * as React from \"react\"\r\n\r\nimport {\r\n Menu as MenuPrimitive,\r\n MenuArrow as MenuArrowPrimitive,\r\n MenuCheckboxItem as MenuCheckboxItemPrimitive,\r\n MenuCheckboxItemIndicator as MenuCheckboxItemIndicatorPrimitive,\r\n MenuGroup as MenuGroupPrimitive,\r\n MenuGroupLabel as MenuGroupLabelPrimitive,\r\n MenuHighlight as MenuHighlightPrimitive,\r\n MenuHighlightItem as MenuHighlightItemPrimitive,\r\n MenuItem as MenuItemPrimitive,\r\n MenuPortal as MenuPortalPrimitive,\r\n MenuPopup as MenuPopupPrimitive,\r\n MenuPositioner as MenuPositionerPrimitive,\r\n MenuRadioGroup as MenuRadioGroupPrimitive,\r\n MenuRadioItem as MenuRadioItemPrimitive,\r\n MenuRadioItemIndicator as MenuRadioItemIndicatorPrimitive,\r\n MenuSeparator as MenuSeparatorPrimitive,\r\n MenuShortcut as MenuShortcutPrimitive,\r\n MenuSubmenu as MenuSubmenuPrimitive,\r\n MenuSubmenuTrigger as MenuSubmenuTriggerPrimitive,\r\n MenuTrigger as MenuTriggerPrimitive,\r\n type MenuArrowProps as MenuArrowPrimitiveProps,\r\n type MenuCheckboxItemIndicatorProps as MenuCheckboxItemIndicatorPrimitiveProps,\r\n type MenuCheckboxItemProps as MenuCheckboxItemPrimitiveProps,\r\n type MenuGroupLabelProps as MenuGroupLabelPrimitiveProps,\r\n type MenuGroupProps as MenuGroupPrimitiveProps,\r\n type MenuHighlightItemProps as MenuHighlightItemPrimitiveProps,\r\n type MenuHighlightProps as MenuHighlightPrimitiveProps,\r\n type MenuItemProps as MenuItemPrimitiveProps,\r\n type MenuPopupProps as MenuPopupPrimitiveProps,\r\n type MenuPortalProps as MenuPortalPrimitiveProps,\r\n type MenuPositionerProps as MenuPositionerPrimitiveProps,\r\n type MenuProps as MenuPrimitiveProps,\r\n type MenuRadioGroupProps as MenuRadioGroupPrimitiveProps,\r\n type MenuRadioItemProps as MenuRadioItemPrimitiveProps,\r\n type MenuRadioItemIndicatorProps as MenuRadioItemIndicatorPrimitiveProps,\r\n type MenuSeparatorProps as MenuSeparatorPrimitiveProps,\r\n type MenuShortcutProps as MenuShortcutPrimitiveProps,\r\n type MenuSubmenuProps as MenuSubmenuPrimitiveProps,\r\n type MenuSubmenuTriggerProps as MenuSubmenuTriggerPrimitiveProps,\r\n type MenuTriggerProps as MenuTriggerPrimitiveProps,\r\n} from \"../primitives/menu\"\r\nimport { cn } from \"@xploreu/lib/cn\"\r\nimport { CheckIcon, ChevronRightIcon, CircleIcon } from \"lucide-react\"\r\n\r\ntype MenuProps = MenuPrimitiveProps\r\n\r\nfunction Menu(props: MenuProps) {\r\n return <MenuPrimitive {...props} />\r\n}\r\n\r\ntype MenuTriggerProps = MenuTriggerPrimitiveProps\r\n\r\nfunction MenuTrigger(props: MenuTriggerProps) {\r\n return <MenuTriggerPrimitive {...props} />\r\n}\r\n\r\ntype MenuPortalProps = MenuPortalPrimitiveProps\r\n\r\nfunction MenuPortal(props: MenuPortalProps) {\r\n return <MenuPortalPrimitive {...props} />\r\n}\r\n\r\ntype MenuPanelProps = MenuPopupPrimitiveProps & MenuPositionerPrimitiveProps\r\n\r\nfunction MenuPanel({\r\n className,\r\n finalFocus,\r\n id,\r\n children,\r\n sideOffset = 4,\r\n transition = { duration: 0.2 },\r\n ...props\r\n}: MenuPanelProps) {\r\n return (\r\n <MenuPortal>\r\n <MenuPositionerPrimitive\r\n className=\"z-50\"\r\n sideOffset={sideOffset}\r\n {...props}\r\n >\r\n <MenuPopupPrimitive\r\n finalFocus={finalFocus}\r\n id={id}\r\n transition={transition}\r\n className={cn(\r\n \"bg-bg-primary text-text-primary max-h-(--available-height) min-w-[8rem] origin-(--transform-origin) overflow-x-hidden overflow-y-auto rounded-md border border-border-primary p-1 shadow-xp-lg outline-hidden\",\r\n className,\r\n )}\r\n >\r\n <MenuHighlightPrimitive className=\"absolute inset-0 z-0 rounded-sm bg-bg-primary-hover\">\r\n {children}\r\n </MenuHighlightPrimitive>\r\n </MenuPopupPrimitive>\r\n </MenuPositionerPrimitive>\r\n </MenuPortal>\r\n )\r\n}\r\n\r\ntype MenuGroupProps = MenuGroupPrimitiveProps\r\n\r\nfunction MenuGroup(props: MenuGroupProps) {\r\n return <MenuGroupPrimitive {...props} />\r\n}\r\n\r\ntype MenuGroupLabelProps = MenuGroupLabelPrimitiveProps & {\r\n inset?: boolean;\r\n}\r\n\r\nfunction MenuGroupLabel({ className, inset, ...props }: MenuGroupLabelProps) {\r\n return (\r\n <MenuGroupLabelPrimitive\r\n data-inset={inset}\r\n className={cn(\r\n \"px-2 py-1.5 text-label-semibold-4 text-text-secondary data-[inset]:pl-8\",\r\n className,\r\n )}\r\n {...props}\r\n />\r\n )\r\n}\r\n\r\ntype MenuItemProps = MenuItemPrimitiveProps & {\r\n inset?: boolean;\r\n variant?: \"default\" | \"destructive\";\r\n}\r\n\r\nfunction MenuItem({\r\n className,\r\n inset,\r\n variant = \"default\",\r\n disabled,\r\n ...props\r\n}: MenuItemProps) {\r\n return (\r\n <MenuHighlightItemPrimitive\r\n activeClassName={\r\n variant === \"destructive\" ? \"bg-bg-error-primary\" : \"\"\r\n }\r\n disabled={disabled}\r\n >\r\n <MenuItemPrimitive\r\n disabled={disabled}\r\n data-inset={inset}\r\n data-variant={variant}\r\n className={cn(\r\n \"focus:text-text-primary data-[variant=destructive]:text-text-error-primary data-[variant=destructive]:focus:text-text-error-primary data-[variant=destructive]:*:[svg]:!text-fg-error-primary [&_svg:not([class*='text-'])]:text-fg-secondary relative flex cursor-default items-center gap-2 rounded-sm px-2 py-1.5 text-body-regular-sm outline-hidden select-none data-[disabled=true]:pointer-events-none data-[disabled=true]:opacity-50 data-[inset]:pl-8 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4\",\r\n className,\r\n )}\r\n {...props}\r\n />\r\n </MenuHighlightItemPrimitive>\r\n )\r\n}\r\n\r\ntype MenuCheckboxItemProps = MenuCheckboxItemPrimitiveProps\r\n\r\nfunction MenuCheckboxItem({\r\n className,\r\n children,\r\n checked,\r\n disabled,\r\n ...props\r\n}: MenuCheckboxItemProps) {\r\n return (\r\n <MenuHighlightItemPrimitive disabled={disabled}>\r\n <MenuCheckboxItemPrimitive\r\n disabled={disabled}\r\n className={cn(\r\n \"focus:text-text-primary relative flex cursor-default items-center gap-2 rounded-sm py-1.5 pr-2 pl-8 text-body-regular outline-hidden select-none data-[disabled=true]:pointer-events-none data-[disabled=true]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4\",\r\n className,\r\n )}\r\n checked={checked}\r\n {...props}\r\n >\r\n <span className=\"pointer-events-none absolute left-2 flex size-3.5 items-center justify-center\">\r\n <MenuCheckboxItemIndicatorPrimitive\r\n animate={{ opacity: 1, scale: 1 }}\r\n initial={{ opacity: 0, scale: 0.5 }}\r\n >\r\n <CheckIcon className=\"size-4\" />\r\n </MenuCheckboxItemIndicatorPrimitive>\r\n </span>\r\n {children}\r\n </MenuCheckboxItemPrimitive>\r\n </MenuHighlightItemPrimitive>\r\n )\r\n}\r\n\r\ntype MenuRadioGroupProps = MenuRadioGroupPrimitiveProps\r\n\r\nfunction MenuRadioGroup(props: MenuRadioGroupProps) {\r\n return <MenuRadioGroupPrimitive {...props} />\r\n}\r\n\r\ntype MenuRadioItemProps = MenuRadioItemPrimitiveProps\r\n\r\nfunction MenuRadioItem({\r\n className,\r\n children,\r\n disabled,\r\n ...props\r\n}: MenuRadioItemProps) {\r\n return (\r\n <MenuHighlightItemPrimitive disabled={disabled}>\r\n <MenuRadioItemPrimitive\r\n disabled={disabled}\r\n className={cn(\r\n \"focus:text-text-primary relative flex cursor-default items-center gap-2 rounded-sm py-1.5 pr-2 pl-8 text-body-regular outline-hidden select-none disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4\",\r\n className,\r\n )}\r\n {...props}\r\n >\r\n <span className=\"pointer-events-none absolute left-2 flex size-3.5 items-center justify-center\">\r\n <MenuRadioItemIndicatorPrimitive layoutId=\"menu-item-indicator-radio\">\r\n <CircleIcon className=\"size-2 fill-current\" />\r\n </MenuRadioItemIndicatorPrimitive>\r\n </span>\r\n {children}\r\n </MenuRadioItemPrimitive>\r\n </MenuHighlightItemPrimitive>\r\n )\r\n}\r\n\r\ntype MenuSeparatorProps = MenuSeparatorPrimitiveProps\r\n\r\nfunction MenuSeparator({ className, ...props }: MenuSeparatorProps) {\r\n return (\r\n <MenuSeparatorPrimitive\r\n className={cn(\"-mx-1 my-1 h-px bg-border-primary\", className)}\r\n {...props}\r\n />\r\n )\r\n}\r\n\r\ntype MenuShortcutProps = MenuShortcutPrimitiveProps\r\n\r\nfunction MenuShortcut({ className, ...props }: MenuShortcutProps) {\r\n return (\r\n <MenuShortcutPrimitive\r\n className={cn(\r\n \"text-text-quaternary ml-auto text-body-regular-xs tracking-widest\",\r\n className,\r\n )}\r\n {...props}\r\n />\r\n )\r\n}\r\n\r\ntype MenuArrowProps = MenuArrowPrimitiveProps\r\n\r\nfunction MenuArrow(props: MenuArrowProps) {\r\n return <MenuArrowPrimitive {...props} />\r\n}\r\n\r\ntype MenuSubmenuProps = MenuSubmenuPrimitiveProps\r\n\r\nfunction MenuSubmenu(props: MenuSubmenuProps) {\r\n return <MenuSubmenuPrimitive {...props} />\r\n}\r\n\r\ntype MenuSubmenuTriggerProps = MenuSubmenuTriggerPrimitiveProps & {\r\n inset?: boolean;\r\n children?: React.ReactNode;\r\n}\r\n\r\nfunction MenuSubmenuTrigger({\r\n disabled,\r\n className,\r\n inset,\r\n children,\r\n ...props\r\n}: MenuSubmenuTriggerProps) {\r\n return (\r\n <MenuHighlightItemPrimitive disabled={disabled}>\r\n <MenuSubmenuTriggerPrimitive\r\n disabled={disabled}\r\n data-inset={inset}\r\n className={cn(\r\n \"focus:text-text-primary data-[state=open]:text-text-primary flex cursor-default items-center rounded-sm px-2 py-1.5 text-body-regular outline-hidden select-none data-[inset]:pl-8\",\r\n \"aria-[expanded=true]:[&_[data-slot=chevron]]:rotate-90 [&_[data-slot=chevron]]:transition-transform [&_[data-slot=chevron]]:duration-300 [&_[data-slot=chevron]]:ease-in-out\",\r\n className,\r\n )}\r\n {...props}\r\n >\r\n {children}\r\n <ChevronRightIcon\r\n data-slot=\"chevron\"\r\n className=\"ml-auto size-4\"\r\n />\r\n </MenuSubmenuTriggerPrimitive>\r\n </MenuHighlightItemPrimitive>\r\n )\r\n}\r\n\r\ntype MenuSubmenuPanelProps = MenuPopupPrimitiveProps &\r\n MenuPositionerPrimitiveProps\r\n\r\nfunction MenuSubmenuPanel({\r\n className,\r\n finalFocus,\r\n id,\r\n children,\r\n sideOffset = 4,\r\n transition = { duration: 0.2 },\r\n ...props\r\n}: MenuSubmenuPanelProps) {\r\n return (\r\n <MenuPortal>\r\n <MenuPositionerPrimitive\r\n className=\"z-50\"\r\n sideOffset={sideOffset}\r\n {...props}\r\n >\r\n <MenuPopupPrimitive\r\n finalFocus={finalFocus}\r\n id={id}\r\n transition={transition}\r\n className={cn(\r\n \"bg-bg-primary text-text-primary max-h-(--available-height) min-w-[8rem] origin-(--transform-origin) overflow-x-hidden overflow-y-auto rounded-md border border-border-primary p-1 shadow-xp-lg\",\r\n className,\r\n )}\r\n >\r\n {children}\r\n </MenuPopupPrimitive>\r\n </MenuPositionerPrimitive>\r\n </MenuPortal>\r\n )\r\n}\r\n\r\nexport {\r\n Menu,\r\n MenuTrigger,\r\n MenuPortal,\r\n MenuPanel,\r\n MenuGroup,\r\n MenuGroupLabel,\r\n MenuItem,\r\n MenuCheckboxItem,\r\n MenuRadioGroup,\r\n MenuRadioItem,\r\n MenuSeparator,\r\n MenuShortcut,\r\n MenuArrow,\r\n MenuSubmenu,\r\n MenuSubmenuTrigger,\r\n MenuSubmenuPanel,\r\n type MenuProps,\r\n type MenuTriggerProps,\r\n type MenuPortalProps,\r\n type MenuPanelProps,\r\n type MenuGroupProps,\r\n type MenuGroupLabelProps,\r\n type MenuItemProps,\r\n type MenuCheckboxItemProps,\r\n type MenuRadioGroupProps,\r\n type MenuRadioItemProps,\r\n type MenuSeparatorProps,\r\n type MenuShortcutProps,\r\n type MenuArrowProps,\r\n type MenuSubmenuProps,\r\n type MenuSubmenuTriggerProps,\r\n type MenuSubmenuPanelProps,\r\n}"]}
|
|
@@ -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-3VMZENNL.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-VE5SIEG4.js.map
|
|
2
|
+
//# sourceMappingURL=chunk-VE5SIEG4.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,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CAAU,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-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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AA,CACE,QAAA,CAAA,CAAA5C,GAAAA,EAAO,IAAKkB,CAAAA,EACXa,GAAAA,CAACc,CAAAA,CAAA,CAEC,KAAA,CAAO3B,CAAAA,CAEP,QAAA,CAAAM,IAAAA,CAAC,OAAI,SAAA,CAAU,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-VE5SIEG4.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 C from'react';import {Menu}from'@base-ui/react/menu';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 [T,c]=getStrictContext("MenuActiveValueContext"),[R,k]=getStrictContext("MenuContext");function A(e){let[n,o]=useControlledState({value:e?.open,defaultValue:e?.defaultOpen,onChange:e?.onOpenChange}),[i,u]=C.useState(null);return jsx(T,{value:{highlightedValue:i,setHighlightedValue:u},children:jsx(R,{value:{isOpen:n,setIsOpen:o},children:jsx(Menu.Root,{"data-slot":"menu",...e,onOpenChange:o})})})}function w(e){return jsx(Menu.Trigger,{"data-slot":"menu-trigger",...e})}function D(e){let{isOpen:n}=k();return jsx(AnimatePresence,{children:n&&jsx(Menu.Portal,{"data-slot":"menu-portal",keepMounted:true,...e})})}function B(e){return jsx(Menu.Positioner,{"data-slot":"menu-positioner",...e})}function E({finalFocus:e,id:n,transition:o={duration:.2},style:i,...u}){return jsx(Menu.Popup,{finalFocus:e,id:n,render:jsx(motion.div,{animate:{opacity:1,scale:1},"data-slot":"menu-popup",exit:{opacity:0,scale:.95},initial:{opacity:0,scale:.95},style:{willChange:"opacity, transform",...i},transition:o,...u},"menu-popup")})}function F(e){return jsx(Menu.Group,{"data-slot":"menu-group",...e})}function q(e){return jsx(Menu.GroupLabel,{"data-slot":"menu-group-label",...e})}function z(e){return jsx(Menu.Separator,{"data-slot":"menu-separator",...e})}function J(e){return jsx("span",{"data-slot":"menu-shortcut",...e})}function K(e){return jsx(Menu.Arrow,{"data-slot":"menu-arrow",...e})}function N({transition:e={type:"spring",stiffness:350,damping:35},...n}){let{highlightedValue:o}=c();return jsx(b,{click:false,controlledItems:true,"data-slot":"menu-highlight",transition:e,value:o,...n})}function Q(e){return jsx(c$1,{"data-slot":"menu-highlight-item",...e})}function U({disabled:e,label:n,closeOnClick:o,nativeButton:i,id:u,...s}){let{setHighlightedValue:m}=c(),[,p]=useDataState("highlighted",void 0,a=>{if(a===true){let d=p.current,l=d?.dataset.value||d?.id||null;l&&m(l);}});return jsx(Menu.Item,{ref:p,closeOnClick:o,"data-slot":"menu-item",disabled:e,id:u,label:n,nativeButton:i,...s})}function W({label:e,defaultChecked:n,checked:o,onCheckedChange:i,disabled:u,closeOnClick:s,nativeButton:m,id:p,...a}){let{setHighlightedValue:d}=c(),[,l]=useDataState("highlighted",void 0,M=>{if(M===true){let h=l.current,y=h?.dataset.value||h?.id||null;y&&d(y);}});return jsx(Menu.CheckboxItem,{ref:l,checked:o,closeOnClick:s,"data-slot":"menu-checkbox-item",defaultChecked:n,disabled:u,id:p,label:e,nativeButton:m,onCheckedChange:i,...a})}function X({keepMounted:e,...n}){return jsx(Menu.CheckboxItemIndicator,{"data-slot":"menu-checkbox-item-indicator",keepMounted:e,render:jsx(motion.div,{"data-slot":"menu-checkbox-item-indicator",...n})})}function Y(e){return jsx(Menu.RadioGroup,{"data-slot":"menu-radio-group",...e})}function Z({value:e,disabled:n,label:o,closeOnClick:i,nativeButton:u,id:s,...m}){let{setHighlightedValue:p}=c(),[,a]=useDataState("highlighted",void 0,d=>{if(d===true){let l=a.current,M=l?.dataset.value||l?.id||null;M&&p(M);}});return jsx(Menu.RadioItem,{ref:a,closeOnClick:i,"data-slot":"menu-radio-item",disabled:n,id:s,label:o,nativeButton:u,value:e,...m})}function _({keepMounted:e,...n}){return jsx(Menu.RadioItemIndicator,{"data-slot":"menu-radio-item-indicator",keepMounted:e,render:jsx(motion.div,{"data-slot":"menu-radio-item-indicator",...n})})}function $(e){let[n,o]=useControlledState({value:e?.open,defaultValue:e?.defaultOpen,onChange:e?.onOpenChange});return jsx(R,{value:{isOpen:n,setIsOpen:o},children:jsx(Menu.SubmenuRoot,{"data-slot":"menu-submenu",...e,onOpenChange:o})})}function j({label:e,id:n,nativeButton:o,...i}){let{setHighlightedValue:u}=c(),[,s]=useDataState("highlighted",void 0,m=>{if(m===true){let p=s.current,a=p?.dataset.value||p?.id||null;a&&u(a);}});return jsx(Menu.SubmenuTrigger,{ref:s,"data-slot":"menu-submenu-trigger",id:n,label:e,nativeButton:o,...i})}export{c as a,k as b,A as c,w as d,D as e,B as f,E 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};//# sourceMappingURL=chunk-VNU37GJC.js.map
|
|
2
|
+
//# sourceMappingURL=chunk-VNU37GJC.js.map
|