react-customizable-dropdown 1.0.1 → 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/components/Dropdown/Dropdown.d.ts +3 -0
- package/dist/components/Dropdown/Dropdown.types.d.ts +81 -0
- package/dist/components/Dropdown/index.d.ts +2 -0
- package/dist/dropdown.es.js +410 -461
- package/dist/dropdown.umd.js +5 -19
- package/dist/index.d.ts +1 -0
- package/package.json +3 -3
- package/dist/react-customizable-dropdown-bg.png +0 -0
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import type { ReactNode, CSSProperties } from "react";
|
|
2
|
+
export interface DropdownOption {
|
|
3
|
+
value?: any;
|
|
4
|
+
label?: any;
|
|
5
|
+
sublabel?: any;
|
|
6
|
+
disabled?: boolean;
|
|
7
|
+
group?: string;
|
|
8
|
+
[key: string]: any;
|
|
9
|
+
}
|
|
10
|
+
export interface DropdownTheme {
|
|
11
|
+
primaryColor?: string;
|
|
12
|
+
backgroundColor?: string;
|
|
13
|
+
hoverColor?: string;
|
|
14
|
+
textColor?: string;
|
|
15
|
+
padding?: string;
|
|
16
|
+
menuBackgroundColor?: string;
|
|
17
|
+
optionTextColor?: string;
|
|
18
|
+
selectedOptionTextColor?: string;
|
|
19
|
+
selectedOptionBackgroundColor?: string;
|
|
20
|
+
multiSelectSelectedOptionTextColor?: string;
|
|
21
|
+
multiSelectSelectedOptionBackgroundColor?: string;
|
|
22
|
+
focusBorderColor?: string;
|
|
23
|
+
}
|
|
24
|
+
export interface DropdownProps {
|
|
25
|
+
/** Label for the dropdown */
|
|
26
|
+
label?: ReactNode;
|
|
27
|
+
/** Custom classes for the label */
|
|
28
|
+
labelClassName?: string;
|
|
29
|
+
/** Custom classes for dropdown option items */
|
|
30
|
+
optionClassName?: string;
|
|
31
|
+
/** Custom classes for selected options in the dropdown list (when dropdown is open) */
|
|
32
|
+
selectedOptionClassName?: string;
|
|
33
|
+
/** Custom classes for the dropdown menu wrapper/container */
|
|
34
|
+
menuClassName?: string;
|
|
35
|
+
/** Custom classes for the dropdown trigger/field area */
|
|
36
|
+
triggerClassName?: string;
|
|
37
|
+
/** Inline styles for the dropdown trigger/field area */
|
|
38
|
+
triggerStyle?: CSSProperties;
|
|
39
|
+
/** Custom arrow/chevron icon component to display instead of the default */
|
|
40
|
+
arrowIcon?: ReactNode;
|
|
41
|
+
/** Custom class name for the arrow icon wrapper */
|
|
42
|
+
arrowIconClassName?: string;
|
|
43
|
+
/** Field name for the label from the option object (defaults to 'label') */
|
|
44
|
+
labelField?: string;
|
|
45
|
+
/** Field name for the value from the option object (defaults to 'value') */
|
|
46
|
+
valueField?: string;
|
|
47
|
+
/** Field name for the sublabel from the option object (defaults to 'sublabel') */
|
|
48
|
+
sublabelField?: string;
|
|
49
|
+
/** Custom classes for the sublabel */
|
|
50
|
+
sublabelClassName?: string;
|
|
51
|
+
/** Array of options to display */
|
|
52
|
+
options: DropdownOption[];
|
|
53
|
+
/** Current selected value(s) */
|
|
54
|
+
value?: any;
|
|
55
|
+
/** Callback when selection changes */
|
|
56
|
+
onChange?: (value: any, option?: DropdownOption | DropdownOption[]) => void;
|
|
57
|
+
/** Placeholder text when nothing is selected */
|
|
58
|
+
placeholder?: string;
|
|
59
|
+
/** Whether to allow selecting multiple options */
|
|
60
|
+
multiSelect?: boolean;
|
|
61
|
+
/** Whether to show a search input */
|
|
62
|
+
searchable?: boolean;
|
|
63
|
+
/** Custom functionality to handle search externally */
|
|
64
|
+
onSearch?: (query: string) => void;
|
|
65
|
+
/** Debounce delay for search in ms */
|
|
66
|
+
searchDebounce?: number;
|
|
67
|
+
/** Disable the entire dropdown */
|
|
68
|
+
disabled?: boolean;
|
|
69
|
+
/** Custom theme overrides */
|
|
70
|
+
theme?: DropdownTheme;
|
|
71
|
+
/** Whether the options are currently loading */
|
|
72
|
+
loading?: boolean;
|
|
73
|
+
/** Custom render function for options */
|
|
74
|
+
renderOption?: (option: DropdownOption) => ReactNode;
|
|
75
|
+
/** Custom render function for selected value */
|
|
76
|
+
renderValue?: (value: DropdownOption | DropdownOption[]) => ReactNode;
|
|
77
|
+
/** Custom class names */
|
|
78
|
+
className?: string;
|
|
79
|
+
/** Inline styles */
|
|
80
|
+
style?: CSSProperties;
|
|
81
|
+
}
|
package/dist/dropdown.es.js
CHANGED
|
@@ -1,511 +1,442 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
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"
|
|
22
167
|
}
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
if (typeof e == "function")
|
|
32
|
-
return e.$$typeof === D ? null : e.displayName || e.name || null;
|
|
33
|
-
if (typeof e == "string") return e;
|
|
34
|
-
switch (e) {
|
|
35
|
-
case O:
|
|
36
|
-
return "Fragment";
|
|
37
|
-
case z:
|
|
38
|
-
return "Profiler";
|
|
39
|
-
case K:
|
|
40
|
-
return "StrictMode";
|
|
41
|
-
case q:
|
|
42
|
-
return "Suspense";
|
|
43
|
-
case F:
|
|
44
|
-
return "SuspenseList";
|
|
45
|
-
case N:
|
|
46
|
-
return "Activity";
|
|
47
|
-
}
|
|
48
|
-
if (typeof e == "object")
|
|
49
|
-
switch (typeof e.tag == "number" && console.error(
|
|
50
|
-
"Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."
|
|
51
|
-
), e.$$typeof) {
|
|
52
|
-
case Z:
|
|
53
|
-
return "Portal";
|
|
54
|
-
case A:
|
|
55
|
-
return e.displayName || "Context";
|
|
56
|
-
case Q:
|
|
57
|
-
return (e._context.displayName || "Context") + ".Consumer";
|
|
58
|
-
case p:
|
|
59
|
-
var o = e.render;
|
|
60
|
-
return e = e.displayName, e || (e = o.displayName || o.name || "", e = e !== "" ? "ForwardRef(" + e + ")" : "ForwardRef"), e;
|
|
61
|
-
case u:
|
|
62
|
-
return o = e.displayName || null, o !== null ? o : x(e.type) || "Memo";
|
|
63
|
-
case g:
|
|
64
|
-
o = e._payload, e = e._init;
|
|
65
|
-
try {
|
|
66
|
-
return x(e(o));
|
|
67
|
-
} catch {
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
return null;
|
|
71
|
-
}
|
|
72
|
-
function a(e) {
|
|
73
|
-
return "" + e;
|
|
74
|
-
}
|
|
75
|
-
function h(e) {
|
|
76
|
-
try {
|
|
77
|
-
a(e);
|
|
78
|
-
var o = !1;
|
|
79
|
-
} catch {
|
|
80
|
-
o = !0;
|
|
81
|
-
}
|
|
82
|
-
if (o) {
|
|
83
|
-
o = console;
|
|
84
|
-
var s = o.error, c = typeof Symbol == "function" && Symbol.toStringTag && e[Symbol.toStringTag] || e.constructor.name || "Object";
|
|
85
|
-
return s.call(
|
|
86
|
-
o,
|
|
87
|
-
"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",
|
|
88
|
-
c
|
|
89
|
-
), a(e);
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
function R(e) {
|
|
93
|
-
if (e === O) return "<>";
|
|
94
|
-
if (typeof e == "object" && e !== null && e.$$typeof === g)
|
|
95
|
-
return "<...>";
|
|
96
|
-
try {
|
|
97
|
-
var o = x(e);
|
|
98
|
-
return o ? "<" + o + ">" : "<...>";
|
|
99
|
-
} catch {
|
|
100
|
-
return "<...>";
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
function f() {
|
|
104
|
-
var e = T.A;
|
|
105
|
-
return e === null ? null : e.getOwner();
|
|
106
|
-
}
|
|
107
|
-
function d() {
|
|
108
|
-
return Error("react-stack-top-frame");
|
|
109
|
-
}
|
|
110
|
-
function k(e) {
|
|
111
|
-
if (_.call(e, "key")) {
|
|
112
|
-
var o = Object.getOwnPropertyDescriptor(e, "key").get;
|
|
113
|
-
if (o && o.isReactWarning) return !1;
|
|
114
|
-
}
|
|
115
|
-
return e.key !== void 0;
|
|
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); }
|
|
116
176
|
}
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
}, (i !== void 0 ? i : null) !== null ? Object.defineProperty(e, "ref", {
|
|
144
|
-
enumerable: !1,
|
|
145
|
-
get: X
|
|
146
|
-
}) : Object.defineProperty(e, "ref", { enumerable: !1, value: null }), e._store = {}, Object.defineProperty(e._store, "validated", {
|
|
147
|
-
configurable: !1,
|
|
148
|
-
enumerable: !1,
|
|
149
|
-
writable: !0,
|
|
150
|
-
value: 0
|
|
151
|
-
}), Object.defineProperty(e, "_debugInfo", {
|
|
152
|
-
configurable: !1,
|
|
153
|
-
enumerable: !1,
|
|
154
|
-
writable: !0,
|
|
155
|
-
value: null
|
|
156
|
-
}), Object.defineProperty(e, "_debugStack", {
|
|
157
|
-
configurable: !1,
|
|
158
|
-
enumerable: !1,
|
|
159
|
-
writable: !0,
|
|
160
|
-
value: y
|
|
161
|
-
}), Object.defineProperty(e, "_debugTask", {
|
|
162
|
-
configurable: !1,
|
|
163
|
-
enumerable: !1,
|
|
164
|
-
writable: !0,
|
|
165
|
-
value: $
|
|
166
|
-
}), Object.freeze && (Object.freeze(e.props), Object.freeze(e)), e;
|
|
167
|
-
}
|
|
168
|
-
function j(e, o, s, c, y, $) {
|
|
169
|
-
var i = o.children;
|
|
170
|
-
if (i !== void 0)
|
|
171
|
-
if (c)
|
|
172
|
-
if (Y(i)) {
|
|
173
|
-
for (c = 0; c < i.length; c++)
|
|
174
|
-
L(i[c]);
|
|
175
|
-
Object.freeze && Object.freeze(i);
|
|
176
|
-
} else
|
|
177
|
-
console.error(
|
|
178
|
-
"React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead."
|
|
179
|
-
);
|
|
180
|
-
else L(i);
|
|
181
|
-
if (_.call(o, "key")) {
|
|
182
|
-
i = x(e);
|
|
183
|
-
var r = Object.keys(o).filter(function(l) {
|
|
184
|
-
return l !== "key";
|
|
185
|
-
});
|
|
186
|
-
c = 0 < r.length ? "{key: someKey, " + r.join(": ..., ") + ": ...}" : "{key: someKey}", ee[i + c] || (r = 0 < r.length ? "{" + r.join(": ..., ") + ": ...}" : "{}", console.error(
|
|
187
|
-
`A props object containing a "key" prop is being spread into JSX:
|
|
188
|
-
let props = %s;
|
|
189
|
-
<%s {...props} />
|
|
190
|
-
React keys must be passed directly to JSX without using spread:
|
|
191
|
-
let props = %s;
|
|
192
|
-
<%s key={someKey} {...props} />`,
|
|
193
|
-
c,
|
|
194
|
-
i,
|
|
195
|
-
r,
|
|
196
|
-
i
|
|
197
|
-
), ee[i + c] = !0);
|
|
198
|
-
}
|
|
199
|
-
if (i = null, s !== void 0 && (h(s), i = "" + s), k(o) && (h(o.key), i = "" + o.key), "key" in o) {
|
|
200
|
-
s = {};
|
|
201
|
-
for (var t in o)
|
|
202
|
-
t !== "key" && (s[t] = o[t]);
|
|
203
|
-
} else s = o;
|
|
204
|
-
return i && E(
|
|
205
|
-
s,
|
|
206
|
-
typeof e == "function" ? e.displayName || e.name || "Unknown" : e
|
|
207
|
-
), V(
|
|
208
|
-
e,
|
|
209
|
-
i,
|
|
210
|
-
s,
|
|
211
|
-
f(),
|
|
212
|
-
y,
|
|
213
|
-
$
|
|
214
|
-
);
|
|
215
|
-
}
|
|
216
|
-
function L(e) {
|
|
217
|
-
U(e) ? e._store && (e._store.validated = 1) : typeof e == "object" && e !== null && e.$$typeof === g && (e._payload.status === "fulfilled" ? U(e._payload.value) && e._payload.value._store && (e._payload.value._store.validated = 1) : e._store && (e._store.validated = 1));
|
|
218
|
-
}
|
|
219
|
-
function U(e) {
|
|
220
|
-
return typeof e == "object" && e !== null && e.$$typeof === B;
|
|
221
|
-
}
|
|
222
|
-
var C = ce, B = /* @__PURE__ */ Symbol.for("react.transitional.element"), Z = /* @__PURE__ */ Symbol.for("react.portal"), O = /* @__PURE__ */ Symbol.for("react.fragment"), K = /* @__PURE__ */ Symbol.for("react.strict_mode"), z = /* @__PURE__ */ Symbol.for("react.profiler"), Q = /* @__PURE__ */ Symbol.for("react.consumer"), A = /* @__PURE__ */ Symbol.for("react.context"), p = /* @__PURE__ */ Symbol.for("react.forward_ref"), q = /* @__PURE__ */ Symbol.for("react.suspense"), F = /* @__PURE__ */ Symbol.for("react.suspense_list"), u = /* @__PURE__ */ Symbol.for("react.memo"), g = /* @__PURE__ */ Symbol.for("react.lazy"), N = /* @__PURE__ */ Symbol.for("react.activity"), D = /* @__PURE__ */ Symbol.for("react.client.reference"), T = C.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, _ = Object.prototype.hasOwnProperty, Y = Array.isArray, P = console.createTask ? console.createTask : function() {
|
|
223
|
-
return null;
|
|
224
|
-
};
|
|
225
|
-
C = {
|
|
226
|
-
react_stack_bottom_frame: function(e) {
|
|
227
|
-
return e();
|
|
228
|
-
}
|
|
229
|
-
};
|
|
230
|
-
var S, H = {}, I = C.react_stack_bottom_frame.bind(
|
|
231
|
-
C,
|
|
232
|
-
d
|
|
233
|
-
)(), J = P(R(d)), ee = {};
|
|
234
|
-
W.Fragment = O, W.jsx = function(e, o, s) {
|
|
235
|
-
var c = 1e4 > T.recentlyCreatedOwnerStacks++;
|
|
236
|
-
return j(
|
|
237
|
-
e,
|
|
238
|
-
o,
|
|
239
|
-
s,
|
|
240
|
-
!1,
|
|
241
|
-
c ? Error("react-stack-top-frame") : I,
|
|
242
|
-
c ? P(R(e)) : J
|
|
243
|
-
);
|
|
244
|
-
}, W.jsxs = function(e, o, s) {
|
|
245
|
-
var c = 1e4 > T.recentlyCreatedOwnerStacks++;
|
|
246
|
-
return j(
|
|
247
|
-
e,
|
|
248
|
-
o,
|
|
249
|
-
s,
|
|
250
|
-
!0,
|
|
251
|
-
c ? Error("react-stack-top-frame") : I,
|
|
252
|
-
c ? P(R(e)) : J
|
|
253
|
-
);
|
|
254
|
-
};
|
|
255
|
-
})()), W;
|
|
256
|
-
}
|
|
257
|
-
var ae;
|
|
258
|
-
function ue() {
|
|
259
|
-
return ae || (ae = 1, process.env.NODE_ENV === "production" ? G.exports = ie() : G.exports = de()), G.exports;
|
|
260
|
-
}
|
|
261
|
-
var n = ue();
|
|
262
|
-
const me = ({
|
|
263
|
-
options: x,
|
|
264
|
-
value: a,
|
|
265
|
-
onChange: h,
|
|
266
|
-
placeholder: R = "Select...",
|
|
267
|
-
multiSelect: f = !1,
|
|
268
|
-
searchable: d = !1,
|
|
269
|
-
disabled: k = !1,
|
|
270
|
-
loading: E = !1,
|
|
271
|
-
className: X = "",
|
|
272
|
-
style: V = {},
|
|
273
|
-
theme: j,
|
|
274
|
-
label: L,
|
|
275
|
-
labelClassName: U = "",
|
|
276
|
-
optionClassName: C = "",
|
|
277
|
-
selectedOptionClassName: B = "",
|
|
278
|
-
menuClassName: Z = "",
|
|
279
|
-
triggerClassName: O = "",
|
|
280
|
-
triggerStyle: K = {},
|
|
281
|
-
arrowIcon: z,
|
|
282
|
-
arrowIconClassName: Q = "",
|
|
283
|
-
labelField: A = "label",
|
|
284
|
-
valueField: p = "value",
|
|
285
|
-
sublabelField: q = "sublabel",
|
|
286
|
-
sublabelClassName: F = ""
|
|
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,
|
|
191
|
+
labelClassName: G = "",
|
|
192
|
+
optionClassName: D = "",
|
|
193
|
+
selectedOptionClassName: v = "",
|
|
194
|
+
menuClassName: J = "",
|
|
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: _ = ""
|
|
287
203
|
}) => {
|
|
288
|
-
const [
|
|
289
|
-
|
|
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(() => {
|
|
209
|
+
const e = {
|
|
290
210
|
primaryColor: "#3b82f6",
|
|
291
|
-
// blue-500
|
|
292
211
|
backgroundColor: "#ffffff",
|
|
293
212
|
hoverColor: "#eff6ff",
|
|
294
|
-
// blue-50
|
|
295
213
|
textColor: "#1f2937",
|
|
296
|
-
// gray-800
|
|
297
214
|
padding: "0.5rem 1rem",
|
|
298
215
|
menuBackgroundColor: "#ffffff",
|
|
299
216
|
optionTextColor: "#1f2937",
|
|
300
217
|
selectedOptionTextColor: "#3b82f6",
|
|
301
218
|
selectedOptionBackgroundColor: "#eff6ff",
|
|
302
219
|
multiSelectSelectedOptionTextColor: "#1e40af",
|
|
303
|
-
// blue-800
|
|
304
220
|
multiSelectSelectedOptionBackgroundColor: "#dbeafe",
|
|
305
|
-
// blue-100
|
|
306
221
|
focusBorderColor: "#3b82f6"
|
|
307
|
-
|
|
308
|
-
}, t = j || {}, l = t.selectedOptionTextColor ?? t.primaryColor ?? r.selectedOptionTextColor, v = t.selectedOptionBackgroundColor ?? t.hoverColor ?? r.selectedOptionBackgroundColor, b = t.multiSelectSelectedOptionTextColor ?? "#1e40af", w = t.multiSelectSelectedOptionBackgroundColor ?? "#dbeafe", m = {
|
|
309
|
-
...r,
|
|
310
|
-
...t,
|
|
311
|
-
menuBackgroundColor: t.menuBackgroundColor ?? t.backgroundColor ?? r.menuBackgroundColor,
|
|
312
|
-
optionTextColor: t.optionTextColor ?? t.textColor ?? r.optionTextColor,
|
|
313
|
-
selectedOptionTextColor: l,
|
|
314
|
-
selectedOptionBackgroundColor: v,
|
|
315
|
-
multiSelectSelectedOptionTextColor: b,
|
|
316
|
-
multiSelectSelectedOptionBackgroundColor: w,
|
|
317
|
-
focusBorderColor: t.focusBorderColor ?? t.primaryColor ?? r.focusBorderColor
|
|
318
|
-
};
|
|
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";
|
|
319
223
|
return {
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
"--dd-multi-selected-text": m.multiSelectSelectedOptionTextColor,
|
|
330
|
-
"--dd-multi-selected-bg": m.multiSelectSelectedOptionBackgroundColor,
|
|
331
|
-
"--dd-focus-border": m.focusBorderColor,
|
|
332
|
-
...V
|
|
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
|
|
333
233
|
};
|
|
334
|
-
}, [
|
|
335
|
-
|
|
336
|
-
const
|
|
337
|
-
|
|
234
|
+
}, [I]);
|
|
235
|
+
W(() => {
|
|
236
|
+
const e = (o) => {
|
|
237
|
+
A.current && !A.current.contains(o.target) && g(!1);
|
|
338
238
|
};
|
|
339
|
-
return document.addEventListener("mousedown",
|
|
340
|
-
document.removeEventListener("mousedown",
|
|
239
|
+
return document.addEventListener("mousedown", e), () => {
|
|
240
|
+
document.removeEventListener("mousedown", e);
|
|
341
241
|
};
|
|
342
242
|
}, []);
|
|
343
|
-
const
|
|
344
|
-
|
|
345
|
-
|
|
243
|
+
const K = () => {
|
|
244
|
+
b || (g(!i), i || (y(-1), setTimeout(() => {
|
|
245
|
+
u && S.current && S.current.focus();
|
|
346
246
|
}, 0)));
|
|
347
|
-
},
|
|
348
|
-
|
|
247
|
+
}, F = () => {
|
|
248
|
+
u ? i || (g(!0), y(-1), setTimeout(() => {
|
|
349
249
|
S.current && S.current.focus();
|
|
350
|
-
}, 0)) :
|
|
351
|
-
},
|
|
352
|
-
if (
|
|
353
|
-
if (Array.isArray(
|
|
354
|
-
return
|
|
355
|
-
const
|
|
356
|
-
return
|
|
357
|
-
})(),
|
|
358
|
-
if (
|
|
359
|
-
let l,
|
|
360
|
-
if (
|
|
361
|
-
const
|
|
362
|
-
|
|
363
|
-
(
|
|
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);
|
|
256
|
+
return e ? [e] : [];
|
|
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])
|
|
364
264
|
);
|
|
365
265
|
} else
|
|
366
|
-
l =
|
|
367
|
-
|
|
368
|
-
},
|
|
369
|
-
if (
|
|
370
|
-
const
|
|
371
|
-
(
|
|
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])
|
|
372
272
|
);
|
|
373
|
-
|
|
374
|
-
},
|
|
375
|
-
if (
|
|
376
|
-
|
|
273
|
+
C(p, d);
|
|
274
|
+
}, oe = (e) => {
|
|
275
|
+
if (e.stopPropagation(), i && u) {
|
|
276
|
+
R(""), g(!1);
|
|
377
277
|
return;
|
|
378
278
|
}
|
|
379
|
-
|
|
380
|
-
},
|
|
381
|
-
() =>
|
|
382
|
-
[
|
|
383
|
-
), $ = (
|
|
384
|
-
if (!
|
|
385
|
-
switch (
|
|
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)
|
|
285
|
+
switch (e.key) {
|
|
386
286
|
case "Enter":
|
|
387
|
-
|
|
287
|
+
e.preventDefault(), i ? x >= 0 && x < T.length && N(T[x]) : g(!0);
|
|
388
288
|
break;
|
|
389
289
|
case "Escape":
|
|
390
|
-
|
|
290
|
+
i && (e.preventDefault(), g(!1));
|
|
391
291
|
break;
|
|
392
292
|
case "ArrowDown":
|
|
393
|
-
|
|
394
|
-
(
|
|
395
|
-
) : (g(!0),
|
|
293
|
+
e.preventDefault(), i ? y(
|
|
294
|
+
(o) => o < T.length - 1 ? o + 1 : o
|
|
295
|
+
) : (g(!0), y(0));
|
|
396
296
|
break;
|
|
397
297
|
case "ArrowUp":
|
|
398
|
-
|
|
298
|
+
e.preventDefault(), i && y((o) => o > 0 ? o - 1 : o);
|
|
399
299
|
break;
|
|
400
300
|
}
|
|
401
301
|
};
|
|
402
|
-
|
|
403
|
-
if (
|
|
404
|
-
const
|
|
405
|
-
if (
|
|
406
|
-
const l =
|
|
407
|
-
|
|
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);
|
|
408
308
|
}
|
|
409
309
|
}
|
|
410
|
-
}, [
|
|
411
|
-
const
|
|
412
|
-
return /* @__PURE__ */
|
|
310
|
+
}, [x, i]);
|
|
311
|
+
const te = (e) => Array.isArray(n) ? n.includes(e) : n === e;
|
|
312
|
+
return /* @__PURE__ */ h(
|
|
413
313
|
"div",
|
|
414
314
|
{
|
|
415
|
-
ref:
|
|
416
|
-
className:
|
|
417
|
-
style:
|
|
315
|
+
ref: A,
|
|
316
|
+
className: Y,
|
|
317
|
+
style: {
|
|
318
|
+
...t.container,
|
|
319
|
+
...b ? t.containerDisabled : {},
|
|
320
|
+
...q
|
|
321
|
+
},
|
|
418
322
|
onKeyDown: $,
|
|
419
323
|
children: [
|
|
420
|
-
|
|
324
|
+
z && /* @__PURE__ */ r(
|
|
421
325
|
"label",
|
|
422
326
|
{
|
|
423
|
-
className:
|
|
424
|
-
onClick:
|
|
425
|
-
style:
|
|
426
|
-
|
|
327
|
+
className: G,
|
|
328
|
+
onClick: K,
|
|
329
|
+
style: {
|
|
330
|
+
...t.label,
|
|
331
|
+
...I?.textColor ? { color: I.textColor } : {}
|
|
332
|
+
},
|
|
333
|
+
children: z
|
|
427
334
|
}
|
|
428
335
|
),
|
|
429
|
-
/* @__PURE__ */
|
|
336
|
+
/* @__PURE__ */ h(
|
|
430
337
|
"div",
|
|
431
338
|
{
|
|
432
|
-
onClick:
|
|
433
|
-
className:
|
|
434
|
-
flex items-center justify-between
|
|
435
|
-
w-full
|
|
436
|
-
bg-[var(--dd-bg)]
|
|
437
|
-
cursor-pointer
|
|
438
|
-
transition-all duration-200
|
|
439
|
-
text-[var(--dd-text)]
|
|
440
|
-
${O || "border rounded-lg"}
|
|
441
|
-
`,
|
|
339
|
+
onClick: F,
|
|
340
|
+
className: Q,
|
|
442
341
|
style: {
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
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
|
|
448
349
|
},
|
|
449
350
|
role: "button",
|
|
450
|
-
tabIndex:
|
|
351
|
+
tabIndex: u ? -1 : 0,
|
|
451
352
|
"aria-haspopup": "listbox",
|
|
452
|
-
"aria-expanded":
|
|
353
|
+
"aria-expanded": i,
|
|
453
354
|
children: [
|
|
454
|
-
/* @__PURE__ */
|
|
355
|
+
/* @__PURE__ */ r("div", { style: t.triggerContent, children: u && (i || k.length === 0) ? /* @__PURE__ */ r(
|
|
455
356
|
"input",
|
|
456
357
|
{
|
|
457
358
|
ref: S,
|
|
458
359
|
type: "text",
|
|
459
|
-
value:
|
|
460
|
-
onChange: (
|
|
360
|
+
value: w,
|
|
361
|
+
onChange: (e) => R(e.target.value),
|
|
461
362
|
onKeyDown: $,
|
|
462
|
-
placeholder:
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
363
|
+
placeholder: k.length === 0 ? H : "Search...",
|
|
364
|
+
style: {
|
|
365
|
+
...t.searchInput,
|
|
366
|
+
color: s.textColor
|
|
466
367
|
},
|
|
467
|
-
|
|
368
|
+
onClick: (e) => {
|
|
369
|
+
e.stopPropagation(), i || g(!0);
|
|
370
|
+
},
|
|
371
|
+
disabled: b
|
|
468
372
|
}
|
|
469
|
-
) :
|
|
373
|
+
) : k.length === 0 ? /* @__PURE__ */ r("span", { style: t.placeholder, children: H }) : B ? k.map((e) => /* @__PURE__ */ h(
|
|
470
374
|
"span",
|
|
471
375
|
{
|
|
472
|
-
className: "inline-flex items-center px-2 py-0.5 rounded text-sm animate-fadeIn",
|
|
473
376
|
style: {
|
|
474
|
-
|
|
475
|
-
|
|
377
|
+
...t.multiTag,
|
|
378
|
+
backgroundColor: s.multiSelectSelectedOptionBackgroundColor,
|
|
379
|
+
color: s.multiSelectSelectedOptionTextColor
|
|
476
380
|
},
|
|
477
|
-
onClick: (
|
|
381
|
+
onClick: (o) => o.stopPropagation(),
|
|
478
382
|
children: [
|
|
479
|
-
|
|
480
|
-
/* @__PURE__ */
|
|
383
|
+
e[m],
|
|
384
|
+
/* @__PURE__ */ r(
|
|
481
385
|
"span",
|
|
482
386
|
{
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
387
|
+
style: {
|
|
388
|
+
...t.multiTagRemove,
|
|
389
|
+
color: s.multiSelectSelectedOptionTextColor
|
|
390
|
+
},
|
|
391
|
+
onClick: (o) => ee(e[c], o),
|
|
486
392
|
children: "×"
|
|
487
393
|
}
|
|
488
394
|
)
|
|
489
395
|
]
|
|
490
396
|
},
|
|
491
|
-
|
|
492
|
-
)) : /* @__PURE__ */
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
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(
|
|
496
421
|
"div",
|
|
497
422
|
{
|
|
498
|
-
onClick:
|
|
499
|
-
|
|
500
|
-
title:
|
|
501
|
-
|
|
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
|
+
},
|
|
432
|
+
children: /* @__PURE__ */ r(
|
|
502
433
|
"svg",
|
|
503
434
|
{
|
|
504
|
-
|
|
435
|
+
style: t.icon,
|
|
505
436
|
fill: "none",
|
|
506
437
|
stroke: "currentColor",
|
|
507
438
|
viewBox: "0 0 24 24",
|
|
508
|
-
children: /* @__PURE__ */
|
|
439
|
+
children: /* @__PURE__ */ r(
|
|
509
440
|
"path",
|
|
510
441
|
{
|
|
511
442
|
strokeLinecap: "round",
|
|
@@ -518,18 +449,22 @@ const me = ({
|
|
|
518
449
|
)
|
|
519
450
|
}
|
|
520
451
|
),
|
|
521
|
-
/* @__PURE__ */
|
|
452
|
+
/* @__PURE__ */ r(
|
|
522
453
|
"div",
|
|
523
454
|
{
|
|
524
|
-
className:
|
|
525
|
-
|
|
455
|
+
className: Z,
|
|
456
|
+
style: {
|
|
457
|
+
...t.chevronContainer,
|
|
458
|
+
transform: i ? "rotate(180deg)" : "rotate(0deg)"
|
|
459
|
+
},
|
|
460
|
+
children: V || /* @__PURE__ */ r(
|
|
526
461
|
"svg",
|
|
527
462
|
{
|
|
528
|
-
|
|
463
|
+
style: t.chevronIcon,
|
|
529
464
|
fill: "none",
|
|
530
465
|
stroke: "currentColor",
|
|
531
466
|
viewBox: "0 0 24 24",
|
|
532
|
-
children: /* @__PURE__ */
|
|
467
|
+
children: /* @__PURE__ */ r(
|
|
533
468
|
"path",
|
|
534
469
|
{
|
|
535
470
|
strokeLinecap: "round",
|
|
@@ -546,53 +481,67 @@ const me = ({
|
|
|
546
481
|
]
|
|
547
482
|
}
|
|
548
483
|
),
|
|
549
|
-
|
|
484
|
+
i && /* @__PURE__ */ r(
|
|
550
485
|
"div",
|
|
551
486
|
{
|
|
552
|
-
className:
|
|
553
|
-
|
|
554
|
-
|
|
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
|
+
),
|
|
555
503
|
"Loading options..."
|
|
556
|
-
] }) : /* @__PURE__ */
|
|
557
|
-
const l =
|
|
558
|
-
|
|
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(
|
|
559
508
|
"li",
|
|
560
509
|
{
|
|
561
|
-
className:
|
|
562
|
-
px-4 py-2 cursor-pointer transition-colors duration-150 flex items-center justify-between
|
|
563
|
-
text-[var(--dd-option-text)]
|
|
564
|
-
${C}
|
|
565
|
-
${l ? B : ""}
|
|
566
|
-
`,
|
|
510
|
+
className: `${D} ${l ? v : ""}`,
|
|
567
511
|
style: {
|
|
568
|
-
|
|
569
|
-
|
|
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,
|
|
570
516
|
fontWeight: l ? 500 : 400
|
|
571
517
|
},
|
|
572
|
-
onMouseEnter: () =>
|
|
518
|
+
onMouseEnter: () => y(o),
|
|
573
519
|
role: "option",
|
|
574
520
|
"aria-selected": l,
|
|
575
|
-
onClick: (
|
|
521
|
+
onClick: (O) => N(e, O),
|
|
576
522
|
children: [
|
|
577
|
-
/* @__PURE__ */
|
|
578
|
-
/* @__PURE__ */
|
|
579
|
-
|
|
523
|
+
/* @__PURE__ */ h("div", { style: t.optionContent, children: [
|
|
524
|
+
/* @__PURE__ */ r("span", { children: e[m] }),
|
|
525
|
+
e[P] && /* @__PURE__ */ r(
|
|
580
526
|
"span",
|
|
581
527
|
{
|
|
582
|
-
className:
|
|
583
|
-
|
|
528
|
+
className: _,
|
|
529
|
+
style: t.sublabel,
|
|
530
|
+
children: e[P]
|
|
584
531
|
}
|
|
585
532
|
)
|
|
586
533
|
] }),
|
|
587
|
-
l && /* @__PURE__ */
|
|
534
|
+
l && /* @__PURE__ */ r(
|
|
588
535
|
"svg",
|
|
589
536
|
{
|
|
590
|
-
|
|
591
|
-
|
|
537
|
+
style: {
|
|
538
|
+
...t.checkIcon,
|
|
539
|
+
color: s.selectedOptionTextColor
|
|
540
|
+
},
|
|
592
541
|
fill: "none",
|
|
593
542
|
stroke: "currentColor",
|
|
594
543
|
viewBox: "0 0 24 24",
|
|
595
|
-
children: /* @__PURE__ */
|
|
544
|
+
children: /* @__PURE__ */ r(
|
|
596
545
|
"path",
|
|
597
546
|
{
|
|
598
547
|
strokeLinecap: "round",
|
|
@@ -605,7 +554,7 @@ const me = ({
|
|
|
605
554
|
)
|
|
606
555
|
]
|
|
607
556
|
},
|
|
608
|
-
|
|
557
|
+
e[c]
|
|
609
558
|
);
|
|
610
559
|
}) })
|
|
611
560
|
}
|
|
@@ -615,5 +564,5 @@ const me = ({
|
|
|
615
564
|
);
|
|
616
565
|
};
|
|
617
566
|
export {
|
|
618
|
-
|
|
567
|
+
se as Dropdown
|
|
619
568
|
};
|
package/dist/dropdown.umd.js
CHANGED
|
@@ -1,19 +1,5 @@
|
|
|
1
|
-
(function(
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
let
|
|
6
|
-
<%s key={someKey} {...props} />`,c,i,r,i),te[i+c]=!0)}if(i=null,s!==void 0&&(v(s),i=""+s),y(o)&&(v(o.key),i=""+o.key),"key"in o){s={};for(var t in o)t!=="key"&&(s[t]=o[t])}else s=o;return i&&C(s,typeof e=="function"?e.displayName||e.name||"Unknown":e),J(e,i,s,f(),E,M)}function W(e){G(e)?e._store&&(e._store.validated=1):typeof e=="object"&&e!==null&&e.$$typeof===b&&(e._payload.status==="fulfilled"?G(e._payload.value)&&e._payload.value._store&&(e._payload.value._store.validated=1):e._store&&(e._store.validated=1))}function G(e){return typeof e=="object"&&e!==null&&e.$$typeof===L}var _=m,L=Symbol.for("react.transitional.element"),q=Symbol.for("react.portal"),j=Symbol.for("react.fragment"),F=Symbol.for("react.strict_mode"),X=Symbol.for("react.profiler"),ee=Symbol.for("react.consumer"),P=Symbol.for("react.context"),x=Symbol.for("react.forward_ref"),$=Symbol.for("react.suspense"),re=Symbol.for("react.suspense_list"),u=Symbol.for("react.memo"),b=Symbol.for("react.lazy"),B=Symbol.for("react.activity"),V=Symbol.for("react.client.reference"),T=_.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,w=Object.prototype.hasOwnProperty,U=Array.isArray,D=console.createTask?console.createTask:function(){return null};_={react_stack_bottom_frame:function(e){return e()}};var O,Z={},z=_.react_stack_bottom_frame.bind(_,d)(),K=D(S(d)),te={};I.Fragment=j,I.jsx=function(e,o,s){var c=1e4>T.recentlyCreatedOwnerStacks++;return N(e,o,s,!1,c?Error("react-stack-top-frame"):z,c?D(S(e)):K)},I.jsxs=function(e,o,s){var c=1e4>T.recentlyCreatedOwnerStacks++;return N(e,o,s,!0,c?Error("react-stack-top-frame"):z,c?D(S(e)):K)}})()),I}var se;function ce(){return se||(se=1,process.env.NODE_ENV==="production"?H.exports=le():H.exports=ae()),H.exports}var n=ce();const ie=({options:g,value:a,onChange:v,placeholder:S="Select...",multiSelect:f=!1,searchable:d=!1,disabled:y=!1,loading:C=!1,className:Q="",style:J={},theme:N,label:W,labelClassName:G="",optionClassName:_="",selectedOptionClassName:L="",menuClassName:q="",triggerClassName:j="",triggerStyle:F={},arrowIcon:X,arrowIconClassName:ee="",labelField:P="label",valueField:x="value",sublabelField:$="sublabel",sublabelClassName:re=""})=>{const[u,b]=m.useState(!1),[B,V]=m.useState(""),[T,w]=m.useState(-1),U=m.useRef(null),D=m.useRef(null),O=m.useRef(null),Z=m.useMemo(()=>{const r={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=N||{},l=t.selectedOptionTextColor??t.primaryColor??r.selectedOptionTextColor,k=t.selectedOptionBackgroundColor??t.hoverColor??r.selectedOptionBackgroundColor,h=t.multiSelectSelectedOptionTextColor??"#1e40af",R=t.multiSelectSelectedOptionBackgroundColor??"#dbeafe",p={...r,...t,menuBackgroundColor:t.menuBackgroundColor??t.backgroundColor??r.menuBackgroundColor,optionTextColor:t.optionTextColor??t.textColor??r.optionTextColor,selectedOptionTextColor:l,selectedOptionBackgroundColor:k,multiSelectSelectedOptionTextColor:h,multiSelectSelectedOptionBackgroundColor:R,focusBorderColor:t.focusBorderColor??t.primaryColor??r.focusBorderColor};return{"--dd-primary":p.primaryColor,"--dd-bg":p.backgroundColor,"--dd-hover":p.hoverColor,"--dd-text":p.textColor,"--dd-padding":p.padding,"--dd-menu-bg":p.menuBackgroundColor,"--dd-option-text":p.optionTextColor,"--dd-selected-text":p.selectedOptionTextColor,"--dd-selected-bg":p.selectedOptionBackgroundColor,"--dd-multi-selected-text":p.multiSelectSelectedOptionTextColor,"--dd-multi-selected-bg":p.multiSelectSelectedOptionBackgroundColor,"--dd-focus-border":p.focusBorderColor,...J}},[N,J]);m.useEffect(()=>{const r=t=>{U.current&&!U.current.contains(t.target)&&b(!1)};return document.addEventListener("mousedown",r),()=>{document.removeEventListener("mousedown",r)}},[]);const z=()=>{y||(b(!u),u||(w(-1),setTimeout(()=>{d&&O.current&&O.current.focus()},0)))},K=()=>{d?u||(b(!0),w(-1),setTimeout(()=>{O.current&&O.current.focus()},0)):z()},e=(()=>{if(a==null)return[];if(Array.isArray(a))return g.filter(t=>a.includes(t[x]));const r=g.find(t=>t[x]===a);return r?[r]:[]})(),o=(r,t)=>{if(t?.stopPropagation(),r.disabled)return;let l,k;if(f){const h=Array.isArray(a)?a:a?[a]:[];h.includes(r[x])?l=h.filter(p=>p!==r[x]):l=[...h,r[x]],k=g.filter(p=>l.includes(p[x]))}else l=r[x],k=r,b(!1),V("");v&&v(l,k)},s=(r,t)=>{if(t.stopPropagation(),!v)return;const k=(Array.isArray(a)?a:a?[a]:[]).filter(R=>R!==r),h=g.filter(R=>k.includes(R[x]));v(k,h)},c=r=>{if(r.stopPropagation(),u&&d){V(""),b(!1);return}v&&v(f?[]:"",f?[]:[])},E=m.useMemo(()=>g.filter(r=>!d||!B?!0:(typeof r[P]=="string"?r[P]:String(r[x])).toLowerCase().includes(B.toLowerCase())),[g,d,B]),M=r=>{if(!y)switch(r.key){case"Enter":r.preventDefault(),u?T>=0&&T<E.length&&o(E[T]):b(!0);break;case"Escape":u&&(r.preventDefault(),b(!1));break;case"ArrowDown":r.preventDefault(),u?w(t=>t<E.length-1?t+1:t):(b(!0),w(0));break;case"ArrowUp":r.preventDefault(),u&&w(t=>t>0?t-1:t);break}};m.useEffect(()=>{if(u&&D.current&&T>=0){const r=D.current,t=r.children[T];if(t){const l=r.scrollTop,k=l+r.clientHeight,h=t.offsetTop,R=h+t.clientHeight;h<l?r.scrollTop=h:R>k&&(r.scrollTop=R-r.clientHeight)}}},[T,u]);const i=r=>Array.isArray(a)?a.includes(r):a===r;return n.jsxs("div",{ref:U,className:`relative w-full ${Q} ${y?"opacity-60 cursor-not-allowed":""}`,style:Z,onKeyDown:M,children:[W&&n.jsx("label",{className:`block mb-1 text-sm font-medium text-gray-700 cursor-pointer ${G}`,onClick:z,style:N?{color:N.textColor}:void 0,children:W}),n.jsxs("div",{onClick:K,className:`
|
|
7
|
-
flex items-center justify-between
|
|
8
|
-
w-full
|
|
9
|
-
bg-[var(--dd-bg)]
|
|
10
|
-
cursor-pointer
|
|
11
|
-
transition-all duration-200
|
|
12
|
-
text-[var(--dd-text)]
|
|
13
|
-
${j||"border rounded-lg"}
|
|
14
|
-
`,style:{padding:j?void 0:"var(--dd-padding)",minHeight:j?void 0:"42px",borderColor:j?void 0:u?"var(--dd-focus-border)":"#d1d5db",outline:"none",...F},role:"button",tabIndex:d?-1:0,"aria-haspopup":"listbox","aria-expanded":u,children:[n.jsx("div",{className:"flex flex-wrap gap-1 flex-1 overflow-hidden",children:d&&(u||e.length===0)?n.jsx("input",{ref:O,type:"text",value:B,onChange:r=>V(r.target.value),onKeyDown:M,placeholder:e.length===0?S:"Search...",className:"flex-1 outline-none bg-transparent min-w-[60px]",onClick:r=>{r.stopPropagation(),u||b(!0)},disabled:y}):e.length===0?n.jsx("span",{className:"text-gray-400",children:S}):f?e.map(r=>n.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:[r[P],n.jsx("span",{className:"ml-1 cursor-pointer font-bold",style:{color:"currentColor",opacity:.8},onClick:t=>s(r[x],t),children:"×"})]},r[x])):n.jsx("span",{className:"truncate",children:e[0][P]})}),n.jsxs("div",{className:"flex items-center gap-2 ml-2",children:[C&&n.jsx("div",{className:"animate-spin h-4 w-4 border-2 border-[var(--dd-primary)] border-t-transparent rounded-full"}),!C&&!y&&(e.length>0||u&&d&&B)&&n.jsx("div",{onClick:c,className:"p-1 hover:bg-gray-100 rounded-full transition-colors z-10",title:u&&d?"Clear search":"Clear selection",children:n.jsx("svg",{className:"w-3 h-3 text-gray-400 hover:text-gray-600",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:n.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})}),n.jsx("div",{className:`transform transition-transform duration-200 ${u?"rotate-180":""} ${ee}`,children:X||n.jsx("svg",{className:"w-4 h-4 text-gray-500",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:n.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})})})]})]}),u&&n.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 ${q}`,children:C?n.jsxs("div",{className:"px-4 py-8 flex justify-center items-center text-gray-400",children:[n.jsx("div",{className:"animate-spin h-6 w-6 border-2 border-[var(--dd-primary)] border-t-transparent rounded-full mr-2"}),"Loading options..."]}):n.jsx("ul",{ref:D,className:"py-1 overflow-y-auto",role:"listbox",children:E.length===0?n.jsx("li",{className:"px-4 py-2 text-gray-500 text-center text-sm",children:"No options found"}):E.map((r,t)=>{const l=i(r[x]),k=t===T;return n.jsxs("li",{className:`
|
|
15
|
-
px-4 py-2 cursor-pointer transition-colors duration-150 flex items-center justify-between
|
|
16
|
-
text-[var(--dd-option-text)]
|
|
17
|
-
${_}
|
|
18
|
-
${l?L:""}
|
|
19
|
-
`,style:{backgroundColor:l&&L?void 0:k&&!_?"var(--dd-hover)":l?"var(--dd-selected-bg)":_?void 0:"transparent",color:l&&L||_?void 0:l?"var(--dd-selected-text)":"var(--dd-option-text)",fontWeight:l?500:400},onMouseEnter:()=>w(t),role:"option","aria-selected":l,onClick:h=>o(r,h),children:[n.jsxs("div",{className:"flex flex-col",children:[n.jsx("span",{children:r[P]}),r[$]&&n.jsx("span",{className:`text-xs text-gray-500 mt-0.5 ${re}`,children:r[$]})]}),l&&n.jsx("svg",{className:"w-4 h-4",style:{color:"var(--dd-selected-text)"},fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:n.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:3,d:"M5 13l4 4L19 7"})})]},r[x])})})})]})};A.Dropdown=ie,Object.defineProperty(A,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/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./components/Dropdown";
|
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",
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
],
|
|
19
19
|
"scripts": {
|
|
20
20
|
"dev": "vite",
|
|
21
|
-
"build": "tsc -b && vite build",
|
|
21
|
+
"build": "rimraf dist && tsc -b && vite build",
|
|
22
22
|
"lint": "eslint .",
|
|
23
23
|
"preview": "vite preview"
|
|
24
24
|
},
|
|
@@ -59,7 +59,6 @@
|
|
|
59
59
|
"react": "^18.0.0 || ^19.0.0",
|
|
60
60
|
"react-dom": "^18.0.0 || ^19.0.0"
|
|
61
61
|
},
|
|
62
|
-
"dependencies": {},
|
|
63
62
|
"devDependencies": {
|
|
64
63
|
"@eslint/js": "^9.39.1",
|
|
65
64
|
"@types/node": "^24.10.1",
|
|
@@ -74,6 +73,7 @@
|
|
|
74
73
|
"postcss": "^8.5.6",
|
|
75
74
|
"react": "^19.2.0",
|
|
76
75
|
"react-dom": "^19.2.0",
|
|
76
|
+
"rimraf": "^6.1.2",
|
|
77
77
|
"tailwindcss": "^3.4.17",
|
|
78
78
|
"typescript": "~5.9.3",
|
|
79
79
|
"typescript-eslint": "^8.46.4",
|
|
Binary file
|