@addsign/moje-agenda-shared-lib 2.0.4 → 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 +15 -0
- package/dist/components/datatable/DataTable.js +2 -1
- package/dist/components/datatable/DataTable.js.map +1 -1
- package/dist/components/datatable/DataTableServer.js +2 -1
- package/dist/components/datatable/DataTableServer.js.map +1 -1
- package/dist/components/form/AutocompleteSearchBar.js +2 -1
- package/dist/components/form/AutocompleteSearchBar.js.map +1 -1
- package/dist/components/form/AutocompleteSearchBarServer.js +2 -1
- package/dist/components/form/AutocompleteSearchBarServer.js.map +1 -1
- package/dist/components/form/FileInput.js +3 -2
- package/dist/components/form/FileInput.js.map +1 -1
- package/dist/components/form/FileInputMultiple.js +3 -2
- package/dist/components/form/FileInputMultiple.js.map +1 -1
- package/dist/components/form/FormField.js +2 -1
- package/dist/components/form/FormField.js.map +1 -1
- package/dist/components/form/PositionsSelectorSingle.js +2 -1
- package/dist/components/form/PositionsSelectorSingle.js.map +1 -1
- package/dist/components/form/SelectField.js +2 -1
- package/dist/components/form/SelectField.js.map +1 -1
- package/dist/components/profiles/ProfileOverview.js +2 -1
- package/dist/components/profiles/ProfileOverview.js.map +1 -1
- package/dist/components/ui/Combobox.js +17 -7
- package/dist/components/ui/Combobox.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/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/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 +1 -0
- package/dist/main.js +3 -1
- package/dist/main.js.map +1 -1
- package/lib/components/ui/Combobox.tsx +18 -7
- package/lib/components/ui/checkbox.tsx +30 -0
- package/lib/main.ts +1 -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";
|
|
@@ -19,6 +19,7 @@ import "../ui/select.js";
|
|
|
19
19
|
import "../ui/tooltip.js";
|
|
20
20
|
import "../ui/separator.js";
|
|
21
21
|
import "../ui/textarea.js";
|
|
22
|
+
import "../ui/checkbox.js";
|
|
22
23
|
import "../ui/button.js";
|
|
23
24
|
import "../../Calendar-DWT4e7Th.js";
|
|
24
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,QAAQ;AAAA,QACN,OAAO;AAAA,QACP;AAAA,MACF;AAAA,IAAA,CACD;AAAA,EAAA;AAGH,QAAM,UAAU,MAAM;AACd,UAAA,eAAe,OAAOA,cAAqB;AAC/C,mBAAa,IAAI;AACjB,YAAM,EAAE,KAAK,IAAI,MAAM,UAAU,IAAIA,SAAQ;AAG7C,YAAM,mBAAmB,OAAO,KAAK,CAAC,MAAM;AAC5C,YAAM,eAAe,QAAQ,KAAK,eAAe,SAAS;AAG1D,YAAM,sBAAsB,eAAe,KAAK,UAAU,MAAM;AAAA,QAC9D,CAAC,SAAc;AACb,cAAI,kBAAkB;AAEpB,mBAAO,EAAE,OAAO,MAAM,OAAO,KAAK;UAAW,OACxC;AAEE,mBAAA;AAAA,cACL,O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A,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,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,UAAA,eAAe,OAAOA,cAAqB;AAC/C,mBAAa,IAAI;AACjB,YAAM,EAAE,KAAK,IAAI,MAAM,UAAU,IAAIA,SAAQ;AAG7C,YAAM,mBAAmB,OAAO,KAAK,CAAC,MAAM;AAC5C,YAAM,eAAe,QAAQ,K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ACZ,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";
|
|
@@ -20,6 +20,7 @@ import "../ui/select.js";
|
|
|
20
20
|
import "../ui/tooltip.js";
|
|
21
21
|
import "../ui/separator.js";
|
|
22
22
|
import "../ui/textarea.js";
|
|
23
|
+
import "../ui/checkbox.js";
|
|
23
24
|
import "../ui/button.js";
|
|
24
25
|
import "../../Calendar-DWT4e7Th.js";
|
|
25
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,U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S,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.isCom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,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
|
{
|
|
@@ -134,8 +144,8 @@ const Combobox = React.forwardRef(
|
|
|
134
144
|
/* @__PURE__ */ jsx(CommandGroup, { children: frameworks.map((framework) => /* @__PURE__ */ jsxs(
|
|
135
145
|
CommandItem,
|
|
136
146
|
{
|
|
137
|
-
value: framework.
|
|
138
|
-
onSelect: handleSelect,
|
|
147
|
+
value: framework.label,
|
|
148
|
+
onSelect: () => handleSelect(framework.value),
|
|
139
149
|
children: [
|
|
140
150
|
framework.label,
|
|
141
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 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.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,EAC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BAAW;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]}
|
|
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\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,SAAS,cAAc,CAAC;AAAA,IACxB,cAAc;AAAA,KAEhB,QACG;;AAC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AAAA,UAEC,oBAAA,cAAA,EACE,UAAW,WAAA,IAAI,CAAC,cACf;AAAA,YAAC;AAAA,YAAA;AAAA,cAEC,OAAO,UAAU;AAAA,cACjB,UAAU,MAAM,aAAa,UAAU,KAAe;AAAA,cAErD,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]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import "react/jsx-runtime";
|
|
2
2
|
import "react";
|
|
3
|
-
import { D, c, e, i, g, f, b, a, 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 };
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
import { jsxs, jsx } from "react/jsx-runtime";
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
import { u as useComposedRefs } from "../../index-D9mvqz1C.js";
|
|
4
|
+
import { c as createContextScope, b as composeEventHandlers } from "../../index-CDCkSjVs.js";
|
|
5
|
+
import { u as useControllableState } from "../../index-DFSwSCB0.js";
|
|
6
|
+
import { u as usePrevious } from "../../index-CshadhlS.js";
|
|
7
|
+
import { u as useSize } from "../../index-pLFWXSOv.js";
|
|
8
|
+
import { P as Presence } from "../../index-CA2QNu6z.js";
|
|
9
|
+
import { P as Primitive } from "../../index-B761_inZ.js";
|
|
10
|
+
import { cn } from "../../utils/utils.js";
|
|
11
|
+
import { C as Check } from "../../check-B7dJm08z.js";
|
|
12
|
+
var CHECKBOX_NAME = "Checkbox";
|
|
13
|
+
var [createCheckboxContext, createCheckboxScope] = createContextScope(CHECKBOX_NAME);
|
|
14
|
+
var [CheckboxProvider, useCheckboxContext] = createCheckboxContext(CHECKBOX_NAME);
|
|
15
|
+
var Checkbox$1 = React.forwardRef(
|
|
16
|
+
(props, forwardedRef) => {
|
|
17
|
+
const {
|
|
18
|
+
__scopeCheckbox,
|
|
19
|
+
name,
|
|
20
|
+
checked: checkedProp,
|
|
21
|
+
defaultChecked,
|
|
22
|
+
required,
|
|
23
|
+
disabled,
|
|
24
|
+
value = "on",
|
|
25
|
+
onCheckedChange,
|
|
26
|
+
form,
|
|
27
|
+
...checkboxProps
|
|
28
|
+
} = props;
|
|
29
|
+
const [button, setButton] = React.useState(null);
|
|
30
|
+
const composedRefs = useComposedRefs(forwardedRef, (node) => setButton(node));
|
|
31
|
+
const hasConsumerStoppedPropagationRef = React.useRef(false);
|
|
32
|
+
const isFormControl = button ? form || !!button.closest("form") : true;
|
|
33
|
+
const [checked = false, setChecked] = useControllableState({
|
|
34
|
+
prop: checkedProp,
|
|
35
|
+
defaultProp: defaultChecked,
|
|
36
|
+
onChange: onCheckedChange
|
|
37
|
+
});
|
|
38
|
+
const initialCheckedStateRef = React.useRef(checked);
|
|
39
|
+
React.useEffect(() => {
|
|
40
|
+
const form2 = button == null ? void 0 : button.form;
|
|
41
|
+
if (form2) {
|
|
42
|
+
const reset = () => setChecked(initialCheckedStateRef.current);
|
|
43
|
+
form2.addEventListener("reset", reset);
|
|
44
|
+
return () => form2.removeEventListener("reset", reset);
|
|
45
|
+
}
|
|
46
|
+
}, [button, setChecked]);
|
|
47
|
+
return /* @__PURE__ */ jsxs(CheckboxProvider, { scope: __scopeCheckbox, state: checked, disabled, children: [
|
|
48
|
+
/* @__PURE__ */ jsx(
|
|
49
|
+
Primitive.button,
|
|
50
|
+
{
|
|
51
|
+
type: "button",
|
|
52
|
+
role: "checkbox",
|
|
53
|
+
"aria-checked": isIndeterminate(checked) ? "mixed" : checked,
|
|
54
|
+
"aria-required": required,
|
|
55
|
+
"data-state": getState(checked),
|
|
56
|
+
"data-disabled": disabled ? "" : void 0,
|
|
57
|
+
disabled,
|
|
58
|
+
value,
|
|
59
|
+
...checkboxProps,
|
|
60
|
+
ref: composedRefs,
|
|
61
|
+
onKeyDown: composeEventHandlers(props.onKeyDown, (event) => {
|
|
62
|
+
if (event.key === "Enter")
|
|
63
|
+
event.preventDefault();
|
|
64
|
+
}),
|
|
65
|
+
onClick: composeEventHandlers(props.onClick, (event) => {
|
|
66
|
+
setChecked((prevChecked) => isIndeterminate(prevChecked) ? true : !prevChecked);
|
|
67
|
+
if (isFormControl) {
|
|
68
|
+
hasConsumerStoppedPropagationRef.current = event.isPropagationStopped();
|
|
69
|
+
if (!hasConsumerStoppedPropagationRef.current)
|
|
70
|
+
event.stopPropagation();
|
|
71
|
+
}
|
|
72
|
+
})
|
|
73
|
+
}
|
|
74
|
+
),
|
|
75
|
+
isFormControl && /* @__PURE__ */ jsx(
|
|
76
|
+
BubbleInput,
|
|
77
|
+
{
|
|
78
|
+
control: button,
|
|
79
|
+
bubbles: !hasConsumerStoppedPropagationRef.current,
|
|
80
|
+
name,
|
|
81
|
+
value,
|
|
82
|
+
checked,
|
|
83
|
+
required,
|
|
84
|
+
disabled,
|
|
85
|
+
form,
|
|
86
|
+
style: { transform: "translateX(-100%)" },
|
|
87
|
+
defaultChecked: isIndeterminate(defaultChecked) ? false : defaultChecked
|
|
88
|
+
}
|
|
89
|
+
)
|
|
90
|
+
] });
|
|
91
|
+
}
|
|
92
|
+
);
|
|
93
|
+
Checkbox$1.displayName = CHECKBOX_NAME;
|
|
94
|
+
var INDICATOR_NAME = "CheckboxIndicator";
|
|
95
|
+
var CheckboxIndicator = React.forwardRef(
|
|
96
|
+
(props, forwardedRef) => {
|
|
97
|
+
const { __scopeCheckbox, forceMount, ...indicatorProps } = props;
|
|
98
|
+
const context = useCheckboxContext(INDICATOR_NAME, __scopeCheckbox);
|
|
99
|
+
return /* @__PURE__ */ jsx(Presence, { present: forceMount || isIndeterminate(context.state) || context.state === true, children: /* @__PURE__ */ jsx(
|
|
100
|
+
Primitive.span,
|
|
101
|
+
{
|
|
102
|
+
"data-state": getState(context.state),
|
|
103
|
+
"data-disabled": context.disabled ? "" : void 0,
|
|
104
|
+
...indicatorProps,
|
|
105
|
+
ref: forwardedRef,
|
|
106
|
+
style: { pointerEvents: "none", ...props.style }
|
|
107
|
+
}
|
|
108
|
+
) });
|
|
109
|
+
}
|
|
110
|
+
);
|
|
111
|
+
CheckboxIndicator.displayName = INDICATOR_NAME;
|
|
112
|
+
var BubbleInput = (props) => {
|
|
113
|
+
const { control, checked, bubbles = true, defaultChecked, ...inputProps } = props;
|
|
114
|
+
const ref = React.useRef(null);
|
|
115
|
+
const prevChecked = usePrevious(checked);
|
|
116
|
+
const controlSize = useSize(control);
|
|
117
|
+
React.useEffect(() => {
|
|
118
|
+
const input = ref.current;
|
|
119
|
+
const inputProto = window.HTMLInputElement.prototype;
|
|
120
|
+
const descriptor = Object.getOwnPropertyDescriptor(inputProto, "checked");
|
|
121
|
+
const setChecked = descriptor.set;
|
|
122
|
+
if (prevChecked !== checked && setChecked) {
|
|
123
|
+
const event = new Event("click", { bubbles });
|
|
124
|
+
input.indeterminate = isIndeterminate(checked);
|
|
125
|
+
setChecked.call(input, isIndeterminate(checked) ? false : checked);
|
|
126
|
+
input.dispatchEvent(event);
|
|
127
|
+
}
|
|
128
|
+
}, [prevChecked, checked, bubbles]);
|
|
129
|
+
const defaultCheckedRef = React.useRef(isIndeterminate(checked) ? false : checked);
|
|
130
|
+
return /* @__PURE__ */ jsx(
|
|
131
|
+
"input",
|
|
132
|
+
{
|
|
133
|
+
type: "checkbox",
|
|
134
|
+
"aria-hidden": true,
|
|
135
|
+
defaultChecked: defaultChecked ?? defaultCheckedRef.current,
|
|
136
|
+
...inputProps,
|
|
137
|
+
tabIndex: -1,
|
|
138
|
+
ref,
|
|
139
|
+
style: {
|
|
140
|
+
...props.style,
|
|
141
|
+
...controlSize,
|
|
142
|
+
position: "absolute",
|
|
143
|
+
pointerEvents: "none",
|
|
144
|
+
opacity: 0,
|
|
145
|
+
margin: 0
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
);
|
|
149
|
+
};
|
|
150
|
+
function isIndeterminate(checked) {
|
|
151
|
+
return checked === "indeterminate";
|
|
152
|
+
}
|
|
153
|
+
function getState(checked) {
|
|
154
|
+
return isIndeterminate(checked) ? "indeterminate" : checked ? "checked" : "unchecked";
|
|
155
|
+
}
|
|
156
|
+
var Root = Checkbox$1;
|
|
157
|
+
var Indicator = CheckboxIndicator;
|
|
158
|
+
const Checkbox = React.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
|
|
159
|
+
Root,
|
|
160
|
+
{
|
|
161
|
+
ref,
|
|
162
|
+
className: cn(
|
|
163
|
+
"peer h-4 w-4 shrink-0 rounded-sm border border-primary ring-offset-ring focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground",
|
|
164
|
+
className
|
|
165
|
+
),
|
|
166
|
+
...props,
|
|
167
|
+
children: /* @__PURE__ */ jsx(
|
|
168
|
+
Indicator,
|
|
169
|
+
{
|
|
170
|
+
className: cn("flex items-center justify-center text-current"),
|
|
171
|
+
children: /* @__PURE__ */ jsx(Check, { className: "h-4 w-4" })
|
|
172
|
+
}
|
|
173
|
+
)
|
|
174
|
+
}
|
|
175
|
+
));
|
|
176
|
+
Checkbox.displayName = Root.displayName;
|
|
177
|
+
export {
|
|
178
|
+
Checkbox
|
|
179
|
+
};
|
|
180
|
+
//# sourceMappingURL=checkbox.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"checkbox.js","sources":["../../../node_modules/@radix-ui/react-checkbox/dist/index.mjs","../../../lib/components/ui/checkbox.tsx"],"sourcesContent":["\"use client\";\n\n// packages/react/checkbox/src/Checkbox.tsx\nimport * as React from \"react\";\nimport { useComposedRefs } from \"@radix-ui/react-compose-refs\";\nimport { createContextScope } from \"@radix-ui/react-context\";\nimport { composeEventHandlers } from \"@radix-ui/primitive\";\nimport { useControllableState } from \"@radix-ui/react-use-controllable-state\";\nimport { usePrevious } from \"@radix-ui/react-use-previous\";\nimport { useSize } from \"@radix-ui/react-use-size\";\nimport { Presence } from \"@radix-ui/react-presence\";\nimport { Primitive } from \"@radix-ui/react-primitive\";\nimport { jsx, jsxs } from \"react/jsx-runtime\";\nvar CHECKBOX_NAME = \"Checkbox\";\nvar [createCheckboxContext, createCheckboxScope] = createContextScope(CHECKBOX_NAME);\nvar [CheckboxProvider, useCheckboxContext] = createCheckboxContext(CHECKBOX_NAME);\nvar Checkbox = React.forwardRef(\n (props, forwardedRef) => {\n const {\n __scopeCheckbox,\n name,\n checked: checkedProp,\n defaultChecked,\n required,\n disabled,\n value = \"on\",\n onCheckedChange,\n form,\n ...checkboxProps\n } = props;\n const [button, setButton] = React.useState(null);\n const composedRefs = useComposedRefs(forwardedRef, (node) => setButton(node));\n const hasConsumerStoppedPropagationRef = React.useRef(false);\n const isFormControl = button ? form || !!button.closest(\"form\") : true;\n const [checked = false, setChecked] = useControllableState({\n prop: checkedProp,\n defaultProp: defaultChecked,\n onChange: onCheckedChange\n });\n const initialCheckedStateRef = React.useRef(checked);\n React.useEffect(() => {\n const form2 = button?.form;\n if (form2) {\n const reset = () => setChecked(initialCheckedStateRef.current);\n form2.addEventListener(\"reset\", reset);\n return () => form2.removeEventListener(\"reset\", reset);\n }\n }, [button, setChecked]);\n return /* @__PURE__ */ jsxs(CheckboxProvider, { scope: __scopeCheckbox, state: checked, disabled, children: [\n /* @__PURE__ */ jsx(\n Primitive.button,\n {\n type: \"button\",\n role: \"checkbox\",\n \"aria-checked\": isIndeterminate(checked) ? \"mixed\" : checked,\n \"aria-required\": required,\n \"data-state\": getState(checked),\n \"data-disabled\": disabled ? \"\" : void 0,\n disabled,\n value,\n ...checkboxProps,\n ref: composedRefs,\n onKeyDown: composeEventHandlers(props.onKeyDown, (event) => {\n if (event.key === \"Enter\") event.preventDefault();\n }),\n onClick: composeEventHandlers(props.onClick, (event) => {\n setChecked((prevChecked) => isIndeterminate(prevChecked) ? true : !prevChecked);\n if (isFormControl) {\n hasConsumerStoppedPropagationRef.current = event.isPropagationStopped();\n if (!hasConsumerStoppedPropagationRef.current) event.stopPropagation();\n }\n })\n }\n ),\n isFormControl && /* @__PURE__ */ jsx(\n BubbleInput,\n {\n control: button,\n bubbles: !hasConsumerStoppedPropagationRef.current,\n name,\n value,\n checked,\n required,\n disabled,\n form,\n style: { transform: \"translateX(-100%)\" },\n defaultChecked: isIndeterminate(defaultChecked) ? false : defaultChecked\n }\n )\n ] });\n }\n);\nCheckbox.displayName = CHECKBOX_NAME;\nvar INDICATOR_NAME = \"CheckboxIndicator\";\nvar CheckboxIndicator = React.forwardRef(\n (props, forwardedRef) => {\n const { __scopeCheckbox, forceMount, ...indicatorProps } = props;\n const context = useCheckboxContext(INDICATOR_NAME, __scopeCheckbox);\n return /* @__PURE__ */ jsx(Presence, { present: forceMount || isIndeterminate(context.state) || context.state === true, children: /* @__PURE__ */ jsx(\n Primitive.span,\n {\n \"data-state\": getState(context.state),\n \"data-disabled\": context.disabled ? \"\" : void 0,\n ...indicatorProps,\n ref: forwardedRef,\n style: { pointerEvents: \"none\", ...props.style }\n }\n ) });\n }\n);\nCheckboxIndicator.displayName = INDICATOR_NAME;\nvar BubbleInput = (props) => {\n const { control, checked, bubbles = true, defaultChecked, ...inputProps } = props;\n const ref = React.useRef(null);\n const prevChecked = usePrevious(checked);\n const controlSize = useSize(control);\n React.useEffect(() => {\n const input = ref.current;\n const inputProto = window.HTMLInputElement.prototype;\n const descriptor = Object.getOwnPropertyDescriptor(inputProto, \"checked\");\n const setChecked = descriptor.set;\n if (prevChecked !== checked && setChecked) {\n const event = new Event(\"click\", { bubbles });\n input.indeterminate = isIndeterminate(checked);\n setChecked.call(input, isIndeterminate(checked) ? false : checked);\n input.dispatchEvent(event);\n }\n }, [prevChecked, checked, bubbles]);\n const defaultCheckedRef = React.useRef(isIndeterminate(checked) ? false : checked);\n return /* @__PURE__ */ jsx(\n \"input\",\n {\n type: \"checkbox\",\n \"aria-hidden\": true,\n defaultChecked: defaultChecked ?? defaultCheckedRef.current,\n ...inputProps,\n tabIndex: -1,\n ref,\n style: {\n ...props.style,\n ...controlSize,\n position: \"absolute\",\n pointerEvents: \"none\",\n opacity: 0,\n margin: 0\n }\n }\n );\n};\nfunction isIndeterminate(checked) {\n return checked === \"indeterminate\";\n}\nfunction getState(checked) {\n return isIndeterminate(checked) ? \"indeterminate\" : checked ? \"checked\" : \"unchecked\";\n}\nvar Root = Checkbox;\nvar Indicator = CheckboxIndicator;\nexport {\n Checkbox,\n CheckboxIndicator,\n Indicator,\n Root,\n createCheckboxScope\n};\n//# sourceMappingURL=index.mjs.map\n","\"use client\";\r\n\r\nimport * as React from \"react\";\r\nimport * as CheckboxPrimitive from \"@radix-ui/react-checkbox\";\r\nimport { Check } from \"lucide-react\";\r\n\r\nimport { cn } from \"../../utils/utils\";\r\n\r\nconst Checkbox = React.forwardRef<\r\n React.ElementRef<typeof CheckboxPrimitive.Root>,\r\n React.ComponentPropsWithoutRef<typeof CheckboxPrimitive.Root>\r\n>(({ className, ...props }, ref) => (\r\n <CheckboxPrimitive.Root\r\n ref={ref}\r\n className={cn(\r\n \"peer h-4 w-4 shrink-0 rounded-sm border border-primary ring-offset-ring focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground\",\r\n className\r\n )}\r\n {...props}\r\n >\r\n <CheckboxPrimitive.Indicator\r\n className={cn(\"flex items-center justify-center text-current\")}\r\n >\r\n <Check className=\"h-4 w-4\" />\r\n </CheckboxPrimitive.Indicator>\r\n </CheckboxPrimitive.Root>\r\n));\r\nCheckbox.displayName = CheckboxPrimitive.Root.displayName;\r\n\r\nexport { Checkbox };\r\n"],"names":["Checkbox","CheckboxPrimitive.Root","CheckboxPrimitive.Indicator"],"mappings":";;;;;;;;;;;AAaA,IAAI,gBAAgB;AACpB,IAAI,CAAC,uBAAuB,mBAAmB,IAAI,mBAAmB,aAAa;AACnF,IAAI,CAAC,kBAAkB,kBAAkB,IAAI,sBAAsB,aAAa;AAChF,IAAIA,aAAW,MAAM;AAAA,EACnB,CAAC,OAAO,iBAAiB;AACvB,UAAM;AAAA,MACJ;AAAA,MACA;AAAA,MACA,SAAS;AAAA,MACT;AAAA,MACA;AAAA,MACA;AAAA,MACA,QAAQ;AAAA,MACR;AA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BAAC,OAAM,EAAA,WAAU,UAAU,CAAA;AAAA,MAAA;AAAA,IAC7B;AAAA,EAAA;AACF,CACD;AACD,SAAS,cAAcD,KAAuB;","x_google_ignoreList":[0]}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
2
|
import * as React from "react";
|
|
3
3
|
import React__default from "react";
|
|
4
|
-
import { R as Root, P as Portal, O as Overlay, C as Content, D as Dialog, e as DialogContent } from "../../Dialog-
|
|
4
|
+
import { R as Root, P as Portal, O as Overlay, C as Content, D as Dialog, e as DialogContent } from "../../Dialog-BtXGfOmv.js";
|
|
5
5
|
import { P as Primitive } from "../../index-B761_inZ.js";
|
|
6
|
-
import {
|
|
6
|
+
import { u as useId } from "../../index-Deoi9R3y.js";
|
|
7
7
|
import { cn } from "../../utils/utils.js";
|
|
8
8
|
import { c as createLucideIcon } from "../../createLucideIcon-KSoQd4Wi.js";
|
|
9
9
|
/**
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
2
|
import * as React from "react";
|
|
3
|
-
import { c as createContextScope,
|
|
3
|
+
import { c as createContextScope, b as composeEventHandlers } from "../../index-CDCkSjVs.js";
|
|
4
4
|
import { u as useComposedRefs, S as Slot } from "../../index-D9mvqz1C.js";
|
|
5
|
-
import { D as DismissableLayer } from "../../index-
|
|
6
|
-
import { h as hideOthers, R as ReactRemoveScroll, u as useFocusGuards, F as FocusScope, P as Portal$1 } from "../../index-
|
|
7
|
-
import { u as
|
|
8
|
-
import { c as createPopperScope, A as Anchor, C as Content, a as Arrow, R as Root2$1 } from "../../index-
|
|
9
|
-
import { P as Presence } from "../../index-
|
|
5
|
+
import { D as DismissableLayer } from "../../index-CAxGI0Uw.js";
|
|
6
|
+
import { h as hideOthers, R as ReactRemoveScroll, u as useFocusGuards, F as FocusScope, P as Portal$1 } from "../../index-CDlDRp01.js";
|
|
7
|
+
import { u as useId } from "../../index-Deoi9R3y.js";
|
|
8
|
+
import { c as createPopperScope, A as Anchor, C as Content, a as Arrow, R as Root2$1 } from "../../index-DjvLSytK.js";
|
|
9
|
+
import { P as Presence } from "../../index-CA2QNu6z.js";
|
|
10
10
|
import { P as Primitive } from "../../index-B761_inZ.js";
|
|
11
|
+
import { u as useControllableState } from "../../index-DFSwSCB0.js";
|
|
11
12
|
import { cn } from "../../utils/utils.js";
|
|
12
13
|
var POPOVER_NAME = "Popover";
|
|
13
14
|
var [createPopoverContext, createPopoverScope] = createContextScope(POPOVER_NAME, [
|