bmi-next-brokers 2.5.9 → 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.
|
@@ -11,21 +11,20 @@ export interface SearchableInputGroupField {
|
|
|
11
11
|
}
|
|
12
12
|
export interface SearchableInputGroupProps extends Omit<React.HTMLAttributes<HTMLDivElement>, "onSelect"> {
|
|
13
13
|
fields: SearchableInputGroupField[];
|
|
14
|
-
/**
|
|
15
|
-
|
|
16
|
-
/**
|
|
14
|
+
/** Opción seleccionada actualmente. Controlado por el padre. */
|
|
15
|
+
selectedItem?: Record<string, unknown> | null;
|
|
16
|
+
/** Opciones del dropdown. Si no se pasa onSearch, el filtrado es interno. */
|
|
17
17
|
options?: Record<string, unknown>[];
|
|
18
|
-
/**
|
|
19
|
-
onSearch
|
|
18
|
+
/** Búsqueda remota: el padre filtra las opciones. Si se omite, el filtrado es interno. */
|
|
19
|
+
onSearch?: (key: string, value: string) => void;
|
|
20
20
|
/** Se llama al seleccionar una fila del dropdown. */
|
|
21
21
|
onSelect?: (item: Record<string, unknown>) => void;
|
|
22
|
-
/**
|
|
22
|
+
/** Se llama cuando selectedItem ya no está en las opciones filtradas. */
|
|
23
|
+
onReset?: () => void;
|
|
23
24
|
noResultMessage?: string;
|
|
24
|
-
/** Mientras loading=true no se muestra el mensaje de sin resultados. */
|
|
25
|
-
loading?: boolean;
|
|
26
25
|
disabled?: boolean;
|
|
27
26
|
size?: SelectSize;
|
|
28
27
|
btc?: boolean;
|
|
29
28
|
containerClassName?: string;
|
|
30
29
|
}
|
|
31
|
-
export declare const SearchableInputGroup: ({ fields,
|
|
30
|
+
export declare const SearchableInputGroup: ({ fields, selectedItem, options, onSearch, onSelect, onReset, noResultMessage, disabled, btc, size, className, containerClassName, ...rest }: SearchableInputGroupProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,112 +1,176 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { useState as
|
|
3
|
-
import { createPortal as
|
|
4
|
-
import { Input as
|
|
5
|
-
import { s as
|
|
6
|
-
import { useBTC as
|
|
7
|
-
import { useDropdownPosition as
|
|
8
|
-
import '../../assets/index4.css';const
|
|
9
|
-
container:
|
|
10
|
-
inputs:
|
|
11
|
-
inputWrapper:
|
|
12
|
-
},
|
|
13
|
-
fields:
|
|
14
|
-
|
|
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
|
+
fields: u,
|
|
14
|
+
selectedItem: c = null,
|
|
15
15
|
options: a = [],
|
|
16
|
-
onSearch:
|
|
17
|
-
onSelect:
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
disabled:
|
|
21
|
-
btc:
|
|
22
|
-
size:
|
|
23
|
-
className:
|
|
24
|
-
containerClassName:
|
|
25
|
-
...
|
|
16
|
+
onSearch: d,
|
|
17
|
+
onSelect: S,
|
|
18
|
+
onReset: s,
|
|
19
|
+
noResultMessage: W = "No se encontraron resultados",
|
|
20
|
+
disabled: C = !1,
|
|
21
|
+
btc: F = !1,
|
|
22
|
+
size: m = "medium",
|
|
23
|
+
className: E,
|
|
24
|
+
containerClassName: L,
|
|
25
|
+
...P
|
|
26
26
|
}) => {
|
|
27
|
-
const { btc:
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
27
|
+
const { btc: T } = I(), M = F ?? T, K = !!d, [x, g] = N(!1), [j, V] = N(
|
|
28
|
+
{}
|
|
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,
|
|
32
34
|
optionsLength: a.length,
|
|
33
35
|
isSearchable: !0
|
|
34
|
-
})
|
|
35
|
-
|
|
36
|
-
const
|
|
37
|
-
|
|
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
|
+
);
|
|
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));
|
|
38
48
|
};
|
|
39
|
-
return document.addEventListener("mousedown",
|
|
40
|
-
}, [])
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
49
|
+
return document.addEventListener("mousedown", r), () => document.removeEventListener("mousedown", r);
|
|
50
|
+
}, []), _(() => {
|
|
51
|
+
if (!o) return;
|
|
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
|
+
})
|
|
58
|
+
) || s == null || s()), r === "" && n.length > 0 && c && (s == null || s()), b.current = {
|
|
59
|
+
...b.current,
|
|
60
|
+
[o]: l
|
|
61
|
+
};
|
|
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] ?? "");
|
|
87
|
+
}
|
|
88
|
+
return "";
|
|
89
|
+
};
|
|
90
|
+
return /* @__PURE__ */ O(
|
|
47
91
|
"div",
|
|
48
92
|
{
|
|
49
|
-
ref:
|
|
50
|
-
className: [
|
|
93
|
+
ref: h,
|
|
94
|
+
className: [$.container, L].filter(Boolean).join(" "),
|
|
51
95
|
children: [
|
|
52
|
-
/* @__PURE__ */
|
|
96
|
+
/* @__PURE__ */ i(
|
|
53
97
|
"div",
|
|
54
98
|
{
|
|
55
|
-
className: `${
|
|
56
|
-
...
|
|
57
|
-
children:
|
|
58
|
-
|
|
99
|
+
className: `${$.inputs} ${E || ""}`,
|
|
100
|
+
...P,
|
|
101
|
+
children: u.map((r) => /* @__PURE__ */ i(
|
|
102
|
+
"div",
|
|
59
103
|
{
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
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
|
+
))
|
|
70
125
|
}
|
|
71
126
|
),
|
|
72
|
-
|
|
73
|
-
/* @__PURE__ */
|
|
127
|
+
q && Z(
|
|
128
|
+
/* @__PURE__ */ i(
|
|
74
129
|
"div",
|
|
75
130
|
{
|
|
76
|
-
ref:
|
|
131
|
+
ref: v,
|
|
77
132
|
className: [
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
133
|
+
e.dropdown,
|
|
134
|
+
e[m],
|
|
135
|
+
e.dropdownPortal,
|
|
136
|
+
e.dropdownTable
|
|
82
137
|
].join(" "),
|
|
83
|
-
style:
|
|
84
|
-
children:
|
|
138
|
+
style: A,
|
|
139
|
+
children: k.length > 0 ? k.map((r, n) => /* @__PURE__ */ i(
|
|
85
140
|
"div",
|
|
86
141
|
{
|
|
87
|
-
className: `${
|
|
88
|
-
onMouseDown: (
|
|
89
|
-
|
|
142
|
+
className: `${e.option} ${e.optionTable} ${U(r) ? e.optionSelected : ""}`,
|
|
143
|
+
onMouseDown: (t) => {
|
|
144
|
+
t.preventDefault(), t.stopPropagation(), J(r);
|
|
90
145
|
},
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
146
|
+
style: { padding: 0, gap: 0 },
|
|
147
|
+
children: u.map(({ key: t, columnKey: p, columnHeader: y }) => /* @__PURE__ */ O(
|
|
148
|
+
"div",
|
|
149
|
+
{
|
|
150
|
+
className: e.tableColumn,
|
|
151
|
+
style: { padding: "8px 12px 8px 18px" },
|
|
152
|
+
children: [
|
|
153
|
+
y && /* @__PURE__ */ i(
|
|
154
|
+
"div",
|
|
155
|
+
{
|
|
156
|
+
className: `${e.columnHeader} ${e[m]}`,
|
|
157
|
+
children: y
|
|
158
|
+
}
|
|
159
|
+
),
|
|
160
|
+
/* @__PURE__ */ i(
|
|
161
|
+
"div",
|
|
162
|
+
{
|
|
163
|
+
className: `${e.columnValue} ${e[m]}`,
|
|
164
|
+
children: String(r[p ?? t] ?? "")
|
|
165
|
+
}
|
|
166
|
+
)
|
|
167
|
+
]
|
|
168
|
+
},
|
|
169
|
+
t
|
|
170
|
+
))
|
|
107
171
|
},
|
|
108
|
-
|
|
109
|
-
)) :
|
|
172
|
+
n
|
|
173
|
+
)) : /* @__PURE__ */ i("span", { className: e.noResults, children: W })
|
|
110
174
|
}
|
|
111
175
|
),
|
|
112
176
|
document.getElementById("root") || document.body
|
|
@@ -116,5 +180,5 @@ import '../../assets/index4.css';const G = "_container_1kajw_1", M = "_inputs_1k
|
|
|
116
180
|
);
|
|
117
181
|
};
|
|
118
182
|
export {
|
|
119
|
-
|
|
183
|
+
lr as SearchableInputGroup
|
|
120
184
|
};
|
package/package.json
CHANGED