@sentio/ui-core 0.1.0

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.js ADDED
@@ -0,0 +1,3248 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+
30
+ // src/index.ts
31
+ var index_exports = {};
32
+ __export(index_exports, {
33
+ BD: () => BD,
34
+ BarLoading: () => BarLoading,
35
+ BaseDialog: () => BaseDialog,
36
+ Button: () => NewButton,
37
+ COLOR_MAP: () => COLOR_MAP,
38
+ CloseSquareO: () => import_lu2.LuSquareX,
39
+ Collapse: () => Collapse,
40
+ CopyButton: () => CopyButton,
41
+ CopyIcon: () => CopyIcon,
42
+ CopySuccessIcon: () => CopySuccessIcon,
43
+ DarkModeContext: () => DarkModeContext,
44
+ DeleteIcon: () => DeleteIcon,
45
+ DisclosurePanel: () => DisclosurePanel,
46
+ Empty: () => Empty,
47
+ EyeO: () => import_lu2.LuEye,
48
+ FlatTree: () => FlatTree,
49
+ HeaderToolsContent: () => HeaderToolsContent,
50
+ HeaderToolsToggleButton: () => HeaderToolsToggleButton,
51
+ Input: () => Input,
52
+ LinkifyText: () => LinkifyText,
53
+ MenuContext: () => MenuContext,
54
+ MenuItem: () => MenuItem,
55
+ MinusSquareO: () => import_lu2.LuSquareMinus,
56
+ MoveLeftIcon: () => MoveLeftIcon,
57
+ MoveRightIcon: () => MoveRightIcon,
58
+ NavSizeContext: () => NavSizeContext,
59
+ PlusSquareO: () => import_lu2.LuSquarePlus,
60
+ PopoverTooltip: () => PopoverTooltip,
61
+ PopupMenuButton: () => PopupMenuButton,
62
+ ROOT_KEY: () => ROOT_KEY,
63
+ RadioSelect: () => RadioSelect,
64
+ RenameIcon: () => RenameIcon,
65
+ ResizeTable: () => ResizeTable,
66
+ SUFFIX_NODE_KEY: () => SUFFIX_NODE_KEY,
67
+ Select: () => Select,
68
+ SpinLoading: () => SpinLoading,
69
+ StatusBadge: () => StatusBadge,
70
+ StatusRole: () => StatusRole,
71
+ SubMenuButton: () => SubMenuButton,
72
+ SvgFolderContext: () => SvgFolderContext,
73
+ Switch: () => Switch,
74
+ classNames: () => import_class_variance_authority10.cx,
75
+ getNumberWithDecimal: () => getNumberWithDecimal,
76
+ parseHex: () => parseHex,
77
+ useBoolean: () => useBoolean,
78
+ useDarkMode: () => useDarkMode,
79
+ useDetectExtenstion: () => useDetectExtenstion,
80
+ useMobile: () => useMobile
81
+ });
82
+ module.exports = __toCommonJS(index_exports);
83
+
84
+ // src/common/BarLoading.tsx
85
+ var import_react_spinners = require("react-spinners");
86
+ var import_react = require("react");
87
+ var import_class_variance_authority = require("class-variance-authority");
88
+ var import_jsx_runtime = require("react/jsx-runtime");
89
+ function _BarLoading({
90
+ hint = "Loading Sentio",
91
+ loading = true,
92
+ className,
93
+ iconClassName,
94
+ width = 150,
95
+ gray
96
+ }) {
97
+ if (loading) {
98
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
99
+ "div",
100
+ {
101
+ className: (0, import_class_variance_authority.cx)(
102
+ "loading-container flex h-full flex-col justify-center overflow-hidden",
103
+ className
104
+ ),
105
+ children: [
106
+ hint && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "loading-text text-icontent text-gray my-2 text-center font-medium", children: hint }),
107
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "flex justify-center pt-1", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
108
+ import_react_spinners.BarLoader,
109
+ {
110
+ color: "#0756D5",
111
+ loading: true,
112
+ height: 5,
113
+ width,
114
+ cssOverride: {
115
+ borderRadius: "4px"
116
+ }
117
+ }
118
+ ) })
119
+ ]
120
+ }
121
+ );
122
+ }
123
+ return null;
124
+ }
125
+ var BarLoading = (0, import_react.memo)(_BarLoading);
126
+
127
+ // src/common/SpinLoading.tsx
128
+ var import_react_spinners2 = require("react-spinners");
129
+ var import_class_variance_authority2 = require("class-variance-authority");
130
+ var import_jsx_runtime2 = require("react/jsx-runtime");
131
+ var SpinLoading = function Spinner(args) {
132
+ const {
133
+ loading = false,
134
+ children,
135
+ className,
136
+ size = 48,
137
+ showMask,
138
+ maskOpacity = 80
139
+ } = args;
140
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: (0, import_class_variance_authority2.cx)("relative", className), children: [
141
+ showMask && loading && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
142
+ "div",
143
+ {
144
+ className: (0, import_class_variance_authority2.cx)(
145
+ "absolute bottom-0 left-0 right-0 top-0 z-[1]",
146
+ maskOpacity ? `bg-white dark:bg-sentio-gray-100/${maskOpacity}` : "dark:bg-sentio-gray-100 bg-white"
147
+ )
148
+ }
149
+ ),
150
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "absolute left-[50%] top-[50%] z-[1] -translate-y-6", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
151
+ import_react_spinners2.ClipLoader,
152
+ {
153
+ loading,
154
+ color: "#3B82F6",
155
+ size,
156
+ cssOverride: {
157
+ borderWidth: 3
158
+ }
159
+ }
160
+ ) }),
161
+ children
162
+ ] });
163
+ };
164
+
165
+ // src/common/CopyButton.tsx
166
+ var import_react2 = require("react");
167
+ var import_copy_to_clipboard = __toESM(require("copy-to-clipboard"));
168
+ var import_class_variance_authority3 = require("class-variance-authority");
169
+ var import_jsx_runtime3 = require("react/jsx-runtime");
170
+ var CopyIcon = (props) => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
171
+ "svg",
172
+ {
173
+ xmlns: "http://www.w3.org/2000/svg",
174
+ fill: "none",
175
+ viewBox: "0 0 24 24",
176
+ strokeWidth: "2",
177
+ stroke: "currentColor",
178
+ ...props,
179
+ children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
180
+ "path",
181
+ {
182
+ strokeLinecap: "round",
183
+ strokeLinejoin: "round",
184
+ d: "M16.5 8.25V6a2.25 2.25 0 0 0-2.25-2.25H6A2.25 2.25 0 0 0 3.75 6v8.25A2.25 2.25 0 0 0 6 16.5h2.25m8.25-8.25H18a2.25 2.25 0 0 1 2.25 2.25V18A2.25 2.25 0 0 1 18 20.25h-7.5A2.25 2.25 0 0 1 8.25 18v-1.5m8.25-8.25h-6a2.25 2.25 0 0 0-2.25 2.25v6"
185
+ }
186
+ )
187
+ }
188
+ );
189
+ var CopySuccessIcon = (props) => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
190
+ "svg",
191
+ {
192
+ xmlns: "http://www.w3.org/2000/svg",
193
+ viewBox: "0 0 24 24",
194
+ fill: "rgb(var(--cyan-600))",
195
+ ...props,
196
+ children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
197
+ "path",
198
+ {
199
+ fillRule: "evenodd",
200
+ d: "M2.25 12c0-5.385 4.365-9.75 9.75-9.75s9.75 4.365 9.75 9.75-4.365 9.75-9.75 9.75S2.25 17.385 2.25 12Zm13.36-1.814a.75.75 0 1 0-1.22-.872l-3.236 4.53L9.53 12.22a.75.75 0 0 0-1.06 1.06l2.25 2.25a.75.75 0 0 0 1.14-.094l3.75-5.25Z",
201
+ clipRule: "evenodd"
202
+ }
203
+ )
204
+ }
205
+ );
206
+ var CopyButton = ({
207
+ text = "",
208
+ size = 16,
209
+ ml,
210
+ mr,
211
+ placement = "right",
212
+ hover,
213
+ children,
214
+ className
215
+ }) => {
216
+ const [copied, setCopied] = (0, import_react2.useState)(false);
217
+ const [isHovered, setIsHovered] = (0, import_react2.useState)(false);
218
+ const [isMobile, setIsMobile] = (0, import_react2.useState)(false);
219
+ const timeoutRef = (0, import_react2.useRef)(null);
220
+ const iconContainerRef = (0, import_react2.useRef)(null);
221
+ (0, import_react2.useEffect)(() => {
222
+ const checkMobile = () => {
223
+ setIsMobile(window.innerWidth < 640);
224
+ };
225
+ checkMobile();
226
+ window.addEventListener("resize", checkMobile);
227
+ return () => window.removeEventListener("resize", checkMobile);
228
+ }, []);
229
+ const copyToClipboard = (0, import_react2.useCallback)((val) => {
230
+ (0, import_copy_to_clipboard.default)(val);
231
+ setCopied(true);
232
+ if (timeoutRef.current) {
233
+ clearTimeout(timeoutRef.current);
234
+ }
235
+ timeoutRef.current = setTimeout(() => {
236
+ setCopied(false);
237
+ timeoutRef.current = null;
238
+ }, 2e3);
239
+ }, []);
240
+ const onCopy = (0, import_react2.useCallback)(
241
+ (e) => {
242
+ const target = e.target;
243
+ if (target.nodeName.toLowerCase() === "a" && target.getAttribute("href")) {
244
+ return;
245
+ }
246
+ e.stopPropagation();
247
+ e.preventDefault();
248
+ if (copied) return;
249
+ if (typeof text === "function") {
250
+ const val = text();
251
+ if (val instanceof Promise) {
252
+ val.then((res) => {
253
+ copyToClipboard(res);
254
+ }).catch((error) => {
255
+ console.error(error);
256
+ });
257
+ } else {
258
+ copyToClipboard(val);
259
+ }
260
+ } else {
261
+ copyToClipboard(text);
262
+ }
263
+ },
264
+ [copied, text, copyToClipboard]
265
+ );
266
+ const handleEventProxy = (0, import_react2.useCallback)(
267
+ (e) => {
268
+ if (children) {
269
+ onCopy(e);
270
+ }
271
+ },
272
+ [children, onCopy]
273
+ );
274
+ const isPureComponent = !children;
275
+ const iconContainerStyle = {
276
+ minWidth: `${size}px`,
277
+ maxWidth: `${size}px`,
278
+ minHeight: `${size}px`,
279
+ maxHeight: `${size}px`,
280
+ marginLeft: ml !== void 0 ? `${ml}px` : void 0,
281
+ marginRight: mr !== void 0 ? `${mr}px` : void 0,
282
+ visibility: !isPureComponent && hover ? isMobile ? "visible" : isHovered ? "visible" : "hidden" : "visible"
283
+ };
284
+ const containerStyle = {
285
+ display: !isPureComponent ? "inline-block" : "contents"
286
+ };
287
+ const svgStyle = {
288
+ margin: 0
289
+ };
290
+ const iconCopyStyle = {
291
+ transform: copied ? "translateY(-100%)" : "translateY(0)"
292
+ };
293
+ const iconSuccessStyle = {
294
+ transform: copied ? "translateY(-100%)" : "translateY(100%)"
295
+ };
296
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
297
+ "div",
298
+ {
299
+ className: (0, import_class_variance_authority3.cx)(
300
+ "inline-block min-w-fit overflow-hidden whitespace-nowrap",
301
+ "space-x-1",
302
+ className
303
+ ),
304
+ style: containerStyle,
305
+ onClick: handleEventProxy,
306
+ onMouseEnter: () => setIsHovered(true),
307
+ onMouseLeave: () => setIsHovered(false),
308
+ children: [
309
+ placement === "right" && children,
310
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
311
+ "div",
312
+ {
313
+ ref: iconContainerRef,
314
+ className: (0, import_class_variance_authority3.cx)(
315
+ "icon-container inline-block overflow-hidden align-sub",
316
+ isPureComponent ? className : "",
317
+ copied ? "copied" : ""
318
+ ),
319
+ style: iconContainerStyle,
320
+ children: [
321
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
322
+ CopyIcon,
323
+ {
324
+ className: "icon-copy block cursor-pointer transition-all",
325
+ width: size,
326
+ height: size,
327
+ style: { ...svgStyle, ...iconCopyStyle },
328
+ onClick: onCopy
329
+ }
330
+ ),
331
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
332
+ CopySuccessIcon,
333
+ {
334
+ className: "icon-success block transition-all",
335
+ width: size,
336
+ height: size,
337
+ style: { ...svgStyle, ...iconSuccessStyle }
338
+ }
339
+ )
340
+ ]
341
+ }
342
+ ),
343
+ placement === "left" && children
344
+ ]
345
+ }
346
+ );
347
+ };
348
+
349
+ // src/common/NewButton.tsx
350
+ var import_react5 = require("react");
351
+
352
+ // src/common/DivTooltip.tsx
353
+ var import_react3 = __toESM(require("react"));
354
+ var import_react4 = require("@floating-ui/react");
355
+ var import_class_variance_authority4 = require("class-variance-authority");
356
+ var import_lodash = require("lodash");
357
+ var import_jsx_runtime4 = require("react/jsx-runtime");
358
+ var PopoverTooltip = ({
359
+ icon,
360
+ text,
361
+ className,
362
+ buttonClassName,
363
+ activeButtonClassName,
364
+ children,
365
+ strategy: propStrategy,
366
+ hideArrow,
367
+ offsetOptions = 8,
368
+ placementOption = "bottom",
369
+ maxWidth = "max-w-[300px]",
370
+ usePortal = false,
371
+ enableFadeAnimation = false,
372
+ animationDuration = 150
373
+ }) => {
374
+ const arrowRef = (0, import_react3.useRef)(null);
375
+ const [open, setOpen] = (0, import_react3.useState)(false);
376
+ const [isVisible, setIsVisible] = (0, import_react3.useState)(false);
377
+ const timeoutRef = (0, import_react3.useRef)();
378
+ const {
379
+ x,
380
+ y,
381
+ refs,
382
+ strategy,
383
+ middlewareData: { arrow: { x: arrowX, y: arrowY } = {} },
384
+ context,
385
+ placement
386
+ } = (0, import_react4.useFloating)({
387
+ open,
388
+ onOpenChange: (newOpen) => {
389
+ setOpen(newOpen);
390
+ if (enableFadeAnimation) {
391
+ if (newOpen) {
392
+ setIsVisible(true);
393
+ } else {
394
+ if (timeoutRef.current) {
395
+ clearTimeout(timeoutRef.current);
396
+ }
397
+ timeoutRef.current = setTimeout(() => {
398
+ setIsVisible(false);
399
+ }, animationDuration);
400
+ }
401
+ } else {
402
+ setIsVisible(newOpen);
403
+ }
404
+ },
405
+ middleware: [
406
+ (0, import_react4.offset)(offsetOptions),
407
+ (0, import_react4.flip)(),
408
+ (0, import_react4.shift)(),
409
+ (0, import_react4.arrow)({ element: arrowRef, padding: 8 })
410
+ ],
411
+ strategy: propStrategy,
412
+ placement: placementOption,
413
+ whileElementsMounted: import_react4.autoUpdate
414
+ });
415
+ const {
416
+ delay = {
417
+ open: 500,
418
+ close: 0
419
+ }
420
+ } = (0, import_react4.useDelayGroup)(context);
421
+ const { getReferenceProps, getFloatingProps } = (0, import_react4.useInteractions)([
422
+ (0, import_react4.useHover)(context, {
423
+ handleClose: (0, import_react4.safePolygon)({
424
+ buffer: -Infinity
425
+ }),
426
+ delay
427
+ })
428
+ ]);
429
+ (0, import_react3.useEffect)(() => {
430
+ return () => {
431
+ if (timeoutRef.current) {
432
+ clearTimeout(timeoutRef.current);
433
+ }
434
+ };
435
+ }, []);
436
+ if (!text)
437
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(import_jsx_runtime4.Fragment, { children: [
438
+ icon,
439
+ children
440
+ ] });
441
+ const Portal = usePortal ? import_react4.FloatingPortal : import_react3.default.Fragment;
442
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: (0, import_class_variance_authority4.cx)("relative flex items-center", className), children: [
443
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
444
+ "div",
445
+ {
446
+ ref: refs.setReference,
447
+ ...getReferenceProps(),
448
+ className: (0, import_class_variance_authority4.cx)(buttonClassName, open && activeButtonClassName),
449
+ children: [
450
+ icon,
451
+ children
452
+ ]
453
+ }
454
+ ),
455
+ (enableFadeAnimation ? isVisible : open) && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Portal, { children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: "_sentio_", children: /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
456
+ "div",
457
+ {
458
+ className: (0, import_class_variance_authority4.cx)(
459
+ "sentio-tooltip dark:bg-sentio-gray-200 z-10 rounded-md bg-white p-2 text-xs shadow-lg ring-1 ring-black ring-opacity-5 dark:ring-gray-100",
460
+ enableFadeAnimation && `transition-opacity duration-[${animationDuration}ms] ease-in-out`,
461
+ enableFadeAnimation ? open ? "opacity-100" : "opacity-0" : ""
462
+ ),
463
+ ref: refs.setFloating,
464
+ style: {
465
+ position: strategy,
466
+ top: y ?? 0,
467
+ left: x ?? 0
468
+ },
469
+ ...getFloatingProps,
470
+ children: [
471
+ !hideArrow && placement === "bottom" && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
472
+ "div",
473
+ {
474
+ className: "arrow -translate-y-[5px] before:absolute before:h-2 before:w-2 before:rotate-45 before:bg-white before:border-l before:border-t before:border-black/5 dark:before:bg-sentio-gray-200 dark:before:border-gray-100",
475
+ ref: arrowRef,
476
+ style: {
477
+ left: arrowX ?? 0,
478
+ top: arrowY ?? 0,
479
+ position: "absolute"
480
+ }
481
+ }
482
+ ),
483
+ (0, import_lodash.isString)(text) ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
484
+ "p",
485
+ {
486
+ className: (0, import_class_variance_authority4.cx)("w-max whitespace-pre-wrap", maxWidth),
487
+ children: text
488
+ }
489
+ ) : /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
490
+ "div",
491
+ {
492
+ className: (0, import_class_variance_authority4.cx)(
493
+ "w-max overflow-auto",
494
+ maxWidth
495
+ ),
496
+ children: text
497
+ }
498
+ )
499
+ ]
500
+ }
501
+ ) }) })
502
+ ] });
503
+ };
504
+
505
+ // src/common/NewButton.tsx
506
+ var import_class_variance_authority5 = require("class-variance-authority");
507
+ var import_jsx_runtime5 = require("react/jsx-runtime");
508
+ var buttonClass = (0, import_class_variance_authority5.cva)(["inline-flex", "items-center", "font-medium"], {
509
+ variants: {
510
+ role: {
511
+ primary: ["btn-primary"],
512
+ secondary: ["btn-secondary"],
513
+ dashed: ["btn-dashed"],
514
+ text: ["btn-text"],
515
+ link: ["btn-link"],
516
+ tertiary: [],
517
+ tertiarytext: [],
518
+ custom: []
519
+ // custom button
520
+ },
521
+ status: {
522
+ default: "btn-status-default",
523
+ danger: "btn-status-danger"
524
+ },
525
+ size: {
526
+ sm: ["px-2", "py-1.5", "text-xs", "font-normal", "gap-2"],
527
+ default: ["px-2.5", "text-ilabel", "font-ilabel", "gap-2", "py-1"],
528
+ md: ["px-2.5 text-ilabel font-ilabel gap-2", "py-1.5"],
529
+ lg: ["px-3 text-sm gap-3", "py-2"]
530
+ },
531
+ disabled: {
532
+ false: [""],
533
+ true: ["btn-disabled"]
534
+ },
535
+ position: {
536
+ begin: ["rounded-l-md"],
537
+ end: ["rounded-r-md"],
538
+ middle: [""],
539
+ full: ["rounded-md"]
540
+ }
541
+ },
542
+ compoundVariants: [
543
+ {
544
+ role: "secondary",
545
+ size: "default",
546
+ class: "py-[3px]"
547
+ },
548
+ {
549
+ role: "dashed",
550
+ size: "default",
551
+ class: "py-[3px]"
552
+ },
553
+ {
554
+ role: "secondary",
555
+ size: "md",
556
+ class: "py-[5px]"
557
+ },
558
+ {
559
+ role: "dashed",
560
+ size: "md",
561
+ class: "py-[5px]"
562
+ },
563
+ {
564
+ role: "secondary",
565
+ size: "lg",
566
+ class: "py-[7px]"
567
+ },
568
+ {
569
+ role: "dashed",
570
+ size: "lg",
571
+ class: "py-[7px]"
572
+ },
573
+ {
574
+ role: "tertiary",
575
+ disabled: false,
576
+ class: [
577
+ "bg-primary-100 dark:bg-gray-100",
578
+ "hover:bg-primary-100/90 dark:hover:bg-gray-200/90",
579
+ "active:bg-primary-200 dark:active:bg-gray-300",
580
+ "text-primary-600 dark:text-gray-600",
581
+ "hover:text-primary-500 dark:hover:text-gray-700",
582
+ "active:text-primary-700 dark:active:text-gray-800",
583
+ "focus:ring-primary-700 dark:focus:ring-gray-800"
584
+ ]
585
+ },
586
+ {
587
+ role: "tertiary",
588
+ disabled: true,
589
+ class: "cursor-not-allowed bg-gray-100 text-gray-400"
590
+ },
591
+ {
592
+ role: "tertiarytext",
593
+ disabled: false,
594
+ class: [
595
+ "hover:bg-primary-100/90 dark:hover:bg-gray-200/90",
596
+ "active:bg-primary-200 dark:active:bg-gray-300",
597
+ "text-primary-600 dark:text-gray-600",
598
+ "hover:text-primary-500 dark:hover:text-gray-700",
599
+ "active:text-primary-700 dark:active:text-gray-800",
600
+ "focus:ring-primary-700 dark:focus:ring-gray-800"
601
+ ]
602
+ },
603
+ {
604
+ role: "tertiarytext",
605
+ disabled: true,
606
+ class: "cursor-not-allowed text-gray-400"
607
+ }
608
+ ],
609
+ defaultVariants: {
610
+ role: "secondary",
611
+ status: "default",
612
+ size: "default",
613
+ position: "full",
614
+ disabled: false
615
+ }
616
+ });
617
+ function Proccessing({ className, light }) {
618
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("svg", { className: `h-5 w-5 animate-spin ${className}`, viewBox: "0 0 24 24", children: [
619
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
620
+ "circle",
621
+ {
622
+ className: light ? "opacity-5" : "opacity-10",
623
+ cx: "12",
624
+ cy: "12",
625
+ r: "10",
626
+ stroke: "currentColor",
627
+ strokeWidth: "4"
628
+ }
629
+ ),
630
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
631
+ "path",
632
+ {
633
+ className: light ? "opacity-50" : "opacity-75",
634
+ fill: "currentColor",
635
+ d: "M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"
636
+ }
637
+ )
638
+ ] });
639
+ }
640
+ var iconClass = (0, import_class_variance_authority5.cva)("", {
641
+ variants: {
642
+ size: {
643
+ default: "w-4 h-4",
644
+ md: "w-[18px] h-[18px]",
645
+ lg: "w-5 h-4",
646
+ sm: "w-4 h-4"
647
+ },
648
+ disabled: {
649
+ true: "saturate-0",
650
+ false: ""
651
+ }
652
+ },
653
+ defaultVariants: {
654
+ size: "default",
655
+ disabled: false
656
+ }
657
+ });
658
+ var pIconClass = (0, import_class_variance_authority5.cva)("", {
659
+ variants: {
660
+ size: {
661
+ default: "!w-4 !h-4",
662
+ md: "!w-[18px] !h-[18px]",
663
+ lg: "!w-5 !h-5",
664
+ sm: "!w-4 !h-4"
665
+ }
666
+ },
667
+ defaultVariants: {
668
+ size: "default"
669
+ }
670
+ });
671
+ function Button({
672
+ className,
673
+ size,
674
+ type,
675
+ role,
676
+ status,
677
+ onClick,
678
+ children,
679
+ processing,
680
+ disabled,
681
+ disabledHint,
682
+ disabledHintPortal,
683
+ position,
684
+ icon,
685
+ title,
686
+ value,
687
+ id
688
+ }, ref) {
689
+ const iconClasses = iconClass({ size, disabled });
690
+ const iconEl = (0, import_react5.useMemo)(() => {
691
+ let iconEl2 = null;
692
+ if (processing) {
693
+ iconEl2 = /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
694
+ Proccessing,
695
+ {
696
+ className: (0, import_class_variance_authority5.cx)(pIconClass({ size }), role == "primary" ? "text-white" : ""),
697
+ light: role !== "primary"
698
+ }
699
+ );
700
+ } else if (icon) {
701
+ iconEl2 = (0, import_react5.cloneElement)(icon, { className: (0, import_class_variance_authority5.cx)(icon.props.className, iconClasses) });
702
+ }
703
+ return iconEl2;
704
+ }, [icon, iconClasses, processing, role]);
705
+ const cls = (0, import_class_variance_authority5.cx)(
706
+ className,
707
+ buttonClass({
708
+ size,
709
+ status,
710
+ role,
711
+ disabled,
712
+ position
713
+ })
714
+ );
715
+ const btn = /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
716
+ "button",
717
+ {
718
+ title,
719
+ onClick,
720
+ type,
721
+ disabled: disabled || processing,
722
+ className: cls,
723
+ ref,
724
+ value,
725
+ suppressHydrationWarning: true,
726
+ id,
727
+ children: [
728
+ iconEl,
729
+ children
730
+ ]
731
+ }
732
+ );
733
+ if (disabled && disabledHint) {
734
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
735
+ PopoverTooltip,
736
+ {
737
+ usePortal: disabledHintPortal,
738
+ buttonClassName: disabledHintPortal ? "w-full" : "",
739
+ className: "text-gray",
740
+ text: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("p", { className: "text-sm text-gray-500", children: disabledHint }),
741
+ hideArrow: true,
742
+ children: btn
743
+ }
744
+ );
745
+ }
746
+ return btn;
747
+ }
748
+ var NewButton = (0, import_react5.forwardRef)(Button);
749
+ var NewButton_default = NewButton;
750
+
751
+ // src/common/dialog/BaseDialog.tsx
752
+ var import_react6 = require("react");
753
+ var import_react7 = require("@headlessui/react");
754
+ var import_class_variance_authority6 = require("class-variance-authority");
755
+ var import_jsx_runtime6 = require("react/jsx-runtime");
756
+ var BaseZIndexContext = (0, import_react6.createContext)(10);
757
+ function _BaseDialog({
758
+ title,
759
+ open,
760
+ onClose,
761
+ onCancel,
762
+ cancelText,
763
+ cancelProps = {},
764
+ onOk,
765
+ okText,
766
+ okProps = {},
767
+ children,
768
+ buttonsClassName,
769
+ panelClassName,
770
+ titleBorder = true,
771
+ footerBorder = true,
772
+ initialFocus,
773
+ extraButtons,
774
+ errorMessages,
775
+ footer,
776
+ zIndex = 10,
777
+ mask = "normal"
778
+ }) {
779
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_react7.Transition, { appear: true, as: import_react6.Fragment, show: open, children: /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
780
+ import_react7.Dialog,
781
+ {
782
+ className: (0, import_class_variance_authority6.cx)("relative", "_sentio_"),
783
+ as: "div",
784
+ onClose,
785
+ initialFocus,
786
+ style: {
787
+ zIndex
788
+ },
789
+ children: [
790
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
791
+ import_react7.Transition.Child,
792
+ {
793
+ as: import_react6.Fragment,
794
+ enter: "ease-out duration-300",
795
+ enterFrom: "opacity-0",
796
+ enterTo: "opacity-100",
797
+ leave: "ease-in duration-200",
798
+ leaveFrom: "opacity-100",
799
+ leaveTo: "opacity-0",
800
+ children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
801
+ "div",
802
+ {
803
+ className: (0, import_class_variance_authority6.cx)(
804
+ "fixed inset-0 transition-opacity",
805
+ mask === "light" ? "bg-gray-500/30 dark:bg-gray-200/30" : "bg-gray-500/75 dark:bg-gray-200/50"
806
+ )
807
+ }
808
+ )
809
+ }
810
+ ),
811
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "fixed inset-0 z-10 overflow-y-auto", children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "flex min-h-full items-end justify-center p-4 text-center sm:items-center sm:p-0", children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
812
+ import_react7.Transition.Child,
813
+ {
814
+ as: import_react6.Fragment,
815
+ enter: "ease-out duration-300",
816
+ enterFrom: "opacity-0 translate-y-4 sm:translate-y-0 sm:scale-95",
817
+ enterTo: "opacity-100 translate-y-0 sm:scale-100",
818
+ leave: "ease-in duration-200",
819
+ leaveFrom: "opacity-100 translate-y-0 sm:scale-100",
820
+ leaveTo: "opacity-0 translate-y-4 sm:translate-y-0 sm:scale-95",
821
+ children: /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
822
+ import_react7.Dialog.Panel,
823
+ {
824
+ "data-testid": "create-dashboard",
825
+ className: (0, import_class_variance_authority6.cx)(
826
+ "dark:bg-sidebar relative transform overflow-hidden rounded-lg bg-white pb-4 pt-5 text-left shadow-xl transition-all sm:my-8 sm:w-full sm:max-w-3xl",
827
+ panelClassName
828
+ ),
829
+ children: [
830
+ title ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
831
+ import_react7.Dialog.Title,
832
+ {
833
+ as: "h3",
834
+ className: (0, import_class_variance_authority6.cx)(
835
+ "text-ilabel font-ilabel text-text-foreground pl-4",
836
+ titleBorder && "border-border-color border-b pb-4"
837
+ ),
838
+ children: title
839
+ }
840
+ ) : null,
841
+ children,
842
+ footer ? footer : /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
843
+ "div",
844
+ {
845
+ className: (0, import_class_variance_authority6.cx)(
846
+ "flex items-center justify-between pt-4 ",
847
+ footerBorder && "border-border-color border-t"
848
+ ),
849
+ children: [
850
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
851
+ "div",
852
+ {
853
+ className: "truncate px-4 text-sm font-semibold text-red-500",
854
+ title: errorMessages || "",
855
+ children: errorMessages || " "
856
+ }
857
+ ),
858
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
859
+ "div",
860
+ {
861
+ className: (0, import_class_variance_authority6.cx)(
862
+ `flex flex-row-reverse items-center gap-3 px-4`,
863
+ buttonsClassName ?? ""
864
+ ),
865
+ children: [
866
+ extraButtons,
867
+ onOk && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(NewButton_default, { role: "primary", onClick: onOk, ...okProps, children: okText || "OK" }),
868
+ onCancel && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(NewButton_default, { onClick: onCancel, ...cancelProps, children: cancelText || "Cancel" })
869
+ ]
870
+ }
871
+ )
872
+ ]
873
+ }
874
+ )
875
+ ]
876
+ }
877
+ )
878
+ }
879
+ ) }) })
880
+ ]
881
+ }
882
+ ) });
883
+ }
884
+ var BaseDialog = (0, import_react6.memo)(_BaseDialog);
885
+
886
+ // src/common/DisclosurePanel.tsx
887
+ var import_class_variance_authority7 = require("class-variance-authority");
888
+ var import_isFunction = __toESM(require("lodash/isFunction"));
889
+ var import_react8 = require("react");
890
+ var import_lu = require("react-icons/lu");
891
+ var import_jsx_runtime7 = require("react/jsx-runtime");
892
+ function DisclosurePanel({
893
+ title,
894
+ children,
895
+ defaultOpen,
896
+ className,
897
+ containerClassName,
898
+ iconClassName = "h-5 w-5",
899
+ titleClassName
900
+ }) {
901
+ const [open, setOpen] = (0, import_react8.useState)(defaultOpen || false);
902
+ const toggle = (0, import_react8.useCallback)(() => {
903
+ setOpen((prev) => !prev);
904
+ }, []);
905
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
906
+ "div",
907
+ {
908
+ className: containerClassName || "dark:bg-sentio-gray-200 w-full rounded bg-[#F6F8FA]",
909
+ children: [
910
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
911
+ "button",
912
+ {
913
+ className: (0, import_class_variance_authority7.cx)(
914
+ open ? "rounded-t" : "rounded",
915
+ "focus-visible:ring-primary-500 text-ilabel font-ilabel text-text-foreground hover:bg-sentio-gray-100 dark:hover:bg-sentio-gray-400 flex w-full px-2 py-1.5 text-left focus:outline-none focus-visible:ring focus-visible:ring-opacity-75",
916
+ titleClassName
917
+ ),
918
+ onClick: toggle,
919
+ children: [
920
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
921
+ import_lu.LuChevronRight,
922
+ {
923
+ className: (0, import_class_variance_authority7.cx)(
924
+ open ? "rotate-90 transform" : "",
925
+ "mr-1 self-center transition-all",
926
+ iconClassName
927
+ )
928
+ }
929
+ ),
930
+ (0, import_isFunction.default)(title) ? title(open) : title
931
+ ]
932
+ }
933
+ ),
934
+ open && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: (0, import_class_variance_authority7.cx)("p-2", className), children })
935
+ ]
936
+ }
937
+ );
938
+ }
939
+
940
+ // src/common/Collapse.tsx
941
+ var import_solid = require("@heroicons/react/20/solid");
942
+ var import_class_variance_authority8 = require("class-variance-authority");
943
+
944
+ // src/utils/use-boolean.ts
945
+ var import_react9 = require("react");
946
+ function useBoolean(defaultValue = false) {
947
+ const [value, setValue] = (0, import_react9.useState)(defaultValue);
948
+ const setTrue = (0, import_react9.useCallback)(() => setValue(true), []);
949
+ const setFalse = (0, import_react9.useCallback)(() => setValue(false), []);
950
+ const toggle = (0, import_react9.useCallback)(() => setValue((v) => !v), []);
951
+ return {
952
+ value,
953
+ setValue,
954
+ setTrue,
955
+ setFalse,
956
+ toggle
957
+ };
958
+ }
959
+
960
+ // src/common/Collapse.tsx
961
+ var import_react10 = require("react");
962
+ var import_jsx_runtime8 = require("react/jsx-runtime");
963
+ var Collapse = ({
964
+ title,
965
+ children,
966
+ className,
967
+ titleClassName,
968
+ defaultOpen = false,
969
+ iconClassName = "h-5 w-5"
970
+ }) => {
971
+ const { toggle, value: visible, setTrue, setFalse } = useBoolean(defaultOpen);
972
+ (0, import_react10.useEffect)(() => {
973
+ if (defaultOpen) {
974
+ setTrue();
975
+ } else {
976
+ setFalse();
977
+ }
978
+ }, [defaultOpen, setTrue, setFalse]);
979
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: (0, import_class_variance_authority8.cx)("space-y-2", className), children: [
980
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
981
+ "span",
982
+ {
983
+ className: (0, import_class_variance_authority8.cx)(
984
+ "text-gray hover:text-primary active:text-primary-700 inline-flex cursor-pointer items-center gap-2",
985
+ titleClassName
986
+ ),
987
+ onClick: toggle,
988
+ children: [
989
+ title,
990
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
991
+ import_solid.ChevronDownIcon,
992
+ {
993
+ className: (0, import_class_variance_authority8.cx)(
994
+ "transition",
995
+ iconClassName,
996
+ visible ? "rotate-180" : ""
997
+ )
998
+ }
999
+ )
1000
+ ]
1001
+ }
1002
+ ),
1003
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
1004
+ "div",
1005
+ {
1006
+ className: (0, import_class_variance_authority8.cx)(
1007
+ "overflow-hidden transition-all duration-200",
1008
+ visible ? "max-h-[2000px] opacity-100" : "max-h-0 opacity-0"
1009
+ ),
1010
+ children
1011
+ }
1012
+ )
1013
+ ] });
1014
+ };
1015
+
1016
+ // src/common/Input.tsx
1017
+ var import_class_variance_authority9 = require("class-variance-authority");
1018
+ var import_solid2 = require("@heroicons/react/20/solid");
1019
+ var import_react11 = require("react");
1020
+ var import_jsx_runtime9 = require("react/jsx-runtime");
1021
+ var inputContainerStyles = (0, import_class_variance_authority9.cva)(
1022
+ "flex relative rounded-md border focus-within:ring-1 w-full font-normal overflow-hidden",
1023
+ {
1024
+ variants: {
1025
+ size: {
1026
+ sm: "text-sm h-6",
1027
+ md: "text-base h-8",
1028
+ lg: "text-lg h-10"
1029
+ },
1030
+ error: {
1031
+ true: "border-red-300 text-red-900 placeholder:text-red-300 focus-within:ring-red-500",
1032
+ false: "border-gray-300 focus-within:ring-primary-500 focus-within:border-primary-500"
1033
+ },
1034
+ readOnly: {
1035
+ true: "bg-gray-50 text-gray-400",
1036
+ false: "text-text-foreground"
1037
+ }
1038
+ },
1039
+ defaultVariants: {
1040
+ size: "md",
1041
+ error: false,
1042
+ readOnly: false
1043
+ },
1044
+ compoundVariants: []
1045
+ }
1046
+ );
1047
+ var inputStyles = (0, import_class_variance_authority9.cva)(
1048
+ [
1049
+ "block",
1050
+ "w-full",
1051
+ "placeholder:text-ilabel placeholder:font-normal",
1052
+ "border-none focus:ring-0",
1053
+ "focus:outline-none"
1054
+ ],
1055
+ {
1056
+ variants: {
1057
+ size: {
1058
+ sm: "sm:text-xs placeholder:text-xs placeholder:font-normal pl-2 pr-6",
1059
+ md: "sm:text-ilabel placeholder:text-ilabel placeholder:font-normal pl-2 pr-10",
1060
+ lg: "sm:text-lg placeholder:text-lg placeholder:font-normal pl-3 pr-10"
1061
+ },
1062
+ error: {
1063
+ true: "border-red-300",
1064
+ false: "border-gray-300 "
1065
+ }
1066
+ },
1067
+ defaultVariants: {
1068
+ size: "md",
1069
+ error: false
1070
+ }
1071
+ }
1072
+ );
1073
+ var iconStyles = (0, import_class_variance_authority9.cva)("text-red-500", {
1074
+ variants: {
1075
+ size: {
1076
+ sm: "h-4 w-4",
1077
+ md: "h-5 w-5",
1078
+ lg: "h-6 w-6"
1079
+ }
1080
+ },
1081
+ defaultVariants: {
1082
+ size: "md"
1083
+ }
1084
+ });
1085
+ var Input = (0, import_react11.forwardRef)(
1086
+ function Input2(props, inputRef) {
1087
+ const { className, error, errorClassName, size, ...rest } = props;
1088
+ const containerClassName = inputContainerStyles({
1089
+ size,
1090
+ error: !!error,
1091
+ readOnly: rest.disabled
1092
+ });
1093
+ const inputClassName = (0, import_class_variance_authority9.cx)(inputStyles({ size, error: !!error }), className);
1094
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { children: [
1095
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: containerClassName, children: [
1096
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("input", { ...rest, ref: inputRef, className: inputClassName }),
1097
+ error && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "pointer-events-none absolute inset-y-0 right-0 flex items-center pr-3", children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_solid2.ExclamationCircleIcon, { className: iconStyles({ size }) }) })
1098
+ ] }),
1099
+ error && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("p", { className: "mt-2 text-xs text-red-600", children: typeof error == "string" ? error : error.message })
1100
+ ] });
1101
+ }
1102
+ );
1103
+
1104
+ // src/common/select/Radio.tsx
1105
+ var import_react12 = require("@headlessui/react");
1106
+
1107
+ // src/utils/classnames.ts
1108
+ var import_class_variance_authority10 = require("class-variance-authority");
1109
+
1110
+ // src/common/select/Radio.tsx
1111
+ var import_jsx_runtime10 = require("react/jsx-runtime");
1112
+ function RadioSelect({
1113
+ value,
1114
+ onChange,
1115
+ label,
1116
+ labelClassName,
1117
+ options,
1118
+ vertical,
1119
+ containerClassName
1120
+ }) {
1121
+ return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(import_react12.RadioGroup, { value, onChange, children: [
1122
+ label && /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(import_react12.RadioGroup.Label, { className: "text-ilabel text-text-foreground mr-4 font-medium", children: [
1123
+ label,
1124
+ ":"
1125
+ ] }),
1126
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
1127
+ "div",
1128
+ {
1129
+ className: (0, import_class_variance_authority10.cx)(
1130
+ "item-center",
1131
+ vertical ? "flex flex-col gap-2" : "inline-flex gap-4",
1132
+ containerClassName
1133
+ ),
1134
+ children: options.map(({ name, value: value2 }, index) => /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_react12.RadioGroup.Option, { value: value2, children: ({ checked }) => /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("span", { className: "group/radio", children: [
1135
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
1136
+ "input",
1137
+ {
1138
+ readOnly: true,
1139
+ type: "radio",
1140
+ checked,
1141
+ className: "border-sentio-gray-300 group-hover/radio:border-primary-500"
1142
+ }
1143
+ ),
1144
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
1145
+ "label",
1146
+ {
1147
+ className: (0, import_class_variance_authority10.cx)(
1148
+ "text-ilabel group-hover/radio:text-primary-500 group-hover/radio:dark:text-primary-600 ml-2 font-medium ",
1149
+ checked ? "text-primary dark:text-primary-700" : "text-gray",
1150
+ labelClassName
1151
+ ),
1152
+ children: name
1153
+ }
1154
+ )
1155
+ ] }) }, index))
1156
+ }
1157
+ )
1158
+ ] });
1159
+ }
1160
+
1161
+ // src/common/select/Switch.tsx
1162
+ var import_react13 = require("react");
1163
+ var import_react14 = require("@headlessui/react");
1164
+ var import_class_variance_authority11 = require("class-variance-authority");
1165
+ var import_lodash2 = require("lodash");
1166
+ var import_jsx_runtime11 = require("react/jsx-runtime");
1167
+ var switchClass = (0, import_class_variance_authority11.cva)(
1168
+ [
1169
+ "relative inline-flex shrink-0 rounded-full border-2 border-transparent transition-colors duration-200 ease-in-out focus:outline-none focus-visible:ring-2 focus-visible:ring-white focus-visible:ring-opacity-75"
1170
+ ],
1171
+ {
1172
+ variants: {
1173
+ size: {
1174
+ lg: "h-8 w-[68px]",
1175
+ default: "h-6 w-[52px]",
1176
+ sm: "h-[16px] w-[30px]"
1177
+ },
1178
+ enabled: {
1179
+ true: "bg-primary group-hover:bg-primary-500",
1180
+ false: "bg-gray-400/50 group-hover:bg-primary-200"
1181
+ },
1182
+ disabled: {
1183
+ true: "cursor-not-allowed opacity-50",
1184
+ false: "cursor-pointer"
1185
+ }
1186
+ },
1187
+ defaultVariants: {
1188
+ size: "default",
1189
+ enabled: false
1190
+ },
1191
+ compoundVariants: [
1192
+ {
1193
+ enabled: false,
1194
+ disabled: true,
1195
+ class: "!bg-gray-400/50"
1196
+ }
1197
+ ]
1198
+ }
1199
+ );
1200
+ var dotClass = (0, import_class_variance_authority11.cva)(
1201
+ "pointer-events-none inline-block transform rounded-full bg-white dark:bg-sentio-gray-100 shadow-lg ring-0 transition duration-200 ease-in-out",
1202
+ {
1203
+ variants: {
1204
+ size: {
1205
+ lg: "h-7 w-7",
1206
+ default: "h-5 w-5",
1207
+ sm: "h-3 w-3"
1208
+ },
1209
+ enabled: {
1210
+ true: "",
1211
+ false: "translate-x-0"
1212
+ }
1213
+ },
1214
+ defaultVariants: {
1215
+ size: "default"
1216
+ },
1217
+ compoundVariants: [
1218
+ {
1219
+ size: "sm",
1220
+ enabled: true,
1221
+ class: "translate-x-3.5 switch-dot-sm"
1222
+ },
1223
+ {
1224
+ size: "default",
1225
+ enabled: true,
1226
+ class: "translate-x-7"
1227
+ },
1228
+ {
1229
+ size: "lg",
1230
+ enabled: true,
1231
+ class: "translate-x-9"
1232
+ }
1233
+ ]
1234
+ }
1235
+ );
1236
+ var labelClass = (0, import_class_variance_authority11.cva)(
1237
+ "text-text-foreground ml-2 font-medium align-text-bottom",
1238
+ {
1239
+ variants: {
1240
+ size: {
1241
+ lg: "text-sm leading-8",
1242
+ default: "text-icontent leading-6 ",
1243
+ sm: "text-icontent leading-5"
1244
+ },
1245
+ disabled: {
1246
+ true: "cursor-not-allowed opacity-50",
1247
+ false: "cursor-pointer"
1248
+ }
1249
+ },
1250
+ defaultVariants: {
1251
+ size: "default",
1252
+ disabled: false
1253
+ }
1254
+ }
1255
+ );
1256
+ function Switch({
1257
+ checked,
1258
+ onChange: _onChange,
1259
+ srText,
1260
+ size = "default",
1261
+ disabled,
1262
+ label
1263
+ }) {
1264
+ const [enabled, setState] = (0, import_react13.useState)(checked);
1265
+ const onChange = (0, import_react13.useCallback)(() => {
1266
+ setState((enabled2) => {
1267
+ if ((0, import_lodash2.isFunction)(_onChange)) {
1268
+ setTimeout(() => {
1269
+ _onChange(!enabled2);
1270
+ });
1271
+ }
1272
+ return !enabled2;
1273
+ });
1274
+ }, [_onChange]);
1275
+ (0, import_react13.useEffect)(() => {
1276
+ setState(checked);
1277
+ }, [checked]);
1278
+ return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(import_react14.Switch.Group, { children: [
1279
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(
1280
+ import_react14.Switch,
1281
+ {
1282
+ checked: enabled,
1283
+ onChange: onChange || setState,
1284
+ className: switchClass({
1285
+ enabled,
1286
+ size,
1287
+ disabled
1288
+ }),
1289
+ disabled,
1290
+ children: [
1291
+ srText && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("span", { className: "sr-only", children: srText }),
1292
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
1293
+ "span",
1294
+ {
1295
+ "aria-hidden": "true",
1296
+ className: dotClass({
1297
+ enabled,
1298
+ size
1299
+ })
1300
+ }
1301
+ )
1302
+ ]
1303
+ }
1304
+ ),
1305
+ label && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
1306
+ import_react14.Switch.Label,
1307
+ {
1308
+ className: labelClass({
1309
+ size,
1310
+ disabled
1311
+ }),
1312
+ children: label
1313
+ }
1314
+ )
1315
+ ] });
1316
+ }
1317
+
1318
+ // src/common/select/Select.tsx
1319
+ var import_react15 = require("@headlessui/react");
1320
+ var import_solid3 = require("@heroicons/react/20/solid");
1321
+ var import_lodash3 = require("lodash");
1322
+ var import_class_variance_authority12 = require("class-variance-authority");
1323
+ var import_react16 = require("react");
1324
+ var import_isFunction2 = __toESM(require("lodash/isFunction"));
1325
+ var import_react_spinners3 = require("react-spinners");
1326
+ var import_react_laag = require("react-laag");
1327
+ var import_react_resize_detector = require("react-resize-detector");
1328
+ var import_jsx_runtime12 = require("react/jsx-runtime");
1329
+ var buttonClass2 = (0, import_class_variance_authority12.cva)(
1330
+ [
1331
+ "focus:ring-primary focus:border-primary",
1332
+ "relative w-full rounded-md border bg-white dark:bg-sentio-gray-100 text-left focus:outline-none focus:ring-1 text-ilabel"
1333
+ ],
1334
+ {
1335
+ variants: {
1336
+ open: {
1337
+ true: "bg-sentio-gray-100 ring-1 ring-primary border-primary",
1338
+ false: ""
1339
+ },
1340
+ size: {
1341
+ sm: "py-1 px-2",
1342
+ md: "py-2 px-3"
1343
+ },
1344
+ error: {
1345
+ true: "border-red-300 text-red-900 placeholder-red-300 focus-within:ring-red-500",
1346
+ false: "border-border-color"
1347
+ },
1348
+ disabled: {
1349
+ true: "cursor-not-allowed",
1350
+ false: "cursor-default"
1351
+ }
1352
+ },
1353
+ defaultVariants: {
1354
+ open: false,
1355
+ size: "sm",
1356
+ error: false,
1357
+ disabled: false
1358
+ },
1359
+ compoundVariants: [
1360
+ {
1361
+ open: true,
1362
+ error: true,
1363
+ class: "!ring-red-300 border-red-300"
1364
+ }
1365
+ ]
1366
+ }
1367
+ );
1368
+ var optionClass = (0, import_class_variance_authority12.cva)(["relative cursor-default select-none"], {
1369
+ variants: {
1370
+ disabled: {
1371
+ true: "cursor-not-allowed text-gray-400",
1372
+ false: "text-text-foreground"
1373
+ },
1374
+ size: {
1375
+ sm: "py-1 pl-3 pr-5",
1376
+ md: "py-2 pl-3 pr-6"
1377
+ },
1378
+ active: {
1379
+ true: "bg-primary-50 dark:bg-primary-400/50",
1380
+ false: ""
1381
+ },
1382
+ selected: {
1383
+ true: "!bg-primary-100 dark:!bg-primary-400",
1384
+ false: ""
1385
+ }
1386
+ },
1387
+ defaultVariants: {
1388
+ disabled: false,
1389
+ active: false,
1390
+ selected: false,
1391
+ size: "sm"
1392
+ }
1393
+ });
1394
+ var iconClass2 = (0, import_class_variance_authority12.cva)([], {
1395
+ variants: {
1396
+ size: {
1397
+ sm: "h-3.5 w-3.5",
1398
+ md: "h-4 w-4"
1399
+ },
1400
+ disabled: {
1401
+ true: "opacity-50",
1402
+ false: ""
1403
+ }
1404
+ },
1405
+ defaultVariants: {
1406
+ size: "sm",
1407
+ disabled: false
1408
+ }
1409
+ });
1410
+ function generateLabel(label, props) {
1411
+ if ((0, import_isFunction2.default)(label)) {
1412
+ return label(props);
1413
+ }
1414
+ return label;
1415
+ }
1416
+ function Select({
1417
+ className,
1418
+ buttonClassName,
1419
+ optionsClassName,
1420
+ options,
1421
+ value,
1422
+ onChange,
1423
+ placeholder,
1424
+ size = "sm",
1425
+ renderOption,
1426
+ noOptionsMessage,
1427
+ error,
1428
+ disabled,
1429
+ fetchMore,
1430
+ isFetchingMore,
1431
+ scrollBottomThreshold = 100,
1432
+ groupedOptions,
1433
+ groupedOrder,
1434
+ unmountOptions = true,
1435
+ direction = "down",
1436
+ asLayer
1437
+ }) {
1438
+ const selectedIndex = options.findIndex((o) => (0, import_lodash3.isEqual)(o.value, value));
1439
+ const listRef = (0, import_react16.useRef)(null);
1440
+ const [open, setOpen] = (0, import_react16.useState)(false);
1441
+ const { width, ref } = (0, import_react_resize_detector.useResizeDetector)({
1442
+ refreshMode: "debounce",
1443
+ refreshRate: 100,
1444
+ handleHeight: false
1445
+ });
1446
+ const baseZIndex = (0, import_react16.useContext)(BaseZIndexContext);
1447
+ const { renderLayer, triggerProps, layerProps } = (0, import_react_laag.useLayer)({
1448
+ isOpen: open,
1449
+ auto: true,
1450
+ preferX: "left",
1451
+ preferY: direction === "up" ? "top" : "bottom",
1452
+ placement: direction === "up" ? "top-start" : "bottom-start",
1453
+ triggerOffset: 4,
1454
+ onOutsideClick: () => setOpen(false)
1455
+ });
1456
+ const grouped = (0, import_react16.useMemo)(() => {
1457
+ if (!groupedOptions || !options || options.length === 0) {
1458
+ return options;
1459
+ }
1460
+ const groupedOptionsList = options.reduce((acc, option) => {
1461
+ ;
1462
+ (acc[option.group] = acc[option.group] || []).push(option);
1463
+ return acc;
1464
+ }, {});
1465
+ return groupedOrder?.reduce((acc, group) => {
1466
+ return [
1467
+ ...acc,
1468
+ {
1469
+ label: group.label,
1470
+ options: groupedOptionsList[group.key] || []
1471
+ }
1472
+ ];
1473
+ }, []);
1474
+ }, [groupedOptions, groupedOrder, options]);
1475
+ const optionsElement = /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(
1476
+ import_react15.Listbox.Options,
1477
+ {
1478
+ ref: listRef,
1479
+ onScroll: () => {
1480
+ if (listRef.current?.scrollHeight) {
1481
+ const bottomHeight = listRef.current?.scrollHeight - listRef.current?.clientHeight - listRef.current?.scrollTop;
1482
+ if (bottomHeight < scrollBottomThreshold) {
1483
+ fetchMore?.();
1484
+ }
1485
+ }
1486
+ },
1487
+ unmount: unmountOptions,
1488
+ className: (0, import_class_variance_authority10.cx)(
1489
+ "text-ilabel dark:bg-sentio-gray-100 scrollbar-thin max-h-60 w-full overflow-auto rounded-md bg-white py-1 shadow-lg ring-1 ring-black ring-opacity-5 focus:outline-none dark:ring-gray-100 sm:text-sm",
1490
+ asLayer ? "" : "absolute z-10",
1491
+ optionsClassName
1492
+ ),
1493
+ children: [
1494
+ !options || options.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
1495
+ import_react15.Listbox.Option,
1496
+ {
1497
+ value: null,
1498
+ disabled: true,
1499
+ className: optionClass({ disabled: true, size }),
1500
+ children: noOptionsMessage ?? /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { className: "text-gray-400", children: "No options" })
1501
+ }
1502
+ ) : null,
1503
+ groupedOptions && grouped ? grouped.map(({ label, options: options2 }) => {
1504
+ if (!options2 || options2.length === 0) {
1505
+ return null;
1506
+ }
1507
+ return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { children: [
1508
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: "text-gray px-3.5 py-1 text-xs font-medium", children: label }),
1509
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { children: options2.map(
1510
+ (option, i) => /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
1511
+ import_react15.Listbox.Option,
1512
+ {
1513
+ value: option.value,
1514
+ disabled: option.disabled,
1515
+ className: ({ active }) => optionClass({
1516
+ disabled: option.disabled,
1517
+ size,
1518
+ active,
1519
+ selected: (0, import_lodash3.isEqual)(value, option.value)
1520
+ }),
1521
+ title: option.title,
1522
+ children: ({ selected, active }) => {
1523
+ if (renderOption) {
1524
+ return renderOption(option, { selected, active });
1525
+ }
1526
+ return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(import_jsx_runtime12.Fragment, { children: [
1527
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
1528
+ "span",
1529
+ {
1530
+ className: (0, import_class_variance_authority10.cx)(
1531
+ selected ? "font-medium" : "font-normal",
1532
+ "text-ilabel block truncate"
1533
+ ),
1534
+ children: generateLabel(option.label, {
1535
+ selected,
1536
+ active
1537
+ })
1538
+ }
1539
+ ),
1540
+ selected ? /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
1541
+ "span",
1542
+ {
1543
+ className: (0, import_class_variance_authority10.cx)(
1544
+ "text-primary-600 absolute inset-y-0 right-0 flex items-center pr-2 dark:text-white"
1545
+ ),
1546
+ children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
1547
+ import_solid3.CheckIcon,
1548
+ {
1549
+ className: iconClass2({ size }),
1550
+ "aria-hidden": "true"
1551
+ }
1552
+ )
1553
+ }
1554
+ ) : null
1555
+ ] });
1556
+ }
1557
+ },
1558
+ i
1559
+ )
1560
+ ) })
1561
+ ] }, label);
1562
+ }) : options.map((option, i) => /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
1563
+ import_react15.Listbox.Option,
1564
+ {
1565
+ value: option.value,
1566
+ disabled: option.disabled,
1567
+ className: ({ active }) => optionClass({
1568
+ disabled: option.disabled,
1569
+ size,
1570
+ active,
1571
+ selected: selectedIndex === i
1572
+ }),
1573
+ title: option.title,
1574
+ children: ({ selected, active }) => {
1575
+ if (renderOption) {
1576
+ return renderOption(option, { selected, active });
1577
+ }
1578
+ return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(import_jsx_runtime12.Fragment, { children: [
1579
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
1580
+ "span",
1581
+ {
1582
+ className: (0, import_class_variance_authority10.cx)(
1583
+ selected ? "font-medium" : "font-normal",
1584
+ "text-ilabel block truncate"
1585
+ ),
1586
+ children: generateLabel(option.label, { selected, active })
1587
+ }
1588
+ ),
1589
+ selected ? /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
1590
+ "span",
1591
+ {
1592
+ className: (0, import_class_variance_authority10.cx)(
1593
+ "text-primary-600 absolute inset-y-0 right-0 flex items-center pr-2 dark:text-white"
1594
+ ),
1595
+ children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
1596
+ import_solid3.CheckIcon,
1597
+ {
1598
+ className: iconClass2({ size }),
1599
+ "aria-hidden": "true"
1600
+ }
1601
+ )
1602
+ }
1603
+ ) : null
1604
+ ] });
1605
+ }
1606
+ },
1607
+ i
1608
+ )),
1609
+ isFetchingMore && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
1610
+ import_react15.Listbox.Option,
1611
+ {
1612
+ value: null,
1613
+ disabled: true,
1614
+ className: optionClass({ disabled: true, size }),
1615
+ children: /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: "flex w-full items-center justify-center gap-2", children: [
1616
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_react_spinners3.ClipLoader, { size: 16, color: "#A6C2F0" }),
1617
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { className: "text-gray/50 text-xs", children: "Loading more..." })
1618
+ ] })
1619
+ }
1620
+ )
1621
+ ]
1622
+ }
1623
+ );
1624
+ return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_react15.Listbox, { value, onChange, disabled, children: ({ open: headlessOpen }) => {
1625
+ if (headlessOpen !== open && asLayer) {
1626
+ setOpen(headlessOpen);
1627
+ }
1628
+ return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: (0, import_class_variance_authority10.cx)(className, "relative"), ref, children: [
1629
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(
1630
+ import_react15.Listbox.Button,
1631
+ {
1632
+ as: "div",
1633
+ className: (0, import_class_variance_authority10.cx)(
1634
+ buttonClass2({
1635
+ open: headlessOpen,
1636
+ size,
1637
+ error: !!error,
1638
+ disabled: !!disabled
1639
+ }),
1640
+ buttonClassName
1641
+ ),
1642
+ ...triggerProps,
1643
+ children: [
1644
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: "pr-4", children: selectedIndex > -1 ? generateLabel(options[selectedIndex].label, {}) : placeholder ? /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
1645
+ "span",
1646
+ {
1647
+ className: (0, import_class_variance_authority10.cx)(
1648
+ "font-normal",
1649
+ error ? "text-red-400" : "text-gray-400"
1650
+ ),
1651
+ children: placeholder
1652
+ }
1653
+ ) : "" }),
1654
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
1655
+ "button",
1656
+ {
1657
+ type: "button",
1658
+ disabled,
1659
+ className: (0, import_class_variance_authority10.cx)(
1660
+ "absolute inset-y-0 right-0 flex items-center rounded-r-md px-2 focus:outline-none"
1661
+ ),
1662
+ children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
1663
+ import_solid3.ChevronDownIcon,
1664
+ {
1665
+ className: iconClass2({ size, disabled: !!disabled })
1666
+ }
1667
+ )
1668
+ }
1669
+ )
1670
+ ]
1671
+ }
1672
+ ),
1673
+ headlessOpen ? asLayer ? renderLayer(
1674
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
1675
+ "div",
1676
+ {
1677
+ ...layerProps,
1678
+ style: {
1679
+ ...layerProps.style,
1680
+ zIndex: Math.max(10, baseZIndex + 1),
1681
+ minWidth: width
1682
+ },
1683
+ children: optionsElement
1684
+ }
1685
+ )
1686
+ ) : optionsElement : null,
1687
+ error && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("p", { className: "mt-2 text-xs font-medium text-red-600", children: typeof error == "string" ? error : error.message })
1688
+ ] });
1689
+ } });
1690
+ }
1691
+
1692
+ // src/common/tree/FlatTree.tsx
1693
+ var import_react19 = require("react");
1694
+
1695
+ // src/common/tree/Tree.tsx
1696
+ var import_react17 = require("react");
1697
+
1698
+ // src/common/tree/TreeIcons.tsx
1699
+ var import_lu2 = require("react-icons/lu");
1700
+
1701
+ // src/common/tree/Tree.tsx
1702
+ var import_class_variance_authority13 = require("class-variance-authority");
1703
+ var import_react18 = require("react");
1704
+ var import_jsx_runtime13 = require("react/jsx-runtime");
1705
+ var Line = () => {
1706
+ return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { className: "-my-1.5 mr-[19px] h-full min-h-[24px] w-[px] translate-x-2 border-l border-dashed border-gray-400" });
1707
+ };
1708
+ var Tree_default = (0, import_react17.forwardRef)(function Tree({
1709
+ open: defaultOpen,
1710
+ content,
1711
+ children,
1712
+ depth = 0,
1713
+ type,
1714
+ contentClassName,
1715
+ prefix,
1716
+ suffix,
1717
+ onClick,
1718
+ onOpenClick,
1719
+ showToggle,
1720
+ className,
1721
+ expandIcon = /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_lu2.LuSquarePlus, { className: "h-[1em] w-[1em] align-middle" }),
1722
+ collapseIcon = /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_lu2.LuSquareMinus, { className: "h-[1em] w-[1em] align-middle" })
1723
+ }, ref) {
1724
+ const [open, setOpen] = (0, import_react17.useState)(defaultOpen);
1725
+ (0, import_react18.useEffect)(() => {
1726
+ setOpen(defaultOpen);
1727
+ }, [defaultOpen]);
1728
+ const toggle = (0, import_react17.useCallback)(
1729
+ (evt) => {
1730
+ evt.stopPropagation();
1731
+ if (onOpenClick) {
1732
+ onOpenClick(!open);
1733
+ } else {
1734
+ setOpen((val) => {
1735
+ return !val;
1736
+ });
1737
+ }
1738
+ },
1739
+ [open, onOpenClick]
1740
+ );
1741
+ const lineNodes = (0, import_react17.useMemo)(() => {
1742
+ const lines = [];
1743
+ for (let i = 0; i < depth; i++) {
1744
+ lines.push(/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(Line, {}, i));
1745
+ }
1746
+ return lines;
1747
+ }, [depth]);
1748
+ return /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(
1749
+ "div",
1750
+ {
1751
+ className: (0, import_class_variance_authority13.cx)(
1752
+ "text-icontent font-icontent overflow-hidden text-ellipsis whitespace-nowrap align-middle",
1753
+ className
1754
+ ),
1755
+ children: [
1756
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(
1757
+ "div",
1758
+ {
1759
+ ref,
1760
+ className: (0, import_class_variance_authority13.cx)(
1761
+ "flex items-center px-2 py-1 hover:bg-gray-100",
1762
+ contentClassName
1763
+ ),
1764
+ onClick,
1765
+ children: [
1766
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { className: "inline-flex shrink-0 items-center self-stretch", children: lineNodes }),
1767
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { className: "inline-flex shrink-0 items-center", children: children || showToggle ? /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
1768
+ "button",
1769
+ {
1770
+ className: "fill-gray color-gray hover:fill-primary-500 hover:color-primary-500 dark:hover:fill-primary-700 mr-1.5 cursor-pointer",
1771
+ onClick: toggle,
1772
+ children: open ? collapseIcon : expandIcon
1773
+ }
1774
+ ) : /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("span", { className: "mr-[19px] h-1 w-px" }) }),
1775
+ type,
1776
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("span", { className: "flex-1 align-middle", children: content })
1777
+ ]
1778
+ }
1779
+ ),
1780
+ prefix,
1781
+ open ? children : null,
1782
+ suffix
1783
+ ]
1784
+ }
1785
+ );
1786
+ });
1787
+
1788
+ // src/common/tree/FlatTree.tsx
1789
+ var import_react_virtual = require("@tanstack/react-virtual");
1790
+ var import_isNumber = __toESM(require("lodash/isNumber"));
1791
+ var import_class_variance_authority14 = require("class-variance-authority");
1792
+ var import_lodash4 = require("lodash");
1793
+ var import_jsx_runtime14 = require("react/jsx-runtime");
1794
+ var SUFFIX_NODE_KEY = "selectedKey_after";
1795
+ var ROOT_KEY = "root";
1796
+ var TreeContext = (0, import_react19.createContext)({
1797
+ expandKeys: [],
1798
+ onExpand: (key) => {
1799
+ console.log(key);
1800
+ }
1801
+ });
1802
+ var ControledTree = ({
1803
+ item,
1804
+ selected,
1805
+ contentClassName,
1806
+ expandIcon,
1807
+ collapseIcon
1808
+ }) => {
1809
+ const { expandKeys, onExpand, onClick } = (0, import_react19.useContext)(TreeContext);
1810
+ let titleNode;
1811
+ if (typeof item.title === "function") {
1812
+ titleNode = item.title(item);
1813
+ } else {
1814
+ titleNode = item.title;
1815
+ }
1816
+ const onOpenClick = (0, import_react19.useCallback)(() => {
1817
+ onExpand(item.key);
1818
+ }, [onExpand, item.key]);
1819
+ const onNodeClick = (0, import_react19.useCallback)(() => {
1820
+ onClick?.(item);
1821
+ }, [item]);
1822
+ const isLeaf = item.children === void 0 || item.children?.length === 0;
1823
+ return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
1824
+ Tree_default,
1825
+ {
1826
+ contentClassName: (0, import_class_variance_authority14.cx)(
1827
+ selected ? "bg-sentio-gray-100" : "",
1828
+ item.key === SUFFIX_NODE_KEY ? "!px-0 !py-0" : "",
1829
+ contentClassName
1830
+ ),
1831
+ className: item.key === SUFFIX_NODE_KEY ? "sticky left-0 inline-block !overflow-visible" : "group/tree",
1832
+ showToggle: !isLeaf,
1833
+ open: expandKeys.includes(item.key),
1834
+ depth: item.depth,
1835
+ content: titleNode,
1836
+ onOpenClick,
1837
+ onClick: onNodeClick,
1838
+ expandIcon,
1839
+ collapseIcon
1840
+ },
1841
+ item.key
1842
+ );
1843
+ };
1844
+ var DEFAULT_ROW_HEIGHT = 35;
1845
+ function checkRootKeyDefault(v) {
1846
+ return v === ROOT_KEY;
1847
+ }
1848
+ var FlatTree = (props) => {
1849
+ const {
1850
+ data,
1851
+ defaultExpandAll,
1852
+ virtual,
1853
+ rowHeight = DEFAULT_ROW_HEIGHT,
1854
+ height,
1855
+ onClick,
1856
+ suffixNode,
1857
+ expandDepth,
1858
+ contentClassName,
1859
+ expandIcon,
1860
+ collapseIcon,
1861
+ scrollToKey,
1862
+ scrollIntoView,
1863
+ isRootKey = checkRootKeyDefault
1864
+ } = props;
1865
+ const dataRef = (0, import_react19.useRef)(null);
1866
+ const selectedKeyRef = (0, import_react19.useRef)();
1867
+ const [expandKeys, setExpandKeys] = (0, import_react19.useState)([]);
1868
+ const [selectedKey, setSelectedKey] = (0, import_react19.useState)();
1869
+ const parentRef = (0, import_react19.useRef)(null);
1870
+ (0, import_react19.useEffect)(() => {
1871
+ if (defaultExpandAll) {
1872
+ const flatten = (data2) => {
1873
+ return data2.reduce((acc, cur) => {
1874
+ const { children, key } = cur;
1875
+ acc.push(key);
1876
+ if (children) {
1877
+ acc.push(...flatten(children));
1878
+ }
1879
+ return acc;
1880
+ }, []);
1881
+ };
1882
+ setExpandKeys(flatten(data || []));
1883
+ } else {
1884
+ setExpandKeys([]);
1885
+ }
1886
+ }, [data, defaultExpandAll]);
1887
+ const flattenData = (0, import_react19.useMemo)(() => {
1888
+ const expandKeysSet = new Set(expandKeys);
1889
+ const flatten = (data2, depth = 0) => {
1890
+ return data2.reduce((acc, cur) => {
1891
+ const { children } = cur;
1892
+ acc.push({ ...cur, depth });
1893
+ if (children && expandKeysSet.has(cur.key)) {
1894
+ acc.push(...flatten(children, depth + 1));
1895
+ }
1896
+ return acc;
1897
+ }, []);
1898
+ };
1899
+ const list = flatten(data || []);
1900
+ if (selectedKey && (0, import_react19.isValidElement)(suffixNode)) {
1901
+ const index = list.findIndex((item) => item.key === selectedKey);
1902
+ if (index > -1) {
1903
+ list.splice(index + 1, 0, {
1904
+ key: SUFFIX_NODE_KEY,
1905
+ title: suffixNode,
1906
+ depth: 0
1907
+ });
1908
+ }
1909
+ }
1910
+ return list;
1911
+ }, [data, expandKeys, selectedKey, suffixNode]);
1912
+ dataRef.current = flattenData;
1913
+ const estimateSize = (0, import_react19.useCallback)(
1914
+ (index) => {
1915
+ if ((0, import_isNumber.default)(rowHeight)) {
1916
+ return rowHeight;
1917
+ }
1918
+ return rowHeight(index, dataRef.current?.[index]?.key === SUFFIX_NODE_KEY);
1919
+ },
1920
+ [rowHeight]
1921
+ );
1922
+ const rowVirtualizer = (0, import_react_virtual.useVirtualizer)({
1923
+ count: flattenData.length,
1924
+ getScrollElement: () => parentRef.current,
1925
+ estimateSize,
1926
+ overscan: 10
1927
+ });
1928
+ const contextValue = (0, import_react19.useMemo)(() => {
1929
+ return {
1930
+ expandKeys,
1931
+ onExpand: (key) => {
1932
+ setExpandKeys((keys) => {
1933
+ if (keys.includes(key)) {
1934
+ return keys.filter((k) => k !== key);
1935
+ } else {
1936
+ return [...keys, key];
1937
+ }
1938
+ });
1939
+ },
1940
+ onClick: (data2) => {
1941
+ if (onClick === void 0) {
1942
+ return;
1943
+ }
1944
+ if (data2.key === SUFFIX_NODE_KEY || isRootKey(data2.key)) {
1945
+ return;
1946
+ }
1947
+ setSelectedKey((key) => {
1948
+ if (key === data2.key) {
1949
+ selectedKeyRef.current = void 0;
1950
+ return void 0;
1951
+ }
1952
+ selectedKeyRef.current = data2.key;
1953
+ return data2.key;
1954
+ });
1955
+ onClick?.(data2);
1956
+ }
1957
+ };
1958
+ }, [expandKeys, onClick]);
1959
+ (0, import_react19.useEffect)(() => {
1960
+ if (!(0, import_isNumber.default)(expandDepth)) {
1961
+ return;
1962
+ }
1963
+ const flatten = (data2, currentDepth = 0) => {
1964
+ return data2.reduce((acc, cur) => {
1965
+ const { children, key } = cur;
1966
+ if (currentDepth < expandDepth && children && children.length > 0) {
1967
+ acc.push(key);
1968
+ acc.push(...flatten(children, currentDepth + 1));
1969
+ }
1970
+ return acc;
1971
+ }, []);
1972
+ };
1973
+ setExpandKeys(flatten(data || []));
1974
+ }, [data, expandDepth]);
1975
+ (0, import_react19.useEffect)(() => {
1976
+ setSelectedKey(void 0);
1977
+ }, [expandDepth]);
1978
+ (0, import_react19.useEffect)(() => {
1979
+ if (dataRef.current && scrollToKey) {
1980
+ const index = dataRef.current.findIndex(
1981
+ (item) => item.key === scrollToKey
1982
+ );
1983
+ if (index > -1) {
1984
+ rowVirtualizer.scrollToIndex(index, {
1985
+ align: "center",
1986
+ behavior: "auto"
1987
+ });
1988
+ }
1989
+ }
1990
+ }, [scrollToKey]);
1991
+ const visibleItems = rowVirtualizer.getVirtualItems();
1992
+ const [isPending, startTransition] = (0, import_react19.useTransition)();
1993
+ const onScroll = (0, import_react19.useMemo)(() => {
1994
+ if (!scrollIntoView) {
1995
+ return () => {
1996
+ };
1997
+ }
1998
+ const throttleFn = (0, import_lodash4.throttle)(
1999
+ () => {
2000
+ startTransition(() => {
2001
+ parentRef.current?.scrollIntoView(true);
2002
+ });
2003
+ },
2004
+ 1e3,
2005
+ { trailing: true }
2006
+ );
2007
+ let lastScrollTop = 0;
2008
+ return (evt) => {
2009
+ const scrollTop = evt.currentTarget.scrollTop;
2010
+ if (scrollTop > lastScrollTop) {
2011
+ throttleFn();
2012
+ }
2013
+ lastScrollTop = scrollTop;
2014
+ };
2015
+ }, [scrollIntoView]);
2016
+ return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(TreeContext.Provider, { value: contextValue, children: virtual ? /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
2017
+ "div",
2018
+ {
2019
+ className: "overflow-auto",
2020
+ ref: parentRef,
2021
+ style: {
2022
+ height
2023
+ },
2024
+ onScroll,
2025
+ children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
2026
+ "div",
2027
+ {
2028
+ style: {
2029
+ height: `${rowVirtualizer.getTotalSize()}px`,
2030
+ width: "100%",
2031
+ position: "relative"
2032
+ },
2033
+ children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
2034
+ "div",
2035
+ {
2036
+ className: "absolute left-0 top-0 w-max min-w-full",
2037
+ style: {
2038
+ transform: visibleItems?.[0]?.start ? `translateY(${visibleItems[0].start}px)` : void 0
2039
+ },
2040
+ children: rowVirtualizer.getVirtualItems().map((virtualItem) => /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
2041
+ "div",
2042
+ {
2043
+ className: dataRef.current[virtualItem.index].key === scrollToKey ? "bg-primary-100" : "",
2044
+ children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
2045
+ ControledTree,
2046
+ {
2047
+ item: dataRef.current[virtualItem.index],
2048
+ selected: selectedKey === dataRef.current[virtualItem.index].key,
2049
+ contentClassName,
2050
+ expandIcon,
2051
+ collapseIcon
2052
+ }
2053
+ )
2054
+ },
2055
+ virtualItem.key
2056
+ ))
2057
+ }
2058
+ )
2059
+ }
2060
+ )
2061
+ }
2062
+ ) : /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_jsx_runtime14.Fragment, { children: flattenData.map((item, index) => /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
2063
+ "div",
2064
+ {
2065
+ className: item.key === scrollToKey ? "bg-primary-100" : "",
2066
+ children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
2067
+ ControledTree,
2068
+ {
2069
+ item,
2070
+ selected: selectedKey === item.key,
2071
+ contentClassName,
2072
+ expandIcon,
2073
+ collapseIcon
2074
+ }
2075
+ )
2076
+ },
2077
+ item.key || index
2078
+ )) }) });
2079
+ };
2080
+ var FlatTree_default = (0, import_react19.memo)(FlatTree);
2081
+
2082
+ // src/common/text/LinkifyText.tsx
2083
+ var import_linkify_urls = require("linkify-urls");
2084
+ var import_dompurify = __toESM(require("dompurify"));
2085
+ var import_react20 = require("react");
2086
+ var import_lodash5 = require("lodash");
2087
+ var import_jsx_runtime15 = require("react/jsx-runtime");
2088
+ if (import_dompurify.default?.addHook) {
2089
+ import_dompurify.default.addHook("afterSanitizeAttributes", function(node) {
2090
+ if ("target" in node) {
2091
+ node.setAttribute("target", "_blank");
2092
+ }
2093
+ if (!node.hasAttribute("target") && (node.hasAttribute("xlink:href") || node.hasAttribute("href"))) {
2094
+ node.setAttribute("xlink:show", "new");
2095
+ }
2096
+ });
2097
+ }
2098
+ var renderTextWithColoredNumbers = (text) => {
2099
+ const numberRegex = /\b(\d+(?:\.\d+)?)\b/g;
2100
+ return text.replace(numberRegex, (match, number, offset2) => {
2101
+ const before = text.charAt(offset2 - 1);
2102
+ const after = text.charAt(offset2 + match.length);
2103
+ if (before === "x" || /[a-fA-F]/.test(before) || /[a-fA-F]/.test(after)) {
2104
+ return match;
2105
+ }
2106
+ return `<span class="font-mono text-primary-500 dark:text-primary-700">${match}</span>`;
2107
+ });
2108
+ };
2109
+ var LinkifyText = (0, import_react20.memo)(function LinkifyText2({
2110
+ text,
2111
+ className,
2112
+ isHighlightNumbers
2113
+ }) {
2114
+ if ((0, import_lodash5.isUndefined)(text) || (0, import_lodash5.isNull)(text)) {
2115
+ return null;
2116
+ }
2117
+ if (!(0, import_lodash5.isString)(text)) {
2118
+ if (text.toString) {
2119
+ return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("span", { className, children: text.toString() });
2120
+ }
2121
+ return null;
2122
+ }
2123
+ const linkStr = (0, import_linkify_urls.linkifyUrlsToHtml)(
2124
+ isHighlightNumbers ? renderTextWithColoredNumbers(text) : text,
2125
+ {
2126
+ attributes: {
2127
+ class: "text-primary hover:underline",
2128
+ target: "_blank",
2129
+ rel: "noopener noreferrer"
2130
+ }
2131
+ }
2132
+ );
2133
+ return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
2134
+ "span",
2135
+ {
2136
+ className,
2137
+ dangerouslySetInnerHTML: { __html: import_dompurify.default.sanitize(linkStr) }
2138
+ }
2139
+ );
2140
+ });
2141
+
2142
+ // src/common/Empty.tsx
2143
+ var import_react22 = require("react");
2144
+
2145
+ // src/utils/extension-context.ts
2146
+ var import_react21 = require("react");
2147
+ var SvgFolderContext = (0, import_react21.createContext)("");
2148
+ var useDetectExtenstion = () => {
2149
+ const folderPath = (0, import_react21.useContext)(SvgFolderContext);
2150
+ return Boolean(folderPath);
2151
+ };
2152
+ var DarkModeContext = (0, import_react21.createContext)(false);
2153
+ var useDarkMode = () => {
2154
+ return (0, import_react21.useContext)(DarkModeContext);
2155
+ };
2156
+
2157
+ // src/common/Empty.tsx
2158
+ var import_jsx_runtime16 = require("react/jsx-runtime");
2159
+ var Empty = (props) => {
2160
+ const parentFolder = (0, import_react22.useContext)(SvgFolderContext);
2161
+ return /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("div", { className: "mx-auto w-fit", children: [
2162
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
2163
+ "img",
2164
+ {
2165
+ src: props.src ?? `${parentFolder}/empty.svg`,
2166
+ width: 88,
2167
+ height: 88,
2168
+ alt: "empty icon",
2169
+ className: "mx-auto"
2170
+ }
2171
+ ),
2172
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("span", { className: "text-ilabel text-gray", children: props.title || "No results found" })
2173
+ ] });
2174
+ };
2175
+
2176
+ // src/common/badge/StatusBadge.tsx
2177
+ var import_class_variance_authority15 = require("class-variance-authority");
2178
+ var import_jsx_runtime17 = require("react/jsx-runtime");
2179
+ var StatusRole = /* @__PURE__ */ ((StatusRole2) => {
2180
+ StatusRole2["Success"] = "success";
2181
+ StatusRole2["Warning"] = "warning";
2182
+ StatusRole2["Error"] = "error";
2183
+ StatusRole2["Disabled"] = "disabled";
2184
+ StatusRole2["Info"] = "info";
2185
+ return StatusRole2;
2186
+ })(StatusRole || {});
2187
+ var VersionStateColors = {
2188
+ ["success" /* Success */]: "bg-cyan-600/10 text-cyan-600",
2189
+ ["warning" /* Warning */]: "bg-orange-600/10 text-orange-600",
2190
+ ["error" /* Error */]: "bg-red-600/10 text-red-600",
2191
+ ["disabled" /* Disabled */]: "bg-gray-600/10 text-gray-600",
2192
+ ["info" /* Info */]: "bg-gray-300/10 text-gray-300"
2193
+ };
2194
+ function StatusBadge({
2195
+ status,
2196
+ className,
2197
+ colorClasses: _colorClasses,
2198
+ roundClasses,
2199
+ bubble,
2200
+ role
2201
+ }) {
2202
+ const colorClasses = _colorClasses || VersionStateColors[role || "info" /* Info */];
2203
+ return /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(
2204
+ "span",
2205
+ {
2206
+ className: (0, import_class_variance_authority15.cx)(
2207
+ "text-ilabel inline-flex cursor-default items-center px-2 py-0.5 font-medium",
2208
+ colorClasses,
2209
+ roundClasses ? roundClasses : "rounded-full",
2210
+ className
2211
+ ),
2212
+ "data-test-status": status,
2213
+ children: [
2214
+ bubble && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("div", { className: "mr-1.5 h-1.5 w-1.5 rounded-full bg-current" }),
2215
+ status
2216
+ ]
2217
+ }
2218
+ );
2219
+ }
2220
+
2221
+ // src/common/HeaderToolsDropdown.tsx
2222
+ var import_lu3 = require("react-icons/lu");
2223
+ var import_class_variance_authority16 = require("class-variance-authority");
2224
+ var import_jsx_runtime18 = require("react/jsx-runtime");
2225
+ var HeaderToolsToggleButton = ({
2226
+ isOpen,
2227
+ onClick,
2228
+ className
2229
+ }) => {
2230
+ return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
2231
+ "button",
2232
+ {
2233
+ onClick,
2234
+ className: (0, import_class_variance_authority16.cx)(
2235
+ "flex items-center justify-center rounded-md p-1 transition-colors",
2236
+ "dark:hover:bg-sentio-gray-100 hover:bg-gray-200",
2237
+ "text-text-foreground",
2238
+ className
2239
+ ),
2240
+ "aria-label": "Toggle tools",
2241
+ children: isOpen ? /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(import_lu3.LuChevronUp, { className: "h-4 w-4 transition-transform" }) : /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(import_lu3.LuChevronDown, { className: "h-4 w-4 transition-transform" })
2242
+ }
2243
+ );
2244
+ };
2245
+ var HeaderToolsContent = ({
2246
+ isOpen,
2247
+ children,
2248
+ className
2249
+ }) => {
2250
+ if (!isOpen) {
2251
+ return null;
2252
+ }
2253
+ return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("div", { className: (0, import_class_variance_authority16.cx)("w-full overflow-hidden", className), children });
2254
+ };
2255
+
2256
+ // src/common/table/ResizeTable.tsx
2257
+ var import_react30 = require("react");
2258
+ var import_react_table = require("@tanstack/react-table");
2259
+ var import_react_virtual2 = require("@tanstack/react-virtual");
2260
+ var import_hi2 = require("react-icons/hi");
2261
+ var import_lodash6 = require("lodash");
2262
+
2263
+ // src/common/menu/PopupMenuButton.tsx
2264
+ var import_react27 = require("react");
2265
+ var import_react28 = require("@headlessui/react");
2266
+ var import_react29 = require("@floating-ui/react");
2267
+
2268
+ // src/common/menu/SubMenu.tsx
2269
+ var import_react23 = require("react");
2270
+ var import_react24 = require("@floating-ui/react");
2271
+ var import_react25 = require("@headlessui/react");
2272
+ var import_hi = require("react-icons/hi");
2273
+ var import_solid4 = require("@heroicons/react/20/solid");
2274
+ var import_jsx_runtime19 = require("react/jsx-runtime");
2275
+ var COLOR_MAP = {
2276
+ default: {
2277
+ active: "bg-gray-100 text-text-foreground dark:bg-primary-600 dark:text-white",
2278
+ default: "text-text-foreground",
2279
+ disabled: "text-gray-400 cursor-not-allowed"
2280
+ },
2281
+ danger: {
2282
+ active: "bg-red-100 text-red-600 dark:bg-red-600 dark:text-white",
2283
+ default: "text-red-600",
2284
+ disabled: "text-red-200 dark:text-red-600/40 cursor-not-allowed"
2285
+ }
2286
+ };
2287
+ var MenuContext = (0, import_react23.createContext)({});
2288
+ var MenuItem = ({ item, onSelect, labelClassName }) => {
2289
+ const { selectedKey } = (0, import_react23.useContext)(MenuContext);
2290
+ return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_react25.Menu.Item, { disabled: item.disabled, children: ({ active }) => {
2291
+ if (item.items) {
2292
+ return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
2293
+ SubMenuButton,
2294
+ {
2295
+ items: item.items,
2296
+ icon: item.icon,
2297
+ name: item.key,
2298
+ label: item.label,
2299
+ onSelect,
2300
+ active
2301
+ },
2302
+ item.key
2303
+ );
2304
+ }
2305
+ const buttonNode = /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(
2306
+ "button",
2307
+ {
2308
+ onClick: (e) => onSelect?.(item.key, e, item),
2309
+ className: (0, import_class_variance_authority10.cx)(
2310
+ item.disabled ? COLOR_MAP[item.status || "default"].disabled : active ? COLOR_MAP[item.status || "default"].active : COLOR_MAP[item.status || "default"].default,
2311
+ "text-ilabel font-ilabel flex w-full items-center px-4 py-1.5 transition-colors duration-200"
2312
+ ),
2313
+ disabled: item.disabled,
2314
+ children: [
2315
+ item.icon,
2316
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
2317
+ "span",
2318
+ {
2319
+ className: (0, import_class_variance_authority10.cx)(
2320
+ "flex-1 truncate text-left",
2321
+ labelClassName
2322
+ ),
2323
+ children: item.label
2324
+ }
2325
+ ),
2326
+ item.key === selectedKey ? /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_hi.HiCheck, { className: "icon-lg ml-2" }) : null
2327
+ ]
2328
+ }
2329
+ );
2330
+ if (item.disabled && item.disabledHint) {
2331
+ return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
2332
+ PopoverTooltip,
2333
+ {
2334
+ text: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("span", { className: "text-icontent font-icontent text-gray cursor-auto", children: item.disabledHint }),
2335
+ strategy: "fixed",
2336
+ children: buttonNode
2337
+ }
2338
+ );
2339
+ }
2340
+ return buttonNode;
2341
+ } });
2342
+ };
2343
+ var SubMenuButton = (props) => {
2344
+ const {
2345
+ label,
2346
+ status,
2347
+ items,
2348
+ disabled,
2349
+ onSelect,
2350
+ active,
2351
+ placement = "right-start",
2352
+ buttonClass: buttonClass3
2353
+ } = props;
2354
+ const [open, setOpen] = (0, import_react23.useState)(false);
2355
+ const { refs, floatingStyles, context } = (0, import_react24.useFloating)({
2356
+ open,
2357
+ onOpenChange: setOpen,
2358
+ placement,
2359
+ whileElementsMounted: import_react24.autoUpdate,
2360
+ middleware: [(0, import_react24.flip)(), (0, import_react24.shift)()]
2361
+ });
2362
+ const { getReferenceProps, getFloatingProps } = (0, import_react24.useInteractions)([
2363
+ (0, import_react24.useHover)(context, {
2364
+ handleClose: (0, import_react24.safePolygon)()
2365
+ })
2366
+ ]);
2367
+ return /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(
2368
+ import_react25.Menu,
2369
+ {
2370
+ as: "div",
2371
+ className: (0, import_class_variance_authority10.cx)(
2372
+ "group flex items-center",
2373
+ "text-ilabel rounded-md",
2374
+ disabled ? "pointer-events-none cursor-not-allowed text-gray-400" : "cursor-pointer"
2375
+ ),
2376
+ children: [
2377
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(
2378
+ import_react25.Menu.Button,
2379
+ {
2380
+ className: (0, import_class_variance_authority10.cx)(
2381
+ active || open ? COLOR_MAP[status || "default"].active : COLOR_MAP[status || "default"].default,
2382
+ "text-ilabel font-ilabel flex w-full items-center px-4 py-1.5",
2383
+ buttonClass3
2384
+ ),
2385
+ ref: refs.setReference,
2386
+ onClick: (e) => {
2387
+ e.preventDefault();
2388
+ onSelect && onSelect(props.name, e);
2389
+ },
2390
+ ...getReferenceProps,
2391
+ children: [
2392
+ props.icon,
2393
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("span", { className: "flex-shrink flex-grow text-left", children: label }),
2394
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
2395
+ import_solid4.ChevronRightIcon,
2396
+ {
2397
+ className: (0, import_class_variance_authority10.cx)(
2398
+ open ? "text-gray-500" : "text-gray-400",
2399
+ "h-4.5 w-4.5 flex-shrink-0 group-hover:text-gray-500",
2400
+ placement?.startsWith("bottom") ? "rotate-90" : ""
2401
+ ),
2402
+ "aria-label": "expand items"
2403
+ }
2404
+ )
2405
+ ]
2406
+ }
2407
+ ),
2408
+ open && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
2409
+ import_react25.Menu.Items,
2410
+ {
2411
+ static: true,
2412
+ ref: refs.setFloating,
2413
+ style: floatingStyles,
2414
+ className: "dark:bg-sentio-gray-100 dark:divide-sentio-gray-400/50 w-48 origin-top cursor-pointer divide-y divide-gray-200 rounded-md bg-white shadow-lg ring-1 ring-black ring-opacity-5 focus:outline-none dark:ring-gray-100",
2415
+ ...getFloatingProps,
2416
+ children: items.map(
2417
+ (items2, i) => items2 && items2.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
2418
+ "div",
2419
+ {
2420
+ className: "overflow-auto py-1",
2421
+ style: { maxHeight: "60vh" },
2422
+ children: items2.map((item) => /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(MenuItem, { item, onSelect }, item.key))
2423
+ },
2424
+ i
2425
+ ) : null
2426
+ )
2427
+ }
2428
+ )
2429
+ ]
2430
+ }
2431
+ );
2432
+ };
2433
+
2434
+ // src/utils/nav-size-context.ts
2435
+ var import_react26 = require("react");
2436
+ var NavSizeContext = (0, import_react26.createContext)({
2437
+ small: true,
2438
+ showLabel: true,
2439
+ setSmall: (small) => {
2440
+ },
2441
+ setShowLabel: (showLabel) => {
2442
+ }
2443
+ });
2444
+
2445
+ // src/common/menu/PopupMenuButton.tsx
2446
+ var import_jsx_runtime20 = require("react/jsx-runtime");
2447
+ function PopupMenuButton({
2448
+ buttonIcon,
2449
+ items,
2450
+ groupLabels,
2451
+ onSelect,
2452
+ ariaLabel,
2453
+ header,
2454
+ footer,
2455
+ buttonClassName,
2456
+ itemsClassName = "",
2457
+ itemLabelClassName,
2458
+ renderItem,
2459
+ placement = "bottom-start",
2460
+ offset: offset2 = 0,
2461
+ portal = true,
2462
+ width,
2463
+ selectedKey,
2464
+ onOpenCallback
2465
+ }) {
2466
+ const [menuOpen, setMenuOpen] = (0, import_react27.useState)(false);
2467
+ const { small } = (0, import_react27.useContext)(NavSizeContext);
2468
+ const { refs, floatingStyles, context } = (0, import_react29.useFloating)({
2469
+ open: menuOpen,
2470
+ onOpenChange: setMenuOpen,
2471
+ middleware: [(0, import_react29.offset)(offset2), (0, import_react29.flip)(), (0, import_react29.shift)()],
2472
+ placement,
2473
+ whileElementsMounted: import_react29.autoUpdate
2474
+ });
2475
+ const itemStyle = (0, import_react27.useMemo)(() => {
2476
+ return {
2477
+ width
2478
+ };
2479
+ }, [width]);
2480
+ const onOpenCallbackRef = (0, import_react27.useRef)(onOpenCallback);
2481
+ onOpenCallbackRef.current = onOpenCallback;
2482
+ (0, import_react27.useEffect)(() => {
2483
+ if (menuOpen) {
2484
+ onOpenCallbackRef.current?.();
2485
+ }
2486
+ }, [menuOpen]);
2487
+ let menuItems = null;
2488
+ if (menuOpen && items.length > 0) {
2489
+ menuItems = /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(MenuContext.Provider, { value: { selectedKey }, children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("div", { ref: refs.setFloating, style: floatingStyles, children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
2490
+ import_react28.Transition,
2491
+ {
2492
+ as: import_react27.Fragment,
2493
+ enter: "transition ease-out duration-100",
2494
+ enterFrom: "transform opacity-0 scale-95",
2495
+ enterTo: "transform opacity-100 scale-100",
2496
+ leave: "transition ease-in duration-75",
2497
+ leaveFrom: "transform opacity-100 scale-100",
2498
+ leaveTo: "transform opacity-0 scale-95",
2499
+ children: /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)(
2500
+ import_react28.Menu.Items,
2501
+ {
2502
+ className: "dark:bg-sentio-gray-200 dark:divide-sentio-gray-400/50 z-10 mt-1 w-[80vw] origin-top cursor-pointer divide-y divide-gray-200 rounded-md bg-white shadow-lg ring-1 ring-black ring-opacity-5 focus:outline-none dark:ring-gray-100 sm:w-64",
2503
+ style: itemStyle,
2504
+ children: [
2505
+ header,
2506
+ /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("div", { className: `${itemsClassName} divide-y`, children: items.map((items2, i) => /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("div", { className: "py-1", children: [
2507
+ groupLabels?.[i] ? /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("div", { className: "px-4 py-0.5 text-[10px] font-medium leading-[12px] text-gray-500", children: groupLabels[i] }) : null,
2508
+ items2.map(
2509
+ (item) => renderItem ? renderItem(item) : /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
2510
+ MenuItem,
2511
+ {
2512
+ item,
2513
+ onSelect,
2514
+ labelClassName: itemLabelClassName
2515
+ },
2516
+ item.key
2517
+ )
2518
+ )
2519
+ ] }, i)) }),
2520
+ footer
2521
+ ]
2522
+ }
2523
+ )
2524
+ }
2525
+ ) }) });
2526
+ }
2527
+ return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(import_react28.Menu, { children: ({ open }) => {
2528
+ setTimeout(() => {
2529
+ setMenuOpen(open);
2530
+ }, 0);
2531
+ return /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)(import_jsx_runtime20.Fragment, { children: [
2532
+ /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
2533
+ import_react28.Menu.Button,
2534
+ {
2535
+ className: (0, import_class_variance_authority10.cx)(
2536
+ "text-gray w-fit px-1 hover:text-gray-500 active:text-gray-700",
2537
+ buttonClassName
2538
+ ),
2539
+ "aria-label": ariaLabel,
2540
+ ref: refs.setReference,
2541
+ as: buttonIcon ? "div" : void 0,
2542
+ children: typeof buttonIcon === "function" ? buttonIcon(menuOpen) : buttonIcon
2543
+ }
2544
+ ),
2545
+ portal ? /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(import_react29.FloatingPortal, { children: menuItems }) : menuItems
2546
+ ] });
2547
+ } });
2548
+ }
2549
+
2550
+ // src/common/table/Icons.tsx
2551
+ var import_jsx_runtime21 = require("react/jsx-runtime");
2552
+ var MoveLeftIcon = (props) => /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(
2553
+ "svg",
2554
+ {
2555
+ width: "16",
2556
+ height: "16",
2557
+ viewBox: "0 0 16 16",
2558
+ fill: "none",
2559
+ xmlns: "http://www.w3.org/2000/svg",
2560
+ ...props,
2561
+ children: [
2562
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("g", { clipPath: "url(#clip0_6869_7300)", children: [
2563
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
2564
+ "path",
2565
+ {
2566
+ d: "M2.66666 8H9.33332",
2567
+ stroke: "currentColor",
2568
+ strokeWidth: "1.33333",
2569
+ strokeLinecap: "round",
2570
+ strokeLinejoin: "round"
2571
+ }
2572
+ ),
2573
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
2574
+ "path",
2575
+ {
2576
+ d: "M2.66666 8L5.33332 10.6667",
2577
+ stroke: "currentColor",
2578
+ strokeWidth: "1.33333",
2579
+ strokeLinecap: "round",
2580
+ strokeLinejoin: "round"
2581
+ }
2582
+ ),
2583
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
2584
+ "path",
2585
+ {
2586
+ d: "M2.66669 7.9987L5.33335 5.33203",
2587
+ stroke: "currentColor",
2588
+ strokeWidth: "1.33333",
2589
+ strokeLinecap: "round",
2590
+ strokeLinejoin: "round"
2591
+ }
2592
+ ),
2593
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
2594
+ "path",
2595
+ {
2596
+ d: "M13.3333 2.66797V13.3346",
2597
+ stroke: "currentColor",
2598
+ strokeWidth: "1.33333",
2599
+ strokeLinecap: "round",
2600
+ strokeLinejoin: "round"
2601
+ }
2602
+ )
2603
+ ] }),
2604
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("defs", { children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("clipPath", { id: "clip0_6869_7300", children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("rect", { width: "16", height: "16", fill: "white" }) }) })
2605
+ ]
2606
+ }
2607
+ );
2608
+ var MoveRightIcon = (props) => /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(
2609
+ "svg",
2610
+ {
2611
+ width: "16",
2612
+ height: "16",
2613
+ viewBox: "0 0 16 16",
2614
+ fill: "none",
2615
+ xmlns: "http://www.w3.org/2000/svg",
2616
+ ...props,
2617
+ children: [
2618
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("g", { clipPath: "url(#clip0_6869_7309)", children: [
2619
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
2620
+ "path",
2621
+ {
2622
+ d: "M13.3333 8H6.66666",
2623
+ stroke: "currentColor",
2624
+ strokeWidth: "1.33333",
2625
+ strokeLinecap: "round",
2626
+ strokeLinejoin: "round"
2627
+ }
2628
+ ),
2629
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
2630
+ "path",
2631
+ {
2632
+ d: "M13.3333 8L10.6667 10.6667",
2633
+ stroke: "currentColor",
2634
+ strokeWidth: "1.33333",
2635
+ strokeLinecap: "round",
2636
+ strokeLinejoin: "round"
2637
+ }
2638
+ ),
2639
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
2640
+ "path",
2641
+ {
2642
+ d: "M13.3334 7.9987L10.6667 5.33203",
2643
+ stroke: "currentColor",
2644
+ strokeWidth: "1.33333",
2645
+ strokeLinecap: "round",
2646
+ strokeLinejoin: "round"
2647
+ }
2648
+ ),
2649
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
2650
+ "path",
2651
+ {
2652
+ d: "M2.66669 2.66797V13.3346",
2653
+ stroke: "currentColor",
2654
+ strokeWidth: "1.33333",
2655
+ strokeLinecap: "round",
2656
+ strokeLinejoin: "round"
2657
+ }
2658
+ )
2659
+ ] }),
2660
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("defs", { children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("clipPath", { id: "clip0_6869_7309", children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("rect", { width: "16", height: "16", fill: "white" }) }) })
2661
+ ]
2662
+ }
2663
+ );
2664
+ var RenameIcon = (props) => /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(
2665
+ "svg",
2666
+ {
2667
+ width: "16",
2668
+ height: "16",
2669
+ viewBox: "0 0 16 16",
2670
+ fill: "none",
2671
+ xmlns: "http://www.w3.org/2000/svg",
2672
+ ...props,
2673
+ children: [
2674
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
2675
+ "path",
2676
+ {
2677
+ d: "M8 13.3281H14",
2678
+ stroke: "currentColor",
2679
+ strokeWidth: "1.33333",
2680
+ strokeLinecap: "round",
2681
+ strokeLinejoin: "round"
2682
+ }
2683
+ ),
2684
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
2685
+ "path",
2686
+ {
2687
+ d: "M11 2.33609C11.2652 2.07087 11.6249 1.92188 12 1.92188C12.1857 1.92188 12.3696 1.95845 12.5412 2.02953C12.7128 2.1006 12.8687 2.20477 13 2.33609C13.1313 2.46741 13.2355 2.62331 13.3066 2.79489C13.3776 2.96647 13.4142 3.15037 13.4142 3.33609C13.4142 3.52181 13.3776 3.7057 13.3066 3.87728C13.2355 4.04886 13.1313 4.20477 13 4.33609L4.66667 12.6694L2 13.3361L2.66667 10.6694L11 2.33609Z",
2688
+ stroke: "currentColor",
2689
+ strokeWidth: "1.33333",
2690
+ strokeLinecap: "round",
2691
+ strokeLinejoin: "round"
2692
+ }
2693
+ )
2694
+ ]
2695
+ }
2696
+ );
2697
+ var DeleteIcon = (props) => /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(
2698
+ "svg",
2699
+ {
2700
+ width: "16",
2701
+ height: "16",
2702
+ viewBox: "0 0 16 16",
2703
+ fill: "none",
2704
+ xmlns: "http://www.w3.org/2000/svg",
2705
+ ...props,
2706
+ children: [
2707
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("g", { clipPath: "url(#clip0_6869_7344)", children: [
2708
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
2709
+ "path",
2710
+ {
2711
+ d: "M2.66669 4.66797H13.3334",
2712
+ stroke: "currentColor",
2713
+ strokeWidth: "1.02222",
2714
+ strokeLinecap: "round",
2715
+ strokeLinejoin: "round"
2716
+ }
2717
+ ),
2718
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
2719
+ "path",
2720
+ {
2721
+ d: "M6.66669 7.33203V11.332",
2722
+ stroke: "currentColor",
2723
+ strokeWidth: "1.02222",
2724
+ strokeLinecap: "round",
2725
+ strokeLinejoin: "round"
2726
+ }
2727
+ ),
2728
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
2729
+ "path",
2730
+ {
2731
+ d: "M9.33331 7.33203V11.332",
2732
+ stroke: "currentColor",
2733
+ strokeWidth: "1.02222",
2734
+ strokeLinecap: "round",
2735
+ strokeLinejoin: "round"
2736
+ }
2737
+ ),
2738
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
2739
+ "path",
2740
+ {
2741
+ d: "M3.33331 4.66797L3.99998 12.668C3.99998 13.0216 4.14046 13.3607 4.3905 13.6108C4.64055 13.8608 4.97969 14.0013 5.33331 14.0013H10.6666C11.0203 14.0013 11.3594 13.8608 11.6095 13.6108C11.8595 13.3607 12 13.0216 12 12.668L12.6666 4.66797",
2742
+ stroke: "currentColor",
2743
+ strokeWidth: "1.02222",
2744
+ strokeLinecap: "round",
2745
+ strokeLinejoin: "round"
2746
+ }
2747
+ ),
2748
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
2749
+ "path",
2750
+ {
2751
+ d: "M6 4.66667V2.66667C6 2.48986 6.07024 2.32029 6.19526 2.19526C6.32029 2.07024 6.48986 2 6.66667 2H9.33333C9.51014 2 9.67971 2.07024 9.80474 2.19526C9.92976 2.32029 10 2.48986 10 2.66667V4.66667",
2752
+ stroke: "currentColor",
2753
+ strokeWidth: "1.02222",
2754
+ strokeLinecap: "round",
2755
+ strokeLinejoin: "round"
2756
+ }
2757
+ )
2758
+ ] }),
2759
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("defs", { children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("clipPath", { id: "clip0_6869_7344", children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("rect", { width: "16", height: "16", fill: "white" }) }) })
2760
+ ]
2761
+ }
2762
+ );
2763
+
2764
+ // src/common/table/ResizeTable.tsx
2765
+ var import_io5 = require("react-icons/io5");
2766
+ var import_jsx_runtime22 = require("react/jsx-runtime");
2767
+ var reorder = (list, startIndex, endIndex) => {
2768
+ const result = Array.from(list);
2769
+ const [removed] = result.splice(startIndex, 1);
2770
+ result.splice(endIndex, 0, removed);
2771
+ return result;
2772
+ };
2773
+ function onPreventClick(e) {
2774
+ e.stopPropagation();
2775
+ }
2776
+ var _ResizeTable = (0, import_react30.forwardRef)(function _ResizeTable2({
2777
+ data,
2778
+ columns,
2779
+ columnResizeMode,
2780
+ onClick,
2781
+ height,
2782
+ onFetchMore,
2783
+ hasMore,
2784
+ isFetching,
2785
+ allowSort,
2786
+ allowEditColumn,
2787
+ allowResizeColumn,
2788
+ state = {},
2789
+ onStateChange,
2790
+ onColumnRemove,
2791
+ onColumnRename,
2792
+ minSize,
2793
+ manualSorting,
2794
+ minWidth,
2795
+ rowClassNameFn,
2796
+ enableVirtualization = false,
2797
+ estimatedRowHeight = 35,
2798
+ overscan = 5
2799
+ }, tableContainerRef) {
2800
+ const adjustedColumns = (0, import_react30.useMemo)(() => {
2801
+ let totalWidth = 0;
2802
+ const newColumns = columns.map((c) => {
2803
+ const item = Object.assign({ minSize }, c);
2804
+ totalWidth += item.size || item.minSize || 0;
2805
+ return item;
2806
+ });
2807
+ if (minWidth && totalWidth < minWidth) {
2808
+ const ratio = minWidth / totalWidth;
2809
+ newColumns.forEach((c) => {
2810
+ if (c.size) {
2811
+ c.size = Math.floor(c.size * ratio);
2812
+ } else if (c.minSize) {
2813
+ c.size = Math.floor(c.minSize * ratio);
2814
+ }
2815
+ });
2816
+ }
2817
+ return newColumns;
2818
+ }, [columns, minSize, minWidth]);
2819
+ const [tableState, setTableState] = (0, import_react30.useState)(() => {
2820
+ const initialState = {
2821
+ pagination: {
2822
+ pageIndex: 0,
2823
+ pageSize: 10
2824
+ },
2825
+ ...state
2826
+ };
2827
+ return initialState;
2828
+ });
2829
+ const table = (0, import_react_table.useReactTable)({
2830
+ data,
2831
+ columns: adjustedColumns,
2832
+ columnResizeMode,
2833
+ getCoreRowModel: (0, import_react_table.getCoreRowModel)(),
2834
+ getSortedRowModel: allowSort ? (0, import_react_table.getSortedRowModel)() : void 0,
2835
+ state: tableState,
2836
+ onStateChange: setTableState,
2837
+ manualSorting
2838
+ });
2839
+ (0, import_react30.useEffect)(() => {
2840
+ if (state && Object.keys(state).length > 0) {
2841
+ setTableState((prev) => {
2842
+ const newState = {
2843
+ ...prev,
2844
+ ...state,
2845
+ pagination: prev.pagination || state.pagination || { pageIndex: 0, pageSize: 10 }
2846
+ };
2847
+ return (0, import_lodash6.isEqual)(prev, newState) ? prev : newState;
2848
+ });
2849
+ }
2850
+ }, [state]);
2851
+ const debounceStateChange = (0, import_react30.useMemo)(() => {
2852
+ if (!onStateChange) return void 0;
2853
+ return (0, import_lodash6.debounce)(onStateChange, 500, {});
2854
+ }, [onStateChange]);
2855
+ (0, import_react30.useEffect)(() => {
2856
+ debounceStateChange?.(tableState);
2857
+ }, [debounceStateChange, tableState]);
2858
+ const fetchMoreOnBottomReached = (0, import_react30.useMemo)(() => {
2859
+ return (0, import_lodash6.debounce)((containerRefElement) => {
2860
+ if (containerRefElement) {
2861
+ const { scrollHeight, scrollTop, clientHeight } = containerRefElement;
2862
+ if (scrollHeight - scrollTop - clientHeight < 300 && !isFetching && hasMore) {
2863
+ onFetchMore?.();
2864
+ }
2865
+ }
2866
+ }, 500);
2867
+ }, [onFetchMore, isFetching, hasMore]);
2868
+ const tableContainerElementRef = (0, import_react30.useRef)(null);
2869
+ (0, import_react30.useEffect)(() => {
2870
+ if (tableContainerRef) {
2871
+ if (typeof tableContainerRef === "function") {
2872
+ tableContainerRef(tableContainerElementRef.current);
2873
+ } else {
2874
+ tableContainerRef.current = tableContainerElementRef.current;
2875
+ }
2876
+ }
2877
+ }, [tableContainerRef]);
2878
+ const rowVirtualizer = (0, import_react_virtual2.useVirtualizer)({
2879
+ count: enableVirtualization ? table.getRowModel().rows.length : 0,
2880
+ getScrollElement: () => tableContainerElementRef.current,
2881
+ estimateSize: (0, import_react30.useCallback)(() => estimatedRowHeight, [estimatedRowHeight]),
2882
+ overscan,
2883
+ enabled: enableVirtualization
2884
+ });
2885
+ const virtualRows = enableVirtualization ? rowVirtualizer.getVirtualItems() : [];
2886
+ const paddingTop = enableVirtualization && virtualRows.length > 0 ? virtualRows[0].start : 0;
2887
+ const paddingBottom = enableVirtualization && virtualRows.length > 0 ? rowVirtualizer.getTotalSize() - (virtualRows[virtualRows.length - 1].start + virtualRows[virtualRows.length - 1].size) : 0;
2888
+ return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
2889
+ "div",
2890
+ {
2891
+ className: "overflow-auto",
2892
+ style: height ? { height } : void 0,
2893
+ ref: tableContainerElementRef,
2894
+ onScroll: (e) => fetchMoreOnBottomReached(e.target),
2895
+ children: /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)(
2896
+ "table",
2897
+ {
2898
+ className: "w-fit",
2899
+ ...{
2900
+ style: {
2901
+ width: table.getCenterTotalSize()
2902
+ }
2903
+ },
2904
+ children: [
2905
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("thead", { className: "dark:bg-sentio-gray-100 sticky top-0 z-[1] bg-white", children: table.getHeaderGroups().map((headerGroup) => /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
2906
+ "tr",
2907
+ {
2908
+ className: "relative flex w-fit cursor-pointer items-center border-b",
2909
+ children: headerGroup.headers.map((header, i) => /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)(
2910
+ "th",
2911
+ {
2912
+ colSpan: header.colSpan,
2913
+ style: {
2914
+ width: header.getSize()
2915
+ },
2916
+ className: "text-ilabel group/th blinked dark:hover:!bg-sentio-gray-300 dark:bg-sentio-gray-100 text-text-foreground hover:!bg-primary-50 relative flex items-center whitespace-nowrap bg-white px-2 py-2 text-left font-semibold",
2917
+ onClick: header.column.getToggleSortingHandler(),
2918
+ children: [
2919
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("span", { className: "flex w-full flex-1 overflow-hidden", children: [
2920
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("span", { className: "flex-1 truncate", children: header.isPlaceholder ? null : (0, import_react_table.flexRender)(
2921
+ header.column.columnDef.header,
2922
+ header.getContext()
2923
+ ) }),
2924
+ header.column.getCanSort() && allowSort ? /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
2925
+ "span",
2926
+ {
2927
+ className: (0, import_class_variance_authority10.cx)(
2928
+ header.column.getIsSorted() ? "hover:text-text-foreground visible hover:bg-gray-200" : "invisible",
2929
+ "ml-2 flex-none rounded px-1 py-0.5 text-gray-600 group-hover:visible group-focus:visible",
2930
+ "inline-block cursor-pointer",
2931
+ "shrink-0"
2932
+ ),
2933
+ children: header.column.getIsSorted() ? header.column.getIsSorted() == "desc" ? /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(import_hi2.HiOutlineSortDescending, { className: "h-4 w-4" }) : /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(import_hi2.HiOutlineSortAscending, { className: "h-4 w-4" }) : ""
2934
+ }
2935
+ ) : null
2936
+ ] }),
2937
+ allowEditColumn !== false && /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
2938
+ "span",
2939
+ {
2940
+ className: "invisible inline-block group-hover/th:visible",
2941
+ onClick: onPreventClick,
2942
+ children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
2943
+ PopupMenuButton,
2944
+ {
2945
+ buttonClassName: "align-text-bottom",
2946
+ onSelect: (commandKey) => {
2947
+ const colOrder = headerGroup.headers.map(
2948
+ (item) => item?.id
2949
+ );
2950
+ switch (commandKey) {
2951
+ case "reorder.left":
2952
+ table.setColumnOrder(
2953
+ reorder(colOrder, i, i - 1)
2954
+ );
2955
+ break;
2956
+ case "reorder.right":
2957
+ table.setColumnOrder(
2958
+ reorder(colOrder, i, i + 1)
2959
+ );
2960
+ break;
2961
+ case "delete":
2962
+ onColumnRemove?.(header.column.columnDef);
2963
+ break;
2964
+ default:
2965
+ console.log(commandKey, "is not applied");
2966
+ }
2967
+ },
2968
+ buttonIcon: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(import_hi2.HiChevronDown, { className: "icon mr-2" }),
2969
+ items: [
2970
+ [
2971
+ {
2972
+ key: "reorder.left",
2973
+ label: "Move column left",
2974
+ icon: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(MoveLeftIcon, { className: "mr-2" }),
2975
+ disabled: i === 0
2976
+ },
2977
+ {
2978
+ key: "reorder.right",
2979
+ label: "Move column right",
2980
+ icon: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(MoveRightIcon, { className: "mr-2" }),
2981
+ disabled: i === headerGroup.headers.length - 1
2982
+ }
2983
+ ],
2984
+ ...onColumnRename ? [
2985
+ [
2986
+ {
2987
+ key: "rename",
2988
+ label: "Rename column",
2989
+ icon: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(RenameIcon, { className: "mr-2" })
2990
+ }
2991
+ ]
2992
+ ] : [],
2993
+ ...!onColumnRemove ? [] : [
2994
+ [
2995
+ {
2996
+ key: "delete",
2997
+ label: "Remove column",
2998
+ icon: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(DeleteIcon, { className: "mr-2" }),
2999
+ status: "danger"
3000
+ }
3001
+ ]
3002
+ ]
3003
+ ]
3004
+ }
3005
+ )
3006
+ }
3007
+ ),
3008
+ header.column.getCanResize() ? /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
3009
+ "div",
3010
+ {
3011
+ onMouseDown: header.getResizeHandler(),
3012
+ onTouchStart: header.getResizeHandler(),
3013
+ className: (0, import_class_variance_authority10.cx)(
3014
+ `text-md hover:bg-primary-200/50 absolute right-0 top-0 inline-block flex
3015
+ h-full w-2 cursor-col-resize touch-none select-none items-center text-gray-400`
3016
+ ),
3017
+ style: {
3018
+ transform: columnResizeMode === "onEnd" && header.column.getIsResizing() ? `translateX(${table.getState().columnSizingInfo.deltaOffset}px)` : ""
3019
+ },
3020
+ onClick: (e) => e.stopPropagation(),
3021
+ children: "\u22EE"
3022
+ }
3023
+ ) : null
3024
+ ]
3025
+ },
3026
+ header.id
3027
+ ))
3028
+ },
3029
+ headerGroup.id
3030
+ )) }),
3031
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("tbody", { children: [
3032
+ enableVirtualization && paddingTop > 0 && /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("tr", { children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("td", { style: { height: `${paddingTop}px` } }) }),
3033
+ enableVirtualization ? virtualRows.map((virtualRow) => {
3034
+ const row = table.getRowModel().rows[virtualRow.index];
3035
+ return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
3036
+ "tr",
3037
+ {
3038
+ "data-index": virtualRow.index,
3039
+ className: (0, import_class_variance_authority10.cx)(
3040
+ "hover:!bg-primary-50 dark:hover:!bg-sentio-gray-300 group flex w-fit items-center border-b",
3041
+ onClick ? "cursor-pointer" : "",
3042
+ rowClassNameFn ? rowClassNameFn(row) : ""
3043
+ ),
3044
+ children: row.getVisibleCells().map((cell) => /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
3045
+ "td",
3046
+ {
3047
+ ...{
3048
+ style: {
3049
+ width: cell.column.getSize()
3050
+ }
3051
+ },
3052
+ onClick: () => onClick && onClick(row, cell),
3053
+ className: "text-ilabel dark:text-text-foreground-secondary truncate whitespace-nowrap py-2 pl-2 text-gray-600",
3054
+ children: (0, import_react_table.flexRender)(
3055
+ cell.column.columnDef.cell,
3056
+ cell.getContext()
3057
+ )
3058
+ },
3059
+ cell.id
3060
+ ))
3061
+ },
3062
+ row.id
3063
+ );
3064
+ }) : table.getRowModel().rows.map((row) => /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
3065
+ "tr",
3066
+ {
3067
+ className: (0, import_class_variance_authority10.cx)(
3068
+ "hover:!bg-primary-50 dark:hover:!bg-sentio-gray-300 blinked group flex w-fit items-center border-b",
3069
+ onClick ? "cursor-pointer" : "",
3070
+ rowClassNameFn ? rowClassNameFn(row) : ""
3071
+ ),
3072
+ children: row.getVisibleCells().map((cell) => /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
3073
+ "td",
3074
+ {
3075
+ ...{
3076
+ style: {
3077
+ width: cell.column.getSize()
3078
+ }
3079
+ },
3080
+ onClick: () => onClick && onClick(row, cell),
3081
+ className: "text-ilabel dark:text-text-foreground-secondary truncate whitespace-nowrap py-2 pl-2 text-gray-600",
3082
+ children: (0, import_react_table.flexRender)(
3083
+ cell.column.columnDef.cell,
3084
+ cell.getContext()
3085
+ )
3086
+ },
3087
+ cell.id
3088
+ ))
3089
+ },
3090
+ row.id
3091
+ )),
3092
+ enableVirtualization && paddingBottom > 0 && /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("tr", { children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("td", { style: { height: `${paddingBottom}px` } }) }),
3093
+ onFetchMore && /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("tr", { children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
3094
+ "td",
3095
+ {
3096
+ colSpan: table.getHeaderGroups()[0].headers.length,
3097
+ className: "text-ilabel hover:bg-primary-50 cursor-pointer py-2 text-center text-gray-600",
3098
+ onClick: () => {
3099
+ if (isFetching) return;
3100
+ onFetchMore?.();
3101
+ },
3102
+ children: isFetching || hasMore ? /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("span", { className: "inline-flex items-center gap-2", children: [
3103
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
3104
+ import_io5.IoReload,
3105
+ {
3106
+ className: (0, import_class_variance_authority10.cx)(
3107
+ "h-4 w-4",
3108
+ isFetching ? "animate-spin" : ""
3109
+ )
3110
+ }
3111
+ ),
3112
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("span", { children: "Loading..." })
3113
+ ] }) : "No more data"
3114
+ }
3115
+ ) })
3116
+ ] })
3117
+ ]
3118
+ }
3119
+ )
3120
+ }
3121
+ );
3122
+ });
3123
+ var ResizeTable = (0, import_react30.memo)(_ResizeTable);
3124
+
3125
+ // src/utils/number-format.ts
3126
+ var import_bigdecimal = __toESM(require("@sentio/bigdecimal"));
3127
+ var BD = import_bigdecimal.default.clone({
3128
+ EXPONENTIAL_AT: 1e9
3129
+ });
3130
+ function parseHex(hex = "0") {
3131
+ try {
3132
+ return BigInt(BD(hex).toString());
3133
+ } catch {
3134
+ return BigInt(0);
3135
+ }
3136
+ }
3137
+ function getNumberWithDecimal(hex, decimal, asNumber) {
3138
+ if (hex === void 0 || decimal === void 0) {
3139
+ return null;
3140
+ }
3141
+ const bigInt = typeof hex === "bigint" ? hex : parseHex(hex);
3142
+ const n = BD(bigInt.toString()).div(decimal > 0 ? BD(10).pow(decimal) : 1);
3143
+ if (asNumber) {
3144
+ return n.toNumber();
3145
+ }
3146
+ return n.toString();
3147
+ }
3148
+
3149
+ // src/utils/use-mobile.ts
3150
+ var import_react31 = require("react");
3151
+ function useMobile(breakpoint = 768, defaultValue = false) {
3152
+ const [isMobile, setIsMobile] = (0, import_react31.useState)(defaultValue);
3153
+ (0, import_react31.useEffect)(() => {
3154
+ const checkUserAgent = () => {
3155
+ if (typeof window === "undefined") return false;
3156
+ const userAgent = window.navigator.userAgent.toLowerCase();
3157
+ const mobileKeywords = [
3158
+ "android",
3159
+ "iphone",
3160
+ "ipad",
3161
+ "ipod",
3162
+ "blackberry",
3163
+ "windows phone",
3164
+ "mobile",
3165
+ "webos",
3166
+ "opera mini"
3167
+ ];
3168
+ return mobileKeywords.some((keyword) => userAgent.includes(keyword));
3169
+ };
3170
+ const checkScreenWidth = () => {
3171
+ if (typeof window === "undefined") return false;
3172
+ return window.innerWidth < breakpoint;
3173
+ };
3174
+ const checkTouchSupport = () => {
3175
+ if (typeof window === "undefined") return false;
3176
+ return "ontouchstart" in window || navigator.maxTouchPoints > 0;
3177
+ };
3178
+ const detectMobile = () => {
3179
+ const isUserAgentMobile = checkUserAgent();
3180
+ const isScreenSmall = checkScreenWidth();
3181
+ const hasTouchSupport = checkTouchSupport();
3182
+ if (isUserAgentMobile) return true;
3183
+ if (isScreenSmall && hasTouchSupport) return true;
3184
+ return isScreenSmall;
3185
+ };
3186
+ setIsMobile(detectMobile());
3187
+ const handleResize = () => {
3188
+ setIsMobile(detectMobile());
3189
+ };
3190
+ window.addEventListener("resize", handleResize);
3191
+ return () => {
3192
+ window.removeEventListener("resize", handleResize);
3193
+ };
3194
+ }, [breakpoint]);
3195
+ return isMobile;
3196
+ }
3197
+ // Annotate the CommonJS export names for ESM import in node:
3198
+ 0 && (module.exports = {
3199
+ BD,
3200
+ BarLoading,
3201
+ BaseDialog,
3202
+ Button,
3203
+ COLOR_MAP,
3204
+ CloseSquareO,
3205
+ Collapse,
3206
+ CopyButton,
3207
+ CopyIcon,
3208
+ CopySuccessIcon,
3209
+ DarkModeContext,
3210
+ DeleteIcon,
3211
+ DisclosurePanel,
3212
+ Empty,
3213
+ EyeO,
3214
+ FlatTree,
3215
+ HeaderToolsContent,
3216
+ HeaderToolsToggleButton,
3217
+ Input,
3218
+ LinkifyText,
3219
+ MenuContext,
3220
+ MenuItem,
3221
+ MinusSquareO,
3222
+ MoveLeftIcon,
3223
+ MoveRightIcon,
3224
+ NavSizeContext,
3225
+ PlusSquareO,
3226
+ PopoverTooltip,
3227
+ PopupMenuButton,
3228
+ ROOT_KEY,
3229
+ RadioSelect,
3230
+ RenameIcon,
3231
+ ResizeTable,
3232
+ SUFFIX_NODE_KEY,
3233
+ Select,
3234
+ SpinLoading,
3235
+ StatusBadge,
3236
+ StatusRole,
3237
+ SubMenuButton,
3238
+ SvgFolderContext,
3239
+ Switch,
3240
+ classNames,
3241
+ getNumberWithDecimal,
3242
+ parseHex,
3243
+ useBoolean,
3244
+ useDarkMode,
3245
+ useDetectExtenstion,
3246
+ useMobile
3247
+ });
3248
+ //# sourceMappingURL=index.js.map