react-customizable-dropdown 1.0.2 → 1.0.3
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 +404 -196
- package/dist/dropdown.umd.js +5 -14
- package/package.json +1 -1
- package/dist/react-customizable-dropdown-bg.png +0 -0
package/dist/dropdown.es.js
CHANGED
|
@@ -1,248 +1,438 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { useState as
|
|
3
|
-
const
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
1
|
+
import { jsxs as h, jsx as r } from "react/jsx-runtime";
|
|
2
|
+
import { useState as M, useRef as E, useEffect as W, useMemo as U } from "react";
|
|
3
|
+
const t = {
|
|
4
|
+
container: {
|
|
5
|
+
position: "relative",
|
|
6
|
+
width: "100%"
|
|
7
|
+
},
|
|
8
|
+
containerDisabled: {
|
|
9
|
+
opacity: 0.6,
|
|
10
|
+
cursor: "not-allowed"
|
|
11
|
+
},
|
|
12
|
+
label: {
|
|
13
|
+
display: "block",
|
|
14
|
+
marginBottom: "4px",
|
|
15
|
+
fontSize: "14px",
|
|
16
|
+
fontWeight: 500,
|
|
17
|
+
color: "#374151",
|
|
18
|
+
cursor: "pointer"
|
|
19
|
+
},
|
|
20
|
+
trigger: {
|
|
21
|
+
display: "flex",
|
|
22
|
+
alignItems: "center",
|
|
23
|
+
justifyContent: "space-between",
|
|
24
|
+
width: "100%",
|
|
25
|
+
cursor: "pointer",
|
|
26
|
+
transition: "all 0.2s",
|
|
27
|
+
border: "1px solid #d1d5db",
|
|
28
|
+
borderRadius: "8px",
|
|
29
|
+
outline: "none"
|
|
30
|
+
},
|
|
31
|
+
triggerContent: {
|
|
32
|
+
display: "flex",
|
|
33
|
+
flexWrap: "wrap",
|
|
34
|
+
gap: "4px",
|
|
35
|
+
flex: 1,
|
|
36
|
+
overflow: "hidden"
|
|
37
|
+
},
|
|
38
|
+
searchInput: {
|
|
39
|
+
flex: 1,
|
|
40
|
+
outline: "none",
|
|
41
|
+
border: "none",
|
|
42
|
+
background: "transparent",
|
|
43
|
+
minWidth: "60px",
|
|
44
|
+
fontSize: "inherit",
|
|
45
|
+
color: "inherit",
|
|
46
|
+
padding: 0,
|
|
47
|
+
margin: 0
|
|
48
|
+
},
|
|
49
|
+
placeholder: {
|
|
50
|
+
color: "#9ca3af"
|
|
51
|
+
},
|
|
52
|
+
multiTag: {
|
|
53
|
+
display: "inline-flex",
|
|
54
|
+
alignItems: "center",
|
|
55
|
+
padding: "2px 8px",
|
|
56
|
+
borderRadius: "4px",
|
|
57
|
+
fontSize: "14px"
|
|
58
|
+
},
|
|
59
|
+
multiTagRemove: {
|
|
60
|
+
marginLeft: "4px",
|
|
61
|
+
cursor: "pointer",
|
|
62
|
+
fontWeight: "bold",
|
|
63
|
+
opacity: 0.8
|
|
64
|
+
},
|
|
65
|
+
actionsContainer: {
|
|
66
|
+
display: "flex",
|
|
67
|
+
alignItems: "center",
|
|
68
|
+
gap: "8px",
|
|
69
|
+
marginLeft: "8px"
|
|
70
|
+
},
|
|
71
|
+
spinner: {
|
|
72
|
+
width: "16px",
|
|
73
|
+
height: "16px",
|
|
74
|
+
border: "2px solid",
|
|
75
|
+
borderTopColor: "transparent",
|
|
76
|
+
borderRadius: "50%",
|
|
77
|
+
animation: "dropdown-spin 1s linear infinite"
|
|
78
|
+
},
|
|
79
|
+
clearButton: {
|
|
80
|
+
padding: "4px",
|
|
81
|
+
borderRadius: "50%",
|
|
82
|
+
transition: "background-color 0.2s",
|
|
83
|
+
cursor: "pointer",
|
|
84
|
+
display: "flex",
|
|
85
|
+
alignItems: "center",
|
|
86
|
+
justifyContent: "center"
|
|
87
|
+
},
|
|
88
|
+
icon: {
|
|
89
|
+
width: "12px",
|
|
90
|
+
height: "12px",
|
|
91
|
+
color: "#9ca3af"
|
|
92
|
+
},
|
|
93
|
+
chevronContainer: {
|
|
94
|
+
transition: "transform 0.2s"
|
|
95
|
+
},
|
|
96
|
+
chevronIcon: {
|
|
97
|
+
width: "16px",
|
|
98
|
+
height: "16px",
|
|
99
|
+
color: "#6b7280"
|
|
100
|
+
},
|
|
101
|
+
menu: {
|
|
102
|
+
position: "absolute",
|
|
103
|
+
zIndex: 50,
|
|
104
|
+
width: "100%",
|
|
105
|
+
marginTop: "4px",
|
|
106
|
+
border: "1px solid #d1d5db",
|
|
107
|
+
borderRadius: "8px",
|
|
108
|
+
boxShadow: "0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05)",
|
|
109
|
+
maxHeight: "240px",
|
|
110
|
+
overflow: "hidden",
|
|
111
|
+
display: "flex",
|
|
112
|
+
flexDirection: "column"
|
|
113
|
+
},
|
|
114
|
+
loadingContainer: {
|
|
115
|
+
padding: "32px 16px",
|
|
116
|
+
display: "flex",
|
|
117
|
+
justifyContent: "center",
|
|
118
|
+
alignItems: "center",
|
|
119
|
+
color: "#9ca3af"
|
|
120
|
+
},
|
|
121
|
+
loadingSpinner: {
|
|
122
|
+
width: "24px",
|
|
123
|
+
height: "24px",
|
|
124
|
+
border: "2px solid",
|
|
125
|
+
borderTopColor: "transparent",
|
|
126
|
+
borderRadius: "50%",
|
|
127
|
+
marginRight: "8px",
|
|
128
|
+
animation: "dropdown-spin 1s linear infinite"
|
|
129
|
+
},
|
|
130
|
+
optionsList: {
|
|
131
|
+
padding: "4px 0",
|
|
132
|
+
overflowY: "auto",
|
|
133
|
+
margin: 0,
|
|
134
|
+
listStyle: "none"
|
|
135
|
+
},
|
|
136
|
+
option: {
|
|
137
|
+
padding: "8px 16px",
|
|
138
|
+
cursor: "pointer",
|
|
139
|
+
transition: "background-color 0.15s",
|
|
140
|
+
display: "flex",
|
|
141
|
+
alignItems: "center",
|
|
142
|
+
justifyContent: "space-between"
|
|
143
|
+
},
|
|
144
|
+
optionDisabled: {
|
|
145
|
+
opacity: 0.5,
|
|
146
|
+
cursor: "not-allowed"
|
|
147
|
+
},
|
|
148
|
+
optionContent: {
|
|
149
|
+
display: "flex",
|
|
150
|
+
flexDirection: "column"
|
|
151
|
+
},
|
|
152
|
+
sublabel: {
|
|
153
|
+
fontSize: "12px",
|
|
154
|
+
color: "#6b7280",
|
|
155
|
+
marginTop: "2px"
|
|
156
|
+
},
|
|
157
|
+
checkIcon: {
|
|
158
|
+
width: "16px",
|
|
159
|
+
height: "16px",
|
|
160
|
+
flexShrink: 0
|
|
161
|
+
},
|
|
162
|
+
noOptions: {
|
|
163
|
+
padding: "8px 16px",
|
|
164
|
+
color: "#6b7280",
|
|
165
|
+
textAlign: "center",
|
|
166
|
+
fontSize: "14px"
|
|
167
|
+
}
|
|
168
|
+
}, re = () => {
|
|
169
|
+
if (typeof document > "u") return;
|
|
170
|
+
const f = "dropdown-keyframes";
|
|
171
|
+
if (document.getElementById(f)) return;
|
|
172
|
+
const n = document.createElement("style");
|
|
173
|
+
n.id = f, n.textContent = `
|
|
174
|
+
@keyframes dropdown-spin {
|
|
175
|
+
to { transform: rotate(360deg); }
|
|
176
|
+
}
|
|
177
|
+
`, document.head.appendChild(n);
|
|
178
|
+
}, se = ({
|
|
179
|
+
options: f,
|
|
180
|
+
value: n,
|
|
181
|
+
onChange: C,
|
|
182
|
+
placeholder: H = "Select...",
|
|
183
|
+
multiSelect: B = !1,
|
|
184
|
+
searchable: u = !1,
|
|
185
|
+
disabled: b = !1,
|
|
186
|
+
loading: L = !1,
|
|
187
|
+
className: Y = "",
|
|
188
|
+
style: q = {},
|
|
189
|
+
theme: I,
|
|
190
|
+
label: z,
|
|
16
191
|
labelClassName: G = "",
|
|
17
|
-
optionClassName:
|
|
18
|
-
selectedOptionClassName:
|
|
192
|
+
optionClassName: D = "",
|
|
193
|
+
selectedOptionClassName: v = "",
|
|
19
194
|
menuClassName: J = "",
|
|
20
|
-
triggerClassName:
|
|
21
|
-
triggerStyle:
|
|
22
|
-
arrowIcon:
|
|
23
|
-
arrowIconClassName:
|
|
24
|
-
labelField:
|
|
25
|
-
valueField:
|
|
26
|
-
sublabelField:
|
|
27
|
-
sublabelClassName:
|
|
195
|
+
triggerClassName: Q = "",
|
|
196
|
+
triggerStyle: X = {},
|
|
197
|
+
arrowIcon: V,
|
|
198
|
+
arrowIconClassName: Z = "",
|
|
199
|
+
labelField: m = "label",
|
|
200
|
+
valueField: c = "value",
|
|
201
|
+
sublabelField: P = "sublabel",
|
|
202
|
+
sublabelClassName: _ = ""
|
|
28
203
|
}) => {
|
|
29
|
-
const [
|
|
204
|
+
const [i, g] = M(!1), [w, R] = M(""), [x, y] = M(-1), A = E(null), j = E(null), S = E(null);
|
|
205
|
+
W(() => {
|
|
206
|
+
re();
|
|
207
|
+
}, []);
|
|
208
|
+
const s = U(() => {
|
|
30
209
|
const e = {
|
|
31
210
|
primaryColor: "#3b82f6",
|
|
32
|
-
// blue-500
|
|
33
211
|
backgroundColor: "#ffffff",
|
|
34
212
|
hoverColor: "#eff6ff",
|
|
35
|
-
// blue-50
|
|
36
213
|
textColor: "#1f2937",
|
|
37
|
-
// gray-800
|
|
38
214
|
padding: "0.5rem 1rem",
|
|
39
215
|
menuBackgroundColor: "#ffffff",
|
|
40
216
|
optionTextColor: "#1f2937",
|
|
41
217
|
selectedOptionTextColor: "#3b82f6",
|
|
42
218
|
selectedOptionBackgroundColor: "#eff6ff",
|
|
43
219
|
multiSelectSelectedOptionTextColor: "#1e40af",
|
|
44
|
-
// blue-800
|
|
45
220
|
multiSelectSelectedOptionBackgroundColor: "#dbeafe",
|
|
46
|
-
// blue-100
|
|
47
221
|
focusBorderColor: "#3b82f6"
|
|
48
|
-
|
|
49
|
-
}, t = T || {}, o = t.selectedOptionTextColor ?? t.primaryColor ?? e.selectedOptionTextColor, i = t.selectedOptionBackgroundColor ?? t.hoverColor ?? e.selectedOptionBackgroundColor, c = t.multiSelectSelectedOptionTextColor ?? "#1e40af", u = t.multiSelectSelectedOptionBackgroundColor ?? "#dbeafe", s = {
|
|
50
|
-
...e,
|
|
51
|
-
...t,
|
|
52
|
-
menuBackgroundColor: t.menuBackgroundColor ?? t.backgroundColor ?? e.menuBackgroundColor,
|
|
53
|
-
optionTextColor: t.optionTextColor ?? t.textColor ?? e.optionTextColor,
|
|
54
|
-
selectedOptionTextColor: o,
|
|
55
|
-
selectedOptionBackgroundColor: i,
|
|
56
|
-
multiSelectSelectedOptionTextColor: c,
|
|
57
|
-
multiSelectSelectedOptionBackgroundColor: u,
|
|
58
|
-
focusBorderColor: t.focusBorderColor ?? t.primaryColor ?? e.focusBorderColor
|
|
59
|
-
};
|
|
222
|
+
}, o = I || {}, l = o.selectedOptionTextColor ?? o.primaryColor ?? e.selectedOptionTextColor, p = o.selectedOptionBackgroundColor ?? o.hoverColor ?? e.selectedOptionBackgroundColor, d = o.multiSelectSelectedOptionTextColor ?? "#1e40af", a = o.multiSelectSelectedOptionBackgroundColor ?? "#dbeafe";
|
|
60
223
|
return {
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
"--dd-multi-selected-text": s.multiSelectSelectedOptionTextColor,
|
|
71
|
-
"--dd-multi-selected-bg": s.multiSelectSelectedOptionBackgroundColor,
|
|
72
|
-
"--dd-focus-border": s.focusBorderColor,
|
|
73
|
-
...H
|
|
224
|
+
...e,
|
|
225
|
+
...o,
|
|
226
|
+
menuBackgroundColor: o.menuBackgroundColor ?? o.backgroundColor ?? e.menuBackgroundColor,
|
|
227
|
+
optionTextColor: o.optionTextColor ?? o.textColor ?? e.optionTextColor,
|
|
228
|
+
selectedOptionTextColor: l,
|
|
229
|
+
selectedOptionBackgroundColor: p,
|
|
230
|
+
multiSelectSelectedOptionTextColor: d,
|
|
231
|
+
multiSelectSelectedOptionBackgroundColor: a,
|
|
232
|
+
focusBorderColor: o.focusBorderColor ?? o.primaryColor ?? e.focusBorderColor
|
|
74
233
|
};
|
|
75
|
-
}, [
|
|
76
|
-
|
|
77
|
-
const e = (
|
|
78
|
-
|
|
234
|
+
}, [I]);
|
|
235
|
+
W(() => {
|
|
236
|
+
const e = (o) => {
|
|
237
|
+
A.current && !A.current.contains(o.target) && g(!1);
|
|
79
238
|
};
|
|
80
239
|
return document.addEventListener("mousedown", e), () => {
|
|
81
240
|
document.removeEventListener("mousedown", e);
|
|
82
241
|
};
|
|
83
242
|
}, []);
|
|
84
|
-
const
|
|
85
|
-
|
|
86
|
-
|
|
243
|
+
const K = () => {
|
|
244
|
+
b || (g(!i), i || (y(-1), setTimeout(() => {
|
|
245
|
+
u && S.current && S.current.focus();
|
|
87
246
|
}, 0)));
|
|
88
|
-
},
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
}, 0)) :
|
|
92
|
-
},
|
|
93
|
-
if (
|
|
94
|
-
if (Array.isArray(
|
|
95
|
-
return
|
|
96
|
-
const e =
|
|
247
|
+
}, F = () => {
|
|
248
|
+
u ? i || (g(!0), y(-1), setTimeout(() => {
|
|
249
|
+
S.current && S.current.focus();
|
|
250
|
+
}, 0)) : K();
|
|
251
|
+
}, k = (() => {
|
|
252
|
+
if (n == null) return [];
|
|
253
|
+
if (Array.isArray(n))
|
|
254
|
+
return f.filter((o) => n.includes(o[c]));
|
|
255
|
+
const e = f.find((o) => o[c] === n);
|
|
97
256
|
return e ? [e] : [];
|
|
98
|
-
})(),
|
|
99
|
-
if (
|
|
100
|
-
let
|
|
101
|
-
if (
|
|
102
|
-
const
|
|
103
|
-
|
|
104
|
-
(
|
|
257
|
+
})(), N = (e, o) => {
|
|
258
|
+
if (o?.stopPropagation(), e.disabled) return;
|
|
259
|
+
let l, p;
|
|
260
|
+
if (B) {
|
|
261
|
+
const d = Array.isArray(n) ? n : n ? [n] : [];
|
|
262
|
+
d.includes(e[c]) ? l = d.filter((O) => O !== e[c]) : l = [...d, e[c]], p = f.filter(
|
|
263
|
+
(O) => l.includes(O[c])
|
|
105
264
|
);
|
|
106
265
|
} else
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
},
|
|
110
|
-
if (
|
|
111
|
-
const
|
|
112
|
-
(
|
|
266
|
+
l = e[c], p = e, g(!1), R("");
|
|
267
|
+
C && C(l, p);
|
|
268
|
+
}, ee = (e, o) => {
|
|
269
|
+
if (o.stopPropagation(), !C) return;
|
|
270
|
+
const p = (Array.isArray(n) ? n : n ? [n] : []).filter((a) => a !== e), d = f.filter(
|
|
271
|
+
(a) => p.includes(a[c])
|
|
113
272
|
);
|
|
114
|
-
|
|
115
|
-
},
|
|
116
|
-
if (e.stopPropagation(),
|
|
117
|
-
|
|
273
|
+
C(p, d);
|
|
274
|
+
}, oe = (e) => {
|
|
275
|
+
if (e.stopPropagation(), i && u) {
|
|
276
|
+
R(""), g(!1);
|
|
118
277
|
return;
|
|
119
278
|
}
|
|
120
|
-
|
|
121
|
-
},
|
|
122
|
-
() =>
|
|
123
|
-
[
|
|
124
|
-
),
|
|
125
|
-
if (!
|
|
279
|
+
C && C(B ? [] : "", B ? [] : []);
|
|
280
|
+
}, T = U(
|
|
281
|
+
() => f.filter((e) => !u || !w ? !0 : (typeof e[m] == "string" ? e[m] : String(e[c])).toLowerCase().includes(w.toLowerCase())),
|
|
282
|
+
[f, u, w, m, c]
|
|
283
|
+
), $ = (e) => {
|
|
284
|
+
if (!b)
|
|
126
285
|
switch (e.key) {
|
|
127
286
|
case "Enter":
|
|
128
|
-
e.preventDefault(),
|
|
287
|
+
e.preventDefault(), i ? x >= 0 && x < T.length && N(T[x]) : g(!0);
|
|
129
288
|
break;
|
|
130
289
|
case "Escape":
|
|
131
|
-
|
|
290
|
+
i && (e.preventDefault(), g(!1));
|
|
132
291
|
break;
|
|
133
292
|
case "ArrowDown":
|
|
134
|
-
e.preventDefault(),
|
|
135
|
-
(
|
|
136
|
-
) : (
|
|
293
|
+
e.preventDefault(), i ? y(
|
|
294
|
+
(o) => o < T.length - 1 ? o + 1 : o
|
|
295
|
+
) : (g(!0), y(0));
|
|
137
296
|
break;
|
|
138
297
|
case "ArrowUp":
|
|
139
|
-
e.preventDefault(),
|
|
298
|
+
e.preventDefault(), i && y((o) => o > 0 ? o - 1 : o);
|
|
140
299
|
break;
|
|
141
300
|
}
|
|
142
301
|
};
|
|
143
|
-
|
|
144
|
-
if (
|
|
145
|
-
const e =
|
|
146
|
-
if (
|
|
147
|
-
const
|
|
148
|
-
|
|
302
|
+
W(() => {
|
|
303
|
+
if (i && j.current && x >= 0) {
|
|
304
|
+
const e = j.current, o = e.children[x];
|
|
305
|
+
if (o) {
|
|
306
|
+
const l = e.scrollTop, p = l + e.clientHeight, d = o.offsetTop, a = d + o.clientHeight;
|
|
307
|
+
d < l ? e.scrollTop = d : a > p && (e.scrollTop = a - e.clientHeight);
|
|
149
308
|
}
|
|
150
309
|
}
|
|
151
|
-
}, [
|
|
152
|
-
const te = (e) => Array.isArray(
|
|
153
|
-
return /* @__PURE__ */
|
|
310
|
+
}, [x, i]);
|
|
311
|
+
const te = (e) => Array.isArray(n) ? n.includes(e) : n === e;
|
|
312
|
+
return /* @__PURE__ */ h(
|
|
154
313
|
"div",
|
|
155
314
|
{
|
|
156
|
-
ref:
|
|
157
|
-
className:
|
|
158
|
-
style:
|
|
159
|
-
|
|
315
|
+
ref: A,
|
|
316
|
+
className: Y,
|
|
317
|
+
style: {
|
|
318
|
+
...t.container,
|
|
319
|
+
...b ? t.containerDisabled : {},
|
|
320
|
+
...q
|
|
321
|
+
},
|
|
322
|
+
onKeyDown: $,
|
|
160
323
|
children: [
|
|
161
|
-
|
|
324
|
+
z && /* @__PURE__ */ r(
|
|
162
325
|
"label",
|
|
163
326
|
{
|
|
164
|
-
className:
|
|
165
|
-
onClick:
|
|
166
|
-
style:
|
|
167
|
-
|
|
327
|
+
className: G,
|
|
328
|
+
onClick: K,
|
|
329
|
+
style: {
|
|
330
|
+
...t.label,
|
|
331
|
+
...I?.textColor ? { color: I.textColor } : {}
|
|
332
|
+
},
|
|
333
|
+
children: z
|
|
168
334
|
}
|
|
169
335
|
),
|
|
170
|
-
/* @__PURE__ */
|
|
336
|
+
/* @__PURE__ */ h(
|
|
171
337
|
"div",
|
|
172
338
|
{
|
|
173
|
-
onClick:
|
|
174
|
-
className:
|
|
175
|
-
flex items-center justify-between
|
|
176
|
-
w-full
|
|
177
|
-
bg-[var(--dd-bg)]
|
|
178
|
-
cursor-pointer
|
|
179
|
-
transition-all duration-200
|
|
180
|
-
text-[var(--dd-text)]
|
|
181
|
-
${B || "border rounded-lg"}
|
|
182
|
-
`,
|
|
339
|
+
onClick: F,
|
|
340
|
+
className: Q,
|
|
183
341
|
style: {
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
342
|
+
...t.trigger,
|
|
343
|
+
backgroundColor: s.backgroundColor,
|
|
344
|
+
color: s.textColor,
|
|
345
|
+
padding: s.padding,
|
|
346
|
+
minHeight: "42px",
|
|
347
|
+
borderColor: i ? s.focusBorderColor : "#d1d5db",
|
|
348
|
+
...X
|
|
189
349
|
},
|
|
190
350
|
role: "button",
|
|
191
|
-
tabIndex:
|
|
351
|
+
tabIndex: u ? -1 : 0,
|
|
192
352
|
"aria-haspopup": "listbox",
|
|
193
|
-
"aria-expanded":
|
|
353
|
+
"aria-expanded": i,
|
|
194
354
|
children: [
|
|
195
|
-
/* @__PURE__ */ r("div", {
|
|
355
|
+
/* @__PURE__ */ r("div", { style: t.triggerContent, children: u && (i || k.length === 0) ? /* @__PURE__ */ r(
|
|
196
356
|
"input",
|
|
197
357
|
{
|
|
198
|
-
ref:
|
|
358
|
+
ref: S,
|
|
199
359
|
type: "text",
|
|
200
|
-
value:
|
|
201
|
-
onChange: (e) =>
|
|
202
|
-
onKeyDown:
|
|
203
|
-
placeholder:
|
|
204
|
-
|
|
360
|
+
value: w,
|
|
361
|
+
onChange: (e) => R(e.target.value),
|
|
362
|
+
onKeyDown: $,
|
|
363
|
+
placeholder: k.length === 0 ? H : "Search...",
|
|
364
|
+
style: {
|
|
365
|
+
...t.searchInput,
|
|
366
|
+
color: s.textColor
|
|
367
|
+
},
|
|
205
368
|
onClick: (e) => {
|
|
206
|
-
e.stopPropagation(),
|
|
369
|
+
e.stopPropagation(), i || g(!0);
|
|
207
370
|
},
|
|
208
|
-
disabled:
|
|
371
|
+
disabled: b
|
|
209
372
|
}
|
|
210
|
-
) :
|
|
373
|
+
) : k.length === 0 ? /* @__PURE__ */ r("span", { style: t.placeholder, children: H }) : B ? k.map((e) => /* @__PURE__ */ h(
|
|
211
374
|
"span",
|
|
212
375
|
{
|
|
213
|
-
className: "inline-flex items-center px-2 py-0.5 rounded text-sm animate-fadeIn",
|
|
214
376
|
style: {
|
|
215
|
-
|
|
216
|
-
|
|
377
|
+
...t.multiTag,
|
|
378
|
+
backgroundColor: s.multiSelectSelectedOptionBackgroundColor,
|
|
379
|
+
color: s.multiSelectSelectedOptionTextColor
|
|
217
380
|
},
|
|
218
|
-
onClick: (
|
|
381
|
+
onClick: (o) => o.stopPropagation(),
|
|
219
382
|
children: [
|
|
220
|
-
e[
|
|
383
|
+
e[m],
|
|
221
384
|
/* @__PURE__ */ r(
|
|
222
385
|
"span",
|
|
223
386
|
{
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
387
|
+
style: {
|
|
388
|
+
...t.multiTagRemove,
|
|
389
|
+
color: s.multiSelectSelectedOptionTextColor
|
|
390
|
+
},
|
|
391
|
+
onClick: (o) => ee(e[c], o),
|
|
227
392
|
children: "×"
|
|
228
393
|
}
|
|
229
394
|
)
|
|
230
395
|
]
|
|
231
396
|
},
|
|
232
|
-
e[
|
|
233
|
-
)) : /* @__PURE__ */ r(
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
397
|
+
e[c]
|
|
398
|
+
)) : /* @__PURE__ */ r(
|
|
399
|
+
"span",
|
|
400
|
+
{
|
|
401
|
+
style: {
|
|
402
|
+
overflow: "hidden",
|
|
403
|
+
textOverflow: "ellipsis",
|
|
404
|
+
whiteSpace: "nowrap"
|
|
405
|
+
},
|
|
406
|
+
children: k[0][m]
|
|
407
|
+
}
|
|
408
|
+
) }),
|
|
409
|
+
/* @__PURE__ */ h("div", { style: t.actionsContainer, children: [
|
|
410
|
+
L && /* @__PURE__ */ r(
|
|
411
|
+
"div",
|
|
412
|
+
{
|
|
413
|
+
style: {
|
|
414
|
+
...t.spinner,
|
|
415
|
+
borderColor: s.primaryColor,
|
|
416
|
+
borderTopColor: "transparent"
|
|
417
|
+
}
|
|
418
|
+
}
|
|
419
|
+
),
|
|
420
|
+
!L && !b && (k.length > 0 || i && u && w) && /* @__PURE__ */ r(
|
|
237
421
|
"div",
|
|
238
422
|
{
|
|
239
|
-
onClick:
|
|
240
|
-
|
|
241
|
-
title:
|
|
423
|
+
onClick: oe,
|
|
424
|
+
style: t.clearButton,
|
|
425
|
+
title: i && u ? "Clear search" : "Clear selection",
|
|
426
|
+
onMouseEnter: (e) => {
|
|
427
|
+
e.currentTarget.style.backgroundColor = "#f3f4f6";
|
|
428
|
+
},
|
|
429
|
+
onMouseLeave: (e) => {
|
|
430
|
+
e.currentTarget.style.backgroundColor = "transparent";
|
|
431
|
+
},
|
|
242
432
|
children: /* @__PURE__ */ r(
|
|
243
433
|
"svg",
|
|
244
434
|
{
|
|
245
|
-
|
|
435
|
+
style: t.icon,
|
|
246
436
|
fill: "none",
|
|
247
437
|
stroke: "currentColor",
|
|
248
438
|
viewBox: "0 0 24 24",
|
|
@@ -262,11 +452,15 @@ const le = ({
|
|
|
262
452
|
/* @__PURE__ */ r(
|
|
263
453
|
"div",
|
|
264
454
|
{
|
|
265
|
-
className:
|
|
266
|
-
|
|
455
|
+
className: Z,
|
|
456
|
+
style: {
|
|
457
|
+
...t.chevronContainer,
|
|
458
|
+
transform: i ? "rotate(180deg)" : "rotate(0deg)"
|
|
459
|
+
},
|
|
460
|
+
children: V || /* @__PURE__ */ r(
|
|
267
461
|
"svg",
|
|
268
462
|
{
|
|
269
|
-
|
|
463
|
+
style: t.chevronIcon,
|
|
270
464
|
fill: "none",
|
|
271
465
|
stroke: "currentColor",
|
|
272
466
|
viewBox: "0 0 24 24",
|
|
@@ -287,49 +481,63 @@ const le = ({
|
|
|
287
481
|
]
|
|
288
482
|
}
|
|
289
483
|
),
|
|
290
|
-
|
|
484
|
+
i && /* @__PURE__ */ r(
|
|
291
485
|
"div",
|
|
292
486
|
{
|
|
293
|
-
className:
|
|
294
|
-
|
|
295
|
-
|
|
487
|
+
className: J,
|
|
488
|
+
style: {
|
|
489
|
+
...t.menu,
|
|
490
|
+
backgroundColor: s.menuBackgroundColor
|
|
491
|
+
},
|
|
492
|
+
children: L ? /* @__PURE__ */ h("div", { style: t.loadingContainer, children: [
|
|
493
|
+
/* @__PURE__ */ r(
|
|
494
|
+
"div",
|
|
495
|
+
{
|
|
496
|
+
style: {
|
|
497
|
+
...t.loadingSpinner,
|
|
498
|
+
borderColor: s.primaryColor,
|
|
499
|
+
borderTopColor: "transparent"
|
|
500
|
+
}
|
|
501
|
+
}
|
|
502
|
+
),
|
|
296
503
|
"Loading options..."
|
|
297
|
-
] }) : /* @__PURE__ */ r("ul", { ref:
|
|
298
|
-
const
|
|
299
|
-
|
|
504
|
+
] }) : /* @__PURE__ */ r("ul", { ref: j, style: t.optionsList, role: "listbox", children: T.length === 0 ? /* @__PURE__ */ r("li", { style: t.noOptions, children: "No options found" }) : T.map((e, o) => {
|
|
505
|
+
const l = te(e[c]), p = o === x, d = e.disabled;
|
|
506
|
+
let a = "transparent";
|
|
507
|
+
return l ? a = s.selectedOptionBackgroundColor : p && (a = s.hoverColor), /* @__PURE__ */ h(
|
|
300
508
|
"li",
|
|
301
509
|
{
|
|
302
|
-
className:
|
|
303
|
-
px-4 py-2 cursor-pointer transition-colors duration-150 flex items-center justify-between
|
|
304
|
-
text-[var(--dd-option-text)]
|
|
305
|
-
${O}
|
|
306
|
-
${o ? L : ""}
|
|
307
|
-
`,
|
|
510
|
+
className: `${D} ${l ? v : ""}`,
|
|
308
511
|
style: {
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
512
|
+
...t.option,
|
|
513
|
+
...d ? t.optionDisabled : {},
|
|
514
|
+
backgroundColor: D || v ? void 0 : a,
|
|
515
|
+
color: D || v ? void 0 : l ? s.selectedOptionTextColor : s.optionTextColor,
|
|
516
|
+
fontWeight: l ? 500 : 400
|
|
312
517
|
},
|
|
313
|
-
onMouseEnter: () =>
|
|
518
|
+
onMouseEnter: () => y(o),
|
|
314
519
|
role: "option",
|
|
315
|
-
"aria-selected":
|
|
316
|
-
onClick: (
|
|
520
|
+
"aria-selected": l,
|
|
521
|
+
onClick: (O) => N(e, O),
|
|
317
522
|
children: [
|
|
318
|
-
/* @__PURE__ */
|
|
319
|
-
/* @__PURE__ */ r("span", { children: e[
|
|
320
|
-
e[
|
|
523
|
+
/* @__PURE__ */ h("div", { style: t.optionContent, children: [
|
|
524
|
+
/* @__PURE__ */ r("span", { children: e[m] }),
|
|
525
|
+
e[P] && /* @__PURE__ */ r(
|
|
321
526
|
"span",
|
|
322
527
|
{
|
|
323
|
-
className:
|
|
324
|
-
|
|
528
|
+
className: _,
|
|
529
|
+
style: t.sublabel,
|
|
530
|
+
children: e[P]
|
|
325
531
|
}
|
|
326
532
|
)
|
|
327
533
|
] }),
|
|
328
|
-
|
|
534
|
+
l && /* @__PURE__ */ r(
|
|
329
535
|
"svg",
|
|
330
536
|
{
|
|
331
|
-
|
|
332
|
-
|
|
537
|
+
style: {
|
|
538
|
+
...t.checkIcon,
|
|
539
|
+
color: s.selectedOptionTextColor
|
|
540
|
+
},
|
|
333
541
|
fill: "none",
|
|
334
542
|
stroke: "currentColor",
|
|
335
543
|
viewBox: "0 0 24 24",
|
|
@@ -346,7 +554,7 @@ const le = ({
|
|
|
346
554
|
)
|
|
347
555
|
]
|
|
348
556
|
},
|
|
349
|
-
e[
|
|
557
|
+
e[c]
|
|
350
558
|
);
|
|
351
559
|
}) })
|
|
352
560
|
}
|
|
@@ -356,5 +564,5 @@ const le = ({
|
|
|
356
564
|
);
|
|
357
565
|
};
|
|
358
566
|
export {
|
|
359
|
-
|
|
567
|
+
se as Dropdown
|
|
360
568
|
};
|
package/dist/dropdown.umd.js
CHANGED
|
@@ -1,14 +1,5 @@
|
|
|
1
|
-
(function(
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
transition-all duration-200
|
|
7
|
-
text-[var(--dd-text)]
|
|
8
|
-
${N||"border rounded-lg"}
|
|
9
|
-
`,style:{padding:N?void 0:"var(--dd-padding)",minHeight:N?void 0:"42px",borderColor:N?void 0:n?"var(--dd-focus-border)":"#d1d5db",outline:"none",...J},role:"button",tabIndex:f?-1:0,"aria-haspopup":"listbox","aria-expanded":n,children:[o.jsx("div",{className:"flex flex-wrap gap-1 flex-1 overflow-hidden",children:f&&(n||y.length===0)?o.jsx("input",{ref:S,type:"text",value:b,onChange:e=>D(e.target.value),onKeyDown:K,placeholder:y.length===0?$:"Search...",className:"flex-1 outline-none bg-transparent min-w-[60px]",onClick:e=>{e.stopPropagation(),n||u(!0)},disabled:k}):y.length===0?o.jsx("span",{className:"text-gray-400",children:$}):T?y.map(e=>o.jsxs("span",{className:"inline-flex items-center px-2 py-0.5 rounded text-sm animate-fadeIn",style:{backgroundColor:"var(--dd-multi-selected-bg)",color:"var(--dd-multi-selected-text)"},onClick:t=>t.stopPropagation(),children:[e[w],o.jsx("span",{className:"ml-1 cursor-pointer font-bold",style:{color:"currentColor",opacity:.8},onClick:t=>_(e[d],t),children:"×"})]},e[d])):o.jsx("span",{className:"truncate",children:y[0][w]})}),o.jsxs("div",{className:"flex items-center gap-2 ml-2",children:[L&&o.jsx("div",{className:"animate-spin h-4 w-4 border-2 border-[var(--dd-primary)] border-t-transparent rounded-full"}),!L&&!k&&(y.length>0||n&&f&&b)&&o.jsx("div",{onClick:F,className:"p-1 hover:bg-gray-100 rounded-full transition-colors z-10",title:n&&f?"Clear search":"Clear selection",children:o.jsx("svg",{className:"w-3 h-3 text-gray-400 hover:text-gray-600",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})}),o.jsx("div",{className:`transform transition-transform duration-200 ${n?"rotate-180":""} ${Q}`,children:P||o.jsx("svg",{className:"w-4 h-4 text-gray-500",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})})})]})]}),n&&o.jsx("div",{className:`absolute z-50 w-full mt-1 bg-[var(--dd-menu-bg)] border border-gray-300 rounded-lg shadow-lg max-h-60 overflow-hidden flex flex-col animate-enter ${G}`,children:L?o.jsxs("div",{className:"px-4 py-8 flex justify-center items-center text-gray-400",children:[o.jsx("div",{className:"animate-spin h-6 w-6 border-2 border-[var(--dd-primary)] border-t-transparent rounded-full mr-2"}),"Loading options..."]}):o.jsx("ul",{ref:M,className:"py-1 overflow-y-auto",role:"listbox",children:v.length===0?o.jsx("li",{className:"px-4 py-2 text-gray-500 text-center text-sm",children:"No options found"}):v.map((e,t)=>{const r=R(e[d]),i=t===g;return o.jsxs("li",{className:`
|
|
10
|
-
px-4 py-2 cursor-pointer transition-colors duration-150 flex items-center justify-between
|
|
11
|
-
text-[var(--dd-option-text)]
|
|
12
|
-
${B}
|
|
13
|
-
${r?j:""}
|
|
14
|
-
`,style:{backgroundColor:r&&j?void 0:i&&!B?"var(--dd-hover)":r?"var(--dd-selected-bg)":B?void 0:"transparent",color:r&&j||B?void 0:r?"var(--dd-selected-text)":"var(--dd-option-text)",fontWeight:r?500:400},onMouseEnter:()=>C(t),role:"option","aria-selected":r,onClick:c=>W(e,c),children:[o.jsxs("div",{className:"flex flex-col",children:[o.jsx("span",{children:e[w]}),e[V]&&o.jsx("span",{className:`text-xs text-gray-500 mt-0.5 ${X}`,children:e[V]})]}),r&&o.jsx("svg",{className:"w-4 h-4",style:{color:"var(--dd-selected-text)"},fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:3,d:"M5 13l4 4L19 7"})})]},e[d])})})})]})};x.Dropdown=q,Object.defineProperty(x,Symbol.toStringTag,{value:"Module"})}));
|
|
1
|
+
(function(h,t){typeof exports=="object"&&typeof module<"u"?t(exports,require("react/jsx-runtime"),require("react")):typeof define=="function"&&define.amd?define(["exports","react/jsx-runtime","react"],t):(h=typeof globalThis<"u"?globalThis:h||self,t(h.Dropdown={},h.jsxRuntime,h.React))})(this,(function(h,t,f){"use strict";const r={container:{position:"relative",width:"100%"},containerDisabled:{opacity:.6,cursor:"not-allowed"},label:{display:"block",marginBottom:"4px",fontSize:"14px",fontWeight:500,color:"#374151",cursor:"pointer"},trigger:{display:"flex",alignItems:"center",justifyContent:"space-between",width:"100%",cursor:"pointer",transition:"all 0.2s",border:"1px solid #d1d5db",borderRadius:"8px",outline:"none"},triggerContent:{display:"flex",flexWrap:"wrap",gap:"4px",flex:1,overflow:"hidden"},searchInput:{flex:1,outline:"none",border:"none",background:"transparent",minWidth:"60px",fontSize:"inherit",color:"inherit",padding:0,margin:0},placeholder:{color:"#9ca3af"},multiTag:{display:"inline-flex",alignItems:"center",padding:"2px 8px",borderRadius:"4px",fontSize:"14px"},multiTagRemove:{marginLeft:"4px",cursor:"pointer",fontWeight:"bold",opacity:.8},actionsContainer:{display:"flex",alignItems:"center",gap:"8px",marginLeft:"8px"},spinner:{width:"16px",height:"16px",border:"2px solid",borderTopColor:"transparent",borderRadius:"50%",animation:"dropdown-spin 1s linear infinite"},clearButton:{padding:"4px",borderRadius:"50%",transition:"background-color 0.2s",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center"},icon:{width:"12px",height:"12px",color:"#9ca3af"},chevronContainer:{transition:"transform 0.2s"},chevronIcon:{width:"16px",height:"16px",color:"#6b7280"},menu:{position:"absolute",zIndex:50,width:"100%",marginTop:"4px",border:"1px solid #d1d5db",borderRadius:"8px",boxShadow:"0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05)",maxHeight:"240px",overflow:"hidden",display:"flex",flexDirection:"column"},loadingContainer:{padding:"32px 16px",display:"flex",justifyContent:"center",alignItems:"center",color:"#9ca3af"},loadingSpinner:{width:"24px",height:"24px",border:"2px solid",borderTopColor:"transparent",borderRadius:"50%",marginRight:"8px",animation:"dropdown-spin 1s linear infinite"},optionsList:{padding:"4px 0",overflowY:"auto",margin:0,listStyle:"none"},option:{padding:"8px 16px",cursor:"pointer",transition:"background-color 0.15s",display:"flex",alignItems:"center",justifyContent:"space-between"},optionDisabled:{opacity:.5,cursor:"not-allowed"},optionContent:{display:"flex",flexDirection:"column"},sublabel:{fontSize:"12px",color:"#6b7280",marginTop:"2px"},checkIcon:{width:"16px",height:"16px",flexShrink:0},noOptions:{padding:"8px 16px",color:"#6b7280",textAlign:"center",fontSize:"14px"}},q=()=>{if(typeof document>"u")return;const u="dropdown-keyframes";if(document.getElementById(u))return;const n=document.createElement("style");n.id=u,n.textContent=`
|
|
2
|
+
@keyframes dropdown-spin {
|
|
3
|
+
to { transform: rotate(360deg); }
|
|
4
|
+
}
|
|
5
|
+
`,document.head.appendChild(n)},$=({options:u,value:n,onChange:y,placeholder:W="Select...",multiSelect:D=!1,searchable:g=!1,disabled:w=!1,loading:L=!1,className:U="",style:Y={},theme:I,label:H,labelClassName:G="",optionClassName:v="",selectedOptionClassName:j="",menuClassName:J="",triggerClassName:Q="",triggerStyle:X={},arrowIcon:z,arrowIconClassName:Z="",labelField:k="label",valueField:c="value",sublabelField:P="sublabel",sublabelClassName:_=""})=>{const[i,x]=f.useState(!1),[S,M]=f.useState(""),[C,b]=f.useState(-1),A=f.useRef(null),E=f.useRef(null),T=f.useRef(null);f.useEffect(()=>{q()},[]);const s=f.useMemo(()=>{const e={primaryColor:"#3b82f6",backgroundColor:"#ffffff",hoverColor:"#eff6ff",textColor:"#1f2937",padding:"0.5rem 1rem",menuBackgroundColor:"#ffffff",optionTextColor:"#1f2937",selectedOptionTextColor:"#3b82f6",selectedOptionBackgroundColor:"#eff6ff",multiSelectSelectedOptionTextColor:"#1e40af",multiSelectSelectedOptionBackgroundColor:"#dbeafe",focusBorderColor:"#3b82f6"},o=I||{},l=o.selectedOptionTextColor??o.primaryColor??e.selectedOptionTextColor,p=o.selectedOptionBackgroundColor??o.hoverColor??e.selectedOptionBackgroundColor,d=o.multiSelectSelectedOptionTextColor??"#1e40af",a=o.multiSelectSelectedOptionBackgroundColor??"#dbeafe";return{...e,...o,menuBackgroundColor:o.menuBackgroundColor??o.backgroundColor??e.menuBackgroundColor,optionTextColor:o.optionTextColor??o.textColor??e.optionTextColor,selectedOptionTextColor:l,selectedOptionBackgroundColor:p,multiSelectSelectedOptionTextColor:d,multiSelectSelectedOptionBackgroundColor:a,focusBorderColor:o.focusBorderColor??o.primaryColor??e.focusBorderColor}},[I]);f.useEffect(()=>{const e=o=>{A.current&&!A.current.contains(o.target)&&x(!1)};return document.addEventListener("mousedown",e),()=>{document.removeEventListener("mousedown",e)}},[]);const V=()=>{w||(x(!i),i||(b(-1),setTimeout(()=>{g&&T.current&&T.current.focus()},0)))},R=()=>{g?i||(x(!0),b(-1),setTimeout(()=>{T.current&&T.current.focus()},0)):V()},m=(()=>{if(n==null)return[];if(Array.isArray(n))return u.filter(o=>n.includes(o[c]));const e=u.find(o=>o[c]===n);return e?[e]:[]})(),K=(e,o)=>{if(o?.stopPropagation(),e.disabled)return;let l,p;if(D){const d=Array.isArray(n)?n:n?[n]:[];d.includes(e[c])?l=d.filter(B=>B!==e[c]):l=[...d,e[c]],p=u.filter(B=>l.includes(B[c]))}else l=e[c],p=e,x(!1),M("");y&&y(l,p)},F=(e,o)=>{if(o.stopPropagation(),!y)return;const p=(Array.isArray(n)?n:n?[n]:[]).filter(a=>a!==e),d=u.filter(a=>p.includes(a[c]));y(p,d)},ee=e=>{if(e.stopPropagation(),i&&g){M(""),x(!1);return}y&&y(D?[]:"",D?[]:[])},O=f.useMemo(()=>u.filter(e=>!g||!S?!0:(typeof e[k]=="string"?e[k]:String(e[c])).toLowerCase().includes(S.toLowerCase())),[u,g,S,k,c]),N=e=>{if(!w)switch(e.key){case"Enter":e.preventDefault(),i?C>=0&&C<O.length&&K(O[C]):x(!0);break;case"Escape":i&&(e.preventDefault(),x(!1));break;case"ArrowDown":e.preventDefault(),i?b(o=>o<O.length-1?o+1:o):(x(!0),b(0));break;case"ArrowUp":e.preventDefault(),i&&b(o=>o>0?o-1:o);break}};f.useEffect(()=>{if(i&&E.current&&C>=0){const e=E.current,o=e.children[C];if(o){const l=e.scrollTop,p=l+e.clientHeight,d=o.offsetTop,a=d+o.clientHeight;d<l?e.scrollTop=d:a>p&&(e.scrollTop=a-e.clientHeight)}}},[C,i]);const oe=e=>Array.isArray(n)?n.includes(e):n===e;return t.jsxs("div",{ref:A,className:U,style:{...r.container,...w?r.containerDisabled:{},...Y},onKeyDown:N,children:[H&&t.jsx("label",{className:G,onClick:V,style:{...r.label,...I?.textColor?{color:I.textColor}:{}},children:H}),t.jsxs("div",{onClick:R,className:Q,style:{...r.trigger,backgroundColor:s.backgroundColor,color:s.textColor,padding:s.padding,minHeight:"42px",borderColor:i?s.focusBorderColor:"#d1d5db",...X},role:"button",tabIndex:g?-1:0,"aria-haspopup":"listbox","aria-expanded":i,children:[t.jsx("div",{style:r.triggerContent,children:g&&(i||m.length===0)?t.jsx("input",{ref:T,type:"text",value:S,onChange:e=>M(e.target.value),onKeyDown:N,placeholder:m.length===0?W:"Search...",style:{...r.searchInput,color:s.textColor},onClick:e=>{e.stopPropagation(),i||x(!0)},disabled:w}):m.length===0?t.jsx("span",{style:r.placeholder,children:W}):D?m.map(e=>t.jsxs("span",{style:{...r.multiTag,backgroundColor:s.multiSelectSelectedOptionBackgroundColor,color:s.multiSelectSelectedOptionTextColor},onClick:o=>o.stopPropagation(),children:[e[k],t.jsx("span",{style:{...r.multiTagRemove,color:s.multiSelectSelectedOptionTextColor},onClick:o=>F(e[c],o),children:"×"})]},e[c])):t.jsx("span",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:m[0][k]})}),t.jsxs("div",{style:r.actionsContainer,children:[L&&t.jsx("div",{style:{...r.spinner,borderColor:s.primaryColor,borderTopColor:"transparent"}}),!L&&!w&&(m.length>0||i&&g&&S)&&t.jsx("div",{onClick:ee,style:r.clearButton,title:i&&g?"Clear search":"Clear selection",onMouseEnter:e=>{e.currentTarget.style.backgroundColor="#f3f4f6"},onMouseLeave:e=>{e.currentTarget.style.backgroundColor="transparent"},children:t.jsx("svg",{style:r.icon,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})}),t.jsx("div",{className:Z,style:{...r.chevronContainer,transform:i?"rotate(180deg)":"rotate(0deg)"},children:z||t.jsx("svg",{style:r.chevronIcon,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})})})]})]}),i&&t.jsx("div",{className:J,style:{...r.menu,backgroundColor:s.menuBackgroundColor},children:L?t.jsxs("div",{style:r.loadingContainer,children:[t.jsx("div",{style:{...r.loadingSpinner,borderColor:s.primaryColor,borderTopColor:"transparent"}}),"Loading options..."]}):t.jsx("ul",{ref:E,style:r.optionsList,role:"listbox",children:O.length===0?t.jsx("li",{style:r.noOptions,children:"No options found"}):O.map((e,o)=>{const l=oe(e[c]),p=o===C,d=e.disabled;let a="transparent";return l?a=s.selectedOptionBackgroundColor:p&&(a=s.hoverColor),t.jsxs("li",{className:`${v} ${l?j:""}`,style:{...r.option,...d?r.optionDisabled:{},backgroundColor:v||j?void 0:a,color:v||j?void 0:l?s.selectedOptionTextColor:s.optionTextColor,fontWeight:l?500:400},onMouseEnter:()=>b(o),role:"option","aria-selected":l,onClick:B=>K(e,B),children:[t.jsxs("div",{style:r.optionContent,children:[t.jsx("span",{children:e[k]}),e[P]&&t.jsx("span",{className:_,style:r.sublabel,children:e[P]})]}),l&&t.jsx("svg",{style:{...r.checkIcon,color:s.selectedOptionTextColor},fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:3,d:"M5 13l4 4L19 7"})})]},e[c])})})})]})};h.Dropdown=$,Object.defineProperty(h,Symbol.toStringTag,{value:"Module"})}));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-customizable-dropdown",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.3",
|
|
4
4
|
"description": "A highly customizable, accessible, and premium React Dropdown component with built-in search, multi-select, field mapping, sublabels, and extensive theming options.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/dropdown.umd.js",
|
|
Binary file
|