@envisiongroup/porygon 0.1.0-rc.2 → 0.1.0-rc.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (41) hide show
  1. package/dist/react-components/fields/EFWAttachments/EFWAttachments.js +68 -67
  2. package/dist/react-components/fields/EFWAttachments/EFWAttachments.types.d.ts +8 -2
  3. package/dist/react-components/fields/EFWAttachmentsField/EFWAttachmentsField.js +18 -16
  4. package/dist/react-components/fields/EFWDatePicker/EFWDatePicker.js +79 -100
  5. package/dist/react-components/fields/EFWDatePicker/EFWDatePicker.types.d.ts +6 -1
  6. package/dist/react-components/fields/EFWDatePicker/EFWDatePicker.utils.d.ts +2 -0
  7. package/dist/react-components/fields/EFWDatePicker/EFWDatePicker.utils.js +33 -19
  8. package/dist/react-components/fields/EFWDatePickerField/EFWDatePickerField.js +35 -33
  9. package/dist/react-components/fields/EFWField/EFWField.d.ts +2 -1
  10. package/dist/react-components/fields/EFWField/EFWField.js +39 -33
  11. package/dist/react-components/fields/EFWInput/EFWInput.js +86 -67
  12. package/dist/react-components/fields/EFWInput/EFWInput.types.d.ts +13 -1
  13. package/dist/react-components/fields/EFWInput/EFWInput.utils.js +32 -33
  14. package/dist/react-components/fields/EFWInputField/EFWInputField.js +33 -31
  15. package/dist/react-components/fields/EFWNumberInput/EFWNumberInput.js +136 -121
  16. package/dist/react-components/fields/EFWNumberInput/EFWNumberInput.types.d.ts +12 -0
  17. package/dist/react-components/fields/EFWNumberInputField/EFWNumberInputField.js +31 -29
  18. package/dist/react-components/fields/EFWSwitch/EFWSwitch.js +36 -35
  19. package/dist/react-components/fields/EFWSwitch/EFWSwitch.types.d.ts +6 -0
  20. package/dist/react-components/fields/EFWSwitchField/EFWSwitchField.js +24 -22
  21. package/dist/react-components/fields/EFWSwitchField/EFWSwitchField.types.d.ts +1 -1
  22. package/dist/react-components/fields/EFWTagPicker/EFWTagPicker.js +122 -113
  23. package/dist/react-components/fields/EFWTagPicker/EFWTagPicker.types.d.ts +7 -2
  24. package/dist/react-components/fields/EFWTagPickerField/EFWTagPickerField.js +31 -29
  25. package/dist/react-components/fields/EFWTextArea/EFWTextArea.js +59 -57
  26. package/dist/react-components/fields/EFWTextArea/EFWTextArea.types.d.ts +6 -2
  27. package/dist/react-components/fields/EFWTextAreaField/EFWTextAreaField.js +31 -29
  28. package/dist/react-components/forms/EFWForm/EFWForm.d.ts +2 -1
  29. package/dist/react-components/forms/EFWForm/EFWForm.js +245 -210
  30. package/dist/react-components/forms/EFWForm/EFWForm.types.d.ts +13 -8
  31. package/dist/react-components/forms/EFWForm/EFWForm.utils.js +212 -179
  32. package/dist/react-components/tables/EFWTable/EFWTable.d.ts +1 -1
  33. package/dist/react-components/tables/EFWTable/EFWTable.js +473 -392
  34. package/dist/react-components/tables/EFWTable/EFWTable.types.d.ts +21 -0
  35. package/dist/react-components/tables/EFWTable/components/EFWTableCell/EFWTableCell.js +1 -1
  36. package/dist/react-components/tables/EFWTable/components/EFWTableCommandBar/EFWTableCommandBar.js +68 -77
  37. package/dist/react-components/tables/EFWTable/components/EFWTableHeader/EFWTableHeader.js +4 -4
  38. package/dist/react-components/tables/EFWTable/hooks/useDefaultDeleteButton/useDefaultDeleteButton.js +33 -30
  39. package/dist/react-components/tables/EFWTable/hooks/useDefaultUpdateButton/useDefaultUpdateButton.js +1 -1
  40. package/dist/react-components/tables/EFWTable/hooks/useTableController/useTableController.js +1 -1
  41. package/package.json +1 -1
@@ -1,58 +1,60 @@
1
1
  import { jsx as t } from "react/jsx-runtime";
2
- import { EFWField as C } from "../EFWField/EFWField.js";
3
- import { EFWDatePicker as E } from "../EFWDatePicker/EFWDatePicker.js";
2
+ import { EFWField as E } from "../EFWField/EFWField.js";
3
+ import { EFWDatePicker as M } from "../EFWDatePicker/EFWDatePicker.js";
4
4
  const k = (a) => {
5
5
  const {
6
6
  title: l,
7
7
  infoLabel: o,
8
8
  hint: i,
9
9
  style: r = {},
10
- required: n = !1,
11
- validationState: s,
12
- validationMessage: d,
10
+ required: s = !1,
11
+ validationState: d,
12
+ validationMessage: n,
13
13
  disabled: c = !1,
14
14
  editable: e = !0,
15
- hidden: h = !1,
16
- onChange: m,
17
- placeholder: f = "DD/MM/YYYY",
18
- selectedDates: D = [],
19
- allowRangeSelection: u = !1,
20
- restrictedDates: g = [],
21
- allowTextInput: p = !0,
22
- minDate: b,
23
- maxDate: w,
24
- showGoToToday: F,
25
- showCloseButton: x,
26
- onValidationChange: Y
15
+ hidden: f = !1,
16
+ onChange: h,
17
+ placeholder: m = "DD/MM/YYYY",
18
+ selectedDates: D,
19
+ defaultSelectedDates: u,
20
+ allowRangeSelection: g = !1,
21
+ restrictedDates: p = [],
22
+ allowTextInput: b = !0,
23
+ minDate: w,
24
+ maxDate: F,
25
+ showGoToToday: x,
26
+ showCloseButton: Y,
27
+ onValidationChange: C
27
28
  } = a;
28
29
  return /* @__PURE__ */ t(
29
- C,
30
+ E,
30
31
  {
31
32
  style: r,
32
33
  title: l,
33
34
  infoLabel: o,
34
35
  weightLabel: e ? "regular" : "semibold",
35
36
  hint: i,
36
- hidden: h,
37
- required: n,
38
- validationState: s,
39
- validationMessage: d,
40
- onValidationChange: Y,
37
+ hidden: f,
38
+ required: s,
39
+ validationState: d,
40
+ validationMessage: n,
41
+ onValidationChange: C,
41
42
  children: /* @__PURE__ */ t(
42
- E,
43
+ M,
43
44
  {
44
45
  editable: e,
45
46
  selectedDates: D,
46
- minDate: b,
47
- maxDate: w,
48
- onChange: m,
49
- allowTextInput: p,
47
+ defaultSelectedDates: u,
48
+ minDate: w,
49
+ maxDate: F,
50
+ onChange: h,
51
+ allowTextInput: b,
50
52
  disabled: c,
51
- placeholder: f,
52
- restrictedDates: g,
53
- allowRangeSelection: u,
54
- showGoToToday: F,
55
- showCloseButton: x
53
+ placeholder: m,
54
+ restrictedDates: p,
55
+ allowRangeSelection: g,
56
+ showGoToToday: x,
57
+ showCloseButton: Y
56
58
  }
57
59
  )
58
60
  }
@@ -3,7 +3,8 @@ import { EFWFieldProps } from './EFWField.types';
3
3
  /**
4
4
  * Componente de campo de formulario estilizado con soporte para validación y personalización.
5
5
  *
6
- * `EFWField` renderiza un campo de formulario con etiqueta, información adicional, mensajes de validación
6
+ * `EFWField` renderiza un campo de formulario con etiqueta, información adicional, mensajes
7
+ * de validación
7
8
  * y estilos personalizados. Gestiona el estado de validación internamente y notifica cambios de validación al componente padre si se proporciona
8
9
  * `onValidationChange`. Puede ocultarse condicionalmente y permite la integración de componentes hijos
9
10
  * con soporte para validación.
@@ -1,8 +1,8 @@
1
1
  import { jsx as v } from "react/jsx-runtime";
2
- import { makeStyles as B, InfoLabel as N, mergeClasses as R, Field as W } from "@fluentui/react-components";
3
- import $, { useState as x, useMemo as M, useRef as j, useEffect as l, useCallback as q } from "react";
2
+ import { makeStyles as R, InfoLabel as D, mergeClasses as W, Field as $ } from "@fluentui/react-components";
3
+ import j, { useState as x, useMemo as M, useRef as p, useEffect as l, useCallback as q } from "react";
4
4
  import { getValidationIcon as z } from "./EFWField.utils.js";
5
- const D = B({
5
+ const G = R({
6
6
  "efw-textField": {
7
7
  "& .fui-Field__validationMessage:empty": {
8
8
  display: "none !important"
@@ -23,62 +23,68 @@ const D = B({
23
23
  borderBottom: "2px solid var(--colorPaletteRedBorder2) !important"
24
24
  }
25
25
  }
26
- }), J = (S) => {
26
+ }), K = (V) => {
27
27
  const {
28
28
  title: o,
29
- hint: p,
30
- className: V,
31
- style: h = {},
32
- infoLabel: s,
33
- weightLabel: r = "regular",
29
+ hint: h,
30
+ className: y,
31
+ style: _ = {},
32
+ infoLabel: r,
33
+ weightLabel: s = "regular",
34
34
  required: d = !1,
35
- hidden: _ = !1,
36
- orientation: b,
37
- size: y,
35
+ hidden: b = !1,
36
+ orientation: C,
37
+ size: I,
38
38
  children: c,
39
39
  validationState: t = "none",
40
40
  validationMessage: a = "",
41
41
  onValidationChange: f
42
- } = S, n = D(), [e, g] = x(t), [i, u] = x(a), C = M(
42
+ } = V, n = G(), [e, u] = x(t), [i, g] = x(a), E = M(
43
43
  () => z(e),
44
44
  [e]
45
- ), I = M(() => /* @__PURE__ */ v(N, { weight: r, info: s || "", required: d, children: o }), [s, d, r, o]), m = j(0);
45
+ ), L = M(() => /* @__PURE__ */ v(D, { weight: s, info: r || "", required: d, children: o }), [r, d, s, o]), m = p(0);
46
46
  l(() => {
47
47
  m.current += 1, console.log(`EFWField ${o} #${m.current}`);
48
- }), l(() => {
49
- g(t), u(a);
48
+ });
49
+ const F = p(!1);
50
+ l(() => {
51
+ if (!F.current) {
52
+ F.current = !0;
53
+ return;
54
+ }
55
+ u(t), g(a);
50
56
  }, [t, a]);
51
- const E = q((F = "none", w = "") => {
52
- const P = F !== "none" ? F : t, k = w !== "" ? w : a;
53
- g(P), u(k);
57
+ const P = q((w = "none", S = "") => {
58
+ const B = w !== "none" ? w : t, N = S !== "" ? S : a;
59
+ u(B), g(N);
54
60
  }, [t, a]);
55
61
  if (l(() => {
56
62
  f?.({
57
63
  currentValidationState: e,
58
64
  currentValidationMessage: i
59
65
  });
60
- }, [e, i, f]), _) return null;
61
- const L = R(
62
- V,
66
+ }, [e, i, f]), b) return null;
67
+ const k = W(
68
+ y,
63
69
  n["efw-textField"],
64
70
  e === "success" && n["efw-textField-success"],
65
71
  e === "warning" && n["efw-textField-warning"],
66
72
  e === "error" && n["efw-textField-error"]
67
73
  );
68
74
  return /* @__PURE__ */ v(
69
- W,
75
+ $,
70
76
  {
71
- style: { ...h },
72
- className: L,
73
- label: I,
74
- hint: p,
77
+ style: { ..._ },
78
+ className: k,
79
+ label: L,
80
+ hint: h,
75
81
  validationState: e,
76
82
  validationMessage: i,
77
- validationMessageIcon: C,
78
- orientation: b,
79
- size: y,
80
- children: c && $.cloneElement(c, {
81
- setParentComponentState: E,
83
+ validationMessageIcon: E,
84
+ orientation: C,
85
+ size: I,
86
+ children: c && j.cloneElement(c, {
87
+ setParentComponentState: P,
82
88
  validationState: e,
83
89
  validationMessage: i
84
90
  })
@@ -86,5 +92,5 @@ const D = B({
86
92
  );
87
93
  };
88
94
  export {
89
- J as EFWField
95
+ K as EFWField
90
96
  };
@@ -1,100 +1,119 @@
1
- import { jsx as h, Fragment as U } from "react/jsx-runtime";
2
- import { makeStyles as _, tokens as l, mergeClasses as q, Input as D, Text as G } from "@fluentui/react-components";
3
- import { useId as H, useRef as J, useState as B, useMemo as K, useCallback as v, useEffect as Q } from "react";
4
- import { stripFormatting as f, applyFormatting as C, validateChileanRut as X, validateEmail as Y } from "./EFWInput.utils.js";
5
- const Z = _({
1
+ import { jsx as k, Fragment as Y } from "react/jsx-runtime";
2
+ import { makeStyles as Z, tokens as d, mergeClasses as ee, Input as te, Text as re } from "@fluentui/react-components";
3
+ import { useId as oe, useRef as ne, useState as W, useMemo as g, useCallback as z, useEffect as h } from "react";
4
+ import { stripFormatting as c, applyFormatting as f, validateChileanRut as ae, validateEmail as le } from "./EFWInput.utils.js";
5
+ const se = Z({
6
6
  efwInputError: {
7
- backgroundColor: l.colorPaletteRedBackground1,
7
+ backgroundColor: d.colorPaletteRedBackground1,
8
8
  "::after": {
9
- borderBottomColor: l.colorPaletteRedBorder2,
9
+ borderBottomColor: d.colorPaletteRedBorder2,
10
10
  borderBottomStyle: "solid",
11
11
  borderBottomWidth: "2px"
12
12
  }
13
13
  },
14
14
  efwInput: {
15
15
  "& [disabled]": {
16
- backgroundColor: l.colorNeutralBackground3,
17
- color: l.colorNeutralForeground2,
16
+ backgroundColor: d.colorNeutralBackground3,
17
+ color: d.colorNeutralForeground2,
18
18
  "&::placeholder": {
19
19
  color: "transparent"
20
20
  }
21
21
  },
22
22
  // Afectar el span que contiene el input disabled
23
23
  "&:has(span + [disabled])": {
24
- backgroundColor: l.colorNeutralBackground3
24
+ backgroundColor: d.colorNeutralBackground3
25
25
  }
26
26
  }
27
- }), re = (N) => {
27
+ }), fe = ($) => {
28
28
  const {
29
- value: o = "",
30
- onChange: b,
31
- editable: P = !0,
32
- disabled: V = !1,
33
- className: z = "",
34
- autoComplete: R = "off",
35
- type: T = "text",
36
- placeholder: L,
37
- contentBefore: W,
38
- contentAfter: $,
29
+ value: m,
30
+ defaultValue: E,
31
+ onChange: S,
32
+ editable: j = !0,
33
+ disabled: A = !1,
34
+ className: M = "",
35
+ autoComplete: O = "off",
36
+ type: U = "text",
37
+ placeholder: _,
38
+ contentBefore: q,
39
+ contentAfter: G,
39
40
  formatType: t = "none",
40
- formatPattern: n,
41
- formatFunction: y,
42
- minLength: s = 0,
43
- maxLength: m = 250,
44
- validationState: j = "none",
45
- setParentComponentState: r
46
- } = N, F = Z(), k = H(), x = J(o), [p, E] = B(() => o ? f(o, t) : ""), [g, I] = B(() => C(o || "", t)), i = K(
47
- () => ({ formatPattern: n, formatFunction: y }),
48
- [n, y]
49
- ), S = v((e) => {
50
- if (t === "none" || !n) return !0;
41
+ formatPattern: s,
42
+ formatFunction: C,
43
+ minLength: p = 0,
44
+ maxLength: v = 250,
45
+ validationState: H = "none",
46
+ setParentComponentState: l
47
+ } = $, r = m !== void 0, B = (r ? m : E) ?? "", N = E ?? "", P = se(), R = oe(), w = ne(!1), [u, D] = W(() => c(B, t)), [J, F] = W(() => f(B, t, { formatPattern: s, formatFunction: C })), o = g(
48
+ () => ({ formatPattern: s, formatFunction: C }),
49
+ [s, C]
50
+ ), i = g(
51
+ () => c(N, t),
52
+ [N, t]
53
+ ), b = g(
54
+ () => f(i, t, o),
55
+ [i, t, o]
56
+ ), T = g(() => {
57
+ if (!r)
58
+ return { raw: "", formatted: "" };
59
+ const e = c(m ?? "", t), a = f(e, t, o);
60
+ return { raw: e, formatted: a };
61
+ }, [r, m, t, o]), x = r ? T.raw : u, y = r ? T.formatted : J, L = z((e) => {
62
+ if (t === "none" || !s) return !0;
51
63
  try {
52
- return new RegExp(n).test(e);
64
+ return new RegExp(s).test(e);
53
65
  } catch {
54
66
  return !1;
55
67
  }
56
- }, [t, n]), u = v((e) => s > 0 && e.length > 0 && e.length < s ? (r?.("error", `Por favor introduzca más de ${s} caracteres.`), !0) : e.length > m ? (r?.("error", `Por favor introduzca menos de ${m} caracteres.`), !0) : t === "chileanRut" && e.length > 0 && !X(e) ? (r?.("error", "El R.U.T ingresado no es válido."), !0) : t === "email" && e.length > 0 && !Y(e) ? (r?.("error", "El correo ingresado no es válido."), !0) : S(e) ? (r?.("none", ""), !1) : (r?.("error", "El formato del valor ingresado no es válido."), !0), [s, m, t, S, r]);
57
- Q(() => {
58
- if (o !== x.current) {
59
- let e = f(o || "", t);
60
- if (e !== p) {
61
- const a = C(e, t, i);
62
- u(e), E(e), I(a);
63
- }
64
- x.current = o;
65
- }
66
- }, [o, t, i, u, p]);
67
- const A = v((e, a) => {
68
+ }, [t, s]), n = z((e) => p > 0 && e.length > 0 && e.length < p ? (l?.("error", `Por favor introduzca más de ${p} caracteres.`), !0) : e.length > v ? (l?.("error", `Por favor introduzca menos de ${v} caracteres.`), !0) : t === "chileanRut" && e.length > 0 && !ae(e) ? (l?.("error", "El R.U.T ingresado no es válido."), !0) : t === "email" && e.length > 0 && !le(e) ? (l?.("error", "El correo ingresado no es válido."), !0) : L(e) ? (l?.("none", ""), !1) : (l?.("error", "El formato del valor ingresado no es válido."), !0), [p, v, t, L, l]);
69
+ h(() => {
70
+ r && n(x);
71
+ }, [r, x, n]), h(() => {
72
+ r || (D((e) => e === i ? e : i), F((e) => e === b ? e : b), n(i));
73
+ }, [
74
+ r,
75
+ i,
76
+ b,
77
+ n
78
+ ]), h(() => {
79
+ r || F((e) => {
80
+ const a = f(u, t, o);
81
+ return a === e ? e : a;
82
+ });
83
+ }, [r, u, t, o]), h(() => {
84
+ r || w.current || (w.current = !0, n(u));
85
+ }, [r, u, n]);
86
+ const K = z((e, a) => {
68
87
  if (typeof a.value == "string") {
69
- const O = f(a.value, t), c = C(O, t, i), d = f(c, t);
70
- console.log("*********************************"), console.log("strippedValue", d), console.log("newFormattedValue", c), console.log("*********************************"), u(d), E(d), I(c), b?.(d, c);
88
+ const X = c(a.value, t), I = f(X, t, o), V = c(I, t);
89
+ n(V), r || (D(V), F(I)), S?.(V, I);
71
90
  }
72
- }, [t, i, b, u]), M = q(
73
- z,
74
- F.efwInput,
75
- j === "error" && F.efwInputError
91
+ }, [t, o, S, n, r]), Q = ee(
92
+ M,
93
+ P.efwInput,
94
+ H === "error" && P.efwInputError
76
95
  );
77
- return /* @__PURE__ */ h(U, { children: P ? /* @__PURE__ */ h(
78
- D,
96
+ return /* @__PURE__ */ k(Y, { children: j ? /* @__PURE__ */ k(
97
+ te,
79
98
  {
80
- className: M,
81
- id: k,
82
- name: k,
83
- type: T,
84
- placeholder: L,
85
- contentBefore: W,
86
- contentAfter: $,
87
- disabled: V,
88
- value: g,
89
- "data-raw-value": p,
90
- autoComplete: R,
99
+ className: Q,
100
+ id: R,
101
+ name: R,
102
+ type: U,
103
+ placeholder: _,
104
+ contentBefore: q,
105
+ contentAfter: G,
106
+ disabled: A,
107
+ value: y,
108
+ "data-raw-value": x,
109
+ autoComplete: O,
91
110
  autoCorrect: "off",
92
111
  autoCapitalize: "off",
93
112
  spellCheck: "false",
94
- onChange: A
113
+ onChange: K
95
114
  }
96
- ) : /* @__PURE__ */ h(G, { style: g ? void 0 : { opacity: 0.7 }, children: g || "Sin datos disponibles" }) });
115
+ ) : /* @__PURE__ */ k(re, { style: y ? void 0 : { opacity: 0.7 }, children: y || "Sin datos disponibles" }) });
97
116
  };
98
117
  export {
99
- re as EFWInput
118
+ fe as EFWInput
100
119
  };
@@ -16,7 +16,7 @@ import { EFWFieldChildrenProps } from '../EFWField/EFWField.types';
16
16
  * // En un componente React
17
17
  * const [inputValue, setInputValue] = useState<EFWInputValue>("Valor inicial");
18
18
  */
19
- export type EFWInputValue = string | null;
19
+ export type EFWInputValue = string | null | undefined;
20
20
  /**
21
21
  * Tipos de formato disponibles para el componente EFWInput.
22
22
  * Determina cómo se formatea y valida el contenido del campo de entrada.
@@ -103,6 +103,7 @@ export interface EFWInputProps extends Partial<EFWFieldChildrenProps> {
103
103
  /**
104
104
  * Valor actual del campo de entrada.
105
105
  * Puede ser una cadena de texto o null para campos vacíos.
106
+ * La presencia de esta propiedad activa el modo controlado del componente.
106
107
  *
107
108
  * @example
108
109
  * value="Juan Pérez"
@@ -111,6 +112,17 @@ export interface EFWInputProps extends Partial<EFWFieldChildrenProps> {
111
112
  * value={null}
112
113
  */
113
114
  value?: EFWInputValue;
115
+ /**
116
+ * Valor inicial usado en modo uncontrolled.
117
+ * Solo se aplica durante el montaje; luego el estado se maneja internamente.
118
+ *
119
+ * @example
120
+ * defaultValue="Texto inicial"
121
+ *
122
+ * @example
123
+ * defaultValue={null}
124
+ */
125
+ defaultValue?: EFWInputValue;
114
126
  /**
115
127
  * Tipo de input HTML que determina el comportamiento del campo.
116
128
  * Afecta el teclado virtual en dispositivos móviles y la validación del navegador.
@@ -1,50 +1,49 @@
1
1
  const p = (t) => {
2
- const n = (t || "").toString(), r = n.replace(/^0+/, "");
3
- let e = "";
4
- if (r != "" && r.length > 1) {
5
- const l = r.replace(/\./g, "").replace(/-/g, ""), s = l.substring(0, l.length - 1);
2
+ const r = (t || "").toString(), e = r.replace(/^0+/, "");
3
+ let n = "";
4
+ if (e != "" && e.length > 1) {
5
+ const l = e.replace(/\./g, "").replace(/-/g, ""), s = l.substring(0, l.length - 1);
6
6
  let c = 0, o = 1;
7
7
  for (c = s.length - 1; c >= 0; c--)
8
- e = s.charAt(c) + e, o % 3 == 0 && o <= s.length - 1 && (e = "." + e), o++;
8
+ n = s.charAt(c) + n, o % 3 == 0 && o <= s.length - 1 && (n = "." + n), o++;
9
9
  const g = l.substring(l.length - 1);
10
- return e = e + "-" + g, e;
10
+ return n = n + "-" + g, n;
11
11
  } else
12
- return n;
12
+ return r;
13
13
  }, u = (t) => {
14
14
  if (t = t || "", t = t.replace(/\./g, ""), !/^[0-9]+[-|‐]{1}[0-9kK]{1}$/.test(t))
15
15
  return !1;
16
- const n = t.split("-");
17
- let r = n[1];
18
- const e = n[0], i = function(l) {
16
+ const r = t.split("-");
17
+ let e = r[1];
18
+ const n = r[0], i = function(l) {
19
19
  let s = 0, c = 1;
20
20
  for (; l; l = Math.floor(l / 10))
21
21
  c = (c + l % 10 * (9 - s++ % 6)) % 11;
22
22
  return c ? c - 1 : "k";
23
23
  };
24
- return r == "K" && (r = "k"), i(e) == r;
25
- }, d = (t) => /^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/.test(t), m = (t, n, r = ",", e = ".") => {
24
+ return e == "K" && (e = "k"), i(n) == e;
25
+ }, d = (t) => /^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/.test(t), m = (t, r, e = ",", n = ".") => {
26
26
  if (t == null) return "";
27
- typeof t == "number" && (t = t.toString(), Number.isInteger(t) || (t = t.replace(".", e))), r = r || ",", e = e || ".";
28
- const i = new RegExp("[^" + e + "\\d]", "g"), s = t.replace(i, "").toString().split(e), c = s[0].length % 3;
27
+ typeof t == "number" && (t = t.toString(), Number.isInteger(t) || (t = t.replace(".", n))), e = e || ",", n = n || ".";
28
+ const i = new RegExp("[^" + n + "\\d]", "g"), s = t.replace(i, "").toString().split(n), c = s[0].length % 3;
29
29
  let o = s[0].substr(0, c);
30
30
  const g = s[0].substr(c).match(/\d{3}/g);
31
- return g && (o += (c ? r : "") + g.join(r)), o = s[1] != null ? o + e + s[1] : o, n == null ? o : o ? n + o : "";
31
+ return g && (o += (c ? e : "") + g.join(e)), o = s[1] != null ? o + n + s[1] : o, r == null ? o : o ? r + o : "";
32
32
  }, $ = (t = "") => {
33
- const n = t.toString().replace(/[^\d.]/g, "");
34
- return isNaN(Number(n)) || n === "" ? "" : n;
33
+ const r = t.toString().replace(/[^\d.]/g, "");
34
+ return isNaN(Number(r)) || r === "" ? "" : r;
35
35
  }, f = {
36
36
  none: (t) => t,
37
37
  email: (t) => t,
38
38
  phone: (t) => t.replace(/\D/g, ""),
39
39
  creditCard: (t) => t.replace(/\D/g, ""),
40
40
  chileanRut: (t) => {
41
- console.log("value", t, typeof t);
42
- const n = t.replace(/[^\dkK-]/gi, ""), r = n.includes("-"), e = n.replace(/-/g, "");
43
- if (r && e.length >= 2) {
44
- const i = e.length - 1;
45
- return e.slice(0, i) + "-" + e.slice(i);
41
+ const r = t.replace(/[^\dkK-]/gi, ""), e = r.includes("-"), n = r.replace(/-/g, "");
42
+ if (e && n.length >= 2) {
43
+ const i = n.length - 1;
44
+ return n.slice(0, i) + "-" + n.slice(i);
46
45
  }
47
- return e;
46
+ return n;
48
47
  },
49
48
  date: (t) => t.replace(/\D/g, ""),
50
49
  //number: (value) => stripFormatNumber(value || ''),
@@ -61,20 +60,20 @@ const p = (t) => {
61
60
  // if (isNaN(Number(value))) return value; // Si no es un número válido, retornar el valor original
62
61
  // return formatNumber(value)
63
62
  // },
64
- custom: (t, n = {}) => {
65
- if (n.formatFunction)
66
- return n.formatFunction(t) || t;
67
- if (n.formatPattern) {
68
- let r = "", e = 0;
69
- for (let i = 0; i < n.formatPattern.length && e < t.length; i++)
70
- n.formatPattern[i] === "#" ? (r += t[e], e++) : (r += n.formatPattern[i], n.formatPattern[i] === t[e] && e++);
71
- return r;
63
+ custom: (t, r = {}) => {
64
+ if (r.formatFunction)
65
+ return r.formatFunction(t) || t;
66
+ if (r.formatPattern) {
67
+ let e = "", n = 0;
68
+ for (let i = 0; i < r.formatPattern.length && n < t.length; i++)
69
+ r.formatPattern[i] === "#" ? (e += t[n], n++) : (e += r.formatPattern[i], r.formatPattern[i] === t[n] && n++);
70
+ return e;
72
71
  }
73
72
  return t;
74
73
  }
75
- }, F = (t, n) => t ? (console.log("FormatType", n), (f[n] || f.none)(t)) : "", y = (t, n, r = {}) => t ? (a[n] || a.none)(t, r) : "";
74
+ }, F = (t, r) => t ? (f[r] || f.none)(t) : "", P = (t, r, e = {}) => t ? (a[r] || a.none)(t, e) : "";
76
75
  export {
77
- y as applyFormatting,
76
+ P as applyFormatting,
78
77
  p as formatChileanRut,
79
78
  m as formatNumber,
80
79
  $ as stripFormatNumber,
@@ -5,62 +5,64 @@ const P = (n) => {
5
5
  const {
6
6
  title: a,
7
7
  infoLabel: o,
8
- hint: i,
9
- style: l = {},
8
+ hint: l,
9
+ style: i = {},
10
10
  size: r,
11
11
  required: d = !1,
12
12
  contentBefore: f,
13
13
  contentAfter: h,
14
14
  minLength: m = 0,
15
15
  maxLength: s = 250,
16
- validationState: g,
17
- validationMessage: p,
18
- value: u = "",
16
+ validationState: u,
17
+ validationMessage: g,
18
+ value: p,
19
+ defaultValue: c,
19
20
  editable: e = !0,
20
- disabled: c = !1,
21
- hidden: C = !1,
22
- onChange: F,
23
- autoComplete: b = "off",
24
- type: x = "text",
25
- placeholder: L,
26
- formatType: v = "none",
27
- formatPattern: y,
28
- formatFunction: E,
29
- onValidationChange: W
21
+ disabled: C = !1,
22
+ hidden: F = !1,
23
+ onChange: b,
24
+ autoComplete: x = "off",
25
+ type: L = "text",
26
+ placeholder: v,
27
+ formatType: y = "none",
28
+ formatPattern: E,
29
+ formatFunction: W,
30
+ onValidationChange: I
30
31
  } = n;
31
32
  return /* @__PURE__ */ t(
32
33
  q,
33
34
  {
34
- style: l,
35
+ style: i,
35
36
  title: a,
36
37
  infoLabel: o,
37
38
  weightLabel: e ? "regular" : "semibold",
38
- hint: i,
39
+ hint: l,
39
40
  size: r,
40
41
  required: d,
41
- validationState: g,
42
- validationMessage: p,
43
- onValidationChange: W,
44
- hidden: C,
42
+ validationState: u,
43
+ validationMessage: g,
44
+ onValidationChange: I,
45
+ hidden: F,
45
46
  children: /* @__PURE__ */ t(
46
47
  w,
47
48
  {
48
- value: u,
49
+ value: p,
50
+ defaultValue: c,
49
51
  editable: e,
50
- onChange: (I, j) => {
51
- F?.(I, j);
52
+ onChange: (V, j) => {
53
+ b?.(V, j);
52
54
  },
53
55
  minLength: m,
54
56
  maxLength: s,
55
- disabled: c,
56
- autoComplete: b,
57
- type: x,
58
- placeholder: L,
57
+ disabled: C,
58
+ autoComplete: x,
59
+ type: L,
60
+ placeholder: v,
59
61
  contentBefore: f,
60
62
  contentAfter: h,
61
- formatType: v,
62
- formatPattern: y,
63
- formatFunction: E
63
+ formatType: y,
64
+ formatPattern: E,
65
+ formatFunction: W
64
66
  }
65
67
  )
66
68
  }