@starasia/dropdown 1.0.1 → 1.0.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.
- package/dist/dropdown.es.js +85 -85
- package/dist/dropdown.umd.js +7 -7
- package/package.json +1 -1
package/dist/dropdown.es.js
CHANGED
|
@@ -14,16 +14,16 @@ function bn() {
|
|
|
14
14
|
if (zr)
|
|
15
15
|
return G;
|
|
16
16
|
zr = 1;
|
|
17
|
-
var u = or, p = Symbol.for("react.element"), x = Symbol.for("react.fragment"), k = Object.prototype.hasOwnProperty, f = u.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,
|
|
18
|
-
function P(R,
|
|
19
|
-
var _,
|
|
20
|
-
C !== void 0 && (E = "" + C),
|
|
21
|
-
for (_ in
|
|
22
|
-
k.call(
|
|
17
|
+
var u = or, p = Symbol.for("react.element"), x = Symbol.for("react.fragment"), k = Object.prototype.hasOwnProperty, f = u.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner, h = { key: !0, ref: !0, __self: !0, __source: !0 };
|
|
18
|
+
function P(R, g, C) {
|
|
19
|
+
var _, $ = {}, E = null, L = null;
|
|
20
|
+
C !== void 0 && (E = "" + C), g.key !== void 0 && (E = "" + g.key), g.ref !== void 0 && (L = g.ref);
|
|
21
|
+
for (_ in g)
|
|
22
|
+
k.call(g, _) && !h.hasOwnProperty(_) && ($[_] = g[_]);
|
|
23
23
|
if (R && R.defaultProps)
|
|
24
|
-
for (_ in
|
|
25
|
-
|
|
26
|
-
return { $$typeof: p, type: R, key: E, ref: L, props:
|
|
24
|
+
for (_ in g = R.defaultProps, g)
|
|
25
|
+
$[_] === void 0 && ($[_] = g[_]);
|
|
26
|
+
return { $$typeof: p, type: R, key: E, ref: L, props: $, _owner: f.current };
|
|
27
27
|
}
|
|
28
28
|
return G.Fragment = x, G.jsx = P, G.jsxs = P, G;
|
|
29
29
|
}
|
|
@@ -40,11 +40,11 @@ var X = {};
|
|
|
40
40
|
var Nr;
|
|
41
41
|
function xn() {
|
|
42
42
|
return Nr || (Nr = 1, process.env.NODE_ENV !== "production" && function() {
|
|
43
|
-
var u = or, p = Symbol.for("react.element"), x = Symbol.for("react.portal"), k = Symbol.for("react.fragment"), f = Symbol.for("react.strict_mode"),
|
|
43
|
+
var u = or, p = Symbol.for("react.element"), x = Symbol.for("react.portal"), k = Symbol.for("react.fragment"), f = Symbol.for("react.strict_mode"), h = Symbol.for("react.profiler"), P = Symbol.for("react.provider"), R = Symbol.for("react.context"), g = Symbol.for("react.forward_ref"), C = Symbol.for("react.suspense"), _ = Symbol.for("react.suspense_list"), $ = Symbol.for("react.memo"), E = Symbol.for("react.lazy"), L = Symbol.for("react.offscreen"), A = Symbol.iterator, m = "@@iterator";
|
|
44
44
|
function o(r) {
|
|
45
45
|
if (r === null || typeof r != "object")
|
|
46
46
|
return null;
|
|
47
|
-
var n =
|
|
47
|
+
var n = A && r[A] || r[m];
|
|
48
48
|
return typeof n == "function" ? n : null;
|
|
49
49
|
}
|
|
50
50
|
var v = u.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
|
|
@@ -52,10 +52,10 @@ function xn() {
|
|
|
52
52
|
{
|
|
53
53
|
for (var n = arguments.length, e = new Array(n > 1 ? n - 1 : 0), a = 1; a < n; a++)
|
|
54
54
|
e[a - 1] = arguments[a];
|
|
55
|
-
|
|
55
|
+
w("error", r, e);
|
|
56
56
|
}
|
|
57
57
|
}
|
|
58
|
-
function
|
|
58
|
+
function w(r, n, e) {
|
|
59
59
|
{
|
|
60
60
|
var a = v.ReactDebugCurrentFrame, d = a.getStackAddendum();
|
|
61
61
|
d !== "" && (n += "%s", e = e.concat([d]));
|
|
@@ -68,7 +68,7 @@ function xn() {
|
|
|
68
68
|
var j = !1, z = !1, B = !1, ir = !1, Q = !1, rr;
|
|
69
69
|
rr = Symbol.for("react.module.reference");
|
|
70
70
|
function Y(r) {
|
|
71
|
-
return !!(typeof r == "string" || typeof r == "function" || r === k || r ===
|
|
71
|
+
return !!(typeof r == "string" || typeof r == "function" || r === k || r === h || Q || r === f || r === C || r === _ || ir || r === L || j || z || B || typeof r == "object" && r !== null && (r.$$typeof === E || r.$$typeof === $ || r.$$typeof === P || r.$$typeof === R || r.$$typeof === g || // This needs to include all possible module reference object
|
|
72
72
|
// types supported by any Flight configuration anywhere since
|
|
73
73
|
// we don't know which Flight build this will end up being used
|
|
74
74
|
// with.
|
|
@@ -96,7 +96,7 @@ function xn() {
|
|
|
96
96
|
return "Fragment";
|
|
97
97
|
case x:
|
|
98
98
|
return "Portal";
|
|
99
|
-
case
|
|
99
|
+
case h:
|
|
100
100
|
return "Profiler";
|
|
101
101
|
case f:
|
|
102
102
|
return "StrictMode";
|
|
@@ -113,9 +113,9 @@ function xn() {
|
|
|
113
113
|
case P:
|
|
114
114
|
var e = r;
|
|
115
115
|
return O(e._context) + ".Provider";
|
|
116
|
-
case
|
|
116
|
+
case g:
|
|
117
117
|
return T(r, r.render, "ForwardRef");
|
|
118
|
-
case
|
|
118
|
+
case $:
|
|
119
119
|
var a = r.displayName || null;
|
|
120
120
|
return a !== null ? a : D(r.type) || "Memo";
|
|
121
121
|
case E: {
|
|
@@ -236,29 +236,29 @@ function xn() {
|
|
|
236
236
|
}), typeof Reflect == "object" && Reflect.construct) {
|
|
237
237
|
try {
|
|
238
238
|
Reflect.construct(s, []);
|
|
239
|
-
} catch (
|
|
240
|
-
a =
|
|
239
|
+
} catch (F) {
|
|
240
|
+
a = F;
|
|
241
241
|
}
|
|
242
242
|
Reflect.construct(r, [], s);
|
|
243
243
|
} else {
|
|
244
244
|
try {
|
|
245
245
|
s.call();
|
|
246
|
-
} catch (
|
|
247
|
-
a =
|
|
246
|
+
} catch (F) {
|
|
247
|
+
a = F;
|
|
248
248
|
}
|
|
249
249
|
r.call(s.prototype);
|
|
250
250
|
}
|
|
251
251
|
} else {
|
|
252
252
|
try {
|
|
253
253
|
throw Error();
|
|
254
|
-
} catch (
|
|
255
|
-
a =
|
|
254
|
+
} catch (F) {
|
|
255
|
+
a = F;
|
|
256
256
|
}
|
|
257
257
|
r();
|
|
258
258
|
}
|
|
259
|
-
} catch (
|
|
260
|
-
if (
|
|
261
|
-
for (var i =
|
|
259
|
+
} catch (F) {
|
|
260
|
+
if (F && a && typeof F.stack == "string") {
|
|
261
|
+
for (var i = F.stack.split(`
|
|
262
262
|
`), I = a.stack.split(`
|
|
263
263
|
`), b = i.length - 1, y = I.length - 1; b >= 1 && y >= 0 && i[b] !== I[y]; )
|
|
264
264
|
y--;
|
|
@@ -303,9 +303,9 @@ function xn() {
|
|
|
303
303
|
}
|
|
304
304
|
if (typeof r == "object")
|
|
305
305
|
switch (r.$$typeof) {
|
|
306
|
-
case
|
|
306
|
+
case g:
|
|
307
307
|
return qr(r.render);
|
|
308
|
-
case
|
|
308
|
+
case $:
|
|
309
309
|
return ar(r.type, n, e);
|
|
310
310
|
case E: {
|
|
311
311
|
var a = r, d = a._payload, c = a._init;
|
|
@@ -502,7 +502,7 @@ Check your code at ` + n + ":" + e + ".";
|
|
|
502
502
|
return "";
|
|
503
503
|
}
|
|
504
504
|
}
|
|
505
|
-
var
|
|
505
|
+
var Fr = {};
|
|
506
506
|
function dn(r) {
|
|
507
507
|
{
|
|
508
508
|
var n = Dr();
|
|
@@ -515,27 +515,27 @@ Check the top-level render call using <` + e + ">.");
|
|
|
515
515
|
return n;
|
|
516
516
|
}
|
|
517
517
|
}
|
|
518
|
-
function
|
|
518
|
+
function $r(r, n) {
|
|
519
519
|
{
|
|
520
520
|
if (!r._store || r._store.validated || r.key != null)
|
|
521
521
|
return;
|
|
522
522
|
r._store.validated = !0;
|
|
523
523
|
var e = dn(n);
|
|
524
|
-
if (
|
|
524
|
+
if (Fr[e])
|
|
525
525
|
return;
|
|
526
|
-
|
|
526
|
+
Fr[e] = !0;
|
|
527
527
|
var a = "";
|
|
528
528
|
r && r._owner && r._owner !== pr.current && (a = " It was passed a child from " + D(r._owner.type) + "."), U(r), l('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.', e, a), U(null);
|
|
529
529
|
}
|
|
530
530
|
}
|
|
531
|
-
function
|
|
531
|
+
function Ar(r, n) {
|
|
532
532
|
{
|
|
533
533
|
if (typeof r != "object")
|
|
534
534
|
return;
|
|
535
535
|
if (cr(r))
|
|
536
536
|
for (var e = 0; e < r.length; e++) {
|
|
537
537
|
var a = r[e];
|
|
538
|
-
vr(a) &&
|
|
538
|
+
vr(a) && $r(a, n);
|
|
539
539
|
}
|
|
540
540
|
else if (vr(r))
|
|
541
541
|
r._store && (r._store.validated = !0);
|
|
@@ -543,7 +543,7 @@ Check the top-level render call using <` + e + ">.");
|
|
|
543
543
|
var d = o(r);
|
|
544
544
|
if (typeof d == "function" && d !== r.entries)
|
|
545
545
|
for (var c = d.call(r), s; !(s = c.next()).done; )
|
|
546
|
-
vr(s.value) &&
|
|
546
|
+
vr(s.value) && $r(s.value, n);
|
|
547
547
|
}
|
|
548
548
|
}
|
|
549
549
|
}
|
|
@@ -555,9 +555,9 @@ Check the top-level render call using <` + e + ">.");
|
|
|
555
555
|
var e;
|
|
556
556
|
if (typeof n == "function")
|
|
557
557
|
e = n.propTypes;
|
|
558
|
-
else if (typeof n == "object" && (n.$$typeof ===
|
|
558
|
+
else if (typeof n == "object" && (n.$$typeof === g || // Note: Memo only checks outer props here.
|
|
559
559
|
// Inner props are checked in the reconciler.
|
|
560
|
-
n.$$typeof ===
|
|
560
|
+
n.$$typeof === $))
|
|
561
561
|
e = n.propTypes;
|
|
562
562
|
else
|
|
563
563
|
return;
|
|
@@ -605,19 +605,19 @@ Check the top-level render call using <` + e + ">.");
|
|
|
605
605
|
if (a)
|
|
606
606
|
if (cr(W)) {
|
|
607
607
|
for (var q = 0; q < W.length; q++)
|
|
608
|
-
|
|
608
|
+
Ar(W[q], r);
|
|
609
609
|
Object.freeze && Object.freeze(W);
|
|
610
610
|
} else
|
|
611
611
|
l("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");
|
|
612
612
|
else
|
|
613
|
-
|
|
613
|
+
Ar(W, r);
|
|
614
614
|
}
|
|
615
615
|
if (J.call(n, "key")) {
|
|
616
|
-
var V = D(r),
|
|
616
|
+
var V = D(r), F = Object.keys(n).filter(function(wn) {
|
|
617
617
|
return wn !== "key";
|
|
618
|
-
}), hr =
|
|
618
|
+
}), hr = F.length > 0 ? "{key: someKey, " + F.join(": ..., ") + ": ...}" : "{key: someKey}";
|
|
619
619
|
if (!Wr[V + hr]) {
|
|
620
|
-
var hn =
|
|
620
|
+
var hn = F.length > 0 ? "{" + F.join(": ..., ") + ": ...}" : "{}";
|
|
621
621
|
l(`A props object containing a "key" prop is being spread into JSX:
|
|
622
622
|
let props = %s;
|
|
623
623
|
<%s {...props} />
|
|
@@ -1057,8 +1057,8 @@ const mn = `@import url("https://fonts.googleapis.com/css2?family=Poppins:wght@3
|
|
|
1057
1057
|
}
|
|
1058
1058
|
`;
|
|
1059
1059
|
function yn(u) {
|
|
1060
|
-
const [p, x] = Z(u), k = H(null), f = (
|
|
1061
|
-
k.current && !k.current.contains(
|
|
1060
|
+
const [p, x] = Z(u), k = H(null), f = (h) => {
|
|
1061
|
+
k.current && !k.current.contains(h.target) && x(!1);
|
|
1062
1062
|
};
|
|
1063
1063
|
return N(() => (document.addEventListener("click", f, !0), () => {
|
|
1064
1064
|
document.removeEventListener("click", f, !0);
|
|
@@ -1142,41 +1142,41 @@ const kn = ({ ...u }) => /* @__PURE__ */ t.jsx(
|
|
|
1142
1142
|
isComponentVisible: x,
|
|
1143
1143
|
searchAble: k,
|
|
1144
1144
|
onSearch: f,
|
|
1145
|
-
value:
|
|
1145
|
+
value: h,
|
|
1146
1146
|
handleChangeValue: P,
|
|
1147
1147
|
multiSelect: R,
|
|
1148
|
-
searchValue:
|
|
1148
|
+
searchValue: g
|
|
1149
1149
|
}, C) => {
|
|
1150
|
-
const [_,
|
|
1150
|
+
const [_, $] = Z(0), [E, L] = Z(), A = H(null), m = H(null);
|
|
1151
1151
|
return N(() => {
|
|
1152
|
-
if (
|
|
1153
|
-
const o =
|
|
1154
|
-
|
|
1152
|
+
if (A.current) {
|
|
1153
|
+
const o = A.current.getBoundingClientRect();
|
|
1154
|
+
$(o.width);
|
|
1155
1155
|
}
|
|
1156
|
-
}, [
|
|
1157
|
-
p &&
|
|
1158
|
-
if (o.label.startsWith(
|
|
1156
|
+
}, [A, x]), N(() => {
|
|
1157
|
+
p && g ? p.forEach((o) => {
|
|
1158
|
+
if (o.label.startsWith(g || "")) {
|
|
1159
1159
|
L(o.value);
|
|
1160
1160
|
return;
|
|
1161
1161
|
}
|
|
1162
1162
|
}) : L(void 0);
|
|
1163
|
-
}, [
|
|
1163
|
+
}, [g, p]), N(() => {
|
|
1164
1164
|
const o = m.current || (C == null ? void 0 : C.current);
|
|
1165
1165
|
if (!o || !x)
|
|
1166
1166
|
return;
|
|
1167
|
-
const v = p.filter((
|
|
1168
|
-
if (
|
|
1169
|
-
if (
|
|
1167
|
+
const v = p.filter((w) => !w.disable), l = (w) => {
|
|
1168
|
+
if (w.key === "ArrowDown") {
|
|
1169
|
+
if (w.preventDefault(), !v.length)
|
|
1170
1170
|
return;
|
|
1171
1171
|
const j = v.findIndex((B) => B.value === E), z = j === -1 ? 0 : (j + 1) % v.length;
|
|
1172
1172
|
L(v[z].value);
|
|
1173
|
-
} else if (
|
|
1174
|
-
if (
|
|
1173
|
+
} else if (w.key === "ArrowUp") {
|
|
1174
|
+
if (w.preventDefault(), !v.length)
|
|
1175
1175
|
return;
|
|
1176
1176
|
const j = v.findIndex((B) => B.value === E), z = j <= 0 ? v.length - 1 : j - 1;
|
|
1177
1177
|
L(v[z].value);
|
|
1178
|
-
} else if (
|
|
1179
|
-
if (
|
|
1178
|
+
} else if (w.key === "Enter") {
|
|
1179
|
+
if (w.preventDefault(), !E)
|
|
1180
1180
|
return;
|
|
1181
1181
|
const j = p.find((z) => z.value === E);
|
|
1182
1182
|
j && !j.disable && P(j.label, j.value);
|
|
@@ -1186,7 +1186,7 @@ const kn = ({ ...u }) => /* @__PURE__ */ t.jsx(
|
|
|
1186
1186
|
}, [x, p, E, P, C]), N(() => {
|
|
1187
1187
|
if (!E)
|
|
1188
1188
|
return;
|
|
1189
|
-
const o =
|
|
1189
|
+
const o = A.current;
|
|
1190
1190
|
if (!o)
|
|
1191
1191
|
return;
|
|
1192
1192
|
const v = o.querySelector(`[data-value="${E}"]`);
|
|
@@ -1226,7 +1226,7 @@ const kn = ({ ...u }) => /* @__PURE__ */ t.jsx(
|
|
|
1226
1226
|
onChange: (o) => {
|
|
1227
1227
|
f && f(o.target.value);
|
|
1228
1228
|
},
|
|
1229
|
-
value:
|
|
1229
|
+
value: g,
|
|
1230
1230
|
autoFocus: !0,
|
|
1231
1231
|
style: { width: "100%" }
|
|
1232
1232
|
}
|
|
@@ -1238,9 +1238,9 @@ const kn = ({ ...u }) => /* @__PURE__ */ t.jsx(
|
|
|
1238
1238
|
"div",
|
|
1239
1239
|
{
|
|
1240
1240
|
className: `starasia-input-dropdwon-item-container ${R ? "multi" : ""}`,
|
|
1241
|
-
ref:
|
|
1241
|
+
ref: A,
|
|
1242
1242
|
children: p.map((o, v) => {
|
|
1243
|
-
const l = !!(
|
|
1243
|
+
const l = !!(h != null && h.find((w) => w.value === o.value));
|
|
1244
1244
|
return /* @__PURE__ */ t.jsxs(
|
|
1245
1245
|
"div",
|
|
1246
1246
|
{
|
|
@@ -1306,11 +1306,11 @@ const kn = ({ ...u }) => /* @__PURE__ */ t.jsx(
|
|
|
1306
1306
|
R && p();
|
|
1307
1307
|
}
|
|
1308
1308
|
};
|
|
1309
|
-
let
|
|
1310
|
-
for (;
|
|
1311
|
-
|
|
1312
|
-
return
|
|
1313
|
-
|
|
1309
|
+
let h = (P = x.current) == null ? void 0 : P.parentElement;
|
|
1310
|
+
for (; h && !k(h); )
|
|
1311
|
+
h = h.parentElement;
|
|
1312
|
+
return h && h.addEventListener("scroll", f), f(), () => {
|
|
1313
|
+
h && h.removeEventListener("scroll", f);
|
|
1314
1314
|
};
|
|
1315
1315
|
}, []);
|
|
1316
1316
|
const k = (f) => f && (f.scrollHeight > f.clientHeight || f.scrollWidth > f.clientWidth);
|
|
@@ -1328,17 +1328,17 @@ const Sn = ({
|
|
|
1328
1328
|
defaultValue: x,
|
|
1329
1329
|
size: k = "md",
|
|
1330
1330
|
multiSelect: f,
|
|
1331
|
-
searchAble:
|
|
1331
|
+
searchAble: h,
|
|
1332
1332
|
iconLeft: P,
|
|
1333
1333
|
placeholder: R,
|
|
1334
|
-
onSearch:
|
|
1334
|
+
onSearch: g,
|
|
1335
1335
|
error: C,
|
|
1336
1336
|
onBlur: _,
|
|
1337
|
-
onFocus:
|
|
1337
|
+
onFocus: $,
|
|
1338
1338
|
disable: E,
|
|
1339
1339
|
searchValue: L
|
|
1340
1340
|
}) => {
|
|
1341
|
-
const
|
|
1341
|
+
const A = H(), [m, o] = Z([]), [v, l] = Z(""), w = H(null), { isComponentVisible: j, ref: z, setIsComponentVisible: B } = yn(!1), ir = () => {
|
|
1342
1342
|
B((T) => !T);
|
|
1343
1343
|
}, Q = (T, O) => {
|
|
1344
1344
|
if (!f)
|
|
@@ -1354,7 +1354,7 @@ const Sn = ({
|
|
|
1354
1354
|
}
|
|
1355
1355
|
};
|
|
1356
1356
|
N(() => {
|
|
1357
|
-
JSON.stringify(
|
|
1357
|
+
JSON.stringify(A.current) === JSON.stringify(x) || (A.current = x, o(A.current || []));
|
|
1358
1358
|
}, [x]);
|
|
1359
1359
|
const rr = () => m.length ? f ? m == null ? void 0 : m.map((T, O) => /* @__PURE__ */ t.jsxs("div", { className: "starasia-input-dropdown-preview-item", children: [
|
|
1360
1360
|
/* @__PURE__ */ t.jsx("p", { style: { minWidth: "max-content" }, children: T == null ? void 0 : T.label }, O),
|
|
@@ -1365,9 +1365,9 @@ const Sn = ({
|
|
|
1365
1365
|
}
|
|
1366
1366
|
)
|
|
1367
1367
|
] })) : /* @__PURE__ */ t.jsx("p", { style: { minWidth: "max-content" }, children: m == null ? void 0 : m[0].label }) : /* @__PURE__ */ t.jsx("p", { className: "starasia-input-dropdown-placeholder", children: R }), Y = () => {
|
|
1368
|
-
if (z.current &&
|
|
1369
|
-
const T = window.innerHeight, O = z.current.getBoundingClientRect(), D =
|
|
1370
|
-
|
|
1368
|
+
if (z.current && w.current) {
|
|
1369
|
+
const T = window.innerHeight, O = z.current.getBoundingClientRect(), D = w.current.getBoundingClientRect(), S = O.bottom + D.height;
|
|
1370
|
+
w.current.style.left = `${O.left}px`, w.current.style.width = `${O.width}px`, S >= T - 10 ? (w.current.style.top = `${O.top - D.height - 5}px`, l("top")) : (w.current.style.top = `${O.top + O.height}px`, l("bottom"));
|
|
1371
1371
|
}
|
|
1372
1372
|
};
|
|
1373
1373
|
return N(() => (window.addEventListener("scroll", Y), window.addEventListener("resize", Y), () => {
|
|
@@ -1375,13 +1375,13 @@ const Sn = ({
|
|
|
1375
1375
|
}), []), N(() => {
|
|
1376
1376
|
Y();
|
|
1377
1377
|
}, [j]), N(() => {
|
|
1378
|
-
j &&
|
|
1378
|
+
j && w.current && !h && setTimeout(() => {
|
|
1379
1379
|
try {
|
|
1380
|
-
|
|
1380
|
+
w.current && w.current.focus();
|
|
1381
1381
|
} catch {
|
|
1382
1382
|
}
|
|
1383
1383
|
}, 0);
|
|
1384
|
-
}, [j]), /* @__PURE__ */ t.jsx(jn, { handleChangePosition: Y, children: /* @__PURE__ */ t.jsxs(
|
|
1384
|
+
}, [j, h]), /* @__PURE__ */ t.jsx(jn, { handleChangePosition: Y, children: /* @__PURE__ */ t.jsxs(
|
|
1385
1385
|
"div",
|
|
1386
1386
|
{
|
|
1387
1387
|
className: `starasia-input-dropdown-container ${E ? "disable" : ""} starasia-input-dropdown-size-${k} ${j ? "active" : ""} ${C ? "error" : ""}`,
|
|
@@ -1402,7 +1402,7 @@ const Sn = ({
|
|
|
1402
1402
|
className: "starasia-input-dropdown-container-preview-item",
|
|
1403
1403
|
tabIndex: 100,
|
|
1404
1404
|
onBlur: _,
|
|
1405
|
-
onFocus:
|
|
1405
|
+
onFocus: $,
|
|
1406
1406
|
children: rr()
|
|
1407
1407
|
}
|
|
1408
1408
|
),
|
|
@@ -1422,10 +1422,10 @@ const Sn = ({
|
|
|
1422
1422
|
handleChangeValue: Q,
|
|
1423
1423
|
isComponentVisible: j,
|
|
1424
1424
|
positionDropdown: v,
|
|
1425
|
-
searchAble: !!
|
|
1425
|
+
searchAble: !!h,
|
|
1426
1426
|
value: m,
|
|
1427
|
-
onSearch:
|
|
1428
|
-
ref:
|
|
1427
|
+
onSearch: g,
|
|
1428
|
+
ref: w,
|
|
1429
1429
|
multiSelect: f,
|
|
1430
1430
|
searchValue: L
|
|
1431
1431
|
}
|
package/dist/dropdown.umd.js
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*
|
|
7
7
|
* This source code is licensed under the MIT license found in the
|
|
8
8
|
* LICENSE file in the root directory of this source tree.
|
|
9
|
-
*/var hr;function Yr(){if(hr)return G;hr=1;var p=c,f=Symbol.for("react.element"),m=Symbol.for("react.fragment"),E=Object.prototype.hasOwnProperty,v=p.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,
|
|
9
|
+
*/var hr;function Yr(){if(hr)return G;hr=1;var p=c,f=Symbol.for("react.element"),m=Symbol.for("react.fragment"),E=Object.prototype.hasOwnProperty,v=p.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,w={key:!0,ref:!0,__self:!0,__source:!0};function I(j,b,S){var _,W={},R=null,N=null;S!==void 0&&(R=""+S),b.key!==void 0&&(R=""+b.key),b.ref!==void 0&&(N=b.ref);for(_ in b)E.call(b,_)&&!w.hasOwnProperty(_)&&(W[_]=b[_]);if(j&&j.defaultProps)for(_ in b=j.defaultProps,b)W[_]===void 0&&(W[_]=b[_]);return{$$typeof:f,type:j,key:R,ref:N,props:W,_owner:v.current}}return G.Fragment=m,G.jsx=I,G.jsxs=I,G}var X={};/**
|
|
10
10
|
* @license React
|
|
11
11
|
* react-jsx-runtime.development.js
|
|
12
12
|
*
|
|
@@ -14,17 +14,17 @@
|
|
|
14
14
|
*
|
|
15
15
|
* This source code is licensed under the MIT license found in the
|
|
16
16
|
* LICENSE file in the root directory of this source tree.
|
|
17
|
-
*/var wr;function Mr(){return wr||(wr=1,process.env.NODE_ENV!=="production"&&function(){var p=c,f=Symbol.for("react.element"),m=Symbol.for("react.portal"),E=Symbol.for("react.fragment"),v=Symbol.for("react.strict_mode"),
|
|
18
|
-
`+sr+r}}var dr=!1,nr;{var rn=typeof WeakMap=="function"?WeakMap:Map;nr=new rn}function Cr(r,n){if(!r||dr)return"";{var e=nr.get(r);if(e!==void 0)return e}var a;dr=!0;var d=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var u;u=ir.current,ir.current=null,$r();try{if(n){var s=function(){throw Error()};if(Object.defineProperty(s.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(s,[])}catch(
|
|
17
|
+
*/var wr;function Mr(){return wr||(wr=1,process.env.NODE_ENV!=="production"&&function(){var p=c,f=Symbol.for("react.element"),m=Symbol.for("react.portal"),E=Symbol.for("react.fragment"),v=Symbol.for("react.strict_mode"),w=Symbol.for("react.profiler"),I=Symbol.for("react.provider"),j=Symbol.for("react.context"),b=Symbol.for("react.forward_ref"),S=Symbol.for("react.suspense"),_=Symbol.for("react.suspense_list"),W=Symbol.for("react.memo"),R=Symbol.for("react.lazy"),N=Symbol.for("react.offscreen"),L=Symbol.iterator,y="@@iterator";function o(r){if(r===null||typeof r!="object")return null;var n=L&&r[L]||r[y];return typeof n=="function"?n:null}var h=p.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function l(r){{for(var n=arguments.length,e=new Array(n>1?n-1:0),a=1;a<n;a++)e[a-1]=arguments[a];g("error",r,e)}}function g(r,n,e){{var a=h.ReactDebugCurrentFrame,d=a.getStackAddendum();d!==""&&(n+="%s",e=e.concat([d]));var u=e.map(function(s){return String(s)});u.unshift("Warning: "+n),Function.prototype.apply.call(console[r],console,u)}}var C=!1,B=!1,Y=!1,or=!1,$=!1,q;q=Symbol.for("react.module.reference");function M(r){return!!(typeof r=="string"||typeof r=="function"||r===E||r===w||$||r===v||r===S||r===_||or||r===N||C||B||Y||typeof r=="object"&&r!==null&&(r.$$typeof===R||r.$$typeof===W||r.$$typeof===I||r.$$typeof===j||r.$$typeof===b||r.$$typeof===q||r.getModuleId!==void 0))}function T(r,n,e){var a=r.displayName;if(a)return a;var d=n.displayName||n.name||"";return d!==""?e+"("+d+")":e}function O(r){return r.displayName||"Context"}function F(r){if(r==null)return null;if(typeof r.tag=="number"&&l("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),typeof r=="function")return r.displayName||r.name||null;if(typeof r=="string")return r;switch(r){case E:return"Fragment";case m:return"Portal";case w:return"Profiler";case v:return"StrictMode";case S:return"Suspense";case _:return"SuspenseList"}if(typeof r=="object")switch(r.$$typeof){case j:var n=r;return O(n)+".Consumer";case I:var e=r;return O(e._context)+".Provider";case b:return T(r,r.render,"ForwardRef");case W:var a=r.displayName||null;return a!==null?a:F(r.type)||"Memo";case R:{var d=r,u=d._payload,s=d._init;try{return F(s(u))}catch{return null}}}return null}var P=Object.assign,U=0,xr,mr,yr,kr,Er,Rr,jr;function _r(){}_r.__reactDisabledLog=!0;function $r(){{if(U===0){xr=console.log,mr=console.info,yr=console.warn,kr=console.error,Er=console.group,Rr=console.groupCollapsed,jr=console.groupEnd;var r={configurable:!0,enumerable:!0,value:_r,writable:!0};Object.defineProperties(console,{info:r,log:r,warn:r,error:r,group:r,groupCollapsed:r,groupEnd:r})}U++}}function qr(){{if(U--,U===0){var r={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:P({},r,{value:xr}),info:P({},r,{value:mr}),warn:P({},r,{value:yr}),error:P({},r,{value:kr}),group:P({},r,{value:Er}),groupCollapsed:P({},r,{value:Rr}),groupEnd:P({},r,{value:jr})})}U<0&&l("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var ir=h.ReactCurrentDispatcher,sr;function rr(r,n,e){{if(sr===void 0)try{throw Error()}catch(d){var a=d.stack.trim().match(/\n( *(at )?)/);sr=a&&a[1]||""}return`
|
|
18
|
+
`+sr+r}}var dr=!1,nr;{var rn=typeof WeakMap=="function"?WeakMap:Map;nr=new rn}function Cr(r,n){if(!r||dr)return"";{var e=nr.get(r);if(e!==void 0)return e}var a;dr=!0;var d=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var u;u=ir.current,ir.current=null,$r();try{if(n){var s=function(){throw Error()};if(Object.defineProperty(s.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(s,[])}catch(A){a=A}Reflect.construct(r,[],s)}else{try{s.call()}catch(A){a=A}r.call(s.prototype)}}else{try{throw Error()}catch(A){a=A}r()}}catch(A){if(A&&a&&typeof A.stack=="string"){for(var i=A.stack.split(`
|
|
19
19
|
`),D=a.stack.split(`
|
|
20
20
|
`),x=i.length-1,k=D.length-1;x>=1&&k>=0&&i[x]!==D[k];)k--;for(;x>=1&&k>=0;x--,k--)if(i[x]!==D[k]){if(x!==1||k!==1)do if(x--,k--,k<0||i[x]!==D[k]){var z=`
|
|
21
|
-
`+i[x].replace(" at new "," at ");return r.displayName&&z.includes("<anonymous>")&&(z=z.replace("<anonymous>",r.displayName)),typeof r=="function"&&nr.set(r,z),z}while(x>=1&&k>=0);break}}}finally{dr=!1,ir.current=u,qr(),Error.prepareStackTrace=d}var K=r?r.displayName||r.name:"",H=K?rr(K):"";return typeof r=="function"&&nr.set(r,H),H}function nn(r,n,e){return Cr(r,!1)}function en(r){var n=r.prototype;return!!(n&&n.isReactComponent)}function er(r,n,e){if(r==null)return"";if(typeof r=="function")return Cr(r,en(r));if(typeof r=="string")return rr(r);switch(r){case S:return rr("Suspense");case _:return rr("SuspenseList")}if(typeof r=="object")switch(r.$$typeof){case
|
|
21
|
+
`+i[x].replace(" at new "," at ");return r.displayName&&z.includes("<anonymous>")&&(z=z.replace("<anonymous>",r.displayName)),typeof r=="function"&&nr.set(r,z),z}while(x>=1&&k>=0);break}}}finally{dr=!1,ir.current=u,qr(),Error.prepareStackTrace=d}var K=r?r.displayName||r.name:"",H=K?rr(K):"";return typeof r=="function"&&nr.set(r,H),H}function nn(r,n,e){return Cr(r,!1)}function en(r){var n=r.prototype;return!!(n&&n.isReactComponent)}function er(r,n,e){if(r==null)return"";if(typeof r=="function")return Cr(r,en(r));if(typeof r=="string")return rr(r);switch(r){case S:return rr("Suspense");case _:return rr("SuspenseList")}if(typeof r=="object")switch(r.$$typeof){case b:return nn(r.render);case W:return er(r.type,n,e);case R:{var a=r,d=a._payload,u=a._init;try{return er(u(d),n,e)}catch{}}}return""}var Z=Object.prototype.hasOwnProperty,Sr={},Tr=h.ReactDebugCurrentFrame;function ar(r){if(r){var n=r._owner,e=er(r.type,r._source,n?n.type:null);Tr.setExtraStackFrame(e)}else Tr.setExtraStackFrame(null)}function an(r,n,e,a,d){{var u=Function.call.bind(Z);for(var s in r)if(u(r,s)){var i=void 0;try{if(typeof r[s]!="function"){var D=Error((a||"React class")+": "+e+" type `"+s+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof r[s]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw D.name="Invariant Violation",D}i=r[s](n,s,a,e,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(x){i=x}i&&!(i instanceof Error)&&(ar(d),l("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).",a||"React class",e,s,typeof i),ar(null)),i instanceof Error&&!(i.message in Sr)&&(Sr[i.message]=!0,ar(d),l("Failed %s type: %s",e,i.message),ar(null))}}}var tn=Array.isArray;function cr(r){return tn(r)}function on(r){{var n=typeof Symbol=="function"&&Symbol.toStringTag,e=n&&r[Symbol.toStringTag]||r.constructor.name||"Object";return e}}function sn(r){try{return Or(r),!1}catch{return!0}}function Or(r){return""+r}function Pr(r){if(sn(r))return l("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",on(r)),Or(r)}var Q=h.ReactCurrentOwner,dn={key:!0,ref:!0,__self:!0,__source:!0},Ir,Dr,lr;lr={};function cn(r){if(Z.call(r,"ref")){var n=Object.getOwnPropertyDescriptor(r,"ref").get;if(n&&n.isReactWarning)return!1}return r.ref!==void 0}function ln(r){if(Z.call(r,"key")){var n=Object.getOwnPropertyDescriptor(r,"key").get;if(n&&n.isReactWarning)return!1}return r.key!==void 0}function un(r,n){if(typeof r.ref=="string"&&Q.current&&n&&Q.current.stateNode!==n){var e=F(Q.current.type);lr[e]||(l('Component "%s" contains the string ref "%s". Support for string refs will be removed in a future major release. This case cannot be automatically converted to an arrow function. We ask you to manually fix this case by using useRef() or createRef() instead. Learn more about using refs safely here: https://reactjs.org/link/strict-mode-string-ref',F(Q.current.type),r.ref),lr[e]=!0)}}function pn(r,n){{var e=function(){Ir||(Ir=!0,l("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",n))};e.isReactWarning=!0,Object.defineProperty(r,"key",{get:e,configurable:!0})}}function fn(r,n){{var e=function(){Dr||(Dr=!0,l("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",n))};e.isReactWarning=!0,Object.defineProperty(r,"ref",{get:e,configurable:!0})}}var vn=function(r,n,e,a,d,u,s){var i={$$typeof:f,type:r,key:n,ref:e,props:s,_owner:u};return i._store={},Object.defineProperty(i._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(i,"_self",{configurable:!1,enumerable:!1,writable:!1,value:a}),Object.defineProperty(i,"_source",{configurable:!1,enumerable:!1,writable:!1,value:d}),Object.freeze&&(Object.freeze(i.props),Object.freeze(i)),i};function hn(r,n,e,a,d){{var u,s={},i=null,D=null;e!==void 0&&(Pr(e),i=""+e),ln(n)&&(Pr(n.key),i=""+n.key),cn(n)&&(D=n.ref,un(n,d));for(u in n)Z.call(n,u)&&!dn.hasOwnProperty(u)&&(s[u]=n[u]);if(r&&r.defaultProps){var x=r.defaultProps;for(u in x)s[u]===void 0&&(s[u]=x[u])}if(i||D){var k=typeof r=="function"?r.displayName||r.name||"Unknown":r;i&&pn(s,k),D&&fn(s,k)}return vn(r,i,D,d,a,Q.current,s)}}var ur=h.ReactCurrentOwner,Fr=h.ReactDebugCurrentFrame;function J(r){if(r){var n=r._owner,e=er(r.type,r._source,n?n.type:null);Fr.setExtraStackFrame(e)}else Fr.setExtraStackFrame(null)}var pr;pr=!1;function fr(r){return typeof r=="object"&&r!==null&&r.$$typeof===f}function Ar(){{if(ur.current){var r=F(ur.current.type);if(r)return`
|
|
22
22
|
|
|
23
23
|
Check the render method of \``+r+"`."}return""}}function wn(r){{if(r!==void 0){var n=r.fileName.replace(/^.*[\\\/]/,""),e=r.lineNumber;return`
|
|
24
24
|
|
|
25
|
-
Check your code at `+n+":"+e+"."}return""}}var Wr={};function gn(r){{var n=
|
|
25
|
+
Check your code at `+n+":"+e+"."}return""}}var Wr={};function gn(r){{var n=Ar();if(!n){var e=typeof r=="string"?r:r.displayName||r.name;e&&(n=`
|
|
26
26
|
|
|
27
|
-
Check the top-level render call using <`+e+">.")}return n}}function Lr(r,n){{if(!r._store||r._store.validated||r.key!=null)return;r._store.validated=!0;var e=gn(n);if(Wr[e])return;Wr[e]=!0;var a="";r&&r._owner&&r._owner!==ur.current&&(a=" It was passed a child from "+
|
|
27
|
+
Check the top-level render call using <`+e+">.")}return n}}function Lr(r,n){{if(!r._store||r._store.validated||r.key!=null)return;r._store.validated=!0;var e=gn(n);if(Wr[e])return;Wr[e]=!0;var a="";r&&r._owner&&r._owner!==ur.current&&(a=" It was passed a child from "+F(r._owner.type)+"."),J(r),l('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',e,a),J(null)}}function zr(r,n){{if(typeof r!="object")return;if(cr(r))for(var e=0;e<r.length;e++){var a=r[e];fr(a)&&Lr(a,n)}else if(fr(r))r._store&&(r._store.validated=!0);else if(r){var d=o(r);if(typeof d=="function"&&d!==r.entries)for(var u=d.call(r),s;!(s=u.next()).done;)fr(s.value)&&Lr(s.value,n)}}}function bn(r){{var n=r.type;if(n==null||typeof n=="string")return;var e;if(typeof n=="function")e=n.propTypes;else if(typeof n=="object"&&(n.$$typeof===b||n.$$typeof===W))e=n.propTypes;else return;if(e){var a=F(n);an(e,r.props,"prop",a,r)}else if(n.PropTypes!==void 0&&!pr){pr=!0;var d=F(n);l("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",d||"Unknown")}typeof n.getDefaultProps=="function"&&!n.getDefaultProps.isReactClassApproved&&l("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function xn(r){{for(var n=Object.keys(r.props),e=0;e<n.length;e++){var a=n[e];if(a!=="children"&&a!=="key"){J(r),l("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",a),J(null);break}}r.ref!==null&&(J(r),l("Invalid attribute `ref` supplied to `React.Fragment`."),J(null))}}var Nr={};function Br(r,n,e,a,d,u){{var s=M(r);if(!s){var i="";(r===void 0||typeof r=="object"&&r!==null&&Object.keys(r).length===0)&&(i+=" You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");var D=wn(d);D?i+=D:i+=Ar();var x;r===null?x="null":cr(r)?x="array":r!==void 0&&r.$$typeof===f?(x="<"+(F(r.type)||"Unknown")+" />",i=" Did you accidentally export a JSX literal instead of a component?"):x=typeof r,l("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",x,i)}var k=hn(r,n,e,d,u);if(k==null)return k;if(s){var z=n.children;if(z!==void 0)if(a)if(cr(z)){for(var K=0;K<z.length;K++)zr(z[K],r);Object.freeze&&Object.freeze(z)}else l("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else zr(z,r)}if(Z.call(n,"key")){var H=F(r),A=Object.keys(n).filter(function(jn){return jn!=="key"}),vr=A.length>0?"{key: someKey, "+A.join(": ..., ")+": ...}":"{key: someKey}";if(!Nr[H+vr]){var Rn=A.length>0?"{"+A.join(": ..., ")+": ...}":"{}";l(`A props object containing a "key" prop is being spread into JSX:
|
|
28
28
|
let props = %s;
|
|
29
29
|
<%s {...props} />
|
|
30
30
|
React keys must be passed directly to JSX without using spread:
|
|
@@ -443,4 +443,4 @@ React keys must be passed directly to JSX without using spread:
|
|
|
443
443
|
height: 100%;
|
|
444
444
|
width: 100%;
|
|
445
445
|
}
|
|
446
|
-
`;function Ur(p){const[f,m]=c.useState(p),E=c.useRef(null),v=
|
|
446
|
+
`;function Ur(p){const[f,m]=c.useState(p),E=c.useRef(null),v=w=>{E.current&&!E.current.contains(w.target)&&m(!1)};return c.useEffect(()=>(document.addEventListener("click",v,!0),()=>{document.removeEventListener("click",v,!0)}),[]),{ref:E,isComponentVisible:f,setIsComponentVisible:m}}const Hr=({...p})=>t.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",...p,viewBox:"0 0 24 24",fill:"none",color:"#939E99",children:t.jsx("path",{d:"M4 9L12 17L20 9",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5})}),Jr=({...p})=>t.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",...p,viewBox:"0 0 20 20",fill:"none",children:[t.jsx("circle",{cx:"9.80547",cy:"9.8055",r:"7.49047",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round",strokeLinejoin:"round"}),t.jsx("path",{d:"M15.0153 15.4043L17.9519 18.3333",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round",strokeLinejoin:"round"})]}),Kr=({isChecked:p})=>t.jsxs("div",{className:"checkbox-wrapper-30",children:[t.jsxs("span",{className:"checkbox",children:[t.jsx("input",{type:"checkbox",style:{pointerEvents:"none"},checked:p}),t.jsx("svg",{children:t.jsx("use",{xlinkHref:"#checkbox-30",className:"checkbox"})})]}),t.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",style:{display:"none"},children:t.jsx("symbol",{id:"checkbox-30",viewBox:"0 0 22 22",children:t.jsx("path",{fill:"none",stroke:"currentColor",d:"M5.5,11.3L9,14.8L20.2,3.3l0,0c-0.5-1-1.5-1.8-2.7-1.8h-13c-1.7,0-3,1.3-3,3v13c0,1.7,1.3,3,3,3h13 c1.7,0,3-1.3,3-3v-13c0-0.4-0.1-0.8-0.3-1.2"})})})]}),Gr=c.forwardRef(({positionDropdown:p,dropdownLists:f,isComponentVisible:m,searchAble:E,onSearch:v,value:w,handleChangeValue:I,multiSelect:j,searchValue:b},S)=>{const[_,W]=c.useState(0),[R,N]=c.useState(),L=c.useRef(null),y=c.useRef(null);return c.useEffect(()=>{if(L.current){const o=L.current.getBoundingClientRect();W(o.width)}},[L,m]),c.useEffect(()=>{f&&b?f.forEach(o=>{if(o.label.startsWith(b||"")){N(o.value);return}}):N(void 0)},[b,f]),c.useEffect(()=>{const o=y.current||(S==null?void 0:S.current);if(!o||!m)return;const h=f.filter(g=>!g.disable),l=g=>{if(g.key==="ArrowDown"){if(g.preventDefault(),!h.length)return;const C=h.findIndex(Y=>Y.value===R),B=C===-1?0:(C+1)%h.length;N(h[B].value)}else if(g.key==="ArrowUp"){if(g.preventDefault(),!h.length)return;const C=h.findIndex(Y=>Y.value===R),B=C<=0?h.length-1:C-1;N(h[B].value)}else if(g.key==="Enter"){if(g.preventDefault(),!R)return;const C=f.find(B=>B.value===R);C&&!C.disable&&I(C.label,C.value)}};return o.addEventListener("keydown",l),()=>o.removeEventListener("keydown",l)},[m,f,R,I,S]),c.useEffect(()=>{if(!R)return;const o=L.current;if(!o)return;const h=o.querySelector(`[data-value="${R}"]`);h&&h.scrollIntoView&&h.scrollIntoView({block:"nearest"})},[R]),t.jsx(t.Fragment,{children:m?t.jsxs("div",{className:"starasia-input-dropdown-lists-container",onClick:o=>o.stopPropagation(),ref:o=>{if(y.current=o,typeof S=="function")S(o);else if(S)try{S.current=o}catch{}},tabIndex:0,children:[E?t.jsxs("div",{className:"starasia-input-dropdown-container-dropdown-search",style:{order:p=="bottom"?0:2,position:"sticky",top:0,bottom:0,zIndex:1},children:[t.jsx("div",{style:{display:"flex"},children:t.jsx(Jr,{strokeWidth:2,width:20})}),t.jsx("input",{onChange:o=>{v&&v(o.target.value)},value:b,autoFocus:!0,style:{width:"100%"}})]}):null,t.jsx("div",{className:`starasia-input-dropdwon-item-container ${j?"multi":""}`,ref:L,children:f.map((o,h)=>{const l=!!(w!=null&&w.find(g=>g.value===o.value));return t.jsxs("div",{"data-value":o.value,className:`starasia-input-dropdwon-item ${l?"active":" "} ${R===o.value?"highlight":""} ${o.disable?"starasia-input-dropdwon-item-disable":null}`,onClick:()=>I(o.label,o.value),children:[j?t.jsx("div",{style:{marginRight:"8px"},children:t.jsx(Kr,{isChecked:l})}):null,o.icon?t.jsx("div",{children:c.cloneElement(o.icon,{width:16})}):null,t.jsxs("div",{children:[t.jsx("p",{className:`starasia-input-dropdwon-item-text ${l?"active":null} ${o.disable?"starasia-input-dropdwon-item-disable":null}`,style:{textWrap:"nowrap",width:`${_-12}px`,overflow:"hidden",textOverflow:"ellipsis"},children:o.label}),o.description?t.jsx("p",{className:`starasia-input-dropdwon-item-text-description ${l?"active":null} ${o.disable?"starasia-input-dropdwon-item-disable":null}`,style:{textWrap:"nowrap",width:`${_-12}px`,overflow:"hidden",textOverflow:"ellipsis"},children:o.description}):null]})]},h)})})]}):null})}),Xr=({children:p,handleChangePosition:f})=>{const m=c.useRef(null);c.useEffect(()=>{var I;const v=()=>{if(m.current){let j=m.current.parentElement;for(;j&&!E(j);)j=j.parentElement;j&&f()}};let w=(I=m.current)==null?void 0:I.parentElement;for(;w&&!E(w);)w=w.parentElement;return w&&w.addEventListener("scroll",v),v(),()=>{w&&w.removeEventListener("scroll",v)}},[]);const E=v=>v&&(v.scrollHeight>v.clientHeight||v.scrollWidth>v.clientWidth);return t.jsx("div",{ref:m,children:p})},gr="starasia-input-dropdown-styles";(p=>{if(!document.getElementById(gr)){const f=document.createElement("style");f.id=gr,f.textContent=p,document.head.appendChild(f)}})(Vr);const Zr=({dropdownLists:p,onChange:f,defaultValue:m,size:E="md",multiSelect:v,searchAble:w,iconLeft:I,placeholder:j,onSearch:b,error:S,onBlur:_,onFocus:W,disable:R,searchValue:N})=>{const L=c.useRef(),[y,o]=c.useState([]),[h,l]=c.useState(""),g=c.useRef(null),{isComponentVisible:C,ref:B,setIsComponentVisible:Y}=Ur(!1),or=()=>{Y(T=>!T)},$=(T,O)=>{if(!v)o([{label:T,value:O}]),f([{label:T,value:O}]),Y(!1);else if(y==null?void 0:y.find(P=>P.value===O)){const P=[...y?y.filter(U=>U.value!==O):[]];o(P),f(P)}else{const P=[...y||[],{label:T,value:O}];o(P),f(P)}};c.useEffect(()=>{JSON.stringify(L.current)===JSON.stringify(m)||(L.current=m,o(L.current||[]))},[m]);const q=()=>y.length?v?y==null?void 0:y.map((T,O)=>t.jsxs("div",{className:"starasia-input-dropdown-preview-item",children:[t.jsx("p",{style:{minWidth:"max-content"},children:T==null?void 0:T.label},O),t.jsx(Qr,{onClick:()=>$(T.label,T.value)})]})):t.jsx("p",{style:{minWidth:"max-content"},children:y==null?void 0:y[0].label}):t.jsx("p",{className:"starasia-input-dropdown-placeholder",children:j}),M=()=>{if(B.current&&g.current){const T=window.innerHeight,O=B.current.getBoundingClientRect(),F=g.current.getBoundingClientRect(),P=O.bottom+F.height;g.current.style.left=`${O.left}px`,g.current.style.width=`${O.width}px`,P>=T-10?(g.current.style.top=`${O.top-F.height-5}px`,l("top")):(g.current.style.top=`${O.top+O.height}px`,l("bottom"))}};return c.useEffect(()=>(window.addEventListener("scroll",M),window.addEventListener("resize",M),()=>{window.removeEventListener("scroll",M),window.removeEventListener("resize",M)}),[]),c.useEffect(()=>{M()},[C]),c.useEffect(()=>{C&&g.current&&!w&&setTimeout(()=>{try{g.current&&g.current.focus()}catch{}},0)},[C,w]),t.jsx(Xr,{handleChangePosition:M,children:t.jsxs("div",{className:`starasia-input-dropdown-container ${R?"disable":""} starasia-input-dropdown-size-${E} ${C?"active":""} ${S?"error":""}`,ref:B,onClick:or,children:[t.jsxs("div",{className:"starasia-input-dropdown-preview-container",children:[I?t.jsx(t.Fragment,{children:c.cloneElement(I,{width:br(E),color:"#939E99",style:{color:"#939E99"}})}):null,t.jsx("div",{className:"starasia-input-dropdown-container-preview-item",tabIndex:100,onBlur:_,onFocus:W,children:q()}),t.jsx(Hr,{strokeWidth:2,width:br(E),style:{color:"#939E99"}})]}),t.jsx(Gr,{dropdownLists:p,handleChangeValue:$,isComponentVisible:C,positionDropdown:h,searchAble:!!w,value:y,onSearch:b,ref:g,multiSelect:v,searchValue:N})]})})},br=p=>{if(p==="sm")return 16;if(p==="md")return 16;if(p==="lg")return 20},Qr=p=>t.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"18",height:"18",viewBox:"0 0 18 18",fill:"none",...p,children:t.jsx("path",{d:"M12 6L6 12M6.00001 6L12 12",stroke:"currentColor","stroke-width":"1.5","stroke-linecap":"round","stroke-linejoin":"round"})});V.Dropdown=Zr,Object.defineProperty(V,Symbol.toStringTag,{value:"Module"})});
|