@gbmtech/aurora-ui 0.2.17 → 0.2.19

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.
@@ -1,2 +1,2 @@
1
- "use strict";let __rslib_import_meta_url__="undefined"==typeof document?new(require("url".replace("",""))).URL("file:"+__filename).href:document.currentScript&&document.currentScript.src||new URL("main.js",document.baseURI).href;var __webpack_require__={};__webpack_require__.d=(e,a)=>{for(var t in a)__webpack_require__.o(a,t)&&!__webpack_require__.o(e,t)&&Object.defineProperty(e,t,{enumerable:!0,get:a[t]})},__webpack_require__.o=(e,a)=>Object.prototype.hasOwnProperty.call(e,a),__webpack_require__.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var __webpack_exports__={};__webpack_require__.r(__webpack_exports__),__webpack_require__.d(__webpack_exports__,{AsyncSelect:()=>AsyncSelect});let jsx_runtime_namespaceObject=require("react/jsx-runtime"),external_react_namespaceObject=require("react"),use_debounce_cjs_namespaceObject=require("../hooks/use-debounce.cjs"),utils_cjs_namespaceObject=require("../lib/utils.cjs"),react_namespaceObject=require("@phosphor-icons/react"),external_button_cjs_namespaceObject=require("./button.cjs"),external_command_cjs_namespaceObject=require("./command.cjs"),external_popover_cjs_namespaceObject=require("./popover.cjs"),external_spinner_cjs_namespaceObject=require("./spinner.cjs");function AsyncSelect({fetcher:e,preload:a,filterFn:t,renderOption:c,getOptionValue:n,getDisplayValue:s,notFound:_,loadingSkeleton:r,label:m,placeholder:l="Select...",value:j,onChange:p,disabled:i=!1,width:o="200px",className:u,triggerClassName:b,noResultsMessage:x,clearable:d=!0,enabled:O=!0}){let[f,h]=(0,external_react_namespaceObject.useState)(!1),[w,y]=(0,external_react_namespaceObject.useState)(!1),[v,S]=(0,external_react_namespaceObject.useState)([]),[g,k]=(0,external_react_namespaceObject.useState)(!1),[q,C]=(0,external_react_namespaceObject.useState)(null),[N,P]=(0,external_react_namespaceObject.useState)(j),[E,L]=(0,external_react_namespaceObject.useState)(null),[A,D]=(0,external_react_namespaceObject.useState)(""),I=(0,use_debounce_cjs_namespaceObject.useDebounce)(A,300*!a),[U,F]=(0,external_react_namespaceObject.useState)([]);(0,external_react_namespaceObject.useEffect)(()=>{h(!0),P(j)},[j]),(0,external_react_namespaceObject.useEffect)(()=>{if(j&&v.length>0){let e=v.find(e=>n(e)===j);e&&L(e)}},[j,v,n]),(0,external_react_namespaceObject.useEffect)(()=>{let a=async()=>{try{k(!0),C(null);let a=await e(j);F(a),S(a)}catch(e){C(e instanceof Error?e.message:"Failed to fetch options")}finally{k(!1)}};!f&&O&&a()},[f,e,j]),(0,external_react_namespaceObject.useEffect)(()=>{let c=async()=>{try{k(!0),C(null);let a=await e(I);F(a),S(a)}catch(e){C(e instanceof Error?e.message:"Failed to fetch options")}finally{k(!1)}};!f&&O||!a&&O?c():a&&(I?S(U.filter(e=>!t||t(e,I))):S(U))},[e,I,f,a,t]);let M=(0,external_react_namespaceObject.useCallback)(e=>{let a=d&&e===N?"":e;P(a),L(v.find(e=>n(e)===a)||null),p(a),y(!1)},[N,p,d,v,n]);return(0,jsx_runtime_namespaceObject.jsxs)(external_popover_cjs_namespaceObject.Popover,{open:w,onOpenChange:y,children:[(0,jsx_runtime_namespaceObject.jsx)(external_popover_cjs_namespaceObject.PopoverTrigger,{asChild:!0,children:(0,jsx_runtime_namespaceObject.jsxs)(external_button_cjs_namespaceObject.Button,{variant:"secondary",role:"combobox","aria-expanded":w,className:(0,utils_cjs_namespaceObject.cn)("justify-between",i&&"cursor-not-allowed opacity-50",b),style:{width:o},disabled:i,children:[E?s(E):l,(0,jsx_runtime_namespaceObject.jsx)(react_namespaceObject.CaretUpDown,{className:"opacity-50",size:10})]})}),(0,jsx_runtime_namespaceObject.jsx)(external_popover_cjs_namespaceObject.PopoverContent,{style:{width:o},className:(0,utils_cjs_namespaceObject.cn)("p-0",u),children:(0,jsx_runtime_namespaceObject.jsxs)(external_command_cjs_namespaceObject.Command,{shouldFilter:!1,children:[(0,jsx_runtime_namespaceObject.jsxs)("div",{className:"relative w-full border-b",children:[(0,jsx_runtime_namespaceObject.jsx)(external_command_cjs_namespaceObject.CommandInput,{placeholder:`Search ${m.toLowerCase()}...`,value:A,onValueChange:e=>{D(e)}}),g&&v.length>0&&(0,jsx_runtime_namespaceObject.jsx)("div",{className:"-translate-y-1/2 absolute top-1/2 right-2 flex transform items-center",children:(0,jsx_runtime_namespaceObject.jsx)(external_spinner_cjs_namespaceObject.Spinner,{})})]}),(0,jsx_runtime_namespaceObject.jsxs)(external_command_cjs_namespaceObject.CommandList,{children:[q&&(0,jsx_runtime_namespaceObject.jsx)("div",{className:"p-4 text-center text-destructive",children:q}),g&&0===v.length&&(r||(0,jsx_runtime_namespaceObject.jsx)(DefaultLoadingSkeleton,{})),!g&&!q&&0===v.length&&(_||(0,jsx_runtime_namespaceObject.jsx)(external_command_cjs_namespaceObject.CommandEmpty,{children:x??`No ${m.toLowerCase()} found.`})),(0,jsx_runtime_namespaceObject.jsx)(external_command_cjs_namespaceObject.CommandGroup,{children:v.map(e=>(0,jsx_runtime_namespaceObject.jsxs)(external_command_cjs_namespaceObject.CommandItem,{value:n(e),onSelect:M,children:[c(e),(0,jsx_runtime_namespaceObject.jsx)(react_namespaceObject.Check,{className:(0,utils_cjs_namespaceObject.cn)("ml-auto h-3 w-3",N===n(e)?"opacity-100":"opacity-0")})]},n(e)))})]})]})})]})}function DefaultLoadingSkeleton(){return(0,jsx_runtime_namespaceObject.jsx)(external_command_cjs_namespaceObject.CommandGroup,{children:[1,2,3].map(e=>(0,jsx_runtime_namespaceObject.jsx)(external_command_cjs_namespaceObject.CommandItem,{disabled:!0,children:(0,jsx_runtime_namespaceObject.jsxs)("div",{className:"flex w-full items-center gap-2",children:[(0,jsx_runtime_namespaceObject.jsx)("div",{className:"h-6 w-6 animate-pulse rounded-full bg-muted"}),(0,jsx_runtime_namespaceObject.jsxs)("div",{className:"flex flex-1 flex-col gap-1",children:[(0,jsx_runtime_namespaceObject.jsx)("div",{className:"h-4 w-24 animate-pulse rounded bg-muted"}),(0,jsx_runtime_namespaceObject.jsx)("div",{className:"h-3 w-16 animate-pulse rounded bg-muted"})]})]})},e))})}for(var __webpack_i__ in exports.AsyncSelect=__webpack_exports__.AsyncSelect,__webpack_exports__)-1===["AsyncSelect"].indexOf(__webpack_i__)&&(exports[__webpack_i__]=__webpack_exports__[__webpack_i__]);Object.defineProperty(exports,"__esModule",{value:!0});
1
+ "use strict";let __rslib_import_meta_url__="undefined"==typeof document?new(require("url".replace("",""))).URL("file:"+__filename).href:document.currentScript&&document.currentScript.src||new URL("main.js",document.baseURI).href;var __webpack_require__={};__webpack_require__.d=(e,a)=>{for(var t in a)__webpack_require__.o(a,t)&&!__webpack_require__.o(e,t)&&Object.defineProperty(e,t,{enumerable:!0,get:a[t]})},__webpack_require__.o=(e,a)=>Object.prototype.hasOwnProperty.call(e,a),__webpack_require__.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var __webpack_exports__={};__webpack_require__.r(__webpack_exports__),__webpack_require__.d(__webpack_exports__,{AsyncSelect:()=>AsyncSelect});let jsx_runtime_namespaceObject=require("react/jsx-runtime"),external_react_namespaceObject=require("react"),use_debounce_cjs_namespaceObject=require("../hooks/use-debounce.cjs"),utils_cjs_namespaceObject=require("../lib/utils.cjs"),react_namespaceObject=require("@phosphor-icons/react"),external_button_cjs_namespaceObject=require("./button.cjs"),external_command_cjs_namespaceObject=require("./command.cjs"),external_popover_cjs_namespaceObject=require("./popover.cjs"),external_spinner_cjs_namespaceObject=require("./spinner.cjs");function AsyncSelect({fetcher:e,preload:a,filterFn:t,renderOption:c,getOptionValue:n,getDisplayValue:s,notFound:_,loadingSkeleton:r,label:m,placeholder:l="Select...",value:j,onChange:p,onSearchChange:i,disabled:o=!1,width:u="200px",className:b,triggerClassName:x,noResultsMessage:d,clearable:O=!0,enabled:f=!0,keyExtractor:h}){let[w,y]=(0,external_react_namespaceObject.useState)(!1),[v,S]=(0,external_react_namespaceObject.useState)(!1),[g,k]=(0,external_react_namespaceObject.useState)([]),[q,C]=(0,external_react_namespaceObject.useState)(!1),[N,P]=(0,external_react_namespaceObject.useState)(null),[E,L]=(0,external_react_namespaceObject.useState)(j),[A,D]=(0,external_react_namespaceObject.useState)(null),[I,U]=(0,external_react_namespaceObject.useState)(""),F=(0,use_debounce_cjs_namespaceObject.useDebounce)(I,300*!a),[M,R]=(0,external_react_namespaceObject.useState)([]);(0,external_react_namespaceObject.useEffect)(()=>{y(!0),L(j)},[j]),(0,external_react_namespaceObject.useEffect)(()=>{if(j&&g.length>0){let e=g.find(e=>n(e)===j);e&&D(e)}},[j,g,n]),(0,external_react_namespaceObject.useEffect)(()=>{let a=async()=>{try{C(!0),P(null);let a=await e(j);R(a),k(a)}catch(e){P(e instanceof Error?e.message:"Failed to fetch options")}finally{C(!1)}};!w&&f&&a()},[w,e,j]),(0,external_react_namespaceObject.useEffect)(()=>{let c=async()=>{try{C(!0),P(null);let a=await e(F);R(a),k(a)}catch(e){P(e instanceof Error?e.message:"Failed to fetch options")}finally{C(!1)}};!w&&f||!a&&f?c():a&&(F?k(M.filter(e=>!t||t(e,F))):k(M))},[e,F,w,a,t]);let T=(0,external_react_namespaceObject.useCallback)(e=>{let a=O&&e===E?"":e;L(a),D(g.find(e=>n(e)===a)||null),p(a),S(!1)},[E,p,O,g,n]);return(0,jsx_runtime_namespaceObject.jsxs)(external_popover_cjs_namespaceObject.Popover,{open:v,onOpenChange:S,children:[(0,jsx_runtime_namespaceObject.jsx)(external_popover_cjs_namespaceObject.PopoverTrigger,{asChild:!0,children:(0,jsx_runtime_namespaceObject.jsxs)(external_button_cjs_namespaceObject.Button,{variant:"secondary",role:"combobox","aria-expanded":v,className:(0,utils_cjs_namespaceObject.cn)("justify-between",o&&"cursor-not-allowed opacity-50",x),style:{width:u},disabled:o,children:[A?s(A):l,(0,jsx_runtime_namespaceObject.jsx)(react_namespaceObject.CaretUpDown,{className:"opacity-50",size:10})]})}),(0,jsx_runtime_namespaceObject.jsx)(external_popover_cjs_namespaceObject.PopoverContent,{style:{width:u},className:(0,utils_cjs_namespaceObject.cn)("p-0",b),children:(0,jsx_runtime_namespaceObject.jsxs)(external_command_cjs_namespaceObject.Command,{shouldFilter:!1,children:[(0,jsx_runtime_namespaceObject.jsxs)("div",{className:"relative w-full border-b",children:[(0,jsx_runtime_namespaceObject.jsx)(external_command_cjs_namespaceObject.CommandInput,{placeholder:`Search ${m.toLowerCase()}...`,value:I,onValueChange:e=>{U(e),i?.(e)}}),q&&g.length>0&&(0,jsx_runtime_namespaceObject.jsx)("div",{className:"-translate-y-1/2 absolute top-1/2 right-2 flex transform items-center",children:(0,jsx_runtime_namespaceObject.jsx)(external_spinner_cjs_namespaceObject.Spinner,{})})]}),(0,jsx_runtime_namespaceObject.jsxs)(external_command_cjs_namespaceObject.CommandList,{children:[N&&(0,jsx_runtime_namespaceObject.jsx)("div",{className:"p-4 text-center text-destructive",children:N}),q&&0===g.length&&(r||(0,jsx_runtime_namespaceObject.jsx)(DefaultLoadingSkeleton,{})),!q&&!N&&0===g.length&&(_||(0,jsx_runtime_namespaceObject.jsx)(external_command_cjs_namespaceObject.CommandEmpty,{children:d??`No ${m.toLowerCase()} found.`})),(0,jsx_runtime_namespaceObject.jsx)(external_command_cjs_namespaceObject.CommandGroup,{children:g.map(e=>(0,jsx_runtime_namespaceObject.jsxs)(external_command_cjs_namespaceObject.CommandItem,{value:n(e),onSelect:T,children:[c(e),(0,jsx_runtime_namespaceObject.jsx)(react_namespaceObject.Check,{className:(0,utils_cjs_namespaceObject.cn)("ml-auto h-3 w-3",E===n(e)?"opacity-100":"opacity-0")})]},h?h(e):n(e)))})]})]})})]})}function DefaultLoadingSkeleton(){return(0,jsx_runtime_namespaceObject.jsx)(external_command_cjs_namespaceObject.CommandGroup,{children:[1,2,3].map(e=>(0,jsx_runtime_namespaceObject.jsx)(external_command_cjs_namespaceObject.CommandItem,{disabled:!0,children:(0,jsx_runtime_namespaceObject.jsxs)("div",{className:"flex w-full items-center gap-2",children:[(0,jsx_runtime_namespaceObject.jsx)("div",{className:"h-6 w-6 animate-pulse rounded-full bg-muted"}),(0,jsx_runtime_namespaceObject.jsxs)("div",{className:"flex flex-1 flex-col gap-1",children:[(0,jsx_runtime_namespaceObject.jsx)("div",{className:"h-4 w-24 animate-pulse rounded bg-muted"}),(0,jsx_runtime_namespaceObject.jsx)("div",{className:"h-3 w-16 animate-pulse rounded bg-muted"})]})]})},e))})}for(var __webpack_i__ in exports.AsyncSelect=__webpack_exports__.AsyncSelect,__webpack_exports__)-1===["AsyncSelect"].indexOf(__webpack_i__)&&(exports[__webpack_i__]=__webpack_exports__[__webpack_i__]);Object.defineProperty(exports,"__esModule",{value:!0});
2
2
  //# sourceMappingURL=async-select.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"components\\async-select.cjs","sources":["webpack://@gbmtech/aurora-ui/./src/components/async-select.tsx"],"sourcesContent":["import { useCallback, useEffect, useState } from 'react'\n\nimport { useDebounce } from '@/hooks/use-debounce'\nimport { cn } from '@/lib/utils'\nimport { CaretUpDown, Check } from '@phosphor-icons/react'\nimport { Button } from './button'\nimport {\n Command,\n CommandEmpty,\n CommandGroup,\n CommandInput,\n CommandItem,\n CommandList,\n} from './command'\nimport { Popover, PopoverContent, PopoverTrigger } from './popover'\nimport { Spinner } from './spinner'\n\nexport interface Option {\n value: string\n label: string\n disabled?: boolean\n description?: string\n icon?: React.ReactNode\n}\n\nexport interface AsyncSelectProps<T> {\n /** Async function to fetch options */\n fetcher: (query?: string) => Promise<T[]>\n /** Preload all data ahead of time */\n preload?: boolean\n /** Function to filter options */\n filterFn?: (option: T, query: string) => boolean\n /** Function to render each option */\n renderOption: (option: T) => React.ReactNode\n /** Function to get the value from an option */\n getOptionValue: (option: T) => string\n /** Function to get the display value for the selected option */\n getDisplayValue: (option: T) => React.ReactNode\n /** Custom not found message */\n notFound?: React.ReactNode\n /** Custom loading skeleton */\n loadingSkeleton?: React.ReactNode\n /** Currently selected value */\n value: string\n /** Callback when selection changes */\n onChange: (value: string) => void\n /** Label for the select field */\n label: string\n /** Placeholder text when no selection */\n placeholder?: string\n /** Disable the entire select */\n disabled?: boolean\n /** Custom width for the popover */\n width?: string | number\n /** Custom class names */\n className?: string\n /** Custom trigger button class names */\n triggerClassName?: string\n /** Custom no results message */\n noResultsMessage?: string\n /** Allow clearing the selection */\n clearable?: boolean\n /** */\n enabled?: boolean\n}\n\nexport function AsyncSelect<T>({\n fetcher,\n preload,\n filterFn,\n renderOption,\n getOptionValue,\n getDisplayValue,\n notFound,\n loadingSkeleton,\n label,\n placeholder = 'Select...',\n value,\n onChange,\n disabled = false,\n width = '200px',\n className,\n triggerClassName,\n noResultsMessage,\n clearable = true,\n enabled = true,\n}: AsyncSelectProps<T>) {\n const [mounted, setMounted] = useState(false)\n const [open, setOpen] = useState(false)\n const [options, setOptions] = useState<T[]>([])\n const [loading, setLoading] = useState(false)\n const [error, setError] = useState<string | null>(null)\n const [selectedValue, setSelectedValue] = useState(value)\n const [selectedOption, setSelectedOption] = useState<T | null>(null)\n const [searchTerm, setSearchTerm] = useState('')\n const debouncedSearchTerm = useDebounce(searchTerm, preload ? 0 : 300)\n const [originalOptions, setOriginalOptions] = useState<T[]>([])\n\n useEffect(() => {\n setMounted(true)\n setSelectedValue(value)\n }, [value])\n\n // Initialize selectedOption when options are loaded and value exists\n useEffect(() => {\n if (value && options.length > 0) {\n const option = options.find(opt => getOptionValue(opt) === value)\n if (option) {\n setSelectedOption(option)\n }\n }\n }, [value, options, getOptionValue])\n\n // Effect for initial fetch\n useEffect(() => {\n const initializeOptions = async () => {\n try {\n setLoading(true)\n setError(null)\n // If we have a value, use it for the initial search\n const data = await fetcher(value)\n setOriginalOptions(data)\n setOptions(data)\n } catch (err) {\n setError(err instanceof Error ? err.message : 'Failed to fetch options')\n } finally {\n setLoading(false)\n }\n }\n\n if (!mounted && enabled) {\n initializeOptions()\n }\n }, [mounted, fetcher, value])\n\n useEffect(() => {\n const fetchOptions = async () => {\n try {\n setLoading(true)\n setError(null)\n const data = await fetcher(debouncedSearchTerm)\n setOriginalOptions(data)\n setOptions(data)\n } catch (err) {\n setError(err instanceof Error ? err.message : 'Failed to fetch options')\n } finally {\n setLoading(false)\n }\n }\n\n if (!mounted && enabled) {\n fetchOptions()\n } else if (!preload && enabled) {\n fetchOptions()\n } else if (preload) {\n if (debouncedSearchTerm) {\n setOptions(\n originalOptions.filter(option =>\n filterFn ? filterFn(option, debouncedSearchTerm) : true\n )\n )\n } else {\n setOptions(originalOptions)\n }\n }\n }, [fetcher, debouncedSearchTerm, mounted, preload, filterFn])\n\n const handleSelect = useCallback(\n (currentValue: string) => {\n const newValue =\n clearable && currentValue === selectedValue ? '' : currentValue\n setSelectedValue(newValue)\n setSelectedOption(\n options.find(option => getOptionValue(option) === newValue) || null\n )\n onChange(newValue)\n setOpen(false)\n },\n [selectedValue, onChange, clearable, options, getOptionValue]\n )\n\n return (\n <Popover open={open} onOpenChange={setOpen}>\n <PopoverTrigger asChild>\n <Button\n variant=\"secondary\"\n role=\"combobox\"\n aria-expanded={open}\n className={cn(\n 'justify-between',\n disabled && 'cursor-not-allowed opacity-50',\n triggerClassName\n )}\n style={{ width: width }}\n disabled={disabled}\n >\n {selectedOption ? getDisplayValue(selectedOption) : placeholder}\n <CaretUpDown className=\"opacity-50\" size={10} />\n </Button>\n </PopoverTrigger>\n <PopoverContent style={{ width: width }} className={cn('p-0', className)}>\n <Command shouldFilter={false}>\n <div className=\"relative w-full border-b\">\n <CommandInput\n placeholder={`Search ${label.toLowerCase()}...`}\n value={searchTerm}\n onValueChange={value => {\n setSearchTerm(value)\n }}\n />\n {loading && options.length > 0 && (\n <div className=\"-translate-y-1/2 absolute top-1/2 right-2 flex transform items-center\">\n <Spinner />\n </div>\n )}\n </div>\n <CommandList>\n {error && (\n <div className=\"p-4 text-center text-destructive\">{error}</div>\n )}\n {loading &&\n options.length === 0 &&\n (loadingSkeleton || <DefaultLoadingSkeleton />)}\n {!loading &&\n !error &&\n options.length === 0 &&\n (notFound || (\n <CommandEmpty>\n {noResultsMessage ?? `No ${label.toLowerCase()} found.`}\n </CommandEmpty>\n ))}\n <CommandGroup>\n {options.map(option => (\n <CommandItem\n key={getOptionValue(option)}\n value={getOptionValue(option)}\n onSelect={handleSelect}\n >\n {renderOption(option)}\n <Check\n className={cn(\n 'ml-auto h-3 w-3',\n selectedValue === getOptionValue(option)\n ? 'opacity-100'\n : 'opacity-0'\n )}\n />\n </CommandItem>\n ))}\n </CommandGroup>\n </CommandList>\n </Command>\n </PopoverContent>\n </Popover>\n )\n}\n\nfunction DefaultLoadingSkeleton() {\n return (\n <CommandGroup>\n {[1, 2, 3].map(i => (\n <CommandItem key={i} disabled>\n <div className=\"flex w-full items-center gap-2\">\n <div className=\"h-6 w-6 animate-pulse rounded-full bg-muted\" />\n <div className=\"flex flex-1 flex-col gap-1\">\n <div className=\"h-4 w-24 animate-pulse rounded bg-muted\" />\n <div className=\"h-3 w-16 animate-pulse rounded bg-muted\" />\n </div>\n </div>\n </CommandItem>\n ))}\n </CommandGroup>\n )\n}\n"],"names":["AsyncSelect","fetcher","preload","filterFn","renderOption","getOptionValue","getDisplayValue","notFound","loadingSkeleton","label","placeholder","value","onChange","disabled","width","className","triggerClassName","noResultsMessage","clearable","enabled","mounted","setMounted","useState","open","setOpen","options","setOptions","loading","setLoading","error","setError","selectedValue","setSelectedValue","selectedOption","setSelectedOption","searchTerm","setSearchTerm","debouncedSearchTerm","useDebounce","originalOptions","setOriginalOptions","useEffect","option","opt","initializeOptions","data","err","Error","fetchOptions","handleSelect","useCallback","currentValue","newValue","Popover","PopoverTrigger","Button","cn","CaretUpDown","PopoverContent","Command","CommandInput","Spinner","CommandList","DefaultLoadingSkeleton","CommandEmpty","CommandGroup","C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AAAA,C,UACTjC,GACC,oCAAC,OAAI,UAAU,mC,SAAoCA,C,GAEpDF,GACCF,AAAmB,IAAnBA,EAAQ,MAAM,EACbjB,CAAAA,GAAmB,oCAACuD,uBAAAA,CAAAA,EAAAA,EACtB,CAACpC,GACA,CAACE,GACDJ,AAAmB,IAAnBA,EAAQ,MAAM,EACblB,CAAAA,GACC,oCAACyD,qCAAAA,YAAYA,CAAAA,C,SACV/C,GAAoB,CAAC,GAAG,EAAER,EAAM,WAAW,GAAG,OAAO,CAAC,A,IAG7D,oCAACwD,qCAAAA,YAAYA,CAAAA,C,SACVxC,EAAQ,GAAG,CAACiB,AAAAA,GACX,qCAACwB,qCAAAA,WAAWA,CAAAA,CAEV,MAAO7D,EAAeqC,GACtB,SAAUO,E,UAET7C,EAAasC,GACd,oCAACyB,sBAAAA,KAAKA,CAAAA,CACJ,UAAWX,AAAAA,GAAAA,0BAAAA,EAAAA,AAAAA,EACT,kBACAzB,IAAkB1B,EAAeqC,GAC7B,cACA,Y,KAVHrC,EAAeqC,I,aAqBtC,CAEA,SAASqB,yBACP,MACE,oCAACE,qCAAAA,YAAYA,CAAAA,C,SACV,CAAC,EAAG,EAAG,EAAE,CAAC,GAAG,CAACG,AAAAA,GACb,oCAACF,qCAAAA,WAAWA,CAAAA,CAAS,SAAQ,G,SAC3B,qCAAC,OAAI,UAAU,iC,UACb,oCAAC,OAAI,UAAU,6C,GACf,qCAAC,OAAI,UAAU,6B,UACb,oCAAC,OAAI,UAAU,yC,GACf,oCAAC,OAAI,UAAU,yC,UALHE,G,EAY1B,C"}
1
+ {"version":3,"file":"components\\async-select.cjs","sources":["webpack://@gbmtech/aurora-ui/./src/components/async-select.tsx"],"sourcesContent":["import { useCallback, useEffect, useState } from 'react'\n\nimport { useDebounce } from '@/hooks/use-debounce'\nimport { cn } from '@/lib/utils'\nimport { CaretUpDown, Check } from '@phosphor-icons/react'\nimport { Button } from './button'\nimport {\n Command,\n CommandEmpty,\n CommandGroup,\n CommandInput,\n CommandItem,\n CommandList,\n} from './command'\nimport { Popover, PopoverContent, PopoverTrigger } from './popover'\nimport { Spinner } from './spinner'\n\nexport interface Option {\n value: string\n label: string\n disabled?: boolean\n description?: string\n icon?: React.ReactNode\n}\n\nexport interface AsyncSelectProps<T> {\n /** Async function to fetch options */\n fetcher: (query?: string) => Promise<T[]>\n /** Preload all data ahead of time */\n preload?: boolean\n /** Function to filter options */\n filterFn?: (option: T, query: string) => boolean\n /** Function to render each option */\n renderOption: (option: T) => React.ReactNode\n /** Function to get the value from an option */\n getOptionValue: (option: T) => string\n /** Function to get the display value for the selected option */\n getDisplayValue: (option: T) => React.ReactNode\n /** Custom not found message */\n notFound?: React.ReactNode\n /** Custom loading skeleton */\n loadingSkeleton?: React.ReactNode\n /** Currently selected value */\n value: string\n /** Callback when selection changes */\n onChange: (value: string) => void\n onSearchChange?: (value: string) => void\n /** Label for the select field */\n label: string\n /** Placeholder text when no selection */\n placeholder?: string\n /** Disable the entire select */\n disabled?: boolean\n /** Custom width for the popover */\n width?: string | number\n /** Custom class names */\n className?: string\n /** Custom trigger button class names */\n triggerClassName?: string\n /** Custom no results message */\n noResultsMessage?: string\n /** Allow clearing the selection */\n clearable?: boolean\n /** */\n enabled?: boolean\n keyExtractor?: (option: T) => string\n}\n\nexport function AsyncSelect<T>({\n fetcher,\n preload,\n filterFn,\n renderOption,\n getOptionValue,\n getDisplayValue,\n notFound,\n loadingSkeleton,\n label,\n placeholder = 'Select...',\n value,\n onChange,\n onSearchChange,\n disabled = false,\n width = '200px',\n className,\n triggerClassName,\n noResultsMessage,\n clearable = true,\n enabled = true,\n keyExtractor,\n}: AsyncSelectProps<T>) {\n const [mounted, setMounted] = useState(false)\n const [open, setOpen] = useState(false)\n const [options, setOptions] = useState<T[]>([])\n const [loading, setLoading] = useState(false)\n const [error, setError] = useState<string | null>(null)\n const [selectedValue, setSelectedValue] = useState(value)\n const [selectedOption, setSelectedOption] = useState<T | null>(null)\n const [searchTerm, setSearchTerm] = useState('')\n const debouncedSearchTerm = useDebounce(searchTerm, preload ? 0 : 300)\n const [originalOptions, setOriginalOptions] = useState<T[]>([])\n\n useEffect(() => {\n setMounted(true)\n setSelectedValue(value)\n }, [value])\n\n // Initialize selectedOption when options are loaded and value exists\n useEffect(() => {\n if (value && options.length > 0) {\n const option = options.find(opt => getOptionValue(opt) === value)\n if (option) {\n setSelectedOption(option)\n }\n }\n }, [value, options, getOptionValue])\n\n // Effect for initial fetch\n useEffect(() => {\n const initializeOptions = async () => {\n try {\n setLoading(true)\n setError(null)\n // If we have a value, use it for the initial search\n const data = await fetcher(value)\n setOriginalOptions(data)\n setOptions(data)\n } catch (err) {\n setError(err instanceof Error ? err.message : 'Failed to fetch options')\n } finally {\n setLoading(false)\n }\n }\n\n if (!mounted && enabled) {\n initializeOptions()\n }\n }, [mounted, fetcher, value])\n\n useEffect(() => {\n const fetchOptions = async () => {\n try {\n setLoading(true)\n setError(null)\n const data = await fetcher(debouncedSearchTerm)\n setOriginalOptions(data)\n setOptions(data)\n } catch (err) {\n setError(err instanceof Error ? err.message : 'Failed to fetch options')\n } finally {\n setLoading(false)\n }\n }\n\n if (!mounted && enabled) {\n fetchOptions()\n } else if (!preload && enabled) {\n fetchOptions()\n } else if (preload) {\n if (debouncedSearchTerm) {\n setOptions(\n originalOptions.filter(option =>\n filterFn ? filterFn(option, debouncedSearchTerm) : true\n )\n )\n } else {\n setOptions(originalOptions)\n }\n }\n }, [fetcher, debouncedSearchTerm, mounted, preload, filterFn])\n\n const handleSelect = useCallback(\n (currentValue: string) => {\n const newValue =\n clearable && currentValue === selectedValue ? '' : currentValue\n setSelectedValue(newValue)\n setSelectedOption(\n options.find(option => getOptionValue(option) === newValue) || null\n )\n onChange(newValue)\n setOpen(false)\n },\n [selectedValue, onChange, clearable, options, getOptionValue]\n )\n\n return (\n <Popover open={open} onOpenChange={setOpen}>\n <PopoverTrigger asChild>\n <Button\n variant=\"secondary\"\n role=\"combobox\"\n aria-expanded={open}\n className={cn(\n 'justify-between',\n disabled && 'cursor-not-allowed opacity-50',\n triggerClassName\n )}\n style={{ width: width }}\n disabled={disabled}\n >\n {selectedOption ? getDisplayValue(selectedOption) : placeholder}\n <CaretUpDown className=\"opacity-50\" size={10} />\n </Button>\n </PopoverTrigger>\n <PopoverContent style={{ width: width }} className={cn('p-0', className)}>\n <Command shouldFilter={false}>\n <div className=\"relative w-full border-b\">\n <CommandInput\n placeholder={`Search ${label.toLowerCase()}...`}\n value={searchTerm}\n onValueChange={value => {\n setSearchTerm(value)\n onSearchChange?.(value)\n }}\n />\n {loading && options.length > 0 && (\n <div className=\"-translate-y-1/2 absolute top-1/2 right-2 flex transform items-center\">\n <Spinner />\n </div>\n )}\n </div>\n <CommandList>\n {error && (\n <div className=\"p-4 text-center text-destructive\">{error}</div>\n )}\n {loading &&\n options.length === 0 &&\n (loadingSkeleton || <DefaultLoadingSkeleton />)}\n {!loading &&\n !error &&\n options.length === 0 &&\n (notFound || (\n <CommandEmpty>\n {noResultsMessage ?? `No ${label.toLowerCase()} found.`}\n </CommandEmpty>\n ))}\n <CommandGroup>\n {options.map(option => (\n <CommandItem\n key={\n keyExtractor ? keyExtractor(option) : getOptionValue(option)\n }\n value={getOptionValue(option)}\n onSelect={handleSelect}\n >\n {renderOption(option)}\n <Check\n className={cn(\n 'ml-auto h-3 w-3',\n selectedValue === getOptionValue(option)\n ? 'opacity-100'\n : 'opacity-0'\n )}\n />\n </CommandItem>\n ))}\n </CommandGroup>\n </CommandList>\n </Command>\n </PopoverContent>\n </Popover>\n )\n}\n\nfunction DefaultLoadingSkeleton() {\n return (\n <CommandGroup>\n {[1, 2, 3].map(i => (\n <CommandItem key={i} disabled>\n <div className=\"flex w-full items-center gap-2\">\n <div className=\"h-6 w-6 animate-pulse rounded-full bg-muted\" />\n <div className=\"flex flex-1 flex-col gap-1\">\n <div className=\"h-4 w-24 animate-pulse rounded bg-muted\" />\n <div className=\"h-3 w-16 animate-pulse rounded bg-muted\" />\n </div>\n </div>\n </CommandItem>\n ))}\n </CommandGroup>\n )\n}\n"],"names":["AsyncSelect","fetcher","preload","filterFn","renderOption","getOptionValue","getDisplayValue","notFound","loadingSkeleton","label","placeholder","value","onChange","onSearchChange","disabled","width","className","triggerClassName","noResultsMessage","clearable","enabled","keyExtractor","mounted","setMounted","useState","open","setOpen","options","setOptions","loading","setLoading","error","setError","selectedValue","setSelectedValue","selectedOption","setSelectedOption","searchTerm","setSearchTerm","debouncedSearchTerm","useDebounce","originalOptions","setOriginalOptions","useEffect","option","opt","initializeOptions","data","err","Error","fetchOptions","handleSelect","useCallback","currentValue","newValue","Popover","PopoverTrigger","Button","cn","CaretUpDown","PopoverContent","Command","CommandInput","Spinner","CommandList","DefaultLoadingSkeleton","CommandEmpty","CommandGroup","CommandItem","Check","i"],"mappings":"g0CAoEO,SAASA,YAAe,CAC7BC,QAAAA,CAAO,CACPC,QAAAA,CAAO,CACPC,SAAAA,CAAQ,CACRC,aAAAA,CAAY,CACZC,eAAAA,CAAc,CACdC,gBAAAA,CAAe,CACfC,SAAAA,CAAQ,CACRC,gBAAAA,CAAe,CACfC,MAAAA,CAAK,CACLC,YAAAA,EAAc,WAAW,CACzBC,MAAAA,CAAK,CACLC,SAAAA,CAAQ,CACRC,eAAAA,CAAc,CACdC,SAAAA,EAAW,EAAK,CAChBC,MAAAA,EAAQ,OAAO,CACfC,UAAAA,CAAS,CACTC,iBAAAA,CAAgB,CAChBC,iBAAAA,CAAgB,CAChBC,UAAAA,EAAY,EAAI,CAChBC,QAAAA,EAAU,EAAI,CACdC,aAAAA,CAAY,CACQ,EACpB,GAAM,CAACC,EAASC,EAAW,CAAGC,AAAAA,GAAAA,+BAAAA,QAAAA,AAAAA,EAAS,IACjC,CAACC,EAAMC,EAAQ,CAAGF,AAAAA,GAAAA,+BAAAA,QAAAA,AAAAA,EAAS,IAC3B,CAACG,EAASC,EAAW,CAAGJ,AAAAA,GAAAA,+BAAAA,QAAAA,AAAAA,EAAc,EAAE,EACxC,CAACK,EAAS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,oCAACE,qCAAAA,YAAYA,CAAAA,C,SACV,CAAC,EAAG,EAAG,EAAE,CAAC,GAAG,CAACG,AAAAA,GACb,oCAACF,qCAAAA,WAAWA,CAAAA,CAAS,SAAQ,G,SAC3B,qCAAC,OAAI,UAAU,iC,UACb,oCAAC,OAAI,UAAU,6C,GACf,qCAAC,OAAI,UAAU,6B,UACb,oCAAC,OAAI,UAAU,yC,GACf,oCAAC,OAAI,UAAU,yC,UALHE,G,EAY1B,C"}
@@ -1 +1 @@
1
- "use strict";let __rslib_import_meta_url__="undefined"==typeof document?new(require("url".replace("",""))).URL("file:"+__filename).href:document.currentScript&&document.currentScript.src||new URL("main.js",document.baseURI).href;var __webpack_modules__={"./data-table-action-bar":function(e){e.exports=require("./data-table-action-bar.cjs")},"./data-table-advanced-toolbar":function(e){e.exports=require("./data-table-advanced-toolbar.cjs")},"./data-table-column-header":function(e){e.exports=require("./data-table-column-header.cjs")},"@/components/data-table/data-table-date-filter":function(e){e.exports=require("./data-table-date-filter.cjs")},"@/components/data-table/data-table-faceted-filter":function(e){e.exports=require("./data-table-faceted-filter.cjs")},"./data-table-filter-list":function(e){e.exports=require("./data-table-filter-list.cjs")},"./data-table-filter-menu":function(e){e.exports=require("./data-table-filter-menu.cjs")},"@/components/data-table/data-table-pagination":function(e){e.exports=require("./data-table-pagination.cjs")},"@/components/data-table/data-table-range-filter":function(e){e.exports=require("./data-table-range-filter.cjs")},"./data-table-skeleton":function(e){e.exports=require("./data-table-skeleton.cjs")},"@/components/data-table/data-table-slider-filter":function(e){e.exports=require("./data-table-slider-filter.cjs")},"./data-table-sort-list":function(e){e.exports=require("./data-table-sort-list.cjs")},"./data-table-toolbar":function(e){e.exports=require("./data-table-toolbar.cjs")},"@/components/data-table/data-table-view-options":function(e){e.exports=require("./data-table-view-options.cjs")},"./data-table":function(e){e.exports=require("./data-table.cjs")}},__webpack_module_cache__={};function __webpack_require__(e){var _=__webpack_module_cache__[e];if(void 0!==_)return _.exports;var a=__webpack_module_cache__[e]={exports:{}};return __webpack_modules__[e](a,a.exports,__webpack_require__),a.exports}__webpack_require__.n=e=>{var _=e&&e.__esModule?()=>e.default:()=>e;return __webpack_require__.d(_,{a:_}),_},__webpack_require__.d=(e,_)=>{for(var a in _)__webpack_require__.o(_,a)&&!__webpack_require__.o(e,a)&&Object.defineProperty(e,a,{enumerable:!0,get:_[a]})},__webpack_require__.o=(e,_)=>Object.prototype.hasOwnProperty.call(e,_),__webpack_require__.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var __webpack_exports__={};for(var __webpack_i__ in(()=>{__webpack_require__.r(__webpack_exports__);var e=__webpack_require__("./data-table-action-bar"),_={};for(var a in e)"default"!==a&&(_[a]=(function(_){return e[_]}).bind(0,a));__webpack_require__.d(__webpack_exports__,_);var t=__webpack_require__("./data-table-advanced-toolbar"),_={};for(var a in t)"default"!==a&&(_[a]=(function(e){return t[e]}).bind(0,a));__webpack_require__.d(__webpack_exports__,_);var r=__webpack_require__("./data-table-column-header"),_={};for(var a in r)"default"!==a&&(_[a]=(function(e){return r[e]}).bind(0,a));__webpack_require__.d(__webpack_exports__,_);var n=__webpack_require__("@/components/data-table/data-table-date-filter"),_={};for(var a in n)"default"!==a&&(_[a]=(function(e){return n[e]}).bind(0,a));__webpack_require__.d(__webpack_exports__,_);var i=__webpack_require__("@/components/data-table/data-table-faceted-filter"),_={};for(var a in i)"default"!==a&&(_[a]=(function(e){return i[e]}).bind(0,a));__webpack_require__.d(__webpack_exports__,_);var o=__webpack_require__("./data-table-filter-list"),_={};for(var a in o)"default"!==a&&(_[a]=(function(e){return o[e]}).bind(0,a));__webpack_require__.d(__webpack_exports__,_);var c=__webpack_require__("./data-table-filter-menu"),_={};for(var a in c)"default"!==a&&(_[a]=(function(e){return c[e]}).bind(0,a));__webpack_require__.d(__webpack_exports__,_);var b=__webpack_require__("@/components/data-table/data-table-pagination"),_={};for(var a in b)"default"!==a&&(_[a]=(function(e){return b[e]}).bind(0,a));__webpack_require__.d(__webpack_exports__,_);var u=__webpack_require__("@/components/data-table/data-table-range-filter"),_={};for(var a in u)"default"!==a&&(_[a]=(function(e){return u[e]}).bind(0,a));__webpack_require__.d(__webpack_exports__,_);var d=__webpack_require__("./data-table-skeleton"),_={};for(var a in d)"default"!==a&&(_[a]=(function(e){return d[e]}).bind(0,a));__webpack_require__.d(__webpack_exports__,_);var p=__webpack_require__("@/components/data-table/data-table-slider-filter"),_={};for(var a in p)"default"!==a&&(_[a]=(function(e){return p[e]}).bind(0,a));__webpack_require__.d(__webpack_exports__,_);var l=__webpack_require__("./data-table-sort-list"),_={};for(var a in l)"default"!==a&&(_[a]=(function(e){return l[e]}).bind(0,a));__webpack_require__.d(__webpack_exports__,_);var f=__webpack_require__("./data-table-toolbar"),_={};for(var a in f)"default"!==a&&(_[a]=(function(e){return f[e]}).bind(0,a));__webpack_require__.d(__webpack_exports__,_);var s=__webpack_require__("@/components/data-table/data-table-view-options"),_={};for(var a in s)"default"!==a&&(_[a]=(function(e){return s[e]}).bind(0,a));__webpack_require__.d(__webpack_exports__,_);var w=__webpack_require__("./data-table"),_={};for(var a in w)"default"!==a&&(_[a]=(function(e){return w[e]}).bind(0,a));__webpack_require__.d(__webpack_exports__,_)})(),__webpack_exports__)exports[__webpack_i__]=__webpack_exports__[__webpack_i__];Object.defineProperty(exports,"__esModule",{value:!0});
1
+ "use strict";let __rslib_import_meta_url__="undefined"==typeof document?new(require("url".replace("",""))).URL("file:"+__filename).href:document.currentScript&&document.currentScript.src||new URL("main.js",document.baseURI).href;var __webpack_modules__={"./data-table-action-bar":function(e){e.exports=require("./data-table-action-bar.cjs")},"./data-table-advanced-toolbar":function(e){e.exports=require("./data-table-advanced-toolbar.cjs")},"./data-table-column-header":function(e){e.exports=require("./data-table-column-header.cjs")},"./data-table-date-filter":function(e){e.exports=require("./data-table-date-filter.cjs")},"./data-table-faceted-filter":function(e){e.exports=require("./data-table-faceted-filter.cjs")},"./data-table-filter-list":function(e){e.exports=require("./data-table-filter-list.cjs")},"./data-table-filter-menu":function(e){e.exports=require("./data-table-filter-menu.cjs")},"./data-table-pagination":function(e){e.exports=require("./data-table-pagination.cjs")},"./data-table-range-filter":function(e){e.exports=require("./data-table-range-filter.cjs")},"./data-table-skeleton":function(e){e.exports=require("./data-table-skeleton.cjs")},"./data-table-slider-filter":function(e){e.exports=require("./data-table-slider-filter.cjs")},"./data-table-sort-list":function(e){e.exports=require("./data-table-sort-list.cjs")},"./data-table-toolbar":function(e){e.exports=require("./data-table-toolbar.cjs")},"./data-table-view-options":function(e){e.exports=require("./data-table-view-options.cjs")},"./data-table":function(e){e.exports=require("./data-table.cjs")}},__webpack_module_cache__={};function __webpack_require__(e){var _=__webpack_module_cache__[e];if(void 0!==_)return _.exports;var r=__webpack_module_cache__[e]={exports:{}};return __webpack_modules__[e](r,r.exports,__webpack_require__),r.exports}__webpack_require__.n=e=>{var _=e&&e.__esModule?()=>e.default:()=>e;return __webpack_require__.d(_,{a:_}),_},__webpack_require__.d=(e,_)=>{for(var r in _)__webpack_require__.o(_,r)&&!__webpack_require__.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:_[r]})},__webpack_require__.o=(e,_)=>Object.prototype.hasOwnProperty.call(e,_),__webpack_require__.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var __webpack_exports__={};for(var __webpack_i__ in(()=>{__webpack_require__.r(__webpack_exports__);var e=__webpack_require__("./data-table-action-bar"),_={};for(var r in e)"default"!==r&&(_[r]=(function(_){return e[_]}).bind(0,r));__webpack_require__.d(__webpack_exports__,_);var a=__webpack_require__("./data-table-advanced-toolbar"),_={};for(var r in a)"default"!==r&&(_[r]=(function(e){return a[e]}).bind(0,r));__webpack_require__.d(__webpack_exports__,_);var t=__webpack_require__("./data-table-column-header"),_={};for(var r in t)"default"!==r&&(_[r]=(function(e){return t[e]}).bind(0,r));__webpack_require__.d(__webpack_exports__,_);var i=__webpack_require__("./data-table-date-filter"),_={};for(var r in i)"default"!==r&&(_[r]=(function(e){return i[e]}).bind(0,r));__webpack_require__.d(__webpack_exports__,_);var n=__webpack_require__("./data-table-faceted-filter"),_={};for(var r in n)"default"!==r&&(_[r]=(function(e){return n[e]}).bind(0,r));__webpack_require__.d(__webpack_exports__,_);var o=__webpack_require__("./data-table-filter-list"),_={};for(var r in o)"default"!==r&&(_[r]=(function(e){return o[e]}).bind(0,r));__webpack_require__.d(__webpack_exports__,_);var u=__webpack_require__("./data-table-filter-menu"),_={};for(var r in u)"default"!==r&&(_[r]=(function(e){return u[e]}).bind(0,r));__webpack_require__.d(__webpack_exports__,_);var c=__webpack_require__("./data-table-pagination"),_={};for(var r in c)"default"!==r&&(_[r]=(function(e){return c[e]}).bind(0,r));__webpack_require__.d(__webpack_exports__,_);var b=__webpack_require__("./data-table-range-filter"),_={};for(var r in b)"default"!==r&&(_[r]=(function(e){return b[e]}).bind(0,r));__webpack_require__.d(__webpack_exports__,_);var d=__webpack_require__("./data-table-skeleton"),_={};for(var r in d)"default"!==r&&(_[r]=(function(e){return d[e]}).bind(0,r));__webpack_require__.d(__webpack_exports__,_);var p=__webpack_require__("./data-table-slider-filter"),_={};for(var r in p)"default"!==r&&(_[r]=(function(e){return p[e]}).bind(0,r));__webpack_require__.d(__webpack_exports__,_);var l=__webpack_require__("./data-table-sort-list"),_={};for(var r in l)"default"!==r&&(_[r]=(function(e){return l[e]}).bind(0,r));__webpack_require__.d(__webpack_exports__,_);var f=__webpack_require__("./data-table-toolbar"),_={};for(var r in f)"default"!==r&&(_[r]=(function(e){return f[e]}).bind(0,r));__webpack_require__.d(__webpack_exports__,_);var s=__webpack_require__("./data-table-view-options"),_={};for(var r in s)"default"!==r&&(_[r]=(function(e){return s[e]}).bind(0,r));__webpack_require__.d(__webpack_exports__,_);var w=__webpack_require__("./data-table"),_={};for(var r in w)"default"!==r&&(_[r]=(function(e){return w[e]}).bind(0,r));__webpack_require__.d(__webpack_exports__,_)})(),__webpack_exports__)exports[__webpack_i__]=__webpack_exports__[__webpack_i__];Object.defineProperty(exports,"__esModule",{value:!0});
@@ -26,6 +26,7 @@ export interface AsyncSelectProps<T> {
26
26
  value: string;
27
27
  /** Callback when selection changes */
28
28
  onChange: (value: string) => void;
29
+ onSearchChange?: (value: string) => void;
29
30
  /** Label for the select field */
30
31
  label: string;
31
32
  /** Placeholder text when no selection */
@@ -44,6 +45,7 @@ export interface AsyncSelectProps<T> {
44
45
  clearable?: boolean;
45
46
  /** */
46
47
  enabled?: boolean;
48
+ keyExtractor?: (option: T) => string;
47
49
  }
48
- export declare function AsyncSelect<T>({ fetcher, preload, filterFn, renderOption, getOptionValue, getDisplayValue, notFound, loadingSkeleton, label, placeholder, value, onChange, disabled, width, className, triggerClassName, noResultsMessage, clearable, enabled, }: AsyncSelectProps<T>): import("react/jsx-runtime").JSX.Element;
50
+ export declare function AsyncSelect<T>({ fetcher, preload, filterFn, renderOption, getOptionValue, getDisplayValue, notFound, loadingSkeleton, label, placeholder, value, onChange, onSearchChange, disabled, width, className, triggerClassName, noResultsMessage, clearable, enabled, keyExtractor, }: AsyncSelectProps<T>): import("react/jsx-runtime").JSX.Element;
49
51
  //# sourceMappingURL=async-select.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"async-select.d.ts","sourceRoot":"","sources":["../../../src/components/async-select.tsx"],"names":[],"mappings":"AAiBA,MAAM,WAAW,MAAM;IACrB,KAAK,EAAE,MAAM,CAAA;IACb,KAAK,EAAE,MAAM,CAAA;IACb,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,IAAI,CAAC,EAAE,KAAK,CAAC,SAAS,CAAA;CACvB;AAED,MAAM,WAAW,gBAAgB,CAAC,CAAC;IACjC,sCAAsC;IACtC,OAAO,EAAE,CAAC,KAAK,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AAO,EACP,OAAO,EACP,QAAQ,EACR,YAAY,EACZ,cAAc,EACd,eAAe,EACf,QAAQ,EACR,eAAe,EACf,KAAK,EACL,WAAyB,EACzB,KAAK,EACL,QAAQ,EACR,QAAgB,EAChB,KAAe,EACf,SAAS,EACT,gBAAgB,EAChB,gBAAgB,EAChB,SAAgB,EAChB,OAAc,GACf,EAAE,gBAAgB,CAAC,CAAC,CAAC,2CAyKrB"}
1
+ {"version":3,"file":"async-select.d.ts","sourceRoot":"","sources":["../../../src/components/async-select.tsx"],"names":[],"mappings":"AAiBA,MAAM,WAAW,MAAM;IACrB,KAAK,EAAE,MAAM,CAAA;IACb,KAAK,EAAE,MAAM,CAAA;IACb,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,IAAI,CAAC,EAAE,KAAK,CAAC,SAAS,CAAA;CACvB;AAED,MAAM,WAAW,gBAAgB,CAAC,CAAC;IACjC,sCAAsC;IACtC,OAAO,EAAE,CAAC,KAAK,CAAC,EAAE,MAAM,KAAK,OAAO,CAAC,CAAC,EAAE,CAAC,CAAA;IACzC,qCAAqC;IACrC,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,iCAAiC;IACjC,QAAQ,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,KAAK,OAAO,CAAA;IAChD,qCAAqC;IACrC,YAAY,EAAE,CAAC,MAAM,EAAE,CAAC,KAAK,KAAK,CAAC,SAAS,CAAA;IAC5C,+CAA+C;IAC/C,cAAc,EAAE,CAAC,MAAM,EAAE,CAAC,KAAK,MAAM,CAAA;IACrC,gEAAgE;IAChE,eAAe,EAAE,CAAC,MAAM,EAAE,CAAC,KAAK,KAAK,CAAC,SAAS,CAAA;IAC/C,+BAA+B;IAC/B,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAA;IAC1B,8BAA8B;IAC9B,eAAe,CAAC,EAAE,KAAK,CAAC,SAAS,CAAA;IACjC,+BAA+B;IAC/B,KAAK,EAAE,MAAM,CAAA;IACb,sCAAsC;IACtC,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAA;IACjC,cAAc,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAA;IACxC,iCAAiC;IACjC,KAAK,EAAE,MAAM,CAAA;IACb,yCAAyC;IACzC,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,gCAAgC;IAChC,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,mCAAmC;IACnC,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;IACvB,yBAAyB;IACzB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,wCAAwC;IACxC,gBAAgB,CAAC,EAAE,MAAM,CAAA;IACzB,gCAAgC;IAChC,gBAAgB,CAAC,EAAE,MAAM,CAAA;IACzB,mCAAmC;IACnC,SAAS,CAAC,EAAE,OAAO,CAAA;IACnB,MAAM;IACN,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,YAAY,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC,KAAK,MAAM,CAAA;CACrC;AAED,wBAAgB,WAAW,CAAC,CAAC,EAAE,EAC7B,OAAO,EACP,OAAO,EACP,QAAQ,EACR,YAAY,EACZ,cAAc,EACd,eAAe,EACf,QAAQ,EACR,eAAe,EACf,KAAK,EACL,WAAyB,EACzB,KAAK,EACL,QAAQ,EACR,cAAc,EACd,QAAgB,EAChB,KAAe,EACf,SAAS,EACT,gBAAgB,EAChB,gBAAgB,EAChB,SAAgB,EAChB,OAAc,EACd,YAAY,GACb,EAAE,gBAAgB,CAAC,CAAC,CAAC,2CA4KrB"}
@@ -1,2 +1,2 @@
1
- import*as e from"react/jsx-runtime";import*as s from"react";import*as t from"../hooks/use-debounce.js";import*as a from"../lib/utils.js";import*as l from"@phosphor-icons/react";import*as n from"./button.js";import*as o from"./command.js";import*as r from"./popover.js";import*as i from"./spinner.js";function c({fetcher:c,preload:d,filterFn:u,renderOption:p,getOptionValue:h,getDisplayValue:f,notFound:x,loadingSkeleton:j,label:v,placeholder:y="Select...",value:C,onChange:b,disabled:g=!1,width:w="200px",className:S,triggerClassName:N,noResultsMessage:E,clearable:k=!0,enabled:F=!0}){let[I,L]=(0,s.useState)(!1),[P,D]=(0,s.useState)(!1),[G,$]=(0,s.useState)([]),[z,A]=(0,s.useState)(!1),[B,O]=(0,s.useState)(null),[T,U]=(0,s.useState)(C),[V,q]=(0,s.useState)(null),[H,J]=(0,s.useState)(""),K=(0,t.useDebounce)(H,300*!d),[M,Q]=(0,s.useState)([]);(0,s.useEffect)(()=>{L(!0),U(C)},[C]),(0,s.useEffect)(()=>{if(C&&G.length>0){let e=G.find(e=>h(e)===C);e&&q(e)}},[C,G,h]),(0,s.useEffect)(()=>{let e=async()=>{try{A(!0),O(null);let e=await c(C);Q(e),$(e)}catch(e){O(e instanceof Error?e.message:"Failed to fetch options")}finally{A(!1)}};!I&&F&&e()},[I,c,C]),(0,s.useEffect)(()=>{let e=async()=>{try{A(!0),O(null);let e=await c(K);Q(e),$(e)}catch(e){O(e instanceof Error?e.message:"Failed to fetch options")}finally{A(!1)}};!I&&F||!d&&F?e():d&&(K?$(M.filter(e=>!u||u(e,K))):$(M))},[c,K,I,d,u]);let R=(0,s.useCallback)(e=>{let s=k&&e===T?"":e;U(s),q(G.find(e=>h(e)===s)||null),b(s),D(!1)},[T,b,k,G,h]);return(0,e.jsxs)(r.Popover,{open:P,onOpenChange:D,children:[(0,e.jsx)(r.PopoverTrigger,{asChild:!0,children:(0,e.jsxs)(n.Button,{variant:"secondary",role:"combobox","aria-expanded":P,className:(0,a.cn)("justify-between",g&&"cursor-not-allowed opacity-50",N),style:{width:w},disabled:g,children:[V?f(V):y,(0,e.jsx)(l.CaretUpDown,{className:"opacity-50",size:10})]})}),(0,e.jsx)(r.PopoverContent,{style:{width:w},className:(0,a.cn)("p-0",S),children:(0,e.jsxs)(o.Command,{shouldFilter:!1,children:[(0,e.jsxs)("div",{className:"relative w-full border-b",children:[(0,e.jsx)(o.CommandInput,{placeholder:`Search ${v.toLowerCase()}...`,value:H,onValueChange:e=>{J(e)}}),z&&G.length>0&&(0,e.jsx)("div",{className:"-translate-y-1/2 absolute top-1/2 right-2 flex transform items-center",children:(0,e.jsx)(i.Spinner,{})})]}),(0,e.jsxs)(o.CommandList,{children:[B&&(0,e.jsx)("div",{className:"p-4 text-center text-destructive",children:B}),z&&0===G.length&&(j||(0,e.jsx)(m,{})),!z&&!B&&0===G.length&&(x||(0,e.jsx)(o.CommandEmpty,{children:E??`No ${v.toLowerCase()} found.`})),(0,e.jsx)(o.CommandGroup,{children:G.map(s=>(0,e.jsxs)(o.CommandItem,{value:h(s),onSelect:R,children:[p(s),(0,e.jsx)(l.Check,{className:(0,a.cn)("ml-auto h-3 w-3",T===h(s)?"opacity-100":"opacity-0")})]},h(s)))})]})]})})]})}function m(){return(0,e.jsx)(o.CommandGroup,{children:[1,2,3].map(s=>(0,e.jsx)(o.CommandItem,{disabled:!0,children:(0,e.jsxs)("div",{className:"flex w-full items-center gap-2",children:[(0,e.jsx)("div",{className:"h-6 w-6 animate-pulse rounded-full bg-muted"}),(0,e.jsxs)("div",{className:"flex flex-1 flex-col gap-1",children:[(0,e.jsx)("div",{className:"h-4 w-24 animate-pulse rounded bg-muted"}),(0,e.jsx)("div",{className:"h-3 w-16 animate-pulse rounded bg-muted"})]})]})},s))})}export{c as AsyncSelect};
1
+ import*as e from"react/jsx-runtime";import*as s from"react";import*as t from"../hooks/use-debounce.js";import*as a from"../lib/utils.js";import*as l from"@phosphor-icons/react";import*as n from"./button.js";import*as o from"./command.js";import*as r from"./popover.js";import*as i from"./spinner.js";function c({fetcher:c,preload:d,filterFn:u,renderOption:p,getOptionValue:h,getDisplayValue:f,notFound:x,loadingSkeleton:j,label:v,placeholder:y="Select...",value:C,onChange:b,onSearchChange:g,disabled:w=!1,width:S="200px",className:N,triggerClassName:E,noResultsMessage:k,clearable:F=!0,enabled:I=!0,keyExtractor:L}){let[P,D]=(0,s.useState)(!1),[G,$]=(0,s.useState)(!1),[z,A]=(0,s.useState)([]),[B,O]=(0,s.useState)(!1),[T,U]=(0,s.useState)(null),[V,q]=(0,s.useState)(C),[H,J]=(0,s.useState)(null),[K,M]=(0,s.useState)(""),Q=(0,t.useDebounce)(K,300*!d),[R,W]=(0,s.useState)([]);(0,s.useEffect)(()=>{D(!0),q(C)},[C]),(0,s.useEffect)(()=>{if(C&&z.length>0){let e=z.find(e=>h(e)===C);e&&J(e)}},[C,z,h]),(0,s.useEffect)(()=>{let e=async()=>{try{O(!0),U(null);let e=await c(C);W(e),A(e)}catch(e){U(e instanceof Error?e.message:"Failed to fetch options")}finally{O(!1)}};!P&&I&&e()},[P,c,C]),(0,s.useEffect)(()=>{let e=async()=>{try{O(!0),U(null);let e=await c(Q);W(e),A(e)}catch(e){U(e instanceof Error?e.message:"Failed to fetch options")}finally{O(!1)}};!P&&I||!d&&I?e():d&&(Q?A(R.filter(e=>!u||u(e,Q))):A(R))},[c,Q,P,d,u]);let X=(0,s.useCallback)(e=>{let s=F&&e===V?"":e;q(s),J(z.find(e=>h(e)===s)||null),b(s),$(!1)},[V,b,F,z,h]);return(0,e.jsxs)(r.Popover,{open:G,onOpenChange:$,children:[(0,e.jsx)(r.PopoverTrigger,{asChild:!0,children:(0,e.jsxs)(n.Button,{variant:"secondary",role:"combobox","aria-expanded":G,className:(0,a.cn)("justify-between",w&&"cursor-not-allowed opacity-50",E),style:{width:S},disabled:w,children:[H?f(H):y,(0,e.jsx)(l.CaretUpDown,{className:"opacity-50",size:10})]})}),(0,e.jsx)(r.PopoverContent,{style:{width:S},className:(0,a.cn)("p-0",N),children:(0,e.jsxs)(o.Command,{shouldFilter:!1,children:[(0,e.jsxs)("div",{className:"relative w-full border-b",children:[(0,e.jsx)(o.CommandInput,{placeholder:`Search ${v.toLowerCase()}...`,value:K,onValueChange:e=>{M(e),g?.(e)}}),B&&z.length>0&&(0,e.jsx)("div",{className:"-translate-y-1/2 absolute top-1/2 right-2 flex transform items-center",children:(0,e.jsx)(i.Spinner,{})})]}),(0,e.jsxs)(o.CommandList,{children:[T&&(0,e.jsx)("div",{className:"p-4 text-center text-destructive",children:T}),B&&0===z.length&&(j||(0,e.jsx)(m,{})),!B&&!T&&0===z.length&&(x||(0,e.jsx)(o.CommandEmpty,{children:k??`No ${v.toLowerCase()} found.`})),(0,e.jsx)(o.CommandGroup,{children:z.map(s=>(0,e.jsxs)(o.CommandItem,{value:h(s),onSelect:X,children:[p(s),(0,e.jsx)(l.Check,{className:(0,a.cn)("ml-auto h-3 w-3",V===h(s)?"opacity-100":"opacity-0")})]},L?L(s):h(s)))})]})]})})]})}function m(){return(0,e.jsx)(o.CommandGroup,{children:[1,2,3].map(s=>(0,e.jsx)(o.CommandItem,{disabled:!0,children:(0,e.jsxs)("div",{className:"flex w-full items-center gap-2",children:[(0,e.jsx)("div",{className:"h-6 w-6 animate-pulse rounded-full bg-muted"}),(0,e.jsxs)("div",{className:"flex flex-1 flex-col gap-1",children:[(0,e.jsx)("div",{className:"h-4 w-24 animate-pulse rounded bg-muted"}),(0,e.jsx)("div",{className:"h-3 w-16 animate-pulse rounded bg-muted"})]})]})},s))})}export{c as AsyncSelect};
2
2
  //# sourceMappingURL=async-select.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"components\\async-select.js","sources":["webpack://@gbmtech/aurora-ui/./src/components/async-select.tsx"],"sourcesContent":["import { useCallback, useEffect, useState } from 'react'\n\nimport { useDebounce } from '@/hooks/use-debounce'\nimport { cn } from '@/lib/utils'\nimport { CaretUpDown, Check } from '@phosphor-icons/react'\nimport { Button } from './button'\nimport {\n Command,\n CommandEmpty,\n CommandGroup,\n CommandInput,\n CommandItem,\n CommandList,\n} from './command'\nimport { Popover, PopoverContent, PopoverTrigger } from './popover'\nimport { Spinner } from './spinner'\n\nexport interface Option {\n value: string\n label: string\n disabled?: boolean\n description?: string\n icon?: React.ReactNode\n}\n\nexport interface AsyncSelectProps<T> {\n /** Async function to fetch options */\n fetcher: (query?: string) => Promise<T[]>\n /** Preload all data ahead of time */\n preload?: boolean\n /** Function to filter options */\n filterFn?: (option: T, query: string) => boolean\n /** Function to render each option */\n renderOption: (option: T) => React.ReactNode\n /** Function to get the value from an option */\n getOptionValue: (option: T) => string\n /** Function to get the display value for the selected option */\n getDisplayValue: (option: T) => React.ReactNode\n /** Custom not found message */\n notFound?: React.ReactNode\n /** Custom loading skeleton */\n loadingSkeleton?: React.ReactNode\n /** Currently selected value */\n value: string\n /** Callback when selection changes */\n onChange: (value: string) => void\n /** Label for the select field */\n label: string\n /** Placeholder text when no selection */\n placeholder?: string\n /** Disable the entire select */\n disabled?: boolean\n /** Custom width for the popover */\n width?: string | number\n /** Custom class names */\n className?: string\n /** Custom trigger button class names */\n triggerClassName?: string\n /** Custom no results message */\n noResultsMessage?: string\n /** Allow clearing the selection */\n clearable?: boolean\n /** */\n enabled?: boolean\n}\n\nexport function AsyncSelect<T>({\n fetcher,\n preload,\n filterFn,\n renderOption,\n getOptionValue,\n getDisplayValue,\n notFound,\n loadingSkeleton,\n label,\n placeholder = 'Select...',\n value,\n onChange,\n disabled = false,\n width = '200px',\n className,\n triggerClassName,\n noResultsMessage,\n clearable = true,\n enabled = true,\n}: AsyncSelectProps<T>) {\n const [mounted, setMounted] = useState(false)\n const [open, setOpen] = useState(false)\n const [options, setOptions] = useState<T[]>([])\n const [loading, setLoading] = useState(false)\n const [error, setError] = useState<string | null>(null)\n const [selectedValue, setSelectedValue] = useState(value)\n const [selectedOption, setSelectedOption] = useState<T | null>(null)\n const [searchTerm, setSearchTerm] = useState('')\n const debouncedSearchTerm = useDebounce(searchTerm, preload ? 0 : 300)\n const [originalOptions, setOriginalOptions] = useState<T[]>([])\n\n useEffect(() => {\n setMounted(true)\n setSelectedValue(value)\n }, [value])\n\n // Initialize selectedOption when options are loaded and value exists\n useEffect(() => {\n if (value && options.length > 0) {\n const option = options.find(opt => getOptionValue(opt) === value)\n if (option) {\n setSelectedOption(option)\n }\n }\n }, [value, options, getOptionValue])\n\n // Effect for initial fetch\n useEffect(() => {\n const initializeOptions = async () => {\n try {\n setLoading(true)\n setError(null)\n // If we have a value, use it for the initial search\n const data = await fetcher(value)\n setOriginalOptions(data)\n setOptions(data)\n } catch (err) {\n setError(err instanceof Error ? err.message : 'Failed to fetch options')\n } finally {\n setLoading(false)\n }\n }\n\n if (!mounted && enabled) {\n initializeOptions()\n }\n }, [mounted, fetcher, value])\n\n useEffect(() => {\n const fetchOptions = async () => {\n try {\n setLoading(true)\n setError(null)\n const data = await fetcher(debouncedSearchTerm)\n setOriginalOptions(data)\n setOptions(data)\n } catch (err) {\n setError(err instanceof Error ? err.message : 'Failed to fetch options')\n } finally {\n setLoading(false)\n }\n }\n\n if (!mounted && enabled) {\n fetchOptions()\n } else if (!preload && enabled) {\n fetchOptions()\n } else if (preload) {\n if (debouncedSearchTerm) {\n setOptions(\n originalOptions.filter(option =>\n filterFn ? filterFn(option, debouncedSearchTerm) : true\n )\n )\n } else {\n setOptions(originalOptions)\n }\n }\n }, [fetcher, debouncedSearchTerm, mounted, preload, filterFn])\n\n const handleSelect = useCallback(\n (currentValue: string) => {\n const newValue =\n clearable && currentValue === selectedValue ? '' : currentValue\n setSelectedValue(newValue)\n setSelectedOption(\n options.find(option => getOptionValue(option) === newValue) || null\n )\n onChange(newValue)\n setOpen(false)\n },\n [selectedValue, onChange, clearable, options, getOptionValue]\n )\n\n return (\n <Popover open={open} onOpenChange={setOpen}>\n <PopoverTrigger asChild>\n <Button\n variant=\"secondary\"\n role=\"combobox\"\n aria-expanded={open}\n className={cn(\n 'justify-between',\n disabled && 'cursor-not-allowed opacity-50',\n triggerClassName\n )}\n style={{ width: width }}\n disabled={disabled}\n >\n {selectedOption ? getDisplayValue(selectedOption) : placeholder}\n <CaretUpDown className=\"opacity-50\" size={10} />\n </Button>\n </PopoverTrigger>\n <PopoverContent style={{ width: width }} className={cn('p-0', className)}>\n <Command shouldFilter={false}>\n <div className=\"relative w-full border-b\">\n <CommandInput\n placeholder={`Search ${label.toLowerCase()}...`}\n value={searchTerm}\n onValueChange={value => {\n setSearchTerm(value)\n }}\n />\n {loading && options.length > 0 && (\n <div className=\"-translate-y-1/2 absolute top-1/2 right-2 flex transform items-center\">\n <Spinner />\n </div>\n )}\n </div>\n <CommandList>\n {error && (\n <div className=\"p-4 text-center text-destructive\">{error}</div>\n )}\n {loading &&\n options.length === 0 &&\n (loadingSkeleton || <DefaultLoadingSkeleton />)}\n {!loading &&\n !error &&\n options.length === 0 &&\n (notFound || (\n <CommandEmpty>\n {noResultsMessage ?? `No ${label.toLowerCase()} found.`}\n </CommandEmpty>\n ))}\n <CommandGroup>\n {options.map(option => (\n <CommandItem\n key={getOptionValue(option)}\n value={getOptionValue(option)}\n onSelect={handleSelect}\n >\n {renderOption(option)}\n <Check\n className={cn(\n 'ml-auto h-3 w-3',\n selectedValue === getOptionValue(option)\n ? 'opacity-100'\n : 'opacity-0'\n )}\n />\n </CommandItem>\n ))}\n </CommandGroup>\n </CommandList>\n </Command>\n </PopoverContent>\n </Popover>\n )\n}\n\nfunction DefaultLoadingSkeleton() {\n return (\n <CommandGroup>\n {[1, 2, 3].map(i => (\n <CommandItem key={i} disabled>\n <div className=\"flex w-full items-center gap-2\">\n <div className=\"h-6 w-6 animate-pulse rounded-full bg-muted\" />\n <div className=\"flex flex-1 flex-col gap-1\">\n <div className=\"h-4 w-24 animate-pulse rounded bg-muted\" />\n <div className=\"h-3 w-16 animate-pulse rounded bg-muted\" />\n </div>\n </div>\n </CommandItem>\n ))}\n </CommandGroup>\n )\n}\n"],"names":["AsyncSelect","fetcher","preload","filterFn","renderOption","getOptionValue","getDisplayValue","notFound","loadingSkeleton","label","placeholder","value","onChange","disabled","width","className","triggerClassName","noResultsMessage","clearable","enabled","mounted","setMounted","useState","open","setOpen","options","setOptions","loading","setLoading","error","setError","selectedValue","setSelectedValue","selectedOption","setSelectedOption","searchTerm","setSearchTerm","debouncedSearchTerm","useDebounce","originalOptions","setOriginalOptions","useEffect","option","opt","initializeOptions","data","err","Error","fetchOptions","handleSelect","useCallback","currentValue","newValue","Popover","PopoverTrigger","Button","cn","CaretUpDown","PopoverContent","Command","CommandInput","Spinner","CommandList","DefaultLoadingSkeleton","CommandEmpty","CommandGroup","CommandItem","Check","i"],"mappings":"4SAkEO,SAASA,EAAe,CAC7BC,QAAAA,CAAO,CACPC,QAAAA,CAAO,CACPC,SAAAA,CAAQ,CACRC,aAAAA,CAAY,CACZC,eAAAA,CAAc,CACdC,gBAAAA,CAAe,CACfC,SAAAA,CAAQ,CACRC,gBAAAA,CAAe,CACfC,MAAAA,CAAK,CACLC,YAAAA,EAAc,WAAW,CACzBC,MAAAA,CAAK,CACLC,SAAAA,CAAQ,CACRC,SAAAA,EAAW,EAAK,CAChBC,MAAAA,EAAQ,OAAO,CACfC,UAAAA,CAAS,CACTC,iBAAAA,CAAgB,CAChBC,iBAAAA,CAAgB,CAChBC,UAAAA,EAAY,EAAI,CAChBC,QAAAA,EAAU,EAAI,CACM,EACpB,GAAM,CAACC,EAASC,EAAW,CAAGC,AAAAA,GAAAA,EAAAA,QAAAA,AAAAA,EAAS,IACjC,CAACC,EAAMC,EAAQ,CAAGF,AAAAA,GAAAA,EAAAA,QAAAA,AAAAA,EAAS,IAC3B,CAACG,EAASC,EAAW,CAAGJ,AAAAA,GAAAA,EAAAA,QAAAA,AAAAA,EAAc,EAAE,EACxC,CAACK,EAASC,EAAW,CAAGN,AAAAA,GAAAA,EAAAA,QAAAA,AAAAA,EAAS,IACjC,CAACO,EAAOC,EAAS,CAAGR,AAAAA,GAAAA,EAAAA,QAAAA,AAAAA,EAAwB,MAC5C,CAACS,EAAeC,EAAiB,CAAGV,AAAAA,GAAAA,EAAAA,QAAAA,AAAAA,EAASX,GAC7C,CAACsB,EAAgBC,EAAkB,CAAGZ,AAAAA,GAAAA,EAAAA,QAAAA,AAAAA,EAAmB,MACzD,CAACa,EAAYC,EA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,IACbyB,EAAczB,EAChB,C,GAEDgB,GAAWF,EAAQ,MAAM,CAAG,GAC3B,UAAC,OAAI,UAAU,wE,SACb,UAACoC,EAAAA,OAAOA,CAAAA,CAAAA,E,MAId,WAACC,EAAAA,WAAWA,CAAAA,C,UACTjC,GACC,UAAC,OAAI,UAAU,mC,SAAoCA,C,GAEpDF,GACCF,AAAmB,IAAnBA,EAAQ,MAAM,EACbjB,CAAAA,GAAmB,UAACuD,EAAAA,CAAAA,EAAAA,EACtB,CAACpC,GACA,CAACE,GACDJ,AAAmB,IAAnBA,EAAQ,MAAM,EACblB,CAAAA,GACC,UAACyD,EAAAA,YAAYA,CAAAA,C,SACV/C,GAAoB,CAAC,GAAG,EAAER,EAAM,WAAW,GAAG,OAAO,CAAC,A,IAG7D,UAACwD,EAAAA,YAAYA,CAAAA,C,SACVxC,EAAQ,GAAG,CAACiB,AAAAA,GACX,WAACwB,EAAAA,WAAWA,CAAAA,CAEV,MAAO7D,EAAeqC,GACtB,SAAUO,E,UAET7C,EAAasC,GACd,UAACyB,EAAAA,KAAKA,CAAAA,CACJ,UAAWX,AAAAA,GAAAA,EAAAA,EAAAA,AAAAA,EACT,kBACAzB,IAAkB1B,EAAeqC,GAC7B,cACA,Y,KAVHrC,EAAeqC,I,aAqBtC,CAEA,SAASqB,IACP,MACE,UAACE,EAAAA,YAAYA,CAAAA,C,SACV,CAAC,EAAG,EAAG,EAAE,CAAC,GAAG,CAACG,AAAAA,GACb,UAACF,EAAAA,WAAWA,CAAAA,CAAS,SAAQ,G,SAC3B,WAAC,OAAI,UAAU,iC,UACb,UAAC,OAAI,UAAU,6C,GACf,WAAC,OAAI,UAAU,6B,UACb,UAAC,OAAI,UAAU,yC,GACf,UAAC,OAAI,UAAU,yC,UALHE,G,EAY1B,Q"}
1
+ {"version":3,"file":"components\\async-select.js","sources":["webpack://@gbmtech/aurora-ui/./src/components/async-select.tsx"],"sourcesContent":["import { useCallback, useEffect, useState } from 'react'\n\nimport { useDebounce } from '@/hooks/use-debounce'\nimport { cn } from '@/lib/utils'\nimport { CaretUpDown, Check } from '@phosphor-icons/react'\nimport { Button } from './button'\nimport {\n Command,\n CommandEmpty,\n CommandGroup,\n CommandInput,\n CommandItem,\n CommandList,\n} from './command'\nimport { Popover, PopoverContent, PopoverTrigger } from './popover'\nimport { Spinner } from './spinner'\n\nexport interface Option {\n value: string\n label: string\n disabled?: boolean\n description?: string\n icon?: React.ReactNode\n}\n\nexport interface AsyncSelectProps<T> {\n /** Async function to fetch options */\n fetcher: (query?: string) => Promise<T[]>\n /** Preload all data ahead of time */\n preload?: boolean\n /** Function to filter options */\n filterFn?: (option: T, query: string) => boolean\n /** Function to render each option */\n renderOption: (option: T) => React.ReactNode\n /** Function to get the value from an option */\n getOptionValue: (option: T) => string\n /** Function to get the display value for the selected option */\n getDisplayValue: (option: T) => React.ReactNode\n /** Custom not found message */\n notFound?: React.ReactNode\n /** Custom loading skeleton */\n loadingSkeleton?: React.ReactNode\n /** Currently selected value */\n value: string\n /** Callback when selection changes */\n onChange: (value: string) => void\n onSearchChange?: (value: string) => void\n /** Label for the select field */\n label: string\n /** Placeholder text when no selection */\n placeholder?: string\n /** Disable the entire select */\n disabled?: boolean\n /** Custom width for the popover */\n width?: string | number\n /** Custom class names */\n className?: string\n /** Custom trigger button class names */\n triggerClassName?: string\n /** Custom no results message */\n noResultsMessage?: string\n /** Allow clearing the selection */\n clearable?: boolean\n /** */\n enabled?: boolean\n keyExtractor?: (option: T) => string\n}\n\nexport function AsyncSelect<T>({\n fetcher,\n preload,\n filterFn,\n renderOption,\n getOptionValue,\n getDisplayValue,\n notFound,\n loadingSkeleton,\n label,\n placeholder = 'Select...',\n value,\n onChange,\n onSearchChange,\n disabled = false,\n width = '200px',\n className,\n triggerClassName,\n noResultsMessage,\n clearable = true,\n enabled = true,\n keyExtractor,\n}: AsyncSelectProps<T>) {\n const [mounted, setMounted] = useState(false)\n const [open, setOpen] = useState(false)\n const [options, setOptions] = useState<T[]>([])\n const [loading, setLoading] = useState(false)\n const [error, setError] = useState<string | null>(null)\n const [selectedValue, setSelectedValue] = useState(value)\n const [selectedOption, setSelectedOption] = useState<T | null>(null)\n const [searchTerm, setSearchTerm] = useState('')\n const debouncedSearchTerm = useDebounce(searchTerm, preload ? 0 : 300)\n const [originalOptions, setOriginalOptions] = useState<T[]>([])\n\n useEffect(() => {\n setMounted(true)\n setSelectedValue(value)\n }, [value])\n\n // Initialize selectedOption when options are loaded and value exists\n useEffect(() => {\n if (value && options.length > 0) {\n const option = options.find(opt => getOptionValue(opt) === value)\n if (option) {\n setSelectedOption(option)\n }\n }\n }, [value, options, getOptionValue])\n\n // Effect for initial fetch\n useEffect(() => {\n const initializeOptions = async () => {\n try {\n setLoading(true)\n setError(null)\n // If we have a value, use it for the initial search\n const data = await fetcher(value)\n setOriginalOptions(data)\n setOptions(data)\n } catch (err) {\n setError(err instanceof Error ? err.message : 'Failed to fetch options')\n } finally {\n setLoading(false)\n }\n }\n\n if (!mounted && enabled) {\n initializeOptions()\n }\n }, [mounted, fetcher, value])\n\n useEffect(() => {\n const fetchOptions = async () => {\n try {\n setLoading(true)\n setError(null)\n const data = await fetcher(debouncedSearchTerm)\n setOriginalOptions(data)\n setOptions(data)\n } catch (err) {\n setError(err instanceof Error ? err.message : 'Failed to fetch options')\n } finally {\n setLoading(false)\n }\n }\n\n if (!mounted && enabled) {\n fetchOptions()\n } else if (!preload && enabled) {\n fetchOptions()\n } else if (preload) {\n if (debouncedSearchTerm) {\n setOptions(\n originalOptions.filter(option =>\n filterFn ? filterFn(option, debouncedSearchTerm) : true\n )\n )\n } else {\n setOptions(originalOptions)\n }\n }\n }, [fetcher, debouncedSearchTerm, mounted, preload, filterFn])\n\n const handleSelect = useCallback(\n (currentValue: string) => {\n const newValue =\n clearable && currentValue === selectedValue ? '' : currentValue\n setSelectedValue(newValue)\n setSelectedOption(\n options.find(option => getOptionValue(option) === newValue) || null\n )\n onChange(newValue)\n setOpen(false)\n },\n [selectedValue, onChange, clearable, options, getOptionValue]\n )\n\n return (\n <Popover open={open} onOpenChange={setOpen}>\n <PopoverTrigger asChild>\n <Button\n variant=\"secondary\"\n role=\"combobox\"\n aria-expanded={open}\n className={cn(\n 'justify-between',\n disabled && 'cursor-not-allowed opacity-50',\n triggerClassName\n )}\n style={{ width: width }}\n disabled={disabled}\n >\n {selectedOption ? getDisplayValue(selectedOption) : placeholder}\n <CaretUpDown className=\"opacity-50\" size={10} />\n </Button>\n </PopoverTrigger>\n <PopoverContent style={{ width: width }} className={cn('p-0', className)}>\n <Command shouldFilter={false}>\n <div className=\"relative w-full border-b\">\n <CommandInput\n placeholder={`Search ${label.toLowerCase()}...`}\n value={searchTerm}\n onValueChange={value => {\n setSearchTerm(value)\n onSearchChange?.(value)\n }}\n />\n {loading && options.length > 0 && (\n <div className=\"-translate-y-1/2 absolute top-1/2 right-2 flex transform items-center\">\n <Spinner />\n </div>\n )}\n </div>\n <CommandList>\n {error && (\n <div className=\"p-4 text-center text-destructive\">{error}</div>\n )}\n {loading &&\n options.length === 0 &&\n (loadingSkeleton || <DefaultLoadingSkeleton />)}\n {!loading &&\n !error &&\n options.length === 0 &&\n (notFound || (\n <CommandEmpty>\n {noResultsMessage ?? `No ${label.toLowerCase()} found.`}\n </CommandEmpty>\n ))}\n <CommandGroup>\n {options.map(option => (\n <CommandItem\n key={\n keyExtractor ? keyExtractor(option) : getOptionValue(option)\n }\n value={getOptionValue(option)}\n onSelect={handleSelect}\n >\n {renderOption(option)}\n <Check\n className={cn(\n 'ml-auto h-3 w-3',\n selectedValue === getOptionValue(option)\n ? 'opacity-100'\n : 'opacity-0'\n )}\n />\n </CommandItem>\n ))}\n </CommandGroup>\n </CommandList>\n </Command>\n </PopoverContent>\n </Popover>\n )\n}\n\nfunction DefaultLoadingSkeleton() {\n return (\n <CommandGroup>\n {[1, 2, 3].map(i => (\n <CommandItem key={i} disabled>\n <div className=\"flex w-full items-center gap-2\">\n <div className=\"h-6 w-6 animate-pulse rounded-full bg-muted\" />\n <div className=\"flex flex-1 flex-col gap-1\">\n <div className=\"h-4 w-24 animate-pulse rounded bg-muted\" />\n <div className=\"h-3 w-16 animate-pulse rounded bg-muted\" />\n </div>\n </div>\n </CommandItem>\n ))}\n </CommandGroup>\n )\n}\n"],"names":["AsyncSelect","fetcher","preload","filterFn","renderOption","getOptionValue","getDisplayValue","notFound","loadingSkeleton","label","placeholder","value","onChange","onSearchChange","disabled","width","className","triggerClassName","noResultsMessage","clearable","enabled","keyExtractor","mounted","setMounted","useState","open","setOpen","options","setOptions","loading","setLoading","error","setError","selectedValue","setSelectedValue","selectedOption","setSelectedOption","searchTerm","setSearchTerm","debouncedSearchTerm","useDebounce","originalOptions","setOriginalOptions","useEffect","option","opt","initializeOptions","data","err","Error","fetchOptions","handleSelect","useCallback","currentValue","newValue","Popover","PopoverTrigger","Button","cn","CaretUpDown","PopoverContent","Command","CommandInput","Spinner","CommandList","DefaultLoadingSkeleton","CommandEmpty","CommandGroup","CommandItem","Check","i"],"mappings":"4SAoEO,SAASA,EAAe,CAC7BC,QAAAA,CAAO,CACPC,QAAAA,CAAO,CACPC,SAAAA,CAAQ,CACRC,aAAAA,CAAY,CACZC,eAAAA,CAAc,CACdC,gBAAAA,CAAe,CACfC,SAAAA,CAAQ,CACRC,gBAAAA,CAAe,CACfC,MAAAA,CAAK,CACLC,YAAAA,EAAc,WAAW,CACzBC,MAAAA,CAAK,CACLC,SAAAA,CAAQ,CACRC,eAAAA,CAAc,CACdC,SAAAA,EAAW,EAAK,CAChBC,MAAAA,EAAQ,OAAO,CACfC,UAAAA,CAAS,CACTC,iBAAAA,CAAgB,CAChBC,iBAAAA,CAAgB,CAChBC,UAAAA,EAAY,EAAI,CAChBC,QAAAA,EAAU,EAAI,CACdC,aAAAA,CAAY,CACQ,EACpB,GAAM,CAACC,EAASC,EAAW,CAAGC,AAAAA,GAAAA,EAAAA,QAAAA,AAAAA,EAAS,IACjC,CAACC,EAAMC,EAAQ,CAAGF,AAAAA,GAAAA,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NvB,EAAeA,EAAauB,GAAUvC,EAAeuC,I,aAsBzE,CAEA,SAASqB,IACP,MACE,UAACE,EAAAA,YAAYA,CAAAA,C,SACV,CAAC,EAAG,EAAG,EAAE,CAAC,GAAG,CAACG,AAAAA,GACb,UAACF,EAAAA,WAAWA,CAAAA,CAAS,SAAQ,G,SAC3B,WAAC,OAAI,UAAU,iC,UACb,UAAC,OAAI,UAAU,6C,GACf,WAAC,OAAI,UAAU,6B,UACb,UAAC,OAAI,UAAU,yC,GACf,UAAC,OAAI,UAAU,yC,UALHE,G,EAY1B,Q"}
@@ -1 +1 @@
1
- import*as t from"./data-table-pagination.js";export*from"./data-table-action-bar.js";export*from"./data-table-advanced-toolbar.js";export*from"./data-table-column-header.js";export*from"./data-table-date-filter.js";export*from"./data-table-faceted-filter.js";export*from"./data-table-filter-list.js";export*from"./data-table-filter-menu.js";export*from"./data-table-range-filter.js";export*from"./data-table-skeleton.js";export*from"./data-table-slider-filter.js";export*from"./data-table-sort-list.js";export*from"./data-table-toolbar.js";export*from"./data-table-view-options.js";export*from"./data-table.js";var a={"@/components/data-table/data-table-pagination":function(a){a.exports=t}},e={};!function t(o){var r=e[o];if(void 0!==r)return r.exports;var l=e[o]={exports:{}};return a[o](l,l.exports,t),l.exports}("@/components/data-table/data-table-pagination");
1
+ import*as t from"./data-table-date-filter.js";import*as a from"./data-table-faceted-filter.js";import*as e from"./data-table-pagination.js";import*as o from"./data-table-slider-filter.js";import*as r from"./data-table-view-options.js";export*from"./data-table-action-bar.js";export*from"./data-table-advanced-toolbar.js";export*from"./data-table-column-header.js";export*from"./data-table-filter-list.js";export*from"./data-table-filter-menu.js";export*from"./data-table-range-filter.js";export*from"./data-table-skeleton.js";export*from"./data-table-sort-list.js";export*from"./data-table-toolbar.js";export*from"./data-table.js";var n={"@/components/data-table/data-table-date-filter":function(a){a.exports=t},"@/components/data-table/data-table-faceted-filter":function(t){t.exports=a},"@/components/data-table/data-table-pagination":function(t){t.exports=e},"@/components/data-table/data-table-slider-filter":function(t){t.exports=o},"@/components/data-table/data-table-view-options":function(t){t.exports=r}},d={};function l(t){var a=d[t];if(void 0!==a)return a.exports;var e=d[t]={exports:{}};return n[t](e,e.exports,l),e.exports}l.d=(t,a)=>{for(var e in a)l.o(a,e)&&!l.o(t,e)&&Object.defineProperty(t,e,{enumerable:!0,get:a[e]})},l.o=(t,a)=>Object.prototype.hasOwnProperty.call(t,a),l.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var i={};l.r(i);var f=l("@/components/data-table/data-table-date-filter"),b={};for(var s in f)"default"!==s&&(b[s]=(function(t){return f[t]}).bind(0,s));l.d(i,b);var p=l("@/components/data-table/data-table-faceted-filter"),b={};for(var s in p)"default"!==s&&(b[s]=(function(t){return p[t]}).bind(0,s));l.d(i,b);var m=l("@/components/data-table/data-table-pagination"),b={};for(var s in m)"default"!==s&&(b[s]=(function(t){return m[t]}).bind(0,s));l.d(i,b);var c=l("@/components/data-table/data-table-slider-filter"),b={};for(var s in c)"default"!==s&&(b[s]=(function(t){return c[t]}).bind(0,s));l.d(i,b);var u=l("@/components/data-table/data-table-view-options"),b={};for(var s in u)"default"!==s&&(b[s]=(function(t){return u[t]}).bind(0,s));l.d(i,b);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gbmtech/aurora-ui",
3
- "version": "0.2.17",
3
+ "version": "0.2.19",
4
4
  "main": "./dist/cjs/index.cjs",
5
5
  "module": "./dist/esm/index.js",
6
6
  "types": "./dist/types/index.d.ts",