@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.
Files changed (39) hide show
  1. package/dist/assets/tailwind.css +1484 -1
  2. package/dist/components/Button.js +24 -21
  3. package/dist/components/Button.js.map +1 -0
  4. package/dist/components/Calendar.js +89 -57
  5. package/dist/components/Calendar.js.map +1 -0
  6. package/dist/components/ConfirmationModalDialog.js +52 -47
  7. package/dist/components/ConfirmationModalDialog.js.map +1 -0
  8. package/dist/components/DataTable.js +211 -145
  9. package/dist/components/DataTable.js.map +1 -0
  10. package/dist/components/Spinner.js +9 -8
  11. package/dist/components/Spinner.js.map +1 -0
  12. package/dist/components/form/AutocompleteSearchBar.js +323 -239
  13. package/dist/components/form/AutocompleteSearchBar.js.map +1 -0
  14. package/dist/components/form/FormField.js +171 -142
  15. package/dist/components/form/FormField.js.map +1 -0
  16. package/dist/components/form/PositionsSelectorSingle.js +143 -113
  17. package/dist/components/form/PositionsSelectorSingle.js.map +1 -0
  18. package/dist/components/layout/PageTitle.js +9 -8
  19. package/dist/components/layout/PageTitle.js.map +1 -0
  20. package/dist/components/layout/SectionTitle.js +9 -8
  21. package/dist/components/layout/SectionTitle.js.map +1 -0
  22. package/dist/contexts/FederationContext.js +12 -8
  23. package/dist/contexts/FederationContext.js.map +1 -0
  24. package/dist/contexts/useFederationContext.js +5 -4
  25. package/dist/contexts/useFederationContext.js.map +1 -0
  26. package/dist/iconBase-BY_L6Cb_.js +144 -0
  27. package/dist/iconBase-BY_L6Cb_.js.map +1 -0
  28. package/dist/index-C0yNf1cc.js +48 -0
  29. package/dist/index-C0yNf1cc.js.map +1 -0
  30. package/dist/main.js +29 -28
  31. package/dist/main.js.map +1 -0
  32. package/dist/types.d.ts +7 -3
  33. package/dist/types.js +1 -0
  34. package/dist/types.js.map +1 -0
  35. package/dist/utils/getFullName.js +9 -3
  36. package/dist/utils/getFullName.js.map +1 -0
  37. package/package.json +1 -1
  38. package/dist/iconBase-DkR9t2l_.js +0 -117
  39. package/dist/index-CO5g84CR.js +0 -47
@@ -1,316 +1,400 @@
1
- import { jsxs as N, jsx as n } from "react/jsx-runtime";
2
- import { useRef as F, useEffect as p, useState as m } from "react";
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 K, j as _, c as ee } from "../../index-CO5g84CR.js";
4
+ import { i as MdExpandLess, j as MdExpandMore, c as MdClose } from "../../index-C0yNf1cc.js";
5
5
  import "../../contexts/FederationContext.js";
6
- import { useFederationContext as te } from "../../contexts/useFederationContext.js";
7
- function re(e) {
8
- for (var t = [], r = 1; r < arguments.length; r++)
9
- t[r - 1] = arguments[r];
10
- e && e.addEventListener && e.addEventListener.apply(e, t);
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 ae(e) {
13
- for (var t = [], r = 1; r < arguments.length; r++)
14
- t[r - 1] = arguments[r];
15
- e && e.removeEventListener && e.removeEventListener.apply(e, t);
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 le = ["mousedown", "touchstart"], se = function(e, t, r) {
18
- r === void 0 && (r = le);
19
- var d = F(t);
20
- p(function() {
21
- d.current = t;
22
- }, [t]), p(function() {
23
- for (var o = function(i) {
24
- var c = e.current;
25
- c && !c.contains(i.target) && d.current(i);
26
- }, a = 0, u = r; a < u.length; a++) {
27
- var h = u[a];
28
- re(document, h, o);
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 i = 0, c = r; i < c.length; i++) {
32
- var k = c[i];
33
- ae(document, k, o);
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
- }, [r, e]);
49
+ }, [events, ref]);
37
50
  };
38
- const me = ({
39
- label: e,
40
- name: t,
41
- required: r,
42
- disabled: d,
43
- description: o,
44
- fetchUrl: a,
45
- valueKey: u,
46
- labelKey: h,
47
- onChange: i,
48
- onFocus: c,
49
- onBlur: k,
50
- placeholder: j,
51
- serverSearch: w = !1,
52
- value: L,
53
- initOptions: R,
54
- showId: E
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 V, W;
57
- const [M, C] = m(""), [J, O] = m(!1), [x, A] = m([]), [Q, b] = m(-1), [P, S] = m(
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
- ), [g, y] = m([]), X = F(null), q = F(null), D = te(), [B, z] = m(!1), [H] = m({});
60
- p(() => {
61
- a && (async () => {
62
- O(!0), console.log(
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
- a
89
+ fetchUrl
66
90
  );
67
- const { data: s } = await D.apiClient.get(a || ""), f = s.content || s;
68
- A(
69
- f.map((v) => ({
70
- value: v[u],
71
- label: v[h] + (E ? " (" + v[u] + ")" : "")
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
- ), O(!1);
74
- })();
75
- }, [a]), p(() => {
76
- R && A(R);
77
- }, [R]), p(() => {
78
- if (L && x) {
79
- const l = x.find((s) => s.value == L);
80
- l && (C(l.label), S(l));
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
- }, [L, x]), p(() => {
83
- w && (async () => {
84
- O(!0);
85
- const { data: s } = await D.apiClient.get(a + M);
86
- A(
87
- s.map((f) => ({
88
- value: f[u],
89
- label: f[h] + (E ? " (" + f[u] + ")" : "")
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
- ), y(
92
- s.map((f) => ({
93
- value: f[u],
94
- label: f[h] + (E ? " (" + f[u] + ")" : "")
126
+ );
127
+ setSearchResults(
128
+ data.map((item) => ({
129
+ value: item[valueKey],
130
+ label: item[labelKey] + (showId ? " (" + item[valueKey] + ")" : "")
95
131
  }))
96
- ), O(!1);
97
- })();
132
+ );
133
+ setLoading(false);
134
+ };
135
+ if (serverSearch)
136
+ fetchOptions();
98
137
  }, [
99
- M,
100
- w,
101
- u,
102
- h,
103
- a,
104
- D.apiClient,
105
- E
106
- ]), se(q, () => {
107
- y([]), P || (C(""), i(null)), $();
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 Y = (l) => {
110
- C(l.target.value), S(null), b(-1), y(
111
- x.filter(
112
- (s) => {
113
- var f, v, G;
114
- return (G = s == null ? void 0 : s.label) == null ? void 0 : G.toLowerCase().includes((v = (f = l.target) == null ? void 0 : f.value) == null ? void 0 : v.toLowerCase());
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
- }, Z = () => {
119
- console.log("handleFocus query", M), z(!0), c(), y(
120
- x
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
- }, U = () => {
177
+ };
178
+ const handleClearQuery = () => {
126
179
  console.log(
127
180
  "%csrcsharedAutocompleteSearchBar.tsx:95 handleClearQuery",
128
181
  "color: #007acc;"
129
- ), C(""), i(null), S(null), setTimeout(() => {
130
- b(-1), y(x);
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
- return /* @__PURE__ */ N("div", { className: "w-full min-h-20 flex-col justify-start items-start gap-1.5 inline-flex", children: [
144
- /* @__PURE__ */ N(
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: q,
223
+ ref,
149
224
  children: [
150
- /* @__PURE__ */ N(
225
+ /* @__PURE__ */ jsxs(
151
226
  "label",
152
227
  {
153
228
  className: "text-slate-700 text-sm leading-tight font-medium",
154
- htmlFor: t,
229
+ htmlFor: name,
155
230
  children: [
156
- e,
231
+ label,
157
232
  " ",
158
- r ? "*" : ""
233
+ required ? "*" : ""
159
234
  ]
160
235
  }
161
236
  ),
162
- /* @__PURE__ */ n(
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
- ${B ? "outline-4 outline-indigo-200 outline-offset-0 border-indigo-300" : ""}
167
- ${B && ((V = H[t]) != null && V.message) ? "outline-4 outline-red-200 outline-offset-0 border-none" : ""}
168
- ${!B && ((W = H[t]) != null && W.message) ? "border-red-200" : ""}
169
- ${d ? "bg-gray-100" : "bg-transparent"}`,
170
- children: /* @__PURE__ */ n("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__ */ n(
171
- oe,
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: M,
174
- onChange: Y,
175
- onKeyDown: I,
176
- onFocus: Z,
177
- clearQuery: U,
178
- inputRef: X,
179
- placeholder: j,
180
- isFocused: B,
181
- onBlur: $,
182
- isLoading: J
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
- g.length > 0 && /* @__PURE__ */ n(
188
- ne,
262
+ searchResults.length > 0 && /* @__PURE__ */ jsx(
263
+ OptionList,
189
264
  {
190
- options: g,
191
- selectedOptionIndex: Q,
192
- handleOptionClick: T
265
+ options: searchResults,
266
+ selectedOptionIndex,
267
+ handleOptionClick
193
268
  }
194
269
  )
195
270
  ]
196
271
  }
197
272
  ),
198
- o && /* @__PURE__ */ n("div", { className: "HintText self-stretch text-slate-600 text-sm font-normal leading-tight", children: o })
273
+ description && /* @__PURE__ */ jsx("div", { className: "HintText self-stretch text-slate-600 text-sm font-normal leading-tight", children: description })
199
274
  ] });
200
- }, ne = ({
201
- options: e,
202
- selectedOptionIndex: t,
203
- handleOptionClick: r
275
+ };
276
+ const OptionList = ({
277
+ options,
278
+ selectedOptionIndex,
279
+ handleOptionClick
204
280
  }) => {
205
- const d = F(null);
206
- return p(() => {
207
- var o;
208
- if (t >= 0 && t < e.length) {
209
- const a = (o = d.current) == null ? void 0 : o.children[t];
210
- a == null || a.scrollIntoView({
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
- }, [t, e.length]), /* @__PURE__ */ n(
291
+ }, [selectedOptionIndex, options.length]);
292
+ return /* @__PURE__ */ jsx(
216
293
  "div",
217
294
  {
218
- ref: d,
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: e == null ? void 0 : e.map((o, a) => /* @__PURE__ */ n(
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 ${t === a ? "bg-gray-200" : ""}`,
224
- onClick: () => r(o),
225
- children: /* @__PURE__ */ n("p", { className: "font-normal", children: o.label })
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
- o.value
304
+ option.value
228
305
  ))
229
306
  }
230
307
  );
231
- }, oe = ({
232
- value: e,
233
- onChange: t,
234
- onKeyDown: r,
235
- onFocus: d,
236
- onBlur: o,
237
- inputRef: a,
238
- placeholder: u,
239
- clearQuery: h,
240
- isFocused: i,
241
- isLoading: c
242
- }) => /* @__PURE__ */ N("div", { className: "relative flex items-center w-full sharedResource", children: [
243
- /* @__PURE__ */ n(
244
- "input",
245
- {
246
- type: "text",
247
- className: `pl-1 py-1 border-gray-800 w-full ${c ? "pr-10" : "pr-20"}`,
248
- value: e,
249
- onChange: t,
250
- onKeyDown: r,
251
- onFocus: d,
252
- ref: a,
253
- placeholder: u,
254
- disabled: c
255
- }
256
- ),
257
- c && /* @__PURE__ */ n("div", { className: "loader absolute right-0 text-gray-500", children: /* @__PURE__ */ N(
258
- "svg",
259
- {
260
- className: "animate-spin h-5 w-5",
261
- xmlns: "http://www.w3.org/2000/svg",
262
- fill: "none",
263
- viewBox: "0 0 24 24",
264
- children: [
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
- e && !c && /* @__PURE__ */ n(
305
- ee,
306
- {
307
- className: "material-icons absolute right-10 cursor-pointer text-gray-500",
308
- onClick: () => {
309
- h();
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
- me as default
398
+ AutocompleteSearchBar as default
316
399
  };
400
+ //# sourceMappingURL=AutocompleteSearchBar.js.map