@addsign/moje-agenda-shared-lib 2.0.3 → 2.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Dialog-BtXGfOmv.js +423 -0
- package/dist/Dialog-BtXGfOmv.js.map +1 -0
- package/dist/assets/style.css +18 -0
- package/dist/assets/tailwind.css +25 -24
- package/dist/components/datatable/DataTable.js +3 -1
- package/dist/components/datatable/DataTable.js.map +1 -1
- package/dist/components/datatable/DataTableServer.js +3 -1
- package/dist/components/datatable/DataTableServer.js.map +1 -1
- package/dist/components/form/AutocompleteSearchBar.js +3 -1
- package/dist/components/form/AutocompleteSearchBar.js.map +1 -1
- package/dist/components/form/AutocompleteSearchBarServer.js +3 -1
- package/dist/components/form/AutocompleteSearchBarServer.js.map +1 -1
- package/dist/components/form/FileInput.js +4 -2
- package/dist/components/form/FileInput.js.map +1 -1
- package/dist/components/form/FileInputMultiple.js +4 -2
- package/dist/components/form/FileInputMultiple.js.map +1 -1
- package/dist/components/form/FormField.js +3 -1
- package/dist/components/form/FormField.js.map +1 -1
- package/dist/components/form/PositionsSelectorSingle.js +3 -1
- package/dist/components/form/PositionsSelectorSingle.js.map +1 -1
- package/dist/components/form/SelectField.js +3 -1
- package/dist/components/form/SelectField.js.map +1 -1
- package/dist/components/profiles/ProfileOverview.js +3 -1
- package/dist/components/profiles/ProfileOverview.js.map +1 -1
- package/dist/components/ui/Combobox.js +18 -7
- package/dist/components/ui/Combobox.js.map +1 -1
- package/dist/components/ui/DateTimePicker.d.ts +1 -1
- package/dist/components/ui/DateTimePicker.js +25 -13
- package/dist/components/ui/DateTimePicker.js.map +1 -1
- package/dist/components/ui/Dialog.js +1 -1
- package/dist/components/ui/ScrollArea.js +2 -2
- package/dist/components/ui/checkbox.d.ts +4 -0
- package/dist/components/ui/checkbox.js +180 -0
- package/dist/components/ui/checkbox.js.map +1 -0
- package/dist/components/ui/command.js +2 -2
- package/dist/components/ui/datepicker.js +11 -0
- package/dist/components/ui/datepicker.js.map +1 -1
- package/dist/components/ui/input.js +1 -0
- package/dist/components/ui/input.js.map +1 -1
- package/dist/components/ui/popover.js +7 -6
- package/dist/components/ui/popover.js.map +1 -1
- package/dist/components/ui/radioGroup.js +7 -5
- package/dist/components/ui/radioGroup.js.map +1 -1
- package/dist/components/ui/select.js +8 -6
- package/dist/components/ui/select.js.map +1 -1
- package/dist/components/ui/textarea.d.ts +3 -0
- package/dist/components/ui/textarea.js +21 -0
- package/dist/components/ui/textarea.js.map +1 -0
- package/dist/components/ui/tooltip.js +6 -5
- package/dist/components/ui/tooltip.js.map +1 -1
- package/dist/index-BLOUFOiQ.js +2266 -0
- package/dist/index-BLOUFOiQ.js.map +1 -0
- package/dist/index-CA2QNu6z.js +131 -0
- package/dist/index-CA2QNu6z.js.map +1 -0
- package/dist/index-CAxGI0Uw.js +230 -0
- package/dist/index-CAxGI0Uw.js.map +1 -0
- package/dist/index-CDCkSjVs.js +110 -0
- package/dist/index-CDCkSjVs.js.map +1 -0
- package/dist/index-CDlDRp01.js +1173 -0
- package/dist/index-CDlDRp01.js.map +1 -0
- package/dist/index-CshadhlS.js +15 -0
- package/dist/index-CshadhlS.js.map +1 -0
- package/dist/index-DFSwSCB0.js +47 -0
- package/dist/index-DFSwSCB0.js.map +1 -0
- package/dist/index-Deoi9R3y.js +15 -0
- package/dist/index-Deoi9R3y.js.map +1 -0
- package/dist/index-DjvLSytK.js +2203 -0
- package/dist/index-DjvLSytK.js.map +1 -0
- package/dist/index-E5yk6fTE.js +129 -0
- package/dist/index-E5yk6fTE.js.map +1 -0
- package/dist/index-pLFWXSOv.js +40 -0
- package/dist/index-pLFWXSOv.js.map +1 -0
- package/dist/main.d.ts +2 -0
- package/dist/main.js +5 -1
- package/dist/main.js.map +1 -1
- package/lib/components/ui/Combobox.tsx +19 -7
- package/lib/components/ui/DatePicker.tsx +11 -0
- package/lib/components/ui/DateTimePicker.tsx +30 -16
- package/lib/components/ui/checkbox.tsx +30 -0
- package/lib/components/ui/input.tsx +1 -0
- package/lib/components/ui/textarea.tsx +22 -0
- package/lib/main.ts +2 -0
- package/package.json +4 -2
- package/tailwind.config.js +97 -0
|
@@ -8,7 +8,7 @@ import "../../index.esm-ifS8v9eQ.js";
|
|
|
8
8
|
import "../../jspdf.plugin.autotable-7hp3hM-a.js";
|
|
9
9
|
import "../../contexts/FederationContext.js";
|
|
10
10
|
import { useFederationContext } from "../../contexts/useFederationContext.js";
|
|
11
|
-
import "../../Dialog-
|
|
11
|
+
import "../../Dialog-BtXGfOmv.js";
|
|
12
12
|
import "../ui/ScrollArea.js";
|
|
13
13
|
import "../ui/input.js";
|
|
14
14
|
import "../ui/form.js";
|
|
@@ -18,6 +18,8 @@ import "../ui/Combobox.js";
|
|
|
18
18
|
import "../ui/select.js";
|
|
19
19
|
import "../ui/tooltip.js";
|
|
20
20
|
import "../ui/separator.js";
|
|
21
|
+
import "../ui/textarea.js";
|
|
22
|
+
import "../ui/checkbox.js";
|
|
21
23
|
import "../ui/button.js";
|
|
22
24
|
import "../../Calendar-DWT4e7Th.js";
|
|
23
25
|
import "../ui/DateTimePicker.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,QA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,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;"}
|
|
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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,QACV,UAAU,UACV,CAAC,YACC;AAAA,kBAAC;AAAA,kBAAA;AAAA,oBACC,WAAU;AAAA,oBACV,IAAI,OAAO;AAAA,oBACX,SAAS;AAAA,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;"}
|
|
@@ -9,7 +9,7 @@ import { useFederationContext } from "../../contexts/useFederationContext.js";
|
|
|
9
9
|
import { getFullName } from "../../utils/getFullName.js";
|
|
10
10
|
import { handleErrors } from "../../utils/handleErrors.js";
|
|
11
11
|
import { EApproverRoles } from "../../types.js";
|
|
12
|
-
import "../../Dialog-
|
|
12
|
+
import "../../Dialog-BtXGfOmv.js";
|
|
13
13
|
import "../ui/ScrollArea.js";
|
|
14
14
|
import "../ui/input.js";
|
|
15
15
|
import "../ui/form.js";
|
|
@@ -19,6 +19,8 @@ import "../ui/Combobox.js";
|
|
|
19
19
|
import "../ui/select.js";
|
|
20
20
|
import "../ui/tooltip.js";
|
|
21
21
|
import "../ui/separator.js";
|
|
22
|
+
import "../ui/textarea.js";
|
|
23
|
+
import "../ui/checkbox.js";
|
|
22
24
|
import "../ui/button.js";
|
|
23
25
|
import "../../Calendar-DWT4e7Th.js";
|
|
24
26
|
import "../ui/DateTimePicker.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,UAAU;AAAA,EACZ;AAAA,EACA;AAAA,IACE,MAAM;AAAA,IACN,OAAO;AAAA,MACL,eAAe;AAAA,MACf,eAAe;AAAA,MACf,eAAe;AAAA,MACf,eAAe;AAAA,MACf,eAAe;AAAA,MACf,eAAe;AAAA,IACjB;AAAA,IACA,KAAK;AAAA,IACL,UAAU;AAAA,IACV,UAAU;AAAA,EACZ;AAAA,EACA;AAAA,IACE,MAAM;AAAA,IACN,OAAO,CAAC,eAAe,iBAAiB;AAAA,IACxC,KAAK;AAAA,IACL,UAAU;AAAA,IACV,UAAU;AAAA,EACZ;AACF;AAEA,SAAwB,gBAAgB;AAAA,EACtC;AAAA,EACA;AAAA,EACA;AACF,GAAyB;AACvB,QAAM,CAAC,kBAAkB,mBAAmB,IAAI,SAE9C,CAAE,CAAA;AACJ,QAAM,UAAU;AAEV,QAAA,mBAAmB,QAAQ,MAAM;AAC9B,WAAA,mBAAmB,IAAI,CAAC,UAAU;AACvC,YAAM,iBAAiB,iBAAiB;AAAA,QAAO,CAAC,aAC9C,MAAM,MAAM,SAAS,SAAS,IAAI;AAAA,MAAA;AAGpC,YAAM,qBAAqB,MAAM;AAAA,QAC/B,CAAC,SACC,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AA,wBAAI;AAAA,wBAEN,IAAI;AAAA,4BACH,cAAS,OAAO,OAAO,GAAG,MAA1B,mBAA6B,SAAQ;AAAA,0BACrC,eAAe;AAAA,wBAAE;AAAA,sBAAA,GAErB;AAAA,wBAED,cAAS,OAAO,OAAO,GAAG,MAA1B,mBAA6B,YAC5B,qBAAC,KAAE,EAAA,WAAU,YACX,UAAA;AAAA,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
|
+
{"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,UAAU;AAAA,EACZ;AAAA,EACA;AAAA,IACE,MAAM;AAAA,IACN,OAAO;AAAA,MACL,eAAe;AAAA,MACf,eAAe;AAAA,MACf,eAAe;AAAA,MACf,eAAe;AAAA,MACf,eAAe;AAAA,MACf,eAAe;AAAA,IACjB;AAAA,IACA,KAAK;AAAA,IACL,UAAU;AAAA,IACV,UAAU;AAAA,EACZ;AAAA,EACA;AAAA,IACE,MAAM;AAAA,IACN,OAAO,CAAC,eAAe,iBAAiB;AAAA,IACxC,KAAK;AAAA,IACL,UAAU;AAAA,IACV,UAAU;AAAA,EACZ;AACF;AAEA,SAAwB,gBAAgB;AAAA,EACtC;AAAA,EACA;AAAA,EACA;AACF,GAAyB;AACvB,QAAM,CAAC,kBAAkB,mBAAmB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AA;AAAA,sBAAC,oBAAA,KAAA,EAAE,WAAU,WAAW,CAAA;AAAA,sBAAK;AAAA,wBAC5B,cAAS,OAAO,OAAO,GAAG,MAA1B,mBAA6B,aAC5B,qBAAC,KAAE,EAAA,WAAU,YACV,UAAA;AAAA,wBAAA;AAAA,4BACC,cAAS,OAAO,OAAO,GAAG,MAA1B,mBAA6B,aAAY;AAAA,wBAC3C;AAAA,wBAAG;AAAA,wBAAI;AAAA,wBAEN,IAAI;AAAA,4BACH,cAAS,OAAO,OAAO,GAAG,MAA1B,mBAA6B,SAAQ;AAAA,0BACrC,eAAe;AAAA,wBAAE;AAAA,sBAAA,GAErB;AAAA,wBAED,cAAS,OAAO,OAAO,GAAG,MAA1B,mBAA6B,YAC5B,qBAAC,KAAE,EAAA,WAAU,YACX,UAAA;AAAA,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;"}
|
|
@@ -35,22 +35,32 @@ const Combobox = React.forwardRef(
|
|
|
35
35
|
placeholder,
|
|
36
36
|
placeholderSearch = "Vyhledejte položku",
|
|
37
37
|
clearable = false,
|
|
38
|
-
options = [],
|
|
38
|
+
options: propOptions = [],
|
|
39
39
|
allowAddNew = false
|
|
40
40
|
}, ref) => {
|
|
41
41
|
var _a;
|
|
42
42
|
const [open, setOpen] = React.useState(false);
|
|
43
43
|
const [value, setValue] = React.useState(propValue || "");
|
|
44
44
|
const [inputValue, setInputValue] = React.useState("");
|
|
45
|
-
const [frameworks, setFrameworks] = React.useState(
|
|
45
|
+
const [frameworks, setFrameworks] = React.useState(propOptions);
|
|
46
46
|
React.useEffect(() => {
|
|
47
|
+
console.log(
|
|
48
|
+
"%clibcomponentsCombobox.tsx:51 propValue",
|
|
49
|
+
"color: #007acc;",
|
|
50
|
+
propValue
|
|
51
|
+
);
|
|
47
52
|
if (propValue !== void 0) {
|
|
48
53
|
setValue(propValue);
|
|
49
54
|
}
|
|
50
55
|
}, [propValue]);
|
|
51
56
|
React.useEffect(() => {
|
|
52
|
-
|
|
53
|
-
|
|
57
|
+
console.log(
|
|
58
|
+
"%clibcomponentsCombobox.tsx:60 setFrameworks",
|
|
59
|
+
"color: #007acc;",
|
|
60
|
+
setFrameworks
|
|
61
|
+
);
|
|
62
|
+
setFrameworks(propOptions);
|
|
63
|
+
}, [propOptions]);
|
|
54
64
|
const handleSelect = (currentValue) => {
|
|
55
65
|
if (currentValue === "add-custom") {
|
|
56
66
|
if (inputValue && !frameworks.some((f) => f.value === inputValue.toLowerCase())) {
|
|
@@ -105,7 +115,7 @@ const Combobox = React.forwardRef(
|
|
|
105
115
|
}
|
|
106
116
|
)
|
|
107
117
|
] }),
|
|
108
|
-
/* @__PURE__ */ jsx(PopoverContent, { className: "min-w-[200px] w-
|
|
118
|
+
/* @__PURE__ */ jsx(PopoverContent, { className: "min-w-[200px] w-[var(--radix-popover-trigger-width)] p-0", children: /* @__PURE__ */ jsxs(Command, { children: [
|
|
109
119
|
/* @__PURE__ */ jsx(
|
|
110
120
|
CommandInput,
|
|
111
121
|
{
|
|
@@ -119,6 +129,7 @@ const Combobox = React.forwardRef(
|
|
|
119
129
|
/* @__PURE__ */ jsx(CommandEmpty, { children: allowAddNew && /* @__PURE__ */ jsxs(
|
|
120
130
|
Button,
|
|
121
131
|
{
|
|
132
|
+
type: "button",
|
|
122
133
|
variant: "ghost",
|
|
123
134
|
className: "w-full justify-start",
|
|
124
135
|
onClick: () => handleSelect("add-custom"),
|
|
@@ -133,8 +144,8 @@ const Combobox = React.forwardRef(
|
|
|
133
144
|
/* @__PURE__ */ jsx(CommandGroup, { children: frameworks.map((framework) => /* @__PURE__ */ jsxs(
|
|
134
145
|
CommandItem,
|
|
135
146
|
{
|
|
136
|
-
value: framework.
|
|
137
|
-
onSelect: handleSelect,
|
|
147
|
+
value: framework.label,
|
|
148
|
+
onSelect: () => handleSelect(framework.value),
|
|
138
149
|
children: [
|
|
139
150
|
framework.label,
|
|
140
151
|
/* @__PURE__ */ jsx(
|
|
@@ -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, 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 <span className=\"flex-1 text-left truncate mr-2 font-normal\">\r\n {value ? (\r\n frameworks.find((framework) => framework.value === value)\r\n ?.label\r\n ) : (\r\n <span className=\"text-muted-foreground font-normal\">\r\n {placeholder}\r\n </span>\r\n )}\r\n </span>\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-1 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;AAAA,EACzC,CAAC,QAAQ,EAAE,GAAG,YAAY,KAAK,SAAQ,CAAE;AAC3C,CAAC;ACiBD,MAAM,WAAW,MAAM;AAAA,EACrB,CACE;AAAA,IACE,OAAO;AAAA,IACP,UAAU;AAAA,IACV;AAAA,IACA;AAAA,IACA,oBAAoB;AAAA,IACpB,YAAY;AAAA,IACZ,UAAU,CAAC;AAAA,IACX,cAAc;AAAA,KAEhB,QACG;;AACH,UAAM,CAAC,MAAM,OAAO,IAAI,MAAM,SAAS,KAAK;AAC5C,UAAM,CAAC,OAAO,QAAQ,IAAI,MAAM,SAAS,aAAa,EAAE;AACxD,UAAM,CAAC,YAAY,aAAa,IAAI,MAAM,SAAS,EAAE;AACrD,UAAM,CAAC,YAAY,aAAa,IAAI,MAAM,SAAwB,OAAO;AAEzE,UAAM,UAAU,MAAM;AACpB,UAAI,cAAc,QAAW;AAC3B,iBAAS,SAAS;AAAA,MACpB;AAAA,IAAA,GACC,CAAC,SAAS,CA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AAEA,SAAS,cAAc;","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: propOptions = [],\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] =\r\n React.useState<IOptionItem[]>(propOptions);\r\n\r\n React.useEffect(() => {\r\n console.log(\r\n \"%clibcomponentsCombobox.tsx:51 propValue\",\r\n \"color: #007acc;\",\r\n propValue\r\n );\r\n if (propValue !== undefined) {\r\n setValue(propValue);\r\n }\r\n }, [propValue]);\r\n\r\n React.useEffect(() => {\r\n console.log(\r\n \"%clibcomponentsCombobox.tsx:60 setFrameworks\",\r\n \"color: #007acc;\",\r\n setFrameworks\r\n );\r\n setFrameworks(propOptions);\r\n }, [propOptions]);\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 <span className=\"flex-1 text-left truncate mr-2 font-normal\">\r\n {value ? (\r\n frameworks.find((framework) => framework.value === value)\r\n ?.label\r\n ) : (\r\n <span className=\"text-muted-foreground font-normal\">\r\n {placeholder}\r\n </span>\r\n )}\r\n </span>\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-1 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-[var(--radix-popover-trigger-width)] 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 type=\"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.label as string}\r\n onSelect={() => handleSelect(framework.value as string)}\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\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ignoreList":[0,1]}
|
|
@@ -64,35 +64,46 @@ function set(date, values) {
|
|
|
64
64
|
const DATE_FORMAT = "dd.MM.yyyy HH:mm";
|
|
65
65
|
const DateTimePicker = forwardRef(
|
|
66
66
|
({ value, onChange, className, clearable = true, placeholder, ...props }, ref) => {
|
|
67
|
-
const [dateTime, setDateTime] = React__default.useState(value);
|
|
67
|
+
const [dateTime, setDateTime] = React__default.useState(value || null);
|
|
68
68
|
const [inputValue, setInputValue] = React__default.useState("");
|
|
69
69
|
useEffect(() => {
|
|
70
70
|
if (value) {
|
|
71
71
|
setDateTime(value);
|
|
72
72
|
setInputValue(format(value, DATE_FORMAT));
|
|
73
73
|
} else {
|
|
74
|
-
setDateTime(
|
|
74
|
+
setDateTime(null);
|
|
75
75
|
setInputValue("");
|
|
76
76
|
}
|
|
77
77
|
}, [value]);
|
|
78
78
|
const handleInputChange = (event) => {
|
|
79
|
+
event.stopPropagation();
|
|
79
80
|
setInputValue(event.target.value);
|
|
81
|
+
const parsedDateTime = parse(event.target.value, DATE_FORMAT, /* @__PURE__ */ new Date());
|
|
82
|
+
if (isValid(parsedDateTime)) {
|
|
83
|
+
setDateTime(parsedDateTime);
|
|
84
|
+
onChange == null ? void 0 : onChange(parsedDateTime);
|
|
85
|
+
setInputValue(format(parsedDateTime, DATE_FORMAT));
|
|
86
|
+
} else {
|
|
87
|
+
setInputValue("");
|
|
88
|
+
setDateTime(null);
|
|
89
|
+
onChange == null ? void 0 : onChange(null);
|
|
90
|
+
}
|
|
80
91
|
};
|
|
81
92
|
const handleInputBlur = () => {
|
|
82
93
|
if (inputValue === "") {
|
|
83
|
-
setDateTime(
|
|
84
|
-
onChange == null ? void 0 : onChange(
|
|
94
|
+
setDateTime(null);
|
|
95
|
+
onChange == null ? void 0 : onChange(null);
|
|
85
96
|
return;
|
|
86
97
|
}
|
|
87
|
-
const parsedDateTime = parse(inputValue, DATE_FORMAT, /* @__PURE__ */ new Date());
|
|
98
|
+
const parsedDateTime = parse(inputValue || "", DATE_FORMAT, /* @__PURE__ */ new Date());
|
|
88
99
|
if (isValid(parsedDateTime)) {
|
|
89
100
|
setDateTime(parsedDateTime);
|
|
90
101
|
onChange == null ? void 0 : onChange(parsedDateTime);
|
|
91
102
|
setInputValue(format(parsedDateTime, DATE_FORMAT));
|
|
92
103
|
} else {
|
|
93
104
|
setInputValue("");
|
|
94
|
-
setDateTime(
|
|
95
|
-
onChange == null ? void 0 : onChange(
|
|
105
|
+
setDateTime(null);
|
|
106
|
+
onChange == null ? void 0 : onChange(null);
|
|
96
107
|
}
|
|
97
108
|
};
|
|
98
109
|
const handleDateSelect = (selectedDate) => {
|
|
@@ -106,9 +117,9 @@ const DateTimePicker = forwardRef(
|
|
|
106
117
|
onChange == null ? void 0 : onChange(newDateTime);
|
|
107
118
|
setInputValue(format(newDateTime, DATE_FORMAT));
|
|
108
119
|
} else {
|
|
109
|
-
setDateTime(
|
|
120
|
+
setDateTime(null);
|
|
110
121
|
setInputValue("");
|
|
111
|
-
onChange == null ? void 0 : onChange(
|
|
122
|
+
onChange == null ? void 0 : onChange(null);
|
|
112
123
|
}
|
|
113
124
|
};
|
|
114
125
|
const handleTimeSelect = (time) => {
|
|
@@ -127,8 +138,8 @@ const DateTimePicker = forwardRef(
|
|
|
127
138
|
};
|
|
128
139
|
const handleClear = () => {
|
|
129
140
|
setInputValue("");
|
|
130
|
-
setDateTime(
|
|
131
|
-
onChange == null ? void 0 : onChange(
|
|
141
|
+
setDateTime(null);
|
|
142
|
+
onChange == null ? void 0 : onChange(null);
|
|
132
143
|
};
|
|
133
144
|
const timeOptions = Array.from({ length: 48 }, (_, i) => {
|
|
134
145
|
const hours = Math.floor(i / 2);
|
|
@@ -142,7 +153,7 @@ const DateTimePicker = forwardRef(
|
|
|
142
153
|
{
|
|
143
154
|
ref,
|
|
144
155
|
type: "text",
|
|
145
|
-
value: inputValue,
|
|
156
|
+
value: inputValue || "",
|
|
146
157
|
onChange: handleInputChange,
|
|
147
158
|
onBlur: handleInputBlur,
|
|
148
159
|
placeholder,
|
|
@@ -157,6 +168,7 @@ const DateTimePicker = forwardRef(
|
|
|
157
168
|
clearable && inputValue && /* @__PURE__ */ jsxs(
|
|
158
169
|
Button,
|
|
159
170
|
{
|
|
171
|
+
type: "button",
|
|
160
172
|
variant: "ghost",
|
|
161
173
|
size: "icon",
|
|
162
174
|
className: "absolute right-2 top-1/2 -translate-y-1/2 h-4 w-4 p-0",
|
|
@@ -173,7 +185,7 @@ const DateTimePicker = forwardRef(
|
|
|
173
185
|
Calendar,
|
|
174
186
|
{
|
|
175
187
|
mode: "single",
|
|
176
|
-
selected: dateTime,
|
|
188
|
+
selected: dateTime || void 0,
|
|
177
189
|
onSelect: handleDateSelect,
|
|
178
190
|
initialFocus: true
|
|
179
191
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DateTimePicker.js","sources":["../../../node_modules/lucide-react/dist/esm/icons/calendar-clock.js","../../../node_modules/lucide-react/dist/esm/icons/clock.js","../../../node_modules/date-fns/set.mjs","../../../lib/components/ui/DateTimePicker.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 CalendarClock = createLucideIcon(\"CalendarClock\", [\n [\"path\", { d: \"M21 7.5V6a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h3.5\", key: \"1osxxc\" }],\n [\"path\", { d: \"M16 2v4\", key: \"4m81vk\" }],\n [\"path\", { d: \"M8 2v4\", key: \"1cmpym\" }],\n [\"path\", { d: \"M3 10h5\", key: \"r794hk\" }],\n [\"path\", { d: \"M17.5 17.5 16 16.3V14\", key: \"akvzfd\" }],\n [\"circle\", { cx: \"16\", cy: \"16\", r: \"6\", key: \"qoo3c4\" }]\n]);\n\nexport { CalendarClock as default };\n//# sourceMappingURL=calendar-clock.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 Clock = createLucideIcon(\"Clock\", [\n [\"circle\", { cx: \"12\", cy: \"12\", r: \"10\", key: \"1mglay\" }],\n [\"polyline\", { points: \"12 6 12 12 16 14\", key: \"68esgv\" }]\n]);\n\nexport { Clock as default };\n//# sourceMappingURL=clock.js.map\n","import { constructFrom } from \"./constructFrom.mjs\";\nimport { setMonth } from \"./setMonth.mjs\";\nimport { toDate } from \"./toDate.mjs\";\n\n/**\n * @name set\n * @category Common Helpers\n * @summary Set date values to a given date.\n *\n * @description\n * Set date values to a given date.\n *\n * Sets time values to date from object `values`.\n * A value is not set if it is undefined or null or doesn't exist in `values`.\n *\n * Note about bundle size: `set` does not internally use `setX` functions from date-fns but instead opts\n * to use native `Date#setX` methods. If you use this function, you may not want to include the\n * other `setX` functions that date-fns provides if you are concerned about the bundle size.\n *\n * @typeParam DateType - The `Date` type, the function operates on. Gets inferred from passed arguments. Allows to use extensions like [`UTCDate`](https://github.com/date-fns/utc).\n *\n * @param date - The date to be changed\n * @param values - The date values to be set\n *\n * @returns The new date with options set\n *\n * @example\n * // Transform 1 September 2014 into 20 October 2015 in a single line:\n * const result = set(new Date(2014, 8, 20), { year: 2015, month: 9, date: 20 })\n * //=> Tue Oct 20 2015 00:00:00\n *\n * @example\n * // Set 12 PM to 1 September 2014 01:23:45 to 1 September 2014 12:00:00:\n * const result = set(new Date(2014, 8, 1, 1, 23, 45), { hours: 12 })\n * //=> Mon Sep 01 2014 12:23:45\n */\n\nexport function set(date, values) {\n let _date = toDate(date);\n\n // Check if date is Invalid Date because Date.prototype.setFullYear ignores the value of Invalid Date\n if (isNaN(+_date)) {\n return constructFrom(date, NaN);\n }\n\n if (values.year != null) {\n _date.setFullYear(values.year);\n }\n\n if (values.month != null) {\n _date = setMonth(_date, values.month);\n }\n\n if (values.date != null) {\n _date.setDate(values.date);\n }\n\n if (values.hours != null) {\n _date.setHours(values.hours);\n }\n\n if (values.minutes != null) {\n _date.setMinutes(values.minutes);\n }\n\n if (values.seconds != null) {\n _date.setSeconds(values.seconds);\n }\n\n if (values.milliseconds != null) {\n _date.setMilliseconds(values.milliseconds);\n }\n\n return _date;\n}\n\n// Fallback for modularized imports:\nexport default set;\n","import { format, parse, isValid, set } from \"date-fns\";\r\nimport { CalendarClockIcon, Clock, XIcon } from \"lucide-react\";\r\n\r\nimport { Button } from \"./button\";\r\nimport { Calendar } from \"./Calendar\";\r\nimport { Popover, PopoverContent, PopoverTrigger } from \"./popover\";\r\nimport { cn } from \"../../utils/utils\";\r\nimport React, { forwardRef, useEffect } from \"react\";\r\nimport { Input } from \"./input\";\r\nimport {\r\n Select,\r\n SelectContent,\r\n SelectItem,\r\n SelectTrigger,\r\n SelectValue,\r\n} from \"./select\";\r\n\r\nconst DATE_FORMAT = \"dd.MM.yyyy HH:mm\";\r\n\r\ninterface DateTimePickerProps {\r\n value?: Date;\r\n onChange?: (date: Date | undefined) => void;\r\n className?: string;\r\n placeholder?: string;\r\n clearable?: boolean;\r\n}\r\n\r\nconst DateTimePicker = forwardRef<HTMLInputElement, DateTimePickerProps>(\r\n (\r\n { value, onChange, className, clearable = true, placeholder, ...props },\r\n ref\r\n ) => {\r\n const [dateTime, setDateTime] = React.useState<Date | undefined>(value);\r\n const [inputValue, setInputValue] = React.useState<string>(\"\");\r\n\r\n useEffect(() => {\r\n if (value) {\r\n setDateTime(value);\r\n setInputValue(format(value, DATE_FORMAT));\r\n } else {\r\n setDateTime(undefined);\r\n setInputValue(\"\");\r\n }\r\n }, [value]);\r\n\r\n const handleInputChange = (event: React.ChangeEvent<HTMLInputElement>) => {\r\n setInputValue(event.target.value);\r\n };\r\n\r\n const handleInputBlur = () => {\r\n if (inputValue === \"\") {\r\n setDateTime(undefined);\r\n onChange?.(undefined);\r\n return;\r\n }\r\n\r\n const parsedDateTime = parse(inputValue, DATE_FORMAT, new Date());\r\n if (isValid(parsedDateTime)) {\r\n setDateTime(parsedDateTime);\r\n onChange?.(parsedDateTime);\r\n setInputValue(format(parsedDateTime, DATE_FORMAT));\r\n } else {\r\n setInputValue(\"\");\r\n setDateTime(undefined);\r\n onChange?.(undefined);\r\n }\r\n };\r\n\r\n const handleDateSelect = (selectedDate: Date | undefined) => {\r\n if (selectedDate) {\r\n const newDateTime = dateTime\r\n ? set(dateTime, {\r\n year: selectedDate.getFullYear(),\r\n month: selectedDate.getMonth(),\r\n date: selectedDate.getDate(),\r\n })\r\n : set(selectedDate, { hours: 12, minutes: 0 });\r\n setDateTime(newDateTime);\r\n onChange?.(newDateTime);\r\n setInputValue(format(newDateTime, DATE_FORMAT));\r\n } else {\r\n setDateTime(undefined);\r\n setInputValue(\"\");\r\n onChange?.(undefined);\r\n }\r\n };\r\n\r\n const handleTimeSelect = (time: string) => {\r\n const [hours, minutes] = time.split(\":\").map(Number);\r\n if (dateTime) {\r\n const newDateTime = set(dateTime, { hours, minutes });\r\n setDateTime(newDateTime);\r\n onChange?.(newDateTime);\r\n setInputValue(format(newDateTime, DATE_FORMAT));\r\n } else {\r\n const newDateTime = set(new Date(), { hours, minutes });\r\n setDateTime(newDateTime);\r\n onChange?.(newDateTime);\r\n setInputValue(format(newDateTime, DATE_FORMAT));\r\n }\r\n };\r\n\r\n const handleClear = () => {\r\n setInputValue(\"\");\r\n setDateTime(undefined);\r\n onChange?.(undefined);\r\n };\r\n\r\n const timeOptions = Array.from({ length: 48 }, (_, i) => {\r\n const hours = Math.floor(i / 2);\r\n const minutes = i % 2 === 0 ? \"00\" : \"30\";\r\n return `${hours.toString().padStart(2, \"0\")}:${minutes}`;\r\n });\r\n\r\n return (\r\n <Popover>\r\n <PopoverTrigger asChild>\r\n <div className={cn(\"relative w-full\", className)}>\r\n <Input\r\n ref={ref}\r\n type=\"text\"\r\n value={inputValue}\r\n onChange={handleInputChange}\r\n onBlur={handleInputBlur}\r\n placeholder={placeholder}\r\n className={cn(\r\n \"w-full pl-8 pr-8\",\r\n !dateTime && \"text-muted-foreground\"\r\n )}\r\n {...props}\r\n />\r\n <CalendarClockIcon className=\"absolute left-2 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground\" />\r\n {clearable && inputValue && (\r\n <Button\r\n variant=\"ghost\"\r\n size=\"icon\"\r\n className=\"absolute right-2 top-1/2 -translate-y-1/2 h-4 w-4 p-0\"\r\n onClick={handleClear}\r\n >\r\n <XIcon className=\"h-4 w-4 text-muted-foreground\" />\r\n <span className=\"sr-only\">Smazat datum a čas</span>\r\n </Button>\r\n )}\r\n </div>\r\n </PopoverTrigger>\r\n <PopoverContent className=\"w-auto p-0\" align=\"start\">\r\n <Calendar\r\n mode=\"single\"\r\n selected={dateTime}\r\n onSelect={handleDateSelect}\r\n initialFocus\r\n />\r\n <div className=\"p-3 border-t border-border\">\r\n <Select\r\n onValueChange={handleTimeSelect}\r\n value={dateTime ? format(dateTime, \"HH:mm\") : undefined}\r\n >\r\n <SelectTrigger>\r\n <SelectValue placeholder=\"Select time\">\r\n {dateTime ? (\r\n <div className=\"flex items-center\">\r\n <Clock className=\"mr-2 h-4 w-4\" />\r\n {format(dateTime, \"HH:mm\")}\r\n </div>\r\n ) : (\r\n \"Select time\"\r\n )}\r\n </SelectValue>\r\n </SelectTrigger>\r\n <SelectContent>\r\n {timeOptions.map((time) => (\r\n <SelectItem key={time} value={time}>\r\n {time}\r\n </SelectItem>\r\n ))}\r\n </SelectContent>\r\n </Select>\r\n </div>\r\n </PopoverContent>\r\n </Popover>\r\n );\r\n }\r\n);\r\n\r\nDateTimePicker.displayName = \"DateTimePicker\";\r\n\r\nexport default DateTimePicker;\r\n"],"names":["React","CalendarClockIcon","XIcon"],"mappings":";;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AASA,MAAM,gBAAgB,iBAAiB,iBAAiB;AAAA,EACtD,CAAC,QAAQ,EAAE,GAAG,gEAAgE,KAAK,SAAQ,CAAE;AAAA,EAC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;AAAA,UAAC;AAAA,UAAA;AAAA,YACC,SAAQ;AAAA,YACR,MAAK;AAAA,YACL,WAAU;AAAA,YACV,SAAS;AAAA,YAET,UAAA;AAAA,cAAC,oBAAAC,GAAA,EAAM,WAAU,gCAAgC,CAAA;AAAA,cAChD,oBAAA,QAAA,EAAK,WAAU,WAAU,UAAkB,sBAAA;AAAA,YAAA;AAAA,UAAA;AAAA,QAC9C;AAAA,MAAA,EAAA,CAEJ,EACF,CAAA;AAAA,MACC,qBAAA,gBAAA,EAAe,WAAU,cAAa,OAAM,SAC3C,UAAA;AAAA,QAAA;AAAA,UAAC;AAAA,UAAA;AAAA,YACC,MAAK;AAAA,YACL,UAAU;AAAA,YACV,UAAU;AAAA,YACV,cAAY;AAAA,UAAA;AAAA,QACd;AAAA,QACA,oBAAC,OAAI,EAAA,WAAU,8BACb,UAAA;AAAA,UAAC;AAAA,UAAA;AAAA,YACC,eAAe;AAAA,YACf,OAAO,WAAW,OAAO,UAAU,OAAO,IAAI;AAAA,YAE9C,UAAA;AAAA,cAAC,oBAAA,eAAA,EACC,8BAAC,aAAY,EAAA,aAAY,eACtB,UACC,WAAA,qBAAC,OAAI,EAAA,WAAU,qBACb,UAAA;AAAA,gBAAC,oBAAA,OAAA,EAAM,WAAU,eAAe,CAAA;AAAA,gBAC/B,OAAO,UAAU,OAAO;AAAA,cAAA,GAC3B,IAEA,cAEJ,CAAA,GACF;AAAA,cACC,oBAAA,eAAA,EACE,UAAY,YAAA,IAAI,CAAC,SACf,oBAAA,YAAA,EAAsB,OAAO,MAC3B,UADc,KAAA,GAAA,IAEjB,CACD,GACH;AAAA,YAAA;AAAA,UAAA;AAAA,QAAA,GAEJ;AAAA,MAAA,GACF;AAAA,IACF,EAAA,CAAA;AAAA,EAEJ;AACF;AAEA,eAAe,cAAc;","x_google_ignoreList":[0,1,2]}
|
|
1
|
+
{"version":3,"file":"DateTimePicker.js","sources":["../../../node_modules/lucide-react/dist/esm/icons/calendar-clock.js","../../../node_modules/lucide-react/dist/esm/icons/clock.js","../../../node_modules/date-fns/set.mjs","../../../lib/components/ui/DateTimePicker.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 CalendarClock = createLucideIcon(\"CalendarClock\", [\n [\"path\", { d: \"M21 7.5V6a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h3.5\", key: \"1osxxc\" }],\n [\"path\", { d: \"M16 2v4\", key: \"4m81vk\" }],\n [\"path\", { d: \"M8 2v4\", key: \"1cmpym\" }],\n [\"path\", { d: \"M3 10h5\", key: \"r794hk\" }],\n [\"path\", { d: \"M17.5 17.5 16 16.3V14\", key: \"akvzfd\" }],\n [\"circle\", { cx: \"16\", cy: \"16\", r: \"6\", key: \"qoo3c4\" }]\n]);\n\nexport { CalendarClock as default };\n//# sourceMappingURL=calendar-clock.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 Clock = createLucideIcon(\"Clock\", [\n [\"circle\", { cx: \"12\", cy: \"12\", r: \"10\", key: \"1mglay\" }],\n [\"polyline\", { points: \"12 6 12 12 16 14\", key: \"68esgv\" }]\n]);\n\nexport { Clock as default };\n//# sourceMappingURL=clock.js.map\n","import { constructFrom } from \"./constructFrom.mjs\";\nimport { setMonth } from \"./setMonth.mjs\";\nimport { toDate } from \"./toDate.mjs\";\n\n/**\n * @name set\n * @category Common Helpers\n * @summary Set date values to a given date.\n *\n * @description\n * Set date values to a given date.\n *\n * Sets time values to date from object `values`.\n * A value is not set if it is undefined or null or doesn't exist in `values`.\n *\n * Note about bundle size: `set` does not internally use `setX` functions from date-fns but instead opts\n * to use native `Date#setX` methods. If you use this function, you may not want to include the\n * other `setX` functions that date-fns provides if you are concerned about the bundle size.\n *\n * @typeParam DateType - The `Date` type, the function operates on. Gets inferred from passed arguments. Allows to use extensions like [`UTCDate`](https://github.com/date-fns/utc).\n *\n * @param date - The date to be changed\n * @param values - The date values to be set\n *\n * @returns The new date with options set\n *\n * @example\n * // Transform 1 September 2014 into 20 October 2015 in a single line:\n * const result = set(new Date(2014, 8, 20), { year: 2015, month: 9, date: 20 })\n * //=> Tue Oct 20 2015 00:00:00\n *\n * @example\n * // Set 12 PM to 1 September 2014 01:23:45 to 1 September 2014 12:00:00:\n * const result = set(new Date(2014, 8, 1, 1, 23, 45), { hours: 12 })\n * //=> Mon Sep 01 2014 12:23:45\n */\n\nexport function set(date, values) {\n let _date = toDate(date);\n\n // Check if date is Invalid Date because Date.prototype.setFullYear ignores the value of Invalid Date\n if (isNaN(+_date)) {\n return constructFrom(date, NaN);\n }\n\n if (values.year != null) {\n _date.setFullYear(values.year);\n }\n\n if (values.month != null) {\n _date = setMonth(_date, values.month);\n }\n\n if (values.date != null) {\n _date.setDate(values.date);\n }\n\n if (values.hours != null) {\n _date.setHours(values.hours);\n }\n\n if (values.minutes != null) {\n _date.setMinutes(values.minutes);\n }\n\n if (values.seconds != null) {\n _date.setSeconds(values.seconds);\n }\n\n if (values.milliseconds != null) {\n _date.setMilliseconds(values.milliseconds);\n }\n\n return _date;\n}\n\n// Fallback for modularized imports:\nexport default set;\n","import { format, parse, isValid, set } from \"date-fns\";\r\nimport { CalendarClockIcon, Clock, XIcon } from \"lucide-react\";\r\n\r\nimport { Button } from \"./button\";\r\nimport { Calendar } from \"./Calendar\";\r\nimport { Popover, PopoverContent, PopoverTrigger } from \"./popover\";\r\nimport { cn } from \"../../utils/utils\";\r\nimport React, { forwardRef, useEffect } from \"react\";\r\nimport { Input } from \"./input\";\r\nimport {\r\n Select,\r\n SelectContent,\r\n SelectItem,\r\n SelectTrigger,\r\n SelectValue,\r\n} from \"./select\";\r\n\r\nconst DATE_FORMAT = \"dd.MM.yyyy HH:mm\";\r\n\r\ninterface DateTimePickerProps {\r\n value?: Date;\r\n onChange?: (date: Date | undefined | null) => void;\r\n className?: string;\r\n placeholder?: string;\r\n clearable?: boolean;\r\n}\r\n\r\nconst DateTimePicker = forwardRef<HTMLInputElement, DateTimePickerProps>(\r\n (\r\n { value, onChange, className, clearable = true, placeholder, ...props },\r\n ref\r\n ) => {\r\n const [dateTime, setDateTime] = React.useState<Date | null>(value || null);\r\n const [inputValue, setInputValue] = React.useState<string | null>(\"\");\r\n\r\n useEffect(() => {\r\n if (value) {\r\n setDateTime(value);\r\n setInputValue(format(value, DATE_FORMAT));\r\n } else {\r\n setDateTime(null);\r\n setInputValue(\"\");\r\n }\r\n }, [value]);\r\n\r\n const handleInputChange = (event: React.ChangeEvent<HTMLInputElement>) => {\r\n event.stopPropagation(); // Stop bubbling to prevent interference with other components\r\n\r\n setInputValue(event.target.value);\r\n const parsedDateTime = parse(event.target.value, DATE_FORMAT, new Date());\r\n\r\n if (isValid(parsedDateTime)) {\r\n setDateTime(parsedDateTime);\r\n onChange?.(parsedDateTime);\r\n setInputValue(format(parsedDateTime, DATE_FORMAT));\r\n } else {\r\n setInputValue(\"\");\r\n setDateTime(null);\r\n onChange?.(null);\r\n }\r\n };\r\n\r\n const handleInputBlur = () => {\r\n if (inputValue === \"\") {\r\n setDateTime(null);\r\n onChange?.(null);\r\n return;\r\n }\r\n\r\n const parsedDateTime = parse(inputValue || \"\", DATE_FORMAT, new Date());\r\n if (isValid(parsedDateTime)) {\r\n setDateTime(parsedDateTime);\r\n onChange?.(parsedDateTime);\r\n setInputValue(format(parsedDateTime, DATE_FORMAT));\r\n } else {\r\n setInputValue(\"\");\r\n setDateTime(null);\r\n onChange?.(null);\r\n }\r\n };\r\n\r\n const handleDateSelect = (selectedDate: Date | undefined | null) => {\r\n if (selectedDate) {\r\n const newDateTime = dateTime\r\n ? set(dateTime, {\r\n year: selectedDate.getFullYear(),\r\n month: selectedDate.getMonth(),\r\n date: selectedDate.getDate(),\r\n })\r\n : set(selectedDate, { hours: 12, minutes: 0 });\r\n setDateTime(newDateTime);\r\n onChange?.(newDateTime);\r\n setInputValue(format(newDateTime, DATE_FORMAT));\r\n } else {\r\n setDateTime(null);\r\n setInputValue(\"\");\r\n onChange?.(null);\r\n }\r\n };\r\n\r\n const handleTimeSelect = (time: string) => {\r\n const [hours, minutes] = time.split(\":\").map(Number);\r\n if (dateTime) {\r\n const newDateTime = set(dateTime, { hours, minutes });\r\n setDateTime(newDateTime);\r\n onChange?.(newDateTime);\r\n setInputValue(format(newDateTime, DATE_FORMAT));\r\n } else {\r\n const newDateTime = set(new Date(), { hours, minutes });\r\n setDateTime(newDateTime);\r\n onChange?.(newDateTime);\r\n setInputValue(format(newDateTime, DATE_FORMAT));\r\n }\r\n };\r\n\r\n const handleClear = () => {\r\n setInputValue(\"\");\r\n setDateTime(null);\r\n onChange?.(null);\r\n };\r\n\r\n const timeOptions = Array.from({ length: 48 }, (_, i) => {\r\n const hours = Math.floor(i / 2);\r\n const minutes = i % 2 === 0 ? \"00\" : \"30\";\r\n return `${hours.toString().padStart(2, \"0\")}:${minutes}`;\r\n });\r\n\r\n return (\r\n <Popover>\r\n <PopoverTrigger asChild>\r\n <div className={cn(\"relative w-full\", className)}>\r\n <Input\r\n ref={ref}\r\n type=\"text\"\r\n value={inputValue || \"\"}\r\n onChange={handleInputChange}\r\n onBlur={handleInputBlur}\r\n placeholder={placeholder}\r\n className={cn(\r\n \"w-full pl-8 pr-8\",\r\n !dateTime && \"text-muted-foreground\"\r\n )}\r\n {...props}\r\n />\r\n <CalendarClockIcon className=\"absolute left-2 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground\" />\r\n {clearable && inputValue && (\r\n <Button\r\n type=\"button\"\r\n variant=\"ghost\"\r\n size=\"icon\"\r\n className=\"absolute right-2 top-1/2 -translate-y-1/2 h-4 w-4 p-0\"\r\n onClick={handleClear}\r\n >\r\n <XIcon className=\"h-4 w-4 text-muted-foreground\" />\r\n <span className=\"sr-only\">Smazat datum a čas</span>\r\n </Button>\r\n )}\r\n </div>\r\n </PopoverTrigger>\r\n <PopoverContent className=\"w-auto p-0\" align=\"start\">\r\n <Calendar\r\n mode=\"single\"\r\n selected={dateTime || undefined}\r\n onSelect={handleDateSelect}\r\n initialFocus\r\n />\r\n <div className=\"p-3 border-t border-border\">\r\n <Select\r\n onValueChange={handleTimeSelect}\r\n value={dateTime ? format(dateTime, \"HH:mm\") : undefined}\r\n >\r\n <SelectTrigger>\r\n <SelectValue placeholder=\"Select time\">\r\n {dateTime ? (\r\n <div className=\"flex items-center\">\r\n <Clock className=\"mr-2 h-4 w-4\" />\r\n {format(dateTime, \"HH:mm\")}\r\n </div>\r\n ) : (\r\n \"Select time\"\r\n )}\r\n </SelectValue>\r\n </SelectTrigger>\r\n <SelectContent>\r\n {timeOptions.map((time) => (\r\n <SelectItem key={time} value={time}>\r\n {time}\r\n </SelectItem>\r\n ))}\r\n </SelectContent>\r\n </Select>\r\n </div>\r\n </PopoverContent>\r\n </Popover>\r\n );\r\n }\r\n);\r\n\r\nDateTimePicker.displayName = \"DateTimePicker\";\r\n\r\nexport default DateTimePicker;\r\n"],"names":["React","CalendarClockIcon","XIcon"],"mappings":";;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AASA,MAAM,gBAAgB,iBAAiB,iBAAiB;AAAA,EACtD,CAAC,QAAQ,EAAE,GAAG,gEAAgE,KAAK,SAAQ,CAAE;AAAA,EAC7F,CAAC,QAAQ,EAAE,GAAG,WAAW,KAAK,SAAQ,CAAE;AAAA,EACxC,CAAC,QAAQ,EAAE,GAAG,UAAU,KAAK,SAAQ,CAAE;AAAA,EACvC,CAAC,QAAQ,EAAE,GAAG,WAAW,KAAK,SAAQ,CAAE;AAAA,EACxC,CAAC,QAAQ,EAAE,GAAG,yBAAyB,KAAK,SAAQ,CAAE;AAAA,EACtD,CAAC,UAAU,EAAE,IAAI,MAAM,IAAI,MAAM,GAAG,KAAK,KAAK,UAAU;AAC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h, d } from "../../Dialog-
|
|
3
|
+
import { D, c, e, i, g, f, b, a, h, d } from "../../Dialog-BtXGfOmv.js";
|
|
4
4
|
import "../../utils/utils.js";
|
|
5
5
|
import "../../x-DciOkaU0.js";
|
|
6
6
|
export {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { jsx, jsxs, Fragment } from "react/jsx-runtime";
|
|
2
2
|
import * as React from "react";
|
|
3
3
|
import { P as Primitive } from "../../index-B761_inZ.js";
|
|
4
|
-
import { P as Presence } from "../../index-
|
|
5
|
-
import { c as createContextScope,
|
|
4
|
+
import { P as Presence } from "../../index-CA2QNu6z.js";
|
|
5
|
+
import { c as createContextScope, b as composeEventHandlers, a as useCallbackRef, u as useLayoutEffect2 } from "../../index-CDCkSjVs.js";
|
|
6
6
|
import { u as useComposedRefs } from "../../index-D9mvqz1C.js";
|
|
7
7
|
import { u as useDirection } from "../../index-Bk8dRTPE.js";
|
|
8
8
|
import { c as clamp } from "../../index-IXOTxK3N.js";
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import * as CheckboxPrimitive from "@radix-ui/react-checkbox";
|
|
3
|
+
declare const Checkbox: React.ForwardRefExoticComponent<Omit<CheckboxPrimitive.CheckboxProps & React.RefAttributes<HTMLButtonElement>, "ref"> & React.RefAttributes<HTMLButtonElement>>;
|
|
4
|
+
export { Checkbox };
|