componentes-sinco 1.0.1-rc.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs ADDED
@@ -0,0 +1,696 @@
1
+ // src/Components/SCTextField.tsx
2
+ import React, { useEffect, useState } from "react";
3
+ import { FormControl, IconButton, InputAdornment, InputLabel, OutlinedInput, FilledInput, Input, Box, Typography, Popover, SvgIcon, Tooltip } from "@mui/material";
4
+ import Grid from "@mui/material/Grid2";
5
+ import * as Muicon from "@mui/icons-material";
6
+ import { Visibility, VisibilityOff, InfoOutlined } from "@mui/icons-material";
7
+ var SCTextField = ({
8
+ label = "",
9
+ placeholder = "",
10
+ width = "100%",
11
+ variant = "outlined",
12
+ color,
13
+ disabled,
14
+ required,
15
+ maxLength,
16
+ background,
17
+ size,
18
+ format,
19
+ title,
20
+ iconTitle,
21
+ infoTitle,
22
+ iconInputStart,
23
+ iconInputEnd,
24
+ infoElement,
25
+ value,
26
+ state,
27
+ onChange,
28
+ onBlur,
29
+ onKeyDown
30
+ }) => {
31
+ const [showPassword, setShowPassword] = useState(false);
32
+ const [error, setError] = useState(false);
33
+ const [anchorInfoTitle, setAnchorInfoTitle] = useState(null);
34
+ const openInfoTitle = Boolean(anchorInfoTitle);
35
+ const [anchorInfoElement, setAnchorInfoElement] = useState(null);
36
+ const openInfoElement = Boolean(anchorInfoElement);
37
+ const inputComponents = {
38
+ outlined: OutlinedInput,
39
+ filled: FilledInput,
40
+ standard: Input
41
+ };
42
+ const InputComponent = inputComponents[variant] || OutlinedInput;
43
+ let IconInputStartValidation;
44
+ let IconInputEndValidation;
45
+ let IconInputStart;
46
+ let IconInputEnd;
47
+ let IconTitle;
48
+ if (iconInputStart) {
49
+ if (!(iconInputStart in Muicon)) {
50
+ if (iconInputStart.type === void 0) {
51
+ IconInputStartValidation = "text";
52
+ } else {
53
+ IconInputStartValidation = "icon";
54
+ }
55
+ } else {
56
+ IconInputStartValidation = "icon";
57
+ IconInputStart = Muicon[iconInputStart];
58
+ }
59
+ }
60
+ if (iconInputEnd) {
61
+ if (!(iconInputEnd in Muicon)) {
62
+ if (iconInputEnd.type === void 0) {
63
+ IconInputEndValidation = "text";
64
+ } else {
65
+ IconInputEndValidation = "icon";
66
+ }
67
+ } else {
68
+ IconInputEndValidation = "icon";
69
+ IconInputEnd = Muicon[iconInputEnd];
70
+ }
71
+ }
72
+ if (iconTitle) {
73
+ if (!(iconTitle in Muicon)) {
74
+ IconTitle = iconInputStart;
75
+ } else {
76
+ IconTitle = Muicon[iconTitle];
77
+ }
78
+ }
79
+ useEffect(() => {
80
+ if (state) {
81
+ state(value);
82
+ }
83
+ }, [value]);
84
+ useEffect(() => {
85
+ if (error) {
86
+ setTimeout(() => {
87
+ setError(false);
88
+ }, 1e3);
89
+ }
90
+ }, [error]);
91
+ const handleClickShowPassword = () => setShowPassword((show) => !show);
92
+ const handleMouseDownPassword = (event) => {
93
+ event.preventDefault();
94
+ };
95
+ const handleKeyPress = (event) => {
96
+ const target = event.target;
97
+ const key = event.key;
98
+ if (format === "int") {
99
+ if (!/^[0-9]$/.test(key)) {
100
+ event.preventDefault();
101
+ }
102
+ ;
103
+ }
104
+ if (format === "decimal") {
105
+ if (target.value === "" && key === "." || key === "-" || key === "+") {
106
+ event.preventDefault();
107
+ }
108
+ }
109
+ if (target.type === "text") {
110
+ const regex = /^[a-zA-ZáéíóúÁÉÍÓÚñÑ0-9\s_\-.,@]+$/;
111
+ if (!regex.test(key)) {
112
+ event.preventDefault();
113
+ }
114
+ }
115
+ if (onKeyDown) {
116
+ onKeyDown(event);
117
+ }
118
+ };
119
+ const handleChange = (event) => {
120
+ let valueMax = maxLength ? maxLength + 1 : 50;
121
+ if (event.target.value.length < valueMax) {
122
+ if (state) {
123
+ state(event.target.value);
124
+ }
125
+ if (onChange) {
126
+ onChange(event);
127
+ }
128
+ }
129
+ };
130
+ const handleBlur = (event) => {
131
+ const error2 = !value.trim() && required ? true : false;
132
+ setError(error2 ? true : false);
133
+ if (onBlur) {
134
+ onBlur(event);
135
+ }
136
+ };
137
+ const handleClickInfoTitle = (event) => {
138
+ setAnchorInfoTitle(event.currentTarget);
139
+ };
140
+ const handleCloseInfoTitle = () => {
141
+ setAnchorInfoTitle(null);
142
+ };
143
+ const handleClickInfoElement = (event) => {
144
+ setAnchorInfoElement(event.currentTarget);
145
+ };
146
+ const handleCloseInfoElement = () => {
147
+ setAnchorInfoElement(null);
148
+ };
149
+ return /* @__PURE__ */ React.createElement(Box, { sx: { width } }, /* @__PURE__ */ React.createElement(Grid, { container: true, alignItems: "center", mb: 1.25, gap: 0.5 }, iconTitle && IconTitle ? /* @__PURE__ */ React.createElement(SvgIcon, { color: "action", fontSize: "small", component: IconTitle }) : "", title ? /* @__PURE__ */ React.createElement(Typography, { mx: 0.5, variant: "subtitle2", color: "text.secondary" }, title) : "", infoTitle ? /* @__PURE__ */ React.createElement(Tooltip, { title: infoTitle, placement: "top-end" }, /* @__PURE__ */ React.createElement(
150
+ InfoOutlined,
151
+ {
152
+ color: "action",
153
+ fontSize: "small",
154
+ onMouseEnter: (event) => handleClickInfoTitle(event),
155
+ onMouseLeave: () => handleCloseInfoTitle()
156
+ }
157
+ )) : ""), /* @__PURE__ */ React.createElement(Grid, { container: true, sx: { flexWrap: "nowrap", alignItems: "center" } }, /* @__PURE__ */ React.createElement(
158
+ FormControl,
159
+ {
160
+ color,
161
+ fullWidth: true,
162
+ size: size ? size : "medium",
163
+ variant,
164
+ sx: { background: background || "transparent", borderRadius: "4px" }
165
+ },
166
+ /* @__PURE__ */ React.createElement(
167
+ InputLabel,
168
+ {
169
+ htmlFor: "",
170
+ required: required && label !== "" ? true : false,
171
+ error,
172
+ disabled: disabled || false
173
+ },
174
+ label ? label : ""
175
+ ),
176
+ /* @__PURE__ */ React.createElement(
177
+ InputComponent,
178
+ {
179
+ size: size ? size : "medium",
180
+ fullWidth: true,
181
+ value,
182
+ error,
183
+ id: label == null ? void 0 : label.replace(/\s+/g, ""),
184
+ disabled: disabled || false,
185
+ onKeyUp: handleKeyPress,
186
+ onChange: handleChange,
187
+ onBlur: handleBlur,
188
+ inputProps: { maxLength: maxLength ? maxLength : 50 },
189
+ type: !showPassword && format === "password" ? "password" : (format || "text").toUpperCase() === "INT" || (format || "text").toUpperCase() === "DECIMAL" ? "number" : "text",
190
+ className: format === "password" && !showPassword ? "" : "",
191
+ placeholder,
192
+ startAdornment: iconInputStart ? /* @__PURE__ */ React.createElement(InputAdornment, { position: "start" }, IconInputStartValidation === "text" ? iconInputStart : IconInputStart ? /* @__PURE__ */ React.createElement(IconInputStart, { fontSize: "small" }) : null) : "",
193
+ endAdornment: /* @__PURE__ */ React.createElement(InputAdornment, { position: "end" }, format === "password" ? /* @__PURE__ */ React.createElement(
194
+ IconButton,
195
+ {
196
+ onClick: handleClickShowPassword,
197
+ onMouseDown: handleMouseDownPassword,
198
+ edge: "end"
199
+ },
200
+ showPassword ? /* @__PURE__ */ React.createElement(VisibilityOff, null) : /* @__PURE__ */ React.createElement(Visibility, null)
201
+ ) : iconInputEnd === void 0 && infoElement !== void 0 ? /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(
202
+ InfoOutlined,
203
+ {
204
+ sx: { ml: 0.5 },
205
+ color: "action",
206
+ fontSize: "small",
207
+ component: "svg",
208
+ onMouseEnter: (event) => handleClickInfoElement(event),
209
+ onMouseLeave: () => handleCloseInfoElement()
210
+ }
211
+ ), /* @__PURE__ */ React.createElement(
212
+ Popover,
213
+ {
214
+ sx: { pointerEvents: "none" },
215
+ open: openInfoElement,
216
+ anchorEl: anchorInfoElement,
217
+ onClose: handleCloseInfoElement,
218
+ anchorOrigin: {
219
+ vertical: "bottom",
220
+ horizontal: "left"
221
+ },
222
+ transformOrigin: {
223
+ vertical: "top",
224
+ horizontal: "left"
225
+ },
226
+ disableRestoreFocus: true
227
+ },
228
+ /* @__PURE__ */ React.createElement(Typography, { p: 2 }, infoElement)
229
+ )) : iconInputEnd !== void 0 ? IconInputEndValidation === "text" ? iconInputEnd : IconInputEnd ? /* @__PURE__ */ React.createElement(IconInputEnd, { fontSize: "small" }) : null : ""),
230
+ label: label ? label + (format === "password" && !showPassword ? "" : "") : "",
231
+ autoComplete: format === "password" ? "new-password" : "off"
232
+ }
233
+ )
234
+ ), (iconInputEnd !== void 0 || format === "password") && infoElement ? /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(
235
+ InfoOutlined,
236
+ {
237
+ sx: { marginLeft: "4px" },
238
+ color: "action",
239
+ fontSize: "small",
240
+ onMouseEnter: (event) => handleClickInfoElement(event),
241
+ onMouseLeave: handleCloseInfoElement
242
+ }
243
+ ), /* @__PURE__ */ React.createElement(
244
+ Popover,
245
+ {
246
+ sx: { pointerEvents: "none" },
247
+ open: openInfoElement,
248
+ anchorEl: anchorInfoElement,
249
+ onClose: handleCloseInfoElement,
250
+ anchorOrigin: {
251
+ vertical: "bottom",
252
+ horizontal: "left"
253
+ },
254
+ transformOrigin: {
255
+ vertical: "top",
256
+ horizontal: "left"
257
+ },
258
+ disableRestoreFocus: true
259
+ },
260
+ /* @__PURE__ */ React.createElement(Typography, { p: 2 }, infoElement)
261
+ )) : ""));
262
+ };
263
+
264
+ // src/Components/Drawer/SCDrawer.tsx
265
+ import React4 from "react";
266
+ import { Box as Box4, Drawer, Typography as Typography4, IconButton as IconButton4, Button as Button2, Stack as Stack3 } from "@mui/material";
267
+ import Grid3 from "@mui/material/Grid2";
268
+ import * as Muicon3 from "@mui/icons-material";
269
+ import { FilterListOutlined } from "@mui/icons-material";
270
+ import CloseIcon from "@mui/icons-material/Close";
271
+
272
+ // src/Components/ToastNotification/SCToastNotification.tsx
273
+ import React2, { useEffect as useEffect3, useState as useState3 } from "react";
274
+ import { Stack, LinearProgress, Divider, Box as Box2, Typography as Typography2, IconButton as IconButton2, Button } from "@mui/material";
275
+ import { Close, InfoRounded, CheckCircleRounded, WarningRounded, ErrorRounded, KeyboardArrowDown, KeyboardArrowUp } from "@mui/icons-material";
276
+
277
+ // src/Components/ToastNotification/useProgress.ts
278
+ import { useEffect as useEffect2, useState as useState2 } from "react";
279
+ var useProgress = (timeProgress, lote) => {
280
+ const [progress, setProgress] = useState2(0);
281
+ useEffect2(() => {
282
+ const interval = setInterval(() => {
283
+ setProgress((prev) => {
284
+ if (prev >= 100) {
285
+ clearInterval(interval);
286
+ }
287
+ if (lote) {
288
+ const nextProgress = prev + lote;
289
+ return nextProgress <= 100 ? nextProgress : 100;
290
+ } else {
291
+ return prev + 1;
292
+ }
293
+ });
294
+ }, timeProgress * 10);
295
+ return () => {
296
+ clearInterval(interval);
297
+ };
298
+ }, [timeProgress, lote]);
299
+ return {
300
+ progress
301
+ };
302
+ };
303
+
304
+ // src/Components/ToastNotification/SCToastNotification.tsx
305
+ var SCToastNotification = (toast) => {
306
+ var _a;
307
+ const [stateOptions, setStateOptions] = useState3(true);
308
+ const [stateToast, setStateToast] = useState3(true);
309
+ const timeProgress = toast.time || 10;
310
+ const { progress } = useProgress(timeProgress);
311
+ const toastColorConfig = toast.type || "info";
312
+ const toastIconOption = {
313
+ success: /* @__PURE__ */ React2.createElement(CheckCircleRounded, { color: "success" }),
314
+ error: /* @__PURE__ */ React2.createElement(ErrorRounded, { color: "error" }),
315
+ warning: /* @__PURE__ */ React2.createElement(WarningRounded, { color: "warning" }),
316
+ info: /* @__PURE__ */ React2.createElement(InfoRounded, { color: "info" })
317
+ };
318
+ toast.actions = (_a = toast.actions) != null ? _a : [{ text: "Action", fn: () => {
319
+ alert("");
320
+ } }, { text: "Consultar", fn: () => {
321
+ } }];
322
+ const ToastIconConfig = toastIconOption[toast.type];
323
+ const closeToast = () => {
324
+ setStateToast(false);
325
+ };
326
+ const toggleToastOptions = () => {
327
+ setStateOptions((prevShowOptions) => !prevShowOptions);
328
+ };
329
+ useEffect3(() => {
330
+ progress >= 100 && setStateToast(false);
331
+ }, [progress]);
332
+ return /* @__PURE__ */ React2.createElement(React2.Fragment, null, stateToast && /* @__PURE__ */ React2.createElement(
333
+ Stack,
334
+ {
335
+ position: "fixed",
336
+ zIndex: 1400,
337
+ right: 16,
338
+ top: 16,
339
+ width: 370,
340
+ sx: {
341
+ boxShadow: (theme) => theme.shadows[8]
342
+ }
343
+ },
344
+ /* @__PURE__ */ React2.createElement(
345
+ Box2,
346
+ {
347
+ padding: 1.5,
348
+ gap: 1.5,
349
+ display: "flex",
350
+ alignItems: "center",
351
+ sx: {
352
+ backgroundColor: {
353
+ success: "success.50",
354
+ error: "error.50",
355
+ warning: "warning.50",
356
+ info: "info.50"
357
+ }[toastColorConfig]
358
+ }
359
+ },
360
+ /* @__PURE__ */ React2.createElement(
361
+ Stack,
362
+ {
363
+ p: 1,
364
+ gap: 1,
365
+ borderRadius: 50,
366
+ bgcolor: {
367
+ success: "success.100",
368
+ error: "error.100",
369
+ warning: "warning.100",
370
+ info: "info.100"
371
+ }[toast.type || "info"]
372
+ },
373
+ /* @__PURE__ */ React2.createElement(Stack, null, ToastIconConfig)
374
+ ),
375
+ /* @__PURE__ */ React2.createElement(Divider, { orientation: "vertical", flexItem: true }),
376
+ /* @__PURE__ */ React2.createElement(Stack, { width: 285 }, /* @__PURE__ */ React2.createElement(
377
+ Stack,
378
+ {
379
+ justifyContent: "space-between",
380
+ flexDirection: "row",
381
+ alignItems: "center"
382
+ },
383
+ /* @__PURE__ */ React2.createElement(Typography2, { variant: "subtitle2", color: "text.primary" }, toast.title),
384
+ /* @__PURE__ */ React2.createElement(
385
+ IconButton2,
386
+ {
387
+ size: "small",
388
+ "data-testid": "close-icon",
389
+ onClick: closeToast
390
+ },
391
+ /* @__PURE__ */ React2.createElement(Close, { fontSize: "small" })
392
+ )
393
+ ), /* @__PURE__ */ React2.createElement(Stack, { gap: 0.5 }, /* @__PURE__ */ React2.createElement(Typography2, { color: "text.primary", variant: "body2" }, toast.subtitle), !stateOptions && toast.listITems && toast.listITems.length > 0 && /* @__PURE__ */ React2.createElement(Stack, null, toast.listITems.map((element, i) => /* @__PURE__ */ React2.createElement(Typography2, { variant: "caption", key: i }, "\u2022 ", element)))), /* @__PURE__ */ React2.createElement(Stack, { justifyContent: "flex-end", flexDirection: "row" }, toast.actions && toast.actions.length > 0 && /* @__PURE__ */ React2.createElement(Stack, { flexDirection: "row", gap: 1 }, toast.actions.map((button, index) => /* @__PURE__ */ React2.createElement(
394
+ Button,
395
+ {
396
+ key: index,
397
+ sx: { textTransform: "capitalize" },
398
+ color: index === 0 ? "info" : toast.type === "success" ? "success" : toast.type === "error" ? "error" : toast.type === "warning" ? "warning" : "info",
399
+ variant: "text",
400
+ onClick: button.fn,
401
+ disabled: button.disabled || false,
402
+ size: "small"
403
+ },
404
+ button.text
405
+ ))), toast.seeMore && /* @__PURE__ */ React2.createElement(
406
+ Button,
407
+ {
408
+ onClick: toggleToastOptions,
409
+ size: "small",
410
+ variant: "text",
411
+ color: toastColorConfig
412
+ },
413
+ stateOptions ? "Ver m\xE1s" : "Ver menos",
414
+ stateOptions ? /* @__PURE__ */ React2.createElement(KeyboardArrowDown, null) : /* @__PURE__ */ React2.createElement(KeyboardArrowUp, null)
415
+ )))
416
+ ),
417
+ /* @__PURE__ */ React2.createElement(
418
+ LinearProgress,
419
+ {
420
+ sx: {
421
+ ".MuiLinearProgress-bar": {
422
+ transition: "0.1s linear !important",
423
+ transform: "scaleX(-1)"
424
+ }
425
+ },
426
+ color: toastColorConfig,
427
+ variant: "determinate",
428
+ value: 100 - progress
429
+ }
430
+ )
431
+ ));
432
+ };
433
+
434
+ // src/Components/SCTextArea.tsx
435
+ import React3, { useEffect as useEffect4, useState as useState4 } from "react";
436
+ import { Typography as Typography3, Stack as Stack2, TextField, Box as Box3, IconButton as IconButton3, Tooltip as Tooltip2 } from "@mui/material";
437
+ import Grid2 from "@mui/material/Grid2";
438
+ import * as Muicon2 from "@mui/icons-material";
439
+ import { InfoOutlined as InfoOutlined2 } from "@mui/icons-material";
440
+ var SCTextArea = ({
441
+ title,
442
+ infoTitle,
443
+ colorTitle,
444
+ iconTitle,
445
+ placeholder,
446
+ label = "",
447
+ variant,
448
+ required,
449
+ disabled,
450
+ width = "100%",
451
+ rows = 3,
452
+ maxLength = 200,
453
+ value,
454
+ state,
455
+ onBlur
456
+ }) => {
457
+ const [helperCount, setHelperCount] = useState4(0);
458
+ const [stateError, setStateError] = useState4(false);
459
+ const [anchorInfoTitle, setAnchorInfoTitle] = React3.useState(null);
460
+ const openInfoTitle = Boolean(anchorInfoTitle);
461
+ useEffect4(() => {
462
+ setHelperCount(value.length);
463
+ }, [value]);
464
+ let IconTitle = null;
465
+ if (iconTitle) {
466
+ if (Muicon2[iconTitle] === void 0) {
467
+ IconTitle = null;
468
+ } else {
469
+ IconTitle = Muicon2[iconTitle];
470
+ }
471
+ }
472
+ const handleBlur = (event) => {
473
+ if (required && value.trim() === "") {
474
+ setStateError(true);
475
+ setTimeout(() => {
476
+ setStateError(false);
477
+ }, 1e3);
478
+ return;
479
+ }
480
+ if (onBlur) {
481
+ onBlur(event);
482
+ }
483
+ };
484
+ return /* @__PURE__ */ React3.createElement(React3.Fragment, null, /* @__PURE__ */ React3.createElement(Box3, { sx: { width } }, /* @__PURE__ */ React3.createElement(Grid2, { container: true, sx: { alignItems: "center" } }, iconTitle && IconTitle && /* @__PURE__ */ React3.createElement(IconTitle, { color: "action", sx: { mr: "4px" } }), title && /* @__PURE__ */ React3.createElement(Typography3, { color: colorTitle || "text.secondary", variant: "body1" }, title), infoTitle && /* @__PURE__ */ React3.createElement(Tooltip2, { title: infoTitle, placement: "top-end" }, /* @__PURE__ */ React3.createElement(IconButton3, { size: "small" }, /* @__PURE__ */ React3.createElement(
485
+ InfoOutlined2,
486
+ {
487
+ color: "action",
488
+ fontSize: "small"
489
+ }
490
+ )))), /* @__PURE__ */ React3.createElement(Stack2, null, /* @__PURE__ */ React3.createElement(
491
+ TextField,
492
+ {
493
+ required,
494
+ placeholder,
495
+ error: stateError,
496
+ variant,
497
+ sx: { mt: "10px" },
498
+ id: "outlined-multiline-static",
499
+ label,
500
+ multiline: true,
501
+ disabled,
502
+ rows,
503
+ value,
504
+ onBlur: handleBlur,
505
+ onChange: (e) => {
506
+ if (state) {
507
+ state(e.target.value.substring(0, maxLength));
508
+ }
509
+ },
510
+ autoComplete: "off"
511
+ }
512
+ )), /* @__PURE__ */ React3.createElement(Stack2, null, /* @__PURE__ */ React3.createElement(
513
+ Typography3,
514
+ {
515
+ variant: "caption",
516
+ color: "text.secondary",
517
+ mr: 1,
518
+ mt: 1,
519
+ align: "right"
520
+ },
521
+ helperCount + "/" + maxLength
522
+ ))));
523
+ };
524
+
525
+ // src/Components/Drawer/SCDrawer.tsx
526
+ var SCDrawer = ({
527
+ title,
528
+ colorTitle,
529
+ textButton,
530
+ iconButton,
531
+ buttonColor,
532
+ anchor = "left",
533
+ iconPosition,
534
+ width,
535
+ open,
536
+ arrayElements = [],
537
+ actions
538
+ }) => {
539
+ const [drawerOpen, setDrawerOpen] = React4.useState(open);
540
+ let IconBoton;
541
+ if (iconButton && iconButton in Muicon3) {
542
+ IconBoton = Muicon3[iconButton];
543
+ } else {
544
+ IconBoton = FilterListOutlined;
545
+ }
546
+ React4.useEffect(() => {
547
+ if (open !== void 0) {
548
+ setDrawerOpen(open);
549
+ }
550
+ }, [open]);
551
+ const handleDrawerClose = () => {
552
+ setDrawerOpen(false);
553
+ };
554
+ const toggleDrawer = (newOpen) => () => {
555
+ setDrawerOpen(newOpen);
556
+ };
557
+ const inputValidation = () => {
558
+ var _a;
559
+ let requiredValues = 0;
560
+ let filledValues = 0;
561
+ for (let i = 0; i < arrayElements.length; i++) {
562
+ if (arrayElements[i].component === void 0) {
563
+ if (arrayElements[i].required) {
564
+ requiredValues++;
565
+ }
566
+ if (arrayElements[i].required && ((_a = arrayElements[i].value) == null ? void 0 : _a.trim()) !== "") {
567
+ filledValues++;
568
+ }
569
+ }
570
+ }
571
+ if (requiredValues === filledValues) {
572
+ handleDrawerClose();
573
+ } else {
574
+ SCToastNotification({
575
+ type: "error",
576
+ title: "Algunos campos son requeridos",
577
+ time: 3e3
578
+ });
579
+ return;
580
+ }
581
+ };
582
+ const clean = () => {
583
+ var _a, _b;
584
+ for (let i = 0; i < arrayElements.length; i++) {
585
+ if (arrayElements[i].component === void 0) {
586
+ (_b = (_a = arrayElements[i]).state) == null ? void 0 : _b.call(_a, "");
587
+ }
588
+ }
589
+ };
590
+ actions = actions != null ? actions : [{ text: "Limpiar", fn: clean }, { text: "Consultar", fn: inputValidation }];
591
+ return /* @__PURE__ */ React4.createElement(React4.Fragment, null, /* @__PURE__ */ React4.createElement(
592
+ Button2,
593
+ {
594
+ sx: { textTransform: "capitalize" },
595
+ color: buttonColor,
596
+ onClick: toggleDrawer(true),
597
+ size: "small",
598
+ startIcon: iconPosition === "left" || !iconPosition ? /* @__PURE__ */ React4.createElement(IconButton4, null) : null,
599
+ endIcon: iconPosition === "right" ? /* @__PURE__ */ React4.createElement(IconButton4, null) : null
600
+ },
601
+ textButton || "Filtrar"
602
+ ), /* @__PURE__ */ React4.createElement(
603
+ Drawer,
604
+ {
605
+ open: drawerOpen,
606
+ onClose: toggleDrawer(false),
607
+ anchor: anchor || "left",
608
+ sx: {
609
+ "& .MuiDrawer-paper": {
610
+ width: width || "450px",
611
+ boxSizing: "border-box",
612
+ borderRadius: anchor !== "right" ? "0px 4px 4px 0px" : "4px 0px 0px 4px"
613
+ }
614
+ }
615
+ },
616
+ /* @__PURE__ */ React4.createElement(Stack3, { flexDirection: "column", height: "100%" }, /* @__PURE__ */ React4.createElement(Grid3, { container: true, sx: { backgroundColor: "secondary.main", alignItems: "center", height: "42px", textAlign: "left", padding: "10px 12px 10px 12px", justifyContent: "space-between", alignContent: "center" } }, /* @__PURE__ */ React4.createElement(Typography4, { variant: "h6", color: colorTitle || "text.primary" }, title || "Personaliza tu b\xFAsqueda"), /* @__PURE__ */ React4.createElement(IconButton4, { onClick: handleDrawerClose }, /* @__PURE__ */ React4.createElement(CloseIcon, { color: "action" }))), /* @__PURE__ */ React4.createElement(Stack3, { alignItems: "flex-start", height: "100%", gap: "16px", flex: 1, overflow: "auto", padding: "12px 16px 12px 16px" }, arrayElements == null ? void 0 : arrayElements.map((arrayElement, index) => /* @__PURE__ */ React4.createElement(
617
+ Box4,
618
+ {
619
+ key: `Stack_${arrayElement.type || ""} ${arrayElement.name || ""}${index}`,
620
+ sx: { width: "100%" }
621
+ },
622
+ arrayElement.component ? /* @__PURE__ */ React4.createElement(Stack3, { direction: "row", alignItems: "left", gap: 1 }, arrayElement.component) : arrayElement.type === "text" ? /* @__PURE__ */ React4.createElement(
623
+ SCTextField,
624
+ {
625
+ title: arrayElement.title,
626
+ label: arrayElement.name,
627
+ placeholder: arrayElement.placeholder,
628
+ infoTitle: arrayElement.infoTitle,
629
+ iconTitle: arrayElement.iconTitle,
630
+ infoElement: arrayElement.infoElement,
631
+ iconInputEnd: arrayElement.iconInputEnd,
632
+ iconInputStart: arrayElement.iconInputStart,
633
+ width: arrayElement.width,
634
+ maxLength: arrayElement.maxLength,
635
+ background: arrayElement.background,
636
+ size: arrayElement.size,
637
+ variant: arrayElement.variant,
638
+ disabled: arrayElement.disabled,
639
+ required: arrayElement.required,
640
+ value: arrayElement.value,
641
+ onChange: arrayElement.onChange,
642
+ onBlur: arrayElement.onBlur,
643
+ state: arrayElement.state
644
+ }
645
+ ) : arrayElement.type === "textArea" ? /* @__PURE__ */ React4.createElement(
646
+ SCTextArea,
647
+ {
648
+ label: arrayElement.name,
649
+ placeholder: arrayElement.placeholder,
650
+ title: arrayElement.title,
651
+ infoTitle: arrayElement.infoTitle,
652
+ iconTitle: arrayElement.iconTitle,
653
+ width: arrayElement.width,
654
+ maxLength: arrayElement.maxLength,
655
+ background: arrayElement.background,
656
+ rows: arrayElement.rows,
657
+ variant: arrayElement.variant,
658
+ disabled: arrayElement.disabled,
659
+ required: arrayElement.required,
660
+ value: arrayElement.value || " ",
661
+ onBlur: arrayElement.onBlur,
662
+ state: arrayElement.state
663
+ }
664
+ ) : null
665
+ ))), (actions == null ? void 0 : actions.length) > 0 && /* @__PURE__ */ React4.createElement(
666
+ Grid3,
667
+ {
668
+ container: true,
669
+ bgcolor: "background.default",
670
+ gap: 2,
671
+ padding: "9px 16px 9px 16px",
672
+ height: "42px",
673
+ alignItems: "center",
674
+ justifyContent: actions.length > 1 ? "space-between" : "flex-end",
675
+ flexDirection: "row"
676
+ },
677
+ actions.map((button, index) => /* @__PURE__ */ React4.createElement(
678
+ Button2,
679
+ {
680
+ key: index,
681
+ variant: index === 0 || actions && actions.length < 2 ? "contained" : "text",
682
+ color: "primary",
683
+ onClick: button.fn,
684
+ disabled: button.disabled || false,
685
+ size: "small"
686
+ },
687
+ button.text
688
+ ))
689
+ ))
690
+ ));
691
+ };
692
+ export {
693
+ SCDrawer,
694
+ SCTextArea,
695
+ SCTextField
696
+ };