@zauru-sdk/components 1.0.54 → 1.0.61

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 (94) hide show
  1. package/CHANGELOG.md +56 -0
  2. package/LICENCE.md +11 -11
  3. package/package.json +7 -7
  4. package/src/Alerts/ErrorBoundaryAlert/ErrorBoundaryAlert.tsx +66 -66
  5. package/src/Alerts/StaticAlert.tsx +121 -121
  6. package/src/Alerts/index.ts +2 -2
  7. package/src/BlockUI/BlockUI.tsx +50 -50
  8. package/src/BlockUI/index.tsx +1 -1
  9. package/src/Buttons/Button.tsx +90 -90
  10. package/src/Buttons/index.ts +1 -1
  11. package/src/Card/Card.tsx +24 -24
  12. package/src/Card/index.ts +1 -1
  13. package/src/Chat/ChatLayout.tsx +131 -131
  14. package/src/Chat/ChatMessageHistory.tsx +142 -142
  15. package/src/Chat/index.ts +2 -2
  16. package/src/ConnectionState/ConnectionState.tsx +27 -27
  17. package/src/ConnectionState/index.tsx +1 -1
  18. package/src/Containers/BodyContainer.tsx +14 -14
  19. package/src/Containers/ButtonSectionContainer.tsx +21 -21
  20. package/src/Containers/Container.tsx +39 -39
  21. package/src/Containers/DoubleContainer.tsx +48 -48
  22. package/src/Containers/MainContainer.tsx +17 -17
  23. package/src/Containers/OutletContainer.tsx +14 -14
  24. package/src/Containers/SubContainer.tsx +37 -37
  25. package/src/Containers/index.ts +7 -7
  26. package/src/DynamicTable/BasicPrintDynamicTable.tsx +73 -73
  27. package/src/DynamicTable/DynamicPrintTable.tsx +288 -288
  28. package/src/DynamicTable/DynamicTable.tsx +405 -405
  29. package/src/DynamicTable/GenericDynamicTable.tsx +456 -456
  30. package/src/DynamicTable/index.tsx +4 -4
  31. package/src/Footer/Footer.tsx +50 -50
  32. package/src/Footer/index.tsx +1 -1
  33. package/src/Form/Checkbox/index.tsx +96 -96
  34. package/src/Form/Checklist/index.tsx +35 -35
  35. package/src/Form/DatePicker/index.tsx +132 -132
  36. package/src/Form/DynamicBaculoForm/index.tsx +361 -361
  37. package/src/Form/FieldContainer/DoubleFieldContainer.tsx +35 -35
  38. package/src/Form/FieldContainer/QuadrupleFieldContainer.tsx +36 -36
  39. package/src/Form/FieldContainer/TripleFieldContainer.tsx +35 -35
  40. package/src/Form/FieldContainer/index.ts +3 -3
  41. package/src/Form/FileUpload/index.tsx +184 -184
  42. package/src/Form/FormButtons/index.tsx +78 -78
  43. package/src/Form/FormLayout/index.tsx +37 -37
  44. package/src/Form/SelectField/index.tsx +237 -237
  45. package/src/Form/TextArea/index.tsx +125 -125
  46. package/src/Form/TextField/index.tsx +194 -194
  47. package/src/Form/TimePicker/index.tsx +127 -127
  48. package/src/Form/YesNo/index.tsx +77 -77
  49. package/src/Form/index.ts +13 -13
  50. package/src/Labels/InfoLabel/index.tsx +21 -21
  51. package/src/Labels/index.tsx +1 -1
  52. package/src/Layouts/homeLayout/index.tsx +34 -34
  53. package/src/Layouts/index.ts +1 -1
  54. package/src/LineSeparator/LineSeparator.tsx +3 -3
  55. package/src/LineSeparator/index.tsx +1 -1
  56. package/src/Modal/Modal.tsx +104 -104
  57. package/src/Modal/index.tsx +1 -1
  58. package/src/NavBar/NavBar.tsx +223 -223
  59. package/src/NavBar/NavBar.types.ts +64 -64
  60. package/src/NavBar/NavBar.utils.ts +58 -58
  61. package/src/NavBar/index.tsx +5 -5
  62. package/src/ProgressBar/ProgressBar.tsx +25 -25
  63. package/src/ProgressBar/ProgressCircle.tsx +75 -75
  64. package/src/ProgressBar/index.tsx +2 -2
  65. package/src/Skeletons/LoadingInputSkeleton.tsx +12 -12
  66. package/src/Skeletons/index.ts +1 -1
  67. package/src/Tab/Tab.tsx +63 -63
  68. package/src/Tab/index.ts +1 -1
  69. package/src/Table/ZauruTable.tsx +265 -265
  70. package/src/Table/index.tsx +1 -1
  71. package/src/TaskList/TaskList.tsx +88 -88
  72. package/src/TaskList/index.ts +1 -1
  73. package/src/Titles/LabelArray.tsx +17 -17
  74. package/src/Titles/TableColumnTitle.tsx +9 -9
  75. package/src/Titles/TitleH1.tsx +10 -10
  76. package/src/Titles/TitleH2.tsx +10 -10
  77. package/src/Titles/TitleH3.tsx +10 -10
  78. package/src/Titles/index.ts +5 -5
  79. package/src/Tooltip/Tooltip.tsx +42 -42
  80. package/src/Tooltip/index.ts +1 -1
  81. package/src/WithTooltip/WithTooltip.tsx +21 -21
  82. package/src/WithTooltip/index.tsx +1 -1
  83. package/src/Wizards/StepWizard.tsx +88 -88
  84. package/src/Wizards/index.ts +1 -1
  85. package/src/Zendesk/Chat.tsx +83 -83
  86. package/src/Zendesk/index.ts +2 -2
  87. package/src/Zendesk/zendesk.config.ts +40 -40
  88. package/src/index.ts +24 -24
  89. package/src/postcss.config.mjs +5 -5
  90. package/src/tailwind.config.ts +10 -10
  91. package/src/tailwind.css +3 -3
  92. package/tsconfig.cjs.json +8 -8
  93. package/tsconfig.esm.json +11 -11
  94. package/tsconfig.json +17 -17
@@ -1,237 +1,237 @@
1
- import { IdeaIconSVG } from "@zauru-sdk/icons";
2
- import { useAppSelector } from "@zauru-sdk/redux";
3
- import { SelectFieldOption } from "@zauru-sdk/types";
4
- import { useEffect, useState } from "react";
5
- import type { SingleValue, InputActionMeta } from "react-select";
6
- import Select, { components } from "react-select";
7
- import { LoadingInputSkeleton } from "../../Skeletons/index.js";
8
-
9
- type Props = {
10
- id?: string;
11
- formName?: string;
12
- name?: string;
13
- title?: string;
14
- defaultValue?: SingleValue<SelectFieldOption>;
15
- defaultValueMulti?: SingleValue<SelectFieldOption>[];
16
- helpText?: string;
17
- options: Array<SelectFieldOption>;
18
- onChange?: (value: SingleValue<SelectFieldOption>) => void;
19
- onChangeMulti?: (value: Array<SingleValue<SelectFieldOption>>) => void;
20
- onInputChange?: (newValue: string, actionMeta: InputActionMeta) => void;
21
- isClearable?: boolean;
22
- error?: string | undefined;
23
- disabled?: boolean;
24
- menuIsOpen?: boolean;
25
- readOnly?: boolean;
26
- isMulti?: boolean;
27
- loading?: boolean;
28
- hint?: string;
29
- className?: string;
30
- };
31
-
32
- const Input = (props: any) => (
33
- <components.Input {...props} readOnly={props.selectProps.isReadOnly} />
34
- );
35
-
36
- export const SelectFieldWithoutValidation = (props: Props) => {
37
- const {
38
- id,
39
- name,
40
- title,
41
- defaultValue,
42
- defaultValueMulti = [],
43
- helpText,
44
- hint,
45
- options,
46
- onChange,
47
- onChangeMulti,
48
- isClearable = false,
49
- error = false,
50
- disabled = false,
51
- readOnly = false,
52
- isMulti = false,
53
- loading = false,
54
- className = "",
55
- onInputChange,
56
- } = props;
57
-
58
- const [value, setValue] = useState<SingleValue<SelectFieldOption>>(
59
- defaultValue || null
60
- );
61
- const [valueMulti, setValueMulti] =
62
- useState<SingleValue<SelectFieldOption>[]>(defaultValueMulti);
63
- const [inputValue, setInputValue] = useState("");
64
- const [showTooltip, setShowTooltip] = useState<boolean>(false);
65
- const [isClient, setIsClient] = useState(typeof window !== "undefined");
66
-
67
- const menuIsOpen = readOnly ? false : props?.menuIsOpen;
68
- const color = error ? "red" : "gray";
69
- let documentRef = null;
70
-
71
- const isReadOnly = disabled || readOnly;
72
- const bgColor = isReadOnly ? "bg-gray-200" : `bg-${color}-50`;
73
- const textColor = isReadOnly ? "text-gray-500" : `text-${color}-900`;
74
- const borderColor = isReadOnly ? "border-gray-300" : `border-${color}-500`;
75
-
76
- if (typeof window !== "undefined") {
77
- documentRef = document;
78
- }
79
-
80
- useEffect(() => {
81
- setValue(defaultValue || null);
82
- }, [defaultValue]);
83
-
84
- useEffect(() => {
85
- setIsClient(true);
86
- }, []);
87
-
88
- if (!isClient || loading || !documentRef) {
89
- return (
90
- <>
91
- {title && (
92
- <label
93
- htmlFor={error ? `${name}-error` : `${name}-success`}
94
- className={`block text-sm font-medium text-${color}-700 dark:text-${color}-500`}
95
- >
96
- {title}
97
- </label>
98
- )}
99
- <LoadingInputSkeleton />
100
- {helpText && (
101
- <p
102
- className={`mt-2 italic text-sm text-${color}-500 dark:text-${color}-400`}
103
- >
104
- {helpText}
105
- </p>
106
- )}
107
- </>
108
- );
109
- }
110
-
111
- const handleOnChange = (
112
- selection: SingleValue<SelectFieldOption> | unknown
113
- ) => {
114
- // Verificar si el valor de selección es un objeto con propiedades 'value' y 'label'
115
- if (
116
- typeof selection === "object" &&
117
- selection !== null &&
118
- "value" in selection &&
119
- "label" in selection
120
- ) {
121
- setValue(selection as SingleValue<SelectFieldOption>);
122
- onChange && onChange(selection as SingleValue<SelectFieldOption>);
123
- } else {
124
- setValue(null);
125
- onChange && onChange(null);
126
- }
127
- };
128
-
129
- const handleOnChangeMulti = (
130
- selection: SingleValue<SelectFieldOption>[] | unknown
131
- ) => {
132
- if (Array.isArray(selection)) {
133
- setValueMulti(selection as SingleValue<SelectFieldOption>[]);
134
- onChangeMulti &&
135
- onChangeMulti(selection as SingleValue<SelectFieldOption>[]);
136
- } else {
137
- setValueMulti([]);
138
- onChangeMulti && onChangeMulti([]);
139
- }
140
- };
141
-
142
- const selectComponent = (
143
- <>
144
- <Select
145
- className={`block w-full rounded-md ${bgColor} ${borderColor} ${textColor} shadow-sm focus:border-indigo-500 focus:ring-indigo-500 sm:text-sm`}
146
- id={isMulti ? undefined : id}
147
- instanceId={isMulti ? undefined : id}
148
- isDisabled={disabled}
149
- name={isMulti ? undefined : name}
150
- options={options}
151
- onChange={isMulti ? handleOnChangeMulti : handleOnChange}
152
- defaultValue={isMulti ? valueMulti : value}
153
- onInputChange={(newValue: string, actionMeta: InputActionMeta) => {
154
- setInputValue(newValue);
155
- onInputChange && onInputChange(newValue, actionMeta);
156
- }}
157
- inputValue={inputValue}
158
- onMenuOpen={() => {}}
159
- onMenuClose={() => {}}
160
- menuPortalTarget={documentRef?.body}
161
- styles={{ menuPortal: (base) => ({ ...base, zIndex: 9999 }) }}
162
- isClearable={isClearable}
163
- isSearchable={true}
164
- components={{ Input }}
165
- menuIsOpen={menuIsOpen}
166
- //windowThreshold={50}
167
- isMulti={isMulti}
168
- />
169
- {isMulti && (
170
- <input
171
- hidden
172
- readOnly
173
- name={name}
174
- value={valueMulti.map((x) => x?.value).join(",")}
175
- id={id}
176
- />
177
- )}
178
- </>
179
- );
180
-
181
- return (
182
- <div className={`col-span-6 sm:col-span-3 ${className}`}>
183
- {title && (
184
- <label
185
- htmlFor={error ? `${name}-error` : `${name}-success`}
186
- className={`block text-sm font-medium ${
187
- color === "red"
188
- ? "text-red-700 dark:text-red-500"
189
- : "text-gray-700 dark:text-gray-500"
190
- }`}
191
- >
192
- {title}
193
- </label>
194
- )}
195
- <div className="flex relative items-center">
196
- {selectComponent}
197
- {helpText && (
198
- <div className="flex items-center relative ml-3">
199
- <div
200
- className="relative cursor-pointer"
201
- onMouseEnter={() => setShowTooltip(true)}
202
- onMouseLeave={() => setShowTooltip(false)}
203
- >
204
- <IdeaIconSVG />
205
- {showTooltip && (
206
- <div className="absolute -left-48 top-0 mt-8 p-2 bg-white border rounded shadow text-black z-50">
207
- {helpText}
208
- </div>
209
- )}
210
- </div>
211
- </div>
212
- )}
213
- </div>
214
- {error && (
215
- <p className={`mt-2 text-sm text-${color}-600 dark:text-${color}-500`}>
216
- <span className="font-medium">Oops!</span> {error}
217
- </p>
218
- )}
219
- {!error && hint && (
220
- <p
221
- className={`mt-2 italic text-sm text-${color}-500 dark:text-${color}-400`}
222
- >
223
- {hint}
224
- </p>
225
- )}
226
- </div>
227
- );
228
- };
229
-
230
- export const SelectField = (props: Props) => {
231
- const { formValidations } = useAppSelector((state) => state.formValidation);
232
- const error = formValidations[props.formName ?? "-1"]?.[props.name ?? "-1"];
233
-
234
- props = { ...props, error };
235
-
236
- return <SelectFieldWithoutValidation {...props} />;
237
- };
1
+ import { IdeaIconSVG } from "@zauru-sdk/icons";
2
+ import { useAppSelector } from "@zauru-sdk/redux";
3
+ import { SelectFieldOption } from "@zauru-sdk/types";
4
+ import { useEffect, useState } from "react";
5
+ import type { SingleValue, InputActionMeta } from "react-select";
6
+ import Select, { components } from "react-select";
7
+ import { LoadingInputSkeleton } from "../../Skeletons/index.js";
8
+
9
+ type Props = {
10
+ id?: string;
11
+ formName?: string;
12
+ name?: string;
13
+ title?: string;
14
+ defaultValue?: SingleValue<SelectFieldOption>;
15
+ defaultValueMulti?: SingleValue<SelectFieldOption>[];
16
+ helpText?: string;
17
+ options: Array<SelectFieldOption>;
18
+ onChange?: (value: SingleValue<SelectFieldOption>) => void;
19
+ onChangeMulti?: (value: Array<SingleValue<SelectFieldOption>>) => void;
20
+ onInputChange?: (newValue: string, actionMeta: InputActionMeta) => void;
21
+ isClearable?: boolean;
22
+ error?: string | undefined;
23
+ disabled?: boolean;
24
+ menuIsOpen?: boolean;
25
+ readOnly?: boolean;
26
+ isMulti?: boolean;
27
+ loading?: boolean;
28
+ hint?: string;
29
+ className?: string;
30
+ };
31
+
32
+ const Input = (props: any) => (
33
+ <components.Input {...props} readOnly={props.selectProps.isReadOnly} />
34
+ );
35
+
36
+ export const SelectFieldWithoutValidation = (props: Props) => {
37
+ const {
38
+ id,
39
+ name,
40
+ title,
41
+ defaultValue,
42
+ defaultValueMulti = [],
43
+ helpText,
44
+ hint,
45
+ options,
46
+ onChange,
47
+ onChangeMulti,
48
+ isClearable = false,
49
+ error = false,
50
+ disabled = false,
51
+ readOnly = false,
52
+ isMulti = false,
53
+ loading = false,
54
+ className = "",
55
+ onInputChange,
56
+ } = props;
57
+
58
+ const [value, setValue] = useState<SingleValue<SelectFieldOption>>(
59
+ defaultValue || null
60
+ );
61
+ const [valueMulti, setValueMulti] =
62
+ useState<SingleValue<SelectFieldOption>[]>(defaultValueMulti);
63
+ const [inputValue, setInputValue] = useState("");
64
+ const [showTooltip, setShowTooltip] = useState<boolean>(false);
65
+ const [isClient, setIsClient] = useState(typeof window !== "undefined");
66
+
67
+ const menuIsOpen = readOnly ? false : props?.menuIsOpen;
68
+ const color = error ? "red" : "gray";
69
+ let documentRef = null;
70
+
71
+ const isReadOnly = disabled || readOnly;
72
+ const bgColor = isReadOnly ? "bg-gray-200" : `bg-${color}-50`;
73
+ const textColor = isReadOnly ? "text-gray-500" : `text-${color}-900`;
74
+ const borderColor = isReadOnly ? "border-gray-300" : `border-${color}-500`;
75
+
76
+ if (typeof window !== "undefined") {
77
+ documentRef = document;
78
+ }
79
+
80
+ useEffect(() => {
81
+ setValue(defaultValue || null);
82
+ }, [defaultValue]);
83
+
84
+ useEffect(() => {
85
+ setIsClient(true);
86
+ }, []);
87
+
88
+ if (!isClient || loading || !documentRef) {
89
+ return (
90
+ <>
91
+ {title && (
92
+ <label
93
+ htmlFor={error ? `${name}-error` : `${name}-success`}
94
+ className={`block text-sm font-medium text-${color}-700 dark:text-${color}-500`}
95
+ >
96
+ {title}
97
+ </label>
98
+ )}
99
+ <LoadingInputSkeleton />
100
+ {helpText && (
101
+ <p
102
+ className={`mt-2 italic text-sm text-${color}-500 dark:text-${color}-400`}
103
+ >
104
+ {helpText}
105
+ </p>
106
+ )}
107
+ </>
108
+ );
109
+ }
110
+
111
+ const handleOnChange = (
112
+ selection: SingleValue<SelectFieldOption> | unknown
113
+ ) => {
114
+ // Verificar si el valor de selección es un objeto con propiedades 'value' y 'label'
115
+ if (
116
+ typeof selection === "object" &&
117
+ selection !== null &&
118
+ "value" in selection &&
119
+ "label" in selection
120
+ ) {
121
+ setValue(selection as SingleValue<SelectFieldOption>);
122
+ onChange && onChange(selection as SingleValue<SelectFieldOption>);
123
+ } else {
124
+ setValue(null);
125
+ onChange && onChange(null);
126
+ }
127
+ };
128
+
129
+ const handleOnChangeMulti = (
130
+ selection: SingleValue<SelectFieldOption>[] | unknown
131
+ ) => {
132
+ if (Array.isArray(selection)) {
133
+ setValueMulti(selection as SingleValue<SelectFieldOption>[]);
134
+ onChangeMulti &&
135
+ onChangeMulti(selection as SingleValue<SelectFieldOption>[]);
136
+ } else {
137
+ setValueMulti([]);
138
+ onChangeMulti && onChangeMulti([]);
139
+ }
140
+ };
141
+
142
+ const selectComponent = (
143
+ <>
144
+ <Select
145
+ className={`block w-full rounded-md ${bgColor} ${borderColor} ${textColor} shadow-sm focus:border-indigo-500 focus:ring-indigo-500 sm:text-sm`}
146
+ id={isMulti ? undefined : id}
147
+ instanceId={isMulti ? undefined : id}
148
+ isDisabled={disabled}
149
+ name={isMulti ? undefined : name}
150
+ options={options}
151
+ onChange={isMulti ? handleOnChangeMulti : handleOnChange}
152
+ defaultValue={isMulti ? valueMulti : value}
153
+ onInputChange={(newValue: string, actionMeta: InputActionMeta) => {
154
+ setInputValue(newValue);
155
+ onInputChange && onInputChange(newValue, actionMeta);
156
+ }}
157
+ inputValue={inputValue}
158
+ onMenuOpen={() => {}}
159
+ onMenuClose={() => {}}
160
+ menuPortalTarget={documentRef?.body}
161
+ styles={{ menuPortal: (base) => ({ ...base, zIndex: 9999 }) }}
162
+ isClearable={isClearable}
163
+ isSearchable={true}
164
+ components={{ Input }}
165
+ menuIsOpen={menuIsOpen}
166
+ //windowThreshold={50}
167
+ isMulti={isMulti}
168
+ />
169
+ {isMulti && (
170
+ <input
171
+ hidden
172
+ readOnly
173
+ name={name}
174
+ value={valueMulti.map((x) => x?.value).join(",")}
175
+ id={id}
176
+ />
177
+ )}
178
+ </>
179
+ );
180
+
181
+ return (
182
+ <div className={`col-span-6 sm:col-span-3 ${className}`}>
183
+ {title && (
184
+ <label
185
+ htmlFor={error ? `${name}-error` : `${name}-success`}
186
+ className={`block text-sm font-medium ${
187
+ color === "red"
188
+ ? "text-red-700 dark:text-red-500"
189
+ : "text-gray-700 dark:text-gray-500"
190
+ }`}
191
+ >
192
+ {title}
193
+ </label>
194
+ )}
195
+ <div className="flex relative items-center">
196
+ {selectComponent}
197
+ {helpText && (
198
+ <div className="flex items-center relative ml-3">
199
+ <div
200
+ className="relative cursor-pointer"
201
+ onMouseEnter={() => setShowTooltip(true)}
202
+ onMouseLeave={() => setShowTooltip(false)}
203
+ >
204
+ <IdeaIconSVG />
205
+ {showTooltip && (
206
+ <div className="absolute -left-48 top-0 mt-8 p-2 bg-white border rounded shadow text-black z-50">
207
+ {helpText}
208
+ </div>
209
+ )}
210
+ </div>
211
+ </div>
212
+ )}
213
+ </div>
214
+ {error && (
215
+ <p className={`mt-2 text-sm text-${color}-600 dark:text-${color}-500`}>
216
+ <span className="font-medium">Oops!</span> {error}
217
+ </p>
218
+ )}
219
+ {!error && hint && (
220
+ <p
221
+ className={`mt-2 italic text-sm text-${color}-500 dark:text-${color}-400`}
222
+ >
223
+ {hint}
224
+ </p>
225
+ )}
226
+ </div>
227
+ );
228
+ };
229
+
230
+ export const SelectField = (props: Props) => {
231
+ const { formValidations } = useAppSelector((state) => state.formValidation);
232
+ const error = formValidations[props.formName ?? "-1"]?.[props.name ?? "-1"];
233
+
234
+ props = { ...props, error };
235
+
236
+ return <SelectFieldWithoutValidation {...props} />;
237
+ };