bmi-next-brokers 2.6.0 → 2.6.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,157 +1,176 @@
1
- import { jsxs as Q, jsx as c } from "react/jsx-runtime";
2
- import { useState as N, useRef as S, useMemo as U, useEffect as B } from "react";
3
- import { createPortal as X } from "react-dom";
4
- import { Input as Y } from "../Input/Input.js";
5
- import { s as t } from "../../Select.module-D_7bjq9u.js";
6
- import { useBTC as Z } from "../../hooks/btcContext/useBtcContext.js";
7
- import { useDropdownPosition as z } from "../../hooks/useDropdownPosition.js";
8
- import '../../assets/index4.css';const R = "_container_1kajw_1", nn = "_inputs_1kajw_7", rn = "_inputWrapper_1kajw_13", _ = {
9
- container: R,
10
- inputs: nn,
11
- inputWrapper: rn
12
- }, ln = ({
1
+ import { jsxs as O, jsx as i } from "react/jsx-runtime";
2
+ import { useState as N, useRef as w, useMemo as Y, useEffect as _ } from "react";
3
+ import { createPortal as Z } from "react-dom";
4
+ import { Input as z } from "../Input/Input.js";
5
+ import { s as e } from "../../Select.module-D_7bjq9u.js";
6
+ import { useBTC as I } from "../../hooks/btcContext/useBtcContext.js";
7
+ import { useDropdownPosition as R } from "../../hooks/useDropdownPosition.js";
8
+ import '../../assets/index4.css';const rr = "_container_1kajw_1", nr = "_inputs_1kajw_7", tr = "_inputWrapper_1kajw_13", $ = {
9
+ container: rr,
10
+ inputs: nr,
11
+ inputWrapper: tr
12
+ }, lr = ({
13
13
  fields: u,
14
- selectedItem: s = null,
15
- options: l = [],
14
+ selectedItem: c = null,
15
+ options: a = [],
16
16
  onSearch: d,
17
- onSelect: k,
18
- onReset: a,
19
- noResultMessage: O = "No se encontraron resultados",
20
- disabled: $ = !1,
17
+ onSelect: S,
18
+ onReset: s,
19
+ noResultMessage: W = "No se encontraron resultados",
20
+ disabled: C = !1,
21
21
  btc: F = !1,
22
- size: p = "medium",
23
- className: C,
22
+ size: m = "medium",
23
+ className: E,
24
24
  containerClassName: L,
25
25
  ...P
26
26
  }) => {
27
- const { btc: T } = Z(), W = F ?? T, j = !!d, [w, y] = N(!1), [K, M] = N(
27
+ const { btc: T } = I(), M = F ?? T, K = !!d, [x, g] = N(!1), [j, V] = N(
28
28
  {}
29
- ), [o, g] = N(null), f = S(null), h = S(null), b = S({}), V = w && !$, i = o ? K[o] ?? "" : "", A = z({
30
- isOpen: w,
31
- containerRef: f,
32
- dropdownRef: h,
33
- size: p,
34
- optionsLength: l.length,
29
+ ), [o, f] = N(null), h = w(null), v = w(null), b = w({}), D = w({}), q = x && !C, l = o ? j[o] ?? "" : "", A = R({
30
+ isOpen: x,
31
+ containerRef: h,
32
+ dropdownRef: v,
33
+ size: m,
34
+ optionsLength: a.length,
35
35
  isSearchable: !0
36
- }), D = (n) => typeof n == "string" ? n.normalize("NFD").replace(/[̀-ͯ]/g, "").replace(/\s+/g, "").toLowerCase() : "", v = U(() => {
37
- if (!o || !i || j) return l;
38
- const n = u.find((e) => e.key === o);
39
- if (!n) return l;
40
- const r = n.columnKey ?? n.key;
41
- return l.filter(
42
- (e) => D(String(e[r] ?? "")).includes(D(i))
36
+ }), Q = (r) => typeof r == "string" ? r.normalize("NFD").replace(/[̀-ͯ]/g, "").replace(/\s+/g, "").toLowerCase() : "", k = Y(() => {
37
+ if (!o || !l || K) return a;
38
+ const r = u.find((t) => t.key === o);
39
+ if (!r) return a;
40
+ const n = r.columnKey ?? r.key;
41
+ return a.filter(
42
+ (t) => Q(String(t[n] ?? "")).includes(Q(l))
43
43
  );
44
- }, [l, i, o, j]);
45
- B(() => {
46
- const n = (r) => {
47
- f.current && !f.current.contains(r.target) && h.current && !h.current.contains(r.target) && (y(!1), g(null));
44
+ }, [a, l, o, K]);
45
+ _(() => {
46
+ const r = (n) => {
47
+ h.current && !h.current.contains(n.target) && v.current && !v.current.contains(n.target) && (g(!1), f(null));
48
48
  };
49
- return document.addEventListener("mousedown", n), () => document.removeEventListener("mousedown", n);
50
- }, []), B(() => {
49
+ return document.addEventListener("mousedown", r), () => document.removeEventListener("mousedown", r);
50
+ }, []), _(() => {
51
51
  if (!o) return;
52
- const n = i.trim(), r = (b.current[o] ?? "").trim();
53
- s && n.length > 0 && (v.some(
54
- (x) => u.every((m) => {
55
- const E = m.columnKey ?? m.key;
56
- return String(x[E] ?? "") === String(s[E] ?? "");
52
+ const r = l.trim(), n = (b.current[o] ?? "").trim();
53
+ c && r.length > 0 && (k.some(
54
+ (p) => u.every((y) => {
55
+ const B = y.columnKey ?? y.key;
56
+ return String(p[B] ?? "") === String(c[B] ?? "");
57
57
  })
58
- ) || a == null || a()), n === "" && r.length > 0 && s && (a == null || a()), b.current = {
58
+ ) || s == null || s()), r === "" && n.length > 0 && c && (s == null || s()), b.current = {
59
59
  ...b.current,
60
- [o]: i
60
+ [o]: l
61
61
  };
62
- }, [i, o, s, v]);
63
- const G = (n, r) => {
64
- M((e) => ({ ...e, [n]: r })), g(n), y(!0), d == null || d(n, r);
65
- }, q = (n) => {
66
- g(n), w || y(!0);
67
- }, H = (n) => {
68
- k == null || k(n), y(!1), g(null);
69
- }, I = (n) => s ? u.every((r) => {
70
- const e = r.columnKey ?? r.key;
71
- return String(n[e] ?? "") === String(s[e] ?? "");
72
- }) : !1, J = (n) => {
73
- if (o === n.key)
74
- return K[n.key] ?? "";
75
- if (s) {
76
- const r = n.columnKey ?? n.key;
77
- return String(s[r] ?? "");
62
+ }, [l, o, c, k]), _(() => {
63
+ if (!c) return;
64
+ a.some(
65
+ (n) => u.every((t) => {
66
+ const p = t.columnKey ?? t.key;
67
+ return String(n[p] ?? "") === String(c[p] ?? "");
68
+ })
69
+ ) || s == null || s();
70
+ }, [a]);
71
+ const G = (r, n) => {
72
+ V((t) => ({ ...t, [r]: n })), f(r), g(!0), d == null || d(r, n);
73
+ }, H = (r) => {
74
+ f(r), x || g(!0);
75
+ }, J = (r) => {
76
+ var n, t;
77
+ S == null || S(r), g(!1), f(null), o && ((t = (n = D.current[o]) == null ? void 0 : n.querySelector("input")) == null || t.blur());
78
+ }, U = (r) => c ? u.every((n) => {
79
+ const t = n.columnKey ?? n.key;
80
+ return String(r[t] ?? "") === String(c[t] ?? "");
81
+ }) : !1, X = (r) => {
82
+ if (o === r.key)
83
+ return j[r.key] ?? "";
84
+ if (c) {
85
+ const n = r.columnKey ?? r.key;
86
+ return String(c[n] ?? "");
78
87
  }
79
88
  return "";
80
89
  };
81
- return /* @__PURE__ */ Q(
90
+ return /* @__PURE__ */ O(
82
91
  "div",
83
92
  {
84
- ref: f,
85
- className: [_.container, L].filter(Boolean).join(" "),
93
+ ref: h,
94
+ className: [$.container, L].filter(Boolean).join(" "),
86
95
  children: [
87
- /* @__PURE__ */ c(
96
+ /* @__PURE__ */ i(
88
97
  "div",
89
98
  {
90
- className: `${_.inputs} ${C || ""}`,
99
+ className: `${$.inputs} ${E || ""}`,
91
100
  ...P,
92
- children: u.map((n) => /* @__PURE__ */ c("div", { className: _.inputWrapper, children: /* @__PURE__ */ c(
93
- Y,
101
+ children: u.map((r) => /* @__PURE__ */ i(
102
+ "div",
94
103
  {
95
- label: n.label,
96
- placeholder: n.placeholder,
97
- value: J(n),
98
- onChange: (r) => G(n.key, r.target.value),
99
- onFocus: () => q(n.key),
100
- icon: "SearchIcon",
101
- size: p,
102
- disabled: $,
103
- btc: W
104
- }
105
- ) }, n.key))
104
+ className: $.inputWrapper,
105
+ ref: (n) => {
106
+ D.current[r.key] = n;
107
+ },
108
+ children: /* @__PURE__ */ i(
109
+ z,
110
+ {
111
+ label: r.label,
112
+ placeholder: r.placeholder,
113
+ value: X(r),
114
+ onChange: (n) => G(r.key, n.target.value),
115
+ onFocus: () => H(r.key),
116
+ icon: "SearchIcon",
117
+ size: m,
118
+ disabled: C,
119
+ btc: M
120
+ }
121
+ )
122
+ },
123
+ r.key
124
+ ))
106
125
  }
107
126
  ),
108
- V && X(
109
- /* @__PURE__ */ c(
127
+ q && Z(
128
+ /* @__PURE__ */ i(
110
129
  "div",
111
130
  {
112
- ref: h,
131
+ ref: v,
113
132
  className: [
114
- t.dropdown,
115
- t[p],
116
- t.dropdownPortal,
117
- t.dropdownTable
133
+ e.dropdown,
134
+ e[m],
135
+ e.dropdownPortal,
136
+ e.dropdownTable
118
137
  ].join(" "),
119
138
  style: A,
120
- children: v.length > 0 ? v.map((n, r) => /* @__PURE__ */ c(
139
+ children: k.length > 0 ? k.map((r, n) => /* @__PURE__ */ i(
121
140
  "div",
122
141
  {
123
- className: `${t.option} ${t.optionTable} ${I(n) ? t.optionSelected : ""}`,
124
- onMouseDown: (e) => {
125
- e.preventDefault(), e.stopPropagation(), H(n);
142
+ className: `${e.option} ${e.optionTable} ${U(r) ? e.optionSelected : ""}`,
143
+ onMouseDown: (t) => {
144
+ t.preventDefault(), t.stopPropagation(), J(r);
126
145
  },
127
146
  style: { padding: 0, gap: 0 },
128
- children: u.map(({ key: e, columnKey: x, columnHeader: m }) => /* @__PURE__ */ Q(
147
+ children: u.map(({ key: t, columnKey: p, columnHeader: y }) => /* @__PURE__ */ O(
129
148
  "div",
130
149
  {
131
- className: t.tableColumn,
150
+ className: e.tableColumn,
132
151
  style: { padding: "8px 12px 8px 18px" },
133
152
  children: [
134
- m && /* @__PURE__ */ c(
153
+ y && /* @__PURE__ */ i(
135
154
  "div",
136
155
  {
137
- className: `${t.columnHeader} ${t[p]}`,
138
- children: m
156
+ className: `${e.columnHeader} ${e[m]}`,
157
+ children: y
139
158
  }
140
159
  ),
141
- /* @__PURE__ */ c(
160
+ /* @__PURE__ */ i(
142
161
  "div",
143
162
  {
144
- className: `${t.columnValue} ${t[p]}`,
145
- children: String(n[x ?? e] ?? "")
163
+ className: `${e.columnValue} ${e[m]}`,
164
+ children: String(r[p ?? t] ?? "")
146
165
  }
147
166
  )
148
167
  ]
149
168
  },
150
- e
169
+ t
151
170
  ))
152
171
  },
153
- r
154
- )) : /* @__PURE__ */ c("span", { className: t.noResults, children: O })
172
+ n
173
+ )) : /* @__PURE__ */ i("span", { className: e.noResults, children: W })
155
174
  }
156
175
  ),
157
176
  document.getElementById("root") || document.body
@@ -161,5 +180,5 @@ import '../../assets/index4.css';const R = "_container_1kajw_1", nn = "_inputs_1
161
180
  );
162
181
  };
163
182
  export {
164
- ln as SearchableInputGroup
183
+ lr as SearchableInputGroup
165
184
  };
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.0",
4
+ "version": "2.6.1",
5
5
  "author": "BMI Ahorro España",
6
6
  "contributors": [
7
7
  "José Ramón Jiménez <jrjimenez@bmicos.com>",