@zauru-sdk/components 1.0.99 → 1.0.100

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 (95) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/dist/Form/Checkbox/index.d.ts +1 -3
  3. package/dist/Form/DatePicker/index.d.ts +1 -3
  4. package/dist/Form/FileUpload/index.d.ts +1 -2
  5. package/dist/Form/ReactZodForm/index.d.ts +12 -0
  6. package/dist/Form/SelectField/index.d.ts +6 -9
  7. package/dist/Form/TextArea/index.d.ts +1 -3
  8. package/dist/Form/TextField/index.d.ts +1 -3
  9. package/dist/Form/TimePicker/index.d.ts +1 -2
  10. package/dist/Form/YesNo/index.d.ts +1 -0
  11. package/dist/Form/index.d.ts +1 -2
  12. package/dist/Layouts/homeLayout/index.d.ts +3 -1
  13. package/dist/Modal/Modal.d.ts +1 -1
  14. package/dist/Zendesk/zendesk.config.d.ts +1 -1
  15. package/dist/cjs/Alerts/StaticAlert.js +0 -6
  16. package/dist/cjs/Buttons/Button.js +13 -2
  17. package/dist/cjs/DynamicTable/DynamicPrintTable.js +2 -2
  18. package/dist/cjs/DynamicTable/DynamicTable.js +3 -3
  19. package/dist/cjs/DynamicTable/GenericDynamicTable.js +4 -5
  20. package/dist/cjs/Footer/Footer.js +1 -1
  21. package/dist/cjs/Form/Checkbox/index.js +14 -14
  22. package/dist/cjs/Form/Checklist/index.js +1 -1
  23. package/dist/cjs/Form/DatePicker/index.js +14 -13
  24. package/dist/cjs/Form/DynamicBaculoForm/index.js +1 -1
  25. package/dist/cjs/Form/FileUpload/index.js +25 -13
  26. package/dist/cjs/Form/ReactZodForm/index.js +31 -0
  27. package/dist/cjs/Form/SelectField/index.js +118 -73
  28. package/dist/cjs/Form/TextArea/index.js +15 -15
  29. package/dist/cjs/Form/TextField/index.js +20 -16
  30. package/dist/cjs/Form/TimePicker/index.js +17 -15
  31. package/dist/cjs/Form/YesNo/index.js +12 -6
  32. package/dist/cjs/Form/index.js +1 -2
  33. package/dist/cjs/Layouts/homeLayout/index.js +45 -8
  34. package/dist/cjs/Modal/Modal.js +1 -2
  35. package/dist/cjs/NavBar/NavBar.js +12 -17
  36. package/dist/cjs/Table/ZauruTable.js +11 -4
  37. package/dist/cjs/WithTooltip/WithTooltip.js +1 -1
  38. package/dist/cjs/Zendesk/zendesk.config.js +7 -9
  39. package/dist/esm/Alerts/StaticAlert.js +0 -6
  40. package/dist/esm/Buttons/Button.js +13 -2
  41. package/dist/esm/DynamicTable/DynamicPrintTable.js +4 -4
  42. package/dist/esm/DynamicTable/DynamicTable.js +6 -6
  43. package/dist/esm/DynamicTable/GenericDynamicTable.js +7 -8
  44. package/dist/esm/Footer/Footer.js +1 -1
  45. package/dist/esm/Form/Checkbox/index.js +13 -12
  46. package/dist/esm/Form/Checklist/index.js +2 -2
  47. package/dist/esm/Form/DatePicker/index.js +13 -11
  48. package/dist/esm/Form/DynamicBaculoForm/index.js +2 -2
  49. package/dist/esm/Form/FileUpload/index.js +24 -11
  50. package/dist/esm/Form/ReactZodForm/index.js +27 -0
  51. package/dist/esm/Form/SelectField/index.js +118 -49
  52. package/dist/esm/Form/TextArea/index.js +14 -13
  53. package/dist/esm/Form/TextField/index.js +19 -14
  54. package/dist/esm/Form/TimePicker/index.js +16 -13
  55. package/dist/esm/Form/YesNo/index.js +12 -6
  56. package/dist/esm/Form/index.js +1 -2
  57. package/dist/esm/Layouts/homeLayout/index.js +46 -9
  58. package/dist/esm/Modal/Modal.js +1 -2
  59. package/dist/esm/NavBar/NavBar.js +12 -17
  60. package/dist/esm/Table/ZauruTable.js +11 -4
  61. package/dist/esm/WithTooltip/WithTooltip.js +2 -2
  62. package/dist/esm/Zendesk/zendesk.config.js +7 -6
  63. package/package.json +6 -3
  64. package/src/Alerts/StaticAlert.tsx +0 -10
  65. package/src/Buttons/Button.tsx +24 -4
  66. package/src/DynamicTable/DynamicPrintTable.tsx +5 -6
  67. package/src/DynamicTable/DynamicTable.tsx +7 -7
  68. package/src/DynamicTable/GenericDynamicTable.tsx +7 -8
  69. package/src/Footer/Footer.tsx +1 -1
  70. package/src/Form/Checkbox/index.tsx +21 -18
  71. package/src/Form/Checklist/index.tsx +2 -2
  72. package/src/Form/DatePicker/index.tsx +22 -19
  73. package/src/Form/DynamicBaculoForm/index.tsx +2 -2
  74. package/src/Form/FileUpload/index.tsx +29 -14
  75. package/src/Form/ReactZodForm/index.tsx +60 -0
  76. package/src/Form/SelectField/index.tsx +246 -130
  77. package/src/Form/TextArea/index.tsx +22 -19
  78. package/src/Form/TextField/index.tsx +25 -18
  79. package/src/Form/TimePicker/index.tsx +25 -18
  80. package/src/Form/YesNo/index.tsx +20 -7
  81. package/src/Form/index.ts +1 -2
  82. package/src/Layouts/homeLayout/index.tsx +114 -21
  83. package/src/Modal/Modal.tsx +2 -5
  84. package/src/NavBar/NavBar.tsx +35 -46
  85. package/src/Table/ZauruTable.tsx +11 -4
  86. package/src/WithTooltip/WithTooltip.tsx +8 -7
  87. package/src/Zendesk/zendesk.config.ts +8 -6
  88. package/dist/Form/FormLayout/index.d.ts +0 -11
  89. package/dist/Form/RadioButtonGroup/index.d.ts +0 -20
  90. package/dist/cjs/Form/FormLayout/index.js +0 -11
  91. package/dist/cjs/Form/RadioButtonGroup/index.js +0 -26
  92. package/dist/esm/Form/FormLayout/index.js +0 -7
  93. package/dist/esm/Form/RadioButtonGroup/index.js +0 -21
  94. package/src/Form/FormLayout/index.tsx +0 -37
  95. package/src/Form/RadioButtonGroup/index.tsx +0 -108
package/CHANGELOG.md CHANGED
@@ -3,6 +3,14 @@
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.100](https://github.com/intuitiva/zauru-typescript-sdk/compare/v1.0.99...v1.0.100) (2024-09-14)
7
+
8
+ **Note:** Version bump only for package @zauru-sdk/components
9
+
10
+
11
+
12
+
13
+
6
14
  ## [1.0.99](https://github.com/intuitiva/zauru-typescript-sdk/compare/v1.0.98...v1.0.99) (2024-09-13)
7
15
 
8
16
  **Note:** Version bump only for package @zauru-sdk/components
@@ -2,16 +2,14 @@ import React from "react";
2
2
  type Props = {
3
3
  id?: string;
4
4
  name?: string;
5
- formName?: string;
6
5
  label?: string;
7
6
  defaultValue?: boolean;
8
7
  onChange?: (value: boolean, event: React.ChangeEvent<HTMLInputElement>) => {
9
8
  stopUIChange: boolean;
10
9
  } | void;
11
10
  disabled?: boolean;
12
- error?: string | undefined;
13
11
  borderColor?: string;
12
+ required?: boolean;
14
13
  };
15
- export declare const CheckboxWithoutValidation: (props: Props) => import("react/jsx-runtime").JSX.Element;
16
14
  export declare const CheckBox: (props: Props) => import("react/jsx-runtime").JSX.Element;
17
15
  export {};
@@ -1,7 +1,6 @@
1
1
  type Props = {
2
2
  id?: string;
3
3
  name: string;
4
- formName?: string;
5
4
  title?: string;
6
5
  hint?: string;
7
6
  helpText?: string;
@@ -9,10 +8,9 @@ type Props = {
9
8
  onChange?: (value: string) => void;
10
9
  isClearable?: boolean;
11
10
  tabIndex?: number;
12
- error?: string;
13
11
  disabled?: boolean;
14
12
  className?: string;
13
+ required?: boolean;
15
14
  };
16
- export declare const FormDatePickerWithoutValidation: (props: Props) => import("react/jsx-runtime").JSX.Element;
17
15
  export declare const FormDatePicker: (props: Props) => import("react/jsx-runtime").JSX.Element;
18
16
  export {};
@@ -9,13 +9,12 @@ type Props = {
9
9
  onChange?: (event: React.ChangeEvent<HTMLInputElement>) => void;
10
10
  disabled?: boolean;
11
11
  readOnly?: boolean;
12
- error?: string | undefined;
13
12
  fileTypes?: string[];
14
13
  showAvailableTypes?: boolean;
15
14
  className?: string;
16
15
  defaultValue?: string | File;
17
16
  download?: boolean;
17
+ required?: boolean;
18
18
  };
19
- export declare const FileUploadFieldWithoutValidation: (props: Props) => import("react/jsx-runtime").JSX.Element;
20
19
  export declare const FileUploadField: (props: Props) => import("react/jsx-runtime").JSX.Element;
21
20
  export {};
@@ -0,0 +1,12 @@
1
+ import { FieldValues, SubmitHandler } from "react-hook-form";
2
+ import { ZodSchema } from "zod";
3
+ import React from "react";
4
+ type Props = {
5
+ children: React.ReactNode;
6
+ schema?: ZodSchema;
7
+ onSubmit?: SubmitHandler<FieldValues>;
8
+ id?: string;
9
+ method?: "post" | "put" | "delete" | "patch";
10
+ };
11
+ export declare const ReactZodForm: (props: Props) => import("react/jsx-runtime").JSX.Element;
12
+ export default ReactZodForm;
@@ -1,19 +1,16 @@
1
1
  import { SelectFieldOption } from "@zauru-sdk/types";
2
- import type { SingleValue, InputActionMeta } from "react-select";
3
2
  type Props = {
4
3
  id?: string;
5
- formName?: string;
6
4
  name?: string;
7
5
  title?: string;
8
- defaultValue?: SingleValue<SelectFieldOption>;
9
- defaultValueMulti?: SingleValue<SelectFieldOption>[];
6
+ defaultValue?: SelectFieldOption;
7
+ defaultValueMulti?: SelectFieldOption[];
10
8
  helpText?: string;
11
9
  options: Array<SelectFieldOption>;
12
- onChange?: (value: SingleValue<SelectFieldOption>) => void;
13
- onChangeMulti?: (value: Array<SingleValue<SelectFieldOption>>) => void;
14
- onInputChange?: (newValue: string, actionMeta: InputActionMeta) => void;
10
+ onChange?: (value: SelectFieldOption | null) => void;
11
+ onChangeMulti?: (value: SelectFieldOption[]) => void;
12
+ onInputChange?: (newValue: string) => void;
15
13
  isClearable?: boolean;
16
- error?: string | undefined;
17
14
  disabled?: boolean;
18
15
  menuIsOpen?: boolean;
19
16
  readOnly?: boolean;
@@ -21,7 +18,7 @@ type Props = {
21
18
  loading?: boolean;
22
19
  hint?: string;
23
20
  className?: string;
21
+ required?: boolean;
24
22
  };
25
- export declare const SelectFieldWithoutValidation: (props: Props) => import("react/jsx-runtime").JSX.Element;
26
23
  export declare const SelectField: (props: Props) => import("react/jsx-runtime").JSX.Element;
27
24
  export {};
@@ -2,7 +2,6 @@ import React from "react";
2
2
  type Props = {
3
3
  id?: string;
4
4
  name: string;
5
- formName?: string;
6
5
  title?: string;
7
6
  defaultValue?: string | number;
8
7
  hidden?: boolean;
@@ -12,12 +11,11 @@ type Props = {
12
11
  onKeyDown?: (event: React.KeyboardEvent) => void;
13
12
  disabled?: boolean;
14
13
  readOnly?: boolean;
15
- error?: string | undefined;
16
14
  rows?: number;
17
15
  cols?: number;
18
16
  stopChangeEvents?: boolean;
19
17
  className?: string;
18
+ required?: boolean;
20
19
  };
21
- export declare const TextAreaWithoutValidation: (props: Props) => import("react/jsx-runtime").JSX.Element;
22
20
  export declare const TextArea: (props: Props) => import("react/jsx-runtime").JSX.Element;
23
21
  export {};
@@ -2,7 +2,6 @@ import React from "react";
2
2
  type Props = {
3
3
  id?: string;
4
4
  name?: string;
5
- formName?: string;
6
5
  title?: string;
7
6
  defaultValue?: string | number;
8
7
  hidden?: boolean;
@@ -13,13 +12,12 @@ type Props = {
13
12
  onKeyDown?: (event: React.KeyboardEvent) => void;
14
13
  disabled?: boolean;
15
14
  readOnly?: boolean;
16
- error?: string;
17
15
  min?: string | number;
18
16
  integer?: boolean;
19
17
  stopChangeEvents?: boolean;
20
18
  style?: React.CSSProperties;
21
19
  className?: string;
20
+ required?: boolean;
22
21
  };
23
- export declare const TextFieldWithoutValidation: (props: Props) => import("react/jsx-runtime").JSX.Element;
24
22
  export declare const TextField: (props: Props) => import("react/jsx-runtime").JSX.Element;
25
23
  export {};
@@ -8,9 +8,8 @@ type Props = {
8
8
  defaultValue?: string;
9
9
  onChange?: (value: string) => void;
10
10
  tabIndex?: number;
11
- error?: string;
12
11
  disabled?: boolean;
12
+ required?: boolean;
13
13
  };
14
- export declare const FormTimePickerWithoutValidation: (props: Props) => import("react/jsx-runtime").JSX.Element;
15
14
  export declare const FormTimePicker: (props: Props) => import("react/jsx-runtime").JSX.Element;
16
15
  export {};
@@ -7,6 +7,7 @@ type Props = {
7
7
  helpText?: string;
8
8
  onChange?: (value: boolean) => void;
9
9
  disabled?: boolean;
10
+ required?: boolean;
10
11
  };
11
12
  export declare const YesNo: (props: Props) => import("react/jsx-runtime").JSX.Element;
12
13
  export {};
@@ -5,10 +5,9 @@ export * from "./DynamicBaculoForm/index.js";
5
5
  export * from "./FieldContainer/index.js";
6
6
  export * from "./FileUpload/index.js";
7
7
  export * from "./FormButtons/index.js";
8
- export * from "./FormLayout/index.js";
9
8
  export * from "./SelectField/index.js";
10
9
  export * from "./TextArea/index.js";
11
10
  export * from "./TextField/index.js";
12
11
  export * from "./TimePicker/index.js";
13
12
  export * from "./YesNo/index.js";
14
- export * from "./RadioButtonGroup/index.js";
13
+ export * from "./ReactZodForm/index.js";
@@ -1,6 +1,8 @@
1
1
  type Props = {
2
2
  title?: string;
3
3
  description?: string;
4
+ loading?: boolean;
5
+ color?: "green" | "blue" | "red" | "purple" | "yellow";
4
6
  };
5
- export declare const HomeLayout: ({ title, description }: Props) => import("react/jsx-runtime").JSX.Element;
7
+ export declare const HomeLayout: ({ title, description, loading, color, }: Props) => import("react/jsx-runtime").JSX.Element;
6
8
  export {};
@@ -2,7 +2,7 @@ import React from "react";
2
2
  export type ModalOption = "OK" | "CANCEL" | null;
3
3
  type ModalParams = {
4
4
  title: string;
5
- description: React.ReactNode | (() => React.ReactNode);
5
+ description: React.ReactNode;
6
6
  okButtonText?: string;
7
7
  showOptions?: boolean;
8
8
  };
@@ -6,4 +6,4 @@ export declare function zendeskJwt(current_user: {
6
6
  }, configuration: {
7
7
  zendeskJWTSecret: string;
8
8
  zendeskJWTKey: string;
9
- }): string;
9
+ }): {};
@@ -16,12 +16,6 @@ const getConfig = (type) => {
16
16
  buttonClassName: "rounded-md focus:outline-none focus:ring-2 focus:ring-green-500",
17
17
  path: ((0, jsx_runtime_1.jsx)("path", { d: "M8.445 12.6675A.9.9 0 0 0 7.1424 13.91l2.5726 2.7448c.3679.3856.9884.3689 1.335-.036l5.591-7.0366a.9.9 0 0 0-1.3674-1.1705l-4.6548 5.9132a.4.4 0 0 1-.607.0252l-1.567-1.6826zM1.9995 12c0-5.5 4.5-10 10-10s10 4.5 10 10-4.5 10-10 10-10-4.5-10-10z" })),
18
18
  };
19
- case "warning":
20
- return {
21
- containerClassName: "text-yellow-900 bg-yellow-100 border border-yellow-200 rounded-md",
22
- buttonClassName: "rounded-md focus:outline-none focus:ring-2 focus:ring-yellow-500",
23
- path: ((0, jsx_runtime_1.jsx)("path", { d: "M12 2C6.5 2 2 6.5 2 12s4.5 10 10 10 10-4.5 10-10S17.5 2 12 2M12 18a1.5 1.5 0 1 1 0-3 1.5 1.5 0 0 1 0 3zm0-9a1 1 0 0 1 1 1v4a1 1 0 0 1-2 0v-4a1 1 0 0 1 1-1z" })),
24
- };
25
19
  default:
26
20
  return {
27
21
  containerClassName: "text-blue-900 bg-blue-100 border border-blue-200 rounded-md",
@@ -2,8 +2,13 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Button = void 0;
4
4
  const jsx_runtime_1 = require("react/jsx-runtime");
5
+ const react_hook_form_1 = require("react-hook-form");
6
+ const index_js_1 = require("../index.js");
5
7
  const Button = (props) => {
6
8
  const { type = "submit", loading = false, loadingText = "Guardando...", title = "Guardar", name = "save", onClickSave, selectedColor = "indigo", children, className = "", disabled = false, } = props;
9
+ const formContext = (0, react_hook_form_1.useFormContext)();
10
+ const formHasErrors = formContext ? !formContext.formState.isValid : false;
11
+ const formErrors = formContext ? formContext.formState.errors : {};
7
12
  const COLORS = {
8
13
  green: {
9
14
  bg900: "bg-green-900",
@@ -40,8 +45,14 @@ const Button = (props) => {
40
45
  };
41
46
  const color = COLORS[selectedColor];
42
47
  const inside = children ?? title;
43
- return ((0, jsx_runtime_1.jsx)("button", { type: type, name: "action", disabled: loading || disabled, value: name, onClick: onClickSave, className: `ml-2 ${loading || disabled ? " bg-opacity-25 " : ""} ${loading
48
+ const errorMessage = formHasErrors
49
+ ? Object.values(formErrors)
50
+ .map((error) => error?.message?.toString())
51
+ .join(", ")
52
+ : "";
53
+ const buttonContent = ((0, jsx_runtime_1.jsx)("button", { type: type, name: "action", disabled: loading || disabled || formHasErrors, value: name, onClick: onClickSave, className: `ml-2 ${loading || disabled || formHasErrors ? " bg-opacity-25 " : ""} ${loading
44
54
  ? " cursor-progress"
45
- : `${disabled ? "" : `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 }));
55
+ : `${disabled || formHasErrors ? "" : `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
+ return formHasErrors ? ((0, jsx_runtime_1.jsx)(index_js_1.WithTooltip, { text: errorMessage, children: buttonContent })) : (buttonContent);
46
57
  };
47
58
  exports.Button = Button;
@@ -36,11 +36,11 @@ const errorAnimation = {
36
36
  const DynamicPrintTable = ({ forwardedRef, ...props }) => {
37
37
  const { items, onChange, className } = props;
38
38
  const { formValidations } = (0, redux_1.useAppSelector)((state) => state.formValidation);
39
- const createItemSelect = (rowIndex, defaultValue) => ((0, jsx_runtime_1.jsx)(index_js_2.SelectFieldWithoutValidation, { name: "item_select", isClearable: true, onChange: (value) => {
39
+ const createItemSelect = (rowIndex, defaultValue) => ((0, jsx_runtime_1.jsx)(index_js_2.SelectField, { name: "item_select", isClearable: true, onChange: (value) => {
40
40
  const selectedItem = items?.find((x) => x.value === value?.value);
41
41
  updateRow(rowIndex, selectedItem);
42
42
  }, options: items, defaultValue: defaultValue }, rowIndex));
43
- const createItemQuantity = (rowIndex, defaultValue) => ((0, jsx_runtime_1.jsx)(index_js_1.TextFieldWithoutValidation, { name: "item_quantity", type: "number", integer: true, defaultValue: defaultValue ?? 1, min: 1, onChange: (value) => {
43
+ const createItemQuantity = (rowIndex, defaultValue) => ((0, jsx_runtime_1.jsx)(index_js_1.TextField, { name: "item_quantity", type: "number", integer: true, defaultValue: defaultValue ?? 1, min: 1, onChange: (value) => {
44
44
  updateRow(rowIndex, undefined, Number(value));
45
45
  } }, rowIndex));
46
46
  const createTemplateName = (rowIndex, defaultValue) => ((0, jsx_runtime_1.jsx)("div", { children: defaultValue != "" ? defaultValue : "No hay etiqueta" }, rowIndex));
@@ -173,7 +173,7 @@ const DynamicTable = ({ forwardedRef, ...props }, ref) => {
173
173
  return ((0, jsx_runtime_1.jsxs)("tr", { children: [(0, jsx_runtime_1.jsx)("th", { className: "align-middle py-2 text-center", style: {
174
174
  ...cellBordered,
175
175
  ...pastelGrayBackground,
176
- }, children: intersectionTitle ?? "" }), cols.map((col) => ((0, jsx_runtime_1.jsx)("th", { className: "align-middle py-2 text-center", style: { ...cellBordered, ...pastelGrayBackground }, children: (0, jsx_runtime_1.jsxs)("div", { className: "inline-flex", children: [(0, jsx_runtime_1.jsx)(index_js_2.TextFieldWithoutValidation, { style: { maxWidth: "45%", minWidth: "45%" }, name: `column${col.id}`, defaultValue: tableData[`column${col.id}`] || 1, type: "number", onChange: (value) => handleInputChange(`column${col.id}`, value) }), col.id > 0 && ((0, jsx_runtime_1.jsx)("button", { className: "bg-red-500 hover:bg-red-600 font-bold py-1 px-2 rounded ml-2", onClick: () => removeCol(col.id), children: "x" }))] }) }, col.id))), (0, jsx_runtime_1.jsx)("th", { children: (0, jsx_runtime_1.jsx)("button", { className: "bg-blue-500 hover:bg-blue-600 font-bold py-2 px-4 rounded", onClick: addCol, children: "+" }) })] }));
176
+ }, children: intersectionTitle ?? "" }), cols.map((col) => ((0, jsx_runtime_1.jsx)("th", { className: "align-middle py-2 text-center", style: { ...cellBordered, ...pastelGrayBackground }, children: (0, jsx_runtime_1.jsxs)("div", { className: "inline-flex", children: [(0, jsx_runtime_1.jsx)(index_js_2.TextField, { style: { maxWidth: "45%", minWidth: "45%" }, name: `column${col.id}`, defaultValue: tableData[`column${col.id}`] || 1, type: "number", onChange: (value) => handleInputChange(`column${col.id}`, value) }), col.id > 0 && ((0, jsx_runtime_1.jsx)("button", { className: "bg-red-500 hover:bg-red-600 font-bold py-1 px-2 rounded ml-2", onClick: () => removeCol(col.id), children: "x" }))] }) }, col.id))), (0, jsx_runtime_1.jsx)("th", { children: (0, jsx_runtime_1.jsx)("button", { className: "bg-blue-500 hover:bg-blue-600 font-bold py-2 px-4 rounded", onClick: addCol, children: "+" }) })] }));
177
177
  };
178
178
  const renderRow = (rowId) => {
179
179
  const cols = getCols();
@@ -183,14 +183,14 @@ const DynamicTable = ({ forwardedRef, ...props }, ref) => {
183
183
  textOverflow: "ellipsis",
184
184
  msTextOverflow: "ellipsis",
185
185
  maxWidth: "200px",
186
- }, children: (0, jsx_runtime_1.jsxs)("div", { className: "inline-flex", children: [(0, jsx_runtime_1.jsx)(index_js_2.TextFieldWithoutValidation, { style: { maxWidth: "45%", minWidth: "45%" }, name: `row${rowId}`, defaultValue: tableData[`row${rowId}`] || 1, type: "number", onChange: (value) => handleInputChange(`row${rowId}`, value) }), rowId > 0 && ((0, jsx_runtime_1.jsx)("button", { className: "bg-red-500 hover:bg-red-600 font-bold py-1 px-2 rounded ml-2", onClick: () => {
186
+ }, children: (0, jsx_runtime_1.jsxs)("div", { className: "inline-flex", children: [(0, jsx_runtime_1.jsx)(index_js_2.TextField, { style: { maxWidth: "45%", minWidth: "45%" }, name: `row${rowId}`, defaultValue: tableData[`row${rowId}`] || 1, type: "number", onChange: (value) => handleInputChange(`row${rowId}`, value) }), rowId > 0 && ((0, jsx_runtime_1.jsx)("button", { className: "bg-red-500 hover:bg-red-600 font-bold py-1 px-2 rounded ml-2", onClick: () => {
187
187
  removeRow(rowId);
188
188
  }, children: "x" }))] }) }), cols.map((col) => {
189
189
  const cellId = `cell-${rowId}-${col.id}`;
190
190
  const cellValidation = tableData[cellId] === true;
191
191
  if (!cellInputs)
192
192
  tableData[cellId] = cellValidation;
193
- return ((0, jsx_runtime_1.jsx)("td", { id: cellId, style: { ...cellBordered, ...cellCenteredContent }, children: cellInputs ? ((0, jsx_runtime_1.jsx)(index_js_1.TextAreaWithoutValidation, { name: cellId, defaultValue: tableData[cellId] || "", onChange: (value) => handleInputChange(cellId, value) })) : ((0, jsx_runtime_1.jsx)(index_js_3.CheckboxWithoutValidation, { name: cellId, defaultValue: cellValidation, onChange: (value) => {
193
+ return ((0, jsx_runtime_1.jsx)("td", { id: cellId, style: { ...cellBordered, ...cellCenteredContent }, children: cellInputs ? ((0, jsx_runtime_1.jsx)(index_js_1.TextArea, { name: cellId, defaultValue: tableData[cellId] || "", onChange: (value) => handleInputChange(cellId, value) })) : ((0, jsx_runtime_1.jsx)(index_js_3.CheckBox, { name: cellId, defaultValue: cellValidation, onChange: (value) => {
194
194
  if (value) {
195
195
  return handleValidation(cellId, col.id, rowId);
196
196
  }
@@ -64,7 +64,6 @@ const GenericDynamicTable = (props) => {
64
64
  newDeletedData.push(deletedItem);
65
65
  }
66
66
  setDeletedData(newDeletedData);
67
- onChange && onChange(tableData?.filter((x) => x.id !== rowId));
68
67
  setTableData((prevData) => prevData?.filter((x) => x.id !== rowId));
69
68
  };
70
69
  const handleChange = (name, value, rowId) => {
@@ -97,10 +96,10 @@ const GenericDynamicTable = (props) => {
97
96
  return ((0, jsx_runtime_1.jsx)("td", { className: "align-middle p-1", children: (0, jsx_runtime_1.jsx)("div", { children: defaultVal }) }, `${rowData.id}-${column.name}`));
98
97
  }
99
98
  const FieldComponent = column.type === "textField"
100
- ? index_js_2.TextFieldWithoutValidation
99
+ ? index_js_2.TextField
101
100
  : column.type === "checkbox"
102
- ? index_js_3.CheckboxWithoutValidation
103
- : index_js_1.SelectFieldWithoutValidation;
101
+ ? index_js_3.CheckBox
102
+ : index_js_1.SelectField;
104
103
  const setTableValue = (columnName, newValue) => {
105
104
  setTableData((prevState) => {
106
105
  // Encontrar el índice de la fila que está cambiando
@@ -185,7 +184,7 @@ const GenericDynamicTable = (props) => {
185
184
  setFilteredTableData(tableData);
186
185
  }
187
186
  };
188
- return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [name && ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(GenericDynamicTableErrorComponent, { name: name }), (0, jsx_runtime_1.jsx)("input", { name: name, type: "hidden", value: JSON.stringify(tableData), hidden: true }), (0, jsx_runtime_1.jsx)("input", { name: `deleted_${name}`, type: "hidden", value: JSON.stringify(deletedData), hidden: true })] })), (0, jsx_runtime_1.jsxs)("div", { className: `${className}`, children: [searcheables.length > 0 && ((0, jsx_runtime_1.jsx)("div", { children: (0, jsx_runtime_1.jsx)(index_js_2.TextFieldWithoutValidation, { className: "mb-2", name: "search", title: `Buscar por: ${searcheables
187
+ return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [name && ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(GenericDynamicTableErrorComponent, { name: name }), (0, jsx_runtime_1.jsx)("input", { name: name, type: "hidden", value: JSON.stringify(tableData), hidden: true }), (0, jsx_runtime_1.jsx)("input", { name: `deleted_${name}`, type: "hidden", value: JSON.stringify(deletedData), hidden: true })] })), (0, jsx_runtime_1.jsxs)("div", { className: `${className}`, children: [searcheables.length > 0 && ((0, jsx_runtime_1.jsx)("div", { children: (0, jsx_runtime_1.jsx)(index_js_2.TextField, { className: "mb-2", name: "search", title: `Buscar por: ${searcheables
189
188
  .map((x) => x.label)
190
189
  .join(", ")}`, onChange: handleChangeSearch, disabled: loading }) })), (0, jsx_runtime_1.jsxs)("table", { className: "w-full", children: [(0, jsx_runtime_1.jsx)("thead", { children: renderHeader() }), (0, jsx_runtime_1.jsx)("tbody", { children: renderRows() }), footerRow && !editable ? ((0, jsx_runtime_1.jsx)("tfoot", { className: "border-t-2 border-black", children: (0, jsx_runtime_1.jsx)("tr", { children: Object.keys(footerRow ?? {})?.map((x, indx) => {
191
190
  return ((0, jsx_runtime_1.jsx)("td", { className: "align-middle", children: footerRow[x] }, indx));
@@ -15,6 +15,6 @@ const COLORS = {
15
15
  };
16
16
  const Footer = ({ href, selectedColor, showConnection = false, }) => {
17
17
  const color = COLORS[selectedColor];
18
- return ((0, jsx_runtime_1.jsx)("footer", { className: `inset-x-0 bottom-0 px-2 py-[20px] ${color}`, children: (0, jsx_runtime_1.jsxs)("div", { className: "px-4 mx-auto flex flex-wrap items-center justify-center", children: [(0, jsx_runtime_1.jsxs)("p", { className: "text-white text-[1.2rem]", children: [`Creado en `, " ", (0, jsx_runtime_1.jsx)("a", { href: href, children: "Zauru" }), " ", `con ❤️ ${new Date().getFullYear()} v.3.2`] }), showConnection && ((0, jsx_runtime_1.jsx)("div", { className: "ml-5", children: (0, jsx_runtime_1.jsx)(index_js_1.ConnectionState, {}) }))] }) }));
18
+ return ((0, jsx_runtime_1.jsx)("footer", { className: `inset-x-0 bottom-0 px-2 py-[20px] ${color}`, children: (0, jsx_runtime_1.jsxs)("div", { className: "px-4 mx-auto flex flex-wrap items-center justify-center", children: [(0, jsx_runtime_1.jsxs)("p", { className: "text-white text-[1.2rem]", children: [`Creado en `, " ", (0, jsx_runtime_1.jsx)("a", { href: href, children: "Zauru" }), " ", `con ❤️ ${new Date().getFullYear()} v.2.0.0`] }), showConnection && ((0, jsx_runtime_1.jsx)("div", { className: "ml-5", children: (0, jsx_runtime_1.jsx)(index_js_1.ConnectionState, {}) }))] }) }));
19
19
  };
20
20
  exports.Footer = Footer;
@@ -1,17 +1,20 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.CheckBox = exports.CheckboxWithoutValidation = void 0;
3
+ exports.CheckBox = void 0;
4
4
  const jsx_runtime_1 = require("react/jsx-runtime");
5
- const redux_1 = require("@zauru-sdk/redux");
6
5
  const react_1 = require("react");
7
- const CheckboxWithoutValidation = (props) => {
8
- const { id, name, defaultValue = false, onChange, disabled = false, error, label, } = props;
6
+ const react_hook_form_1 = require("react-hook-form");
7
+ const CheckBox = (props) => {
8
+ const { id, name, defaultValue = false, onChange, disabled = false, label, required = false, } = props;
9
9
  const [checked, setChecked] = (0, react_1.useState)(defaultValue);
10
10
  (0, react_1.useEffect)(() => {
11
11
  setChecked(defaultValue);
12
12
  }, [defaultValue]);
13
13
  const handleInputChange = (event) => {
14
14
  const isChecked = event.target.checked;
15
+ if (register) {
16
+ register.onChange(event);
17
+ }
15
18
  if (onChange) {
16
19
  const result = onChange(isChecked, event);
17
20
  if (result?.stopUIChange) {
@@ -20,20 +23,17 @@ const CheckboxWithoutValidation = (props) => {
20
23
  }
21
24
  setChecked(isChecked);
22
25
  };
26
+ const { register: tempRegister, formState: { errors }, } = (0, react_hook_form_1.useFormContext)() || { formState: {} }; // Obtener el contexto solo si existe
27
+ const error = errors ? errors[props.name ?? "-1"] : undefined;
28
+ const register = tempRegister
29
+ ? tempRegister(props.name ?? "-1", { required })
30
+ : undefined; // Solo usar register si está disponible
23
31
  const color = error ? "red" : "gray";
24
32
  const borderColor = disabled ? "border-gray-300" : `border-${color}-500`;
25
- const inputComponent = ((0, jsx_runtime_1.jsx)("input", { type: "checkbox", id: id ?? name, name: name, checked: checked, onChange: handleInputChange, className: `form-checkbox h-4 w-4 text-indigo-600 ${borderColor} focus:border-indigo-500 focus:ring-indigo-500`, disabled: disabled }));
33
+ const inputComponent = ((0, jsx_runtime_1.jsx)("input", { type: "checkbox", id: id ?? name, checked: checked, className: `form-checkbox h-4 w-4 text-indigo-600 ${borderColor} focus:border-indigo-500 focus:ring-indigo-500`, disabled: disabled, ...(register ?? {}), name: name, onChange: handleInputChange }));
26
34
  if (!error && !label) {
27
35
  return inputComponent;
28
36
  }
29
- return ((0, jsx_runtime_1.jsxs)("div", { className: "col-span-6 sm:col-span-3", children: [(0, jsx_runtime_1.jsxs)("div", { className: `flex items-center ${borderColor}`, children: [inputComponent, label && ((0, jsx_runtime_1.jsx)("label", { htmlFor: id ?? name, className: `ml-2 block text-sm font-medium text-${color}-700 dark:text-${color}-500`, children: label }))] }), error && ((0, jsx_runtime_1.jsxs)("p", { className: `mt-2 text-sm text-${color}-600 dark:text-${color}-500`, children: [(0, jsx_runtime_1.jsx)("span", { className: "font-medium", children: "Oops!" }), " ", error] }))] }));
30
- };
31
- exports.CheckboxWithoutValidation = CheckboxWithoutValidation;
32
- //<reference> https://tailwindui.com/components/application-ui/forms/form-layouts
33
- const CheckBox = (props) => {
34
- const { formValidations } = (0, redux_1.useAppSelector)((state) => state.formValidation);
35
- const error = formValidations[props.formName ?? "-1"]?.[props.name ?? "-1"];
36
- props = { ...props, error };
37
- return (0, jsx_runtime_1.jsx)(exports.CheckboxWithoutValidation, { ...props });
37
+ return ((0, jsx_runtime_1.jsxs)("div", { className: "col-span-6 sm:col-span-3", children: [(0, jsx_runtime_1.jsxs)("div", { className: `flex items-center ${borderColor}`, children: [inputComponent, label && ((0, jsx_runtime_1.jsxs)("label", { htmlFor: id ?? name, className: `ml-2 block text-sm font-medium text-${color}-700 dark:text-${color}-500`, children: [label, required && (0, jsx_runtime_1.jsx)("span", { className: "text-red-500", children: "*" })] }))] }), error && ((0, jsx_runtime_1.jsxs)("p", { className: `mt-2 text-sm text-${color}-600 dark:text-${color}-500`, children: [(0, jsx_runtime_1.jsx)("span", { className: "font-medium", children: "Oops!" }), " ", error.message?.toString()] }))] }));
38
38
  };
39
39
  exports.CheckBox = CheckBox;
@@ -9,6 +9,6 @@ const Checklist = ({ items, onChange }) => {
9
9
  onChange(name, value);
10
10
  }
11
11
  };
12
- return ((0, jsx_runtime_1.jsx)("div", { children: items.map((item) => ((0, jsx_runtime_1.jsx)(index_js_1.CheckboxWithoutValidation, { ...item, onChange: (value) => handleCheckboxChange(item.name, value) }, item.id))) }));
12
+ return ((0, jsx_runtime_1.jsx)("div", { children: items.map((item) => ((0, jsx_runtime_1.jsx)(index_js_1.CheckBox, { ...item, onChange: (value) => handleCheckboxChange(item.name, value) }, item.id))) }));
13
13
  };
14
14
  exports.Checklist = Checklist;
@@ -1,14 +1,19 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.FormDatePicker = exports.FormDatePickerWithoutValidation = void 0;
3
+ exports.FormDatePicker = void 0;
4
4
  const jsx_runtime_1 = require("react/jsx-runtime");
5
5
  const react_1 = require("react");
6
6
  const icons_1 = require("@zauru-sdk/icons");
7
- const redux_1 = require("@zauru-sdk/redux");
8
- const FormDatePickerWithoutValidation = (props) => {
9
- const { id, name, title, defaultValue = "", hint, helpText, onChange, tabIndex, error, disabled = false, className = "", isClearable = false, } = props;
7
+ const react_hook_form_1 = require("react-hook-form");
8
+ const FormDatePicker = (props) => {
9
+ const { id, name, title, defaultValue = "", hint, helpText, onChange, tabIndex, disabled = false, className = "", isClearable = false, required = false, } = props;
10
10
  const [value, setValue] = (0, react_1.useState)(defaultValue);
11
11
  const [showTooltip, setShowTooltip] = (0, react_1.useState)(false);
12
+ const { register: tempRegister, formState: { errors }, } = (0, react_hook_form_1.useFormContext)() || { formState: {} }; // Obtener el contexto solo si existe
13
+ const error = errors ? errors[props.name ?? "-1"] : undefined;
14
+ const register = tempRegister
15
+ ? tempRegister(props.name ?? "-1", { required })
16
+ : undefined; // Solo usar register si está disponible
12
17
  const color = error ? "red" : "gray";
13
18
  const isReadOnly = disabled;
14
19
  const bgColor = isReadOnly ? "bg-gray-200" : `bg-${color}-50`;
@@ -21,16 +26,12 @@ const FormDatePickerWithoutValidation = (props) => {
21
26
  setValue("");
22
27
  onChange && onChange("");
23
28
  };
24
- return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [title && ((0, jsx_runtime_1.jsx)("label", { htmlFor: error ? `${name}-error` : `${name}-success`, className: `block text-sm font-medium ${textColor} ${className}`, children: title })), (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, name: name, tabIndex: tabIndex, type: "date", onChange: (e) => {
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) => {
25
30
  setValue(e.target.value);
26
31
  onChange && onChange(e.target.value);
27
- }, 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` }), value && isClearable && ((0, jsx_runtime_1.jsx)("button", { type: "button", onClick: clearValue, className: "absolute right-0 mr-10", children: (0, jsx_runtime_1.jsx)(icons_1.CloseSvgIcon, {}) })), helpText && ((0, jsx_runtime_1.jsx)("div", { className: "flex items-center relative ml-3", children: (0, jsx_runtime_1.jsxs)("div", { className: "relative cursor-pointer", onMouseEnter: () => setShowTooltip(true), onMouseLeave: () => setShowTooltip(false), children: [(0, jsx_runtime_1.jsx)(icons_1.IdeaIconSVG, {}), showTooltip && ((0, jsx_runtime_1.jsx)("div", { className: "absolute -left-48 top-0 mt-8 p-2 bg-white border rounded shadow text-black", children: helpText }))] }) }))] }), error && ((0, jsx_runtime_1.jsxs)("p", { className: `mt-2 text-sm text-${color}-600 dark:text-${color}-500`, children: [(0, jsx_runtime_1.jsx)("span", { className: "font-medium", children: "Oops!" }), " ", error] })), !error && hint && ((0, jsx_runtime_1.jsx)("p", { className: `mt-2 italic text-sm text-${color}-500 dark:text-${color}-400`, children: hint }))] }));
28
- };
29
- exports.FormDatePickerWithoutValidation = FormDatePickerWithoutValidation;
30
- const FormDatePicker = (props) => {
31
- const { formValidations } = (0, redux_1.useAppSelector)((state) => state.formValidation);
32
- const error = formValidations[props.formName ?? "-1"]?.[props.name ?? "-1"];
33
- props = { ...props, error };
34
- return (0, jsx_runtime_1.jsx)(exports.FormDatePickerWithoutValidation, { ...props });
32
+ if (register) {
33
+ register.onChange(e);
34
+ }
35
+ } }), value && isClearable && ((0, jsx_runtime_1.jsx)("button", { type: "button", onClick: clearValue, className: "absolute right-0 mr-10", children: (0, jsx_runtime_1.jsx)(icons_1.CloseSvgIcon, {}) })), helpText && ((0, jsx_runtime_1.jsx)("div", { className: "flex items-center relative ml-3", children: (0, jsx_runtime_1.jsxs)("div", { className: "relative cursor-pointer", onMouseEnter: () => setShowTooltip(true), onMouseLeave: () => setShowTooltip(false), children: [(0, jsx_runtime_1.jsx)(icons_1.IdeaIconSVG, {}), showTooltip && ((0, jsx_runtime_1.jsx)("div", { className: "absolute -left-48 top-0 mt-8 p-2 bg-white border rounded shadow text-black", children: helpText }))] }) }))] }), error && ((0, jsx_runtime_1.jsxs)("p", { className: `mt-2 text-sm text-${color}-600 dark:text-${color}-500`, children: [(0, jsx_runtime_1.jsx)("span", { className: "font-medium", children: "Oops!" }), " ", error.message?.toString()] })), !error && hint && ((0, jsx_runtime_1.jsx)("p", { className: `mt-2 italic text-sm text-${color}-500 dark:text-${color}-400`, children: hint }))] }));
35
36
  };
36
37
  exports.FormDatePicker = FormDatePicker;
@@ -36,7 +36,7 @@ function DynamicBaculoForm(props) {
36
36
  return ((0, jsx_runtime_1.jsx)(index_js_11.SubContainer, { title: field.name, children: (0, jsx_runtime_1.jsx)(GenericDynamicTable_js_1.GenericDynamicTable, { name: "fixed_columns_table", columns: columns }) }, field.id));
37
37
  }
38
38
  case "zauru_data":
39
- return ((0, jsx_runtime_1.jsx)(index_js_1.TextFieldWithoutValidation, { title: `${field.required ? "*" : ""}${field.name}`, hint: field.hint, defaultValue: defaultValue?.value ?? field.default_value, disabled: true }, field.id));
39
+ return ((0, jsx_runtime_1.jsx)(index_js_1.TextField, { title: `${field.required ? "*" : ""}${field.name}`, hint: field.hint, defaultValue: defaultValue?.value ?? field.default_value, disabled: true }, field.id));
40
40
  case "hour":
41
41
  return ((0, jsx_runtime_1.jsx)(index_js_9.FormTimePicker, { title: `${field.required ? "*" : ""}${field.name}`, name: `${namesStr}${field.form_id}_${field.id}`, hint: field.hint, disabled: readOnly, defaultValue: defaultValue?.value }, field.id));
42
42
  case "date":
@@ -1,12 +1,17 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.FileUploadField = exports.FileUploadFieldWithoutValidation = void 0;
3
+ exports.FileUploadField = void 0;
4
4
  const jsx_runtime_1 = require("react/jsx-runtime");
5
5
  const icons_1 = require("@zauru-sdk/icons");
6
- const redux_1 = require("@zauru-sdk/redux");
7
6
  const react_1 = require("react");
8
- const FileUploadFieldWithoutValidation = (props) => {
9
- const { id, name, title, helpText, hint, onChange, disabled = false, readOnly = false, error, fileTypes = [], showAvailableTypes = false, className, defaultValue = undefined, download = false, } = props;
7
+ const react_hook_form_1 = require("react-hook-form");
8
+ const FileUploadField = (props) => {
9
+ const { id, name, title, helpText, hint, onChange, disabled = false, readOnly = false, fileTypes = [], showAvailableTypes = false, className, defaultValue = undefined, download = false, required = false, } = props;
10
+ const { register: tempRegister, formState: { errors }, } = (0, react_hook_form_1.useFormContext)() || { formState: {} }; // Obtener el contexto solo si existe
11
+ const error = errors ? errors[props.name ?? "-1"] : undefined;
12
+ const register = tempRegister
13
+ ? tempRegister(props.name ?? "-1", { required })
14
+ : undefined; // Solo usar register si está disponible
10
15
  const [showTooltip, setShowTooltip] = (0, react_1.useState)(false);
11
16
  if (typeof defaultValue == "string") {
12
17
  if (download) {
@@ -19,11 +24,25 @@ const FileUploadFieldWithoutValidation = (props) => {
19
24
  }
20
25
  }, children: [title && ((0, jsx_runtime_1.jsx)("label", { htmlFor: name, className: "block mb-1 text-sm font-medium text-gray-700", children: title })), " ", (0, jsx_runtime_1.jsx)(icons_1.DownloadIconSVG, {})] }));
21
26
  }
22
- return ((0, jsx_runtime_1.jsxs)("div", { className: `col-span-6 sm:col-span-3 ${className}`, children: [title && ((0, jsx_runtime_1.jsx)("label", { htmlFor: name, className: `block mb-1 text-sm font-medium text-gray-700`, children: title })), " ", (0, jsx_runtime_1.jsx)("div", { role: "button", tabIndex: 0, onClick: () => {
27
+ return ((0, jsx_runtime_1.jsxs)("div", { className: `col-span-6 sm:col-span-3 ${className}`, children: [title && ((0, jsx_runtime_1.jsxs)("label", { htmlFor: name, className: `block mb-1 text-sm font-medium text-gray-700`, children: [title, required && (0, jsx_runtime_1.jsx)("span", { className: "text-red-500", children: "*" })] })), " ", (0, jsx_runtime_1.jsx)("div", { role: "button", tabIndex: 0, onClick: () => {
28
+ if (register) {
29
+ register.onChange({
30
+ target: {
31
+ value: defaultValue,
32
+ },
33
+ });
34
+ }
23
35
  window.open(defaultValue, "_blank");
24
36
  }, onKeyDown: (event) => {
25
37
  // Permite que el evento se active con la tecla Enter
26
38
  if (event.key === "Enter") {
39
+ if (register) {
40
+ register.onChange({
41
+ target: {
42
+ value: defaultValue,
43
+ },
44
+ });
45
+ }
27
46
  window.open(defaultValue, "_blank");
28
47
  }
29
48
  }, children: (0, jsx_runtime_1.jsx)("img", { src: defaultValue, alt: name, className: `h-48 w-48 inline mr-1 pb-1`, style: {
@@ -47,13 +66,6 @@ const FileUploadFieldWithoutValidation = (props) => {
47
66
  const bgColor = isReadOnly ? "bg-gray-200" : `bg-${color}-50`;
48
67
  const textColor = isReadOnly ? "text-gray-500" : `text-${color}-900`;
49
68
  const borderColor = isReadOnly ? "border-gray-300" : `border-${color}-500`;
50
- return ((0, jsx_runtime_1.jsxs)("div", { className: `col-span-6 sm:col-span-3 ${className}`, children: [title && ((0, jsx_runtime_1.jsx)("label", { htmlFor: name, className: `block mb-1 text-sm font-medium text-${color}-700`, children: title })), (0, jsx_runtime_1.jsxs)("div", { className: "flex relative items-center", children: [(0, jsx_runtime_1.jsx)("input", { type: "file", name: name, id: id ?? name, disabled: disabled, readOnly: readOnly, accept: fileTypes.map((ft) => `.${ft}`).join(", "), onChange: handleInputChange, className: `block w-full rounded-md ${bgColor} ${borderColor} ${textColor} shadow-sm focus:border-indigo-500 focus:ring-indigo-500 sm:text-sm` }), helpText && ((0, jsx_runtime_1.jsx)("div", { className: "flex items-center relative ml-3", children: (0, jsx_runtime_1.jsxs)("div", { className: "relative cursor-pointer", onMouseEnter: () => setShowTooltip(true), onMouseLeave: () => setShowTooltip(false), children: [(0, jsx_runtime_1.jsx)(icons_1.IdeaIconSVG, {}), showTooltip && ((0, jsx_runtime_1.jsx)("div", { className: "absolute -left-48 top-0 mt-8 p-2 bg-white border rounded shadow text-black z-50", children: helpText }))] }) }))] }), error && ((0, jsx_runtime_1.jsxs)("p", { className: `mt-2 text-sm text-${color}-600`, children: [(0, jsx_runtime_1.jsx)("span", { className: "font-medium", children: "Oops!" }), " ", error] })), !error && hintMessage && ((0, jsx_runtime_1.jsx)("p", { className: `mt-2 italic text-sm text-${color}-500`, children: hintMessage }))] }));
51
- };
52
- exports.FileUploadFieldWithoutValidation = FileUploadFieldWithoutValidation;
53
- const FileUploadField = (props) => {
54
- const { formValidations } = (0, redux_1.useAppSelector)((state) => state.formValidation);
55
- const error = formValidations[props.formName ?? "-1"]?.[props.name ?? "-1"];
56
- props = { ...props, error };
57
- return (0, jsx_runtime_1.jsx)(exports.FileUploadFieldWithoutValidation, { ...props });
69
+ return ((0, jsx_runtime_1.jsxs)("div", { className: `col-span-6 sm:col-span-3 ${className}`, children: [title && ((0, jsx_runtime_1.jsx)("label", { htmlFor: name, className: `block mb-1 text-sm font-medium text-${color}-700`, children: title })), (0, jsx_runtime_1.jsxs)("div", { className: "flex relative items-center", children: [(0, jsx_runtime_1.jsx)("input", { type: "file", name: name, id: id ?? name, disabled: disabled, readOnly: readOnly, accept: fileTypes.map((ft) => `.${ft}`).join(", "), onChange: handleInputChange, className: `block w-full rounded-md ${bgColor} ${borderColor} ${textColor} shadow-sm focus:border-indigo-500 focus:ring-indigo-500 sm:text-sm` }), helpText && ((0, jsx_runtime_1.jsx)("div", { className: "flex items-center relative ml-3", children: (0, jsx_runtime_1.jsxs)("div", { className: "relative cursor-pointer", onMouseEnter: () => setShowTooltip(true), onMouseLeave: () => setShowTooltip(false), children: [(0, jsx_runtime_1.jsx)(icons_1.IdeaIconSVG, {}), showTooltip && ((0, jsx_runtime_1.jsx)("div", { className: "absolute -left-48 top-0 mt-8 p-2 bg-white border rounded shadow text-black z-50", children: helpText }))] }) }))] }), error && ((0, jsx_runtime_1.jsxs)("p", { className: `mt-2 text-sm text-${color}-600`, children: [(0, jsx_runtime_1.jsx)("span", { className: "font-medium", children: "Oops!" }), " ", error.message?.toString()] })), !error && hintMessage && ((0, jsx_runtime_1.jsx)("p", { className: `mt-2 italic text-sm text-${color}-500`, children: hintMessage }))] }));
58
70
  };
59
71
  exports.FileUploadField = FileUploadField;
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ReactZodForm = void 0;
4
+ const jsx_runtime_1 = require("react/jsx-runtime");
5
+ const zod_1 = require("@hookform/resolvers/zod");
6
+ const react_1 = require("@remix-run/react");
7
+ const react_hook_form_1 = require("react-hook-form");
8
+ const zod_2 = require("zod");
9
+ const emptySchema = zod_2.z.any();
10
+ const ReactZodForm = (props) => {
11
+ const { children, method = "post", schema = emptySchema, onSubmit, id, } = props;
12
+ const submit = (0, react_1.useSubmit)();
13
+ const methods = (0, react_hook_form_1.useForm)({
14
+ resolver: (0, zod_1.zodResolver)(schema),
15
+ mode: "onSubmit",
16
+ });
17
+ const handleSubmit = (data, event) => {
18
+ if (onSubmit) {
19
+ onSubmit(data, event);
20
+ }
21
+ else {
22
+ // If no onSubmit is provided, use Remix's submit function
23
+ submit(event?.target, { method });
24
+ }
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 }) }));
29
+ };
30
+ exports.ReactZodForm = ReactZodForm;
31
+ exports.default = exports.ReactZodForm;