@addsign/moje-agenda-shared-lib 2.0.0 → 2.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. package/dist/Dialog-IPFWYptw.js +421 -0
  2. package/dist/Dialog-IPFWYptw.js.map +1 -0
  3. package/dist/assets/style.css +12 -7
  4. package/dist/components/datatable/DataTable.js +1 -2
  5. package/dist/components/datatable/DataTable.js.map +1 -1
  6. package/dist/components/datatable/DataTableServer.js +1 -2
  7. package/dist/components/datatable/DataTableServer.js.map +1 -1
  8. package/dist/components/form/AutocompleteSearchBar.js +1 -2
  9. package/dist/components/form/AutocompleteSearchBar.js.map +1 -1
  10. package/dist/components/form/AutocompleteSearchBarServer.js +1 -2
  11. package/dist/components/form/AutocompleteSearchBarServer.js.map +1 -1
  12. package/dist/components/form/FileInput.js +1 -2
  13. package/dist/components/form/FileInput.js.map +1 -1
  14. package/dist/components/form/FileInputMultiple.js +1 -2
  15. package/dist/components/form/FileInputMultiple.js.map +1 -1
  16. package/dist/components/form/FormField.js +1 -2
  17. package/dist/components/form/FormField.js.map +1 -1
  18. package/dist/components/form/PositionsSelectorSingle.js +1 -2
  19. package/dist/components/form/PositionsSelectorSingle.js.map +1 -1
  20. package/dist/components/form/SelectField.js +1 -2
  21. package/dist/components/form/SelectField.js.map +1 -1
  22. package/dist/components/profiles/ProfileOverview.js +1 -2
  23. package/dist/components/profiles/ProfileOverview.js.map +1 -1
  24. package/dist/components/ui/Combobox.d.ts +14 -1
  25. package/dist/components/ui/Combobox.js +122 -98
  26. package/dist/components/ui/Combobox.js.map +1 -1
  27. package/dist/components/ui/command.js +1 -1
  28. package/dist/components/ui/command.js.map +1 -1
  29. package/dist/index-BF3Kkq7m.js +2212 -0
  30. package/dist/index-BF3Kkq7m.js.map +1 -0
  31. package/dist/index-Bm-YZac9.js +28864 -0
  32. package/dist/index-Bm-YZac9.js.map +1 -0
  33. package/dist/index-C4pkvuV-.js +1395 -0
  34. package/dist/index-C4pkvuV-.js.map +1 -0
  35. package/dist/index-M6rMtqtn.js +2203 -0
  36. package/dist/index-M6rMtqtn.js.map +1 -0
  37. package/dist/index.es-XWsfbnWC.js +9628 -0
  38. package/dist/index.es-XWsfbnWC.js.map +1 -0
  39. package/dist/jspdf.plugin.autotable-DXW3wQb-.js +11475 -0
  40. package/dist/jspdf.plugin.autotable-DXW3wQb-.js.map +1 -0
  41. package/dist/main.js +1 -4
  42. package/dist/main.js.map +1 -1
  43. package/lib/components/ui/Combobox.tsx +155 -102
  44. package/lib/components/ui/command.tsx +1 -1
  45. package/package.json +1 -1
@@ -14,8 +14,7 @@ import "../ui/input.js";
14
14
  import "../ui/form.js";
15
15
  import "../ui/radioGroup.js";
16
16
  import "../ui/command.js";
17
- import "../ui/button.js";
18
- import "../ui/popover.js";
17
+ import "../ui/Combobox.js";
19
18
  import "../../Calendar-DWT4e7Th.js";
20
19
  import "../ui/DateTimePicker.js";
21
20
  import "../ui/DatePicker.js";
@@ -1 +1 @@
1
- {"version":3,"file":"SelectField.js","sources":["../../../lib/components/form/SelectField.tsx"],"sourcesContent":["import * as React from \"react\";\r\nimport { IFormFieldGlobalProps, IOptionItem } from \"../../types\";\r\nimport { MdCheck, MdClose, MdExpandLess, MdExpandMore } from \"react-icons/md\";\r\nimport { useClickAway } from \"react-use\";\r\nimport { SpinnerIcon, useFederationContext } from \"../../main\";\r\nimport { FaSpinner } from \"react-icons/fa\";\r\n\r\nexport interface ISelectFieldProps extends IFormFieldGlobalProps {\r\n options?: IOptionItem[];\r\n valueKey?: string;\r\n labelKey?: string | ((item: any) => string);\r\n fetchUrl?: string;\r\n loading?: boolean;\r\n}\r\n\r\nexport default function SelectField({\r\n label,\r\n name,\r\n value,\r\n description,\r\n onInputChange,\r\n options,\r\n placeholder,\r\n className,\r\n errors = {},\r\n clearable,\r\n required,\r\n disabled,\r\n rounded = true,\r\n fetchUrl,\r\n valueKey,\r\n labelKey,\r\n loading,\r\n}: ISelectFieldProps) {\r\n const [isFocused, setIsFocused] = React.useState(false);\r\n const [isLoading, setIsLoading] = React.useState(false);\r\n const apiClient = useFederationContext()?.apiClient;\r\n const [localOptions, setLocalOptions] = React.useState(options);\r\n\r\n const ref = React.useRef(null);\r\n const handleClear = (e: any) => {\r\n // value;\r\n e.stopPropagation(); // Add this line\r\n\r\n setIsFocused(false);\r\n onInputChange({\r\n ...e,\r\n target: {\r\n value: \"\",\r\n name: name,\r\n },\r\n });\r\n };\r\n\r\n React.useEffect(() => {\r\n const fetchOptions = async (fetchUrl: string) => {\r\n setIsLoading(true);\r\n const { data } = await apiClient.get(fetchUrl);\r\n\r\n // Check if the first item in the data array is a number to determine the data type\r\n const isArrayOfNumbers = typeof data[0] === \"number\";\r\n const isInPageable = data && data.hasOwnProperty(\"content\");\r\n\r\n // Transform data based on its type\r\n const transformedOptions = (isInPageable ? data.content : data).map(\r\n (item: any) => {\r\n if (isArrayOfNumbers) {\r\n // If it's a number, use the number for both value and label\r\n return { value: item, label: item.toString() };\r\n } else {\r\n // Otherwise, extract using predefined keys or defaults\r\n return {\r\n value: item[valueKey || \"id\"],\r\n label:\r\n labelKey instanceof Function && labelKey !== undefined\r\n ? labelKey(item)\r\n : item[labelKey as string],\r\n };\r\n }\r\n }\r\n );\r\n\r\n setLocalOptions([\r\n { value: null, label: \" \" }, // Add an empty option as the first item\r\n ...transformedOptions,\r\n ]);\r\n setIsLoading(false);\r\n };\r\n\r\n if (fetchUrl) fetchOptions(fetchUrl);\r\n if (options) setLocalOptions(options);\r\n }, [fetchUrl, options, apiClient, valueKey, labelKey]); // ensure valueKey and labelKey are also in the dependency array if they are dynamic\r\n\r\n const handleToggleFocus = () => {\r\n setIsFocused((prev) => !prev);\r\n };\r\n\r\n useClickAway(ref, () => {\r\n setIsFocused(false);\r\n });\r\n\r\n const hangleChange = (option: IOptionItem) => {\r\n const tmp: any = {\r\n target: {\r\n value: option.value,\r\n name: name,\r\n },\r\n };\r\n\r\n onInputChange(tmp);\r\n setIsFocused(false);\r\n };\r\n const currentlySelectedOption = React.useMemo(() => {\r\n if (value === undefined || value === \"\") return null;\r\n return localOptions?.find((option) => option.value == value);\r\n }, [localOptions, value, options]);\r\n\r\n const listOfOptions = () => {\r\n if (!localOptions) return [];\r\n return (\r\n <div\r\n id=\"list\"\r\n className=\"max-h-[390px] min-w-20 w-auto whitespace-nowrap absolute z-[100000] -top-[1px] mt-[4px] bg-white rounded-lg shadow-xl border\r\n border-gray-200 justify-start items-start inline-flex overflow-auto cursor-default\"\r\n >\r\n <div className=\"grow shrink basis-0 py-1 flex-col justify-start items-start inline-flex\">\r\n {localOptions.map((option, index) => {\r\n return (\r\n <div\r\n className=\"group self-stretch px-1.5 py-px justify-start items-center inline-flex hover:bg-gray-50 \"\r\n onClick={() => hangleChange(option)}\r\n key={index}\r\n >\r\n <div className=\"grow shrink basis-0 px-1 py-2 rounded-md flex-col justify-start items-start gap-2 inline-flex\">\r\n <div className=\"self-stretch justify-start items-center gap-2 inline-flex\">\r\n <div className=\"text-gray-900 text-sm font-normal leading-normal\">\r\n {option.label}\r\n </div>\r\n {option.description && (\r\n <div className=\"text-slate-600 sm-base font-normal leading-normal\">\r\n {option.description}\r\n </div>\r\n )}\r\n </div>\r\n </div>\r\n <div className=\"w-5 h-5 relative\">\r\n {option.value === value && value !== \"\" && (\r\n <MdCheck size={22} className=\"text-primary\" />\r\n )}{\" \"}\r\n {option.value !== value && (\r\n <MdCheck\r\n size={22}\r\n className=\"text-transparent group-hover:text-gray-300\"\r\n />\r\n )}\r\n </div>\r\n </div>\r\n );\r\n })}\r\n </div>\r\n </div>\r\n );\r\n };\r\n\r\n return (\r\n <>\r\n <div\r\n className={\r\n \"w-full min-h-30 flex-col justify-start items-start gap-0inline-flex \" +\r\n className\r\n }\r\n id=\"selectField\"\r\n ref={ref}\r\n >\r\n <div className=\"self-stretch flex-col justify-start items-start gap-1.5 flex\">\r\n {label && (\r\n <label\r\n className=\"text-slate-700 text-sm font-medium leading-tight\"\r\n htmlFor={name}\r\n >\r\n {label} {required ? \"*\" : \"\"}\r\n </label>\r\n )}\r\n <div\r\n className={`self-stretch w-full px-3 py-1 bg-white border justify-start items-center gap-0 inline-flex outline-none \r\n ${isFocused ? \"outline-4 outline-indigo-200 outline-offset-0 border-indigo-300 \" : \"\"}\r\n ${\r\n isFocused && errors[name]?.message\r\n ? \"outline-4 outline-red-200 outline-offset-0 border-none\"\r\n : \"\"\r\n } \r\n ${rounded ? \" rounded-lg \" : \" rounded-none \"}\r\n ${!isFocused && errors[name]?.message ? \"border-red-200\" : \"\"} \r\n ${disabled || isLoading ? \"opacity-80 cursor-not-allowed \" : \"\"}\r\n `}\r\n onClick={() =>\r\n !disabled && !isLoading ? handleToggleFocus() : null\r\n }\r\n >\r\n <div className=\"grow shrink basis-0 min-h-[32px] justify-start items-center gap-0 flex whitespace-nowrap w-[calc(100%-40px)] \">\r\n <div\r\n className=\"text-gray-900 text-sm font-normal leading-normal text-ellipsis overflow-hidden w-full\"\r\n id={name}\r\n >\r\n {currentlySelectedOption?.label}\r\n {!currentlySelectedOption?.label && placeholder && (\r\n <span className=\"text-slate-400 font-normal\">\r\n {\" \"}\r\n {placeholder}\r\n </span>\r\n )}\r\n </div>\r\n <div className=\"text-slate-600 text-base font-normal leading-normal\">\r\n {currentlySelectedOption?.description}\r\n </div>\r\n </div>\r\n {clearable &&\r\n value !== \"\" &&\r\n value !== null &&\r\n value !== undefined &&\r\n !disabled && (\r\n <div\r\n className=\"w-6 h-6 relative cursor-pointer \"\r\n id={name + \":clear\"}\r\n onClick={handleClear}\r\n >\r\n <div className=\"absolute inset-0 flex items-center justify-center hover:bg-gray-100 w-6 rounded-full text-lg\">\r\n <MdClose />\r\n </div>{\" \"}\r\n </div>\r\n )}\r\n {isLoading === true ||\r\n (loading && (\r\n <div className=\"w-6 h-6 relative flex items-center justify-center align-middle\">\r\n <SpinnerIcon icon={<FaSpinner />} />\r\n </div>\r\n ))}\r\n\r\n <div className=\"w-6 h-6 relative cursor-pointer \">\r\n <div className=\"absolute inset-0 flex items-center justify-center hover:bg-gray-100 w-6 rounded-full text-lg\">\r\n {isFocused && !disabled && <MdExpandLess />}\r\n {!isFocused && !disabled && <MdExpandMore />}\r\n </div>\r\n </div>\r\n </div>\r\n </div>{\" \"}\r\n <div className=\"w-full relative\">{isFocused && listOfOptions()}</div>\r\n {description && !isFocused && (\r\n <div\r\n className=\"self-stretch text-slate-600 text-sm font-normal leading-tight\"\r\n id={name + \":description\"}\r\n >\r\n {description}\r\n </div>\r\n )}\r\n {errors[name] && (\r\n <div\r\n className=\"HintText self-stretch text-red-600 text-sm font-normal leading-tight\"\r\n id={name + \":error\"}\r\n >\r\n {errors[name]?.message}\r\n </div>\r\n )}\r\n </div>\r\n </>\r\n );\r\n}\r\n"],"names":["fetchUrl"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAeA,SAAwB,YAAY;AAAA,EAClC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,SAAS,CAAC;AAAA,EACV;AAAA,EACA;AAAA,EACA;AAAA,EACA,UAAU;AAAA,EACV;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,GAAsB;;AACpB,QAAM,CAAC,WAAW,YAAY,IAAI,MAAM,SAAS,KAAK;AACtD,QAAM,CAAC,WAAW,YAAY,IAAI,MAAM,SAAS,KAAK;AAChD,QAAA,aAAY,0BAAwB,MAAxB,mBAAwB;AAC1C,QAAM,CAAC,cAAc,eAAe,IAAI,MAAM,SAAS,OAAO;AAExD,QAAA,MAAM,MAAM,OAAO,IAAI;AACvB,QAAA,cAAc,CAAC,MAAW;AAE9B,MAAE,gBAAgB;AAElB,iBAAa,KAAK;AACJ,kBAAA;AAAA,MACZ,GAAG;AAAA,MACH,QAAQ;AAAA,QACN,OAAO;AAAA,QACP;AAAA,MACF;AAAA,IAAA,CACD;AAAA,EAAA;AAGH,QAAM,UAAU,MAAM;AACd,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oBAAC,OAAI,EAAA,WAAU,mEACb,UAAA,oBAAC,aAAY,EAAA,MAAO,oBAAA,WAAA,CAAU,CAAA,EAAI,CAAA,GACpC;AAAA,oCAGH,OAAI,EAAA,WAAU,qCACb,UAAC,qBAAA,OAAA,EAAI,WAAU,gGACZ,UAAA;AAAA,kBAAa,aAAA,CAAC,YAAY,oBAAC,cAAa,CAAA,CAAA;AAAA,kBACxC,CAAC,aAAa,CAAC,gCAAa,cAAa,CAAA,CAAA;AAAA,gBAAA,EAAA,CAC5C,EACF,CAAA;AAAA,cAAA;AAAA,YAAA;AAAA,UACF;AAAA,QAAA,GACF;AAAA,QAAO;AAAA,4BACN,OAAI,EAAA,WAAU,mBAAmB,UAAA,aAAa,iBAAgB;AAAA,QAC9D,eAAe,CAAC,aACf;AAAA,UAAC;AAAA,UAAA;AAAA,YACC,WAAU;AAAA,YACV,IAAI,OAAO;AAAA,YAEV,UAAA;AAAA,UAAA;AAAA,QACH;AAAA,QAED,OAAO,IAAI,KACV;AAAA,UAAC;AAAA,UAAA;AAAA,YACC,WAAU;AAAA,YACV,IAAI,OAAO;AAAA,YAEV,WAAA,YAAO,IAAI,MAAX,mBAAc;AAAA,UAAA;AAAA,QACjB;AAAA,MAAA;AAAA,IAAA;AAAA,EAGN,EAAA,CAAA;AAEJ;"}
1
+ {"version":3,"file":"SelectField.js","sources":["../../../lib/components/form/SelectField.tsx"],"sourcesContent":["import * as React from \"react\";\r\nimport { IFormFieldGlobalProps, IOptionItem } from \"../../types\";\r\nimport { MdCheck, MdClose, MdExpandLess, MdExpandMore } from \"react-icons/md\";\r\nimport { useClickAway } from \"react-use\";\r\nimport { SpinnerIcon, useFederationContext } from \"../../main\";\r\nimport { FaSpinner } from \"react-icons/fa\";\r\n\r\nexport interface ISelectFieldProps extends IFormFieldGlobalProps {\r\n options?: IOptionItem[];\r\n valueKey?: string;\r\n labelKey?: string | ((item: any) => string);\r\n fetchUrl?: string;\r\n loading?: boolean;\r\n}\r\n\r\nexport default function SelectField({\r\n label,\r\n name,\r\n value,\r\n description,\r\n onInputChange,\r\n options,\r\n placeholder,\r\n className,\r\n errors = {},\r\n clearable,\r\n required,\r\n disabled,\r\n rounded = true,\r\n fetchUrl,\r\n valueKey,\r\n labelKey,\r\n loading,\r\n}: ISelectFieldProps) {\r\n const [isFocused, setIsFocused] = React.useState(false);\r\n const [isLoading, setIsLoading] = React.useState(false);\r\n const apiClient = useFederationContext()?.apiClient;\r\n const [localOptions, setLocalOptions] = React.useState(options);\r\n\r\n const ref = React.useRef(null);\r\n const handleClear = (e: any) => {\r\n // value;\r\n e.stopPropagation(); // Add this line\r\n\r\n setIsFocused(false);\r\n onInputChange({\r\n ...e,\r\n target: {\r\n value: \"\",\r\n name: name,\r\n },\r\n });\r\n };\r\n\r\n React.useEffect(() => {\r\n const fetchOptions = async (fetchUrl: string) => {\r\n setIsLoading(true);\r\n const { data } = await apiClient.get(fetchUrl);\r\n\r\n // Check if the first item in the data array is a number to determine the data type\r\n const isArrayOfNumbers = typeof data[0] === \"number\";\r\n const isInPageable = data && data.hasOwnProperty(\"content\");\r\n\r\n // Transform data based on its type\r\n const transformedOptions = (isInPageable ? data.content : data).map(\r\n (item: any) => {\r\n if (isArrayOfNumbers) {\r\n // If it's a number, use the number for both value and label\r\n return { value: item, label: item.toString() };\r\n } else {\r\n // Otherwise, extract using predefined keys or defaults\r\n return {\r\n value: item[valueKey || \"id\"],\r\n label:\r\n labelKey instanceof Function && labelKey !== undefined\r\n ? labelKey(item)\r\n : item[labelKey as string],\r\n };\r\n }\r\n }\r\n );\r\n\r\n setLocalOptions([\r\n { value: null, label: \" \" }, // Add an empty option as the first item\r\n ...transformedOptions,\r\n ]);\r\n setIsLoading(false);\r\n };\r\n\r\n if (fetchUrl) fetchOptions(fetchUrl);\r\n if (options) setLocalOptions(options);\r\n }, [fetchUrl, options, apiClient, valueKey, labelKey]); // ensure valueKey and labelKey are also in the dependency array if they are dynamic\r\n\r\n const handleToggleFocus = () => {\r\n setIsFocused((prev) => !prev);\r\n };\r\n\r\n useClickAway(ref, () => {\r\n setIsFocused(false);\r\n });\r\n\r\n const hangleChange = (option: IOptionItem) => {\r\n const tmp: any = {\r\n target: {\r\n value: option.value,\r\n name: name,\r\n },\r\n };\r\n\r\n onInputChange(tmp);\r\n setIsFocused(false);\r\n };\r\n const currentlySelectedOption = React.useMemo(() => {\r\n if (value === undefined || value === \"\") return null;\r\n return localOptions?.find((option) => option.value == value);\r\n }, [localOptions, value, options]);\r\n\r\n const listOfOptions = () => {\r\n if (!localOptions) return [];\r\n return (\r\n <div\r\n id=\"list\"\r\n className=\"max-h-[390px] min-w-20 w-auto whitespace-nowrap absolute z-[100000] -top-[1px] mt-[4px] bg-white rounded-lg shadow-xl border\r\n border-gray-200 justify-start items-start inline-flex overflow-auto cursor-default\"\r\n >\r\n <div className=\"grow shrink basis-0 py-1 flex-col justify-start items-start inline-flex\">\r\n {localOptions.map((option, index) => {\r\n return (\r\n <div\r\n className=\"group self-stretch px-1.5 py-px justify-start items-center inline-flex hover:bg-gray-50 \"\r\n onClick={() => hangleChange(option)}\r\n key={index}\r\n >\r\n <div className=\"grow shrink basis-0 px-1 py-2 rounded-md flex-col justify-start items-start gap-2 inline-flex\">\r\n <div className=\"self-stretch justify-start items-center gap-2 inline-flex\">\r\n <div className=\"text-gray-900 text-sm font-normal leading-normal\">\r\n {option.label}\r\n </div>\r\n {option.description && (\r\n <div className=\"text-slate-600 sm-base font-normal leading-normal\">\r\n {option.description}\r\n </div>\r\n )}\r\n </div>\r\n </div>\r\n <div className=\"w-5 h-5 relative\">\r\n {option.value === value && value !== \"\" && (\r\n <MdCheck size={22} className=\"text-primary\" />\r\n )}{\" \"}\r\n {option.value !== value && (\r\n <MdCheck\r\n size={22}\r\n className=\"text-transparent group-hover:text-gray-300\"\r\n />\r\n )}\r\n </div>\r\n </div>\r\n );\r\n })}\r\n </div>\r\n </div>\r\n );\r\n };\r\n\r\n return (\r\n <>\r\n <div\r\n className={\r\n \"w-full min-h-30 flex-col justify-start items-start gap-0inline-flex \" +\r\n className\r\n }\r\n id=\"selectField\"\r\n ref={ref}\r\n >\r\n <div className=\"self-stretch flex-col justify-start items-start gap-1.5 flex\">\r\n {label && (\r\n <label\r\n className=\"text-slate-700 text-sm font-medium leading-tight\"\r\n htmlFor={name}\r\n >\r\n {label} {required ? \"*\" : \"\"}\r\n </label>\r\n )}\r\n <div\r\n className={`self-stretch w-full px-3 py-1 bg-white border justify-start items-center gap-0 inline-flex outline-none \r\n ${isFocused ? \"outline-4 outline-indigo-200 outline-offset-0 border-indigo-300 \" : \"\"}\r\n ${\r\n isFocused && errors[name]?.message\r\n ? \"outline-4 outline-red-200 outline-offset-0 border-none\"\r\n : \"\"\r\n } \r\n ${rounded ? \" rounded-lg \" : \" rounded-none \"}\r\n ${!isFocused && errors[name]?.message ? \"border-red-200\" : \"\"} \r\n ${disabled || isLoading ? \"opacity-80 cursor-not-allowed \" : \"\"}\r\n `}\r\n onClick={() =>\r\n !disabled && !isLoading ? handleToggleFocus() : null\r\n }\r\n >\r\n <div className=\"grow shrink basis-0 min-h-[32px] justify-start items-center gap-0 flex whitespace-nowrap w-[calc(100%-40px)] \">\r\n <div\r\n className=\"text-gray-900 text-sm font-normal leading-normal text-ellipsis overflow-hidden w-full\"\r\n id={name}\r\n >\r\n {currentlySelectedOption?.label}\r\n {!currentlySelectedOption?.label && placeholder && (\r\n <span className=\"text-slate-400 font-normal\">\r\n {\" \"}\r\n {placeholder}\r\n </span>\r\n )}\r\n </div>\r\n <div className=\"text-slate-600 text-base font-normal leading-normal\">\r\n {currentlySelectedOption?.description}\r\n </div>\r\n </div>\r\n {clearable &&\r\n value !== \"\" &&\r\n value !== null &&\r\n value !== undefined &&\r\n !disabled && (\r\n <div\r\n className=\"w-6 h-6 relative cursor-pointer \"\r\n id={name + \":clear\"}\r\n onClick={handleClear}\r\n >\r\n <div className=\"absolute inset-0 flex items-center justify-center hover:bg-gray-100 w-6 rounded-full text-lg\">\r\n <MdClose />\r\n </div>{\" \"}\r\n </div>\r\n )}\r\n {isLoading === true ||\r\n (loading && (\r\n <div className=\"w-6 h-6 relative flex items-center justify-center align-middle\">\r\n <SpinnerIcon icon={<FaSpinner />} />\r\n </div>\r\n ))}\r\n\r\n <div className=\"w-6 h-6 relative cursor-pointer \">\r\n <div className=\"absolute inset-0 flex items-center justify-center hover:bg-gray-100 w-6 rounded-full text-lg\">\r\n {isFocused && !disabled && <MdExpandLess />}\r\n {!isFocused && !disabled && <MdExpandMore />}\r\n </div>\r\n </div>\r\n </div>\r\n </div>{\" \"}\r\n <div className=\"w-full relative\">{isFocused && listOfOptions()}</div>\r\n {description && !isFocused && (\r\n <div\r\n className=\"self-stretch text-slate-600 text-sm font-normal leading-tight\"\r\n id={name + \":description\"}\r\n >\r\n {description}\r\n </div>\r\n )}\r\n {errors[name] && (\r\n <div\r\n className=\"HintText self-stretch text-red-600 text-sm font-normal leading-tight\"\r\n id={name + \":error\"}\r\n >\r\n {errors[name]?.message}\r\n </div>\r\n )}\r\n </div>\r\n </>\r\n );\r\n}\r\n"],"names":["fetchUrl"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAeA,SAAwB,YAAY;AAAA,EAClC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,SAAS,CAAC;AAAA,EACV;AAAA,EACA;AAAA,EACA;AAAA,EACA,UAAU;AAAA,EACV;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,GAAsB;;AACpB,QAAM,CAAC,WAAW,YAAY,IAAI,MAAM,SAAS,KAAK;AACtD,QAAM,CAAC,WAAW,YAAY,IAAI,MAAM,SAAS,KAAK;AAChD,QAAA,aAAY,0BAAwB,MAAxB,mBAAwB;AAC1C,QAAM,CAAC,cAAc,eAAe,IAAI,MAAM,SAAS,OAAO;AAExD,QAAA,MAAM,MAAM,OAAO,IAAI;AACvB,QAAA,cAAc,CAAC,MAAW;AAE9B,MAAE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AAA,oBAET,UAAA;AAAA,sBAAA,oBAAC,OAAI,EAAA,WAAU,gGACb,UAAA,oBAAC,UAAQ,CAAA,GACX;AAAA,sBAAO;AAAA,oBAAA;AAAA,kBAAA;AAAA,gBACT;AAAA,gBAEH,cAAc,QACZ,WACC,oBAAC,OAAI,EAAA,WAAU,mEACb,UAAA,oBAAC,aAAY,EAAA,MAAO,oBAAA,WAAA,CAAU,CAAA,EAAI,CAAA,GACpC;AAAA,oCAGH,OAAI,EAAA,WAAU,qCACb,UAAC,qBAAA,OAAA,EAAI,WAAU,gGACZ,UAAA;AAAA,kBAAa,aAAA,CAAC,YAAY,oBAAC,cAAa,CAAA,CAAA;AAAA,kBACxC,CAAC,aAAa,CAAC,gCAAa,cAAa,CAAA,CAAA;AAAA,gBAAA,EAAA,CAC5C,EACF,CAAA;AAAA,cAAA;AAAA,YAAA;AAAA,UACF;AAAA,QAAA,GACF;AAAA,QAAO;AAAA,4BACN,OAAI,EAAA,WAAU,mBAAmB,UAAA,aAAa,iBAAgB;AAAA,QAC9D,eAAe,CAAC,aACf;AAAA,UAAC;AAAA,UAAA;AAAA,YACC,WAAU;AAAA,YACV,IAAI,OAAO;AAAA,YAEV,UAAA;AAAA,UAAA;AAAA,QACH;AAAA,QAED,OAAO,IAAI,KACV;AAAA,UAAC;AAAA,UAAA;AAAA,YACC,WAAU;AAAA,YACV,IAAI,OAAO;AAAA,YAEV,WAAA,YAAO,IAAI,MAAX,mBAAc;AAAA,UAAA;AAAA,QACjB;AAAA,MAAA;AAAA,IAAA;AAAA,EAGN,EAAA,CAAA;AAEJ;"}
@@ -15,8 +15,7 @@ import "../ui/input.js";
15
15
  import "../ui/form.js";
16
16
  import "../ui/radioGroup.js";
17
17
  import "../ui/command.js";
18
- import "../ui/button.js";
19
- import "../ui/popover.js";
18
+ import "../ui/Combobox.js";
20
19
  import "../../Calendar-DWT4e7Th.js";
21
20
  import "../ui/DateTimePicker.js";
22
21
  import "../ui/DatePicker.js";
@@ -1 +1 @@
1
- {"version":3,"file":"ProfileOverview.js","sources":["../../../lib/components/profiles/ProfileOverview.tsx"],"sourcesContent":["import { useEffect, useMemo, useState } from \"react\";\r\nimport SectionTitle from \"../layout/SectionTitle\";\r\nimport {\r\n EApproverRoles,\r\n IProfileApprover,\r\n IStep,\r\n getFullName,\r\n handleErrors,\r\n useFederationContext,\r\n} from \"../../main\";\r\nimport { AxiosResponse } from \"axios\";\r\nimport IconInCircle from \"../layout/IconInCircle\";\r\n\r\ninterface ProfileOverviewProps {\r\n employeeId?: number;\r\n onProfileApproversChange?: (data: IProfileApprover[]) => void;\r\n steps: IStep[];\r\n}\r\n\r\ninterface IApproverRoleGroup {\r\n name: string;\r\n roles: EApproverRoles[];\r\n all: boolean;\r\n parallel: boolean;\r\n stepType: number;\r\n}\r\n\r\nconst approverRoleGroups: IApproverRoleGroup[] = [\r\n {\r\n name: \"Předschvalovatelé\",\r\n roles: [EApproverRoles.predschvalovatel],\r\n all: true,\r\n parallel: true,\r\n stepType: 1,\r\n },\r\n {\r\n name: \"Schvalovatelé\",\r\n roles: [\r\n EApproverRoles.vedouci,\r\n EApproverRoles.zastupce,\r\n EApproverRoles.zastupce9,\r\n EApproverRoles.vyssiSchvalovatel,\r\n EApproverRoles.vyssiSchvalovatelZastupce,\r\n EApproverRoles.vyssiSchvalovatelZastupce9,\r\n ],\r\n all: false,\r\n parallel: true,\r\n stepType: 2,\r\n },\r\n {\r\n name: \"Docházkový vedoucí\",\r\n roles: [EApproverRoles.dochazkovyVedouci],\r\n all: true,\r\n parallel: false,\r\n stepType: 3,\r\n },\r\n];\r\n\r\nexport default function ProfileOverview({\r\n employeeId,\r\n onProfileApproversChange,\r\n steps,\r\n}: ProfileOverviewProps) {\r\n const [profileApprovers, setProfileApprovers] = useState<\r\n Array<IProfileApprover>\r\n >([]);\r\n const context = useFederationContext();\r\n\r\n const currentApprovers = useMemo(() => {\r\n return approverRoleGroups.map((group) => {\r\n const groupApprovers = profileApprovers.filter((approver) =>\r\n group.roles.includes(approver.role)\r\n );\r\n\r\n const groupApprovedSteps = steps.filter(\r\n (step) =>\r\n step.type == group.stepType &&\r\n groupApprovers.some(\r\n (approver) =>\r\n step.employee.employeeId == approver?.approver?.employeeId\r\n )\r\n );\r\n\r\n return {\r\n ...group,\r\n numberOfApprovers: groupApprovers.length,\r\n numberOfApprovedSteps: groupApprovedSteps.length,\r\n isComplete:\r\n (group.all && groupApprovers.length == groupApprovedSteps.length) ||\r\n (!group.all && groupApprovedSteps.length > 0),\r\n };\r\n });\r\n }, [profileApprovers, steps]);\r\n\r\n useEffect(() => {\r\n context.apiClient\r\n .get<IProfileApprover[]>(\r\n \"/timeoff/approve-profile\" + (employeeId ? \"/\" + employeeId : \"\")\r\n )\r\n .then((response: AxiosResponse) => {\r\n setProfileApprovers(response.data);\r\n })\r\n .catch((error) => {\r\n handleErrors(\r\n error,\r\n context.emitter,\r\n \"Nepodařilo se dohledat schvalovací profil pro uživatele \" +\r\n employeeId\r\n );\r\n console.error(\"Error submitting form:\", error);\r\n });\r\n }, [employeeId, context.emitter, context.apiClient]);\r\n\r\n const decisionsTranslations = (decision: string): string | null => {\r\n const translations: { [key: string]: string } = {\r\n approved: \"Schváleno\",\r\n rejected: \"Zamítnuto\",\r\n cancelled: \"Stornováno\",\r\n evided: \"Zaevidováno\",\r\n };\r\n\r\n return translations[decision] || null;\r\n };\r\n // pri nacteni profileApprovers se muze dat vedet parent componente inbfo o aktualnich schvalovatelich\r\n useEffect(() => {\r\n if (onProfileApproversChange) onProfileApproversChange(profileApprovers);\r\n }, [profileApprovers, onProfileApproversChange]);\r\n\r\n const findStep = (\r\n steps: IStep[],\r\n group: IApproverRoleGroup,\r\n row: IProfileApprover\r\n ) => {\r\n return steps.find(\r\n (step) =>\r\n step.type == group.stepType &&\r\n step.employee.employeeId == row.position?.employee?.employeeId\r\n );\r\n };\r\n\r\n return (\r\n <>\r\n <SectionTitle>Postup schvalování</SectionTitle>\r\n <div className=\"flex gap-4\">\r\n {currentApprovers.map((group, index) => (\r\n <div\r\n key={group.name}\r\n className={\r\n \"w-full lg:w-1/3 rounded-lg shadow-xl p-5 border gap-4 flex flex-col \"\r\n }\r\n >\r\n <div className=\"flex justify-between\">\r\n <h3 className=\"text-xl font-bold\">\r\n {group.name} - {index}\r\n </h3>\r\n\r\n <IconInCircle\r\n isComplete={group.isComplete}\r\n title={\r\n group.numberOfApprovedSteps + \" / \" + group.numberOfApprovers\r\n }\r\n isPending={!group.isComplete}\r\n ></IconInCircle>\r\n </div>\r\n {profileApprovers\r\n .filter((it) => group.roles.includes(it.role))\r\n .map((row, index) => (\r\n <div\r\n key={index}\r\n className=\" border rounded-lg p-4 flex justify-between gap-5\"\r\n >\r\n <div>\r\n <h3 className=\"\">\r\n {getFullName(row.position?.employee, true)}\r\n </h3>\r\n <p className=\"text-sm \">{row.roleTxt}</p>\r\n {findStep(steps, group, row) && (\r\n <>\r\n <p className=\"text-sm \"></p>{\" \"}\r\n {findStep(steps, group, row)?.decision && (\r\n <p className=\"text-sm \">\r\n {decisionsTranslations(\r\n findStep(steps, group, row)?.decision || \"\"\r\n )}{\" \"}\r\n (\r\n {new Date(\r\n findStep(steps, group, row)?.date || 0\r\n ).toLocaleString()}\r\n )\r\n </p>\r\n )}\r\n {findStep(steps, group, row)?.comment && (\r\n <p className=\"text-sm \">\r\n <b>Komentář</b>:{\" \"}\r\n {findStep(steps, group, row)?.comment}{\" \"}\r\n </p>\r\n )}\r\n </>\r\n )}\r\n </div>\r\n <IconInCircle\r\n isComplete={findStep(steps, group, row) != null}\r\n isPending={!group.isComplete}\r\n />\r\n </div>\r\n ))}\r\n </div>\r\n ))}\r\n </div>\r\n </>\r\n );\r\n}\r\n"],"names":["steps","index"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AA2BA,MAAM,qBAA2C;AAAA,EAC/C;AAAA,IACE,MAAM;AAAA,IACN,OAAO,CAAC,eAAe,gBAAgB;AAAA,IACvC,KAAK;AAAA,IACL,UAAU;AAAA,IACV,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AS,OAAO,OAAO,GAAG,KAAK;AAAA,sBAC3C,WAAW,CAAC,MAAM;AAAA,oBAAA;AAAA,kBACpB;AAAA,gBAAA;AAAA,cAAA;AAAA,cAnCKA;AAAAA,YAAA;AAAA,WAqCR;AAAA,QAAA;AAAA,MAAA;AAAA,MA3DE,MAAM;AAAA,IA6Dd,CAAA,GACH;AAAA,EACF,EAAA,CAAA;AAEJ;"}
1
+ {"version":3,"file":"ProfileOverview.js","sources":["../../../lib/components/profiles/ProfileOverview.tsx"],"sourcesContent":["import { useEffect, useMemo, useState } from \"react\";\r\nimport SectionTitle from \"../layout/SectionTitle\";\r\nimport {\r\n EApproverRoles,\r\n IProfileApprover,\r\n IStep,\r\n getFullName,\r\n handleErrors,\r\n useFederationContext,\r\n} from \"../../main\";\r\nimport { AxiosResponse } from \"axios\";\r\nimport IconInCircle from \"../layout/IconInCircle\";\r\n\r\ninterface ProfileOverviewProps {\r\n employeeId?: number;\r\n onProfileApproversChange?: (data: IProfileApprover[]) => void;\r\n steps: IStep[];\r\n}\r\n\r\ninterface IApproverRoleGroup {\r\n name: string;\r\n roles: EApproverRoles[];\r\n all: boolean;\r\n parallel: boolean;\r\n stepType: number;\r\n}\r\n\r\nconst approverRoleGroups: IApproverRoleGroup[] = [\r\n {\r\n name: \"Předschvalovatelé\",\r\n roles: [EApproverRoles.predschvalovatel],\r\n all: true,\r\n parallel: true,\r\n stepType: 1,\r\n },\r\n {\r\n name: \"Schvalovatelé\",\r\n roles: [\r\n EApproverRoles.vedouci,\r\n EApproverRoles.zastupce,\r\n EApproverRoles.zastupce9,\r\n EApproverRoles.vyssiSchvalovatel,\r\n EApproverRoles.vyssiSchvalovatelZastupce,\r\n EApproverRoles.vyssiSchvalovatelZastupce9,\r\n ],\r\n all: false,\r\n parallel: true,\r\n stepType: 2,\r\n },\r\n {\r\n name: \"Docházkový vedoucí\",\r\n roles: [EApproverRoles.dochazkovyVedouci],\r\n all: true,\r\n parallel: false,\r\n stepType: 3,\r\n },\r\n];\r\n\r\nexport default function ProfileOverview({\r\n employeeId,\r\n onProfileApproversChange,\r\n steps,\r\n}: ProfileOverviewProps) {\r\n const [profileApprovers, setProfileApprovers] = useState<\r\n Array<IProfileApprover>\r\n >([]);\r\n const context = useFederationContext();\r\n\r\n const currentApprovers = useMemo(() => {\r\n return approverRoleGroups.map((group) => {\r\n const groupApprovers = profileApprovers.filter((approver) =>\r\n group.roles.includes(approver.role)\r\n );\r\n\r\n const groupApprovedSteps = steps.filter(\r\n (step) =>\r\n step.type == group.stepType &&\r\n groupApprovers.some(\r\n (approver) =>\r\n step.employee.employeeId == approver?.approver?.employeeId\r\n )\r\n );\r\n\r\n return {\r\n ...group,\r\n numberOfApprovers: groupApprovers.length,\r\n numberOfApprovedSteps: groupApprovedSteps.length,\r\n isComplete:\r\n (group.all && groupApprovers.length == groupApprovedSteps.length) ||\r\n (!group.all && groupApprovedSteps.length > 0),\r\n };\r\n });\r\n }, [profileApprovers, steps]);\r\n\r\n useEffect(() => {\r\n context.apiClient\r\n .get<IProfileApprover[]>(\r\n \"/timeoff/approve-profile\" + (employeeId ? \"/\" + employeeId : \"\")\r\n )\r\n .then((response: AxiosResponse) => {\r\n setProfileApprovers(response.data);\r\n })\r\n .catch((error) => {\r\n handleErrors(\r\n error,\r\n context.emitter,\r\n \"Nepodařilo se dohledat schvalovací profil pro uživatele \" +\r\n employeeId\r\n );\r\n console.error(\"Error submitting form:\", error);\r\n });\r\n }, [employeeId, context.emitter, context.apiClient]);\r\n\r\n const decisionsTranslations = (decision: string): string | null => {\r\n const translations: { [key: string]: string } = {\r\n approved: \"Schváleno\",\r\n rejected: \"Zamítnuto\",\r\n cancelled: \"Stornováno\",\r\n evided: \"Zaevidováno\",\r\n };\r\n\r\n return translations[decision] || null;\r\n };\r\n // pri nacteni profileApprovers se muze dat vedet parent componente inbfo o aktualnich schvalovatelich\r\n useEffect(() => {\r\n if (onProfileApproversChange) onProfileApproversChange(profileApprovers);\r\n }, [profileApprovers, onProfileApproversChange]);\r\n\r\n const findStep = (\r\n steps: IStep[],\r\n group: IApproverRoleGroup,\r\n row: IProfileApprover\r\n ) => {\r\n return steps.find(\r\n (step) =>\r\n step.type == group.stepType &&\r\n step.employee.employeeId == row.position?.employee?.employeeId\r\n );\r\n };\r\n\r\n return (\r\n <>\r\n <SectionTitle>Postup schvalování</SectionTitle>\r\n <div className=\"flex gap-4\">\r\n {currentApprovers.map((group, index) => (\r\n <div\r\n key={group.name}\r\n className={\r\n \"w-full lg:w-1/3 rounded-lg shadow-xl p-5 border gap-4 flex flex-col \"\r\n }\r\n >\r\n <div className=\"flex justify-between\">\r\n <h3 className=\"text-xl font-bold\">\r\n {group.name} - {index}\r\n </h3>\r\n\r\n <IconInCircle\r\n isComplete={group.isComplete}\r\n title={\r\n group.numberOfApprovedSteps + \" / \" + group.numberOfApprovers\r\n }\r\n isPending={!group.isComplete}\r\n ></IconInCircle>\r\n </div>\r\n {profileApprovers\r\n .filter((it) => group.roles.includes(it.role))\r\n .map((row, index) => (\r\n <div\r\n key={index}\r\n className=\" border rounded-lg p-4 flex justify-between gap-5\"\r\n >\r\n <div>\r\n <h3 className=\"\">\r\n {getFullName(row.position?.employee, true)}\r\n </h3>\r\n <p className=\"text-sm \">{row.roleTxt}</p>\r\n {findStep(steps, group, row) && (\r\n <>\r\n <p className=\"text-sm \"></p>{\" \"}\r\n {findStep(steps, group, row)?.decision && (\r\n <p className=\"text-sm \">\r\n {decisionsTranslations(\r\n findStep(steps, group, row)?.decision || \"\"\r\n )}{\" \"}\r\n (\r\n {new Date(\r\n findStep(steps, group, row)?.date || 0\r\n ).toLocaleString()}\r\n )\r\n </p>\r\n )}\r\n {findStep(steps, group, row)?.comment && (\r\n <p className=\"text-sm \">\r\n <b>Komentář</b>:{\" \"}\r\n {findStep(steps, group, row)?.comment}{\" \"}\r\n </p>\r\n )}\r\n </>\r\n )}\r\n </div>\r\n <IconInCircle\r\n isComplete={findStep(steps, group, row) != null}\r\n isPending={!group.isComplete}\r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wBAAA,oBAAC,OAAE,UAAQ,WAAA,CAAA;AAAA,wBAAI;AAAA,wBAAE;AAAA,yBAChB,cAAS,OAAO,OAAO,GAAG,MAA1B,mBAA6B;AAAA,wBAAS;AAAA,sBAAA,GACzC;AAAA,oBAAA,GAEJ;AAAA,kBAAA,GAEJ;AAAA,kBACA;AAAA,oBAAC;AAAA,oBAAA;AAAA,sBACC,YAAY,SAAS,OAAO,OAAO,GAAG,KAAK;AAAA,sBAC3C,WAAW,CAAC,MAAM;AAAA,oBAAA;AAAA,kBACpB;AAAA,gBAAA;AAAA,cAAA;AAAA,cAnCKA;AAAAA,YAAA;AAAA,WAqCR;AAAA,QAAA;AAAA,MAAA;AAAA,MA3DE,MAAM;AAAA,IA6Dd,CAAA,GACH;AAAA,EACF,EAAA,CAAA;AAEJ;"}
@@ -1 +1,14 @@
1
- export default function ComboboxDemo(): import("react/jsx-runtime").JSX.Element;
1
+ import { IOptionItem } from '../../types';
2
+ import * as React from "react";
3
+ interface ComboboxProps {
4
+ value?: string;
5
+ onChange?: (value: string | undefined) => void;
6
+ className?: string;
7
+ placeholder?: string;
8
+ placeholderSearch?: string;
9
+ clearable?: boolean;
10
+ options?: IOptionItem[];
11
+ allowAddNew?: boolean;
12
+ }
13
+ declare const Combobox: React.ForwardRefExoticComponent<ComboboxProps & React.RefAttributes<HTMLButtonElement>>;
14
+ export default Combobox;
@@ -5,6 +5,7 @@ import { Button } from "./button.js";
5
5
  import { Command, CommandInput, CommandList, CommandEmpty, CommandGroup, CommandItem } from "./command.js";
6
6
  import { Popover, PopoverTrigger, PopoverContent } from "./popover.js";
7
7
  import { c as createLucideIcon } from "../../createLucideIcon-KSoQd4Wi.js";
8
+ import { X } from "../../x-DciOkaU0.js";
8
9
  import { C as Check } from "../../check-B7dJm08z.js";
9
10
  /**
10
11
  * @license lucide-react v0.456.0 - ISC
@@ -26,113 +27,136 @@ const Plus = createLucideIcon("Plus", [
26
27
  ["path", { d: "M5 12h14", key: "1ays0h" }],
27
28
  ["path", { d: "M12 5v14", key: "s699le" }]
28
29
  ]);
29
- const predefinedFrameworks = [
30
- {
31
- value: "next.js",
32
- label: "Next.js"
33
- },
34
- {
35
- value: "sveltekit",
36
- label: "SvelteKit"
37
- },
38
- {
39
- value: "nuxt.js",
40
- label: "Nuxt.js"
41
- },
42
- {
43
- value: "remix",
44
- label: "Remix"
45
- },
46
- {
47
- value: "astro",
48
- label: "Astro"
49
- }
50
- ];
51
- function ComboboxDemo() {
52
- var _a;
53
- const [open, setOpen] = React.useState(false);
54
- const [value, setValue] = React.useState("");
55
- const [inputValue, setInputValue] = React.useState("");
56
- const [frameworks, setFrameworks] = React.useState(predefinedFrameworks);
57
- const handleSelect = (currentValue) => {
58
- if (currentValue === "add-custom") {
59
- if (inputValue && !frameworks.some((f) => f.value === inputValue.toLowerCase())) {
60
- const newFramework = {
61
- value: inputValue.toLowerCase(),
62
- label: inputValue
63
- };
64
- setFrameworks([...frameworks, newFramework]);
65
- setValue(newFramework.value);
66
- }
67
- } else {
68
- setValue(currentValue === value ? "" : currentValue);
69
- }
70
- setOpen(false);
71
- };
72
- return /* @__PURE__ */ jsxs(Popover, { open, onOpenChange: setOpen, children: [
73
- /* @__PURE__ */ jsx(PopoverTrigger, { asChild: true, children: /* @__PURE__ */ jsxs(
74
- Button,
75
- {
76
- variant: "outline",
77
- role: "combobox",
78
- "aria-expanded": open,
79
- className: "w-[200px] justify-between",
80
- children: [
81
- value ? (_a = frameworks.find((framework) => framework.value === value)) == null ? void 0 : _a.label : "Select framework...",
82
- /* @__PURE__ */ jsx(ChevronsUpDown, { className: "ml-2 h-4 w-4 shrink-0 opacity-50" })
83
- ]
30
+ const Combobox = React.forwardRef(
31
+ ({
32
+ value: propValue,
33
+ onChange: propOnChange,
34
+ className,
35
+ placeholder,
36
+ placeholderSearch = "Vyhledejte položku",
37
+ clearable = false,
38
+ options = [],
39
+ allowAddNew = false
40
+ }, ref) => {
41
+ var _a;
42
+ const [open, setOpen] = React.useState(false);
43
+ const [value, setValue] = React.useState(propValue || "");
44
+ const [inputValue, setInputValue] = React.useState("");
45
+ const [frameworks, setFrameworks] = React.useState(options);
46
+ React.useEffect(() => {
47
+ if (propValue !== void 0) {
48
+ setValue(propValue);
84
49
  }
85
- ) }),
86
- /* @__PURE__ */ jsx(PopoverContent, { className: "w-[200px] p-0", children: /* @__PURE__ */ jsxs(Command, { children: [
87
- /* @__PURE__ */ jsx(
88
- CommandInput,
89
- {
90
- placeholder: "Search framework...",
91
- className: "h-9",
92
- value: inputValue,
93
- onValueChange: setInputValue
50
+ }, [propValue]);
51
+ React.useEffect(() => {
52
+ setFrameworks(options);
53
+ }, [options]);
54
+ const handleSelect = (currentValue) => {
55
+ if (currentValue === "add-custom") {
56
+ if (inputValue && !frameworks.some((f) => f.value === inputValue.toLowerCase())) {
57
+ const newFramework = {
58
+ value: inputValue.toLowerCase(),
59
+ label: inputValue
60
+ };
61
+ setFrameworks([...frameworks, newFramework]);
62
+ updateValue(newFramework.value);
94
63
  }
95
- ),
96
- /* @__PURE__ */ jsxs(CommandList, { children: [
97
- /* @__PURE__ */ jsx(CommandEmpty, { children: /* @__PURE__ */ jsxs(
64
+ } else {
65
+ updateValue(currentValue === value ? "" : currentValue);
66
+ }
67
+ setOpen(false);
68
+ };
69
+ const updateValue = (newValue) => {
70
+ setValue(newValue);
71
+ propOnChange == null ? void 0 : propOnChange(newValue || void 0);
72
+ };
73
+ const handleClear = (e) => {
74
+ e.stopPropagation();
75
+ updateValue("");
76
+ setInputValue("");
77
+ setOpen(false);
78
+ };
79
+ return /* @__PURE__ */ jsxs(Popover, { open, onOpenChange: setOpen, children: [
80
+ /* @__PURE__ */ jsxs("div", { className: "relative w-full", children: [
81
+ /* @__PURE__ */ jsx(PopoverTrigger, { asChild: true, children: /* @__PURE__ */ jsxs(
98
82
  Button,
99
83
  {
100
- variant: "ghost",
101
- className: "w-full justify-start",
102
- onClick: () => handleSelect("add-custom"),
84
+ ref,
85
+ type: "button",
86
+ variant: "outline",
87
+ role: "combobox",
88
+ "aria-expanded": open,
89
+ className: cn("w-full justify-between", className),
103
90
  children: [
104
- /* @__PURE__ */ jsx(Plus, { className: "mr-2 h-4 w-4" }),
105
- 'Add "',
106
- inputValue,
107
- '"'
91
+ value ? (_a = frameworks.find((framework) => framework.value === value)) == null ? void 0 : _a.label : /* @__PURE__ */ jsx("div", { className: "text-muted-foreground font-normal", children: placeholder }),
92
+ /* @__PURE__ */ jsx(ChevronsUpDown, { className: "h-4 w-4 shrink-0 opacity-50 ml-6" })
108
93
  ]
109
94
  }
110
95
  ) }),
111
- /* @__PURE__ */ jsx(CommandGroup, { children: frameworks.map((framework) => /* @__PURE__ */ jsxs(
112
- CommandItem,
96
+ clearable && value && /* @__PURE__ */ jsx(
97
+ Button,
113
98
  {
114
- value: framework.value,
115
- onSelect: handleSelect,
116
- children: [
117
- framework.label,
118
- /* @__PURE__ */ jsx(
119
- Check,
120
- {
121
- className: cn(
122
- "ml-auto h-4 w-4",
123
- value === framework.value ? "opacity-100" : "opacity-0"
124
- )
125
- }
126
- )
127
- ]
128
- },
129
- framework.value
130
- )) })
131
- ] })
132
- ] }) })
133
- ] });
134
- }
99
+ type: "button",
100
+ variant: "ghost",
101
+ size: "sm",
102
+ className: "absolute right-6 top-0 h-full px-3 py-2 hover:bg-transparent",
103
+ onClick: handleClear,
104
+ children: /* @__PURE__ */ jsx(X, { className: "h-4 w-4 shrink-0 opacity-50 hover:opacity-100" })
105
+ }
106
+ )
107
+ ] }),
108
+ /* @__PURE__ */ jsx(PopoverContent, { className: "min-w-[200px] w-full p-0", children: /* @__PURE__ */ jsxs(Command, { children: [
109
+ /* @__PURE__ */ jsx(
110
+ CommandInput,
111
+ {
112
+ placeholder: placeholderSearch,
113
+ className: "h-9",
114
+ value: inputValue,
115
+ onValueChange: setInputValue
116
+ }
117
+ ),
118
+ /* @__PURE__ */ jsxs(CommandList, { children: [
119
+ /* @__PURE__ */ jsx(CommandEmpty, { children: allowAddNew && /* @__PURE__ */ jsxs(
120
+ Button,
121
+ {
122
+ variant: "ghost",
123
+ className: "w-full justify-start",
124
+ onClick: () => handleSelect("add-custom"),
125
+ children: [
126
+ /* @__PURE__ */ jsx(Plus, { className: "mr-2 h-4 w-4" }),
127
+ 'Přidat "',
128
+ inputValue,
129
+ '"'
130
+ ]
131
+ }
132
+ ) }),
133
+ /* @__PURE__ */ jsx(CommandGroup, { children: frameworks.map((framework) => /* @__PURE__ */ jsxs(
134
+ CommandItem,
135
+ {
136
+ value: framework.value,
137
+ onSelect: handleSelect,
138
+ children: [
139
+ framework.label,
140
+ /* @__PURE__ */ jsx(
141
+ Check,
142
+ {
143
+ className: cn(
144
+ "ml-auto h-4 w-4",
145
+ value === framework.value ? "opacity-100" : "opacity-0"
146
+ )
147
+ }
148
+ )
149
+ ]
150
+ },
151
+ framework.value
152
+ )) })
153
+ ] })
154
+ ] }) })
155
+ ] });
156
+ }
157
+ );
158
+ Combobox.displayName = "Combobox";
135
159
  export {
136
- ComboboxDemo as default
160
+ Combobox as default
137
161
  };
138
162
  //# sourceMappingURL=Combobox.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Combobox.js","sources":["../../../node_modules/lucide-react/dist/esm/icons/chevrons-up-down.js","../../../node_modules/lucide-react/dist/esm/icons/plus.js","../../../lib/components/ui/Combobox.tsx"],"sourcesContent":["/**\n * @license lucide-react v0.456.0 - ISC\n *\n * This source code is licensed under the ISC license.\n * See the LICENSE file in the root directory of this source tree.\n */\n\nimport createLucideIcon from '../createLucideIcon.js';\n\nconst ChevronsUpDown = createLucideIcon(\"ChevronsUpDown\", [\n [\"path\", { d: \"m7 15 5 5 5-5\", key: \"1hf1tw\" }],\n [\"path\", { d: \"m7 9 5-5 5 5\", key: \"sgt6xg\" }]\n]);\n\nexport { ChevronsUpDown as default };\n//# sourceMappingURL=chevrons-up-down.js.map\n","/**\n * @license lucide-react v0.456.0 - ISC\n *\n * This source code is licensed under the ISC license.\n * See the LICENSE file in the root directory of this source tree.\n */\n\nimport createLucideIcon from '../createLucideIcon.js';\n\nconst Plus = createLucideIcon(\"Plus\", [\n [\"path\", { d: \"M5 12h14\", key: \"1ays0h\" }],\n [\"path\", { d: \"M12 5v14\", key: \"s699le\" }]\n]);\n\nexport { Plus as default };\n//# sourceMappingURL=plus.js.map\n","\"use client\";\r\n\r\nimport * as React from \"react\";\r\nimport { Check, ChevronsUpDown, Plus } from \"lucide-react\";\r\n\r\nimport { cn } from \"../../utils/utils\";\r\nimport { Button } from \"./button\";\r\nimport {\r\n Command,\r\n CommandEmpty,\r\n CommandGroup,\r\n CommandInput,\r\n CommandItem,\r\n CommandList,\r\n} from \"./command\";\r\nimport { Popover, PopoverContent, PopoverTrigger } from \"./popover\";\r\n\r\nconst predefinedFrameworks = [\r\n {\r\n value: \"next.js\",\r\n label: \"Next.js\",\r\n },\r\n {\r\n value: \"sveltekit\",\r\n label: \"SvelteKit\",\r\n },\r\n {\r\n value: \"nuxt.js\",\r\n label: \"Nuxt.js\",\r\n },\r\n {\r\n value: \"remix\",\r\n label: \"Remix\",\r\n },\r\n {\r\n value: \"astro\",\r\n label: \"Astro\",\r\n },\r\n];\r\n\r\nexport default function ComboboxDemo() {\r\n const [open, setOpen] = React.useState(false);\r\n const [value, setValue] = React.useState(\"\");\r\n const [inputValue, setInputValue] = React.useState(\"\");\r\n const [frameworks, setFrameworks] = React.useState(predefinedFrameworks);\r\n\r\n const handleSelect = (currentValue: string) => {\r\n if (currentValue === \"add-custom\") {\r\n if (\r\n inputValue &&\r\n !frameworks.some((f) => f.value === inputValue.toLowerCase())\r\n ) {\r\n const newFramework = {\r\n value: inputValue.toLowerCase(),\r\n label: inputValue,\r\n };\r\n setFrameworks([...frameworks, newFramework]);\r\n setValue(newFramework.value);\r\n }\r\n } else {\r\n setValue(currentValue === value ? \"\" : currentValue);\r\n }\r\n setOpen(false);\r\n };\r\n\r\n return (\r\n <Popover open={open} onOpenChange={setOpen}>\r\n <PopoverTrigger asChild>\r\n <Button\r\n variant=\"outline\"\r\n role=\"combobox\"\r\n aria-expanded={open}\r\n className=\"w-[200px] justify-between\"\r\n >\r\n {value\r\n ? frameworks.find((framework) => framework.value === value)?.label\r\n : \"Select framework...\"}\r\n <ChevronsUpDown className=\"ml-2 h-4 w-4 shrink-0 opacity-50\" />\r\n </Button>\r\n </PopoverTrigger>\r\n <PopoverContent className=\"w-[200px] p-0\">\r\n <Command>\r\n <CommandInput\r\n placeholder=\"Search framework...\"\r\n className=\"h-9\"\r\n value={inputValue}\r\n onValueChange={setInputValue}\r\n />\r\n <CommandList>\r\n <CommandEmpty>\r\n <Button\r\n variant=\"ghost\"\r\n className=\"w-full justify-start\"\r\n onClick={() => handleSelect(\"add-custom\")}\r\n >\r\n <Plus className=\"mr-2 h-4 w-4\" />\r\n Add \"{inputValue}\"\r\n </Button>\r\n </CommandEmpty>\r\n <CommandGroup>\r\n {frameworks.map((framework) => (\r\n <CommandItem\r\n key={framework.value}\r\n value={framework.value}\r\n onSelect={handleSelect}\r\n >\r\n {framework.label}\r\n <Check\r\n className={cn(\r\n \"ml-auto h-4 w-4\",\r\n value === framework.value ? \"opacity-100\" : \"opacity-0\"\r\n )}\r\n />\r\n </CommandItem>\r\n ))}\r\n </CommandGroup>\r\n </CommandList>\r\n </Command>\r\n </PopoverContent>\r\n </Popover>\r\n );\r\n}\r\n"],"names":[],"mappings":";;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AASA,MAAM,iBAAiB,iBAAiB,kBAAkB;AAAA,EACxD,CAAC,QAAQ,EAAE,GAAG,iBAAiB,KAAK,SAAQ,CAAE;AAAA,EAC9C,CAAC,QAAQ,EAAE,GAAG,gBAAgB,KAAK,SAAQ,CAAE;AAC/C,CAAC;ACZD;AAAA;AAAA;AAAA;AAAA;AAAA;AASA,MAAM,OAAO,iBAAiB,QAAQ;AAAA,EACpC,CAAC,QAAQ,EAAE,GAAG,YAAY,KAAK,SAAQ,CAAE;AAAA,EACzC,CAAC,QAAQ,EAAE,GAAG,YA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K,CAAC,cAAc,UAAU,UAAU,KAAK,MAAxD,mBAA2D,QAC3D;AAAA,UACJ,oBAAC,gBAAe,EAAA,WAAU,mCAAmC,CAAA;AAAA,QAAA;AAAA,MAAA;AAAA,IAAA,GAEjE;AAAA,IACC,oBAAA,gBAAA,EAAe,WAAU,iBACxB,+BAAC,SACC,EAAA,UAAA;AAAA,MAAA;AAAA,QAAC;AAAA,QAAA;AAAA,UACC,aAAY;AAAA,UACZ,WAAU;AAAA,UACV,OAAO;AAAA,UACP,eAAe;AAAA,QAAA;AAAA,MACjB;AAAA,2BACC,aACC,EAAA,UAAA;AAAA,QAAA,oBAAC,cACC,EAAA,UAAA;AAAA,UAAC;AAAA,UAAA;AAAA,YACC,SAAQ;AAAA,YACR,WAAU;AAAA,YACV,SAAS,MAAM,aAAa,YAAY;AAAA,YAExC,UAAA;AAAA,cAAC,oBAAA,MAAA,EAAK,WAAU,eAAe,CAAA;AAAA,cAAE;AAAA,cAC3B;AAAA,cAAW;AAAA,YAAA;AAAA,UAAA;AAAA,QAAA,GAErB;AAAA,QACC,oBAAA,cAAA,EACE,UAAW,WAAA,IAAI,CAAC,cACf;AAAA,UAAC;AAAA,UAAA;AAAA,YAEC,OAAO,UAAU;AAAA,YACjB,UAAU;AAAA,YAET,UAAA;AAAA,cAAU,UAAA;AAAA,cACX;AAAA,gBAAC;AAAA,gBAAA;AAAA,kBACC,WAAW;AAAA,oBACT;AAAA,oBACA,UAAU,UAAU,QAAQ,gBAAgB;AAAA,kBAC9C;AAAA,gBAAA;AAAA,cACF;AAAA,YAAA;AAAA,UAAA;AAAA,UAVK,UAAU;AAAA,QAYlB,CAAA,GACH;AAAA,MAAA,GACF;AAAA,IAAA,EAAA,CACF,EACF,CAAA;AAAA,EACF,EAAA,CAAA;AAEJ;","x_google_ignoreList":[0,1]}
1
+ {"version":3,"file":"Combobox.js","sources":["../../../node_modules/lucide-react/dist/esm/icons/chevrons-up-down.js","../../../node_modules/lucide-react/dist/esm/icons/plus.js","../../../lib/components/ui/Combobox.tsx"],"sourcesContent":["/**\n * @license lucide-react v0.456.0 - ISC\n *\n * This source code is licensed under the ISC license.\n * See the LICENSE file in the root directory of this source tree.\n */\n\nimport createLucideIcon from '../createLucideIcon.js';\n\nconst ChevronsUpDown = createLucideIcon(\"ChevronsUpDown\", [\n [\"path\", { d: \"m7 15 5 5 5-5\", key: \"1hf1tw\" }],\n [\"path\", { d: \"m7 9 5-5 5 5\", key: \"sgt6xg\" }]\n]);\n\nexport { ChevronsUpDown as default };\n//# sourceMappingURL=chevrons-up-down.js.map\n","/**\n * @license lucide-react v0.456.0 - ISC\n *\n * This source code is licensed under the ISC license.\n * See the LICENSE file in the root directory of this source tree.\n */\n\nimport createLucideIcon from '../createLucideIcon.js';\n\nconst Plus = createLucideIcon(\"Plus\", [\n [\"path\", { d: \"M5 12h14\", key: \"1ays0h\" }],\n [\"path\", { d: \"M12 5v14\", key: \"s699le\" }]\n]);\n\nexport { Plus as default };\n//# sourceMappingURL=plus.js.map\n","\"use client\";\r\n\r\nimport * as React from \"react\";\r\nimport { Check, ChevronsUpDown, Plus, X } from \"lucide-react\";\r\n\r\nimport { cn } from \"../../utils/utils\";\r\nimport { Button } from \"./button\";\r\nimport {\r\n Command,\r\n CommandEmpty,\r\n CommandGroup,\r\n CommandInput,\r\n CommandItem,\r\n CommandList,\r\n} from \"./command\";\r\nimport { Popover, PopoverContent, PopoverTrigger } from \"./popover\";\r\nimport { IOptionItem } from \"../../types\";\r\n\r\ninterface ComboboxProps {\r\n value?: string;\r\n onChange?: (value: string | undefined) => void;\r\n className?: string;\r\n placeholder?: string;\r\n placeholderSearch?: string;\r\n clearable?: boolean;\r\n options?: IOptionItem[];\r\n allowAddNew?: boolean;\r\n}\r\n\r\nconst Combobox = React.forwardRef<HTMLButtonElement, ComboboxProps>(\r\n (\r\n {\r\n value: propValue,\r\n onChange: propOnChange,\r\n className,\r\n placeholder,\r\n placeholderSearch = \"Vyhledejte položku\",\r\n clearable = false,\r\n options = [],\r\n allowAddNew = false,\r\n },\r\n ref\r\n ) => {\r\n const [open, setOpen] = React.useState(false);\r\n const [value, setValue] = React.useState(propValue || \"\");\r\n const [inputValue, setInputValue] = React.useState(\"\");\r\n const [frameworks, setFrameworks] = React.useState<IOptionItem[]>(options);\r\n\r\n React.useEffect(() => {\r\n if (propValue !== undefined) {\r\n setValue(propValue);\r\n }\r\n }, [propValue]);\r\n\r\n React.useEffect(() => {\r\n setFrameworks(options);\r\n }, [options]);\r\n\r\n const handleSelect = (currentValue: string) => {\r\n if (currentValue === \"add-custom\") {\r\n if (\r\n inputValue &&\r\n !frameworks.some((f) => f.value === inputValue.toLowerCase())\r\n ) {\r\n const newFramework = {\r\n value: inputValue.toLowerCase(),\r\n label: inputValue,\r\n };\r\n\r\n setFrameworks([...frameworks, newFramework]);\r\n updateValue(newFramework.value);\r\n }\r\n } else {\r\n updateValue(currentValue === value ? \"\" : currentValue);\r\n }\r\n setOpen(false);\r\n };\r\n\r\n const updateValue = (newValue: string) => {\r\n setValue(newValue);\r\n propOnChange?.(newValue || undefined);\r\n };\r\n\r\n const handleClear = (e: React.MouseEvent) => {\r\n e.stopPropagation();\r\n updateValue(\"\");\r\n setInputValue(\"\");\r\n setOpen(false);\r\n };\r\n\r\n value;\r\n return (\r\n <Popover open={open} onOpenChange={setOpen}>\r\n <div className=\"relative w-full\">\r\n <PopoverTrigger asChild>\r\n <Button\r\n ref={ref}\r\n type=\"button\"\r\n variant=\"outline\"\r\n role=\"combobox\"\r\n aria-expanded={open}\r\n className={cn(\"w-full justify-between\", className)}\r\n >\r\n {value ? (\r\n frameworks.find((framework) => framework.value === value)?.label\r\n ) : (\r\n <div className=\"text-muted-foreground font-normal\">\r\n {placeholder}\r\n </div>\r\n )}\r\n <ChevronsUpDown className=\"h-4 w-4 shrink-0 opacity-50 ml-6\" />\r\n </Button>\r\n </PopoverTrigger>\r\n {clearable && value && (\r\n <Button\r\n type=\"button\"\r\n variant=\"ghost\"\r\n size=\"sm\"\r\n className=\"absolute right-6 top-0 h-full px-3 py-2 hover:bg-transparent\"\r\n onClick={handleClear}\r\n >\r\n <X className=\"h-4 w-4 shrink-0 opacity-50 hover:opacity-100\" />\r\n </Button>\r\n )}\r\n </div>\r\n <PopoverContent className=\"min-w-[200px] w-full p-0\">\r\n <Command>\r\n <CommandInput\r\n placeholder={placeholderSearch}\r\n className=\"h-9\"\r\n value={inputValue}\r\n onValueChange={setInputValue}\r\n />\r\n <CommandList>\r\n <CommandEmpty>\r\n {allowAddNew && (\r\n <Button\r\n variant=\"ghost\"\r\n className=\"w-full justify-start\"\r\n onClick={() => handleSelect(\"add-custom\")}\r\n >\r\n <Plus className=\"mr-2 h-4 w-4\" />\r\n Přidat \"{inputValue}\"\r\n </Button>\r\n )}\r\n </CommandEmpty>\r\n\r\n <CommandGroup>\r\n {frameworks.map((framework) => (\r\n <CommandItem\r\n key={framework.value}\r\n value={framework.value as string}\r\n onSelect={handleSelect}\r\n >\r\n {framework.label}\r\n <Check\r\n className={cn(\r\n \"ml-auto h-4 w-4\",\r\n value === framework.value ? \"opacity-100\" : \"opacity-0\"\r\n )}\r\n />\r\n </CommandItem>\r\n ))}\r\n </CommandGroup>\r\n </CommandList>\r\n </Command>\r\n </PopoverContent>\r\n </Popover>\r\n );\r\n }\r\n);\r\n\r\nCombobox.displayName = \"Combobox\";\r\n\r\nexport default Combobox;\r\n"],"names":[],"mappings":";;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AASA,MAAM,iBAAiB,iBAAiB,kBAAkB;AAAA,EACxD,CAAC,QAAQ,EAAE,GAAG,iBAAiB,KAAK,SAAQ,CAAE;AAAA,EAC9C,CAAC,QAAQ,EAAE,GAAG,gBAAgB,KAAK,SAAQ,CAAE;AAC/C,CAAC;ACZD;AAAA;AAAA;AAAA;AAAA;AAAA;AASA,MAAM,OAAO,iBAAiB,QAAQ;AAAA,EACpC,CAAC,QAAQ,EAAE,GAAG,YAAY,KAAK,SAAQ,CAAE;AAA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MAAA,EAAK,WAAU,eAAe,CAAA;AAAA,gBAAE;AAAA,gBACxB;AAAA,gBAAW;AAAA,cAAA;AAAA,YAAA;AAAA,UAAA,GAG1B;AAAA,UAEC,oBAAA,cAAA,EACE,UAAW,WAAA,IAAI,CAAC,cACf;AAAA,YAAC;AAAA,YAAA;AAAA,cAEC,OAAO,UAAU;AAAA,cACjB,UAAU;AAAA,cAET,UAAA;AAAA,gBAAU,UAAA;AAAA,gBACX;AAAA,kBAAC;AAAA,kBAAA;AAAA,oBACC,WAAW;AAAA,sBACT;AAAA,sBACA,UAAU,UAAU,QAAQ,gBAAgB;AAAA,oBAC9C;AAAA,kBAAA;AAAA,gBACF;AAAA,cAAA;AAAA,YAAA;AAAA,YAVK,UAAU;AAAA,UAYlB,CAAA,GACH;AAAA,QAAA,GACF;AAAA,MAAA,EAAA,CACF,EACF,CAAA;AAAA,IACF,EAAA,CAAA;AAAA,EAEJ;AACF;AAEA,SAAS,cAAc;","x_google_ignoreList":[0,1]}
@@ -575,7 +575,7 @@ const CommandEmpty = React.forwardRef((props, ref) => /* @__PURE__ */ jsx(
575
575
  Ve.Empty,
576
576
  {
577
577
  ref,
578
- className: "py-6 text-center text-sm",
578
+ className: "py-0 text-center text-sm",
579
579
  ...props
580
580
  }
581
581
  ));