prometeo-design-system 2.7.0 → 2.7.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.
@@ -1,7 +1,7 @@
1
1
  import { j as q } from "./jsx-runtime-DKDX3adD.js";
2
2
  import m, { createContext as mn, useContext as hn, useCallback as R, useRef as Se, useLayoutEffect as yn, useState as he, useEffect as _e, useMemo as fe, memo as pn } from "react";
3
3
  import { InputMultiple as gn } from "./InputMultiple.es.js";
4
- import { I as wn } from "./Input-BTsR-vNF.js";
4
+ import { I as wn } from "./Input-C22kKz7U.js";
5
5
  import { createPortal as bn } from "react-dom";
6
6
  import { Icons as Mt } from "./Icons.es.js";
7
7
  import { c as Be } from "./cn-B6yFEsav.js";
@@ -0,0 +1,255 @@
1
+ import { j as r } from "./jsx-runtime-DKDX3adD.js";
2
+ import { Icons as E } from "./Icons.es.js";
3
+ import { c as t } from "./cn-B6yFEsav.js";
4
+ import { useRef as H, useLayoutEffect as oe, memo as le, forwardRef as se, useState as ne, useEffect as ae } from "react";
5
+ import ue from "./Spinner.es.js";
6
+ import { H as ce } from "./HelperComponent-U6mPwuDH.js";
7
+ import fe from "./ButtonV2.es.js";
8
+ const de = (o) => {
9
+ let e = o;
10
+ for (; e && e !== document.body; ) {
11
+ const a = window.getComputedStyle(e).backgroundColor;
12
+ if (a && a !== "transparent" && a !== "rgba(0, 0, 0, 0)")
13
+ return a;
14
+ e = e.parentElement;
15
+ }
16
+ const l = window.getComputedStyle(document.body).backgroundColor;
17
+ return l && l !== "transparent" && l !== "rgba(0, 0, 0, 0)" ? l : "rgb(255, 255, 255)";
18
+ };
19
+ function pe() {
20
+ const o = H(null);
21
+ return oe(() => {
22
+ if (!o.current || !o.current.parentElement) return;
23
+ const e = de(o.current.parentElement);
24
+ o.current.style.backgroundColor = e;
25
+ }, []), {
26
+ ref: o
27
+ };
28
+ }
29
+ const b = {
30
+ default: {
31
+ container: "",
32
+ input: t(
33
+ "border-neutral-default-default text-neutral-default-default!",
34
+ "focus:ring-primary-default-default focus:ring-[1px] focus:border-primary-default-default ",
35
+ "hover:border-neutral-strong-default"
36
+ ),
37
+ label: t("text-neutral-medium-default"),
38
+ icon: t(
39
+ "text-neutral-medium-default",
40
+ "peer-focus:text-primary-default-default"
41
+ )
42
+ },
43
+ error: {
44
+ container: "",
45
+ input: t(
46
+ "border-error-default-default text-neutral-default-default",
47
+ "focus:border-error-default focus:border-2",
48
+ "focus:ring-0 focus:ring-error-default/20"
49
+ ),
50
+ label: t("text-lime-500", "peer-focus:text-error-light"),
51
+ icon: t("text-error-light", "peer-focus:text-error-light")
52
+ },
53
+ success: {
54
+ container: "",
55
+ input: t(
56
+ "border-success-default-default text-neutral-default-default",
57
+ "focus:border-success-default focus:border-2",
58
+ "focus:ring-0 focus:ring-success-default/20"
59
+ ),
60
+ label: t("text-success", "peer-focus:text-success-light"),
61
+ icon: t("text-success-light", "peer-focus:text-success-light")
62
+ }
63
+ }, k = se(
64
+ ({
65
+ label: o,
66
+ icon: e,
67
+ iconPosition: l = "left",
68
+ onChange: I,
69
+ value: a = "",
70
+ name: g,
71
+ width: m = "100%",
72
+ height: u,
73
+ variant: c = "default",
74
+ labelVariant: n = "default",
75
+ size: B = "medium",
76
+ disabled: x = !1,
77
+ type: s = "text",
78
+ isFetching: f,
79
+ errorComponent: h,
80
+ helperComponent: w,
81
+ placeholder: $,
82
+ required: R = !1,
83
+ onFocus: L,
84
+ onBlur: P,
85
+ onKeyDown: D,
86
+ onKeyUp: M,
87
+ className: O,
88
+ isActive: y,
89
+ style: T,
90
+ readOnly: G = !1,
91
+ onClear: S,
92
+ ...J
93
+ }, K) => {
94
+ const [j, Q] = ne(!1), { ref: U } = pe(), W = H(null), z = K || null || W;
95
+ let d = B;
96
+ u && (d = "customHeight");
97
+ const p = {
98
+ small: {
99
+ container: "text-sm",
100
+ input: "h-10 px-3 text-[1rem] prometeo-fonts-body-large",
101
+ label: ` prometeo-fonts-label-large
102
+ peer-focus:prometeo-fonts-label-large
103
+ peer-placeholder-shown:${n === "default" ? "prometeo-fonts-body-large" : "prometeo-fonts-label-large"} peer-placeholder-shown:text-neutral-medium-default peer-focus:text-neutral-medium-default `,
104
+ icon: "w-4 h-4 right-3"
105
+ },
106
+ medium: {
107
+ container: "text-base",
108
+ input: "h-12 px-3 prometeo-fonts-body-large",
109
+ label: ` prometeo-fonts-label-large
110
+ peer-focus:prometeo-fonts-label-large
111
+ peer-placeholder-shown:${n === "default" ? "prometeo-fonts-body-large" : "prometeo-fonts-label-large"} peer-placeholder-shown:text-neutral-medium-default text-neutral-medium-default peer-focus:text-neutral-medium-default `,
112
+ icon: "w-5 h-5 right-3"
113
+ },
114
+ large: {
115
+ container: "text-lg",
116
+ input: "h-14 px-3 text-lg border-b border-t-0 border-x-0 rounded-none focus:ring-0 prometeo-fonts-body-xlarge ",
117
+ label: "peer-placeholder-shown:prometeo-fonts-body-xlarge peer-focus:prometeo-fonts-label-large peer-focus:text-neutral-medium-default prometeo-fonts-label-large ",
118
+ icon: "w-6 h-6 right-3"
119
+ },
120
+ customHeight: {
121
+ container: "text-base",
122
+ input: "text-base",
123
+ label: "text-sm peer-focus:text-sm peer-placeholder-shown:text-xs ",
124
+ icon: "w-6 h-6 right-3"
125
+ }
126
+ };
127
+ ae(() => {
128
+ y && z.current?.focus();
129
+ }, [y, z.current?.focus]);
130
+ const X = (i) => {
131
+ L?.(i);
132
+ }, Y = (i) => {
133
+ y === void 0 && P?.(i);
134
+ }, Z = () => {
135
+ Q(!j);
136
+ }, C = {};
137
+ m && m !== "100%" && (C.width = m), u && (C.height = u);
138
+ const v = c === "error" && h, _ = !v && w, q = s === "password", A = () => n === "static" ? "-top-1 -translate-y-full left-0 pl-3" : e ? `peer-placeholder-shown:top-1/2 -translate-y-1/2 peer-focus:top-0 peer-focus:left-3 peer-focus:px-1 peer-focus:ml-0 peer-focus:mr-0 ${l === "left" ? "peer-placeholder-shown:ml-6" : "peer-placeholder-shown:mr-6"}` : "peer-placeholder-shown:top-1/2 -translate-y-1/2 peer-focus:top-0 peer-focus:left-3 peer-focus:px-1", F = () => u ? p.customHeight.label : p[d].label, V = () => u ? { height: u } : {}, ee = () => n === "default" ? o : $ || o || "", te = () => q ? e ? l === "left" ? "pl-10 pr-10" : "pr-16" : "pr-10" : e ? l === "left" ? "pl-10 pr-3" : "pr-10 pl-3" : "", re = n === "default" && "transition-all duration-200 ease-in-out", N = h || w;
139
+ return /* @__PURE__ */ r.jsxs(
140
+ "div",
141
+ {
142
+ className: t(
143
+ "relative",
144
+ p[d].container,
145
+ !m && "w-full",
146
+ "bg-inherit",
147
+ n === "static" && "mt-2",
148
+ O
149
+ ),
150
+ style: { ...T, ...C },
151
+ children: [
152
+ /* @__PURE__ */ r.jsx(
153
+ "input",
154
+ {
155
+ id: g,
156
+ name: g,
157
+ ref: z,
158
+ value: a,
159
+ placeholder: ee(),
160
+ type: s === "password" && j ? "text" : s,
161
+ className: t(
162
+ "peer w-full border rounded-lg bg-transparent appearance-none transition-all duration-200 ease-in-out",
163
+ "focus:outline-none px-3",
164
+ n === "default" && "placeholder:text-transparent",
165
+ n === "static" && "placeholder:text-neutral-medium-default ",
166
+ b[c].input,
167
+ p[d].input,
168
+ e && "pr-10",
169
+ x && "bg-transparent opacity-60 border-neutral-strong-default text-neutral-medium-disabled",
170
+ b[c].container,
171
+ te()
172
+ ),
173
+ style: V(),
174
+ onChange: I,
175
+ onFocus: X,
176
+ onBlur: Y,
177
+ disabled: x,
178
+ required: R,
179
+ onKeyDown: D,
180
+ onKeyUp: M,
181
+ readOnly: G,
182
+ ...J
183
+ }
184
+ ),
185
+ /* @__PURE__ */ r.jsx(
186
+ "label",
187
+ {
188
+ ref: U,
189
+ htmlFor: g,
190
+ className: t(
191
+ "absolute left-3 pointer-events-none px-1 z-10",
192
+ re,
193
+ F(),
194
+ b[c].label,
195
+ A(),
196
+ R && "after:content-['*'] after:text-error-default after:ml-1",
197
+ x && "text-neutral-medium-disabled prometeo-fonts-label-large"
198
+ ),
199
+ children: o
200
+ }
201
+ ),
202
+ (e || s === "password" || f) && /* @__PURE__ */ r.jsx(
203
+ "button",
204
+ {
205
+ tabIndex: -1,
206
+ type: "button",
207
+ className: t(
208
+ `absolute ${N ? "top-[calc(50%-12px)]" : "top-1/2"} -translate-y-1/2 flex items-center justify-center z-10`,
209
+ p[d].icon,
210
+ b[c].icon,
211
+ s === "password" && !f ? "cursor-pointer" : "pointer-events-none",
212
+ l === "right" ? "right-3" : "left-3"
213
+ ),
214
+ onClick: s === "password" && !f ? Z : void 0,
215
+ onMouseDown: (i) => s === "password" && !f && i.preventDefault(),
216
+ children: /* @__PURE__ */ r.jsxs("div", { children: [
217
+ f && s !== "password" && /* @__PURE__ */ r.jsx("div", { children: /* @__PURE__ */ r.jsx(ue, { size: 24, color: "#7c86ff", loading: !0, variant: "clip" }) }),
218
+ s === "password" && (j ? /* @__PURE__ */ r.jsx(E.EyeVisibility, { size: 24, className: "" }) : /* @__PURE__ */ r.jsx(E.EyeVisibilityOff, { size: 24, className: "" })),
219
+ e
220
+ ] })
221
+ }
222
+ ),
223
+ S && /* @__PURE__ */ r.jsx(
224
+ fe,
225
+ {
226
+ type: "button",
227
+ color: "secondary",
228
+ size: "small",
229
+ animate: !1,
230
+ className: t(
231
+ `absolute ${N ? "top-[calc(50%-12px)]" : "top-1/2"} -translate-y-1/2 flex items-center justify-center z-10 right-1`,
232
+ "size-6 p-4 ",
233
+ "bg-inherit",
234
+ "hover:bg-transparent! p-4 rounded-full"
235
+ ),
236
+ label: "",
237
+ disabled: x,
238
+ onClick: S,
239
+ variant: "text",
240
+ animateIcon: !1,
241
+ icon: /* @__PURE__ */ r.jsx(E.Close, { size: 20, className: "" })
242
+ }
243
+ ),
244
+ N && /* @__PURE__ */ r.jsx("div", { className: "min-h-6", children: (v || _) && /* @__PURE__ */ r.jsx(ce, { className: "absolute ", variant: c, children: h || w }) })
245
+ ]
246
+ }
247
+ );
248
+ }
249
+ );
250
+ k.displayName = "Input";
251
+ const je = le(k);
252
+ export {
253
+ je as I,
254
+ pe as u
255
+ };
package/dist/Input.es.js CHANGED
@@ -1,4 +1,4 @@
1
- import { I as f } from "./Input-BTsR-vNF.js";
1
+ import { I as f } from "./Input-C22kKz7U.js";
2
2
  export {
3
3
  f as default
4
4
  };
@@ -1,7 +1,7 @@
1
1
  import { j as o } from "./jsx-runtime-DKDX3adD.js";
2
2
  import { FastField as u } from "formik";
3
3
  import { memo as s } from "react";
4
- import { I as i } from "./Input-BTsR-vNF.js";
4
+ import { I as i } from "./Input-C22kKz7U.js";
5
5
  const c = ({
6
6
  field: r,
7
7
  form: t,
@@ -1,42 +1,70 @@
1
1
  import { j as e } from "./jsx-runtime-DKDX3adD.js";
2
2
  import { c as j } from "./cn-B6yFEsav.js";
3
- import v from "react";
4
- const V = v.forwardRef(
5
- ({
6
- className: u,
7
- startDate: h,
8
- endDate: x,
9
- label: o,
10
- ...g
11
- }, p) => {
12
- const d = new Date(h), a = new Date(x), s = /* @__PURE__ */ new Date(), c = a.getTime() - d.getTime(), m = s.getTime() - d.getTime(), y = Math.min(100, Math.max(0, m / c * 100)), n = 1440 * 60 * 1e3, l = Math.max(0, Math.ceil((a.getTime() - s.getTime()) / n)), i = Math.floor((s.getTime() - a.getTime()) / n), f = Math.ceil(c / n), T = Math.min(f, Math.max(0, Math.floor(m / n))), r = s > a, w = l === 0 && !r, b = r && i === 0;
13
- let t = o;
14
- return o || (r ? i === 0 ? t = "Vence hoy" : i === 1 ? t = "Vencido hace 1 día" : t = `Vencido hace ${i} días` : l === 0 ? t = "Vence hoy" : l === 1 ? t = "Falta 1 día" : t = `Faltan ${l} días`), /* @__PURE__ */ e.jsxs("div", { ref: p, className: u, ...g, children: [
15
- /* @__PURE__ */ e.jsxs("div", { className: "flex justify-between items-end mb-2 gap-4 px-2", children: [
16
- /* @__PURE__ */ e.jsxs("div", { className: "flex flex-col gap-1", children: [
17
- /* @__PURE__ */ e.jsx("span", { className: "text-sm text-neutral-medium-default", children: "Tiempo restante de resolución" }),
18
- /* @__PURE__ */ e.jsx("span", { className: "font-semibold text-base text-neutral-default-default", children: t })
3
+ import T from "react";
4
+ const M = T.forwardRef(
5
+ (o, g) => {
6
+ const { className: p, label: m, ...b } = o;
7
+ if (o.variant === "date") {
8
+ const { startDate: l, endDate: n } = o, r = new Date(l), t = new Date(n), a = /* @__PURE__ */ new Date(), i = t.getTime() - r.getTime(), c = a.getTime() - r.getTime(), d = Math.min(100, Math.max(0, c / i * 100)), u = 1440 * 60 * 1e3, f = Math.max(0, Math.ceil((t.getTime() - a.getTime()) / u)), x = Math.floor((a.getTime() - t.getTime()) / u), y = Math.ceil(i / u), w = Math.min(y, Math.max(0, Math.floor(c / u))), h = a > t, v = f === 0 && !h, N = h && x === 0;
9
+ let s = m;
10
+ return m || (h ? x === 0 ? s = "Vence hoy" : x === 1 ? s = "Vencido hace 1 día" : s = `Vencido hace ${x} días` : f === 0 ? s = "Vence hoy" : f === 1 ? s = "Falta 1 día" : s = `Faltan ${f} días`), /* @__PURE__ */ e.jsxs("div", { ref: g, className: p, ...b, children: [
11
+ /* @__PURE__ */ e.jsxs("div", { className: "flex justify-between items-end mb-2 gap-4 px-2", children: [
12
+ /* @__PURE__ */ e.jsxs("div", { className: "flex flex-col gap-1", children: [
13
+ /* @__PURE__ */ e.jsx("span", { className: "text-sm text-neutral-medium-default", children: "Tiempo restante de resolución" }),
14
+ /* @__PURE__ */ e.jsx("span", { className: "font-semibold text-base text-neutral-default-default", children: s })
15
+ ] }),
16
+ /* @__PURE__ */ e.jsxs("span", { className: "text-sm text-neutral-medium-default whitespace-nowrap", children: [
17
+ w,
18
+ " / ",
19
+ y,
20
+ " días"
21
+ ] })
19
22
  ] }),
20
- /* @__PURE__ */ e.jsxs("span", { className: "text-sm text-neutral-medium-default whitespace-nowrap", children: [
21
- T,
22
- " / ",
23
- f,
24
- " días"
25
- ] })
26
- ] }),
27
- /* @__PURE__ */ e.jsx("div", { className: "w-full bg-neutral-800 dark:bg-neutral-900 border border-neutral-600 dark:border-neutral-700 rounded-sm h-4 overflow-hidden", children: /* @__PURE__ */ e.jsx(
28
- "div",
29
- {
30
- className: j(
31
- "h-full transition-all duration-300",
32
- w || b ? "bg-yellow-500" : r ? "bg-red-500" : "bg-primary-default-default"
33
- ),
34
- style: { width: `${y}%` }
35
- }
36
- ) })
37
- ] });
23
+ /* @__PURE__ */ e.jsx("div", { className: "w-full bg-neutral-800 dark:bg-neutral-900 border border-neutral-600 dark:border-neutral-700 rounded-sm h-4 overflow-hidden", children: /* @__PURE__ */ e.jsx(
24
+ "div",
25
+ {
26
+ className: j(
27
+ "h-full transition-all duration-300",
28
+ v || N ? "bg-yellow-500" : h ? "bg-red-500" : "bg-primary-default-default"
29
+ ),
30
+ style: { width: `${d}%` }
31
+ }
32
+ ) })
33
+ ] });
34
+ }
35
+ if (o.variant === "quantity") {
36
+ const { current: l, total: n, unit: r = "items" } = o, t = Math.min(100, Math.max(0, l / n * 100)), a = Math.max(0, n - l), i = l >= n, c = t >= 80 && !i;
37
+ let d = m;
38
+ return m || (i ? d = "Completado" : a === 1 ? d = `Falta 1 ${r}` : d = `Faltan ${a} ${r}`), /* @__PURE__ */ e.jsxs("div", { ref: g, className: p, ...b, children: [
39
+ /* @__PURE__ */ e.jsxs("div", { className: "flex justify-between items-end mb-2 gap-4 px-2", children: [
40
+ /* @__PURE__ */ e.jsxs("div", { className: "flex flex-col gap-1", children: [
41
+ /* @__PURE__ */ e.jsx("span", { className: "text-sm text-neutral-medium-default", children: "Progreso" }),
42
+ /* @__PURE__ */ e.jsx("span", { className: "font-semibold text-base text-neutral-default-default", children: d })
43
+ ] }),
44
+ /* @__PURE__ */ e.jsxs("span", { className: "text-sm text-neutral-medium-default whitespace-nowrap", children: [
45
+ l,
46
+ " / ",
47
+ n,
48
+ " ",
49
+ r
50
+ ] })
51
+ ] }),
52
+ /* @__PURE__ */ e.jsx("div", { className: "w-full bg-neutral-800 dark:bg-neutral-900 border border-neutral-600 dark:border-neutral-700 rounded-sm h-4 overflow-hidden", children: /* @__PURE__ */ e.jsx(
53
+ "div",
54
+ {
55
+ className: j(
56
+ "h-full transition-all duration-300",
57
+ i ? "bg-green-500" : c ? "bg-yellow-500" : "bg-primary-default-default"
58
+ ),
59
+ style: { width: `${t}%` }
60
+ }
61
+ ) })
62
+ ] });
63
+ }
64
+ return null;
38
65
  }
39
66
  );
67
+ M.displayName = "ProgressBar";
40
68
  export {
41
- V as default
69
+ M as default
42
70
  };