bmi-next-brokers 2.6.6 → 2.6.7

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