@addsign/moje-agenda-shared-lib 0.0.28 → 0.0.30
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/assets/tailwind.css +1484 -1
- package/dist/components/Button.js +24 -21
- package/dist/components/Button.js.map +1 -0
- package/dist/components/Calendar.js +89 -57
- package/dist/components/Calendar.js.map +1 -0
- package/dist/components/ConfirmationModalDialog.js +52 -47
- package/dist/components/ConfirmationModalDialog.js.map +1 -0
- package/dist/components/DataTable.js +211 -145
- package/dist/components/DataTable.js.map +1 -0
- package/dist/components/Spinner.js +9 -8
- package/dist/components/Spinner.js.map +1 -0
- package/dist/components/form/AutocompleteSearchBar.js +323 -239
- package/dist/components/form/AutocompleteSearchBar.js.map +1 -0
- package/dist/components/form/FormField.js +171 -142
- package/dist/components/form/FormField.js.map +1 -0
- package/dist/components/form/PositionsSelectorSingle.js +143 -113
- package/dist/components/form/PositionsSelectorSingle.js.map +1 -0
- package/dist/components/layout/PageTitle.js +9 -8
- package/dist/components/layout/PageTitle.js.map +1 -0
- package/dist/components/layout/SectionTitle.js +9 -8
- package/dist/components/layout/SectionTitle.js.map +1 -0
- package/dist/contexts/FederationContext.js +12 -8
- package/dist/contexts/FederationContext.js.map +1 -0
- package/dist/contexts/useFederationContext.js +5 -4
- package/dist/contexts/useFederationContext.js.map +1 -0
- package/dist/iconBase-BY_L6Cb_.js +144 -0
- package/dist/iconBase-BY_L6Cb_.js.map +1 -0
- package/dist/index-C0yNf1cc.js +48 -0
- package/dist/index-C0yNf1cc.js.map +1 -0
- package/dist/main.js +29 -28
- package/dist/main.js.map +1 -0
- package/dist/types.d.ts +7 -3
- package/dist/types.js +1 -0
- package/dist/types.js.map +1 -0
- package/dist/utils/getFullName.js +9 -3
- package/dist/utils/getFullName.js.map +1 -0
- package/package.json +1 -1
- package/dist/iconBase-DkR9t2l_.js +0 -117
- package/dist/index-CO5g84CR.js +0 -47
|
@@ -1,316 +1,400 @@
|
|
|
1
|
-
import { jsxs
|
|
2
|
-
import { useRef
|
|
1
|
+
import { jsxs, jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useRef, useEffect, useState } from "react";
|
|
3
3
|
import '../../assets/tailwind.css';/* empty css */
|
|
4
|
-
import { i as
|
|
4
|
+
import { i as MdExpandLess, j as MdExpandMore, c as MdClose } from "../../index-C0yNf1cc.js";
|
|
5
5
|
import "../../contexts/FederationContext.js";
|
|
6
|
-
import { useFederationContext
|
|
7
|
-
function
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
6
|
+
import { useFederationContext } from "../../contexts/useFederationContext.js";
|
|
7
|
+
function on(obj) {
|
|
8
|
+
var args = [];
|
|
9
|
+
for (var _i = 1; _i < arguments.length; _i++) {
|
|
10
|
+
args[_i - 1] = arguments[_i];
|
|
11
|
+
}
|
|
12
|
+
if (obj && obj.addEventListener) {
|
|
13
|
+
obj.addEventListener.apply(obj, args);
|
|
14
|
+
}
|
|
11
15
|
}
|
|
12
|
-
function
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
+
function off(obj) {
|
|
17
|
+
var args = [];
|
|
18
|
+
for (var _i = 1; _i < arguments.length; _i++) {
|
|
19
|
+
args[_i - 1] = arguments[_i];
|
|
20
|
+
}
|
|
21
|
+
if (obj && obj.removeEventListener) {
|
|
22
|
+
obj.removeEventListener.apply(obj, args);
|
|
23
|
+
}
|
|
16
24
|
}
|
|
17
|
-
var
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
25
|
+
var defaultEvents = ["mousedown", "touchstart"];
|
|
26
|
+
var useClickAway = function(ref, onClickAway, events) {
|
|
27
|
+
if (events === void 0) {
|
|
28
|
+
events = defaultEvents;
|
|
29
|
+
}
|
|
30
|
+
var savedCallback = useRef(onClickAway);
|
|
31
|
+
useEffect(function() {
|
|
32
|
+
savedCallback.current = onClickAway;
|
|
33
|
+
}, [onClickAway]);
|
|
34
|
+
useEffect(function() {
|
|
35
|
+
var handler = function(event) {
|
|
36
|
+
var el = ref.current;
|
|
37
|
+
el && !el.contains(event.target) && savedCallback.current(event);
|
|
38
|
+
};
|
|
39
|
+
for (var _i = 0, events_1 = events; _i < events_1.length; _i++) {
|
|
40
|
+
var eventName = events_1[_i];
|
|
41
|
+
on(document, eventName, handler);
|
|
29
42
|
}
|
|
30
43
|
return function() {
|
|
31
|
-
for (var
|
|
32
|
-
var
|
|
33
|
-
|
|
44
|
+
for (var _i2 = 0, events_2 = events; _i2 < events_2.length; _i2++) {
|
|
45
|
+
var eventName2 = events_2[_i2];
|
|
46
|
+
off(document, eventName2, handler);
|
|
34
47
|
}
|
|
35
48
|
};
|
|
36
|
-
}, [
|
|
49
|
+
}, [events, ref]);
|
|
37
50
|
};
|
|
38
|
-
const
|
|
39
|
-
label
|
|
40
|
-
name
|
|
41
|
-
required
|
|
42
|
-
disabled
|
|
43
|
-
description
|
|
44
|
-
fetchUrl
|
|
45
|
-
valueKey
|
|
46
|
-
labelKey
|
|
47
|
-
onChange
|
|
48
|
-
onFocus
|
|
49
|
-
onBlur
|
|
50
|
-
placeholder
|
|
51
|
-
serverSearch
|
|
52
|
-
value
|
|
53
|
-
initOptions
|
|
54
|
-
showId
|
|
51
|
+
const AutocompleteSearchBar = ({
|
|
52
|
+
label,
|
|
53
|
+
name,
|
|
54
|
+
required,
|
|
55
|
+
disabled,
|
|
56
|
+
description,
|
|
57
|
+
fetchUrl,
|
|
58
|
+
valueKey,
|
|
59
|
+
labelKey,
|
|
60
|
+
onChange,
|
|
61
|
+
onFocus,
|
|
62
|
+
onBlur,
|
|
63
|
+
placeholder,
|
|
64
|
+
serverSearch = false,
|
|
65
|
+
value,
|
|
66
|
+
initOptions,
|
|
67
|
+
showId
|
|
55
68
|
}) => {
|
|
56
|
-
var
|
|
57
|
-
const [
|
|
69
|
+
var _a, _b;
|
|
70
|
+
const [query, setQuery] = useState("");
|
|
71
|
+
const [loading, setLoading] = useState(false);
|
|
72
|
+
const [options, setOptions] = useState([]);
|
|
73
|
+
const [selectedOptionIndex, setSelectedOptionIndex] = useState(-1);
|
|
74
|
+
const [selectedOption, setSelectedOption] = useState(
|
|
58
75
|
null
|
|
59
|
-
)
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
76
|
+
);
|
|
77
|
+
const [searchResults, setSearchResults] = useState([]);
|
|
78
|
+
const inputRef = useRef(null);
|
|
79
|
+
const ref = useRef(null);
|
|
80
|
+
const federationContext = useFederationContext();
|
|
81
|
+
const [isFocused, setIsFocused] = useState(false);
|
|
82
|
+
const [errors] = useState({});
|
|
83
|
+
useEffect(() => {
|
|
84
|
+
const fetchOptions = async () => {
|
|
85
|
+
setLoading(true);
|
|
86
|
+
console.log(
|
|
63
87
|
"%csrcsharedAutocompleteSearchBar.tsx:77 fetchUrl, value",
|
|
64
88
|
"color: #007acc;",
|
|
65
|
-
|
|
89
|
+
fetchUrl
|
|
66
90
|
);
|
|
67
|
-
const { data
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
91
|
+
const { data } = await federationContext.apiClient.get(fetchUrl || "");
|
|
92
|
+
const tmpData = data.content || data;
|
|
93
|
+
setOptions(
|
|
94
|
+
tmpData.map((item) => ({
|
|
95
|
+
value: item[valueKey],
|
|
96
|
+
label: item[labelKey] + (showId ? " (" + item[valueKey] + ")" : "")
|
|
72
97
|
}))
|
|
73
|
-
)
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
98
|
+
);
|
|
99
|
+
setLoading(false);
|
|
100
|
+
};
|
|
101
|
+
if (fetchUrl)
|
|
102
|
+
fetchOptions();
|
|
103
|
+
}, [fetchUrl]);
|
|
104
|
+
useEffect(() => {
|
|
105
|
+
if (initOptions)
|
|
106
|
+
setOptions(initOptions);
|
|
107
|
+
}, [initOptions]);
|
|
108
|
+
useEffect(() => {
|
|
109
|
+
if (value && options) {
|
|
110
|
+
const initOption = options.find((it) => it.value == value);
|
|
111
|
+
if (initOption) {
|
|
112
|
+
setQuery(initOption.label);
|
|
113
|
+
setSelectedOption(initOption);
|
|
114
|
+
}
|
|
81
115
|
}
|
|
82
|
-
}, [
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
116
|
+
}, [value, options]);
|
|
117
|
+
useEffect(() => {
|
|
118
|
+
const fetchOptions = async () => {
|
|
119
|
+
setLoading(true);
|
|
120
|
+
const { data } = await federationContext.apiClient.get(fetchUrl + query);
|
|
121
|
+
setOptions(
|
|
122
|
+
data.map((item) => ({
|
|
123
|
+
value: item[valueKey],
|
|
124
|
+
label: item[labelKey] + (showId ? " (" + item[valueKey] + ")" : "")
|
|
90
125
|
}))
|
|
91
|
-
)
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
126
|
+
);
|
|
127
|
+
setSearchResults(
|
|
128
|
+
data.map((item) => ({
|
|
129
|
+
value: item[valueKey],
|
|
130
|
+
label: item[labelKey] + (showId ? " (" + item[valueKey] + ")" : "")
|
|
95
131
|
}))
|
|
96
|
-
)
|
|
97
|
-
|
|
132
|
+
);
|
|
133
|
+
setLoading(false);
|
|
134
|
+
};
|
|
135
|
+
if (serverSearch)
|
|
136
|
+
fetchOptions();
|
|
98
137
|
}, [
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
])
|
|
107
|
-
|
|
138
|
+
query,
|
|
139
|
+
serverSearch,
|
|
140
|
+
valueKey,
|
|
141
|
+
labelKey,
|
|
142
|
+
fetchUrl,
|
|
143
|
+
federationContext.apiClient,
|
|
144
|
+
showId
|
|
145
|
+
]);
|
|
146
|
+
useClickAway(ref, () => {
|
|
147
|
+
setSearchResults([]);
|
|
148
|
+
if (!selectedOption) {
|
|
149
|
+
setQuery("");
|
|
150
|
+
onChange(null);
|
|
151
|
+
}
|
|
152
|
+
handleBlur();
|
|
108
153
|
});
|
|
109
|
-
const
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
154
|
+
const handleQueryChange = (event) => {
|
|
155
|
+
setQuery(event.target.value);
|
|
156
|
+
setSelectedOption(null);
|
|
157
|
+
setSelectedOptionIndex(-1);
|
|
158
|
+
setSearchResults(
|
|
159
|
+
options.filter(
|
|
160
|
+
(option) => {
|
|
161
|
+
var _a2, _b2, _c;
|
|
162
|
+
return (_c = option == null ? void 0 : option.label) == null ? void 0 : _c.toLowerCase().includes((_b2 = (_a2 = event.target) == null ? void 0 : _a2.value) == null ? void 0 : _b2.toLowerCase());
|
|
115
163
|
}
|
|
116
164
|
)
|
|
117
165
|
);
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
|
|
166
|
+
};
|
|
167
|
+
const handleFocus = () => {
|
|
168
|
+
console.log("handleFocus query", query);
|
|
169
|
+
setIsFocused(true);
|
|
170
|
+
onFocus();
|
|
171
|
+
setSearchResults(
|
|
172
|
+
options
|
|
121
173
|
/*.filter((option) =>
|
|
122
174
|
option.label.toLowerCase().includes(query.toLowerCase()),
|
|
123
175
|
),*/
|
|
124
176
|
);
|
|
125
|
-
}
|
|
177
|
+
};
|
|
178
|
+
const handleClearQuery = () => {
|
|
126
179
|
console.log(
|
|
127
180
|
"%csrcsharedAutocompleteSearchBar.tsx:95 handleClearQuery",
|
|
128
181
|
"color: #007acc;"
|
|
129
|
-
)
|
|
130
|
-
|
|
182
|
+
);
|
|
183
|
+
setQuery("");
|
|
184
|
+
onChange(null);
|
|
185
|
+
setSelectedOption(null);
|
|
186
|
+
setTimeout(() => {
|
|
187
|
+
setSelectedOptionIndex(-1);
|
|
188
|
+
setSearchResults(options);
|
|
131
189
|
}, 1e3);
|
|
132
|
-
}, I = (l) => {
|
|
133
|
-
l.key === "ArrowUp" && g.length > 0 ? b(
|
|
134
|
-
(s) => s > 0 ? s - 1 : g.length - 1
|
|
135
|
-
) : l.key === "ArrowDown" && g.length > 0 ? b(
|
|
136
|
-
(s) => s < g.length - 1 ? s + 1 : 0
|
|
137
|
-
) : l.key === "Enter" && Q !== -1 ? T(g[Q]) : l.key === "Escape" && Q !== -1 && $();
|
|
138
|
-
}, T = (l) => {
|
|
139
|
-
C(l.label), S(l), b(-1), i(l.value), $();
|
|
140
|
-
}, $ = () => {
|
|
141
|
-
y([]), k(), z(!1);
|
|
142
190
|
};
|
|
143
|
-
|
|
144
|
-
|
|
191
|
+
const handleKeyDown = (event) => {
|
|
192
|
+
if (event.key === "ArrowUp" && searchResults.length > 0) {
|
|
193
|
+
setSelectedOptionIndex(
|
|
194
|
+
(prevIndex) => prevIndex > 0 ? prevIndex - 1 : searchResults.length - 1
|
|
195
|
+
);
|
|
196
|
+
} else if (event.key === "ArrowDown" && searchResults.length > 0) {
|
|
197
|
+
setSelectedOptionIndex(
|
|
198
|
+
(prevIndex) => prevIndex < searchResults.length - 1 ? prevIndex + 1 : 0
|
|
199
|
+
);
|
|
200
|
+
} else if (event.key === "Enter" && selectedOptionIndex !== -1) {
|
|
201
|
+
handleOptionClick(searchResults[selectedOptionIndex]);
|
|
202
|
+
} else if (event.key === "Escape" && selectedOptionIndex !== -1) {
|
|
203
|
+
handleBlur();
|
|
204
|
+
}
|
|
205
|
+
};
|
|
206
|
+
const handleOptionClick = (option) => {
|
|
207
|
+
setQuery(option.label);
|
|
208
|
+
setSelectedOption(option);
|
|
209
|
+
setSelectedOptionIndex(-1);
|
|
210
|
+
onChange(option.value);
|
|
211
|
+
handleBlur();
|
|
212
|
+
};
|
|
213
|
+
const handleBlur = () => {
|
|
214
|
+
setSearchResults([]);
|
|
215
|
+
onBlur();
|
|
216
|
+
setIsFocused(false);
|
|
217
|
+
};
|
|
218
|
+
return /* @__PURE__ */ jsxs("div", { className: "w-full min-h-20 flex-col justify-start items-start gap-1.5 inline-flex", children: [
|
|
219
|
+
/* @__PURE__ */ jsxs(
|
|
145
220
|
"div",
|
|
146
221
|
{
|
|
147
222
|
className: "self-stretch min-h-14 flex-col justify-start items-start gap-1.5 flex relative",
|
|
148
|
-
ref
|
|
223
|
+
ref,
|
|
149
224
|
children: [
|
|
150
|
-
/* @__PURE__ */
|
|
225
|
+
/* @__PURE__ */ jsxs(
|
|
151
226
|
"label",
|
|
152
227
|
{
|
|
153
228
|
className: "text-slate-700 text-sm leading-tight font-medium",
|
|
154
|
-
htmlFor:
|
|
229
|
+
htmlFor: name,
|
|
155
230
|
children: [
|
|
156
|
-
|
|
231
|
+
label,
|
|
157
232
|
" ",
|
|
158
|
-
|
|
233
|
+
required ? "*" : ""
|
|
159
234
|
]
|
|
160
235
|
}
|
|
161
236
|
),
|
|
162
|
-
/* @__PURE__ */
|
|
237
|
+
/* @__PURE__ */ jsx(
|
|
163
238
|
"div",
|
|
164
239
|
{
|
|
165
240
|
className: `self-stretch px-3 py-1.5 rounded-lg justify-start items-center gap-2 inline-flex outline-none border
|
|
166
|
-
${
|
|
167
|
-
${
|
|
168
|
-
${!
|
|
169
|
-
${
|
|
170
|
-
children: /* @__PURE__ */
|
|
171
|
-
|
|
241
|
+
${isFocused ? "outline-4 outline-indigo-200 outline-offset-0 border-indigo-300" : ""}
|
|
242
|
+
${isFocused && ((_a = errors[name]) == null ? void 0 : _a.message) ? "outline-4 outline-red-200 outline-offset-0 border-none" : ""}
|
|
243
|
+
${!isFocused && ((_b = errors[name]) == null ? void 0 : _b.message) ? "border-red-200" : ""}
|
|
244
|
+
${disabled ? "bg-gray-100" : "bg-transparent"}`,
|
|
245
|
+
children: /* @__PURE__ */ jsx("div", { className: "Content grow shrink basis-0 min-h-5 xl:min-h-8 justify-start items-start gap-2 flex relative flex-col w-full mx-auto", children: /* @__PURE__ */ jsx(
|
|
246
|
+
SearchInput,
|
|
172
247
|
{
|
|
173
|
-
value:
|
|
174
|
-
onChange:
|
|
175
|
-
onKeyDown:
|
|
176
|
-
onFocus:
|
|
177
|
-
clearQuery:
|
|
178
|
-
inputRef
|
|
179
|
-
placeholder
|
|
180
|
-
isFocused
|
|
181
|
-
onBlur:
|
|
182
|
-
isLoading:
|
|
248
|
+
value: query,
|
|
249
|
+
onChange: handleQueryChange,
|
|
250
|
+
onKeyDown: handleKeyDown,
|
|
251
|
+
onFocus: handleFocus,
|
|
252
|
+
clearQuery: handleClearQuery,
|
|
253
|
+
inputRef,
|
|
254
|
+
placeholder,
|
|
255
|
+
isFocused,
|
|
256
|
+
onBlur: handleBlur,
|
|
257
|
+
isLoading: loading
|
|
183
258
|
}
|
|
184
259
|
) })
|
|
185
260
|
}
|
|
186
261
|
),
|
|
187
|
-
|
|
188
|
-
|
|
262
|
+
searchResults.length > 0 && /* @__PURE__ */ jsx(
|
|
263
|
+
OptionList,
|
|
189
264
|
{
|
|
190
|
-
options:
|
|
191
|
-
selectedOptionIndex
|
|
192
|
-
handleOptionClick
|
|
265
|
+
options: searchResults,
|
|
266
|
+
selectedOptionIndex,
|
|
267
|
+
handleOptionClick
|
|
193
268
|
}
|
|
194
269
|
)
|
|
195
270
|
]
|
|
196
271
|
}
|
|
197
272
|
),
|
|
198
|
-
|
|
273
|
+
description && /* @__PURE__ */ jsx("div", { className: "HintText self-stretch text-slate-600 text-sm font-normal leading-tight", children: description })
|
|
199
274
|
] });
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
275
|
+
};
|
|
276
|
+
const OptionList = ({
|
|
277
|
+
options,
|
|
278
|
+
selectedOptionIndex,
|
|
279
|
+
handleOptionClick
|
|
204
280
|
}) => {
|
|
205
|
-
const
|
|
206
|
-
|
|
207
|
-
var
|
|
208
|
-
if (
|
|
209
|
-
const
|
|
210
|
-
|
|
281
|
+
const containerRef = useRef(null);
|
|
282
|
+
useEffect(() => {
|
|
283
|
+
var _a;
|
|
284
|
+
if (selectedOptionIndex >= 0 && selectedOptionIndex < options.length) {
|
|
285
|
+
const selectedElement = (_a = containerRef.current) == null ? void 0 : _a.children[selectedOptionIndex];
|
|
286
|
+
selectedElement == null ? void 0 : selectedElement.scrollIntoView({
|
|
211
287
|
behavior: "instant",
|
|
212
288
|
block: "nearest"
|
|
213
289
|
});
|
|
214
290
|
}
|
|
215
|
-
}, [
|
|
291
|
+
}, [selectedOptionIndex, options.length]);
|
|
292
|
+
return /* @__PURE__ */ jsx(
|
|
216
293
|
"div",
|
|
217
294
|
{
|
|
218
|
-
ref:
|
|
295
|
+
ref: containerRef,
|
|
219
296
|
className: "overflow-y-auto resultOptionContainer w-full max-h-96 absolute outline-4 bg-white border border-gray-200 drop-shadow-xl rounded-xl z-50 top-[73px]",
|
|
220
|
-
children:
|
|
297
|
+
children: options == null ? void 0 : options.map((option, index) => /* @__PURE__ */ jsx(
|
|
221
298
|
"div",
|
|
222
299
|
{
|
|
223
|
-
className: `py-2 px-4 flex items-center justify-between gap-8 hover:bg-gray-200 cursor-pointer ${
|
|
224
|
-
onClick: () =>
|
|
225
|
-
children: /* @__PURE__ */
|
|
300
|
+
className: `py-2 px-4 flex items-center justify-between gap-8 hover:bg-gray-200 cursor-pointer ${selectedOptionIndex === index ? "bg-gray-200" : ""}`,
|
|
301
|
+
onClick: () => handleOptionClick(option),
|
|
302
|
+
children: /* @__PURE__ */ jsx("p", { className: "font-normal", children: option.label })
|
|
226
303
|
},
|
|
227
|
-
|
|
304
|
+
option.value
|
|
228
305
|
))
|
|
229
306
|
}
|
|
230
307
|
);
|
|
231
|
-
}
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
/* @__PURE__ */ n(
|
|
266
|
-
"circle",
|
|
267
|
-
{
|
|
268
|
-
className: "opacity-25",
|
|
269
|
-
cx: "12",
|
|
270
|
-
cy: "12",
|
|
271
|
-
r: "10",
|
|
272
|
-
stroke: "currentColor",
|
|
273
|
-
strokeWidth: "4"
|
|
274
|
-
}
|
|
275
|
-
),
|
|
276
|
-
/* @__PURE__ */ n(
|
|
277
|
-
"path",
|
|
278
|
-
{
|
|
279
|
-
className: "opacity-75",
|
|
280
|
-
fill: "currentColor",
|
|
281
|
-
d: "M4 12a8 8 0 018-8v4a4 4 0 00-4 4H4z"
|
|
282
|
-
}
|
|
283
|
-
)
|
|
284
|
-
]
|
|
285
|
-
}
|
|
286
|
-
) }),
|
|
287
|
-
i && !c && /* @__PURE__ */ n(
|
|
288
|
-
K,
|
|
289
|
-
{
|
|
290
|
-
className: "material-icons absolute right-0 cursor-pointer text-gray-500",
|
|
291
|
-
onClick: o
|
|
292
|
-
}
|
|
293
|
-
),
|
|
294
|
-
!i && !c && /* @__PURE__ */ n(
|
|
295
|
-
_,
|
|
296
|
-
{
|
|
297
|
-
className: "material-icons absolute right-0 cursor-pointer text-gray-500",
|
|
298
|
-
onClick: () => {
|
|
299
|
-
var w;
|
|
300
|
-
(w = a.current) == null || w.focus(), d();
|
|
308
|
+
};
|
|
309
|
+
const SearchInput = ({
|
|
310
|
+
value,
|
|
311
|
+
onChange,
|
|
312
|
+
onKeyDown,
|
|
313
|
+
onFocus,
|
|
314
|
+
onBlur,
|
|
315
|
+
inputRef,
|
|
316
|
+
placeholder,
|
|
317
|
+
clearQuery,
|
|
318
|
+
isFocused,
|
|
319
|
+
isLoading
|
|
320
|
+
}) => {
|
|
321
|
+
const handleExpandMoreClick = () => {
|
|
322
|
+
var _a;
|
|
323
|
+
(_a = inputRef.current) == null ? void 0 : _a.focus();
|
|
324
|
+
onFocus();
|
|
325
|
+
};
|
|
326
|
+
const handleClearQuery = () => {
|
|
327
|
+
clearQuery();
|
|
328
|
+
};
|
|
329
|
+
return /* @__PURE__ */ jsxs("div", { className: "relative flex items-center w-full sharedResource", children: [
|
|
330
|
+
/* @__PURE__ */ jsx(
|
|
331
|
+
"input",
|
|
332
|
+
{
|
|
333
|
+
type: "text",
|
|
334
|
+
className: `pl-1 py-1 border-gray-800 w-full ${isLoading ? "pr-10" : "pr-20"}`,
|
|
335
|
+
value,
|
|
336
|
+
onChange,
|
|
337
|
+
onKeyDown,
|
|
338
|
+
onFocus,
|
|
339
|
+
ref: inputRef,
|
|
340
|
+
placeholder,
|
|
341
|
+
disabled: isLoading
|
|
301
342
|
}
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
343
|
+
),
|
|
344
|
+
isLoading && /* @__PURE__ */ jsx("div", { className: "loader absolute right-0 text-gray-500", children: /* @__PURE__ */ jsxs(
|
|
345
|
+
"svg",
|
|
346
|
+
{
|
|
347
|
+
className: "animate-spin h-5 w-5",
|
|
348
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
349
|
+
fill: "none",
|
|
350
|
+
viewBox: "0 0 24 24",
|
|
351
|
+
children: [
|
|
352
|
+
/* @__PURE__ */ jsx(
|
|
353
|
+
"circle",
|
|
354
|
+
{
|
|
355
|
+
className: "opacity-25",
|
|
356
|
+
cx: "12",
|
|
357
|
+
cy: "12",
|
|
358
|
+
r: "10",
|
|
359
|
+
stroke: "currentColor",
|
|
360
|
+
strokeWidth: "4"
|
|
361
|
+
}
|
|
362
|
+
),
|
|
363
|
+
/* @__PURE__ */ jsx(
|
|
364
|
+
"path",
|
|
365
|
+
{
|
|
366
|
+
className: "opacity-75",
|
|
367
|
+
fill: "currentColor",
|
|
368
|
+
d: "M4 12a8 8 0 018-8v4a4 4 0 00-4 4H4z"
|
|
369
|
+
}
|
|
370
|
+
)
|
|
371
|
+
]
|
|
310
372
|
}
|
|
311
|
-
}
|
|
312
|
-
|
|
313
|
-
|
|
373
|
+
) }),
|
|
374
|
+
isFocused && !isLoading && /* @__PURE__ */ jsx(
|
|
375
|
+
MdExpandLess,
|
|
376
|
+
{
|
|
377
|
+
className: "material-icons absolute right-0 cursor-pointer text-gray-500",
|
|
378
|
+
onClick: onBlur
|
|
379
|
+
}
|
|
380
|
+
),
|
|
381
|
+
!isFocused && !isLoading && /* @__PURE__ */ jsx(
|
|
382
|
+
MdExpandMore,
|
|
383
|
+
{
|
|
384
|
+
className: "material-icons absolute right-0 cursor-pointer text-gray-500",
|
|
385
|
+
onClick: handleExpandMoreClick
|
|
386
|
+
}
|
|
387
|
+
),
|
|
388
|
+
value && !isLoading && /* @__PURE__ */ jsx(
|
|
389
|
+
MdClose,
|
|
390
|
+
{
|
|
391
|
+
className: "material-icons absolute right-10 cursor-pointer text-gray-500",
|
|
392
|
+
onClick: handleClearQuery
|
|
393
|
+
}
|
|
394
|
+
)
|
|
395
|
+
] });
|
|
396
|
+
};
|
|
314
397
|
export {
|
|
315
|
-
|
|
398
|
+
AutocompleteSearchBar as default
|
|
316
399
|
};
|
|
400
|
+
//# sourceMappingURL=AutocompleteSearchBar.js.map
|