react-customizable-dropdown 1.0.2 → 1.0.4

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,248 +1,438 @@
1
- import { jsxs as m, jsx as r } from "react/jsx-runtime";
2
- import { useState as j, useRef as M, useMemo as z, useEffect as U } from "react";
3
- const le = ({
4
- options: g,
5
- value: l,
6
- onChange: x,
7
- placeholder: E = "Select...",
8
- multiSelect: S = !1,
9
- searchable: a = !1,
10
- disabled: y = !1,
11
- loading: N = !1,
12
- className: q = "",
13
- style: H = {},
14
- theme: T,
15
- label: V,
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: O = "",
18
- selectedOptionClassName: L = "",
192
+ optionClassName: D = "",
193
+ selectedOptionClassName: v = "",
19
194
  menuClassName: J = "",
20
- triggerClassName: B = "",
21
- triggerStyle: Q = {},
22
- arrowIcon: P,
23
- arrowIconClassName: X = "",
24
- labelField: k = "label",
25
- valueField: d = "value",
26
- sublabelField: R = "sublabel",
27
- sublabelClassName: Y = ""
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 [n, f] = j(!1), [b, A] = j(""), [p, h] = j(-1), D = M(null), $ = M(null), w = M(null), Z = z(() => {
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
- // blue-500 (defaults to primaryColor)
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
- "--dd-primary": s.primaryColor,
62
- "--dd-bg": s.backgroundColor,
63
- "--dd-hover": s.hoverColor,
64
- "--dd-text": s.textColor,
65
- "--dd-padding": s.padding,
66
- "--dd-menu-bg": s.menuBackgroundColor,
67
- "--dd-option-text": s.optionTextColor,
68
- "--dd-selected-text": s.selectedOptionTextColor,
69
- "--dd-selected-bg": s.selectedOptionBackgroundColor,
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
- }, [T, H]);
76
- U(() => {
77
- const e = (t) => {
78
- D.current && !D.current.contains(t.target) && f(!1);
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 I = () => {
85
- y || (f(!n), n || (h(-1), setTimeout(() => {
86
- a && w.current && w.current.focus();
243
+ const K = () => {
244
+ b || (g(!i), i || (y(-1), setTimeout(() => {
245
+ u && S.current && S.current.focus();
87
246
  }, 0)));
88
- }, _ = () => {
89
- a ? n || (f(!0), h(-1), setTimeout(() => {
90
- w.current && w.current.focus();
91
- }, 0)) : I();
92
- }, C = (() => {
93
- if (l == null) return [];
94
- if (Array.isArray(l))
95
- return g.filter((t) => l.includes(t[d]));
96
- const e = g.find((t) => t[d] === l);
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
- })(), W = (e, t) => {
99
- if (t?.stopPropagation(), e.disabled) return;
100
- let o, i;
101
- if (S) {
102
- const c = Array.isArray(l) ? l : l ? [l] : [];
103
- c.includes(e[d]) ? o = c.filter((s) => s !== e[d]) : o = [...c, e[d]], i = g.filter(
104
- (s) => o.includes(s[d])
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
- o = e[d], i = e, f(!1), A("");
108
- x && x(o, i);
109
- }, F = (e, t) => {
110
- if (t.stopPropagation(), !x) return;
111
- const i = (Array.isArray(l) ? l : l ? [l] : []).filter((u) => u !== e), c = g.filter(
112
- (u) => i.includes(u[d])
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
- x(i, c);
115
- }, ee = (e) => {
116
- if (e.stopPropagation(), n && a) {
117
- A(""), f(!1);
273
+ C(p, d);
274
+ }, oe = (e) => {
275
+ if (e.stopPropagation(), i && u) {
276
+ R(""), g(!1);
118
277
  return;
119
278
  }
120
- x && x(S ? [] : "", S ? [] : []);
121
- }, v = z(
122
- () => g.filter((e) => !a || !b ? !0 : (typeof e[k] == "string" ? e[k] : String(e[d])).toLowerCase().includes(b.toLowerCase())),
123
- [g, a, b]
124
- ), K = (e) => {
125
- if (!y)
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(), n ? p >= 0 && p < v.length && W(v[p]) : f(!0);
287
+ e.preventDefault(), i ? x >= 0 && x < T.length && N(T[x]) : g(!0);
129
288
  break;
130
289
  case "Escape":
131
- n && (e.preventDefault(), f(!1));
290
+ i && (e.preventDefault(), g(!1));
132
291
  break;
133
292
  case "ArrowDown":
134
- e.preventDefault(), n ? h(
135
- (t) => t < v.length - 1 ? t + 1 : t
136
- ) : (f(!0), h(0));
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(), n && h((t) => t > 0 ? t - 1 : t);
298
+ e.preventDefault(), i && y((o) => o > 0 ? o - 1 : o);
140
299
  break;
141
300
  }
142
301
  };
143
- U(() => {
144
- if (n && $.current && p >= 0) {
145
- const e = $.current, t = e.children[p];
146
- if (t) {
147
- const o = e.scrollTop, i = o + e.clientHeight, c = t.offsetTop, u = c + t.clientHeight;
148
- c < o ? e.scrollTop = c : u > i && (e.scrollTop = u - e.clientHeight);
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
- }, [p, n]);
152
- const te = (e) => Array.isArray(l) ? l.includes(e) : l === e;
153
- return /* @__PURE__ */ m(
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: D,
157
- className: `relative w-full ${q} ${y ? "opacity-60 cursor-not-allowed" : ""}`,
158
- style: Z,
159
- onKeyDown: K,
315
+ ref: A,
316
+ className: Y,
317
+ style: {
318
+ ...t.container,
319
+ ...b ? t.containerDisabled : {},
320
+ ...q
321
+ },
322
+ onKeyDown: $,
160
323
  children: [
161
- V && /* @__PURE__ */ r(
324
+ z && /* @__PURE__ */ r(
162
325
  "label",
163
326
  {
164
- className: `block mb-1 text-sm font-medium text-gray-700 cursor-pointer ${G}`,
165
- onClick: I,
166
- style: T ? { color: T.textColor } : void 0,
167
- children: V
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__ */ m(
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
- padding: B ? void 0 : "var(--dd-padding)",
185
- minHeight: B ? void 0 : "42px",
186
- borderColor: B ? void 0 : n ? "var(--dd-focus-border)" : "#d1d5db",
187
- outline: "none",
188
- ...Q
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: a ? -1 : 0,
351
+ tabIndex: u ? -1 : 0,
192
352
  "aria-haspopup": "listbox",
193
- "aria-expanded": n,
353
+ "aria-expanded": i,
194
354
  children: [
195
- /* @__PURE__ */ r("div", { className: "flex flex-wrap gap-1 flex-1 overflow-hidden", children: a && (n || C.length === 0) ? /* @__PURE__ */ r(
355
+ /* @__PURE__ */ r("div", { style: t.triggerContent, children: u && (i || k.length === 0) ? /* @__PURE__ */ r(
196
356
  "input",
197
357
  {
198
- ref: w,
358
+ ref: S,
199
359
  type: "text",
200
- value: b,
201
- onChange: (e) => A(e.target.value),
202
- onKeyDown: K,
203
- placeholder: C.length === 0 ? E : "Search...",
204
- className: "flex-1 outline-none bg-transparent min-w-[60px]",
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(), n || f(!0);
369
+ e.stopPropagation(), i || g(!0);
207
370
  },
208
- disabled: y
371
+ disabled: b
209
372
  }
210
- ) : C.length === 0 ? /* @__PURE__ */ r("span", { className: "text-gray-400", children: E }) : S ? C.map((e) => /* @__PURE__ */ m(
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
- backgroundColor: "var(--dd-multi-selected-bg)",
216
- color: "var(--dd-multi-selected-text)"
377
+ ...t.multiTag,
378
+ backgroundColor: s.multiSelectSelectedOptionBackgroundColor,
379
+ color: s.multiSelectSelectedOptionTextColor
217
380
  },
218
- onClick: (t) => t.stopPropagation(),
381
+ onClick: (o) => o.stopPropagation(),
219
382
  children: [
220
- e[k],
383
+ e[m],
221
384
  /* @__PURE__ */ r(
222
385
  "span",
223
386
  {
224
- className: "ml-1 cursor-pointer font-bold",
225
- style: { color: "currentColor", opacity: 0.8 },
226
- onClick: (t) => F(e[d], t),
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[d]
233
- )) : /* @__PURE__ */ r("span", { className: "truncate", children: C[0][k] }) }),
234
- /* @__PURE__ */ m("div", { className: "flex items-center gap-2 ml-2", children: [
235
- N && /* @__PURE__ */ r("div", { className: "animate-spin h-4 w-4 border-2 border-[var(--dd-primary)] border-t-transparent rounded-full" }),
236
- !N && !y && (C.length > 0 || n && a && b) && /* @__PURE__ */ r(
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: ee,
240
- className: "p-1 hover:bg-gray-100 rounded-full transition-colors z-10",
241
- title: n && a ? "Clear search" : "Clear selection",
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
- className: "w-3 h-3 text-gray-400 hover:text-gray-600",
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: `transform transition-transform duration-200 ${n ? "rotate-180" : ""} ${X}`,
266
- children: P || /* @__PURE__ */ r(
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
- className: "w-4 h-4 text-gray-500",
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
- n && /* @__PURE__ */ r(
484
+ i && /* @__PURE__ */ r(
291
485
  "div",
292
486
  {
293
- 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 ${J}`,
294
- children: N ? /* @__PURE__ */ m("div", { className: "px-4 py-8 flex justify-center items-center text-gray-400", children: [
295
- /* @__PURE__ */ r("div", { className: "animate-spin h-6 w-6 border-2 border-[var(--dd-primary)] border-t-transparent rounded-full mr-2" }),
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: $, className: "py-1 overflow-y-auto", role: "listbox", children: v.length === 0 ? /* @__PURE__ */ r("li", { className: "px-4 py-2 text-gray-500 text-center text-sm", children: "No options found" }) : v.map((e, t) => {
298
- const o = te(e[d]), i = t === p;
299
- return /* @__PURE__ */ m(
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
- backgroundColor: o && L ? void 0 : i && !O ? "var(--dd-hover)" : o ? "var(--dd-selected-bg)" : O ? void 0 : "transparent",
310
- color: o && L || O ? void 0 : o ? "var(--dd-selected-text)" : "var(--dd-option-text)",
311
- fontWeight: o ? 500 : 400
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: () => h(t),
518
+ onMouseEnter: () => y(o),
314
519
  role: "option",
315
- "aria-selected": o,
316
- onClick: (c) => W(e, c),
520
+ "aria-selected": l,
521
+ onClick: (O) => N(e, O),
317
522
  children: [
318
- /* @__PURE__ */ m("div", { className: "flex flex-col", children: [
319
- /* @__PURE__ */ r("span", { children: e[k] }),
320
- e[R] && /* @__PURE__ */ r(
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: `text-xs text-gray-500 mt-0.5 ${Y}`,
324
- children: e[R]
528
+ className: _,
529
+ style: t.sublabel,
530
+ children: e[P]
325
531
  }
326
532
  )
327
533
  ] }),
328
- o && /* @__PURE__ */ r(
534
+ l && /* @__PURE__ */ r(
329
535
  "svg",
330
536
  {
331
- className: "w-4 h-4",
332
- style: { color: "var(--dd-selected-text)" },
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[d]
557
+ e[c]
350
558
  );
351
559
  }) })
352
560
  }
@@ -356,5 +564,5 @@ const le = ({
356
564
  );
357
565
  };
358
566
  export {
359
- le as Dropdown
567
+ se as Dropdown
360
568
  };
@@ -1,14 +1,5 @@
1
- (function(x,o){typeof exports=="object"&&typeof module<"u"?o(exports,require("react/jsx-runtime"),require("react")):typeof define=="function"&&define.amd?define(["exports","react/jsx-runtime","react"],o):(x=typeof globalThis<"u"?globalThis:x||self,o(x.Dropdown={},x.jsxRuntime,x.React))})(this,(function(x,o,a){"use strict";const q=({options:h,value:l,onChange:m,placeholder:$="Select...",multiSelect:T=!1,searchable:f=!1,disabled:k=!1,loading:L=!1,className:z="",style:E={},theme:O,label:H,labelClassName:U="",optionClassName:B="",selectedOptionClassName:j="",menuClassName:G="",triggerClassName:N="",triggerStyle:J={},arrowIcon:P,arrowIconClassName:Q="",labelField:w="label",valueField:d="value",sublabelField:V="sublabel",sublabelClassName:X=""})=>{const[n,u]=a.useState(!1),[b,D]=a.useState(""),[g,C]=a.useState(-1),A=a.useRef(null),M=a.useRef(null),S=a.useRef(null),Y=a.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"},t=O||{},r=t.selectedOptionTextColor??t.primaryColor??e.selectedOptionTextColor,i=t.selectedOptionBackgroundColor??t.hoverColor??e.selectedOptionBackgroundColor,c=t.multiSelectSelectedOptionTextColor??"#1e40af",p=t.multiSelectSelectedOptionBackgroundColor??"#dbeafe",s={...e,...t,menuBackgroundColor:t.menuBackgroundColor??t.backgroundColor??e.menuBackgroundColor,optionTextColor:t.optionTextColor??t.textColor??e.optionTextColor,selectedOptionTextColor:r,selectedOptionBackgroundColor:i,multiSelectSelectedOptionTextColor:c,multiSelectSelectedOptionBackgroundColor:p,focusBorderColor:t.focusBorderColor??t.primaryColor??e.focusBorderColor};return{"--dd-primary":s.primaryColor,"--dd-bg":s.backgroundColor,"--dd-hover":s.hoverColor,"--dd-text":s.textColor,"--dd-padding":s.padding,"--dd-menu-bg":s.menuBackgroundColor,"--dd-option-text":s.optionTextColor,"--dd-selected-text":s.selectedOptionTextColor,"--dd-selected-bg":s.selectedOptionBackgroundColor,"--dd-multi-selected-text":s.multiSelectSelectedOptionTextColor,"--dd-multi-selected-bg":s.multiSelectSelectedOptionBackgroundColor,"--dd-focus-border":s.focusBorderColor,...E}},[O,E]);a.useEffect(()=>{const e=t=>{A.current&&!A.current.contains(t.target)&&u(!1)};return document.addEventListener("mousedown",e),()=>{document.removeEventListener("mousedown",e)}},[]);const I=()=>{k||(u(!n),n||(C(-1),setTimeout(()=>{f&&S.current&&S.current.focus()},0)))},Z=()=>{f?n||(u(!0),C(-1),setTimeout(()=>{S.current&&S.current.focus()},0)):I()},y=(()=>{if(l==null)return[];if(Array.isArray(l))return h.filter(t=>l.includes(t[d]));const e=h.find(t=>t[d]===l);return e?[e]:[]})(),W=(e,t)=>{if(t?.stopPropagation(),e.disabled)return;let r,i;if(T){const c=Array.isArray(l)?l:l?[l]:[];c.includes(e[d])?r=c.filter(s=>s!==e[d]):r=[...c,e[d]],i=h.filter(s=>r.includes(s[d]))}else r=e[d],i=e,u(!1),D("");m&&m(r,i)},_=(e,t)=>{if(t.stopPropagation(),!m)return;const i=(Array.isArray(l)?l:l?[l]:[]).filter(p=>p!==e),c=h.filter(p=>i.includes(p[d]));m(i,c)},F=e=>{if(e.stopPropagation(),n&&f){D(""),u(!1);return}m&&m(T?[]:"",T?[]:[])},v=a.useMemo(()=>h.filter(e=>!f||!b?!0:(typeof e[w]=="string"?e[w]:String(e[d])).toLowerCase().includes(b.toLowerCase())),[h,f,b]),K=e=>{if(!k)switch(e.key){case"Enter":e.preventDefault(),n?g>=0&&g<v.length&&W(v[g]):u(!0);break;case"Escape":n&&(e.preventDefault(),u(!1));break;case"ArrowDown":e.preventDefault(),n?C(t=>t<v.length-1?t+1:t):(u(!0),C(0));break;case"ArrowUp":e.preventDefault(),n&&C(t=>t>0?t-1:t);break}};a.useEffect(()=>{if(n&&M.current&&g>=0){const e=M.current,t=e.children[g];if(t){const r=e.scrollTop,i=r+e.clientHeight,c=t.offsetTop,p=c+t.clientHeight;c<r?e.scrollTop=c:p>i&&(e.scrollTop=p-e.clientHeight)}}},[g,n]);const R=e=>Array.isArray(l)?l.includes(e):l===e;return o.jsxs("div",{ref:A,className:`relative w-full ${z} ${k?"opacity-60 cursor-not-allowed":""}`,style:Y,onKeyDown:K,children:[H&&o.jsx("label",{className:`block mb-1 text-sm font-medium text-gray-700 cursor-pointer ${U}`,onClick:I,style:O?{color:O.textColor}:void 0,children:H}),o.jsxs("div",{onClick:Z,className:`
2
- flex items-center justify-between
3
- w-full
4
- bg-[var(--dd-bg)]
5
- cursor-pointer
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,7 +1,7 @@
1
1
  {
2
2
  "name": "react-customizable-dropdown",
3
- "version": "1.0.2",
4
- "description": "A highly customizable, accessible, and premium React Dropdown component with built-in search, multi-select, field mapping, sublabels, and extensive theming options.",
3
+ "version": "1.0.4",
4
+ "description": "A highly customizable, accessible, and premium React Dropdown component with built-in search, multi-select, field mapping, debouncing, sublabels, and extensive theming options.",
5
5
  "type": "module",
6
6
  "main": "./dist/dropdown.umd.js",
7
7
  "module": "./dist/dropdown.es.js",
@@ -51,7 +51,7 @@
51
51
  "bugs": {
52
52
  "url": "https://github.com/shiningsudipto/react-customizable-dropdown/issues"
53
53
  },
54
- "homepage": "https://github.com/shiningsudipto/react-customizable-dropdown",
54
+ "homepage": "https://react-customizable-dropdown.vercel.app",
55
55
  "publishConfig": {
56
56
  "access": "public"
57
57
  },