@zauru-sdk/components 1.0.51 → 1.0.53

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 (181) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/dist/Buttons/Button.d.ts +1 -1
  3. package/dist/Table/ZauruTable.d.ts +1 -1
  4. package/dist/Zendesk/Chat.d.ts +1 -1
  5. package/dist/cjs/Alerts/ErrorBoundaryAlert/ErrorBoundaryAlert.js +9 -0
  6. package/dist/cjs/Alerts/StaticAlert.js +32 -0
  7. package/dist/cjs/Alerts/index.js +18 -0
  8. package/dist/cjs/BlockUI/BlockUI.js +12 -0
  9. package/dist/cjs/BlockUI/index.js +17 -0
  10. package/dist/cjs/Buttons/Button.js +47 -0
  11. package/dist/cjs/Buttons/index.js +17 -0
  12. package/dist/cjs/Card/Card.js +9 -0
  13. package/dist/cjs/Card/index.js +17 -0
  14. package/dist/cjs/Chat/ChatLayout.js +31 -0
  15. package/dist/cjs/Chat/ChatMessageHistory.js +57 -0
  16. package/dist/cjs/Chat/index.js +18 -0
  17. package/dist/cjs/ConnectionState/ConnectionState.js +25 -0
  18. package/dist/cjs/ConnectionState/index.js +17 -0
  19. package/dist/cjs/Containers/BodyContainer.js +9 -0
  20. package/dist/cjs/Containers/ButtonSectionContainer.js +9 -0
  21. package/dist/cjs/Containers/Container.js +10 -0
  22. package/dist/cjs/Containers/DoubleContainer.js +18 -0
  23. package/dist/cjs/Containers/MainContainer.js +9 -0
  24. package/dist/cjs/Containers/OutletContainer.js +9 -0
  25. package/dist/cjs/Containers/SubContainer.js +10 -0
  26. package/dist/cjs/Containers/index.js +23 -0
  27. package/dist/cjs/DynamicTable/BasicPrintDynamicTable.js +31 -0
  28. package/dist/cjs/DynamicTable/DynamicPrintTable.js +158 -0
  29. package/dist/cjs/DynamicTable/DynamicTable.js +219 -0
  30. package/dist/cjs/DynamicTable/GenericDynamicTable.js +200 -0
  31. package/dist/cjs/DynamicTable/index.js +20 -0
  32. package/dist/cjs/Footer/Footer.js +20 -0
  33. package/dist/cjs/Footer/index.js +17 -0
  34. package/dist/cjs/Form/Checkbox/index.js +39 -0
  35. package/dist/cjs/Form/Checklist/index.js +14 -0
  36. package/dist/cjs/Form/DatePicker/index.js +36 -0
  37. package/dist/cjs/Form/DynamicBaculoForm/index.js +144 -0
  38. package/dist/cjs/Form/FieldContainer/DoubleFieldContainer.js +18 -0
  39. package/dist/cjs/Form/FieldContainer/QuadrupleFieldContainer.js +18 -0
  40. package/dist/cjs/Form/FieldContainer/TripleFieldContainer.js +18 -0
  41. package/dist/cjs/Form/FieldContainer/index.js +19 -0
  42. package/dist/cjs/Form/FileUpload/index.js +59 -0
  43. package/dist/cjs/Form/FormButtons/index.js +9 -0
  44. package/dist/cjs/Form/FormLayout/index.js +11 -0
  45. package/dist/cjs/Form/SelectField/index.js +102 -0
  46. package/dist/cjs/Form/TextArea/index.js +41 -0
  47. package/dist/cjs/Form/TextField/index.js +75 -0
  48. package/dist/cjs/Form/TimePicker/index.js +36 -0
  49. package/dist/cjs/Form/YesNo/index.js +22 -0
  50. package/dist/cjs/Form/index.js +29 -0
  51. package/dist/cjs/Labels/InfoLabel/index.js +9 -0
  52. package/dist/cjs/Labels/index.js +17 -0
  53. package/dist/cjs/Layouts/homeLayout/index.js +14 -0
  54. package/dist/cjs/Layouts/index.js +17 -0
  55. package/dist/cjs/LineSeparator/LineSeparator.js +8 -0
  56. package/dist/cjs/LineSeparator/index.js +17 -0
  57. package/dist/cjs/Modal/Modal.js +36 -0
  58. package/dist/cjs/Modal/index.js +17 -0
  59. package/dist/cjs/NavBar/NavBar.js +36 -0
  60. package/dist/cjs/NavBar/NavBar.types.js +2 -0
  61. package/dist/cjs/NavBar/NavBar.utils.js +61 -0
  62. package/dist/cjs/NavBar/index.js +19 -0
  63. package/dist/cjs/ProgressBar/ProgressBar.js +9 -0
  64. package/dist/cjs/ProgressBar/ProgressCircle.js +26 -0
  65. package/dist/cjs/ProgressBar/index.js +18 -0
  66. package/dist/cjs/Skeletons/LoadingInputSkeleton.js +12 -0
  67. package/dist/cjs/Skeletons/index.js +17 -0
  68. package/dist/cjs/Tab/Tab.js +26 -0
  69. package/dist/cjs/Tab/index.js +17 -0
  70. package/dist/cjs/Table/ZauruTable.js +177 -0
  71. package/dist/cjs/Table/index.js +17 -0
  72. package/dist/cjs/TaskList/TaskList.js +40 -0
  73. package/dist/cjs/TaskList/index.js +17 -0
  74. package/dist/cjs/Titles/LabelArray.js +11 -0
  75. package/dist/cjs/Titles/TableColumnTitle.js +9 -0
  76. package/dist/cjs/Titles/TitleH1.js +9 -0
  77. package/dist/cjs/Titles/TitleH2.js +9 -0
  78. package/dist/cjs/Titles/TitleH3.js +9 -0
  79. package/dist/cjs/Titles/index.js +21 -0
  80. package/dist/cjs/Tooltip/Tooltip.js +18 -0
  81. package/dist/cjs/Tooltip/index.js +17 -0
  82. package/dist/cjs/WithTooltip/WithTooltip.js +9 -0
  83. package/dist/cjs/WithTooltip/index.js +17 -0
  84. package/dist/cjs/Wizards/StepWizard.js +18 -0
  85. package/dist/cjs/Wizards/index.js +17 -0
  86. package/dist/cjs/Zendesk/Chat.js +69 -0
  87. package/dist/cjs/Zendesk/index.js +18 -0
  88. package/dist/cjs/Zendesk/zendesk.config.js +31 -0
  89. package/dist/cjs/index.js +40 -0
  90. package/dist/cjs/tailwind.config.js +9 -0
  91. package/dist/{Table → esm/Table}/ZauruTable.js +3 -1
  92. package/package.json +12 -18
  93. package/src/Table/ZauruTable.tsx +4 -2
  94. package/tsconfig.cjs.json +8 -0
  95. package/tsconfig.esm.json +11 -0
  96. package/tsconfig.json +6 -15
  97. /package/dist/{Alerts → esm/Alerts}/ErrorBoundaryAlert/ErrorBoundaryAlert.js +0 -0
  98. /package/dist/{Alerts → esm/Alerts}/StaticAlert.js +0 -0
  99. /package/dist/{Alerts → esm/Alerts}/index.js +0 -0
  100. /package/dist/{BlockUI → esm/BlockUI}/BlockUI.js +0 -0
  101. /package/dist/{BlockUI → esm/BlockUI}/index.js +0 -0
  102. /package/dist/{Buttons → esm/Buttons}/Button.js +0 -0
  103. /package/dist/{Buttons → esm/Buttons}/index.js +0 -0
  104. /package/dist/{Card → esm/Card}/Card.js +0 -0
  105. /package/dist/{Card → esm/Card}/index.js +0 -0
  106. /package/dist/{Chat → esm/Chat}/ChatLayout.js +0 -0
  107. /package/dist/{Chat → esm/Chat}/ChatMessageHistory.js +0 -0
  108. /package/dist/{Chat → esm/Chat}/index.js +0 -0
  109. /package/dist/{ConnectionState → esm/ConnectionState}/ConnectionState.js +0 -0
  110. /package/dist/{ConnectionState → esm/ConnectionState}/index.js +0 -0
  111. /package/dist/{Containers → esm/Containers}/BodyContainer.js +0 -0
  112. /package/dist/{Containers → esm/Containers}/ButtonSectionContainer.js +0 -0
  113. /package/dist/{Containers → esm/Containers}/Container.js +0 -0
  114. /package/dist/{Containers → esm/Containers}/DoubleContainer.js +0 -0
  115. /package/dist/{Containers → esm/Containers}/MainContainer.js +0 -0
  116. /package/dist/{Containers → esm/Containers}/OutletContainer.js +0 -0
  117. /package/dist/{Containers → esm/Containers}/SubContainer.js +0 -0
  118. /package/dist/{Containers → esm/Containers}/index.js +0 -0
  119. /package/dist/{DynamicTable → esm/DynamicTable}/BasicPrintDynamicTable.js +0 -0
  120. /package/dist/{DynamicTable → esm/DynamicTable}/DynamicPrintTable.js +0 -0
  121. /package/dist/{DynamicTable → esm/DynamicTable}/DynamicTable.js +0 -0
  122. /package/dist/{DynamicTable → esm/DynamicTable}/GenericDynamicTable.js +0 -0
  123. /package/dist/{DynamicTable → esm/DynamicTable}/index.js +0 -0
  124. /package/dist/{Footer → esm/Footer}/Footer.js +0 -0
  125. /package/dist/{Footer → esm/Footer}/index.js +0 -0
  126. /package/dist/{Form → esm/Form}/Checkbox/index.js +0 -0
  127. /package/dist/{Form → esm/Form}/Checklist/index.js +0 -0
  128. /package/dist/{Form → esm/Form}/DatePicker/index.js +0 -0
  129. /package/dist/{Form → esm/Form}/DynamicBaculoForm/index.js +0 -0
  130. /package/dist/{Form → esm/Form}/FieldContainer/DoubleFieldContainer.js +0 -0
  131. /package/dist/{Form → esm/Form}/FieldContainer/QuadrupleFieldContainer.js +0 -0
  132. /package/dist/{Form → esm/Form}/FieldContainer/TripleFieldContainer.js +0 -0
  133. /package/dist/{Form → esm/Form}/FieldContainer/index.js +0 -0
  134. /package/dist/{Form → esm/Form}/FileUpload/index.js +0 -0
  135. /package/dist/{Form → esm/Form}/FormButtons/index.js +0 -0
  136. /package/dist/{Form → esm/Form}/FormLayout/index.js +0 -0
  137. /package/dist/{Form → esm/Form}/SelectField/index.js +0 -0
  138. /package/dist/{Form → esm/Form}/TextArea/index.js +0 -0
  139. /package/dist/{Form → esm/Form}/TextField/index.js +0 -0
  140. /package/dist/{Form → esm/Form}/TimePicker/index.js +0 -0
  141. /package/dist/{Form → esm/Form}/YesNo/index.js +0 -0
  142. /package/dist/{Form → esm/Form}/index.js +0 -0
  143. /package/dist/{Labels → esm/Labels}/InfoLabel/index.js +0 -0
  144. /package/dist/{Labels → esm/Labels}/index.js +0 -0
  145. /package/dist/{Layouts → esm/Layouts}/homeLayout/index.js +0 -0
  146. /package/dist/{Layouts → esm/Layouts}/index.js +0 -0
  147. /package/dist/{LineSeparator → esm/LineSeparator}/LineSeparator.js +0 -0
  148. /package/dist/{LineSeparator → esm/LineSeparator}/index.js +0 -0
  149. /package/dist/{Modal → esm/Modal}/Modal.js +0 -0
  150. /package/dist/{Modal → esm/Modal}/index.js +0 -0
  151. /package/dist/{NavBar → esm/NavBar}/NavBar.js +0 -0
  152. /package/dist/{NavBar → esm/NavBar}/NavBar.types.js +0 -0
  153. /package/dist/{NavBar → esm/NavBar}/NavBar.utils.js +0 -0
  154. /package/dist/{NavBar → esm/NavBar}/index.js +0 -0
  155. /package/dist/{ProgressBar → esm/ProgressBar}/ProgressBar.js +0 -0
  156. /package/dist/{ProgressBar → esm/ProgressBar}/ProgressCircle.js +0 -0
  157. /package/dist/{ProgressBar → esm/ProgressBar}/index.js +0 -0
  158. /package/dist/{Skeletons → esm/Skeletons}/LoadingInputSkeleton.js +0 -0
  159. /package/dist/{Skeletons → esm/Skeletons}/index.js +0 -0
  160. /package/dist/{Tab → esm/Tab}/Tab.js +0 -0
  161. /package/dist/{Tab → esm/Tab}/index.js +0 -0
  162. /package/dist/{Table → esm/Table}/index.js +0 -0
  163. /package/dist/{TaskList → esm/TaskList}/TaskList.js +0 -0
  164. /package/dist/{TaskList → esm/TaskList}/index.js +0 -0
  165. /package/dist/{Titles → esm/Titles}/LabelArray.js +0 -0
  166. /package/dist/{Titles → esm/Titles}/TableColumnTitle.js +0 -0
  167. /package/dist/{Titles → esm/Titles}/TitleH1.js +0 -0
  168. /package/dist/{Titles → esm/Titles}/TitleH2.js +0 -0
  169. /package/dist/{Titles → esm/Titles}/TitleH3.js +0 -0
  170. /package/dist/{Titles → esm/Titles}/index.js +0 -0
  171. /package/dist/{Tooltip → esm/Tooltip}/Tooltip.js +0 -0
  172. /package/dist/{Tooltip → esm/Tooltip}/index.js +0 -0
  173. /package/dist/{WithTooltip → esm/WithTooltip}/WithTooltip.js +0 -0
  174. /package/dist/{WithTooltip → esm/WithTooltip}/index.js +0 -0
  175. /package/dist/{Wizards → esm/Wizards}/StepWizard.js +0 -0
  176. /package/dist/{Wizards → esm/Wizards}/index.js +0 -0
  177. /package/dist/{Zendesk → esm/Zendesk}/Chat.js +0 -0
  178. /package/dist/{Zendesk → esm/Zendesk}/index.js +0 -0
  179. /package/dist/{Zendesk → esm/Zendesk}/zendesk.config.js +0 -0
  180. /package/dist/{index.js → esm/index.js} +0 -0
  181. /package/dist/{tailwind.config.js → esm/tailwind.config.js} +0 -0
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CheckBox = exports.CheckboxWithoutValidation = void 0;
4
+ const jsx_runtime_1 = require("react/jsx-runtime");
5
+ const redux_1 = require("@zauru-sdk/redux");
6
+ const react_1 = require("react");
7
+ const CheckboxWithoutValidation = (props) => {
8
+ const { id, name, defaultValue = false, onChange, disabled = false, error, label, } = props;
9
+ const [checked, setChecked] = (0, react_1.useState)(defaultValue);
10
+ (0, react_1.useEffect)(() => {
11
+ setChecked(defaultValue);
12
+ }, [defaultValue]);
13
+ const handleInputChange = (event) => {
14
+ const isChecked = event.target.checked;
15
+ if (onChange) {
16
+ const result = onChange(isChecked, event);
17
+ if (result?.stopUIChange) {
18
+ return;
19
+ }
20
+ }
21
+ setChecked(isChecked);
22
+ };
23
+ const color = error ? "red" : "gray";
24
+ 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 }));
26
+ if (!error && !label) {
27
+ return inputComponent;
28
+ }
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 });
38
+ };
39
+ exports.CheckBox = CheckBox;
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Checklist = void 0;
4
+ const jsx_runtime_1 = require("react/jsx-runtime");
5
+ const index_js_1 = require("../Checkbox/index.js");
6
+ const Checklist = ({ items, onChange }) => {
7
+ const handleCheckboxChange = (name, value) => {
8
+ if (onChange) {
9
+ onChange(name, value);
10
+ }
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))) }));
13
+ };
14
+ exports.Checklist = Checklist;
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.FormDatePicker = exports.FormDatePickerWithoutValidation = void 0;
4
+ const jsx_runtime_1 = require("react/jsx-runtime");
5
+ const react_1 = require("react");
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;
10
+ const [value, setValue] = (0, react_1.useState)(defaultValue);
11
+ const [showTooltip, setShowTooltip] = (0, react_1.useState)(false);
12
+ const color = error ? "red" : "gray";
13
+ const isReadOnly = disabled;
14
+ const bgColor = isReadOnly ? "bg-gray-200" : `bg-${color}-50`;
15
+ const textColor = isReadOnly ? "text-gray-500" : `text-${color}-500`;
16
+ const borderColor = isReadOnly ? "border-gray-300" : `border-${color}-200`;
17
+ (0, react_1.useEffect)(() => {
18
+ setValue(defaultValue);
19
+ }, [defaultValue]);
20
+ const clearValue = () => {
21
+ setValue("");
22
+ onChange && onChange("");
23
+ };
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) => {
25
+ setValue(e.target.value);
26
+ 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 });
35
+ };
36
+ exports.FormDatePicker = FormDatePicker;
@@ -0,0 +1,144 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DynamicBaculoForm = void 0;
4
+ const jsx_runtime_1 = require("react/jsx-runtime");
5
+ const index_js_1 = require("../TextField/index.js");
6
+ const index_js_2 = require("../FieldContainer/index.js");
7
+ const index_js_3 = require("../FieldContainer/index.js");
8
+ const index_js_4 = require("../YesNo/index.js");
9
+ const index_js_5 = require("../TextArea/index.js");
10
+ const index_js_6 = require("../SelectField/index.js");
11
+ const index_js_7 = require("../FileUpload/index.js");
12
+ const index_js_8 = require("../DatePicker/index.js");
13
+ const index_js_9 = require("../TimePicker/index.js");
14
+ const GenericDynamicTable_js_1 = require("../../DynamicTable/GenericDynamicTable.js");
15
+ const common_1 = require("@zauru-sdk/common");
16
+ const index_js_10 = require("../../Alerts/index.js");
17
+ const index_js_11 = require("../../Containers/index.js");
18
+ const index_js_12 = require("../../LineSeparator/index.js");
19
+ function DynamicBaculoForm(props) {
20
+ const { form, options = { showDescription: false, showTitle: false }, formName = "", namesStr = "", defaultValues = [], showingRules = [], readOnly = false, } = props;
21
+ if (!form) {
22
+ return ((0, jsx_runtime_1.jsx)(index_js_10.StaticAlert, { title: "No se encontr\u00F3 el formulario din\u00E1mico", description: `Ocurrió un error encontrando el formulario para ${formName}, contacte al administrador con este mensaje de error.`, type: "info" }));
23
+ }
24
+ const renderFieldComponent = (field) => {
25
+ const defaultValue = defaultValues?.find((x) => x.settings_form_field.print_var_name === field.print_var_name);
26
+ switch (field.field_type) {
27
+ case "fixed_rows_table":
28
+ case "fixed_columns_table": {
29
+ const columns = field.settings_form_field_table_headers?.map((x) => {
30
+ return {
31
+ label: x.name,
32
+ name: `${namesStr}${x.id}_${field.id}`,
33
+ type: x.cell_type === "yes_no" ? "checkbox" : "textField",
34
+ };
35
+ }) ?? [];
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
+ }
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));
40
+ case "hour":
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
+ case "date":
43
+ return ((0, jsx_runtime_1.jsx)(index_js_8.FormDatePicker, { title: `${field.required ? "*" : ""}${field.name}`, name: `${namesStr}${field.form_id}_${field.id}`, hint: field.hint, disabled: readOnly, defaultValue: defaultValue?.value }, field.id));
44
+ case "file":
45
+ return ((0, jsx_runtime_1.jsx)(index_js_7.FileUploadField, { title: `${field.required ? "*" : ""}${field.name}`, name: `${namesStr}${field.form_id}_${field.id}`, hint: field.hint, disabled: readOnly, defaultValue: defaultValue?.value, download: true }, field.id));
46
+ case "image":
47
+ return ((0, jsx_runtime_1.jsx)(index_js_7.FileUploadField, { title: `${field.required ? "*" : ""}${field.name}`, name: `${namesStr}${field.form_id}_${field.id}`, hint: field.hint, showAvailableTypes: true, fileTypes: ["png", "jpg", "jpeg"], disabled: readOnly, defaultValue: defaultValue?.value }, field.id));
48
+ case "pdf":
49
+ return ((0, jsx_runtime_1.jsx)(index_js_7.FileUploadField, { title: `${field.required ? "*" : ""}${field.name}`, name: `${namesStr}${field.form_id}_${field.id}`, hint: field.hint, showAvailableTypes: true, fileTypes: ["pdf"], disabled: readOnly, defaultValue: defaultValue?.value, download: true }, field.id));
50
+ case "email":
51
+ case "url":
52
+ case "text":
53
+ case "currency":
54
+ case "country":
55
+ return ((0, jsx_runtime_1.jsx)(index_js_1.TextField, { title: `${field.required ? "*" : ""}${field.name}`, name: `${namesStr}${field.form_id}_${field.id}`, hint: field.hint, defaultValue: defaultValue?.value ?? field.default_value, disabled: readOnly }, field.id));
56
+ case "percentage":
57
+ case "number":
58
+ return ((0, jsx_runtime_1.jsx)(index_js_1.TextField, { title: `${field.required ? "*" : ""}${field.name}`, name: `${namesStr}${field.form_id}_${field.id}`, hint: field.hint, defaultValue: defaultValue?.value ?? field.default_value, type: "number", disabled: readOnly }, field.id));
59
+ case "yes_no":
60
+ return ((0, jsx_runtime_1.jsx)(index_js_4.YesNo, { title: `${field.required ? "*" : ""}${field.name}`, name: `${namesStr}${field.form_id}_${field.id}`, disabled: readOnly, defaultValue: field.default_value === "true" || defaultValue?.value === "true" }, field.id));
61
+ case "section":
62
+ return ((0, jsx_runtime_1.jsxs)("div", { children: [(0, jsx_runtime_1.jsx)(index_js_12.LineSeparator, {}), (0, jsx_runtime_1.jsx)("h3", { className: "mb-10 text-3xl font-bold leading-8 text-gray-900", children: field.name })] }, field.id));
63
+ case "multi_line_text":
64
+ return ((0, jsx_runtime_1.jsx)(index_js_5.TextArea, { title: `${field.required ? "*" : ""}${field.name}`, name: `${namesStr}${field.form_id}_${field.id}`, defaultValue: defaultValue?.value ?? field.default_value, hint: field.hint, disabled: readOnly }, field.id));
65
+ case "gt_departamentos": {
66
+ const optionsDep = (0, common_1.getDepSelectOptions)();
67
+ return ((0, jsx_runtime_1.jsx)(index_js_6.SelectField, { title: `${field.required ? "*" : ""}${field.name}`, name: `${namesStr}${field.form_id}_${field.id}`, hint: field.hint, isClearable: !field.required, options: optionsDep, disabled: readOnly, defaultValue: optionsDep.find((x) => x.value === defaultValue?.value) }, field.id));
68
+ }
69
+ case "gt_municipios": {
70
+ const options = (0, common_1.getMunSelectOptions)();
71
+ return ((0, jsx_runtime_1.jsx)(index_js_6.SelectField, { title: `${field.required ? "*" : ""}${field.name}`, name: `${namesStr}${field.form_id}_${field.id}`, hint: field.hint, isClearable: !field.required, options: options, disabled: readOnly, defaultValue: options.find((x) => x.value === defaultValue?.value) }, field.id));
72
+ }
73
+ case "single_select_options": {
74
+ const formFieldOptions = field.settings_form_field_options?.map((x) => {
75
+ return { label: x.label, value: x.value };
76
+ }) ?? [];
77
+ return ((0, jsx_runtime_1.jsx)(index_js_6.SelectField, { title: `${field.required ? "*" : ""}${field.name}`, name: `${namesStr}${field.form_id}_${field.id}`, hint: field.hint, isClearable: !field.required, options: formFieldOptions, disabled: readOnly, defaultValue: formFieldOptions.find((x) => x.value === defaultValue?.value) }, field.id));
78
+ }
79
+ case "multi_select_options": {
80
+ const formFieldOptions2 = field.settings_form_field_options?.map((x) => {
81
+ return { label: x.label, value: x.value };
82
+ }) ?? [];
83
+ const defaultValuesMulti = (() => {
84
+ const values = defaultValue?.value?.split(",").map((str) => str.trim()) ?? [];
85
+ return formFieldOptions2.filter((x) => values.includes(x.value));
86
+ })();
87
+ return ((0, jsx_runtime_1.jsx)(index_js_6.SelectField, { title: `${field.required ? "*" : ""}${field.name}`, name: `${namesStr}${field.form_id}_${field.id}`, hint: field.hint, isClearable: !field.required, isMulti: true, options: formFieldOptions2, defaultValueMulti: defaultValuesMulti, disabled: readOnly }, field.id));
88
+ }
89
+ default:
90
+ return ((0, jsx_runtime_1.jsxs)("div", { children: ["Componente no encontrado para: ", field.field_type] }, field.id)); // o algún componente por defecto si lo prefieres
91
+ }
92
+ };
93
+ const renderFields = () => {
94
+ const fields = form.settings_form_fields;
95
+ const fieldGroups = [];
96
+ let tempGroup = [];
97
+ fields.forEach((field, i) => {
98
+ const rule = showingRules.find((x) => x.name === field.name);
99
+ if (!(rule && !rule.show)) {
100
+ const renderedField = renderFieldComponent(field);
101
+ if (renderedField === null) {
102
+ return;
103
+ }
104
+ tempGroup.push(renderedField);
105
+ const isLastField = i === fields.length - 1;
106
+ const isSectionField = field.field_type === "section";
107
+ if (isSectionField) {
108
+ tempGroup.pop();
109
+ if (tempGroup.length === 1) {
110
+ fieldGroups.push(tempGroup[0]);
111
+ }
112
+ else if (tempGroup.length === 2) {
113
+ fieldGroups.push((0, jsx_runtime_1.jsx)(index_js_3.DoubleFieldContainer, { children: tempGroup }, i));
114
+ }
115
+ else if (tempGroup.length === 3) {
116
+ fieldGroups.push((0, jsx_runtime_1.jsx)(index_js_2.TripleFieldContainer, { children: tempGroup }, i));
117
+ }
118
+ fieldGroups.push(renderedField);
119
+ tempGroup = [];
120
+ }
121
+ else if (isLastField) {
122
+ if (tempGroup.length === 1) {
123
+ fieldGroups.push(tempGroup[0]);
124
+ }
125
+ else if (tempGroup.length === 2) {
126
+ fieldGroups.push((0, jsx_runtime_1.jsx)(index_js_3.DoubleFieldContainer, { children: tempGroup }, i));
127
+ }
128
+ else if (tempGroup.length === 3) {
129
+ fieldGroups.push((0, jsx_runtime_1.jsx)(index_js_2.TripleFieldContainer, { children: tempGroup }, i));
130
+ }
131
+ tempGroup = [];
132
+ }
133
+ else if (tempGroup.length === 3) {
134
+ // Si hay 3 elementos en el grupo temporal y el siguiente campo no es 'section', se agrega a fieldGroups
135
+ fieldGroups.push((0, jsx_runtime_1.jsx)(index_js_2.TripleFieldContainer, { children: tempGroup }, i));
136
+ tempGroup = [];
137
+ }
138
+ }
139
+ });
140
+ return fieldGroups;
141
+ };
142
+ return ((0, jsx_runtime_1.jsx)(index_js_11.SubContainer, { title: options?.showTitle ? form.name : undefined, description: options?.showDescription ? form.description : undefined, children: renderFields() }));
143
+ }
144
+ exports.DynamicBaculoForm = DynamicBaculoForm;
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DoubleFieldContainer = void 0;
4
+ const jsx_runtime_1 = require("react/jsx-runtime");
5
+ const DoubleFieldContainer = (props) => {
6
+ const { children, className, alignCenter = true } = props;
7
+ const getChildren = (index) => {
8
+ if (children && Array.isArray(children) && children[index]) {
9
+ return children[index];
10
+ }
11
+ if (children && index === 0) {
12
+ return children;
13
+ }
14
+ return (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, {});
15
+ };
16
+ return ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: (0, jsx_runtime_1.jsxs)("div", { className: `grid md:grid-cols-2 sm:grid-cols-1 gap-4 ${className}`, style: alignCenter ? { alignItems: "center" } : {}, children: [(0, jsx_runtime_1.jsx)("div", { className: "col-span-1", children: getChildren(0) }), (0, jsx_runtime_1.jsx)("div", { className: "col-span-1", children: getChildren(1) })] }) }));
17
+ };
18
+ exports.DoubleFieldContainer = DoubleFieldContainer;
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.QuadrupleFieldContainer = void 0;
4
+ const jsx_runtime_1 = require("react/jsx-runtime");
5
+ const QuadrupleFieldContainer = (props) => {
6
+ const { children, className } = props;
7
+ const getChildren = (index) => {
8
+ if (children && Array.isArray(children) && children[index]) {
9
+ return children[index];
10
+ }
11
+ if (children && index === 0) {
12
+ return children;
13
+ }
14
+ return (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, {});
15
+ };
16
+ return ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: (0, jsx_runtime_1.jsxs)("div", { className: `grid lg:grid-cols-4 sm:grid-cols-2 xs:grid-cols-1 gap-4 ${className}`, style: { alignItems: "center" }, children: [(0, jsx_runtime_1.jsx)("div", { className: "col-span-1", children: getChildren(0) }), (0, jsx_runtime_1.jsx)("div", { className: "col-span-1", children: getChildren(1) }), (0, jsx_runtime_1.jsx)("div", { className: "col-span-1", children: getChildren(2) }), (0, jsx_runtime_1.jsx)("div", { className: "col-span-1", children: getChildren(3) })] }) }));
17
+ };
18
+ exports.QuadrupleFieldContainer = QuadrupleFieldContainer;
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.TripleFieldContainer = void 0;
4
+ const jsx_runtime_1 = require("react/jsx-runtime");
5
+ const TripleFieldContainer = (props) => {
6
+ const { children, className } = props;
7
+ const getChildren = (index) => {
8
+ if (children && Array.isArray(children) && children[index]) {
9
+ return children[index];
10
+ }
11
+ if (children && index === 0) {
12
+ return children;
13
+ }
14
+ return (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, {});
15
+ };
16
+ return ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: (0, jsx_runtime_1.jsxs)("div", { className: `grid sm:grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4 ${className}`, style: { alignItems: "center" }, children: [(0, jsx_runtime_1.jsx)("div", { className: "col-span-1", children: getChildren(0) }), (0, jsx_runtime_1.jsx)("div", { className: "col-span-1", children: getChildren(1) }), (0, jsx_runtime_1.jsx)("div", { className: "col-span-1", children: getChildren(2) })] }) }));
17
+ };
18
+ exports.TripleFieldContainer = TripleFieldContainer;
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./DoubleFieldContainer.js"), exports);
18
+ __exportStar(require("./QuadrupleFieldContainer.js"), exports);
19
+ __exportStar(require("./TripleFieldContainer.js"), exports);
@@ -0,0 +1,59 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.FileUploadField = exports.FileUploadFieldWithoutValidation = void 0;
4
+ const jsx_runtime_1 = require("react/jsx-runtime");
5
+ const icons_1 = require("@zauru-sdk/icons");
6
+ const redux_1 = require("@zauru-sdk/redux");
7
+ 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;
10
+ const [showTooltip, setShowTooltip] = (0, react_1.useState)(false);
11
+ if (typeof defaultValue == "string") {
12
+ if (download) {
13
+ return ((0, jsx_runtime_1.jsxs)("div", { role: "button", tabIndex: 0, onClick: () => {
14
+ window.open(defaultValue, "_blank");
15
+ }, onKeyDown: (event) => {
16
+ // Permite que el evento se active con la tecla Enter
17
+ if (event.key === "Enter") {
18
+ window.open(defaultValue, "_blank");
19
+ }
20
+ }, 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
+ }
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: () => {
23
+ window.open(defaultValue, "_blank");
24
+ }, onKeyDown: (event) => {
25
+ // Permite que el evento se active con la tecla Enter
26
+ if (event.key === "Enter") {
27
+ window.open(defaultValue, "_blank");
28
+ }
29
+ }, children: (0, jsx_runtime_1.jsx)("img", { src: defaultValue, alt: name, className: `h-48 w-48 inline mr-1 pb-1`, style: {
30
+ stroke: "currentColor",
31
+ strokeWidth: 2,
32
+ strokeLinecap: "round",
33
+ strokeLinejoin: "round",
34
+ fill: "none",
35
+ backgroundColor: "transparent",
36
+ } }) })] }));
37
+ }
38
+ const handleInputChange = (event) => {
39
+ onChange && onChange(event);
40
+ };
41
+ let hintMessage = hint;
42
+ if (showAvailableTypes && fileTypes.length > 0) {
43
+ hintMessage = `${hint} Archivos permitidos: ${fileTypes.join(", ")}`;
44
+ }
45
+ const color = error ? "red" : "gray";
46
+ const isReadOnly = disabled || readOnly;
47
+ const bgColor = isReadOnly ? "bg-gray-200" : `bg-${color}-50`;
48
+ const textColor = isReadOnly ? "text-gray-500" : `text-${color}-900`;
49
+ 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 });
58
+ };
59
+ exports.FileUploadField = FileUploadField;
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.FormButtons = void 0;
4
+ const jsx_runtime_1 = require("react/jsx-runtime");
5
+ const FormButtons = (props) => {
6
+ const { saveTitle = "Guardar", saveName = "save", cancelTitle = "Cancelar", cancelName = "cancel", showCancel = true, showClear = false, clearName = "clear", clearTitle = "Limpiar", loading = false, onClickSave, loadingSaveText = "Guardando...", } = props;
7
+ return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [showClear && ((0, jsx_runtime_1.jsx)("button", { type: "reset", name: "action", disabled: loading, value: clearName, className: `ml-5 ${loading ? " bg-opacity-25 cursor-progress" : ""} rounded-md border border-gray-300 bg-white py-2 px-3 text-sm font-medium leading-4 text-gray-700 shadow-sm hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:ring-offset-2`, children: clearTitle })), showCancel && ((0, jsx_runtime_1.jsx)("button", { type: "button", name: "action", disabled: loading, value: cancelName, className: `${showClear ? "ml-2" : "ml-5"} ${loading ? " bg-opacity-25 cursor-progress" : ""} rounded-md border border-gray-300 bg-white py-2 px-3 text-sm font-medium leading-4 text-gray-700 shadow-sm hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:ring-offset-2`, children: cancelTitle })), (0, jsx_runtime_1.jsx)("button", { type: "submit", name: "action", disabled: loading, value: saveName, onClick: onClickSave, className: `ml-2 ${loading ? " bg-opacity-25 cursor-progress" : "hover:bg-indigo-700"} inline-flex justify-center rounded-md border border-transparent bg-indigo-600 py-2 px-4 text-sm font-medium text-white shadow-sm focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:ring-offset-2`, children: loading ? loadingSaveText : saveTitle })] }));
8
+ };
9
+ exports.FormButtons = FormButtons;
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.FormLayout = void 0;
4
+ const jsx_runtime_1 = require("react/jsx-runtime");
5
+ const react_1 = require("@remix-run/react");
6
+ const index_js_1 = require("../../Containers/index.js");
7
+ const FormLayout = (props) => {
8
+ const { title, children, buttons, method, formId } = props;
9
+ return ((0, jsx_runtime_1.jsxs)(react_1.Form, { id: formId, name: formId, method: method ?? "post", children: [title && ((0, jsx_runtime_1.jsx)("label", { className: "block text-sm font-medium text-gray-700 mb-3", children: title })), (0, jsx_runtime_1.jsxs)("div", { className: "shadow sm:overflow-hidden sm:rounded-md", children: [(0, jsx_runtime_1.jsx)("div", { className: "space-y-6 bg-white px-4 py-5 sm:p-6", children: children }), buttons && ((0, jsx_runtime_1.jsx)(index_js_1.ButtonSectionContainer, { children: buttons }))] })] }, formId));
10
+ };
11
+ exports.FormLayout = FormLayout;
@@ -0,0 +1,102 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.SelectField = exports.SelectFieldWithoutValidation = void 0;
27
+ const jsx_runtime_1 = require("react/jsx-runtime");
28
+ const icons_1 = require("@zauru-sdk/icons");
29
+ const redux_1 = require("@zauru-sdk/redux");
30
+ const react_1 = require("react");
31
+ const react_select_1 = __importStar(require("react-select"));
32
+ const index_js_1 = require("../../Skeletons/index.js");
33
+ const Input = (props) => ((0, jsx_runtime_1.jsx)(react_select_1.components.Input, { ...props, readOnly: props.selectProps.isReadOnly }));
34
+ const SelectFieldWithoutValidation = (props) => {
35
+ const { id, name, title, defaultValue, defaultValueMulti = [], helpText, hint, options, onChange, onChangeMulti, isClearable = false, error = false, disabled = false, readOnly = false, isMulti = false, loading = false, className = "", onInputChange, } = props;
36
+ const [value, setValue] = (0, react_1.useState)(defaultValue || null);
37
+ const [valueMulti, setValueMulti] = (0, react_1.useState)(defaultValueMulti);
38
+ const [inputValue, setInputValue] = (0, react_1.useState)("");
39
+ const [showTooltip, setShowTooltip] = (0, react_1.useState)(false);
40
+ const [isClient, setIsClient] = (0, react_1.useState)(typeof window !== "undefined");
41
+ const menuIsOpen = readOnly ? false : props?.menuIsOpen;
42
+ const color = error ? "red" : "gray";
43
+ let documentRef = null;
44
+ const isReadOnly = disabled || readOnly;
45
+ const bgColor = isReadOnly ? "bg-gray-200" : `bg-${color}-50`;
46
+ const textColor = isReadOnly ? "text-gray-500" : `text-${color}-900`;
47
+ const borderColor = isReadOnly ? "border-gray-300" : `border-${color}-500`;
48
+ if (typeof window !== "undefined") {
49
+ documentRef = document;
50
+ }
51
+ (0, react_1.useEffect)(() => {
52
+ setValue(defaultValue || null);
53
+ }, [defaultValue]);
54
+ (0, react_1.useEffect)(() => {
55
+ setIsClient(true);
56
+ }, []);
57
+ if (!isClient || loading || !documentRef) {
58
+ 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 text-${color}-700 dark:text-${color}-500`, children: title })), (0, jsx_runtime_1.jsx)(index_js_1.LoadingInputSkeleton, {}), helpText && ((0, jsx_runtime_1.jsx)("p", { className: `mt-2 italic text-sm text-${color}-500 dark:text-${color}-400`, children: helpText }))] }));
59
+ }
60
+ const handleOnChange = (selection) => {
61
+ // Verificar si el valor de selección es un objeto con propiedades 'value' y 'label'
62
+ if (typeof selection === "object" &&
63
+ selection !== null &&
64
+ "value" in selection &&
65
+ "label" in selection) {
66
+ setValue(selection);
67
+ onChange && onChange(selection);
68
+ }
69
+ else {
70
+ setValue(null);
71
+ onChange && onChange(null);
72
+ }
73
+ };
74
+ const handleOnChangeMulti = (selection) => {
75
+ if (Array.isArray(selection)) {
76
+ setValueMulti(selection);
77
+ onChangeMulti &&
78
+ onChangeMulti(selection);
79
+ }
80
+ else {
81
+ setValueMulti([]);
82
+ onChangeMulti && onChangeMulti([]);
83
+ }
84
+ };
85
+ const selectComponent = ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(react_select_1.default, { className: `block w-full rounded-md ${bgColor} ${borderColor} ${textColor} shadow-sm focus:border-indigo-500 focus:ring-indigo-500 sm:text-sm`, id: isMulti ? undefined : id, instanceId: isMulti ? undefined : id, isDisabled: disabled, name: isMulti ? undefined : name, options: options, onChange: isMulti ? handleOnChangeMulti : handleOnChange, defaultValue: isMulti ? valueMulti : value, onInputChange: (newValue, actionMeta) => {
86
+ setInputValue(newValue);
87
+ onInputChange && onInputChange(newValue, actionMeta);
88
+ }, inputValue: inputValue, onMenuOpen: () => { }, onMenuClose: () => { }, menuPortalTarget: documentRef?.body, styles: { menuPortal: (base) => ({ ...base, zIndex: 9999 }) }, isClearable: isClearable, isSearchable: true, components: { Input }, menuIsOpen: menuIsOpen,
89
+ //windowThreshold={50}
90
+ isMulti: isMulti }), isMulti && ((0, jsx_runtime_1.jsx)("input", { hidden: true, readOnly: true, name: name, value: valueMulti.map((x) => x?.value).join(","), id: id }))] }));
91
+ 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: error ? `${name}-error` : `${name}-success`, className: `block text-sm font-medium ${color === "red"
92
+ ? "text-red-700 dark:text-red-500"
93
+ : "text-gray-700 dark:text-gray-500"}`, children: title })), (0, jsx_runtime_1.jsxs)("div", { className: "flex relative items-center", children: [selectComponent, 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 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 }))] }));
94
+ };
95
+ exports.SelectFieldWithoutValidation = SelectFieldWithoutValidation;
96
+ const SelectField = (props) => {
97
+ const { formValidations } = (0, redux_1.useAppSelector)((state) => state.formValidation);
98
+ const error = formValidations[props.formName ?? "-1"]?.[props.name ?? "-1"];
99
+ props = { ...props, error };
100
+ return (0, jsx_runtime_1.jsx)(exports.SelectFieldWithoutValidation, { ...props });
101
+ };
102
+ exports.SelectField = SelectField;
@@ -0,0 +1,41 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.TextArea = exports.TextAreaWithoutValidation = void 0;
4
+ const jsx_runtime_1 = require("react/jsx-runtime");
5
+ const redux_1 = require("@zauru-sdk/redux");
6
+ const react_1 = require("react");
7
+ const TextAreaWithoutValidation = (props) => {
8
+ const { id, name, title, defaultValue = "", hidden, hint, onChange, onKeyDown, disabled = false, error = false, readOnly = false, rows, cols, stopChangeEvents, className = "", } = props;
9
+ const [value, setValue] = (0, react_1.useState)(defaultValue);
10
+ const color = error ? "red" : "gray";
11
+ const isReadOnly = disabled || readOnly;
12
+ const bgColor = isReadOnly ? "bg-gray-200" : `bg-${color}-50`;
13
+ const textColor = isReadOnly ? "text-gray-500" : `text-${color}-900`;
14
+ const borderColor = isReadOnly ? "border-gray-300" : `border-${color}-500`;
15
+ (0, react_1.useEffect)(() => {
16
+ setValue(defaultValue);
17
+ }, [defaultValue]);
18
+ if (hidden) {
19
+ return ((0, jsx_runtime_1.jsx)("textarea", { id: id ?? name, name: name, value: defaultValue, readOnly: true, hidden: true }));
20
+ }
21
+ const handleInputChange = (event) => {
22
+ if (stopChangeEvents) {
23
+ event.stopPropagation();
24
+ event.preventDefault();
25
+ }
26
+ setValue(event.target.value);
27
+ onChange && onChange(event.target.value);
28
+ };
29
+ 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: error ? `${name}-error` : `${name}-success`, className: `block text-sm font-medium text-${color}-700 dark:text-${color}-500`, children: title })), (0, jsx_runtime_1.jsx)("textarea", { name: name, readOnly: readOnly, disabled: disabled, id: id ?? name, autoComplete: "given-name", value: value, rows: rows, cols: cols, onChange: handleInputChange, onKeyDown: (event) => {
30
+ onKeyDown && onKeyDown(event);
31
+ }, className: `mt-1 block w-full rounded-md ${bgColor} ${borderColor} ${textColor} shadow-sm focus:border-indigo-500 focus:ring-indigo-500 sm:text-sm` }), 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 }))] }));
32
+ };
33
+ exports.TextAreaWithoutValidation = TextAreaWithoutValidation;
34
+ //<reference> https://tailwindui.com/components/application-ui/forms/form-layouts
35
+ const TextArea = (props) => {
36
+ const { formValidations } = (0, redux_1.useAppSelector)((state) => state.formValidation);
37
+ const error = formValidations[props.formName ?? "-1"]?.[props.name ?? "-1"];
38
+ props = { ...props, error };
39
+ return (0, jsx_runtime_1.jsx)(exports.TextAreaWithoutValidation, { ...props });
40
+ };
41
+ exports.TextArea = TextArea;