meticulous-ui 2.1.1 → 2.1.2
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,13 +1,13 @@
|
|
|
1
1
|
import { j as r } from "../../_virtual/jsx-runtime.js";
|
|
2
|
-
import { useState as C, useRef as S, useMemo as
|
|
3
|
-
import
|
|
2
|
+
import { useState as C, useRef as S, useMemo as M, useEffect as d, useLayoutEffect as ee, useCallback as te, createElement as ne } from "react";
|
|
3
|
+
import re from "../../node_modules/lodash-es/get.js";
|
|
4
4
|
import I from "../../colors/grey.js";
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
5
|
+
import oe from "../MenuItem/MenuItem.js";
|
|
6
|
+
import se from "../../colors/index.js";
|
|
7
|
+
import ie from "../../colors/blue.js";
|
|
8
8
|
import F from "../Spinner/Spinner.js";
|
|
9
|
-
import { DropdownWrapper as
|
|
10
|
-
const
|
|
9
|
+
import { DropdownWrapper as ce, Box as le, PWrapper as fe, ChevronDownWrapper as ue, OptionWrapper as ae, SearchContainer as pe, SearchIcon as de, SearchInput as me, OptionsList as he, LoadMoreSentinel as xe, SpinnerWrapper as be } from "./styles.js";
|
|
10
|
+
const ge = (o) => {
|
|
11
11
|
if (typeof o != "string") return o;
|
|
12
12
|
if (o.endsWith("px")) return parseFloat(o);
|
|
13
13
|
if (o.endsWith("rem")) {
|
|
@@ -15,7 +15,7 @@ const be = (o) => {
|
|
|
15
15
|
return E * i;
|
|
16
16
|
}
|
|
17
17
|
return parseFloat(o);
|
|
18
|
-
},
|
|
18
|
+
}, ye = ({
|
|
19
19
|
options: o,
|
|
20
20
|
onChange: E,
|
|
21
21
|
value: i,
|
|
@@ -29,11 +29,12 @@ const be = (o) => {
|
|
|
29
29
|
searchable: h = !1,
|
|
30
30
|
onLoadMore: l,
|
|
31
31
|
hasMore: x = !1,
|
|
32
|
-
isLoadingMore: a = !1
|
|
32
|
+
isLoadingMore: a = !1,
|
|
33
|
+
searchPh: B = "Search..."
|
|
33
34
|
}) => {
|
|
34
|
-
const [n, j] = C(!1), [
|
|
35
|
+
const [n, j] = C(!1), [H, V] = C("bottom"), [b, D] = C(""), [f, p] = C(-1), g = S(null), w = S(null), k = S(null), R = S(null), K = S(!0), Q = () => j((e) => !e), z = (e) => {
|
|
35
36
|
e !== i && (E(e), j(!1));
|
|
36
|
-
}, c =
|
|
37
|
+
}, c = M(() => {
|
|
37
38
|
if (!h || !b.trim()) return o;
|
|
38
39
|
const e = b.toLowerCase();
|
|
39
40
|
return o.filter(({ label: t }) => t.toLowerCase().includes(e));
|
|
@@ -60,44 +61,44 @@ const be = (o) => {
|
|
|
60
61
|
}, [f, n]), d(() => {
|
|
61
62
|
n && h && k.current && k.current.focus();
|
|
62
63
|
}, [n, h]), d(() => {
|
|
63
|
-
n || (
|
|
64
|
+
n || (K.current = !0);
|
|
64
65
|
}, [n]), d(() => {
|
|
65
66
|
const e = (t) => {
|
|
66
67
|
g.current && !g.current.contains(t.target) && j(!1);
|
|
67
68
|
};
|
|
68
69
|
return document.addEventListener("mousedown", e), () => document.removeEventListener("mousedown", e);
|
|
69
|
-
}, []),
|
|
70
|
+
}, []), ee(() => {
|
|
70
71
|
if (n && w.current && g.current) {
|
|
71
|
-
const e = g.current.getBoundingClientRect(), t = window.innerHeight, s =
|
|
72
|
-
|
|
72
|
+
const e = g.current.getBoundingClientRect(), t = window.innerHeight, s = ge(O), u = t - e.bottom;
|
|
73
|
+
V(
|
|
73
74
|
u < s + 8 && e.top > u ? "top" : "bottom"
|
|
74
75
|
);
|
|
75
76
|
}
|
|
76
77
|
}, [n, O]);
|
|
77
|
-
const
|
|
78
|
+
const q = (e) => {
|
|
78
79
|
let t = e + 1;
|
|
79
80
|
for (; t < c.length; ) {
|
|
80
81
|
if (!c[t].disabled) return t;
|
|
81
82
|
t++;
|
|
82
83
|
}
|
|
83
84
|
return e;
|
|
84
|
-
},
|
|
85
|
+
}, N = (e) => {
|
|
85
86
|
let t = e - 1;
|
|
86
87
|
for (; t >= 0; ) {
|
|
87
88
|
if (!c[t].disabled) return t;
|
|
88
89
|
t--;
|
|
89
90
|
}
|
|
90
91
|
return e;
|
|
91
|
-
},
|
|
92
|
+
}, U = (e) => {
|
|
92
93
|
if (n)
|
|
93
94
|
switch (e.key) {
|
|
94
95
|
case "ArrowDown":
|
|
95
96
|
e.preventDefault();
|
|
96
|
-
const t =
|
|
97
|
+
const t = q(f);
|
|
97
98
|
t === f && x && !a && l?.(), p(t);
|
|
98
99
|
break;
|
|
99
100
|
case "ArrowUp":
|
|
100
|
-
e.preventDefault(), p((u) =>
|
|
101
|
+
e.preventDefault(), p((u) => N(u));
|
|
101
102
|
break;
|
|
102
103
|
case "Enter":
|
|
103
104
|
e.preventDefault();
|
|
@@ -108,7 +109,7 @@ const be = (o) => {
|
|
|
108
109
|
j(!1);
|
|
109
110
|
break;
|
|
110
111
|
}
|
|
111
|
-
}, W =
|
|
112
|
+
}, W = te(() => {
|
|
112
113
|
x && !a && l && l();
|
|
113
114
|
}, [x, a, l]);
|
|
114
115
|
d(() => {
|
|
@@ -129,68 +130,68 @@ const be = (o) => {
|
|
|
129
130
|
return t.observe(e), () => t.disconnect();
|
|
130
131
|
}, [W, l, x, a]);
|
|
131
132
|
const {
|
|
132
|
-
m50:
|
|
133
|
-
m100:
|
|
134
|
-
m200:
|
|
135
|
-
m500:
|
|
136
|
-
} =
|
|
137
|
-
|
|
133
|
+
m50: G,
|
|
134
|
+
m100: J,
|
|
135
|
+
m200: T,
|
|
136
|
+
m500: X
|
|
137
|
+
} = re(se, A, ie), Y = (e, t) => () => !e && p(t), Z = ({ value: e, label: t, disabled: s }, u) => /* @__PURE__ */ ne(
|
|
138
|
+
oe,
|
|
138
139
|
{
|
|
139
140
|
value: e,
|
|
140
141
|
label: t,
|
|
141
142
|
isDisabled: s,
|
|
142
143
|
onSelect: z,
|
|
143
|
-
onMouseEnter:
|
|
144
|
+
onMouseEnter: Y(s, u),
|
|
144
145
|
isSelected: e === i,
|
|
145
146
|
isHighlighted: u === f,
|
|
146
147
|
key: e,
|
|
147
148
|
width: m,
|
|
148
|
-
selectedColor:
|
|
149
|
-
hoverColor:
|
|
150
|
-
activeColor:
|
|
149
|
+
selectedColor: T,
|
|
150
|
+
hoverColor: G,
|
|
151
|
+
activeColor: J
|
|
151
152
|
}
|
|
152
|
-
),
|
|
153
|
+
), _ = (e) => {
|
|
153
154
|
D(e.target.value);
|
|
154
|
-
},
|
|
155
|
+
}, L = (e) => {
|
|
155
156
|
e.stopPropagation();
|
|
156
157
|
};
|
|
157
158
|
return /* @__PURE__ */ r.jsxs(
|
|
158
|
-
|
|
159
|
+
ce,
|
|
159
160
|
{
|
|
160
161
|
ref: g,
|
|
161
162
|
$width: m,
|
|
162
163
|
tabIndex: v ? -1 : 0,
|
|
163
|
-
onKeyDown:
|
|
164
|
+
onKeyDown: U,
|
|
164
165
|
$isLoading: $,
|
|
165
166
|
$isDisabled: v,
|
|
166
167
|
children: [
|
|
167
|
-
/* @__PURE__ */ r.jsxs(
|
|
168
|
-
/* @__PURE__ */ r.jsx(
|
|
169
|
-
/* @__PURE__ */ r.jsx(
|
|
168
|
+
/* @__PURE__ */ r.jsxs(le, { $width: m, onClick: Q, $isOpen: n, $border: X, children: [
|
|
169
|
+
/* @__PURE__ */ r.jsx(fe, { $width: m, color: i ? I.m700 : I.m500, size: "1.2rem", children: i ? o.find(({ value: e }) => i === e)?.label : P }),
|
|
170
|
+
/* @__PURE__ */ r.jsx(ue, { color: I.m500, size: 22, $isOpen: n })
|
|
170
171
|
] }),
|
|
171
|
-
/* @__PURE__ */ r.jsxs(
|
|
172
|
-
h && /* @__PURE__ */ r.jsxs(
|
|
173
|
-
/* @__PURE__ */ r.jsx(
|
|
172
|
+
/* @__PURE__ */ r.jsxs(ae, { $isOpen: n, $width: m, $height: O, $top: H === "top", children: [
|
|
173
|
+
h && /* @__PURE__ */ r.jsxs(pe, { onClick: L, children: [
|
|
174
|
+
/* @__PURE__ */ r.jsx(de, { size: 20, color: I.m600 }),
|
|
174
175
|
/* @__PURE__ */ r.jsx(
|
|
175
|
-
|
|
176
|
+
me,
|
|
176
177
|
{
|
|
177
178
|
ref: k,
|
|
178
179
|
value: b,
|
|
179
|
-
onChange:
|
|
180
|
-
placeholder:
|
|
180
|
+
onChange: _,
|
|
181
|
+
placeholder: B
|
|
181
182
|
}
|
|
182
183
|
)
|
|
183
184
|
] }),
|
|
184
|
-
/* @__PURE__ */ r.jsxs(
|
|
185
|
-
c.map(
|
|
186
|
-
l && /* @__PURE__ */ r.jsx(
|
|
185
|
+
/* @__PURE__ */ r.jsxs(he, { ref: w, children: [
|
|
186
|
+
c.map(Z),
|
|
187
|
+
l && /* @__PURE__ */ r.jsx(xe, { ref: R, children: a && /* @__PURE__ */ r.jsx(F, { size: "small", color: y }) })
|
|
187
188
|
] })
|
|
188
189
|
] }),
|
|
189
|
-
$ && /* @__PURE__ */ r.jsx(
|
|
190
|
+
$ && /* @__PURE__ */ r.jsx(be, { children: /* @__PURE__ */ r.jsx(F, { size: "small", color: y }) })
|
|
190
191
|
]
|
|
191
192
|
}
|
|
192
193
|
);
|
|
193
194
|
};
|
|
194
195
|
export {
|
|
195
|
-
|
|
196
|
+
ye as default
|
|
196
197
|
};
|