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