@unifiedsoftware/react-ui 1.0.23 → 1.0.25

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/index.mjs DELETED
@@ -1,3101 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __defProps = Object.defineProperties;
3
- var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
4
- var __getOwnPropSymbols = Object.getOwnPropertySymbols;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __propIsEnum = Object.prototype.propertyIsEnumerable;
7
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
8
- var __spreadValues = (a, b) => {
9
- for (var prop in b || (b = {}))
10
- if (__hasOwnProp.call(b, prop))
11
- __defNormalProp(a, prop, b[prop]);
12
- if (__getOwnPropSymbols)
13
- for (var prop of __getOwnPropSymbols(b)) {
14
- if (__propIsEnum.call(b, prop))
15
- __defNormalProp(a, prop, b[prop]);
16
- }
17
- return a;
18
- };
19
- var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
20
- var __objRest = (source, exclude) => {
21
- var target = {};
22
- for (var prop in source)
23
- if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
24
- target[prop] = source[prop];
25
- if (source != null && __getOwnPropSymbols)
26
- for (var prop of __getOwnPropSymbols(source)) {
27
- if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
28
- target[prop] = source[prop];
29
- }
30
- return target;
31
- };
32
- var __async = (__this, __arguments, generator) => {
33
- return new Promise((resolve, reject) => {
34
- var fulfilled = (value) => {
35
- try {
36
- step(generator.next(value));
37
- } catch (e) {
38
- reject(e);
39
- }
40
- };
41
- var rejected = (value) => {
42
- try {
43
- step(generator.throw(value));
44
- } catch (e) {
45
- reject(e);
46
- }
47
- };
48
- var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
49
- step((generator = generator.apply(__this, __arguments)).next());
50
- });
51
- };
52
-
53
- // src/components/Autocomplete/Autocomplete.tsx
54
- import { useEffect as useEffect15, useMemo as useMemo3, useRef as useRef11, useState as useState11 } from "react";
55
-
56
- // src/constants/index.ts
57
- var PREFIX_CLS = "us-";
58
-
59
- // src/hooks/useLocalStorage.tsx
60
- import { useCallback, useEffect as useEffect2, useState } from "react";
61
-
62
- // src/hooks/useEventListener.tsx
63
- import { useRef } from "react";
64
-
65
- // src/hooks/useIsomorphicLayoutEffect.tsx
66
- import { useEffect, useLayoutEffect } from "react";
67
- var useIsomorphicLayoutEffect = typeof window !== "undefined" ? useLayoutEffect : useEffect;
68
- var useIsomorphicLayoutEffect_default = useIsomorphicLayoutEffect;
69
-
70
- // src/hooks/useEventListener.tsx
71
- function useEventListener(handler) {
72
- const savedHandler = useRef(handler);
73
- useIsomorphicLayoutEffect_default(() => {
74
- savedHandler.current = handler;
75
- }, [handler]);
76
- }
77
- var useEventListener_default = useEventListener;
78
-
79
- // src/hooks/useLocalStorage.tsx
80
- function useLocalStorage(key, initialValue) {
81
- const readValue = useCallback(() => {
82
- if (typeof window === "undefined") {
83
- return initialValue;
84
- }
85
- try {
86
- const item = window.localStorage.getItem(key);
87
- return item ? parseJSON(item) : initialValue;
88
- } catch (error) {
89
- console.warn(`Error reading localStorage key \u201C${key}\u201D:`, error);
90
- return initialValue;
91
- }
92
- }, [initialValue, key]);
93
- const [storedValue, setStoredValue] = useState(readValue);
94
- const setValue = useCallback(
95
- (value) => {
96
- if (typeof window == "undefined") {
97
- console.warn(`Tried setting localStorage key \u201C${key}\u201D even though environment is not a client`);
98
- }
99
- try {
100
- const newValue = value instanceof Function ? value(storedValue) : value;
101
- window.localStorage.setItem(key, JSON.stringify(newValue));
102
- setStoredValue(newValue);
103
- window.dispatchEvent(new Event("local-storage"));
104
- } catch (error) {
105
- console.warn(`Error setting localStorage key \u201C${key}\u201D:`, error);
106
- }
107
- },
108
- [key, storedValue]
109
- );
110
- useEffect2(() => {
111
- setStoredValue(readValue());
112
- }, []);
113
- const handleStorageChange = useCallback(() => {
114
- setStoredValue(readValue());
115
- }, [readValue]);
116
- useEventListener_default("storage", handleStorageChange);
117
- useEventListener_default("local-storage", handleStorageChange);
118
- return [storedValue, setValue];
119
- }
120
- function parseJSON(value) {
121
- try {
122
- return value === "undefined" ? void 0 : JSON.parse(value != null ? value : "");
123
- } catch (e) {
124
- return void 0;
125
- }
126
- }
127
-
128
- // src/hooks/usePrevious.tsx
129
- import { useEffect as useEffect3, useRef as useRef2 } from "react";
130
- var usePrevious = (value) => {
131
- const ref = useRef2();
132
- useEffect3(() => {
133
- ref.current = value;
134
- });
135
- return ref.current;
136
- };
137
-
138
- // src/hooks/useDisclosure.ts
139
- import { useState as useState2 } from "react";
140
- function useDisclosure({ defaultValue } = {}) {
141
- const [isOpen, setIsOpen] = useState2(defaultValue || false);
142
- const onOpen = () => {
143
- setIsOpen(true);
144
- };
145
- const onClose = () => {
146
- setIsOpen(false);
147
- };
148
- const onToggle = () => {
149
- setIsOpen((prevState) => !prevState);
150
- };
151
- return {
152
- isOpen,
153
- onOpen,
154
- onClose,
155
- onToggle
156
- };
157
- }
158
- var useDisclosure_default = useDisclosure;
159
-
160
- // src/hooks/useOnClickOutside.tsx
161
- import { useEffect as useEffect4 } from "react";
162
- var useOnClickOutside = (ref, handler) => {
163
- useEffect4(() => {
164
- const listener = (event) => {
165
- if (!ref.current || ref.current.contains(event.target)) {
166
- return;
167
- }
168
- handler(event);
169
- };
170
- document.addEventListener("click", listener);
171
- return () => {
172
- document.removeEventListener("click", listener);
173
- };
174
- }, [ref, handler]);
175
- };
176
- var useOnClickOutside_default = useOnClickOutside;
177
-
178
- // src/hooks/useStep.tsx
179
- import { useCallback as useCallback2, useMemo, useState as useState3 } from "react";
180
- var useStep = (maxStep) => {
181
- const [currentStep, setCurrentStep] = useState3(1);
182
- const canGoToNextStep = useMemo(() => currentStep + 1 <= maxStep, [currentStep, maxStep]);
183
- const canGoToPrevStep = useMemo(() => currentStep - 1 >= 1, [currentStep]);
184
- const setStep = useCallback2(
185
- (step) => {
186
- const newStep = step instanceof Function ? step(currentStep) : step;
187
- if (newStep >= 1 && newStep <= maxStep) {
188
- setCurrentStep(newStep);
189
- return;
190
- }
191
- throw new Error("Step not valid");
192
- },
193
- [maxStep, currentStep]
194
- );
195
- const goToNextStep = useCallback2(() => {
196
- if (canGoToNextStep) {
197
- setCurrentStep((step) => step + 1);
198
- }
199
- }, [canGoToNextStep]);
200
- const goToPrevStep = useCallback2(() => {
201
- if (canGoToPrevStep) {
202
- setCurrentStep((step) => step - 1);
203
- }
204
- }, [canGoToPrevStep]);
205
- const reset = useCallback2(() => {
206
- setCurrentStep(1);
207
- }, []);
208
- return [
209
- currentStep,
210
- {
211
- goToNextStep,
212
- goToPrevStep,
213
- canGoToNextStep,
214
- canGoToPrevStep,
215
- setStep,
216
- reset
217
- }
218
- ];
219
- };
220
-
221
- // src/hooks/useDebounce.ts
222
- import { useEffect as useEffect5, useState as useState4 } from "react";
223
- function useDebounce(value, delay) {
224
- const [debouncedValue, setDebouncedValue] = useState4(value);
225
- useEffect5(() => {
226
- const timer = setTimeout(() => setDebouncedValue(value), delay || 500);
227
- return () => {
228
- clearTimeout(timer);
229
- };
230
- }, [value, delay]);
231
- return debouncedValue;
232
- }
233
- var useDebounce_default = useDebounce;
234
-
235
- // src/hooks/useVirtualizer/useVirtualizer.ts
236
- import { useVirtualizer as useReactVirtualizer } from "@tanstack/react-virtual";
237
- import { useEffect as useEffect6 } from "react";
238
- function useVirtualizer(options) {
239
- const {
240
- parentRef,
241
- total,
242
- count = 0,
243
- overscan = 5,
244
- hasNextPage,
245
- isFetchingNextPage,
246
- onFetchNextPage,
247
- estimateSize
248
- } = options;
249
- const virtualizer = useReactVirtualizer({
250
- count: total ? total : hasNextPage ? count + 1 : count,
251
- getScrollElement: () => parentRef.current,
252
- estimateSize,
253
- overscan
254
- });
255
- useEffect6(() => {
256
- if (!onFetchNextPage)
257
- return;
258
- const [lastItem] = [...virtualizer.getVirtualItems()].reverse();
259
- if (!lastItem) {
260
- return;
261
- }
262
- if (lastItem.index >= count - 1 && hasNextPage && !isFetchingNextPage) {
263
- onFetchNextPage == null ? void 0 : onFetchNextPage();
264
- }
265
- }, [hasNextPage, onFetchNextPage, count, isFetchingNextPage, virtualizer.getVirtualItems()]);
266
- return {
267
- getVirtualItems: virtualizer.getVirtualItems,
268
- getTotalSize: virtualizer.getTotalSize,
269
- scrollToIndex: (index, options2) => {
270
- virtualizer.scrollToIndex(index, options2);
271
- },
272
- scrollToOffset: (toOffset, options2) => {
273
- virtualizer.scrollToOffset(toOffset, options2);
274
- }
275
- };
276
- }
277
- var useVirtualizer_default = useVirtualizer;
278
-
279
- // src/hooks/useInfiniteQuery/useInfiniteQuery.ts
280
- import { useEffect as useEffect7, useState as useState5 } from "react";
281
-
282
- // src/hooks/useInfiniteQuery/types.ts
283
- var QueryStatus = /* @__PURE__ */ ((QueryStatus2) => {
284
- QueryStatus2[QueryStatus2["IDLE"] = 0] = "IDLE";
285
- QueryStatus2[QueryStatus2["LOADING"] = 1] = "LOADING";
286
- QueryStatus2[QueryStatus2["SUCCESS"] = 2] = "SUCCESS";
287
- QueryStatus2[QueryStatus2["ERROR"] = 3] = "ERROR";
288
- return QueryStatus2;
289
- })(QueryStatus || {});
290
-
291
- // src/hooks/useInfiniteQuery/useInfiniteQuery.ts
292
- function useInfiniteQuery(options, deps = []) {
293
- const [status, setStatus] = useState5(0 /* IDLE */);
294
- const [data, setData] = useState5({ pages: [] });
295
- const [error, setError] = useState5();
296
- const [hasNextPage, setHasNextPage] = useState5(true);
297
- const [isFetchingNextPage, setIsFetchingNextPage] = useState5(false);
298
- const fetchNextPage = () => __async(this, null, function* () {
299
- try {
300
- setStatus(1 /* LOADING */);
301
- setError(void 0);
302
- setIsFetchingNextPage(true);
303
- const lastIndex = data.pages.length - 1;
304
- const page = options.getNextPage(data.pages[lastIndex], data.pages);
305
- const newPage = yield options.query({ page });
306
- const newData = { pages: [...data.pages, newPage] };
307
- setData(newData);
308
- const newLastIndex = newData.pages.length - 1;
309
- const nextPage = options.getNextPage(newData.pages[newLastIndex], newData.pages);
310
- setHasNextPage(nextPage !== void 0);
311
- setIsFetchingNextPage(false);
312
- setStatus(2 /* SUCCESS */);
313
- } catch (error2) {
314
- setError(error2);
315
- setStatus(3 /* ERROR */);
316
- }
317
- });
318
- useEffect7(() => {
319
- const fetchData = () => __async(this, null, function* () {
320
- try {
321
- setStatus(1 /* LOADING */);
322
- setError(void 0);
323
- setIsFetchingNextPage(true);
324
- const page = void 0;
325
- const newPage = yield options.query({ page });
326
- setData({ pages: [newPage] });
327
- const nextPage = options.getNextPage(newPage, [newPage]);
328
- setHasNextPage(nextPage !== void 0);
329
- setIsFetchingNextPage(false);
330
- setStatus(2 /* SUCCESS */);
331
- } catch (error2) {
332
- setError(error2);
333
- setStatus(3 /* ERROR */);
334
- }
335
- });
336
- fetchData();
337
- }, deps);
338
- return { status, data, error, hasNextPage, isFetchingNextPage, fetchNextPage };
339
- }
340
- var useInfiniteQuery_default = useInfiniteQuery;
341
-
342
- // src/hooks/useElementSize/useElementSize.ts
343
- import { useEffect as useEffect8, useMemo as useMemo2, useRef as useRef3, useState as useState6 } from "react";
344
- var defaultState = {
345
- width: 0,
346
- height: 0
347
- };
348
- function useElementSize(options) {
349
- var _a;
350
- const frameID = useRef3(0);
351
- const [resize, setResize] = useState6(defaultState);
352
- const observer = useMemo2(
353
- () => typeof window !== "undefined" ? new ResizeObserver((entries) => {
354
- const entry = entries[0];
355
- if (entry) {
356
- cancelAnimationFrame(frameID.current);
357
- frameID.current = requestAnimationFrame(() => {
358
- var _a2, _b, _c;
359
- const target = (_b = (_a2 = options.ref) == null ? void 0 : _a2.current) != null ? _b : options.target;
360
- if (target) {
361
- (_c = options.callback) == null ? void 0 : _c.call(options, resize);
362
- setResize({ width: entry.contentRect.width, height: entry.contentRect.height });
363
- }
364
- });
365
- }
366
- }) : null,
367
- []
368
- );
369
- useEffect8(() => {
370
- var _a2, _b;
371
- const target = (_b = (_a2 = options.ref) == null ? void 0 : _a2.current) != null ? _b : options.target;
372
- if (target) {
373
- observer == null ? void 0 : observer.observe(target);
374
- }
375
- return () => {
376
- observer == null ? void 0 : observer.disconnect();
377
- if (frameID.current) {
378
- cancelAnimationFrame(frameID.current);
379
- }
380
- };
381
- }, [(_a = options.ref) == null ? void 0 : _a.current, options.target]);
382
- return resize;
383
- }
384
- var useElementSize_default = useElementSize;
385
-
386
- // src/hooks/useResizeObserver/useResizeObserver.ts
387
- import { useEffect as useEffect9 } from "react";
388
- function hasResizeObserver() {
389
- return typeof window.ResizeObserver !== "undefined";
390
- }
391
- function useResizeObserver(options) {
392
- const { ref, onResize } = options;
393
- useEffect9(() => {
394
- const element = ref == null ? void 0 : ref.current;
395
- if (!element) {
396
- return;
397
- }
398
- if (!hasResizeObserver()) {
399
- window.addEventListener("resize", onResize);
400
- return () => {
401
- window.removeEventListener("resize", onResize);
402
- };
403
- } else {
404
- const resizeObserver = new window.ResizeObserver((entries) => {
405
- if (!entries.length) {
406
- return;
407
- }
408
- onResize();
409
- });
410
- resizeObserver.observe(element);
411
- return () => {
412
- if (element) {
413
- resizeObserver.unobserve(element);
414
- }
415
- };
416
- }
417
- }, [ref, onResize]);
418
- }
419
- var useResizeObserver_default = useResizeObserver;
420
-
421
- // src/hooks/useEffectEvent/useEffectEvent.ts
422
- import { useCallback as useCallback3, useLayoutEffect as useLayoutEffect2, useRef as useRef4 } from "react";
423
- function useEffectEvent(fn) {
424
- const ref = useRef4(null);
425
- useLayoutEffect2(() => {
426
- ref.current = fn;
427
- }, [fn]);
428
- return useCallback3((...args) => {
429
- const f = ref.current;
430
- return f(...args);
431
- }, []);
432
- }
433
- var useEffectEvent_default = useEffectEvent;
434
-
435
- // src/hooks/useValueEffect/useValueEffect.ts
436
- import { useLayoutEffect as useLayoutEffect3, useRef as useRef5, useState as useState7 } from "react";
437
- function useValueEffect(defaultValue) {
438
- const [value, setValue] = useState7(defaultValue);
439
- const effect = useRef5(null);
440
- const nextRef = useEffectEvent_default(() => {
441
- if (!effect.current)
442
- return;
443
- const newValue = effect.current.next();
444
- if (newValue.done) {
445
- effect.current = null;
446
- return;
447
- }
448
- if (value === newValue.value) {
449
- nextRef();
450
- } else {
451
- setValue(newValue.value);
452
- }
453
- });
454
- useLayoutEffect3(() => {
455
- if (effect.current) {
456
- nextRef();
457
- }
458
- });
459
- const queue = useEffectEvent_default((fn) => {
460
- effect.current = fn(value);
461
- nextRef();
462
- });
463
- return [value, queue];
464
- }
465
- var useValueEffect_default = useValueEffect;
466
-
467
- // src/icons/ChevronDownIcon.tsx
468
- import { forwardRef } from "react";
469
- import { jsx, jsxs } from "react/jsx-runtime";
470
- var ChevronDownIcon = forwardRef((props, ref) => {
471
- return /* @__PURE__ */ jsxs(
472
- "svg",
473
- __spreadProps(__spreadValues({
474
- ref,
475
- stroke: "currentColor",
476
- fill: "currentColor",
477
- strokeWidth: "0",
478
- viewBox: "0 0 24 24",
479
- height: "1em",
480
- width: "1em",
481
- xmlns: "http://www.w3.org/2000/svg"
482
- }, props), {
483
- children: [
484
- /* @__PURE__ */ jsx("path", { fill: "none", d: "M0 0h24v24H0V0z" }),
485
- /* @__PURE__ */ jsx("path", { d: "M7.41 8.59L12 13.17l4.59-4.58L18 10l-6 6-6-6 1.41-1.41z" })
486
- ]
487
- })
488
- );
489
- });
490
- var ChevronDownIcon_default = ChevronDownIcon;
491
-
492
- // src/icons/ChevronUpIcon.tsx
493
- import { forwardRef as forwardRef2 } from "react";
494
- import { jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
495
- var ChevronUpIcon = forwardRef2((props, ref) => {
496
- return /* @__PURE__ */ jsxs2(
497
- "svg",
498
- __spreadProps(__spreadValues({
499
- ref,
500
- stroke: "currentColor",
501
- fill: "currentColor",
502
- strokeWidth: "0",
503
- viewBox: "0 0 24 24",
504
- height: "1em",
505
- width: "1em",
506
- xmlns: "http://www.w3.org/2000/svg"
507
- }, props), {
508
- children: [
509
- /* @__PURE__ */ jsx2("path", { fill: "none", d: "M0 0h24v24H0z" }),
510
- /* @__PURE__ */ jsx2("path", { d: "M7.41 15.41L12 10.83l4.59 4.58L18 14l-6-6-6 6z" })
511
- ]
512
- })
513
- );
514
- });
515
- var ChevronUpIcon_default = ChevronUpIcon;
516
-
517
- // src/icons/LoaderIcon.tsx
518
- import { forwardRef as forwardRef3 } from "react";
519
- import { jsx as jsx3, jsxs as jsxs3 } from "react/jsx-runtime";
520
- var LoaderIcon = forwardRef3((props, ref) => {
521
- return /* @__PURE__ */ jsxs3(
522
- "svg",
523
- __spreadProps(__spreadValues({
524
- ref,
525
- stroke: "currentColor",
526
- fill: "none",
527
- strokeWidth: "2",
528
- viewBox: "0 0 24 24",
529
- strokeLinecap: "round",
530
- strokeLinejoin: "round",
531
- height: "1em",
532
- width: "1em",
533
- xmlns: "http://www.w3.org/2000/svg"
534
- }, props), {
535
- children: [
536
- /* @__PURE__ */ jsx3("path", { stroke: "none", d: "M0 0h24v24H0z", fill: "none" }),
537
- /* @__PURE__ */ jsx3("path", { d: "M12 3a9 9 0 1 0 9 9" })
538
- ]
539
- })
540
- );
541
- });
542
- var LoaderIcon_default = LoaderIcon;
543
-
544
- // src/icons/CloseIcon.tsx
545
- import { forwardRef as forwardRef4 } from "react";
546
- import { jsx as jsx4, jsxs as jsxs4 } from "react/jsx-runtime";
547
- var CloseIcon = forwardRef4((props, ref) => {
548
- return /* @__PURE__ */ jsxs4(
549
- "svg",
550
- __spreadProps(__spreadValues({
551
- ref,
552
- xmlns: "http://www.w3.org/2000/svg",
553
- width: "24",
554
- height: "24",
555
- viewBox: "0 0 24 24",
556
- strokeWidth: "2",
557
- stroke: "currentColor",
558
- fill: "none",
559
- strokeLinecap: "round",
560
- strokeLinejoin: "round"
561
- }, props), {
562
- children: [
563
- /* @__PURE__ */ jsx4("path", { stroke: "none", d: "M0 0h24v24H0z", fill: "none" }),
564
- /* @__PURE__ */ jsx4("path", { d: "M18 6l-12 12" }),
565
- /* @__PURE__ */ jsx4("path", { d: "M6 6l12 12" })
566
- ]
567
- })
568
- );
569
- });
570
- var CloseIcon_default = CloseIcon;
571
-
572
- // src/utils/scroll.ts
573
- var scrollToItem = (parentElement, currentElement) => {
574
- const parentRect = parentElement.getBoundingClientRect();
575
- const currentRect = currentElement.getBoundingClientRect();
576
- const behavior = "smooth";
577
- const previousElement = currentElement.previousSibling;
578
- const previousRect = (previousElement == null ? void 0 : previousElement.getBoundingClientRect()) || currentRect;
579
- if (parentRect.left > previousRect.left) {
580
- let offset = 0;
581
- if (previousElement) {
582
- offset = previousRect.left - parentRect.left + parentElement.scrollLeft + previousRect.width / 4;
583
- }
584
- parentElement.scrollTo({ behavior, left: offset });
585
- }
586
- const nextElement = currentElement.nextSibling;
587
- const nextRect = (nextElement == null ? void 0 : nextElement.getBoundingClientRect()) || currentRect;
588
- if (parentRect.right < nextRect.right) {
589
- let offset = parentElement.scrollWidth;
590
- if (nextElement) {
591
- offset = nextRect.right - parentRect.right + parentElement.scrollLeft - nextRect.width / 4;
592
- }
593
- parentElement.scrollTo({ behavior, left: offset });
594
- }
595
- };
596
-
597
- // src/utils/clsx.ts
598
- function toVal(mix) {
599
- let k, y, str = "";
600
- if (typeof mix === "string" || typeof mix === "number") {
601
- str += mix;
602
- } else if (typeof mix === "object") {
603
- if (Array.isArray(mix)) {
604
- for (k = 0; k < mix.length; k++) {
605
- if (mix[k]) {
606
- if (y = toVal(mix[k])) {
607
- str && (str += " ");
608
- str += y;
609
- }
610
- }
611
- }
612
- } else {
613
- for (k in mix) {
614
- if (mix[k]) {
615
- str && (str += " ");
616
- str += k;
617
- }
618
- }
619
- }
620
- }
621
- return str;
622
- }
623
- function clsx(...inputs) {
624
- let i = 0, tmp, x, str = "";
625
- while (i < inputs.length) {
626
- if (tmp = inputs[i++]) {
627
- if (x = toVal(tmp)) {
628
- str && (str += " ");
629
- str += x;
630
- }
631
- }
632
- }
633
- return str;
634
- }
635
- var clsx_default = clsx;
636
-
637
- // src/utils/mergeRefs.ts
638
- function assignRef(ref, value) {
639
- if (ref == null)
640
- return;
641
- if (typeof ref === "function") {
642
- ref(value);
643
- return;
644
- }
645
- try {
646
- ref.current = value;
647
- } catch (error) {
648
- throw new Error(`Cannot assign value '${value}' to ref '${ref}'`);
649
- }
650
- }
651
- function mergeRefs(...refs) {
652
- return (node) => {
653
- refs.forEach((ref) => {
654
- assignRef(ref, node);
655
- });
656
- };
657
- }
658
- var mergeRefs_default = mergeRefs;
659
-
660
- // src/components/Button/Button.tsx
661
- import clsx3 from "clsx";
662
- import { forwardRef as forwardRef6 } from "react";
663
-
664
- // src/components/Icon/Icon.tsx
665
- import clsx2 from "clsx";
666
- import { Children, cloneElement, forwardRef as forwardRef5 } from "react";
667
- var Icon = forwardRef5(({ children, size }, ref) => {
668
- const child = Children.only(children);
669
- return cloneElement(child, __spreadProps(__spreadValues({
670
- ref
671
- }, child.props), {
672
- className: clsx2(`${PREFIX_CLS}icon`, { [`${PREFIX_CLS}font-size-${size}`]: size }, child.props.className)
673
- }));
674
- });
675
- var Icon_default = Icon;
676
-
677
- // src/components/Button/Button.tsx
678
- import { jsx as jsx5, jsxs as jsxs5 } from "react/jsx-runtime";
679
- var Button = forwardRef6(
680
- (_a, ref) => {
681
- var _b = _a, {
682
- as: Component = "button",
683
- children,
684
- className,
685
- role = "presentation",
686
- variant = "text",
687
- color = "primary",
688
- size = "md",
689
- iconOnly,
690
- startContent,
691
- endContent,
692
- block,
693
- loading,
694
- disabled
695
- } = _b, rest = __objRest(_b, [
696
- "as",
697
- "children",
698
- "className",
699
- "role",
700
- "variant",
701
- "color",
702
- "size",
703
- "iconOnly",
704
- "startContent",
705
- "endContent",
706
- "block",
707
- "loading",
708
- "disabled"
709
- ]);
710
- const prefixCls = PREFIX_CLS;
711
- return /* @__PURE__ */ jsxs5(
712
- Component,
713
- __spreadProps(__spreadValues({
714
- ref,
715
- className: clsx3(
716
- `${prefixCls}button`,
717
- {
718
- [`${prefixCls}button--${variant}`]: variant,
719
- [`${prefixCls}button--${color}`]: color,
720
- [`${prefixCls}button--${size}`]: size,
721
- [`${prefixCls}button--block`]: block,
722
- [`${prefixCls}button--icon-only`]: iconOnly,
723
- [`${prefixCls}button--disabled`]: disabled
724
- },
725
- className
726
- ),
727
- role,
728
- disabled
729
- }, rest), {
730
- children: [
731
- /* @__PURE__ */ jsx5("div", { className: `${prefixCls}overlay` }),
732
- /* @__PURE__ */ jsx5("div", { className: `${prefixCls}outline` }),
733
- loading ? /* @__PURE__ */ jsx5(Icon_default, { children: /* @__PURE__ */ jsx5(LoaderIcon_default, { className: `${prefixCls}animation-spin` }) }) : startContent,
734
- /* @__PURE__ */ jsx5("div", { className: `${prefixCls}button__content`, children }),
735
- endContent
736
- ]
737
- })
738
- );
739
- }
740
- );
741
-
742
- // src/components/Popover/Popover.tsx
743
- import { Children as Children2, cloneElement as cloneElement2, useEffect as useEffect10, useRef as useRef6, useState as useState8 } from "react";
744
-
745
- // src/components/Portal/Portal.tsx
746
- import { forwardRef as forwardRef7 } from "react";
747
- import { createPortal } from "react-dom";
748
- import { jsx as jsx6 } from "react/jsx-runtime";
749
- var Portal = forwardRef7(({ children, container }, ref) => {
750
- const prefixCls = PREFIX_CLS;
751
- return createPortal(
752
- /* @__PURE__ */ jsx6("div", { ref, className: `${prefixCls}portal`, children }),
753
- container || document.body
754
- );
755
- });
756
- var Portal_default = Portal;
757
-
758
- // src/components/Transition/Transition.tsx
759
- import clsx4 from "clsx";
760
- import { forwardRef as forwardRef8 } from "react";
761
- import { CSSTransition } from "react-transition-group";
762
- import { jsx as jsx7 } from "react/jsx-runtime";
763
- var Transition = forwardRef8((props, ref) => {
764
- const {
765
- children,
766
- className,
767
- nodeRef,
768
- name,
769
- isOpen,
770
- enter = 0,
771
- leave = 0,
772
- mountOnEnter,
773
- unmountOnExit,
774
- onExited
775
- } = props;
776
- return /* @__PURE__ */ jsx7(
777
- CSSTransition,
778
- {
779
- nodeRef,
780
- in: isOpen,
781
- appear: true,
782
- timeout: { enter, exit: leave },
783
- mountOnEnter,
784
- unmountOnExit,
785
- classNames: clsx4(name, className),
786
- onExited,
787
- children
788
- }
789
- );
790
- });
791
- var Transition_default = Transition;
792
-
793
- // src/components/Popover/constans.ts
794
- var POPOVER_TRANSITION_DURATION_LEAVE = 150;
795
-
796
- // src/components/Popover/PopoverContext.tsx
797
- import { createContext, useContext } from "react";
798
- var PopoverContext = createContext(null);
799
- var usePopover = () => {
800
- const context = useContext(PopoverContext);
801
- if (!context) {
802
- throw new Error("`usePopover` must be used within a `<Popover />`");
803
- }
804
- return context;
805
- };
806
- var PopoverContext_default = PopoverContext;
807
-
808
- // src/components/Popover/Popover.tsx
809
- import { jsx as jsx8, jsxs as jsxs6 } from "react/jsx-runtime";
810
- var Popover = (props) => {
811
- const {
812
- children,
813
- target,
814
- autoClose = true,
815
- triggerClosable = true,
816
- isOpen,
817
- onOpen,
818
- onClose,
819
- onToggle,
820
- onAfterClose
821
- } = props;
822
- const triggerRef = useRef6(null);
823
- const contentRef = useRef6(null);
824
- const [internalOpen, setInternalOpen] = useState8(props.isOpen || false);
825
- const [trigger, content] = Children2.toArray(children);
826
- const prefixCls = PREFIX_CLS;
827
- const handleOpen = () => {
828
- if (isOpen !== void 0) {
829
- onOpen == null ? void 0 : onOpen();
830
- } else {
831
- setInternalOpen(true);
832
- }
833
- };
834
- const handleClose = () => {
835
- if (isOpen !== void 0) {
836
- onClose == null ? void 0 : onClose();
837
- } else {
838
- setInternalOpen(false);
839
- }
840
- };
841
- const handleToggle = () => {
842
- if (isOpen !== void 0) {
843
- onToggle == null ? void 0 : onToggle();
844
- } else {
845
- setInternalOpen((prevState) => !prevState);
846
- }
847
- };
848
- useEffect10(() => {
849
- setInternalOpen(isOpen || false);
850
- }, [isOpen]);
851
- return /* @__PURE__ */ jsxs6(
852
- PopoverContext_default.Provider,
853
- {
854
- value: {
855
- triggerRef,
856
- contentRef,
857
- target,
858
- isOpen: internalOpen,
859
- autoClose,
860
- triggerClosable,
861
- onOpen: handleOpen,
862
- onClose: handleClose,
863
- onToggle: handleToggle
864
- },
865
- children: [
866
- trigger,
867
- /* @__PURE__ */ jsx8(
868
- Transition_default,
869
- {
870
- nodeRef: contentRef,
871
- isOpen: internalOpen,
872
- enter: 300,
873
- leave: POPOVER_TRANSITION_DURATION_LEAVE,
874
- name: `${prefixCls}popover`,
875
- unmountOnExit: true,
876
- onExited: onAfterClose,
877
- children: /* @__PURE__ */ jsx8(Portal_default, { children: cloneElement2(Children2.only(content), __spreadProps(__spreadValues({}, content.props), {
878
- ref: contentRef
879
- })) })
880
- }
881
- )
882
- ]
883
- }
884
- );
885
- };
886
- var Popover_default = Popover;
887
-
888
- // src/components/Popover/PopoverContent.tsx
889
- import { forwardRef as forwardRef9, useCallback as useCallback4, useEffect as useEffect11, useRef as useRef7, useState as useState9 } from "react";
890
- import { jsx as jsx9 } from "react/jsx-runtime";
891
- function getScrollParent(node) {
892
- if (node == null) {
893
- return null;
894
- }
895
- if (node.scrollHeight > node.clientHeight) {
896
- return node;
897
- } else {
898
- return getScrollParent(node.parentNode);
899
- }
900
- }
901
- var PopoverContent = forwardRef9((props, ref) => {
902
- const _a = props, { children, style, className, onClick } = _a, rest = __objRest(_a, ["children", "style", "className", "onClick"]);
903
- const { triggerRef, contentRef, target, onClose } = usePopover();
904
- const prefixCls = PREFIX_CLS;
905
- const menuListRef = useRef7(null);
906
- const [contentStyle, setContentStyle] = useState9({
907
- position: "absolute",
908
- top: 0,
909
- left: 0,
910
- visibility: "hidden"
911
- });
912
- const containerEl = getScrollParent(triggerRef.current) || window;
913
- useElementSize_default({
914
- target: containerEl,
915
- callback: () => {
916
- handleSize();
917
- }
918
- });
919
- useOnClickOutside_default(contentRef, (event) => {
920
- const el = triggerRef.current;
921
- if (!el || el.contains(event.target))
922
- return;
923
- onClose();
924
- });
925
- const handleClick = (ev) => {
926
- ev.stopPropagation();
927
- onClick == null ? void 0 : onClick(ev);
928
- };
929
- const handleSize = useCallback4(() => {
930
- var _a2, _b;
931
- const popoverRect = (_a2 = contentRef.current) == null ? void 0 : _a2.getBoundingClientRect();
932
- const triggerClientRect = (_b = triggerRef.current) == null ? void 0 : _b.getBoundingClientRect();
933
- if (!popoverRect || !triggerClientRect || !containerEl) {
934
- return;
935
- }
936
- const container = { innerWidth: window.innerWidth, innerHeight: window.innerHeight };
937
- const triggerRect = {
938
- width: triggerClientRect.width,
939
- height: triggerClientRect.height,
940
- top: triggerClientRect.top + window.scrollY,
941
- bottom: triggerClientRect.top + triggerClientRect.height + window.scrollY,
942
- left: triggerClientRect.left + window.scrollX,
943
- right: triggerClientRect.left + triggerClientRect.width + window.scrollX
944
- };
945
- const outsideX = triggerRect.left + popoverRect.width > container.innerWidth;
946
- const outsideY = triggerRect.top + popoverRect.height > container.innerHeight + window.scrollY;
947
- const style2 = __spreadProps(__spreadValues({}, target && {
948
- width: triggerRect.width,
949
- minWidth: "auto"
950
- }), {
951
- position: "absolute",
952
- top: outsideY ? void 0 : triggerRect.bottom,
953
- bottom: outsideY ? container.innerHeight - triggerRect.top : void 0,
954
- left: outsideX ? void 0 : triggerRect.left,
955
- right: outsideX ? container.innerWidth - triggerRect.right : void 0,
956
- visibility: void 0
957
- });
958
- setContentStyle(style2);
959
- }, []);
960
- useEffect11(() => {
961
- handleSize();
962
- containerEl.addEventListener("scroll", handleSize);
963
- window.addEventListener("orientationchange", handleSize);
964
- return () => {
965
- containerEl.removeEventListener("scroll", handleSize);
966
- window.removeEventListener("orientationchange", handleSize);
967
- };
968
- }, []);
969
- return /* @__PURE__ */ jsx9(
970
- "div",
971
- __spreadProps(__spreadValues({
972
- ref: mergeRefs_default(menuListRef, ref),
973
- className: clsx_default(`${prefixCls}popover`, className),
974
- style: __spreadValues(__spreadValues({}, style), contentStyle),
975
- onClick: handleClick
976
- }, rest), {
977
- children
978
- })
979
- );
980
- });
981
- var PopoverContent_default = PopoverContent;
982
-
983
- // src/components/Popover/PopoverTrigger.tsx
984
- import { Children as Children3, cloneElement as cloneElement3, forwardRef as forwardRef10 } from "react";
985
- var PopoverTrigger = forwardRef10((props, ref) => {
986
- const _a = props, { children, onClick } = _a, rest = __objRest(_a, ["children", "onClick"]);
987
- const { isOpen, triggerRef, triggerClosable, onOpen, onClose } = usePopover();
988
- const child = Children3.only(typeof children === "function" ? children(isOpen) : children);
989
- const handleClick = (ev) => {
990
- var _a2, _b;
991
- ev.preventDefault();
992
- triggerClosable && isOpen ? onClose() : onOpen();
993
- onClick == null ? void 0 : onClick(ev);
994
- (_b = (_a2 = child.props).onClick) == null ? void 0 : _b.call(_a2, ev);
995
- };
996
- return cloneElement3(child, __spreadProps(__spreadValues(__spreadValues({}, child.props), rest), {
997
- ref: mergeRefs_default(ref, triggerRef),
998
- onClick: handleClick
999
- }));
1000
- });
1001
- var PopoverTrigger_default = PopoverTrigger;
1002
-
1003
- // src/components/Autocomplete/AutocompleteContent.tsx
1004
- import { Fragment as Fragment3, useEffect as useEffect13, useRef as useRef9 } from "react";
1005
-
1006
- // src/components/List/List.tsx
1007
- import { forwardRef as forwardRef11 } from "react";
1008
- import { jsx as jsx10 } from "react/jsx-runtime";
1009
- var List = forwardRef11((_a, ref) => {
1010
- var _b = _a, { as: Component = "div", children } = _b, rest = __objRest(_b, ["as", "children"]);
1011
- const prefixCls = PREFIX_CLS;
1012
- return /* @__PURE__ */ jsx10(Component, __spreadProps(__spreadValues({ ref, className: `${prefixCls}list` }, rest), { children }));
1013
- });
1014
- var List_default = List;
1015
-
1016
- // src/components/List/ListGroup.tsx
1017
- import { forwardRef as forwardRef15 } from "react";
1018
-
1019
- // src/components/Collapse/Collapse.tsx
1020
- import { Children as Children4, useEffect as useEffect12, useRef as useRef8, useState as useState10 } from "react";
1021
-
1022
- // src/components/Collapse/CollapseContext.tsx
1023
- import { createContext as createContext2, useContext as useContext2 } from "react";
1024
- var CollapseContext = createContext2(null);
1025
- var useCollapse = () => {
1026
- const context = useContext2(CollapseContext);
1027
- if (!context) {
1028
- throw new Error("`useCollapse` must be used within a `<Collapse />`");
1029
- }
1030
- return context;
1031
- };
1032
- var CollapseContext_default = CollapseContext;
1033
-
1034
- // src/components/Collapse/Collapse.tsx
1035
- import { jsxs as jsxs7 } from "react/jsx-runtime";
1036
- var Collapse = ({ children, isOpen, onOpen, onClose, onToggle }) => {
1037
- const collapseRef = useRef8(null);
1038
- const [selfIsOpen, setSelfIsOpen] = useState10(isOpen != null ? isOpen : false);
1039
- const [heightAuto, setHeightAuto] = useState10(false);
1040
- const [trigger, content] = Children4.toArray(children);
1041
- const handleOpen = () => {
1042
- setSelfIsOpen(true);
1043
- onOpen == null ? void 0 : onOpen();
1044
- };
1045
- const handleClose = () => {
1046
- setSelfIsOpen(false);
1047
- onClose == null ? void 0 : onClose();
1048
- };
1049
- const handleToggle = () => {
1050
- setSelfIsOpen((prevState) => !prevState);
1051
- onToggle == null ? void 0 : onToggle();
1052
- };
1053
- useEffect12(() => {
1054
- if (isOpen !== void 0) {
1055
- setSelfIsOpen(isOpen);
1056
- }
1057
- setTimeout(() => {
1058
- if (isOpen) {
1059
- setHeightAuto(true);
1060
- } else {
1061
- setHeightAuto(false);
1062
- }
1063
- }, 100);
1064
- }, [isOpen]);
1065
- return /* @__PURE__ */ jsxs7(
1066
- CollapseContext_default.Provider,
1067
- {
1068
- value: {
1069
- collapseRef,
1070
- isOpen: selfIsOpen,
1071
- heightAuto,
1072
- onOpen: handleOpen,
1073
- onClose: handleClose,
1074
- onToggle: handleToggle
1075
- },
1076
- children: [
1077
- trigger,
1078
- content
1079
- ]
1080
- }
1081
- );
1082
- };
1083
- var Collapse_default = Collapse;
1084
-
1085
- // src/components/Collapse/CollapseContent.tsx
1086
- import clsx5 from "clsx";
1087
- import { Children as Children5, cloneElement as cloneElement4, forwardRef as forwardRef12 } from "react";
1088
- var CollapseContent = forwardRef12(({ children }, ref) => {
1089
- var _a, _b;
1090
- const { collapseRef, isOpen, heightAuto } = useCollapse();
1091
- const child = Children5.only(children);
1092
- return cloneElement4(child, __spreadProps(__spreadValues({}, child.props), {
1093
- ref: (node) => {
1094
- collapseRef.current = node;
1095
- if (ref !== null) {
1096
- ref.current = node;
1097
- }
1098
- },
1099
- style: __spreadProps(__spreadValues({}, child.props.style), {
1100
- height: isOpen && heightAuto ? "auto" : isOpen ? (_a = collapseRef.current) == null ? void 0 : _a.scrollHeight : !isOpen && heightAuto ? (_b = collapseRef.current) == null ? void 0 : _b.scrollHeight : 0
1101
- }),
1102
- className: clsx5(`${PREFIX_CLS}collapse`, child.props.className)
1103
- }));
1104
- });
1105
- var CollapseContent_default = CollapseContent;
1106
-
1107
- // src/components/Collapse/CollapseTrigger.tsx
1108
- import { Children as Children6, cloneElement as cloneElement5, forwardRef as forwardRef13 } from "react";
1109
- var CollapseTrigger = forwardRef13(({ children }, ref) => {
1110
- const { collapseRef, onToggle } = useCollapse();
1111
- const child = Children6.only(children);
1112
- const _a = child.props, { onClick } = _a, rest = __objRest(_a, ["onClick"]);
1113
- return cloneElement5(child, __spreadValues({
1114
- ref,
1115
- onClick: (event) => {
1116
- if (!collapseRef.current) {
1117
- return;
1118
- }
1119
- onToggle();
1120
- onClick == null ? void 0 : onClick(event);
1121
- }
1122
- }, rest));
1123
- });
1124
- var CollapseTrigger_default = CollapseTrigger;
1125
-
1126
- // src/components/List/ListItem.tsx
1127
- import { forwardRef as forwardRef14 } from "react";
1128
- import { Fragment, jsx as jsx11, jsxs as jsxs8 } from "react/jsx-runtime";
1129
- var ListItem = forwardRef14(
1130
- (_a, ref) => {
1131
- var _b = _a, {
1132
- as: Component = "div",
1133
- children,
1134
- className,
1135
- title,
1136
- subtitle,
1137
- startContent,
1138
- endContent,
1139
- level = 1,
1140
- hoverable,
1141
- selected,
1142
- disabled,
1143
- slotProps,
1144
- style,
1145
- onClick
1146
- } = _b, rest = __objRest(_b, [
1147
- "as",
1148
- "children",
1149
- "className",
1150
- "title",
1151
- "subtitle",
1152
- "startContent",
1153
- "endContent",
1154
- "level",
1155
- "hoverable",
1156
- "selected",
1157
- "disabled",
1158
- "slotProps",
1159
- "style",
1160
- "onClick"
1161
- ]);
1162
- var _a2, _b2;
1163
- const prefixCls = PREFIX_CLS;
1164
- const handleClick = (event) => {
1165
- onClick == null ? void 0 : onClick(event);
1166
- };
1167
- return /* @__PURE__ */ jsxs8(
1168
- Component,
1169
- __spreadProps(__spreadValues({
1170
- ref,
1171
- className: clsx_default(
1172
- `${prefixCls}list-item`,
1173
- {
1174
- [`${prefixCls}list-item--selected`]: selected,
1175
- [`${prefixCls}list-item--hoverable`]: hoverable,
1176
- [`${prefixCls}list-item--disabled`]: disabled
1177
- },
1178
- className
1179
- ),
1180
- style: __spreadValues({
1181
- paddingLeft: level <= 1 ? `var(--${prefixCls}list-item-padding-x)` : `calc(${level} * var(--${prefixCls}list-item-padding-level))`
1182
- }, style),
1183
- onClick: handleClick
1184
- }, rest), {
1185
- children: [
1186
- hoverable && /* @__PURE__ */ jsx11("div", { className: `${prefixCls}overlay` }),
1187
- startContent && /* @__PURE__ */ jsx11("div", { className: `${prefixCls}list-item__start-content`, children: startContent }),
1188
- /* @__PURE__ */ jsx11("div", { className: `${prefixCls}list-item__content`, children: title || subtitle ? /* @__PURE__ */ jsxs8(Fragment, { children: [
1189
- /* @__PURE__ */ jsx11("span", __spreadProps(__spreadValues({}, slotProps == null ? void 0 : slotProps.title), { className: clsx_default(`${prefixCls}list-item__title`, (_a2 = slotProps == null ? void 0 : slotProps.title) == null ? void 0 : _a2.className), children: title })),
1190
- /* @__PURE__ */ jsx11(
1191
- "span",
1192
- __spreadProps(__spreadValues({}, slotProps == null ? void 0 : slotProps.subtitle), {
1193
- className: clsx_default(`${prefixCls}list-item__subtitle`, (_b2 = slotProps == null ? void 0 : slotProps.subtitle) == null ? void 0 : _b2.className),
1194
- children: subtitle
1195
- })
1196
- )
1197
- ] }) : children }),
1198
- endContent && /* @__PURE__ */ jsx11("div", { className: `${prefixCls}list-item__end-content`, children: endContent })
1199
- ]
1200
- })
1201
- );
1202
- }
1203
- );
1204
- var ListItem_default = ListItem;
1205
-
1206
- // src/components/List/ListGroup.tsx
1207
- import { Fragment as Fragment2, jsx as jsx12, jsxs as jsxs9 } from "react/jsx-runtime";
1208
- var ListGroup = forwardRef15(
1209
- (_a, ref) => {
1210
- var _b = _a, {
1211
- children,
1212
- startContent,
1213
- endContent,
1214
- expandVisible = true,
1215
- expandPosition = "end",
1216
- isOpen,
1217
- onOpen,
1218
- onClose,
1219
- onToggle
1220
- } = _b, rest = __objRest(_b, [
1221
- "children",
1222
- "startContent",
1223
- "endContent",
1224
- "expandVisible",
1225
- "expandPosition",
1226
- "isOpen",
1227
- "onOpen",
1228
- "onClose",
1229
- "onToggle"
1230
- ]);
1231
- const disclosure = isOpen !== void 0 ? { isOpen, onOpen, onClose, onToggle } : useDisclosure_default();
1232
- const prefixCls = PREFIX_CLS;
1233
- return /* @__PURE__ */ jsx12("div", { className: `${prefixCls}list-group`, children: /* @__PURE__ */ jsxs9(Collapse_default, __spreadProps(__spreadValues({}, disclosure), { children: [
1234
- /* @__PURE__ */ jsx12(CollapseTrigger_default, { children: /* @__PURE__ */ jsx12(
1235
- ListItem_default,
1236
- __spreadValues({
1237
- ref,
1238
- startContent: expandVisible && expandPosition === "start" ? /* @__PURE__ */ jsxs9(Fragment2, { children: [
1239
- /* @__PURE__ */ jsx12(Icon_default, { children: disclosure.isOpen ? /* @__PURE__ */ jsx12(ChevronUpIcon_default, {}) : /* @__PURE__ */ jsx12(ChevronDownIcon_default, {}) }),
1240
- startContent
1241
- ] }) : startContent,
1242
- endContent: expandVisible && expandPosition === "end" ? /* @__PURE__ */ jsxs9(Fragment2, { children: [
1243
- endContent,
1244
- /* @__PURE__ */ jsx12(Icon_default, { children: disclosure.isOpen ? /* @__PURE__ */ jsx12(ChevronUpIcon_default, {}) : /* @__PURE__ */ jsx12(ChevronDownIcon_default, {}) })
1245
- ] }) : endContent
1246
- }, rest)
1247
- ) }),
1248
- /* @__PURE__ */ jsx12(CollapseContent_default, { children: /* @__PURE__ */ jsx12("div", { children: /* @__PURE__ */ jsx12(List_default, { children }) }) })
1249
- ] })) });
1250
- }
1251
- );
1252
- var ListGroup_default = ListGroup;
1253
-
1254
- // src/components/ScrollArea/ScrollArea.tsx
1255
- import { forwardRef as forwardRef16 } from "react";
1256
- import { Scrollbars } from "react-custom-scrollbars-2";
1257
- import { jsx as jsx13 } from "react/jsx-runtime";
1258
- var ScrollArea = forwardRef16(({ children, autoHide = false, style }, ref) => {
1259
- const prefixCls = PREFIX_CLS;
1260
- const renderView = (props) => {
1261
- return /* @__PURE__ */ jsx13("div", __spreadProps(__spreadValues({}, props), { className: clsx_default(`${prefixCls}scroll-area__view`, props.className) }));
1262
- };
1263
- const renderTrackHorizontal = (props) => {
1264
- return /* @__PURE__ */ jsx13(
1265
- "div",
1266
- __spreadProps(__spreadValues({}, props), {
1267
- className: clsx_default(`${prefixCls}scroll-area__track ${prefixCls}scroll-area__track--horizontal`, props.className)
1268
- })
1269
- );
1270
- };
1271
- const renderTrackVertical = (props) => {
1272
- return /* @__PURE__ */ jsx13(
1273
- "div",
1274
- __spreadProps(__spreadValues({}, props), {
1275
- className: clsx_default(`${prefixCls}scroll-area__track ${prefixCls}scroll-area__track--vertical`, props.className)
1276
- })
1277
- );
1278
- };
1279
- const renderThumbHorizontal = (props) => {
1280
- return /* @__PURE__ */ jsx13(
1281
- "div",
1282
- __spreadProps(__spreadValues({}, props), {
1283
- className: clsx_default(`${prefixCls}scroll-area__thumb ${prefixCls}scroll-area__thumb--horizontal`, props.className)
1284
- })
1285
- );
1286
- };
1287
- const renderThumbVertical = (props) => {
1288
- return /* @__PURE__ */ jsx13(
1289
- "div",
1290
- __spreadProps(__spreadValues({}, props), {
1291
- className: clsx_default(`${prefixCls}scroll-area__thumb ${prefixCls}scroll-area__thumb--vertical`, props.className)
1292
- })
1293
- );
1294
- };
1295
- return /* @__PURE__ */ jsx13(
1296
- Scrollbars,
1297
- {
1298
- autoHide,
1299
- className: `${prefixCls}scroll-area`,
1300
- renderTrackHorizontal,
1301
- renderTrackVertical,
1302
- renderThumbHorizontal,
1303
- renderThumbVertical,
1304
- renderView,
1305
- style,
1306
- ref: (node) => {
1307
- node && assignRef(ref, node.container.firstElementChild);
1308
- },
1309
- children
1310
- }
1311
- );
1312
- });
1313
- var ScrollArea_default = ScrollArea;
1314
-
1315
- // src/components/Autocomplete/AutocompleteContext.tsx
1316
- import { createContext as createContext3, useContext as useContext3 } from "react";
1317
- var AutocompleteContext = createContext3(null);
1318
- var useAutocomplete = () => {
1319
- const context = useContext3(AutocompleteContext);
1320
- if (!context) {
1321
- throw new Error("`useAutocomplete` must be used within a `<Autocomplete />`");
1322
- }
1323
- return context;
1324
- };
1325
- var AutocompleteContext_default = AutocompleteContext;
1326
-
1327
- // src/components/Autocomplete/AutocompleteContent.tsx
1328
- import { jsx as jsx14 } from "react/jsx-runtime";
1329
- var AutocompleteContent = () => {
1330
- const { data, values, offset, setOffset, keyField, textField, onItemSelect, renderItem } = useAutocomplete();
1331
- const parentRef = useRef9(null);
1332
- const { isOpen } = usePopover();
1333
- const handleItemSelect = (item) => {
1334
- var _a;
1335
- onItemSelect(item);
1336
- setOffset(((_a = parentRef.current) == null ? void 0 : _a.scrollHeight) || 0);
1337
- };
1338
- useEffect13(() => {
1339
- var _a;
1340
- if (!isOpen)
1341
- return;
1342
- (_a = parentRef.current) == null ? void 0 : _a.scrollTo({ top: offset });
1343
- }, [isOpen]);
1344
- return /* @__PURE__ */ jsx14(
1345
- ScrollArea_default,
1346
- {
1347
- ref: parentRef,
1348
- style: {
1349
- height: `200px`,
1350
- width: `100%`,
1351
- position: "relative"
1352
- },
1353
- children: /* @__PURE__ */ jsx14(List_default, { children: renderItem ? data.map((item) => /* @__PURE__ */ jsx14(Fragment3, { children: renderItem(item, {
1354
- title: "",
1355
- selected: values.includes(item[keyField]),
1356
- hoverable: true,
1357
- onClick: () => handleItemSelect(item)
1358
- }) }, item[keyField])) : data.map((item) => /* @__PURE__ */ jsx14(
1359
- ListItem_default,
1360
- {
1361
- title: item[textField],
1362
- selected: values.includes(item[keyField]),
1363
- hoverable: true,
1364
- onClick: () => handleItemSelect(item)
1365
- },
1366
- item[keyField]
1367
- )) })
1368
- }
1369
- );
1370
- };
1371
- var AutocompleteContent_default = AutocompleteContent;
1372
-
1373
- // src/components/Autocomplete/AutocompleteVirtual.tsx
1374
- import { Fragment as Fragment4, useEffect as useEffect14, useRef as useRef10 } from "react";
1375
-
1376
- // src/components/Autocomplete/utils.ts
1377
- var valueToValues = (value) => {
1378
- return Array.isArray(value) ? value : value !== null ? [value] : [];
1379
- };
1380
- var valuesToValue = (values) => {
1381
- return Array.isArray(values) ? values.length !== 0 ? values[0] : null : values;
1382
- };
1383
-
1384
- // src/components/Autocomplete/AutocompleteVirtual.tsx
1385
- import { jsx as jsx15 } from "react/jsx-runtime";
1386
- var AutocompleteVirtual = () => {
1387
- const { data, values, keyField, textField, virtual, onItemSelect, renderItem } = useAutocomplete();
1388
- const parentRef = useRef10(null);
1389
- const virtualizer = useVirtualizer_default(__spreadProps(__spreadValues({}, virtual), { count: data.length, parentRef }));
1390
- const { isOpen } = usePopover();
1391
- const handleItemSelect = (item) => {
1392
- onItemSelect(item);
1393
- };
1394
- useEffect14(() => {
1395
- if (!isOpen)
1396
- return;
1397
- const value = valuesToValue(values);
1398
- const index = data.findIndex((item) => item[keyField] === value);
1399
- if (index !== -1) {
1400
- virtualizer.scrollToIndex(index, { align: "start" });
1401
- }
1402
- }, [isOpen]);
1403
- if (!virtual)
1404
- return null;
1405
- return /* @__PURE__ */ jsx15(
1406
- ScrollArea_default,
1407
- {
1408
- ref: parentRef,
1409
- autoHide: true,
1410
- style: {
1411
- height: `200px`,
1412
- width: `100%`,
1413
- position: "relative"
1414
- },
1415
- children: /* @__PURE__ */ jsx15(List_default, { children: /* @__PURE__ */ jsx15(
1416
- "div",
1417
- {
1418
- style: {
1419
- height: `${virtualizer.getTotalSize()}px`,
1420
- width: "100%",
1421
- position: "relative"
1422
- },
1423
- children: virtualizer.getVirtualItems().map((virtualItem) => {
1424
- const isLoaderRow = virtualItem.index > data.length - 1;
1425
- const item = data[virtualItem.index];
1426
- if (isLoaderRow) {
1427
- return /* @__PURE__ */ jsx15(
1428
- ListItem_default,
1429
- {
1430
- title: virtual.hasNextPage ? "Loading..." : "Nothing more to load",
1431
- style: {
1432
- position: "absolute",
1433
- top: 0,
1434
- left: 0,
1435
- width: "100%",
1436
- height: `${virtualItem.size}px`,
1437
- transform: `translateY(${virtualItem.start}px)`
1438
- }
1439
- },
1440
- virtualItem.index
1441
- );
1442
- }
1443
- if (!item) {
1444
- return /* @__PURE__ */ jsx15(
1445
- ListItem_default,
1446
- {
1447
- title: `Item ${virtualItem.index} not found`,
1448
- style: {
1449
- position: "absolute",
1450
- top: 0,
1451
- left: 0,
1452
- width: "100%",
1453
- height: `${virtualItem.size}px`,
1454
- transform: `translateY(${virtualItem.start}px)`
1455
- }
1456
- },
1457
- virtualItem.index
1458
- );
1459
- }
1460
- if (renderItem) {
1461
- return /* @__PURE__ */ jsx15(Fragment4, { children: renderItem(item, {
1462
- title: "",
1463
- selected: values.includes(item[keyField]),
1464
- hoverable: true,
1465
- style: {
1466
- position: "absolute",
1467
- top: 0,
1468
- left: 0,
1469
- width: "100%",
1470
- height: `${virtualItem.size}px`,
1471
- transform: `translateY(${virtualItem.start}px)`
1472
- },
1473
- onClick: () => handleItemSelect(item)
1474
- }) }, virtualItem.index);
1475
- }
1476
- return /* @__PURE__ */ jsx15(
1477
- ListItem_default,
1478
- {
1479
- title: item[textField],
1480
- selected: values.includes(item[keyField]),
1481
- hoverable: true,
1482
- style: {
1483
- position: "absolute",
1484
- top: 0,
1485
- left: 0,
1486
- width: "100%",
1487
- height: `${virtualItem.size}px`,
1488
- transform: `translateY(${virtualItem.start}px)`
1489
- },
1490
- onClick: () => handleItemSelect(item)
1491
- },
1492
- virtualItem.index
1493
- );
1494
- })
1495
- }
1496
- ) })
1497
- }
1498
- );
1499
- };
1500
- var AutocompleteVirtual_default = AutocompleteVirtual;
1501
-
1502
- // src/components/Autocomplete/Autocomplete.tsx
1503
- import { jsx as jsx16, jsxs as jsxs10 } from "react/jsx-runtime";
1504
- var Autocomplete = (props) => {
1505
- const {
1506
- data,
1507
- value: valueProp,
1508
- keyField = "key",
1509
- textField = "text",
1510
- isMultiple = false,
1511
- disabled,
1512
- loading,
1513
- disclosure: disclosureProp,
1514
- virtual,
1515
- placeholder,
1516
- className,
1517
- style,
1518
- startContent,
1519
- endContent,
1520
- onFilterChange,
1521
- renderItem
1522
- } = props;
1523
- const disclosure = disclosureProp !== void 0 ? disclosureProp : useDisclosure_default();
1524
- const prefixCls = PREFIX_CLS;
1525
- const inputRef = useRef11(null);
1526
- const [filter, setFilter] = useState11("");
1527
- const [search, setSearch] = useState11("");
1528
- const [isSearch, setIsSearch] = useState11(false);
1529
- const [focus, setFocus] = useState11(false);
1530
- const values = useMemo3(() => {
1531
- return valueToValues(valueProp);
1532
- }, [valueProp]);
1533
- const items = useMemo3(() => {
1534
- return data.filter((item) => values.includes(item[keyField]));
1535
- }, [data, values]);
1536
- const [offset, setOffset] = useState11(0);
1537
- const handleClick = () => {
1538
- var _a;
1539
- (_a = inputRef == null ? void 0 : inputRef.current) == null ? void 0 : _a.focus();
1540
- };
1541
- const handleChange = (values2) => {
1542
- var _a, _b, _c, _d, _e;
1543
- if (props.isMultiple) {
1544
- const items2 = data.filter((item) => values2.includes(item[keyField]));
1545
- (_a = props.onChange) == null ? void 0 : _a.call(props, items2);
1546
- (_b = props.onValueChange) == null ? void 0 : _b.call(props, values2);
1547
- } else {
1548
- const newValue = valuesToValue(values2);
1549
- let item = null;
1550
- if (newValue !== void 0) {
1551
- item = (_c = data.find((item2) => item2[keyField] === newValue)) != null ? _c : null;
1552
- }
1553
- (_d = props.onChange) == null ? void 0 : _d.call(props, item);
1554
- (_e = props.onValueChange) == null ? void 0 : _e.call(props, newValue);
1555
- }
1556
- };
1557
- const handleClear = (event) => {
1558
- var _a, _b, _c, _d;
1559
- event.stopPropagation();
1560
- setIsSearch(true);
1561
- setSearch("");
1562
- if (props.isMultiple) {
1563
- (_a = props.onChange) == null ? void 0 : _a.call(props, []);
1564
- (_b = props.onValueChange) == null ? void 0 : _b.call(props, []);
1565
- } else {
1566
- (_c = props.onChange) == null ? void 0 : _c.call(props, null);
1567
- (_d = props.onValueChange) == null ? void 0 : _d.call(props, null);
1568
- }
1569
- setIsSearch(false);
1570
- };
1571
- const handleFilterChange = (event) => {
1572
- !disclosure.isOpen && disclosure.onOpen();
1573
- setIsSearch(true);
1574
- setSearch(event.target.value);
1575
- onFilterChange == null ? void 0 : onFilterChange(event.target.value);
1576
- };
1577
- const handleItemSelect = (item) => {
1578
- var _a;
1579
- const newValue = item[keyField];
1580
- if (props.isMultiple) {
1581
- const newValues = [...values];
1582
- const valueIndex = values.indexOf(newValue);
1583
- if (valueIndex === -1) {
1584
- newValues.push(newValue);
1585
- } else {
1586
- newValues.splice(valueIndex, 1);
1587
- }
1588
- handleChange(newValues);
1589
- } else {
1590
- const value = valuesToValue(values);
1591
- if (value !== newValue) {
1592
- handleChange([newValue]);
1593
- }
1594
- }
1595
- if (isSearch) {
1596
- setFilter(search);
1597
- }
1598
- setIsSearch(false);
1599
- (_a = inputRef.current) == null ? void 0 : _a.focus();
1600
- disclosure.onClose();
1601
- };
1602
- const handleOpen = () => {
1603
- disclosure.onOpen();
1604
- setFocus(true);
1605
- };
1606
- const handleClose = () => {
1607
- disclosure.onClose();
1608
- if (!props.isMultiple) {
1609
- if (isSearch) {
1610
- const item = items[0];
1611
- if (item !== void 0) {
1612
- setSearch(item[textField]);
1613
- onFilterChange == null ? void 0 : onFilterChange(filter);
1614
- } else {
1615
- setSearch("");
1616
- onFilterChange == null ? void 0 : onFilterChange(filter);
1617
- }
1618
- setIsSearch(false);
1619
- }
1620
- }
1621
- };
1622
- useEffect15(() => {
1623
- if (isSearch)
1624
- return;
1625
- if (!props.isMultiple) {
1626
- const item = items[0];
1627
- if (item !== void 0) {
1628
- setSearch(item[textField]);
1629
- }
1630
- }
1631
- }, [items]);
1632
- useEffect15(() => {
1633
- const values2 = valueToValues(valueProp);
1634
- const value = values2[0];
1635
- if (value === void 0) {
1636
- setSearch("");
1637
- onFilterChange == null ? void 0 : onFilterChange("");
1638
- }
1639
- }, [valueProp]);
1640
- return /* @__PURE__ */ jsx16(
1641
- AutocompleteContext_default.Provider,
1642
- {
1643
- value: {
1644
- data,
1645
- values,
1646
- keyField,
1647
- textField,
1648
- isMultiple,
1649
- virtual,
1650
- onChange: handleChange,
1651
- onItemSelect: handleItemSelect,
1652
- offset,
1653
- setOffset,
1654
- renderItem
1655
- },
1656
- children: /* @__PURE__ */ jsxs10(
1657
- Popover_default,
1658
- __spreadProps(__spreadValues({
1659
- target: true
1660
- }, disclosure), {
1661
- isOpen: disclosure.isOpen,
1662
- onOpen: handleOpen,
1663
- onClose: handleClose,
1664
- autoClose: "outside",
1665
- children: [
1666
- /* @__PURE__ */ jsx16(PopoverTrigger_default, { children: /* @__PURE__ */ jsxs10(
1667
- "div",
1668
- {
1669
- className: clsx_default(
1670
- `${prefixCls}input ${prefixCls}input--filterable`,
1671
- {
1672
- [`${prefixCls}input--focus`]: focus,
1673
- [`${prefixCls}input--disabled`]: disabled
1674
- },
1675
- className
1676
- ),
1677
- style,
1678
- onClick: handleClick,
1679
- onFocus: () => {
1680
- setFocus(true);
1681
- },
1682
- onBlur: () => {
1683
- setFocus(false);
1684
- },
1685
- children: [
1686
- /* @__PURE__ */ jsx16("div", { className: `${prefixCls}outline` }),
1687
- /* @__PURE__ */ jsxs10("div", { className: `${prefixCls}input__content`, children: [
1688
- startContent && /* @__PURE__ */ jsx16("div", { className: `${prefixCls}input__start-content`, children: startContent }),
1689
- /* @__PURE__ */ jsx16(
1690
- "input",
1691
- {
1692
- ref: inputRef,
1693
- className: `${prefixCls}input__field`,
1694
- value: search,
1695
- placeholder,
1696
- disabled,
1697
- onChange: handleFilterChange
1698
- }
1699
- ),
1700
- /* @__PURE__ */ jsxs10("div", { className: `${prefixCls}input__end-content`, children: [
1701
- endContent,
1702
- loading ? /* @__PURE__ */ jsx16(Icon_default, { children: /* @__PURE__ */ jsx16(LoaderIcon_default, { className: `${prefixCls}animation-spin` }) }) : /* @__PURE__ */ jsx16(Button, { color: "secondary", variant: "plain", size: "xs", iconOnly: true, onClick: handleClear, children: /* @__PURE__ */ jsx16(Icon_default, { children: /* @__PURE__ */ jsx16(CloseIcon_default, {}) }) }),
1703
- /* @__PURE__ */ jsx16("div", { style: { pointerEvents: "none" }, children: /* @__PURE__ */ jsx16(Icon_default, { children: disclosure.isOpen ? /* @__PURE__ */ jsx16(ChevronUpIcon_default, {}) : /* @__PURE__ */ jsx16(ChevronDownIcon_default, {}) }) })
1704
- ] })
1705
- ] })
1706
- ]
1707
- }
1708
- ) }),
1709
- /* @__PURE__ */ jsx16(PopoverContent_default, { children: /* @__PURE__ */ jsx16("div", { children: virtual ? /* @__PURE__ */ jsx16(AutocompleteVirtual_default, {}) : /* @__PURE__ */ jsx16(AutocompleteContent_default, {}) }) })
1710
- ]
1711
- })
1712
- )
1713
- }
1714
- );
1715
- };
1716
- var Autocomplete_default = Autocomplete;
1717
-
1718
- // src/components/Backdrop/Backdrop.tsx
1719
- import clsx6 from "clsx";
1720
- import { forwardRef as forwardRef17, useRef as useRef12 } from "react";
1721
- import { mergeRefs as mergeRefs2 } from "react-merge-refs";
1722
- import { jsx as jsx17, jsxs as jsxs11 } from "react/jsx-runtime";
1723
- var Backdrop = forwardRef17((props, ref) => {
1724
- const _a = props, { children, className, isOpen, onClose } = _a, rest = __objRest(_a, ["children", "className", "isOpen", "onClose"]);
1725
- const nodeRef = useRef12(null);
1726
- return /* @__PURE__ */ jsx17(
1727
- Transition_default,
1728
- {
1729
- nodeRef,
1730
- isOpen,
1731
- name: `${PREFIX_CLS}backdrop`,
1732
- enter: 300,
1733
- leave: 300,
1734
- mountOnEnter: true,
1735
- unmountOnExit: true,
1736
- children: /* @__PURE__ */ jsx17(Portal_default, { children: /* @__PURE__ */ jsxs11(
1737
- "div",
1738
- __spreadProps(__spreadValues({
1739
- ref: mergeRefs2([ref, nodeRef]),
1740
- className: clsx6(`${PREFIX_CLS}backdrop`, className),
1741
- tabIndex: -1
1742
- }, rest), {
1743
- children: [
1744
- /* @__PURE__ */ jsx17("div", { className: `${PREFIX_CLS}backdrop__overlay`, onClick: onClose }),
1745
- children
1746
- ]
1747
- })
1748
- ) })
1749
- }
1750
- );
1751
- });
1752
- var Backdrop_default = Backdrop;
1753
-
1754
- // src/components/Badge/Badge.tsx
1755
- import clsx7 from "clsx";
1756
- import { jsx as jsx18, jsxs as jsxs12 } from "react/jsx-runtime";
1757
- var Badge = ({ children, placement, content }) => {
1758
- return /* @__PURE__ */ jsxs12("div", { className: clsx7(`${PREFIX_CLS}badge-wrapper`), children: [
1759
- children,
1760
- /* @__PURE__ */ jsx18(
1761
- "div",
1762
- {
1763
- className: clsx7(`${PREFIX_CLS}badge`, {
1764
- [`${PREFIX_CLS}badge--${placement}`]: placement
1765
- }),
1766
- children: content
1767
- }
1768
- )
1769
- ] });
1770
- };
1771
- var Badge_default = Badge;
1772
-
1773
- // src/components/Card/Card.tsx
1774
- import { forwardRef as forwardRef18 } from "react";
1775
- import { jsx as jsx19 } from "react/jsx-runtime";
1776
- var Card = forwardRef18((_a, ref) => {
1777
- var _b = _a, { as: Component = "div", children, className } = _b, rest = __objRest(_b, ["as", "children", "className"]);
1778
- const prefixCls = PREFIX_CLS;
1779
- return /* @__PURE__ */ jsx19(Component, __spreadProps(__spreadValues({ ref, className: clsx_default(`${prefixCls}card`, className) }, rest), { children }));
1780
- });
1781
- var Card_default = Card;
1782
-
1783
- // src/components/Card/CardHeader.tsx
1784
- import { forwardRef as forwardRef19 } from "react";
1785
- import { jsx as jsx20, jsxs as jsxs13 } from "react/jsx-runtime";
1786
- var CardHeader = forwardRef19(
1787
- (_a, ref) => {
1788
- var _b = _a, { as: Component = "div", className, title, subtitle, startContent, endContent } = _b, rest = __objRest(_b, ["as", "className", "title", "subtitle", "startContent", "endContent"]);
1789
- const prefixCls = PREFIX_CLS;
1790
- return /* @__PURE__ */ jsxs13(Component, __spreadProps(__spreadValues({ ref, className: clsx_default(`${prefixCls}card-header`, className) }, rest), { children: [
1791
- startContent && /* @__PURE__ */ jsx20("div", { className: `${prefixCls}card-header__start-content`, children: startContent }),
1792
- /* @__PURE__ */ jsxs13("div", { className: `${prefixCls}card-header__content`, children: [
1793
- /* @__PURE__ */ jsx20("div", { className: `${prefixCls}card-header__title`, children: title }),
1794
- subtitle && /* @__PURE__ */ jsx20("div", { className: `${prefixCls}card-header__subtitle`, children: subtitle })
1795
- ] }),
1796
- endContent && /* @__PURE__ */ jsx20("div", { className: `${prefixCls}card-header__end-content`, children: endContent })
1797
- ] }));
1798
- }
1799
- );
1800
- var CardHeader_default = CardHeader;
1801
-
1802
- // src/components/Chip/Chip.tsx
1803
- import clsx8 from "clsx";
1804
- import { forwardRef as forwardRef20 } from "react";
1805
- import { jsx as jsx21, jsxs as jsxs14 } from "react/jsx-runtime";
1806
- var Chip = forwardRef20(
1807
- (_a, ref) => {
1808
- var _b = _a, { as: Component = "div", children, className, variant = "text", color = "primary", size = "md" } = _b, rest = __objRest(_b, ["as", "children", "className", "variant", "color", "size"]);
1809
- return /* @__PURE__ */ jsxs14(
1810
- Component,
1811
- __spreadProps(__spreadValues({
1812
- ref,
1813
- className: clsx8(
1814
- `${PREFIX_CLS}chip`,
1815
- {
1816
- [`${PREFIX_CLS}chip--${variant}`]: variant,
1817
- [`${PREFIX_CLS}chip--${color}`]: color,
1818
- [`${PREFIX_CLS}chip--${size}`]: size
1819
- },
1820
- className
1821
- )
1822
- }, rest), {
1823
- children: [
1824
- /* @__PURE__ */ jsx21("div", { className: clsx8(`${PREFIX_CLS}overlay`) }),
1825
- /* @__PURE__ */ jsx21("div", { className: `${PREFIX_CLS}outline` }),
1826
- children
1827
- ]
1828
- })
1829
- );
1830
- }
1831
- );
1832
- var Chip_default = Chip;
1833
-
1834
- // src/components/Drawer/Drawer.tsx
1835
- import clsx9 from "clsx";
1836
- import { forwardRef as forwardRef21, useRef as useRef13 } from "react";
1837
- import { mergeRefs as mergeRefs3 } from "react-merge-refs";
1838
- import { jsx as jsx22, jsxs as jsxs15 } from "react/jsx-runtime";
1839
- var Drawer = forwardRef21((props, ref) => {
1840
- const { children, className, isOpen, size = "md", position = "left", onClose } = props;
1841
- const nodeRef = useRef13(null);
1842
- const handleClose = () => {
1843
- onClose();
1844
- };
1845
- return /* @__PURE__ */ jsx22(Backdrop_default, { isOpen, onClose: handleClose, children: /* @__PURE__ */ jsx22(Transition_default, { nodeRef, isOpen, name: `${PREFIX_CLS}drawer`, enter: 600, leave: 300, unmountOnExit: true, children: /* @__PURE__ */ jsxs15(
1846
- "div",
1847
- {
1848
- ref: mergeRefs3([ref, nodeRef]),
1849
- className: clsx9(
1850
- `${PREFIX_CLS}drawer`,
1851
- {
1852
- [`${PREFIX_CLS}drawer--${size}`]: size,
1853
- [`${PREFIX_CLS}drawer--${position}`]: position
1854
- },
1855
- className
1856
- ),
1857
- children: [
1858
- /* @__PURE__ */ jsx22("div", { className: `${PREFIX_CLS}drawer__overlay` }),
1859
- children
1860
- ]
1861
- }
1862
- ) }) });
1863
- });
1864
- var Drawer_default = Drawer;
1865
-
1866
- // src/components/Menu/Menu.tsx
1867
- import clsx13 from "clsx";
1868
- import { useEffect as useEffect17, useMemo as useMemo6, useState as useState12 } from "react";
1869
-
1870
- // src/components/Menu/MenuContext.tsx
1871
- import { createContext as createContext4, useContext as useContext4 } from "react";
1872
- var MenuContext = createContext4(null);
1873
- var useMenu = () => {
1874
- const context = useContext4(MenuContext);
1875
- if (!context) {
1876
- throw new Error("`useMenu` must be used within a `<Menu />`");
1877
- }
1878
- return context;
1879
- };
1880
- var MenuContext_default = MenuContext;
1881
-
1882
- // src/components/Menu/MenuGroup.tsx
1883
- import clsx12 from "clsx";
1884
- import { useMemo as useMemo5 } from "react";
1885
-
1886
- // src/components/Menu/MenuItem.tsx
1887
- import clsx10 from "clsx";
1888
- import { forwardRef as forwardRef22, useContext as useContext6, useEffect as useEffect16 } from "react";
1889
-
1890
- // src/components/Menu/MenuValueContext.tsx
1891
- import { createContext as createContext5, useContext as useContext5 } from "react";
1892
- var MenuValueContext = createContext5([]);
1893
- var useMenuItemValue = () => {
1894
- const context = useContext5(MenuValueContext);
1895
- if (!context) {
1896
- throw new Error("`useMenuValue` must be used within a `<MenuValueContext.Provider />`");
1897
- }
1898
- return context;
1899
- };
1900
- var MenuValueContext_default = MenuValueContext;
1901
-
1902
- // src/components/Menu/MenuItem.tsx
1903
- import { jsx as jsx23, jsxs as jsxs16 } from "react/jsx-runtime";
1904
- var MenuItem = forwardRef22((props, ref) => {
1905
- const _a = props, { as: Component = "div", className, style, value, title, icon, level = 1, disabled, onClick } = _a, rest = __objRest(_a, ["as", "className", "style", "value", "title", "icon", "level", "disabled", "onClick"]);
1906
- const { value: menuValue, originalValue, navMode, onChange, onOpen, onItemSelect } = useMenu();
1907
- const values = useContext6(MenuValueContext_default);
1908
- const mergedValues = [...values, value];
1909
- const isSelected = menuValue[level - 1] === value;
1910
- const handleClick = (event) => {
1911
- if (value !== void 0) {
1912
- onChange(mergedValues);
1913
- }
1914
- onClick == null ? void 0 : onClick(event);
1915
- onItemSelect == null ? void 0 : onItemSelect(props);
1916
- };
1917
- useEffect16(() => {
1918
- if (navMode === "automatic" && originalValue.length > 0 && originalValue[originalValue.length - 1] === value) {
1919
- onOpen(values);
1920
- onChange(mergedValues);
1921
- }
1922
- }, [value, originalValue, navMode]);
1923
- return /* @__PURE__ */ jsxs16(
1924
- Component,
1925
- __spreadProps(__spreadValues({
1926
- ref,
1927
- className: clsx10(
1928
- `${PREFIX_CLS}menu-item`,
1929
- {
1930
- [`${PREFIX_CLS}menu-item--selected`]: isSelected,
1931
- [`${PREFIX_CLS}menu-item--disabled`]: disabled
1932
- },
1933
- className
1934
- ),
1935
- style: __spreadValues({
1936
- paddingLeft: level <= 1 ? `var(--${PREFIX_CLS}menu-item-padding-x)` : `calc(${level} * var(--${PREFIX_CLS}menu-item-padding-level))`
1937
- }, style),
1938
- onClick: handleClick
1939
- }, rest), {
1940
- children: [
1941
- /* @__PURE__ */ jsx23("div", { className: `${PREFIX_CLS}overlay`, children: /* @__PURE__ */ jsx23("div", { className: `${PREFIX_CLS}overlay__surface` }) }),
1942
- icon && /* @__PURE__ */ jsx23("div", { className: `${PREFIX_CLS}menu-item__icon`, children: icon }),
1943
- /* @__PURE__ */ jsx23("div", { className: `${PREFIX_CLS}menu-item__content`, children: /* @__PURE__ */ jsx23("span", { className: `${PREFIX_CLS}menu-item__title`, children: title }) })
1944
- ]
1945
- })
1946
- );
1947
- });
1948
- MenuItem.displayName = "MenuItem";
1949
- var MenuItem_default = MenuItem;
1950
-
1951
- // src/components/Menu/MenuSubmenu.tsx
1952
- import clsx11 from "clsx";
1953
- import { useContext as useContext7, useMemo as useMemo4 } from "react";
1954
-
1955
- // src/components/Menu/utils.ts
1956
- var getOpenValuesByPathname = (pathname) => {
1957
- return pathname.split("/").reduce((previousValue, currentValue) => {
1958
- const previousPath = previousValue[previousValue.length - 1];
1959
- if (previousPath != void 0) {
1960
- previousValue.push(previousPath + "/" + currentValue);
1961
- } else {
1962
- previousValue.push("");
1963
- }
1964
- return previousValue;
1965
- }, []);
1966
- };
1967
- var addOrRemoveValueInArray = (array, value) => {
1968
- const index = array.indexOf(value);
1969
- const newArray = [...array];
1970
- if (index === -1) {
1971
- newArray.push(value);
1972
- } else {
1973
- newArray.splice(index, 1);
1974
- }
1975
- return newArray;
1976
- };
1977
-
1978
- // src/components/Menu/MenuSubmenu.tsx
1979
- import { jsx as jsx24, jsxs as jsxs17 } from "react/jsx-runtime";
1980
- var MenuSubmenu = (_a) => {
1981
- var _b = _a, {
1982
- children,
1983
- className,
1984
- style,
1985
- value,
1986
- title,
1987
- icon,
1988
- level = 1,
1989
- items,
1990
- onClick
1991
- } = _b, rest = __objRest(_b, [
1992
- "children",
1993
- "className",
1994
- "style",
1995
- "value",
1996
- "title",
1997
- "icon",
1998
- "level",
1999
- "items",
2000
- "onClick"
2001
- ]);
2002
- const { value: menuValue, openValues, expandMode, onOpen } = useMenu();
2003
- const values = useContext7(MenuValueContext_default);
2004
- const isOpen = openValues.includes(value);
2005
- const mergedValues = [...values, value];
2006
- const isSelected = menuValue[level - 1] === value;
2007
- const content = useMemo4(() => {
2008
- return items == null ? void 0 : items.map((_a2, index) => {
2009
- var _b2 = _a2, { type } = _b2, item = __objRest(_b2, ["type"]);
2010
- return type === "item" ? /* @__PURE__ */ jsx24(MenuItem_default, __spreadValues({ level: level !== void 0 ? level + 1 : void 0 }, item), index) : type === "submenu" ? /* @__PURE__ */ jsx24(MenuSubmenu, __spreadValues({ level: level !== void 0 ? level + 1 : void 0 }, item), index) : type === "group" ? /* @__PURE__ */ jsx24(MenuGroup_default, __spreadValues({ level: level !== void 0 ? level + 1 : void 0 }, item), index) : /* @__PURE__ */ jsx24(MenuItem_default, __spreadValues({ level: level !== void 0 ? level + 1 : void 0 }, item), index);
2011
- });
2012
- }, [items]);
2013
- const handleClick = (event) => {
2014
- if (expandMode === "multiple") {
2015
- const updatedOpenValues = addOrRemoveValueInArray(openValues, value);
2016
- onOpen(updatedOpenValues);
2017
- } else {
2018
- if (isOpen) {
2019
- const updatedOpenValues = addOrRemoveValueInArray(mergedValues, value);
2020
- onOpen(updatedOpenValues);
2021
- } else {
2022
- const updatedOpenValues = addOrRemoveValueInArray(values, value);
2023
- onOpen(updatedOpenValues);
2024
- }
2025
- }
2026
- onClick == null ? void 0 : onClick(event);
2027
- };
2028
- return /* @__PURE__ */ jsx24(MenuValueContext_default.Provider, { value: mergedValues, children: /* @__PURE__ */ jsx24("div", { className: clsx11(`${PREFIX_CLS}menu-submenu`), children: /* @__PURE__ */ jsxs17(Collapse_default, { isOpen, children: [
2029
- /* @__PURE__ */ jsx24(CollapseTrigger_default, { children: /* @__PURE__ */ jsxs17(
2030
- "div",
2031
- __spreadProps(__spreadValues({
2032
- className: clsx11(
2033
- `${PREFIX_CLS}menu-item`,
2034
- {
2035
- [`${PREFIX_CLS}menu-item--selected`]: isSelected || items && mergedValues.includes(menuValue)
2036
- },
2037
- className
2038
- ),
2039
- style: __spreadValues({
2040
- paddingLeft: level <= 1 ? `var(--${PREFIX_CLS}menu-item-padding-x)` : `calc(${level} * var(--${PREFIX_CLS}menu-item-padding-level))`
2041
- }, style),
2042
- onClick: handleClick
2043
- }, rest), {
2044
- children: [
2045
- /* @__PURE__ */ jsx24("div", { className: `${PREFIX_CLS}overlay`, children: /* @__PURE__ */ jsx24("div", { className: `${PREFIX_CLS}overlay__surface` }) }),
2046
- icon && /* @__PURE__ */ jsx24("div", { className: `${PREFIX_CLS}menu-item__icon`, children: icon }),
2047
- /* @__PURE__ */ jsx24("div", { className: `${PREFIX_CLS}menu-item__content`, children: /* @__PURE__ */ jsx24("span", { className: `${PREFIX_CLS}menu-item__title`, children: title }) }),
2048
- /* @__PURE__ */ jsx24("div", { className: `${PREFIX_CLS}menu-item__icon`, children: isOpen ? /* @__PURE__ */ jsx24(ChevronUpIcon_default, { className: `${PREFIX_CLS}icon` }) : /* @__PURE__ */ jsx24(ChevronDownIcon_default, { className: `${PREFIX_CLS}icon` }) })
2049
- ]
2050
- })
2051
- ) }),
2052
- /* @__PURE__ */ jsx24(CollapseContent_default, { children: /* @__PURE__ */ jsx24(
2053
- "ul",
2054
- {
2055
- className: clsx11(`${PREFIX_CLS}menu`, {
2056
- [`${PREFIX_CLS}menu-open`]: !isOpen
2057
- }),
2058
- children: content || children
2059
- }
2060
- ) })
2061
- ] }) }) });
2062
- };
2063
- var MenuSubmenu_default = MenuSubmenu;
2064
-
2065
- // src/components/Menu/MenuGroup.tsx
2066
- import { Fragment as Fragment5, jsx as jsx25, jsxs as jsxs18 } from "react/jsx-runtime";
2067
- var MenuGroup = (_a) => {
2068
- var _b = _a, {
2069
- children,
2070
- className,
2071
- style,
2072
- title,
2073
- icon,
2074
- level = 1,
2075
- items
2076
- } = _b, rest = __objRest(_b, [
2077
- "children",
2078
- "className",
2079
- "style",
2080
- "title",
2081
- "icon",
2082
- "level",
2083
- "items"
2084
- ]);
2085
- const content = useMemo5(() => {
2086
- return items == null ? void 0 : items.map((_a2, index) => {
2087
- var _b2 = _a2, { type } = _b2, item = __objRest(_b2, ["type"]);
2088
- return type === "item" ? /* @__PURE__ */ jsx25(MenuItem_default, __spreadValues({}, item), index) : type === "submenu" ? /* @__PURE__ */ jsx25(MenuSubmenu_default, __spreadValues({}, item), index) : /* @__PURE__ */ jsx25(MenuItem_default, __spreadValues({}, item), index);
2089
- });
2090
- }, [items]);
2091
- return /* @__PURE__ */ jsxs18(Fragment5, { children: [
2092
- /* @__PURE__ */ jsxs18(
2093
- "div",
2094
- __spreadProps(__spreadValues({
2095
- className: clsx12(`${PREFIX_CLS}menu-group`, className),
2096
- style: __spreadValues({
2097
- paddingLeft: level <= 1 ? `var(--${PREFIX_CLS}menu-group-padding-x)` : `calc(${level} * var(--${PREFIX_CLS}menu-group-padding-level))`
2098
- }, style)
2099
- }, rest), {
2100
- children: [
2101
- icon && /* @__PURE__ */ jsx25("div", { className: `${PREFIX_CLS}menu-group__icon`, children: icon }),
2102
- /* @__PURE__ */ jsx25("div", { className: `${PREFIX_CLS}menu-group__content`, children: /* @__PURE__ */ jsx25("span", { className: `${PREFIX_CLS}menu-group__title`, children: title }) })
2103
- ]
2104
- })
2105
- ),
2106
- content || children
2107
- ] });
2108
- };
2109
- var MenuGroup_default = MenuGroup;
2110
-
2111
- // src/components/Menu/Menu.tsx
2112
- import { jsx as jsx26 } from "react/jsx-runtime";
2113
- var Menu = (_a) => {
2114
- var _b = _a, {
2115
- children,
2116
- value: valueProp = [],
2117
- defaultValue,
2118
- openValues: openValuesProp,
2119
- expandMode = "multiple",
2120
- navMode = "manual",
2121
- items,
2122
- onChange,
2123
- onOpen,
2124
- onItemSelect
2125
- } = _b, rest = __objRest(_b, [
2126
- "children",
2127
- "value",
2128
- "defaultValue",
2129
- "openValues",
2130
- "expandMode",
2131
- "navMode",
2132
- "items",
2133
- "onChange",
2134
- "onOpen",
2135
- "onItemSelect"
2136
- ]);
2137
- var _a2;
2138
- const [selfValue, setSelfValue] = useState12((_a2 = valueProp != null ? valueProp : defaultValue) != null ? _a2 : []);
2139
- const [selfOpenValues, setSelfOpenValues] = useState12(openValuesProp != null ? openValuesProp : []);
2140
- const content = useMemo6(() => {
2141
- return items == null ? void 0 : items.map((_a3, index) => {
2142
- var _b2 = _a3, { type } = _b2, item = __objRest(_b2, ["type"]);
2143
- return type === "item" ? /* @__PURE__ */ jsx26(MenuItem_default, __spreadValues({}, item), index) : type === "submenu" ? /* @__PURE__ */ jsx26(MenuSubmenu_default, __spreadValues({}, item), index) : type === "group" ? /* @__PURE__ */ jsx26(MenuGroup_default, __spreadValues({}, item), index) : /* @__PURE__ */ jsx26(MenuItem_default, __spreadValues({}, item), index);
2144
- });
2145
- }, [items]);
2146
- const handleChange = (value) => {
2147
- if (valueProp !== void 0 && navMode !== "automatic") {
2148
- onChange == null ? void 0 : onChange(value);
2149
- } else {
2150
- setSelfValue(value);
2151
- }
2152
- };
2153
- const handleOpen = (values) => {
2154
- if (openValuesProp !== void 0) {
2155
- onOpen == null ? void 0 : onOpen(values);
2156
- } else {
2157
- setSelfOpenValues(values);
2158
- }
2159
- };
2160
- const handleItemSelect = (props) => {
2161
- onItemSelect == null ? void 0 : onItemSelect(props);
2162
- };
2163
- useEffect17(() => {
2164
- if (valueProp !== void 0 && navMode !== "automatic") {
2165
- setSelfValue(valueProp);
2166
- }
2167
- }, [valueProp]);
2168
- useEffect17(() => {
2169
- if (openValuesProp !== void 0) {
2170
- setSelfOpenValues(openValuesProp);
2171
- }
2172
- }, [openValuesProp]);
2173
- return /* @__PURE__ */ jsx26(
2174
- MenuContext_default.Provider,
2175
- {
2176
- value: {
2177
- value: selfValue,
2178
- originalValue: valueProp,
2179
- openValues: selfOpenValues,
2180
- expandMode,
2181
- navMode,
2182
- onOpen: handleOpen,
2183
- onChange: handleChange,
2184
- onItemSelect: handleItemSelect
2185
- },
2186
- children: /* @__PURE__ */ jsx26("div", __spreadProps(__spreadValues({ className: clsx13(`${PREFIX_CLS}menu`) }, rest), { children: content || children }))
2187
- }
2188
- );
2189
- };
2190
- Menu.displayName = "Menu";
2191
- var Menu_default = Menu;
2192
-
2193
- // src/components/Accordion/Accordion.tsx
2194
- import { forwardRef as forwardRef23 } from "react";
2195
- import { jsx as jsx27 } from "react/jsx-runtime";
2196
- var Accordion = forwardRef23((props, ref) => {
2197
- const _a = props, { children, className } = _a, rest = __objRest(_a, ["children", "className"]);
2198
- const prefixCls = PREFIX_CLS;
2199
- return /* @__PURE__ */ jsx27("div", __spreadProps(__spreadValues({ ref, className: clsx_default(`${prefixCls}accordion`, className) }, rest), { children }));
2200
- });
2201
- var Accordion_default = Accordion;
2202
-
2203
- // src/components/Accordion/AccordionItem.tsx
2204
- import { createContext as createContext6, forwardRef as forwardRef24, useContext as useContext8, useState as useState13 } from "react";
2205
- import { v4 as uuid } from "uuid";
2206
- import { jsx as jsx28 } from "react/jsx-runtime";
2207
- var AccordionItemContext = createContext6(null);
2208
- var useAccordionItem = () => {
2209
- const context = useContext8(AccordionItemContext);
2210
- if (!context) {
2211
- throw new Error("`useAccordionItem` must be used within a `<AccordionItem />`");
2212
- }
2213
- return context;
2214
- };
2215
- var AccordionItem = forwardRef24((props, ref) => {
2216
- const _a = props, { children, className, value: valueProp } = _a, rest = __objRest(_a, ["children", "className", "value"]);
2217
- const [id] = useState13(uuid());
2218
- const value = valueProp != null ? valueProp : id;
2219
- const { isOpen, onOpen, onClose, onToggle } = useDisclosure_default({ defaultValue: true });
2220
- const prefixCls = PREFIX_CLS;
2221
- return /* @__PURE__ */ jsx28(AccordionItemContext.Provider, { value: { value }, children: /* @__PURE__ */ jsx28("div", __spreadProps(__spreadValues({ ref, className: clsx_default(`${prefixCls}accordion-item`, className) }, rest), { children: /* @__PURE__ */ jsx28(Collapse_default, { isOpen, onOpen, onClose, onToggle, children }) })) });
2222
- });
2223
- var AccordionItem_default = AccordionItem;
2224
-
2225
- // src/components/Accordion/AccordionHeader.tsx
2226
- import { forwardRef as forwardRef25 } from "react";
2227
- import { jsx as jsx29, jsxs as jsxs19 } from "react/jsx-runtime";
2228
- var AccordionHeader = forwardRef25((props, ref) => {
2229
- const _a = props, { className, title, subtitle, startContent, endContent } = _a, rest = __objRest(_a, ["className", "title", "subtitle", "startContent", "endContent"]);
2230
- const prefixCls = PREFIX_CLS;
2231
- const { isOpen } = useCollapse();
2232
- return /* @__PURE__ */ jsx29(CollapseTrigger_default, { children: /* @__PURE__ */ jsxs19("div", __spreadProps(__spreadValues({ ref, className: clsx_default(`${prefixCls}accordion-header`, className) }, rest), { children: [
2233
- startContent && /* @__PURE__ */ jsx29("div", { className: `${prefixCls}accordion-header__start-content`, children: startContent }),
2234
- /* @__PURE__ */ jsxs19("div", { className: `${prefixCls}accordion-header__content`, children: [
2235
- /* @__PURE__ */ jsx29("div", { className: `${prefixCls}accordion-header__title`, children: title }),
2236
- subtitle && /* @__PURE__ */ jsx29("div", { className: `${prefixCls}accordion-header__subtitle`, children: subtitle })
2237
- ] }),
2238
- /* @__PURE__ */ jsx29("div", { className: `${prefixCls}accordion-header__end-content`, children: /* @__PURE__ */ jsxs19("div", { className: "us-d-flex us-items-center us-gap-1", children: [
2239
- endContent,
2240
- /* @__PURE__ */ jsx29(Button, { type: "button", variant: "text", color: "secondary", size: "sm", iconOnly: true, children: /* @__PURE__ */ jsx29(Icon_default, { children: isOpen ? /* @__PURE__ */ jsx29(ChevronUpIcon_default, {}) : /* @__PURE__ */ jsx29(ChevronDownIcon_default, {}) }) })
2241
- ] }) })
2242
- ] })) });
2243
- });
2244
- var AccordionHeader_default = AccordionHeader;
2245
-
2246
- // src/components/Accordion/AccordionPanel.tsx
2247
- import { forwardRef as forwardRef26 } from "react";
2248
- import { jsx as jsx30 } from "react/jsx-runtime";
2249
- var AccordionPanel = forwardRef26((_a, ref) => {
2250
- var _b = _a, { children, className } = _b, rest = __objRest(_b, ["children", "className"]);
2251
- const prefixCls = PREFIX_CLS;
2252
- return /* @__PURE__ */ jsx30(CollapseContent_default, { children: /* @__PURE__ */ jsx30("div", { ref, children: /* @__PURE__ */ jsx30("div", __spreadProps(__spreadValues({ className: clsx_default(`${prefixCls}accordion-panel`, className) }, rest), { children })) }) });
2253
- });
2254
- var AccordionPanel_default = AccordionPanel;
2255
-
2256
- // src/components/Accordion/AccordionContent.tsx
2257
- import { forwardRef as forwardRef27 } from "react";
2258
- import { jsx as jsx31 } from "react/jsx-runtime";
2259
- var AccordionContent = forwardRef27((_a, ref) => {
2260
- var _b = _a, { children, className } = _b, rest = __objRest(_b, ["children", "className"]);
2261
- const prefixCls = PREFIX_CLS;
2262
- return /* @__PURE__ */ jsx31(CollapseContent_default, { children: /* @__PURE__ */ jsx31("div", { ref, children: /* @__PURE__ */ jsx31("div", __spreadProps(__spreadValues({ className: clsx_default(`${prefixCls}accordion-content`, className) }, rest), { children })) }) });
2263
- });
2264
- var AccordionContent_default = AccordionContent;
2265
-
2266
- // src/components/Tabs/Tab.tsx
2267
- import clsx14 from "clsx";
2268
- import mergeRefs4 from "merge-refs";
2269
- import { forwardRef as forwardRef28, useEffect as useEffect18, useRef as useRef14, useState as useState14 } from "react";
2270
- import { v4 as uuid2 } from "uuid";
2271
-
2272
- // src/components/Tabs/TabsContext.ts
2273
- import { createContext as createContext7, useContext as useContext9 } from "react";
2274
- var TabsContext = createContext7(null);
2275
- var useTabs = () => {
2276
- const context = useContext9(TabsContext);
2277
- if (!context) {
2278
- throw new Error("`useTabs` must be used within a `<Tabs />`");
2279
- }
2280
- return context;
2281
- };
2282
-
2283
- // src/components/Tabs/Tab.tsx
2284
- import { jsx as jsx32, jsxs as jsxs20 } from "react/jsx-runtime";
2285
- var Tab = forwardRef28(
2286
- (_a, ref) => {
2287
- var _b = _a, {
2288
- as: Component = "div",
2289
- children,
2290
- className,
2291
- role = "presentation",
2292
- value: valueProp,
2293
- startContent,
2294
- endContent,
2295
- closable,
2296
- disabled,
2297
- onClick
2298
- } = _b, rest = __objRest(_b, [
2299
- "as",
2300
- "children",
2301
- "className",
2302
- "role",
2303
- "value",
2304
- "startContent",
2305
- "endContent",
2306
- "closable",
2307
- "disabled",
2308
- "onClick"
2309
- ]);
2310
- const prefixCls = PREFIX_CLS;
2311
- const tabRef = useRef14(null);
2312
- const [id] = useState14(uuid2());
2313
- const value = valueProp != null ? valueProp : id;
2314
- const _a2 = useTabs(), { onClose, registerItem } = _a2, tabs = __objRest(_a2, ["onClose", "registerItem"]);
2315
- const handleClick = (event) => {
2316
- const previousTab = tabs.previousTabRef.current;
2317
- const currentTab = tabRef.current;
2318
- if (!currentTab)
2319
- return;
2320
- if (previousTab) {
2321
- const previousIndicator = previousTab.querySelector(`.${prefixCls}tab__indicator`);
2322
- const currentIndicator = currentTab.querySelector(`.${prefixCls}tab__indicator`);
2323
- if (!previousIndicator || !currentIndicator)
2324
- return;
2325
- const from = {};
2326
- const fromRect = previousIndicator.getBoundingClientRect();
2327
- const fromPos = fromRect.left;
2328
- const fromWidth = fromRect.width;
2329
- const toRect = currentIndicator.getBoundingClientRect();
2330
- const toPos = toRect.left;
2331
- const toWidth = toRect.width;
2332
- const scale = fromWidth / toWidth;
2333
- if (scale) {
2334
- from["transform"] = `translateX(${(fromPos - toPos).toFixed(4)}px) scaleX(${scale.toFixed(4)})`;
2335
- } else {
2336
- from["opacity"] = 0;
2337
- }
2338
- const keyframes = [from, { transform: "none" }];
2339
- currentIndicator.animate(keyframes, {
2340
- duration: 250,
2341
- easing: "cubic-bezier(.3,0,0,1)"
2342
- });
2343
- tabs.previousTabRef.current = tabRef.current;
2344
- }
2345
- tabs.previousTabRef.current = tabRef.current;
2346
- tabs.onChange(value);
2347
- onClick == null ? void 0 : onClick(event);
2348
- };
2349
- const handleClose = (event) => {
2350
- event.stopPropagation();
2351
- onClose(value);
2352
- };
2353
- useEffect18(() => {
2354
- registerItem({ value, disabled });
2355
- if (value === tabs.value) {
2356
- tabs.previousTabRef.current = tabRef.current;
2357
- }
2358
- }, [value, tabs.value]);
2359
- return /* @__PURE__ */ jsxs20(
2360
- Component,
2361
- __spreadProps(__spreadValues({
2362
- ref: mergeRefs4(tabRef, ref, (el) => tabs.tabRefs.current[value] = el),
2363
- className: clsx14(
2364
- `${prefixCls}tab`,
2365
- { [`${prefixCls}tab--selected`]: value === tabs.value, [`${prefixCls}tab--disabled`]: disabled },
2366
- className
2367
- ),
2368
- role,
2369
- onClick: handleClick
2370
- }, rest), {
2371
- children: [
2372
- /* @__PURE__ */ jsx32("div", { className: `${prefixCls}overlay`, children: /* @__PURE__ */ jsx32("div", { className: `${prefixCls}overlay__surface` }) }),
2373
- /* @__PURE__ */ jsxs20("div", { className: `${prefixCls}tab__content`, children: [
2374
- startContent && /* @__PURE__ */ jsx32("div", { className: `${prefixCls}tab__start-content`, children: startContent }),
2375
- children,
2376
- endContent || closable && /* @__PURE__ */ jsxs20("div", { className: `${prefixCls}tab__end-content`, children: [
2377
- endContent,
2378
- closable && /* @__PURE__ */ jsx32(Button, { variant: "text", color: "secondary", iconOnly: true, size: "xs", onClick: handleClose, children: /* @__PURE__ */ jsx32(Icon_default, { children: /* @__PURE__ */ jsx32(CloseIcon_default, {}) }) })
2379
- ] })
2380
- ] }),
2381
- /* @__PURE__ */ jsx32("div", { className: `${prefixCls}tab__indicator` })
2382
- ]
2383
- })
2384
- );
2385
- }
2386
- );
2387
-
2388
- // src/components/Tabs/Tabs.tsx
2389
- import clsx15 from "clsx";
2390
- import { useEffect as useEffect19, useRef as useRef15, useState as useState15 } from "react";
2391
- import { jsx as jsx33, jsxs as jsxs21 } from "react/jsx-runtime";
2392
- var Tabs = (_a) => {
2393
- var _b = _a, {
2394
- children,
2395
- className,
2396
- value,
2397
- defaultValue,
2398
- alignment = "start",
2399
- onChange,
2400
- onClose
2401
- } = _b, rest = __objRest(_b, [
2402
- "children",
2403
- "className",
2404
- "value",
2405
- "defaultValue",
2406
- "alignment",
2407
- "onChange",
2408
- "onClose"
2409
- ]);
2410
- const tabsRef = useRef15(null);
2411
- const tabRefs = useRef15({});
2412
- const previousTabRef = useRef15(null);
2413
- const [selfValue, setSelfValue] = useState15(value != null ? value : defaultValue);
2414
- const [items, setItems] = useState15([]);
2415
- const registerItem = (item) => {
2416
- setItems((prevItems) => {
2417
- const index = prevItems.findIndex((item2) => item2.value);
2418
- if (index === -1) {
2419
- prevItems.push(item);
2420
- }
2421
- return prevItems;
2422
- });
2423
- };
2424
- const scrollToTab = (value2) => {
2425
- const tabsEl = tabsRef.current;
2426
- if (!tabsEl)
2427
- return;
2428
- const currentTabEl = tabRefs.current[value2];
2429
- if (!currentTabEl)
2430
- return;
2431
- scrollToItem(tabsEl, currentTabEl);
2432
- };
2433
- const handleChange = (value2) => {
2434
- setSelfValue(value2);
2435
- onChange == null ? void 0 : onChange(value2);
2436
- scrollToTab(value2);
2437
- };
2438
- const handleClose = (value2) => {
2439
- onClose == null ? void 0 : onClose(value2);
2440
- };
2441
- useEffect19(() => {
2442
- if (value !== void 0) {
2443
- setSelfValue(value);
2444
- scrollToTab(value);
2445
- }
2446
- }, [value]);
2447
- useEffect19(() => {
2448
- if (value === void 0) {
2449
- const item = items.find((tab) => !tab.disabled);
2450
- setSelfValue(item == null ? void 0 : item.value);
2451
- }
2452
- }, [value, items]);
2453
- return /* @__PURE__ */ jsxs21(
2454
- TabsContext.Provider,
2455
- {
2456
- value: { previousTabRef, tabRefs, value: selfValue, onChange: handleChange, onClose: handleClose, registerItem },
2457
- children: [
2458
- /* @__PURE__ */ jsx33(
2459
- "div",
2460
- __spreadProps(__spreadValues({
2461
- ref: tabsRef,
2462
- className: clsx15(`${PREFIX_CLS}tabs`, { [`${PREFIX_CLS}tabs--${alignment}`]: alignment }, className)
2463
- }, rest), {
2464
- children
2465
- })
2466
- ),
2467
- /* @__PURE__ */ jsx33("div", { className: `${PREFIX_CLS}divider` })
2468
- ]
2469
- }
2470
- );
2471
- };
2472
-
2473
- // src/components/Toolbar/Toolbar.tsx
2474
- import clsx16 from "clsx";
2475
- import { Fragment as Fragment6, jsx as jsx34, jsxs as jsxs22 } from "react/jsx-runtime";
2476
- var Toolbar = (props) => {
2477
- const _a = props, {
2478
- children,
2479
- className,
2480
- size = "md",
2481
- startContent,
2482
- endContent,
2483
- startAction,
2484
- endAction,
2485
- title,
2486
- subtitle
2487
- } = _a, rest = __objRest(_a, [
2488
- "children",
2489
- "className",
2490
- "size",
2491
- "startContent",
2492
- "endContent",
2493
- "startAction",
2494
- "endAction",
2495
- "title",
2496
- "subtitle"
2497
- ]);
2498
- const prefixCls = PREFIX_CLS;
2499
- return /* @__PURE__ */ jsxs22("div", __spreadProps(__spreadValues({ className: clsx16(`${prefixCls}toolbar`, { [`${prefixCls}toolbar--${size}`]: size }, className) }, rest), { children: [
2500
- /* @__PURE__ */ jsx34("div", { className: `${prefixCls}outline-b` }),
2501
- /* @__PURE__ */ jsxs22("div", { className: clsx16(`${prefixCls}toolbar__container`), children: [
2502
- startContent ? /* @__PURE__ */ jsx34("div", { className: clsx16(`${prefixCls}toolbar__start-content`), children: startContent }) : startAction && /* @__PURE__ */ jsx34("div", { className: clsx16(`${prefixCls}toolbar__start-action`), children: startAction }),
2503
- /* @__PURE__ */ jsx34("div", { className: clsx16(`${prefixCls}toolbar__content`), children: title || subtitle ? /* @__PURE__ */ jsxs22(Fragment6, { children: [
2504
- title && /* @__PURE__ */ jsx34("div", { className: clsx16(`${prefixCls}toolbar__title`), children: title }),
2505
- subtitle && /* @__PURE__ */ jsx34("div", { className: clsx16(`${prefixCls}toolbar__subtitle`), children: subtitle })
2506
- ] }) : children }),
2507
- endContent ? /* @__PURE__ */ jsx34("div", { className: clsx16(`${prefixCls}toolbar__end-content`), children: endContent }) : endAction && /* @__PURE__ */ jsx34("div", { className: clsx16(`${prefixCls}toolbar__end-action`), children: endAction })
2508
- ] })
2509
- ] }));
2510
- };
2511
- var Toolbar_default = Toolbar;
2512
-
2513
- // src/components/TextInput/TextInput.tsx
2514
- import { forwardRef as forwardRef29, useRef as useRef16, useState as useState16 } from "react";
2515
- import { jsx as jsx35, jsxs as jsxs23 } from "react/jsx-runtime";
2516
- var TextInput = forwardRef29(
2517
- (_a, ref) => {
2518
- var _b = _a, { className, value, defaultValue, disabled, inputRef, startContent, endContent, style, onChange, onClick } = _b, rest = __objRest(_b, ["className", "value", "defaultValue", "disabled", "inputRef", "startContent", "endContent", "style", "onChange", "onClick"]);
2519
- const [focus, setFocus] = useState16(false);
2520
- const selfInputRef = useRef16(null);
2521
- const prefixCls = PREFIX_CLS;
2522
- const handleChange = (event) => {
2523
- onChange == null ? void 0 : onChange(event);
2524
- };
2525
- const handleClick = (event) => {
2526
- var _a2;
2527
- onClick == null ? void 0 : onClick(event);
2528
- (_a2 = selfInputRef == null ? void 0 : selfInputRef.current) == null ? void 0 : _a2.focus();
2529
- };
2530
- return /* @__PURE__ */ jsxs23(
2531
- "div",
2532
- {
2533
- ref,
2534
- className: clsx_default(
2535
- `${prefixCls}input`,
2536
- { [`${prefixCls}input--focus`]: focus, [`${prefixCls}input--disabled`]: disabled },
2537
- className
2538
- ),
2539
- style,
2540
- onFocus: () => {
2541
- setFocus(true);
2542
- },
2543
- onBlur: () => {
2544
- setFocus(false);
2545
- },
2546
- onClick: handleClick,
2547
- children: [
2548
- /* @__PURE__ */ jsx35("div", { className: `${prefixCls}outline` }),
2549
- /* @__PURE__ */ jsxs23("div", { className: `${prefixCls}input__content`, children: [
2550
- startContent && /* @__PURE__ */ jsx35("div", { className: `${prefixCls}input__start-content`, children: startContent }),
2551
- /* @__PURE__ */ jsx35(
2552
- "input",
2553
- __spreadValues({
2554
- ref: mergeRefs_default(selfInputRef, inputRef),
2555
- className: `${prefixCls}input__field`,
2556
- value,
2557
- defaultValue,
2558
- disabled,
2559
- onChange: handleChange
2560
- }, rest)
2561
- ),
2562
- endContent && /* @__PURE__ */ jsx35("div", { className: `${prefixCls}input__end-content`, children: endContent })
2563
- ] })
2564
- ]
2565
- }
2566
- );
2567
- }
2568
- );
2569
- var TextInput_default = TextInput;
2570
-
2571
- // src/components/Switch/Switch.tsx
2572
- import clsx17 from "clsx";
2573
- import { forwardRef as forwardRef30, useEffect as useEffect20, useState as useState17 } from "react";
2574
- import { jsx as jsx36, jsxs as jsxs24 } from "react/jsx-runtime";
2575
- var Switch = forwardRef30(
2576
- (_a, ref) => {
2577
- var _b = _a, {
2578
- id,
2579
- name,
2580
- value,
2581
- defaultValue,
2582
- checked: checkedProp,
2583
- defaultChecked,
2584
- onChange,
2585
- onCheckedChange: onCheckedChangeProp,
2586
- disabled
2587
- } = _b, rest = __objRest(_b, [
2588
- "id",
2589
- "name",
2590
- "value",
2591
- "defaultValue",
2592
- "checked",
2593
- "defaultChecked",
2594
- "onChange",
2595
- "onCheckedChange",
2596
- "disabled"
2597
- ]);
2598
- const [selftChecked, setSelfChecked] = useState17(checkedProp);
2599
- const prefixCls = PREFIX_CLS;
2600
- const handleChange = (event) => {
2601
- const { value: value2, checked } = event.target;
2602
- setSelfChecked(checked);
2603
- onChange == null ? void 0 : onChange(value2);
2604
- onCheckedChangeProp == null ? void 0 : onCheckedChangeProp(checked);
2605
- };
2606
- useEffect20(() => {
2607
- if (checkedProp !== void 0) {
2608
- setSelfChecked(checkedProp);
2609
- }
2610
- }, [checkedProp]);
2611
- return /* @__PURE__ */ jsxs24(
2612
- "label",
2613
- __spreadProps(__spreadValues({
2614
- ref,
2615
- htmlFor: id,
2616
- className: clsx17(`${prefixCls}switch`, {
2617
- [`${prefixCls}switch--checked`]: !!selftChecked
2618
- })
2619
- }, rest), {
2620
- children: [
2621
- /* @__PURE__ */ jsx36(
2622
- "input",
2623
- {
2624
- type: "checkbox",
2625
- id,
2626
- name,
2627
- value,
2628
- defaultValue,
2629
- checked: selftChecked,
2630
- defaultChecked,
2631
- disabled,
2632
- onChange: handleChange
2633
- }
2634
- ),
2635
- /* @__PURE__ */ jsx36("div", { className: `${prefixCls}switch__thumb` })
2636
- ]
2637
- })
2638
- );
2639
- }
2640
- );
2641
- var Switch_default = Switch;
2642
-
2643
- // src/components/Select/Select.tsx
2644
- import { useEffect as useEffect23, useMemo as useMemo7, useRef as useRef19, useState as useState18 } from "react";
2645
-
2646
- // src/components/Select/SelectContent.tsx
2647
- import { Fragment as Fragment7, useEffect as useEffect21, useRef as useRef17 } from "react";
2648
-
2649
- // src/components/Select/SelectContext.tsx
2650
- import { createContext as createContext8, useContext as useContext10 } from "react";
2651
- var SelectContext = createContext8(null);
2652
- var useSelect = () => {
2653
- const context = useContext10(SelectContext);
2654
- if (!context) {
2655
- throw new Error("`useSelect` must be used within a `<Select />`");
2656
- }
2657
- return context;
2658
- };
2659
- var SelectContext_default = SelectContext;
2660
-
2661
- // src/components/Select/SelectContent.tsx
2662
- import { jsx as jsx37 } from "react/jsx-runtime";
2663
- var SelectContent = () => {
2664
- const { data, values, offset, setOffset, keyField, textField, onItemSelect, renderItem } = useSelect();
2665
- const parentRef = useRef17(null);
2666
- const { isOpen } = usePopover();
2667
- const handleItemSelect = (item) => {
2668
- var _a;
2669
- onItemSelect(item);
2670
- setOffset(((_a = parentRef.current) == null ? void 0 : _a.scrollHeight) || 0);
2671
- };
2672
- useEffect21(() => {
2673
- var _a;
2674
- if (!isOpen)
2675
- return;
2676
- (_a = parentRef.current) == null ? void 0 : _a.scrollTo({ top: offset });
2677
- }, [isOpen]);
2678
- return /* @__PURE__ */ jsx37(
2679
- ScrollArea_default,
2680
- {
2681
- ref: parentRef,
2682
- style: {
2683
- height: `200px`,
2684
- width: `100%`,
2685
- position: "relative"
2686
- },
2687
- children: /* @__PURE__ */ jsx37(List_default, { children: renderItem ? data.map((item) => /* @__PURE__ */ jsx37(Fragment7, { children: renderItem(item, {
2688
- title: "",
2689
- selected: values.includes(item[keyField]),
2690
- hoverable: true,
2691
- onClick: () => handleItemSelect(item)
2692
- }) }, item[keyField])) : data.map((item) => /* @__PURE__ */ jsx37(
2693
- ListItem_default,
2694
- {
2695
- title: item[textField],
2696
- selected: values.includes(item[keyField]),
2697
- hoverable: true,
2698
- onClick: () => handleItemSelect(item)
2699
- },
2700
- item[keyField]
2701
- )) })
2702
- }
2703
- );
2704
- };
2705
- var SelectContent_default = SelectContent;
2706
-
2707
- // src/components/Select/SelectVirtual.tsx
2708
- import { Fragment as Fragment8, useEffect as useEffect22, useRef as useRef18 } from "react";
2709
-
2710
- // src/components/Select/utils.ts
2711
- var valueToValues2 = (value) => {
2712
- return Array.isArray(value) ? value : value !== null ? [value] : [];
2713
- };
2714
- var valuesToValue2 = (values) => {
2715
- return Array.isArray(values) ? values.length !== 0 ? values[0] : null : values;
2716
- };
2717
-
2718
- // src/components/Select/SelectVirtual.tsx
2719
- import { jsx as jsx38 } from "react/jsx-runtime";
2720
- var SelectVirtual = () => {
2721
- const { data, values, keyField, textField, virtual, onItemSelect, renderItem } = useSelect();
2722
- const parentRef = useRef18(null);
2723
- const virtualizer = useVirtualizer_default(__spreadProps(__spreadValues({}, virtual), { count: data.length, parentRef }));
2724
- const { isOpen } = usePopover();
2725
- const handleItemSelect = (item) => {
2726
- onItemSelect(item);
2727
- };
2728
- useEffect22(() => {
2729
- if (!isOpen)
2730
- return;
2731
- const value = valuesToValue2(values);
2732
- const index = data.findIndex((item) => item[keyField] === value);
2733
- virtualizer.scrollToIndex(index, { align: "start" });
2734
- }, [isOpen]);
2735
- if (!virtual)
2736
- return null;
2737
- return /* @__PURE__ */ jsx38(
2738
- ScrollArea_default,
2739
- {
2740
- ref: parentRef,
2741
- autoHide: true,
2742
- style: {
2743
- height: `200px`,
2744
- width: `100%`,
2745
- position: "relative"
2746
- },
2747
- children: /* @__PURE__ */ jsx38(List_default, { children: /* @__PURE__ */ jsx38(
2748
- "div",
2749
- {
2750
- style: {
2751
- height: `${virtualizer.getTotalSize()}px`,
2752
- width: "100%",
2753
- position: "relative"
2754
- },
2755
- children: virtualizer.getVirtualItems().map((virtualItem) => {
2756
- const isLoaderRow = virtualItem.index > data.length - 1;
2757
- const item = data[virtualItem.index];
2758
- if (isLoaderRow) {
2759
- return /* @__PURE__ */ jsx38(
2760
- ListItem_default,
2761
- {
2762
- title: virtual.hasNextPage ? "Loading..." : "Nothing more to load",
2763
- style: {
2764
- position: "absolute",
2765
- top: 0,
2766
- left: 0,
2767
- width: "100%",
2768
- height: `${virtualItem.size}px`,
2769
- transform: `translateY(${virtualItem.start}px)`
2770
- }
2771
- },
2772
- virtualItem.index
2773
- );
2774
- }
2775
- if (!item) {
2776
- return /* @__PURE__ */ jsx38(
2777
- ListItem_default,
2778
- {
2779
- title: `Item ${virtualItem.index} not found`,
2780
- style: {
2781
- position: "absolute",
2782
- top: 0,
2783
- left: 0,
2784
- width: "100%",
2785
- height: `${virtualItem.size}px`,
2786
- transform: `translateY(${virtualItem.start}px)`
2787
- }
2788
- },
2789
- virtualItem.index
2790
- );
2791
- }
2792
- if (renderItem) {
2793
- return /* @__PURE__ */ jsx38(Fragment8, { children: renderItem(item, {
2794
- title: "",
2795
- selected: values.includes(item[keyField]),
2796
- hoverable: true,
2797
- style: {
2798
- position: "absolute",
2799
- top: 0,
2800
- left: 0,
2801
- width: "100%",
2802
- height: `${virtualItem.size}px`,
2803
- transform: `translateY(${virtualItem.start}px)`
2804
- },
2805
- onClick: () => handleItemSelect(item)
2806
- }) }, virtualItem.index);
2807
- }
2808
- return /* @__PURE__ */ jsx38(
2809
- ListItem_default,
2810
- {
2811
- title: item[textField],
2812
- selected: values.includes(item[keyField]),
2813
- hoverable: true,
2814
- style: {
2815
- position: "absolute",
2816
- top: 0,
2817
- left: 0,
2818
- width: "100%",
2819
- height: `${virtualItem.size}px`,
2820
- transform: `translateY(${virtualItem.start}px)`
2821
- },
2822
- onClick: () => handleItemSelect(item)
2823
- },
2824
- virtualItem.index
2825
- );
2826
- })
2827
- }
2828
- ) })
2829
- }
2830
- );
2831
- };
2832
- var SelectVirtual_default = SelectVirtual;
2833
-
2834
- // src/components/Select/Select.tsx
2835
- import { jsx as jsx39, jsxs as jsxs25 } from "react/jsx-runtime";
2836
- var Select = (props) => {
2837
- const {
2838
- data,
2839
- value: valueProp,
2840
- keyField = "key",
2841
- textField = "text",
2842
- isMultiple = false,
2843
- disabled,
2844
- loading,
2845
- disclosure: disclosureProp,
2846
- virtual,
2847
- placeholder,
2848
- className,
2849
- style,
2850
- startContent,
2851
- endContent,
2852
- renderItem
2853
- } = props;
2854
- const disclosure = disclosureProp !== void 0 ? disclosureProp : useDisclosure_default();
2855
- const prefixCls = PREFIX_CLS;
2856
- const inputRef = useRef19(null);
2857
- const [search, setSearch] = useState18("");
2858
- const [isSearch, setIsSearch] = useState18(false);
2859
- const [focus, setFocus] = useState18(false);
2860
- const values = useMemo7(() => {
2861
- return valueToValues2(valueProp);
2862
- }, [valueProp]);
2863
- const items = useMemo7(() => {
2864
- return data.filter((item) => values.includes(item[keyField]));
2865
- }, [data, values]);
2866
- const [offset, setOffset] = useState18(0);
2867
- const handleClick = () => {
2868
- var _a;
2869
- (_a = inputRef == null ? void 0 : inputRef.current) == null ? void 0 : _a.focus();
2870
- };
2871
- const handleChange = (values2) => {
2872
- var _a, _b, _c, _d, _e;
2873
- if (props.isMultiple) {
2874
- const items2 = data.filter((item) => values2.includes(item[keyField]));
2875
- (_a = props.onChange) == null ? void 0 : _a.call(props, items2);
2876
- (_b = props.onValueChange) == null ? void 0 : _b.call(props, values2);
2877
- } else {
2878
- const newValue = valuesToValue2(values2);
2879
- let item = null;
2880
- if (newValue !== null) {
2881
- item = (_c = data.find((item2) => item2[keyField] === newValue)) != null ? _c : null;
2882
- }
2883
- (_d = props.onChange) == null ? void 0 : _d.call(props, item);
2884
- (_e = props.onValueChange) == null ? void 0 : _e.call(props, newValue);
2885
- }
2886
- };
2887
- const handleClear = (event) => {
2888
- var _a, _b, _c, _d;
2889
- event.stopPropagation();
2890
- setIsSearch(true);
2891
- setSearch("");
2892
- if (props.isMultiple) {
2893
- (_a = props.onChange) == null ? void 0 : _a.call(props, []);
2894
- (_b = props.onValueChange) == null ? void 0 : _b.call(props, []);
2895
- } else {
2896
- (_c = props.onChange) == null ? void 0 : _c.call(props, null);
2897
- (_d = props.onValueChange) == null ? void 0 : _d.call(props, null);
2898
- }
2899
- setIsSearch(false);
2900
- };
2901
- const handleItemSelect = (item) => {
2902
- var _a;
2903
- const newValue = item[keyField];
2904
- if (props.isMultiple) {
2905
- const newValues = [...values];
2906
- const valueIndex = values.indexOf(newValue);
2907
- if (valueIndex === -1) {
2908
- newValues.push(newValue);
2909
- } else {
2910
- newValues.splice(valueIndex, 1);
2911
- }
2912
- handleChange(newValues);
2913
- } else {
2914
- const value = valuesToValue2(values);
2915
- if (value !== newValue) {
2916
- handleChange([newValue]);
2917
- }
2918
- }
2919
- setIsSearch(false);
2920
- (_a = inputRef.current) == null ? void 0 : _a.focus();
2921
- disclosure.onClose();
2922
- };
2923
- const handleOpen = () => {
2924
- disclosure.onOpen();
2925
- setFocus(true);
2926
- };
2927
- const handleClose = () => {
2928
- disclosure.onClose();
2929
- if (!props.isMultiple) {
2930
- if (isSearch) {
2931
- const item = items[0];
2932
- if (item !== void 0) {
2933
- setSearch(item[textField]);
2934
- } else {
2935
- setSearch("");
2936
- }
2937
- setIsSearch(false);
2938
- }
2939
- }
2940
- };
2941
- useEffect23(() => {
2942
- if (isSearch)
2943
- return;
2944
- if (!props.isMultiple) {
2945
- const item = items[0];
2946
- if (item !== void 0) {
2947
- setSearch(item[textField]);
2948
- }
2949
- }
2950
- }, [items]);
2951
- useEffect23(() => {
2952
- const values2 = valueToValues2(valueProp);
2953
- const value = values2[0];
2954
- if (value === void 0) {
2955
- setSearch("");
2956
- }
2957
- }, [valueProp]);
2958
- return /* @__PURE__ */ jsx39(
2959
- SelectContext_default.Provider,
2960
- {
2961
- value: {
2962
- data,
2963
- values,
2964
- keyField,
2965
- textField,
2966
- isMultiple,
2967
- virtual,
2968
- onChange: handleChange,
2969
- onItemSelect: handleItemSelect,
2970
- offset,
2971
- setOffset,
2972
- renderItem
2973
- },
2974
- children: /* @__PURE__ */ jsxs25(
2975
- Popover_default,
2976
- __spreadProps(__spreadValues({
2977
- target: true
2978
- }, disclosure), {
2979
- isOpen: disclosure.isOpen,
2980
- onOpen: handleOpen,
2981
- onClose: handleClose,
2982
- autoClose: "outside",
2983
- children: [
2984
- /* @__PURE__ */ jsx39(PopoverTrigger_default, { children: /* @__PURE__ */ jsxs25(
2985
- "div",
2986
- {
2987
- className: clsx_default(
2988
- `${prefixCls}input`,
2989
- {
2990
- [`${prefixCls}input--focus`]: focus,
2991
- [`${prefixCls}input--disabled`]: disabled
2992
- },
2993
- className
2994
- ),
2995
- style,
2996
- onClick: handleClick,
2997
- onFocus: () => {
2998
- setFocus(true);
2999
- },
3000
- onBlur: () => {
3001
- setFocus(false);
3002
- },
3003
- children: [
3004
- /* @__PURE__ */ jsx39("input", { type: "text", ref: inputRef, style: { position: "absolute", opacity: 0 } }),
3005
- /* @__PURE__ */ jsx39("div", { className: `${prefixCls}outline` }),
3006
- /* @__PURE__ */ jsxs25("div", { className: `${prefixCls}input__content`, children: [
3007
- startContent && /* @__PURE__ */ jsx39("div", { className: `${prefixCls}input__start-content`, children: startContent }),
3008
- /* @__PURE__ */ jsx39("div", { className: `${prefixCls}input__field`, children: search || placeholder }),
3009
- /* @__PURE__ */ jsxs25("div", { className: `${prefixCls}input__end-content`, children: [
3010
- endContent,
3011
- loading ? /* @__PURE__ */ jsx39(Icon_default, { children: /* @__PURE__ */ jsx39(LoaderIcon_default, { className: `${prefixCls}animation-spin` }) }) : /* @__PURE__ */ jsx39(Button, { color: "secondary", variant: "plain", size: "xs", iconOnly: true, onClick: handleClear, children: /* @__PURE__ */ jsx39(Icon_default, { children: /* @__PURE__ */ jsx39(CloseIcon_default, {}) }) }),
3012
- /* @__PURE__ */ jsx39("div", { style: { pointerEvents: "none" }, children: /* @__PURE__ */ jsx39(Icon_default, { children: disclosure.isOpen ? /* @__PURE__ */ jsx39(ChevronUpIcon_default, {}) : /* @__PURE__ */ jsx39(ChevronDownIcon_default, {}) }) })
3013
- ] })
3014
- ] })
3015
- ]
3016
- }
3017
- ) }),
3018
- /* @__PURE__ */ jsx39(PopoverContent_default, { children: /* @__PURE__ */ jsx39("div", { children: virtual ? /* @__PURE__ */ jsx39(SelectVirtual_default, {}) : /* @__PURE__ */ jsx39(SelectContent_default, {}) }) })
3019
- ]
3020
- })
3021
- )
3022
- }
3023
- );
3024
- };
3025
- var Select_default = Select;
3026
-
3027
- // src/components/Field/Field.tsx
3028
- import { forwardRef as forwardRef31 } from "react";
3029
- import { jsx as jsx40, jsxs as jsxs26 } from "react/jsx-runtime";
3030
- var Field = forwardRef31(({ children, label }, ref) => {
3031
- {
3032
- const prefixCls = PREFIX_CLS;
3033
- return /* @__PURE__ */ jsxs26("div", { ref, className: clsx_default(`${prefixCls}field`), children: [
3034
- /* @__PURE__ */ jsx40("div", { className: `${prefixCls}field__label`, children: label }),
3035
- /* @__PURE__ */ jsx40("div", { className: `${prefixCls}field__content`, children })
3036
- ] });
3037
- }
3038
- });
3039
- var Field_default = Field;
3040
- export {
3041
- Accordion_default as Accordion,
3042
- AccordionContent_default as AccordionContent,
3043
- AccordionHeader_default as AccordionHeader,
3044
- AccordionItem_default as AccordionItem,
3045
- AccordionPanel_default as AccordionPanel,
3046
- Autocomplete_default as Autocomplete,
3047
- Backdrop_default as Backdrop,
3048
- Badge_default as Badge,
3049
- Button,
3050
- Card_default as Card,
3051
- CardHeader_default as CardHeader,
3052
- Chip_default as Chip,
3053
- Collapse_default as Collapse,
3054
- CollapseContent_default as CollapseContent,
3055
- CollapseContext_default as CollapseContext,
3056
- CollapseTrigger_default as CollapseTrigger,
3057
- Drawer_default as Drawer,
3058
- Field_default as Field,
3059
- Icon_default as Icon,
3060
- List_default as List,
3061
- ListGroup_default as ListGroup,
3062
- ListItem_default as ListItem,
3063
- Menu_default as Menu,
3064
- MenuContext_default as MenuContext,
3065
- MenuGroup_default as MenuGroup,
3066
- MenuItem_default as MenuItem,
3067
- MenuSubmenu_default as MenuSubmenu,
3068
- MenuValueContext_default as MenuValueContext,
3069
- Portal_default as Portal,
3070
- QueryStatus,
3071
- ScrollArea_default as ScrollArea,
3072
- Select_default as Select,
3073
- Switch_default as Switch,
3074
- Tab,
3075
- Tabs,
3076
- TextInput_default as TextInput,
3077
- Toolbar_default as Toolbar,
3078
- Transition_default as Transition,
3079
- assignRef,
3080
- clsx_default as clsx,
3081
- getOpenValuesByPathname,
3082
- hasResizeObserver,
3083
- mergeRefs_default as mergeRefs,
3084
- scrollToItem,
3085
- useAccordionItem,
3086
- useCollapse,
3087
- useDebounce_default as useDebounce,
3088
- useDisclosure_default as useDisclosure,
3089
- useEffectEvent_default as useEffectEvent,
3090
- useElementSize_default as useElementSize,
3091
- useInfiniteQuery_default as useInfiniteQuery,
3092
- useLocalStorage,
3093
- useMenu,
3094
- useMenuItemValue,
3095
- useOnClickOutside_default as useOnClickOutside,
3096
- usePrevious,
3097
- useResizeObserver_default as useResizeObserver,
3098
- useStep,
3099
- useValueEffect_default as useValueEffect,
3100
- useVirtualizer_default as useVirtualizer
3101
- };