bmi-next-brokers 2.6.8 → 2.7.0
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/components/Input/Input.js +153 -137
- package/package.json +3 -2
|
@@ -1,239 +1,255 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { useState as
|
|
3
|
-
import { createPortal as
|
|
1
|
+
import { jsxs as v, jsx as l, Fragment as R } from "react/jsx-runtime";
|
|
2
|
+
import { useState as S, useRef as E, useEffect as T } from "react";
|
|
3
|
+
import { createPortal as U } from "react-dom";
|
|
4
4
|
import { s as e } from "../../Input.module-CvbQKI27.js";
|
|
5
5
|
import { Icon as _ } from "../../icons/Icon.js";
|
|
6
|
-
import { FieldError as
|
|
6
|
+
import { FieldError as W } from "../fieldError/index.js";
|
|
7
7
|
import { HelperText as X } from "../helperText/index.js";
|
|
8
8
|
import { useBTC as G } from "../../hooks/btcContext/useBtcContext.js";
|
|
9
|
-
const
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
9
|
+
const F = (a, d, s = !1) => {
|
|
10
|
+
let o = a.replace(
|
|
11
|
+
/{{([^}]+)}}/g,
|
|
12
|
+
(u, n) => `<span class="${d}" data-variable="${n}" contenteditable="false"></span>`
|
|
13
|
+
);
|
|
14
|
+
return s && (o = o.replace(/\n/g, "<br>")), o;
|
|
15
|
+
}, P = (a, d = !1) => {
|
|
16
|
+
let s = "", o = !0;
|
|
17
|
+
const u = (n, x = !1) => {
|
|
18
|
+
if (n.nodeType === Node.TEXT_NODE)
|
|
19
|
+
s += n.textContent ?? "";
|
|
20
|
+
else if (n instanceof HTMLElement) {
|
|
21
|
+
const i = n.tagName.toUpperCase();
|
|
22
|
+
n.dataset.variable ? s += `{{${n.dataset.variable}}}` : i === "BR" ? d && (s += `
|
|
23
|
+
`) : x && (i === "DIV" || i === "P") ? (d && !o && (s += `
|
|
24
|
+
`), o = !1, n.childNodes.forEach((c) => u(c, !1))) : n.childNodes.forEach((c) => u(c, !1));
|
|
25
|
+
}
|
|
16
26
|
};
|
|
17
|
-
return a.childNodes.forEach(
|
|
18
|
-
|
|
27
|
+
return a.childNodes.forEach((n) => u(n, !0)), d ? s.split(`
|
|
28
|
+
`).map((n) => n.trim()).filter((n) => n !== "").join(`
|
|
29
|
+
`) : s;
|
|
30
|
+
}, A = ({
|
|
19
31
|
value: a = "",
|
|
20
|
-
placeholder:
|
|
21
|
-
className:
|
|
22
|
-
style:
|
|
23
|
-
disabled:
|
|
24
|
-
onChange:
|
|
25
|
-
|
|
26
|
-
|
|
32
|
+
placeholder: d,
|
|
33
|
+
className: s,
|
|
34
|
+
style: o,
|
|
35
|
+
disabled: u,
|
|
36
|
+
onChange: n,
|
|
37
|
+
onFocus: x,
|
|
38
|
+
renderVariable: i,
|
|
39
|
+
multiline: c = !1
|
|
27
40
|
}) => {
|
|
28
|
-
const
|
|
29
|
-
const
|
|
30
|
-
|
|
31
|
-
Array.from(
|
|
32
|
-
(
|
|
41
|
+
const g = E(null), m = E(!1), [N, I] = S([]), $ = (t) => {
|
|
42
|
+
const y = t.querySelectorAll("[data-variable]");
|
|
43
|
+
I(
|
|
44
|
+
Array.from(y).map(
|
|
45
|
+
(b) => U(/* @__PURE__ */ l(R, { children: i(b.dataset.variable) }), b)
|
|
33
46
|
)
|
|
34
47
|
);
|
|
35
48
|
};
|
|
36
|
-
return
|
|
37
|
-
const t =
|
|
38
|
-
t && (t.innerHTML =
|
|
39
|
-
}, []),
|
|
40
|
-
const t =
|
|
49
|
+
return T(() => {
|
|
50
|
+
const t = g.current;
|
|
51
|
+
t && (t.innerHTML = F(a, e.variableSpan, c), $(t));
|
|
52
|
+
}, []), T(() => {
|
|
53
|
+
const t = g.current;
|
|
41
54
|
if (!t) return;
|
|
42
|
-
if (
|
|
43
|
-
|
|
55
|
+
if (m.current) {
|
|
56
|
+
m.current = !1;
|
|
44
57
|
return;
|
|
45
58
|
}
|
|
46
|
-
if (P(t) !== a && (t.innerHTML =
|
|
47
|
-
const
|
|
48
|
-
|
|
59
|
+
if (P(t, c) !== a && (t.innerHTML = F(a, e.variableSpan, c), $(t), document.activeElement === t)) {
|
|
60
|
+
const b = document.createRange(), f = window.getSelection();
|
|
61
|
+
b.selectNodeContents(t), b.collapse(!1), f == null || f.removeAllRanges(), f == null || f.addRange(b);
|
|
49
62
|
}
|
|
50
|
-
}, [a]), /* @__PURE__ */
|
|
51
|
-
/* @__PURE__ */
|
|
63
|
+
}, [a]), /* @__PURE__ */ v(R, { children: [
|
|
64
|
+
/* @__PURE__ */ l(
|
|
52
65
|
"div",
|
|
53
66
|
{
|
|
54
|
-
ref:
|
|
55
|
-
contentEditable: !
|
|
67
|
+
ref: g,
|
|
68
|
+
contentEditable: !u,
|
|
56
69
|
suppressContentEditableWarning: !0,
|
|
57
|
-
"data-placeholder":
|
|
58
|
-
className:
|
|
59
|
-
style:
|
|
70
|
+
"data-placeholder": d,
|
|
71
|
+
className: s,
|
|
72
|
+
style: o,
|
|
60
73
|
onInput: () => {
|
|
61
|
-
|
|
62
|
-
const t =
|
|
63
|
-
t && (
|
|
64
|
-
target: { value: P(t) }
|
|
74
|
+
m.current = !0;
|
|
75
|
+
const t = g.current;
|
|
76
|
+
t && (n == null || n({
|
|
77
|
+
target: { value: P(t, c) }
|
|
65
78
|
}));
|
|
66
79
|
},
|
|
67
80
|
onKeyDown: (t) => {
|
|
68
|
-
t.key === "Enter" && !
|
|
81
|
+
t.key === "Enter" && !c && t.preventDefault();
|
|
69
82
|
},
|
|
83
|
+
onFocus: x,
|
|
70
84
|
role: "textbox",
|
|
71
85
|
"aria-multiline": "true"
|
|
72
86
|
}
|
|
73
87
|
),
|
|
74
|
-
|
|
88
|
+
N
|
|
75
89
|
] });
|
|
76
90
|
}, ne = ({
|
|
77
91
|
size: a = "medium",
|
|
78
|
-
label:
|
|
79
|
-
error:
|
|
80
|
-
helperText:
|
|
81
|
-
icon:
|
|
82
|
-
className:
|
|
83
|
-
required:
|
|
92
|
+
label: d,
|
|
93
|
+
error: s,
|
|
94
|
+
helperText: o,
|
|
95
|
+
icon: u,
|
|
96
|
+
className: n,
|
|
97
|
+
required: x,
|
|
84
98
|
inverted: i = !1,
|
|
85
|
-
btc:
|
|
86
|
-
prefix:
|
|
87
|
-
type:
|
|
88
|
-
customBorderColor:
|
|
89
|
-
variableMode:
|
|
90
|
-
renderVariable:
|
|
91
|
-
multiline:
|
|
92
|
-
...
|
|
99
|
+
btc: c,
|
|
100
|
+
prefix: g,
|
|
101
|
+
type: m,
|
|
102
|
+
customBorderColor: N,
|
|
103
|
+
variableMode: I,
|
|
104
|
+
renderVariable: $,
|
|
105
|
+
multiline: w = !1,
|
|
106
|
+
...r
|
|
93
107
|
}) => {
|
|
94
|
-
const [
|
|
95
|
-
if (
|
|
96
|
-
const
|
|
97
|
-
|
|
98
|
-
},
|
|
99
|
-
const
|
|
100
|
-
|
|
101
|
-
},
|
|
102
|
-
|
|
108
|
+
const [t, y] = S(!1), b = m === "password", f = m === "date", H = m === "textarea", C = E(null), { btc: j } = G(), k = c ?? j, B = () => {
|
|
109
|
+
if (m !== "textarea") return;
|
|
110
|
+
const h = C.current;
|
|
111
|
+
h && (h.style.height = "auto");
|
|
112
|
+
}, K = () => {
|
|
113
|
+
const h = C.current;
|
|
114
|
+
h && (h.style.height = "auto", h.style.height = h.scrollHeight + "px");
|
|
115
|
+
}, V = (h) => {
|
|
116
|
+
h.key === "Enter" && !w && h.preventDefault();
|
|
103
117
|
};
|
|
104
|
-
|
|
105
|
-
|
|
118
|
+
T(() => {
|
|
119
|
+
B();
|
|
106
120
|
}, []);
|
|
107
|
-
const
|
|
121
|
+
const M = [
|
|
108
122
|
e.input,
|
|
109
123
|
e[a],
|
|
110
124
|
k && e.btc,
|
|
111
|
-
|
|
125
|
+
s ? e.error : "",
|
|
112
126
|
i ? e.inverted : "",
|
|
113
|
-
|
|
127
|
+
n
|
|
114
128
|
].filter(Boolean).join(" "), D = [
|
|
115
129
|
e.hiddenInput,
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
].filter(Boolean).join(" "),
|
|
119
|
-
|
|
120
|
-
}, L = `${e.textArea} ${e[`textArea_${a}`]} ${e.hiddenInput} ${
|
|
121
|
-
return /* @__PURE__ */
|
|
130
|
+
s ? e.hiddenInputError : "",
|
|
131
|
+
f ? e.dateInput : ""
|
|
132
|
+
].filter(Boolean).join(" "), p = a === "small" ? 16 : a === "large" ? 20 : a === "extraLarge" ? 24 : 18, q = () => {
|
|
133
|
+
y(!t);
|
|
134
|
+
}, L = `${e.textArea} ${e[`textArea_${a}`]} ${e.hiddenInput} ${s ? e.hiddenInputError : ""} ${I ? ` ${e.textArea_variableMode}` : ""}`, O = `${D} ${e.variableInputDiv} ${e[a]}`;
|
|
135
|
+
return /* @__PURE__ */ v(
|
|
122
136
|
"div",
|
|
123
137
|
{
|
|
124
|
-
className: `${e.inputContainer} ${a === "medium" ? e.inputContainer_medium : a === "large" ? e.inputContainer_large : a === "extraLarge" ? e.inputContainer_extraLarge : ""} ${
|
|
138
|
+
className: `${e.inputContainer} ${a === "medium" ? e.inputContainer_medium : a === "large" ? e.inputContainer_large : a === "extraLarge" ? e.inputContainer_extraLarge : ""} ${r.disabled ? e.disabled : ""}`,
|
|
125
139
|
children: [
|
|
126
|
-
|
|
140
|
+
d && /* @__PURE__ */ v(
|
|
127
141
|
"label",
|
|
128
142
|
{
|
|
129
|
-
className: `${e.label} ${a === "large" ? e.label_large : ""} ${a === "extraLarge" ? e.label_extraLarge : ""} ${i ? e.label_inverted : ""} ${
|
|
143
|
+
className: `${e.label} ${a === "large" ? e.label_large : ""} ${a === "extraLarge" ? e.label_extraLarge : ""} ${i ? e.label_inverted : ""} ${r.disabled ? e.disabled : ""}`,
|
|
130
144
|
children: [
|
|
131
|
-
|
|
132
|
-
/* @__PURE__ */
|
|
145
|
+
d,
|
|
146
|
+
/* @__PURE__ */ l(
|
|
133
147
|
"span",
|
|
134
148
|
{
|
|
135
149
|
className: `${e.required} ${i ? e.required_inverted : ""}`,
|
|
136
|
-
children:
|
|
150
|
+
children: x && "*"
|
|
137
151
|
}
|
|
138
152
|
)
|
|
139
153
|
]
|
|
140
154
|
}
|
|
141
155
|
),
|
|
142
|
-
/* @__PURE__ */
|
|
156
|
+
/* @__PURE__ */ v(
|
|
143
157
|
"div",
|
|
144
158
|
{
|
|
145
|
-
className: `${e.inputWrapper} ${
|
|
159
|
+
className: `${e.inputWrapper} ${r.disabled ? e.disabled : ""}`,
|
|
146
160
|
children: [
|
|
147
|
-
/* @__PURE__ */
|
|
161
|
+
/* @__PURE__ */ v(
|
|
148
162
|
"div",
|
|
149
163
|
{
|
|
150
|
-
className:
|
|
164
|
+
className: M,
|
|
151
165
|
ref: C,
|
|
152
166
|
style: {
|
|
153
|
-
...
|
|
154
|
-
...
|
|
167
|
+
...r.style,
|
|
168
|
+
...N && { borderColor: N }
|
|
155
169
|
},
|
|
156
170
|
children: [
|
|
157
|
-
(
|
|
158
|
-
|
|
159
|
-
|
|
171
|
+
(g || u) && /* @__PURE__ */ v("div", { className: e.prefixIcon, children: [
|
|
172
|
+
g && /* @__PURE__ */ l("span", { className: e.prefix, children: g }),
|
|
173
|
+
u && !f && /* @__PURE__ */ l(
|
|
160
174
|
"div",
|
|
161
175
|
{
|
|
162
176
|
className: `${e.icon} ${i ? e.icon_inverted : ""} `,
|
|
163
|
-
children: /* @__PURE__ */
|
|
177
|
+
children: /* @__PURE__ */ l(_, { name: u, width: p, height: p })
|
|
164
178
|
}
|
|
165
179
|
)
|
|
166
180
|
] }),
|
|
167
|
-
|
|
168
|
-
|
|
181
|
+
H ? I && $ ? /* @__PURE__ */ l(
|
|
182
|
+
A,
|
|
169
183
|
{
|
|
170
184
|
className: L,
|
|
171
|
-
value:
|
|
172
|
-
placeholder:
|
|
173
|
-
style:
|
|
174
|
-
disabled:
|
|
175
|
-
onChange:
|
|
176
|
-
|
|
177
|
-
|
|
185
|
+
value: r.value,
|
|
186
|
+
placeholder: r.placeholder,
|
|
187
|
+
style: r.style,
|
|
188
|
+
disabled: r.disabled,
|
|
189
|
+
onChange: r.onChange,
|
|
190
|
+
onFocus: r.onFocus,
|
|
191
|
+
renderVariable: $,
|
|
192
|
+
multiline: w
|
|
178
193
|
}
|
|
179
|
-
) : /* @__PURE__ */
|
|
194
|
+
) : /* @__PURE__ */ l(
|
|
180
195
|
"textarea",
|
|
181
196
|
{
|
|
182
197
|
className: L,
|
|
183
|
-
onChange:
|
|
184
|
-
onKeyDown:
|
|
185
|
-
...
|
|
198
|
+
onChange: K,
|
|
199
|
+
onKeyDown: V,
|
|
200
|
+
...r
|
|
186
201
|
}
|
|
187
|
-
) :
|
|
188
|
-
|
|
202
|
+
) : I && $ ? /* @__PURE__ */ l(
|
|
203
|
+
A,
|
|
189
204
|
{
|
|
190
205
|
className: O,
|
|
191
|
-
value:
|
|
192
|
-
placeholder:
|
|
193
|
-
disabled:
|
|
194
|
-
onChange:
|
|
195
|
-
|
|
196
|
-
|
|
206
|
+
value: r.value,
|
|
207
|
+
placeholder: r.placeholder,
|
|
208
|
+
disabled: r.disabled,
|
|
209
|
+
onChange: r.onChange,
|
|
210
|
+
onFocus: r.onFocus,
|
|
211
|
+
renderVariable: $,
|
|
212
|
+
multiline: w
|
|
197
213
|
}
|
|
198
|
-
) : /* @__PURE__ */
|
|
214
|
+
) : /* @__PURE__ */ l(
|
|
199
215
|
"input",
|
|
200
216
|
{
|
|
201
217
|
className: D,
|
|
202
|
-
type:
|
|
203
|
-
...
|
|
218
|
+
type: b ? t ? "text" : "password" : m,
|
|
219
|
+
...r
|
|
204
220
|
}
|
|
205
221
|
)
|
|
206
222
|
]
|
|
207
223
|
}
|
|
208
224
|
),
|
|
209
|
-
|
|
225
|
+
b && /* @__PURE__ */ l(
|
|
210
226
|
"button",
|
|
211
227
|
{
|
|
212
228
|
type: "button",
|
|
213
229
|
className: `${e.passwordToggle} ${i ? e.passwordToggle_inverted : ""}`,
|
|
214
|
-
onClick:
|
|
215
|
-
disabled:
|
|
216
|
-
"aria-label":
|
|
217
|
-
children: /* @__PURE__ */
|
|
230
|
+
onClick: q,
|
|
231
|
+
disabled: r.disabled,
|
|
232
|
+
"aria-label": t ? "Ocultar contraseña" : "Mostrar contraseña",
|
|
233
|
+
children: /* @__PURE__ */ l(
|
|
218
234
|
_,
|
|
219
235
|
{
|
|
220
|
-
name:
|
|
221
|
-
width:
|
|
222
|
-
height:
|
|
236
|
+
name: t ? "VisibilityOff" : "Visibility",
|
|
237
|
+
width: p,
|
|
238
|
+
height: p
|
|
223
239
|
}
|
|
224
240
|
)
|
|
225
241
|
}
|
|
226
242
|
),
|
|
227
|
-
|
|
243
|
+
f && /* @__PURE__ */ l(
|
|
228
244
|
"div",
|
|
229
245
|
{
|
|
230
|
-
className: `${e.dateIcon} ${i ? e.dateIcon_inverted : ""} ${
|
|
231
|
-
children: /* @__PURE__ */
|
|
246
|
+
className: `${e.dateIcon} ${i ? e.dateIcon_inverted : ""} ${s ? e.dateIcon_error : ""} ${s && i ? e.dateIcon_inverted_error : ""}`,
|
|
247
|
+
children: /* @__PURE__ */ l(
|
|
232
248
|
_,
|
|
233
249
|
{
|
|
234
250
|
name: "CalendarIcon",
|
|
235
|
-
width:
|
|
236
|
-
height:
|
|
251
|
+
width: p + 2,
|
|
252
|
+
height: p + 2
|
|
237
253
|
}
|
|
238
254
|
)
|
|
239
255
|
}
|
|
@@ -241,8 +257,8 @@ const A = (a, s) => a.replace(
|
|
|
241
257
|
]
|
|
242
258
|
}
|
|
243
259
|
),
|
|
244
|
-
|
|
245
|
-
|
|
260
|
+
s && /* @__PURE__ */ l(W, { size: a, message: s }),
|
|
261
|
+
o && !s && /* @__PURE__ */ l(X, { message: o, size: a, inverted: i })
|
|
246
262
|
]
|
|
247
263
|
}
|
|
248
264
|
);
|
package/package.json
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "bmi-next-brokers",
|
|
3
3
|
"description": "Componentes de UI para proyecto BMI Next Brokers",
|
|
4
|
-
"version": "2.
|
|
4
|
+
"version": "2.7.0",
|
|
5
5
|
"author": "BMI Ahorro España",
|
|
6
6
|
"contributors": [
|
|
7
7
|
"José Ramón Jiménez <jrjimenez@bmicos.com>",
|
|
8
8
|
"David Fernández Bolaños <dafernandez@bmicos.com>",
|
|
9
9
|
"Jorge Martín <jmartin@bmicos.com>",
|
|
10
|
-
"Alonso Mangas <amangas@bmicos.com>"
|
|
10
|
+
"Alonso Mangas <amangas@bmicos.com>",
|
|
11
|
+
"Pablo Bejar <pbejar@bmicos.com>"
|
|
11
12
|
],
|
|
12
13
|
"license": "MIT",
|
|
13
14
|
"type": "module",
|