@zauru-sdk/components 1.0.112 → 1.0.114

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (41) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/dist/Form/ReactZodForm/index.d.ts +1 -0
  3. package/dist/HOC/ValidateEmployeeAccess/index.d.ts +5 -0
  4. package/dist/Layouts/errorLayout/index.d.ts +1 -0
  5. package/dist/Layouts/index.d.ts +1 -0
  6. package/dist/SidePanel/index.d.ts +21 -0
  7. package/dist/cjs/Buttons/Button.js +7 -7
  8. package/dist/cjs/Form/DatePicker/index.js +1 -1
  9. package/dist/cjs/Form/ReactZodForm/index.js +2 -4
  10. package/dist/cjs/Form/SelectField/index.js +29 -12
  11. package/dist/cjs/Form/TextField/index.js +10 -16
  12. package/dist/cjs/Form/TimePicker/index.js +1 -1
  13. package/dist/cjs/HOC/ValidateEmployeeAccess/index.js +17 -0
  14. package/dist/cjs/Layouts/errorLayout/index.js +14 -0
  15. package/dist/cjs/Layouts/index.js +1 -0
  16. package/dist/cjs/SidePanel/index.js +48 -0
  17. package/dist/cjs/index.js +2 -0
  18. package/dist/esm/Buttons/Button.js +7 -7
  19. package/dist/esm/Form/DatePicker/index.js +2 -2
  20. package/dist/esm/Form/ReactZodForm/index.js +2 -4
  21. package/dist/esm/Form/SelectField/index.js +30 -13
  22. package/dist/esm/Form/TextField/index.js +10 -16
  23. package/dist/esm/Form/TimePicker/index.js +1 -1
  24. package/dist/esm/HOC/ValidateEmployeeAccess/index.js +13 -0
  25. package/dist/esm/Layouts/errorLayout/index.js +10 -0
  26. package/dist/esm/Layouts/index.js +1 -0
  27. package/dist/esm/SidePanel/index.js +46 -0
  28. package/dist/esm/index.js +2 -0
  29. package/dist/index.d.ts +2 -0
  30. package/package.json +4 -4
  31. package/src/Buttons/Button.tsx +29 -28
  32. package/src/Form/DatePicker/index.tsx +2 -2
  33. package/src/Form/ReactZodForm/index.tsx +4 -2
  34. package/src/Form/SelectField/index.tsx +54 -36
  35. package/src/Form/TextField/index.tsx +14 -17
  36. package/src/Form/TimePicker/index.tsx +1 -1
  37. package/src/HOC/ValidateEmployeeAccess/index.tsx +51 -0
  38. package/src/Layouts/errorLayout/index.tsx +47 -0
  39. package/src/Layouts/index.ts +1 -0
  40. package/src/SidePanel/index.tsx +153 -0
  41. package/src/index.ts +2 -0
package/CHANGELOG.md CHANGED
@@ -3,6 +3,22 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [1.0.114](https://github.com/intuitiva/zauru-typescript-sdk/compare/v1.0.113...v1.0.114) (2024-09-25)
7
+
8
+ **Note:** Version bump only for package @zauru-sdk/components
9
+
10
+
11
+
12
+
13
+
14
+ ## [1.0.113](https://github.com/intuitiva/zauru-typescript-sdk/compare/v1.0.112...v1.0.113) (2024-09-25)
15
+
16
+ **Note:** Version bump only for package @zauru-sdk/components
17
+
18
+
19
+
20
+
21
+
6
22
  ## [1.0.112](https://github.com/intuitiva/zauru-typescript-sdk/compare/v1.0.111...v1.0.112) (2024-09-19)
7
23
 
8
24
  **Note:** Version bump only for package @zauru-sdk/components
@@ -7,6 +7,7 @@ type Props = {
7
7
  onSubmit?: SubmitHandler<FieldValues>;
8
8
  id?: string;
9
9
  method?: "post" | "put" | "delete" | "patch";
10
+ className?: string;
10
11
  };
11
12
  export declare const ReactZodForm: (props: Props) => import("react/jsx-runtime").JSX.Element;
12
13
  export default ReactZodForm;
@@ -0,0 +1,5 @@
1
+ export declare const ValidateEmployeeAccess: ({ children, permissionVariableName, showIfNoPermission, }: {
2
+ children: React.ReactNode;
3
+ permissionVariableName: string;
4
+ showIfNoPermission?: boolean | undefined;
5
+ }) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1 @@
1
+ export declare const ErrorLayout: () => import("react/jsx-runtime").JSX.Element;
@@ -1 +1,2 @@
1
1
  export * from "./homeLayout/index.js";
2
+ export * from "./errorLayout/index.js";
@@ -0,0 +1,21 @@
1
+ import React, { ReactNode } from "react";
2
+ /**
3
+ * SidePanel Component
4
+ *
5
+ * This component creates a collapsible side panel that can be toggled open and closed.
6
+ *
7
+ * @param {ReactNode} children - The content to be displayed inside the side panel.
8
+ * @param {boolean} [closeOnClickOutside=true] - If true, the panel will close when clicking outside of it.
9
+ * @param {number} [widthPercentage=25] - The width of the panel as a percentage of the viewport width.
10
+ * @param {string} [buttonIcon="chevron"] - The icon to use for the toggle button. Can be "chevron", "filter", or a custom ReactNode.
11
+ *
12
+ * @returns A toggleable side panel component.
13
+ */
14
+ interface SidePanelProps {
15
+ children: ReactNode;
16
+ closeOnClickOutside?: boolean;
17
+ widthPercentage?: number;
18
+ buttonIcon?: "chevron" | "filter" | ReactNode;
19
+ }
20
+ declare const SidePanel: React.FC<SidePanelProps>;
21
+ export default SidePanel;
@@ -49,13 +49,13 @@ const Button = (props) => {
49
49
  .map((error) => error?.message?.toString())
50
50
  .join(", ")
51
51
  : "";
52
- const buttonContent = ((0, jsx_runtime_1.jsx)("button", { type: type, name: "action", disabled: loading || disabled || (enableFormErrorsValidation && formHasErrors), value: name, onClick: onClickSave, className: `ml-2 ${loading || disabled || (enableFormErrorsValidation && formHasErrors)
53
- ? " bg-opacity-25 "
54
- : ""} ${loading
55
- ? " cursor-progress"
56
- : `${disabled || (enableFormErrorsValidation && formHasErrors)
57
- ? ""
58
- : `hover:${color.bg700}`}`} inline-flex justify-center rounded-md border border-transparent ${color.bg600} py-2 px-4 text-sm font-medium text-white shadow-sm focus:outline-none focus:ring-2 focus:${color.ring500} focus:ring-offset-2 ${className}`, children: loading ? loadingText : inside }));
52
+ const buttonContent = ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("input", { type: "hidden", name: "action", value: name }), (0, jsx_runtime_1.jsx)("button", { type: type, disabled: loading || disabled || (enableFormErrorsValidation && formHasErrors), onClick: onClickSave, className: `ml-2 ${loading || disabled || (enableFormErrorsValidation && formHasErrors)
53
+ ? " bg-opacity-25 "
54
+ : ""} ${loading
55
+ ? " cursor-progress"
56
+ : `${disabled || (enableFormErrorsValidation && formHasErrors)
57
+ ? ""
58
+ : `hover:${color.bg700}`}`} inline-flex justify-center rounded-md border border-transparent ${color.bg600} py-2 px-4 text-sm font-medium text-white shadow-sm focus:outline-none focus:ring-2 focus:${color.ring500} focus:ring-offset-2 ${className}`, children: loading ? loadingText : inside })] }));
59
59
  return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(enableFormErrorsValidation && formHasErrors && errorMessage) ||
60
60
  (enableFormErrorsDescriptions && errorMessage) ? ((0, jsx_runtime_1.jsx)("div", { className: "flex flex-col items-end mb-2", children: (0, jsx_runtime_1.jsx)("div", { className: "p-2 bg-red-100 border border-red-400 text-red-700 rounded-md shadow-sm", children: (0, jsx_runtime_1.jsx)("p", { className: "text-sm", children: errorMessage }) }) })) : null, buttonContent] }));
61
61
  };
@@ -26,7 +26,7 @@ const FormDatePicker = (props) => {
26
26
  setValue("");
27
27
  onChange && onChange("");
28
28
  };
29
- return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [title && ((0, jsx_runtime_1.jsxs)("label", { htmlFor: error ? `${name}-error` : `${name}-success`, className: `block text-sm font-medium ${textColor} ${className}`, children: [title, required && (0, jsx_runtime_1.jsx)("span", { className: "text-red-500", children: "*" })] })), (0, jsx_runtime_1.jsxs)("div", { className: "flex relative items-center", children: [(0, jsx_runtime_1.jsx)("div", { className: "absolute left-0 flex items-center pl-3 pointer-events-none", children: (0, jsx_runtime_1.jsx)(icons_1.CalendarIconSVG, {}) }), (0, jsx_runtime_1.jsx)("input", { id: id, tabIndex: tabIndex, type: "date", value: value ?? "", pattern: "\\d{4}-\\d{2}-\\d{2}", className: `${bgColor} ${borderColor} ${textColor} text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full pl-10 p-2.5`, ...(register ?? {}), name: name, onChange: (e) => {
29
+ return ((0, jsx_runtime_1.jsxs)("div", { children: [title && ((0, jsx_runtime_1.jsxs)("label", { htmlFor: error ? `${name}-error` : `${name}-success`, className: `block text-sm font-medium ${textColor} ${className}`, children: [title, required && (0, jsx_runtime_1.jsx)("span", { className: "text-red-500", children: "*" })] })), (0, jsx_runtime_1.jsxs)("div", { className: "flex relative items-center", children: [(0, jsx_runtime_1.jsx)("div", { className: "absolute left-0 flex items-center pl-3 pointer-events-none", children: (0, jsx_runtime_1.jsx)(icons_1.CalendarIconSVG, {}) }), (0, jsx_runtime_1.jsx)("input", { id: id, tabIndex: tabIndex, type: "date", value: value ?? "", pattern: "\\d{4}-\\d{2}-\\d{2}", className: `${bgColor} ${borderColor} ${textColor} text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full pl-10 p-2.5`, ...(register ?? {}), name: name, onChange: (e) => {
30
30
  setValue(e.target.value);
31
31
  onChange && onChange(e.target.value);
32
32
  if (register) {
@@ -8,7 +8,7 @@ const react_hook_form_1 = require("react-hook-form");
8
8
  const zod_2 = require("zod");
9
9
  const emptySchema = zod_2.z.any();
10
10
  const ReactZodForm = (props) => {
11
- const { children, method = "post", schema = emptySchema, onSubmit, id, } = props;
11
+ const { children, method = "post", schema = emptySchema, onSubmit, id, className, } = props;
12
12
  const submit = (0, react_1.useSubmit)();
13
13
  const methods = (0, react_hook_form_1.useForm)({
14
14
  resolver: (0, zod_1.zodResolver)(schema),
@@ -23,9 +23,7 @@ const ReactZodForm = (props) => {
23
23
  submit(event?.target, { method });
24
24
  }
25
25
  };
26
- return ((0, jsx_runtime_1.jsx)(react_hook_form_1.FormProvider, { ...methods, children: (0, jsx_runtime_1.jsx)(react_1.Form, { onSubmit: onSubmit ? methods.handleSubmit(onSubmit) : undefined,
27
- //onSubmit={methods.handleSubmit(handleSubmit)}
28
- method: method, id: id, children: children }) }));
26
+ return ((0, jsx_runtime_1.jsx)(react_hook_form_1.FormProvider, { ...methods, children: (0, jsx_runtime_1.jsx)(react_1.Form, { onSubmit: methods.handleSubmit(handleSubmit), method: method, id: id, className: className, children: children }) }));
29
27
  };
30
28
  exports.ReactZodForm = ReactZodForm;
31
29
  exports.default = exports.ReactZodForm;
@@ -7,7 +7,7 @@ const react_1 = require("react");
7
7
  const index_js_1 = require("../../Skeletons/index.js");
8
8
  const react_hook_form_1 = require("react-hook-form");
9
9
  const SelectField = (props) => {
10
- const { id, name, title, defaultValue, defaultValueMulti = [], helpText, hint, options, onChange, onChangeMulti, isClearable = false, disabled = false, readOnly = false, isMulti = false, loading = false, className = "", onInputChange, required, } = props;
10
+ const { id, name, title, defaultValue, defaultValueMulti = [], helpText, hint, options, onChange, onChangeMulti, isClearable = false, disabled = false, readOnly = false, isMulti = false, loading = false, className = "", onInputChange, required = false, } = props;
11
11
  const [value, setValue] = (0, react_1.useState)(defaultValue || null);
12
12
  const [valueMulti, setValueMulti] = (0, react_1.useState)(defaultValueMulti);
13
13
  const [inputValue, setInputValue] = (0, react_1.useState)(defaultValue?.label || "");
@@ -20,13 +20,18 @@ const SelectField = (props) => {
20
20
  const [isTabPressed, setIsTabPressed] = (0, react_1.useState)(false);
21
21
  const [isEnterPressed, setIsEnterPressed] = (0, react_1.useState)(false);
22
22
  const [isSearching, setIsSearching] = (0, react_1.useState)(false);
23
- const { control, formState: { errors }, setValue: setFormValue, } = (0, react_hook_form_1.useFormContext)() || { formState: {} };
23
+ const { register: tempRegister, formState: { errors }, setValue: setFormValue, } = (0, react_hook_form_1.useFormContext)() || { formState: {} };
24
24
  const error = errors ? errors[props.name ?? "-1"] : undefined;
25
+ const register = tempRegister
26
+ ? tempRegister(props.name ?? "-1", {
27
+ required,
28
+ })
29
+ : undefined; // Solo usar register si está disponible
25
30
  const color = error ? "red" : "gray";
26
31
  const isReadOnly = disabled || readOnly;
27
32
  const bgColor = isReadOnly ? "bg-gray-200" : `bg-${color}-50`;
28
33
  const textColor = isReadOnly ? "text-gray-500" : `text-${color}-900`;
29
- const borderColor = isReadOnly ? "border-gray-300" : `border-${color}-500`;
34
+ const borderColor = isReadOnly ? "border-gray-300" : `border-${color}-200`;
30
35
  (0, react_1.useEffect)(() => {
31
36
  setFilteredOptions(options);
32
37
  }, [options]);
@@ -40,7 +45,9 @@ const SelectField = (props) => {
40
45
  if (defaultValue) {
41
46
  setValue(defaultValue);
42
47
  setInputValue(defaultValue.label);
43
- setFormValue(name || "", defaultValue);
48
+ if (setFormValue) {
49
+ setFormValue(name || "", defaultValue.value);
50
+ }
44
51
  }
45
52
  document.addEventListener("mousedown", handleClickOutside);
46
53
  return () => {
@@ -49,6 +56,9 @@ const SelectField = (props) => {
49
56
  }, []);
50
57
  const handleInputChange = (e) => {
51
58
  const newValue = e.target.value;
59
+ if (register) {
60
+ register.onChange(e);
61
+ }
52
62
  setInputValue(newValue);
53
63
  onInputChange && onInputChange(newValue);
54
64
  setIsSearching(true);
@@ -61,13 +71,17 @@ const SelectField = (props) => {
61
71
  : [...valueMulti, option];
62
72
  setValueMulti(newValue);
63
73
  onChangeMulti && onChangeMulti(newValue);
64
- setFormValue(name || "", newValue);
74
+ if (setFormValue) {
75
+ setFormValue(name || "", newValue.map((v) => v.value));
76
+ }
65
77
  }
66
78
  else {
67
79
  setValue(option);
68
80
  setInputValue(option.label);
69
81
  onChange && onChange(option);
70
- setFormValue(name || "", option);
82
+ if (setFormValue) {
83
+ setFormValue(name || "", option.value);
84
+ }
71
85
  }
72
86
  setIsOpen(false);
73
87
  };
@@ -75,12 +89,16 @@ const SelectField = (props) => {
75
89
  if (isMulti) {
76
90
  setValueMulti([]);
77
91
  onChangeMulti && onChangeMulti([]);
78
- setFormValue(name || "", []);
92
+ if (setFormValue) {
93
+ setFormValue(name || "", []);
94
+ }
79
95
  }
80
96
  else {
81
97
  setValue(null);
82
98
  onChange && onChange(null);
83
- setFormValue(name || "", null);
99
+ if (setFormValue) {
100
+ setFormValue(name || "", "");
101
+ }
84
102
  }
85
103
  setInputValue("");
86
104
  };
@@ -145,10 +163,9 @@ const SelectField = (props) => {
145
163
  }
146
164
  return ((0, jsx_runtime_1.jsxs)("div", { className: `col-span-6 sm:col-span-3 ${className}`, ref: selectRef, children: [title && ((0, jsx_runtime_1.jsxs)("label", { htmlFor: error ? `${name}-error` : `${name}-success`, className: `block text-sm font-medium ${color === "red"
147
165
  ? "text-red-700 dark:text-red-500"
148
- : "text-gray-700 dark:text-gray-500"}`, children: [title, required && (0, jsx_runtime_1.jsx)("span", { className: "text-red-500", children: "*" })] })), (0, jsx_runtime_1.jsxs)("div", { className: "relative", children: [(0, jsx_runtime_1.jsx)(react_hook_form_1.Controller, { name: name || "", control: control, rules: { required }, defaultValue: defaultValue || (isMulti ? [] : null), render: ({ field }) => ((0, jsx_runtime_1.jsx)("input", { ...field, type: "text", id: id, value: inputValue, onFocus: () => setIsOpen(true), onBlur: handleBlur, onKeyDown: handleKeyDown, readOnly: isReadOnly, disabled: disabled, className: `block w-full rounded-md ${bgColor} ${borderColor} ${textColor} shadow-sm focus:border-indigo-500 focus:ring-indigo-500 sm:text-sm`, placeholder: isMulti ? "Select options..." : "Select an option...", onChange: (e) => {
149
- field.onChange(e);
150
- handleInputChange(e);
151
- }, autoComplete: "off" })) }), isClearable && (value || valueMulti.length > 0) && ((0, jsx_runtime_1.jsx)("button", { type: "button", onClick: handleClear, className: "absolute inset-y-0 right-0 pr-3 flex items-center", children: "\u00D7" })), isOpen && !isReadOnly && ((0, jsx_runtime_1.jsx)("ul", { ref: optionsRef, className: "absolute z-10 mt-1 w-full bg-white shadow-lg max-h-60 rounded-md py-1 text-base ring-1 ring-black ring-opacity-5 overflow-auto focus:outline-none sm:text-sm", children: filteredOptions.map((option, index) => ((0, jsx_runtime_1.jsx)("li", { className: `cursor-pointer select-none relative py-2 pl-3 pr-9 ${(isMulti
166
+ : "text-gray-700 dark:text-gray-500"}`, children: [title, required && (0, jsx_runtime_1.jsx)("span", { className: "text-red-500", children: "*" })] })), (0, jsx_runtime_1.jsxs)("div", { className: "relative", children: [(0, jsx_runtime_1.jsx)("input", { type: "text", id: id, value: inputValue, onFocus: () => setIsOpen(true), onKeyDown: handleKeyDown, readOnly: isReadOnly, disabled: disabled, className: `block w-full rounded-md ${bgColor} ${borderColor} ${textColor} shadow-sm focus:border-indigo-500 focus:ring-indigo-500 sm:text-sm`, placeholder: isMulti ? "Select options..." : "Select an option...", autoComplete: "off", onChange: handleInputChange, onBlur: handleBlur, required: required }), (0, jsx_runtime_1.jsx)("input", { type: "hidden", ...(register ?? {}), name: name, value: isMulti
167
+ ? valueMulti.map((v) => v.value).join(",")
168
+ : value?.value || "" }), isClearable && (value || valueMulti.length > 0) && ((0, jsx_runtime_1.jsx)("button", { type: "button", onClick: handleClear, className: "absolute inset-y-0 right-0 pr-3 flex items-center", children: "\u00D7" })), isOpen && !isReadOnly && ((0, jsx_runtime_1.jsx)("ul", { ref: optionsRef, className: "absolute z-10 mt-1 w-full bg-white shadow-lg max-h-60 rounded-md py-1 text-base ring-1 ring-black ring-opacity-5 overflow-auto focus:outline-none sm:text-sm", children: filteredOptions.map((option, index) => ((0, jsx_runtime_1.jsx)("li", { className: `cursor-pointer select-none relative py-2 pl-3 pr-9 ${(isMulti
152
169
  ? valueMulti.some((v) => v.value === option.value)
153
170
  : value?.value === option.value)
154
171
  ? "text-white bg-indigo-600"
@@ -9,7 +9,7 @@ const TextField = (props) => {
9
9
  const { id, name, defaultValue = "", hidden, type = "text", onChange, onKeyDown, disabled = false, readOnly = false, min, integer = false, stopChangeEvents, style, title, helpText, className, hint, required, } = props;
10
10
  const [showTooltip, setShowTooltip] = (0, react_1.useState)(false);
11
11
  const [value, setValue] = (0, react_1.useState)(defaultValue);
12
- const { register: tempRegister, formState: { errors }, } = (0, react_hook_form_1.useFormContext)() || { formState: {} }; // Obtener el contexto solo si existe
12
+ const { register: tempRegister, formState: { errors }, setValue: setOnFormValue, } = (0, react_hook_form_1.useFormContext)() || { formState: {} }; // Obtener el contexto solo si existe
13
13
  const error = errors ? errors[props.name ?? "-1"] : undefined;
14
14
  const register = tempRegister
15
15
  ? tempRegister(props.name ?? "-1", {
@@ -21,11 +21,15 @@ const TextField = (props) => {
21
21
  const isReadOnly = disabled || readOnly;
22
22
  const bgColor = isReadOnly ? "bg-gray-200" : `bg-${color}-50`;
23
23
  const textColor = isReadOnly ? "text-gray-500" : `text-${color}-900`;
24
- const borderColor = isReadOnly ? "border-gray-300" : `border-${color}-500`;
24
+ const borderColor = isReadOnly ? "border-gray-300" : `border-${color}-200`;
25
25
  (0, react_1.useEffect)(() => {
26
+ if (setOnFormValue) {
27
+ setOnFormValue(name ?? "-1", defaultValue);
28
+ }
26
29
  setValue(defaultValue);
27
30
  }, [defaultValue]);
28
31
  const handleInputChange = (event) => {
32
+ const newValue = event.target.value;
29
33
  if (register) {
30
34
  register.onChange(event);
31
35
  }
@@ -33,18 +37,8 @@ const TextField = (props) => {
33
37
  event.stopPropagation();
34
38
  event.preventDefault();
35
39
  }
36
- if (integer && type === "number") {
37
- const value = event.target.value;
38
- const isInteger = /^[0-9]*$/.test(value);
39
- if (isInteger || value === "") {
40
- setValue(value);
41
- onChange && onChange(value, event);
42
- }
43
- }
44
- else {
45
- setValue(event.target.value);
46
- onChange && onChange(event.target.value, event);
47
- }
40
+ setValue(newValue);
41
+ onChange && onChange(newValue, event);
48
42
  };
49
43
  const handleKeyDown = (event) => {
50
44
  if (integer && type === "number") {
@@ -63,9 +57,9 @@ const TextField = (props) => {
63
57
  }
64
58
  };
65
59
  if (hidden) {
66
- return ((0, jsx_runtime_1.jsx)("input", { type: "hidden", id: id ?? name, value: value, readOnly: true, hidden: true, ...(register ?? {}), name: name, onChange: handleInputChange }));
60
+ return ((0, jsx_runtime_1.jsx)("input", { type: type, id: id ?? name, value: value, hidden: true, ...(register ?? {}), name: name, onChange: handleInputChange }));
67
61
  }
68
- const inputComponent = ((0, jsx_runtime_1.jsx)("input", { type: type, readOnly: readOnly, disabled: disabled, id: id ?? name, autoComplete: "given-name", value: value, onWheel: (e) => {
62
+ const inputComponent = ((0, jsx_runtime_1.jsx)("input", { type: type, readOnly: isReadOnly, disabled: disabled, id: id ?? name, autoComplete: "off", value: value, onWheel: (e) => {
69
63
  e.currentTarget.blur();
70
64
  }, step: type === "number" ? 0.01 : undefined, onKeyDown: (event) => {
71
65
  handleKeyDown(event);
@@ -17,7 +17,7 @@ const FormTimePicker = (props) => {
17
17
  const color = error ? "red" : "gray";
18
18
  const isReadOnly = disabled;
19
19
  const bgColor = isReadOnly ? "bg-gray-200" : `bg-${color}-50`;
20
- const textColor = isReadOnly ? "text-gray-500" : `text-${color}-500`;
20
+ const textColor = isReadOnly ? "text-gray-500" : `text-${color}-900`;
21
21
  const borderColor = isReadOnly ? "border-gray-300" : `border-${color}-200`;
22
22
  (0, react_1.useEffect)(() => {
23
23
  setValue(defaultValue);
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ValidateEmployeeAccess = void 0;
4
+ const jsx_runtime_1 = require("react/jsx-runtime");
5
+ const hooks_1 = require("@zauru-sdk/hooks");
6
+ const react_1 = require("@remix-run/react");
7
+ const ValidateEmployeeAccess = ({ children, permissionVariableName, showIfNoPermission = false, }) => {
8
+ const { data: employee } = (0, hooks_1.useGetEmployeeProfile)();
9
+ const variable_string = (0, hooks_1.useGetSessionAttribute)(permissionVariableName, "sessionVariable");
10
+ const variable = variable_string?.split(",");
11
+ const hasPermission = variable?.includes(employee?.id?.toString() || "-1");
12
+ if (showIfNoPermission && !hasPermission) {
13
+ return ((0, jsx_runtime_1.jsxs)("div", { className: "bg-gray-900 text-white min-h-screen flex flex-col items-center justify-center p-4", children: [(0, jsx_runtime_1.jsx)("img", { src: "/logo.png", alt: "Zauru Logo", className: "mb-8 h-20" }), (0, jsx_runtime_1.jsx)("h1", { className: "text-5xl font-extrabold text-red-500 mb-6", children: "\u00A1Acceso Denegado!" }), (0, jsx_runtime_1.jsx)("div", { className: "w-full max-w-2xl", children: (0, jsx_runtime_1.jsx)("p", { className: "text-2xl text-gray-300 mb-8 text-center", children: "Lo sentimos, no tienes permiso para acceder a esta p\u00E1gina." }) }), (0, jsx_runtime_1.jsx)(react_1.Link, { to: "/", className: "bg-blue-600 text-white py-3 px-8 rounded-full text-lg font-semibold hover:bg-blue-700 transition duration-300 transform hover:scale-105", children: "Regresar al inicio" }), (0, jsx_runtime_1.jsx)("div", { className: "mt-12 text-gray-500", children: (0, jsx_runtime_1.jsx)("p", { children: "Si crees que esto es un error, por favor contacta a soporte." }) })] }));
14
+ }
15
+ return (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: hasPermission ? children : null });
16
+ };
17
+ exports.ValidateEmployeeAccess = ValidateEmployeeAccess;
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ErrorLayout = void 0;
4
+ const jsx_runtime_1 = require("react/jsx-runtime");
5
+ const react_1 = require("@remix-run/react");
6
+ const ErrorLayout = () => {
7
+ const error = (0, react_1.useRouteError)();
8
+ return ((0, jsx_runtime_1.jsxs)("html", { lang: "es", className: "bg-gray-900 text-white", children: [(0, jsx_runtime_1.jsxs)("head", { children: [(0, jsx_runtime_1.jsx)("meta", { charSet: "utf-8" }), (0, jsx_runtime_1.jsx)("meta", { name: "viewport", content: "width=device-width, initial-scale=1" }), (0, jsx_runtime_1.jsx)("title", { children: "\u00A1Ups! Algo sali\u00F3 mal" }), (0, jsx_runtime_1.jsx)(react_1.Meta, {}), (0, jsx_runtime_1.jsx)(react_1.Links, {})] }), (0, jsx_runtime_1.jsxs)("body", { className: "min-h-screen flex flex-col items-center justify-center p-4", children: [(0, jsx_runtime_1.jsx)("img", { src: "/logo.png", alt: "Zauru Logo", className: "mb-8 h-20" }), (0, jsx_runtime_1.jsx)("h1", { className: "text-5xl font-extrabold text-red-500 mb-6", children: "\u00A1Ups!" }), (0, jsx_runtime_1.jsx)("div", { className: "w-full max-w-2xl", children: (0, jsx_runtime_1.jsx)("p", { className: "text-2xl text-gray-300 mb-8 text-center", children: (0, react_1.isRouteErrorResponse)(error)
9
+ ? `Error ${error.status}: ${error.statusText}`
10
+ : error instanceof Error
11
+ ? error.message
12
+ : "Ha ocurrido un error inesperado" }) }), (0, jsx_runtime_1.jsx)(react_1.Link, { to: "/", className: "bg-blue-600 text-white py-3 px-8 rounded-full text-lg font-semibold hover:bg-blue-700 transition duration-300 transform hover:scale-105", children: "Regresar al inicio" }), (0, jsx_runtime_1.jsx)("div", { className: "mt-12 text-gray-500", children: (0, jsx_runtime_1.jsx)("p", { children: "Si el problema persiste, por favor contacta a soporte." }) }), (0, jsx_runtime_1.jsx)(react_1.Scripts, {})] })] }));
13
+ };
14
+ exports.ErrorLayout = ErrorLayout;
@@ -15,3 +15,4 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./homeLayout/index.js"), exports);
18
+ __exportStar(require("./errorLayout/index.js"), exports);
@@ -0,0 +1,48 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const jsx_runtime_1 = require("react/jsx-runtime");
4
+ const react_1 = require("react");
5
+ const framer_motion_1 = require("framer-motion");
6
+ // SVG icon for the left-pointing chevron
7
+ const ChevronLeftIcon = () => ((0, jsx_runtime_1.jsx)("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", className: "h-6 w-6", children: (0, jsx_runtime_1.jsx)("path", { fillRule: "evenodd", d: "M7.72 12.53a.75.75 0 010-1.06l7.5-7.5a.75.75 0 111.06 1.06L9.31 12l6.97 6.97a.75.75 0 11-1.06 1.06l-7.5-7.5z", clipRule: "evenodd" }) }));
8
+ // SVG icon for the right-pointing chevron
9
+ const ChevronRightIcon = () => ((0, jsx_runtime_1.jsx)("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", className: "h-6 w-6", children: (0, jsx_runtime_1.jsx)("path", { fillRule: "evenodd", d: "M16.28 11.47a.75.75 0 010 1.06l-7.5 7.5a.75.75 0 01-1.06-1.06L14.69 12 7.72 5.03a.75.75 0 011.06-1.06l7.5 7.5z", clipRule: "evenodd" }) }));
10
+ // SVG icon for the filter (bars filter icon)
11
+ const FilterIcon = () => ((0, jsx_runtime_1.jsx)("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", className: "h-6 w-6", children: (0, jsx_runtime_1.jsx)("path", { fillRule: "evenodd", d: "M3 6a1 1 0 011-1h16a1 1 0 110 2H4a1 1 0 01-1-1zm0 6a1 1 0 011-1h10a1 1 0 110 2H4a1 1 0 01-1-1zm0 6a1 1 0 011-1h4a1 1 0 110 2H4a1 1 0 01-1-1z", clipRule: "evenodd" }) }));
12
+ const SidePanel = ({ children, closeOnClickOutside = true, widthPercentage = 25, buttonIcon = "chevron", }) => {
13
+ const [isOpen, setIsOpen] = (0, react_1.useState)(false);
14
+ const panelRef = (0, react_1.useRef)(null);
15
+ const togglePanel = () => {
16
+ setIsOpen(!isOpen);
17
+ };
18
+ (0, react_1.useEffect)(() => {
19
+ const handleClickOutside = (event) => {
20
+ if (closeOnClickOutside &&
21
+ panelRef.current &&
22
+ !panelRef.current.contains(event.target)) {
23
+ setIsOpen(false);
24
+ }
25
+ };
26
+ document.addEventListener("mousedown", handleClickOutside);
27
+ return () => {
28
+ document.removeEventListener("mousedown", handleClickOutside);
29
+ };
30
+ }, [closeOnClickOutside]);
31
+ const renderIcon = () => {
32
+ if (typeof buttonIcon === "string") {
33
+ switch (buttonIcon) {
34
+ case "chevron":
35
+ return isOpen ? (0, jsx_runtime_1.jsx)(ChevronRightIcon, {}) : (0, jsx_runtime_1.jsx)(ChevronLeftIcon, {});
36
+ case "filter":
37
+ return (0, jsx_runtime_1.jsx)(FilterIcon, {});
38
+ default:
39
+ return (0, jsx_runtime_1.jsx)(ChevronLeftIcon, {});
40
+ }
41
+ }
42
+ else {
43
+ return buttonIcon;
44
+ }
45
+ };
46
+ return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(framer_motion_1.AnimatePresence, { children: isOpen && ((0, jsx_runtime_1.jsxs)(framer_motion_1.motion.div, { ref: panelRef, initial: { x: "100%" }, animate: { x: 0 }, exit: { x: "100%" }, transition: { type: "spring", stiffness: 300, damping: 30 }, className: "fixed top-0 right-0 h-full bg-white shadow-lg z-[9999] overflow-y-auto", style: { width: `${widthPercentage}%` }, children: [(0, jsx_runtime_1.jsx)("button", { onClick: togglePanel, className: "absolute top-4 left-4 p-2 rounded-full bg-gray-200 hover:bg-gray-300 transition-colors", children: (0, jsx_runtime_1.jsx)(ChevronRightIcon, {}) }), (0, jsx_runtime_1.jsx)("div", { className: "p-6 mt-16", children: children })] })) }), !isOpen && ((0, jsx_runtime_1.jsx)("button", { onClick: togglePanel, className: "fixed top-1/2 right-0 transform -translate-y-1/2 bg-indigo-600 text-white p-3 rounded-l-lg shadow-md hover:bg-indigo-700 transition-colors z-[10000]", children: renderIcon() }))] }));
47
+ };
48
+ exports.default = SidePanel;
package/dist/cjs/index.js CHANGED
@@ -39,3 +39,5 @@ __exportStar(require("./Tooltip/index.js"), exports);
39
39
  __exportStar(require("./WithTooltip/index.js"), exports);
40
40
  __exportStar(require("./Wizards/index.js"), exports);
41
41
  __exportStar(require("./Zendesk/index.js"), exports);
42
+ __exportStar(require("./HOC/ValidateEmployeeAccess/index.js"), exports);
43
+ __exportStar(require("./SidePanel/index.js"), exports);
@@ -46,13 +46,13 @@ export const Button = (props) => {
46
46
  .map((error) => error?.message?.toString())
47
47
  .join(", ")
48
48
  : "";
49
- const buttonContent = (_jsx("button", { type: type, name: "action", disabled: loading || disabled || (enableFormErrorsValidation && formHasErrors), value: name, onClick: onClickSave, className: `ml-2 ${loading || disabled || (enableFormErrorsValidation && formHasErrors)
50
- ? " bg-opacity-25 "
51
- : ""} ${loading
52
- ? " cursor-progress"
53
- : `${disabled || (enableFormErrorsValidation && formHasErrors)
54
- ? ""
55
- : `hover:${color.bg700}`}`} inline-flex justify-center rounded-md border border-transparent ${color.bg600} py-2 px-4 text-sm font-medium text-white shadow-sm focus:outline-none focus:ring-2 focus:${color.ring500} focus:ring-offset-2 ${className}`, children: loading ? loadingText : inside }));
49
+ const buttonContent = (_jsxs(_Fragment, { children: [_jsx("input", { type: "hidden", name: "action", value: name }), _jsx("button", { type: type, disabled: loading || disabled || (enableFormErrorsValidation && formHasErrors), onClick: onClickSave, className: `ml-2 ${loading || disabled || (enableFormErrorsValidation && formHasErrors)
50
+ ? " bg-opacity-25 "
51
+ : ""} ${loading
52
+ ? " cursor-progress"
53
+ : `${disabled || (enableFormErrorsValidation && formHasErrors)
54
+ ? ""
55
+ : `hover:${color.bg700}`}`} inline-flex justify-center rounded-md border border-transparent ${color.bg600} py-2 px-4 text-sm font-medium text-white shadow-sm focus:outline-none focus:ring-2 focus:${color.ring500} focus:ring-offset-2 ${className}`, children: loading ? loadingText : inside })] }));
56
56
  return (_jsxs(_Fragment, { children: [(enableFormErrorsValidation && formHasErrors && errorMessage) ||
57
57
  (enableFormErrorsDescriptions && errorMessage) ? (_jsx("div", { className: "flex flex-col items-end mb-2", children: _jsx("div", { className: "p-2 bg-red-100 border border-red-400 text-red-700 rounded-md shadow-sm", children: _jsx("p", { className: "text-sm", children: errorMessage }) }) })) : null, buttonContent] }));
58
58
  };
@@ -1,4 +1,4 @@
1
- import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { useEffect, useState } from "react";
3
3
  import { CalendarIconSVG, CloseSvgIcon, IdeaIconSVG } from "@zauru-sdk/icons";
4
4
  import { useFormContext } from "react-hook-form";
@@ -23,7 +23,7 @@ export const FormDatePicker = (props) => {
23
23
  setValue("");
24
24
  onChange && onChange("");
25
25
  };
26
- return (_jsxs(_Fragment, { children: [title && (_jsxs("label", { htmlFor: error ? `${name}-error` : `${name}-success`, className: `block text-sm font-medium ${textColor} ${className}`, children: [title, required && _jsx("span", { className: "text-red-500", children: "*" })] })), _jsxs("div", { className: "flex relative items-center", children: [_jsx("div", { className: "absolute left-0 flex items-center pl-3 pointer-events-none", children: _jsx(CalendarIconSVG, {}) }), _jsx("input", { id: id, tabIndex: tabIndex, type: "date", value: value ?? "", pattern: "\\d{4}-\\d{2}-\\d{2}", className: `${bgColor} ${borderColor} ${textColor} text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full pl-10 p-2.5`, ...(register ?? {}), name: name, onChange: (e) => {
26
+ return (_jsxs("div", { children: [title && (_jsxs("label", { htmlFor: error ? `${name}-error` : `${name}-success`, className: `block text-sm font-medium ${textColor} ${className}`, children: [title, required && _jsx("span", { className: "text-red-500", children: "*" })] })), _jsxs("div", { className: "flex relative items-center", children: [_jsx("div", { className: "absolute left-0 flex items-center pl-3 pointer-events-none", children: _jsx(CalendarIconSVG, {}) }), _jsx("input", { id: id, tabIndex: tabIndex, type: "date", value: value ?? "", pattern: "\\d{4}-\\d{2}-\\d{2}", className: `${bgColor} ${borderColor} ${textColor} text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full pl-10 p-2.5`, ...(register ?? {}), name: name, onChange: (e) => {
27
27
  setValue(e.target.value);
28
28
  onChange && onChange(e.target.value);
29
29
  if (register) {
@@ -5,7 +5,7 @@ import { FormProvider, useForm, } from "react-hook-form";
5
5
  import { z } from "zod";
6
6
  const emptySchema = z.any();
7
7
  export const ReactZodForm = (props) => {
8
- const { children, method = "post", schema = emptySchema, onSubmit, id, } = props;
8
+ const { children, method = "post", schema = emptySchema, onSubmit, id, className, } = props;
9
9
  const submit = useSubmit();
10
10
  const methods = useForm({
11
11
  resolver: zodResolver(schema),
@@ -20,8 +20,6 @@ export const ReactZodForm = (props) => {
20
20
  submit(event?.target, { method });
21
21
  }
22
22
  };
23
- return (_jsx(FormProvider, { ...methods, children: _jsx(Form, { onSubmit: onSubmit ? methods.handleSubmit(onSubmit) : undefined,
24
- //onSubmit={methods.handleSubmit(handleSubmit)}
25
- method: method, id: id, children: children }) }));
23
+ return (_jsx(FormProvider, { ...methods, children: _jsx(Form, { onSubmit: methods.handleSubmit(handleSubmit), method: method, id: id, className: className, children: children }) }));
26
24
  };
27
25
  export default ReactZodForm;
@@ -2,9 +2,9 @@ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-run
2
2
  import { IdeaIconSVG } from "@zauru-sdk/icons";
3
3
  import { useEffect, useState, useRef } from "react";
4
4
  import { LoadingInputSkeleton } from "../../Skeletons/index.js";
5
- import { useFormContext, Controller } from "react-hook-form";
5
+ import { useFormContext } from "react-hook-form";
6
6
  export const SelectField = (props) => {
7
- const { id, name, title, defaultValue, defaultValueMulti = [], helpText, hint, options, onChange, onChangeMulti, isClearable = false, disabled = false, readOnly = false, isMulti = false, loading = false, className = "", onInputChange, required, } = props;
7
+ const { id, name, title, defaultValue, defaultValueMulti = [], helpText, hint, options, onChange, onChangeMulti, isClearable = false, disabled = false, readOnly = false, isMulti = false, loading = false, className = "", onInputChange, required = false, } = props;
8
8
  const [value, setValue] = useState(defaultValue || null);
9
9
  const [valueMulti, setValueMulti] = useState(defaultValueMulti);
10
10
  const [inputValue, setInputValue] = useState(defaultValue?.label || "");
@@ -17,13 +17,18 @@ export const SelectField = (props) => {
17
17
  const [isTabPressed, setIsTabPressed] = useState(false);
18
18
  const [isEnterPressed, setIsEnterPressed] = useState(false);
19
19
  const [isSearching, setIsSearching] = useState(false);
20
- const { control, formState: { errors }, setValue: setFormValue, } = useFormContext() || { formState: {} };
20
+ const { register: tempRegister, formState: { errors }, setValue: setFormValue, } = useFormContext() || { formState: {} };
21
21
  const error = errors ? errors[props.name ?? "-1"] : undefined;
22
+ const register = tempRegister
23
+ ? tempRegister(props.name ?? "-1", {
24
+ required,
25
+ })
26
+ : undefined; // Solo usar register si está disponible
22
27
  const color = error ? "red" : "gray";
23
28
  const isReadOnly = disabled || readOnly;
24
29
  const bgColor = isReadOnly ? "bg-gray-200" : `bg-${color}-50`;
25
30
  const textColor = isReadOnly ? "text-gray-500" : `text-${color}-900`;
26
- const borderColor = isReadOnly ? "border-gray-300" : `border-${color}-500`;
31
+ const borderColor = isReadOnly ? "border-gray-300" : `border-${color}-200`;
27
32
  useEffect(() => {
28
33
  setFilteredOptions(options);
29
34
  }, [options]);
@@ -37,7 +42,9 @@ export const SelectField = (props) => {
37
42
  if (defaultValue) {
38
43
  setValue(defaultValue);
39
44
  setInputValue(defaultValue.label);
40
- setFormValue(name || "", defaultValue);
45
+ if (setFormValue) {
46
+ setFormValue(name || "", defaultValue.value);
47
+ }
41
48
  }
42
49
  document.addEventListener("mousedown", handleClickOutside);
43
50
  return () => {
@@ -46,6 +53,9 @@ export const SelectField = (props) => {
46
53
  }, []);
47
54
  const handleInputChange = (e) => {
48
55
  const newValue = e.target.value;
56
+ if (register) {
57
+ register.onChange(e);
58
+ }
49
59
  setInputValue(newValue);
50
60
  onInputChange && onInputChange(newValue);
51
61
  setIsSearching(true);
@@ -58,13 +68,17 @@ export const SelectField = (props) => {
58
68
  : [...valueMulti, option];
59
69
  setValueMulti(newValue);
60
70
  onChangeMulti && onChangeMulti(newValue);
61
- setFormValue(name || "", newValue);
71
+ if (setFormValue) {
72
+ setFormValue(name || "", newValue.map((v) => v.value));
73
+ }
62
74
  }
63
75
  else {
64
76
  setValue(option);
65
77
  setInputValue(option.label);
66
78
  onChange && onChange(option);
67
- setFormValue(name || "", option);
79
+ if (setFormValue) {
80
+ setFormValue(name || "", option.value);
81
+ }
68
82
  }
69
83
  setIsOpen(false);
70
84
  };
@@ -72,12 +86,16 @@ export const SelectField = (props) => {
72
86
  if (isMulti) {
73
87
  setValueMulti([]);
74
88
  onChangeMulti && onChangeMulti([]);
75
- setFormValue(name || "", []);
89
+ if (setFormValue) {
90
+ setFormValue(name || "", []);
91
+ }
76
92
  }
77
93
  else {
78
94
  setValue(null);
79
95
  onChange && onChange(null);
80
- setFormValue(name || "", null);
96
+ if (setFormValue) {
97
+ setFormValue(name || "", "");
98
+ }
81
99
  }
82
100
  setInputValue("");
83
101
  };
@@ -142,10 +160,9 @@ export const SelectField = (props) => {
142
160
  }
143
161
  return (_jsxs("div", { className: `col-span-6 sm:col-span-3 ${className}`, ref: selectRef, children: [title && (_jsxs("label", { htmlFor: error ? `${name}-error` : `${name}-success`, className: `block text-sm font-medium ${color === "red"
144
162
  ? "text-red-700 dark:text-red-500"
145
- : "text-gray-700 dark:text-gray-500"}`, children: [title, required && _jsx("span", { className: "text-red-500", children: "*" })] })), _jsxs("div", { className: "relative", children: [_jsx(Controller, { name: name || "", control: control, rules: { required }, defaultValue: defaultValue || (isMulti ? [] : null), render: ({ field }) => (_jsx("input", { ...field, type: "text", id: id, value: inputValue, onFocus: () => setIsOpen(true), onBlur: handleBlur, onKeyDown: handleKeyDown, readOnly: isReadOnly, disabled: disabled, className: `block w-full rounded-md ${bgColor} ${borderColor} ${textColor} shadow-sm focus:border-indigo-500 focus:ring-indigo-500 sm:text-sm`, placeholder: isMulti ? "Select options..." : "Select an option...", onChange: (e) => {
146
- field.onChange(e);
147
- handleInputChange(e);
148
- }, autoComplete: "off" })) }), isClearable && (value || valueMulti.length > 0) && (_jsx("button", { type: "button", onClick: handleClear, className: "absolute inset-y-0 right-0 pr-3 flex items-center", children: "\u00D7" })), isOpen && !isReadOnly && (_jsx("ul", { ref: optionsRef, className: "absolute z-10 mt-1 w-full bg-white shadow-lg max-h-60 rounded-md py-1 text-base ring-1 ring-black ring-opacity-5 overflow-auto focus:outline-none sm:text-sm", children: filteredOptions.map((option, index) => (_jsx("li", { className: `cursor-pointer select-none relative py-2 pl-3 pr-9 ${(isMulti
163
+ : "text-gray-700 dark:text-gray-500"}`, children: [title, required && _jsx("span", { className: "text-red-500", children: "*" })] })), _jsxs("div", { className: "relative", children: [_jsx("input", { type: "text", id: id, value: inputValue, onFocus: () => setIsOpen(true), onKeyDown: handleKeyDown, readOnly: isReadOnly, disabled: disabled, className: `block w-full rounded-md ${bgColor} ${borderColor} ${textColor} shadow-sm focus:border-indigo-500 focus:ring-indigo-500 sm:text-sm`, placeholder: isMulti ? "Select options..." : "Select an option...", autoComplete: "off", onChange: handleInputChange, onBlur: handleBlur, required: required }), _jsx("input", { type: "hidden", ...(register ?? {}), name: name, value: isMulti
164
+ ? valueMulti.map((v) => v.value).join(",")
165
+ : value?.value || "" }), isClearable && (value || valueMulti.length > 0) && (_jsx("button", { type: "button", onClick: handleClear, className: "absolute inset-y-0 right-0 pr-3 flex items-center", children: "\u00D7" })), isOpen && !isReadOnly && (_jsx("ul", { ref: optionsRef, className: "absolute z-10 mt-1 w-full bg-white shadow-lg max-h-60 rounded-md py-1 text-base ring-1 ring-black ring-opacity-5 overflow-auto focus:outline-none sm:text-sm", children: filteredOptions.map((option, index) => (_jsx("li", { className: `cursor-pointer select-none relative py-2 pl-3 pr-9 ${(isMulti
149
166
  ? valueMulti.some((v) => v.value === option.value)
150
167
  : value?.value === option.value)
151
168
  ? "text-white bg-indigo-600"