bmi-next-brokers 2.5.9 → 2.6.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.
|
@@ -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,157 @@
|
|
|
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
|
-
|
|
15
|
-
options:
|
|
16
|
-
onSearch:
|
|
17
|
-
onSelect:
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
disabled:
|
|
21
|
-
btc:
|
|
22
|
-
size:
|
|
23
|
-
className:
|
|
24
|
-
containerClassName:
|
|
25
|
-
...
|
|
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 = ({
|
|
13
|
+
fields: u,
|
|
14
|
+
selectedItem: s = null,
|
|
15
|
+
options: l = [],
|
|
16
|
+
onSearch: d,
|
|
17
|
+
onSelect: k,
|
|
18
|
+
onReset: a,
|
|
19
|
+
noResultMessage: O = "No se encontraron resultados",
|
|
20
|
+
disabled: $ = !1,
|
|
21
|
+
btc: F = !1,
|
|
22
|
+
size: p = "medium",
|
|
23
|
+
className: C,
|
|
24
|
+
containerClassName: L,
|
|
25
|
+
...P
|
|
26
26
|
}) => {
|
|
27
|
-
const { btc:
|
|
27
|
+
const { btc: T } = Z(), W = F ?? T, j = !!d, [w, y] = N(!1), [K, M] = N(
|
|
28
|
+
{}
|
|
29
|
+
), [o, g] = N(null), f = S(null), h = S(null), b = S({}), V = w && !$, i = o ? K[o] ?? "" : "", A = z({
|
|
28
30
|
isOpen: w,
|
|
29
|
-
containerRef:
|
|
30
|
-
dropdownRef:
|
|
31
|
-
size:
|
|
32
|
-
optionsLength:
|
|
31
|
+
containerRef: f,
|
|
32
|
+
dropdownRef: h,
|
|
33
|
+
size: p,
|
|
34
|
+
optionsLength: l.length,
|
|
33
35
|
isSearchable: !0
|
|
34
|
-
})
|
|
35
|
-
|
|
36
|
-
const
|
|
37
|
-
|
|
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))
|
|
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));
|
|
38
48
|
};
|
|
39
|
-
return document.addEventListener("mousedown",
|
|
40
|
-
}, [])
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
49
|
+
return document.addEventListener("mousedown", n), () => document.removeEventListener("mousedown", n);
|
|
50
|
+
}, []), B(() => {
|
|
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] ?? "");
|
|
57
|
+
})
|
|
58
|
+
) || a == null || a()), n === "" && r.length > 0 && s && (a == null || a()), b.current = {
|
|
59
|
+
...b.current,
|
|
60
|
+
[o]: i
|
|
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] ?? "");
|
|
78
|
+
}
|
|
79
|
+
return "";
|
|
80
|
+
};
|
|
81
|
+
return /* @__PURE__ */ Q(
|
|
47
82
|
"div",
|
|
48
83
|
{
|
|
49
|
-
ref:
|
|
50
|
-
className: [
|
|
84
|
+
ref: f,
|
|
85
|
+
className: [_.container, L].filter(Boolean).join(" "),
|
|
51
86
|
children: [
|
|
52
|
-
/* @__PURE__ */
|
|
87
|
+
/* @__PURE__ */ c(
|
|
53
88
|
"div",
|
|
54
89
|
{
|
|
55
|
-
className: `${
|
|
56
|
-
...
|
|
57
|
-
children:
|
|
58
|
-
|
|
90
|
+
className: `${_.inputs} ${C || ""}`,
|
|
91
|
+
...P,
|
|
92
|
+
children: u.map((n) => /* @__PURE__ */ c("div", { className: _.inputWrapper, children: /* @__PURE__ */ c(
|
|
93
|
+
Y,
|
|
59
94
|
{
|
|
60
|
-
label:
|
|
61
|
-
placeholder:
|
|
62
|
-
value:
|
|
63
|
-
onChange: (
|
|
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),
|
|
64
100
|
icon: "SearchIcon",
|
|
65
|
-
size:
|
|
66
|
-
disabled:
|
|
67
|
-
btc:
|
|
101
|
+
size: p,
|
|
102
|
+
disabled: $,
|
|
103
|
+
btc: W
|
|
68
104
|
}
|
|
69
|
-
) },
|
|
105
|
+
) }, n.key))
|
|
70
106
|
}
|
|
71
107
|
),
|
|
72
|
-
|
|
73
|
-
/* @__PURE__ */
|
|
108
|
+
V && X(
|
|
109
|
+
/* @__PURE__ */ c(
|
|
74
110
|
"div",
|
|
75
111
|
{
|
|
76
|
-
ref:
|
|
112
|
+
ref: h,
|
|
77
113
|
className: [
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
114
|
+
t.dropdown,
|
|
115
|
+
t[p],
|
|
116
|
+
t.dropdownPortal,
|
|
117
|
+
t.dropdownTable
|
|
82
118
|
].join(" "),
|
|
83
|
-
style:
|
|
84
|
-
children:
|
|
119
|
+
style: A,
|
|
120
|
+
children: v.length > 0 ? v.map((n, r) => /* @__PURE__ */ c(
|
|
85
121
|
"div",
|
|
86
122
|
{
|
|
87
|
-
className: `${
|
|
88
|
-
onMouseDown: (
|
|
89
|
-
|
|
123
|
+
className: `${t.option} ${t.optionTable} ${I(n) ? t.optionSelected : ""}`,
|
|
124
|
+
onMouseDown: (e) => {
|
|
125
|
+
e.preventDefault(), e.stopPropagation(), H(n);
|
|
90
126
|
},
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
127
|
+
style: { padding: 0, gap: 0 },
|
|
128
|
+
children: u.map(({ key: e, columnKey: x, columnHeader: m }) => /* @__PURE__ */ Q(
|
|
129
|
+
"div",
|
|
130
|
+
{
|
|
131
|
+
className: t.tableColumn,
|
|
132
|
+
style: { padding: "8px 12px 8px 18px" },
|
|
133
|
+
children: [
|
|
134
|
+
m && /* @__PURE__ */ c(
|
|
135
|
+
"div",
|
|
136
|
+
{
|
|
137
|
+
className: `${t.columnHeader} ${t[p]}`,
|
|
138
|
+
children: m
|
|
139
|
+
}
|
|
140
|
+
),
|
|
141
|
+
/* @__PURE__ */ c(
|
|
142
|
+
"div",
|
|
143
|
+
{
|
|
144
|
+
className: `${t.columnValue} ${t[p]}`,
|
|
145
|
+
children: String(n[x ?? e] ?? "")
|
|
146
|
+
}
|
|
147
|
+
)
|
|
148
|
+
]
|
|
149
|
+
},
|
|
150
|
+
e
|
|
151
|
+
))
|
|
107
152
|
},
|
|
108
|
-
|
|
109
|
-
)) :
|
|
153
|
+
r
|
|
154
|
+
)) : /* @__PURE__ */ c("span", { className: t.noResults, children: O })
|
|
110
155
|
}
|
|
111
156
|
),
|
|
112
157
|
document.getElementById("root") || document.body
|
|
@@ -116,5 +161,5 @@ import '../../assets/index4.css';const G = "_container_1kajw_1", M = "_inputs_1k
|
|
|
116
161
|
);
|
|
117
162
|
};
|
|
118
163
|
export {
|
|
119
|
-
|
|
164
|
+
ln as SearchableInputGroup
|
|
120
165
|
};
|
package/package.json
CHANGED