@guiwzh/small-design 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,1193 @@
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
+ AutoComplete: () => autoComplete_default,
34
+ Button: () => button_default,
35
+ Icon: () => icon_default,
36
+ Input: () => input_default,
37
+ KeepAliveContext: () => KeepAliveContext,
38
+ KeepAliveLayout: () => Keepalive_default,
39
+ LazyLoad: () => lazyLoad_default,
40
+ Menu: () => Menu_default,
41
+ MenuItem: () => menuItem_default,
42
+ Progress: () => progress_default,
43
+ Signature: () => signature_default,
44
+ SubMenu: () => subMenu_default,
45
+ Transition: () => transition_default,
46
+ Upload: () => upload_default,
47
+ VirtualList: () => virtualList_default,
48
+ useClickOutside: () => useClickOutside_default,
49
+ useDebounce: () => useDebounce_default,
50
+ useKeepOutlet: () => useKeepOutlet
51
+ });
52
+ module.exports = __toCommonJS(index_exports);
53
+
54
+ // src/components/Button/button.tsx
55
+ var import_classnames = __toESM(require("classnames"));
56
+ var import_jsx_runtime = require("react/jsx-runtime");
57
+ var Button = (props) => {
58
+ const { className, disabled = false, size, btnType = "default", href, children, ...restProps } = props;
59
+ const classes = (0, import_classnames.default)("btn", className, {
60
+ [`btn-${btnType}`]: btnType,
61
+ [`btn-${size}`]: size,
62
+ "disabled": disabled
63
+ });
64
+ if (btnType === "link" && href) {
65
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("a", { className: classes, href, ...restProps, children });
66
+ } else {
67
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { className: classes, disabled, ...restProps, children });
68
+ }
69
+ };
70
+ Button.displayName = "Button";
71
+ var button_default = Button;
72
+
73
+ // src/components/Menu/menu.tsx
74
+ var import_react = __toESM(require("react"));
75
+ var import_classnames2 = __toESM(require("classnames"));
76
+ var import_jsx_runtime2 = require("react/jsx-runtime");
77
+ var MenuContext = (0, import_react.createContext)({ index: "0" });
78
+ var Menu = (props) => {
79
+ const { className, mode = "horizontal", style, children, defaultIndex = "0", onSelect, defaultOpenSubMenus = [] } = props;
80
+ const [currentActive, setActive] = (0, import_react.useState)(defaultIndex);
81
+ const handleClick = (index, e) => {
82
+ setActive(index);
83
+ if (onSelect) {
84
+ onSelect(index, e);
85
+ }
86
+ };
87
+ const passedContext = {
88
+ index: currentActive,
89
+ onSelect: handleClick,
90
+ mode,
91
+ defaultOpenSubMenus
92
+ };
93
+ const renderChildren = () => {
94
+ return import_react.Children.map(children, (child, index) => {
95
+ var _a;
96
+ const childElement = child;
97
+ if (typeof child !== "object" || child === null) {
98
+ console.error("Warning: Menu has a child which is not a MenuItem component");
99
+ return null;
100
+ }
101
+ const displayName = (_a = childElement.type) == null ? void 0 : _a.displayName;
102
+ if (displayName === "MenuItem" || displayName === "SubMenu") {
103
+ return import_react.default.cloneElement(childElement, {
104
+ index: index.toString()
105
+ });
106
+ } else {
107
+ console.error("Warning: Menu has a child which is not a MenuItem component");
108
+ }
109
+ });
110
+ };
111
+ const classes = (0, import_classnames2.default)("viking-menu", className, {
112
+ "menu-vertical": mode === "vertical",
113
+ "menu-horizontal": mode !== "vertical"
114
+ });
115
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("ul", { className: classes, style, role: "menubar", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(MenuContext.Provider, { value: passedContext, children: renderChildren() }) });
116
+ };
117
+ var menu_default = Menu;
118
+
119
+ // src/components/Menu/subMenu.tsx
120
+ var import_react2 = __toESM(require("react"));
121
+ var import_classnames4 = __toESM(require("classnames"));
122
+
123
+ // src/components/Icon/icon.tsx
124
+ var import_classnames3 = __toESM(require("classnames"));
125
+ var import_react_fontawesome = require("@fortawesome/react-fontawesome");
126
+ var import_jsx_runtime3 = require("react/jsx-runtime");
127
+ var Icon = (props) => {
128
+ const { className, theme, ...restProps } = props;
129
+ const classes = (0, import_classnames3.default)("viking-icon", className, {
130
+ [`icon-${theme}`]: theme
131
+ });
132
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_react_fontawesome.FontAwesomeIcon, { className: classes, ...restProps });
133
+ };
134
+ var icon_default = Icon;
135
+
136
+ // src/components/Transition/transition.tsx
137
+ var import_react_transition_group = require("react-transition-group");
138
+ var import_jsx_runtime4 = require("react/jsx-runtime");
139
+ var Transition = (props) => {
140
+ const {
141
+ children,
142
+ classNames: classNames9,
143
+ animation,
144
+ wrapper,
145
+ unmountOnExit = true,
146
+ //该属性可以根据in属性的true和false实现子节点的挂载与卸载,从而无需自行添加display:none与block的转换
147
+ appear = true,
148
+ ...restProps
149
+ } = props;
150
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
151
+ import_react_transition_group.CSSTransition,
152
+ {
153
+ classNames: classNames9 ? classNames9 : animation,
154
+ unmountOnExit,
155
+ appear,
156
+ ...restProps,
157
+ children: wrapper ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { children }) : children
158
+ }
159
+ );
160
+ };
161
+ var transition_default = Transition;
162
+
163
+ // src/components/Menu/subMenu.tsx
164
+ var import_jsx_runtime5 = require("react/jsx-runtime");
165
+ var SubMenu = ({ index, title, children, className }) => {
166
+ const context = (0, import_react2.useContext)(MenuContext);
167
+ const openedSubMenus = context.defaultOpenSubMenus;
168
+ const isOpend = index && context.mode === "vertical" ? openedSubMenus.includes(index) : false;
169
+ const [menuOpen, setOpen] = (0, import_react2.useState)(isOpend);
170
+ const classes = (0, import_classnames4.default)("menu-item submenu-item", className, {
171
+ "is-active": context.index === index,
172
+ "is-opened": menuOpen,
173
+ "is-vertical": context.mode === "vertical"
174
+ });
175
+ const handleClick = (e) => {
176
+ e.preventDefault();
177
+ setOpen(!menuOpen);
178
+ };
179
+ const timer = (0, import_react2.useRef)();
180
+ const handleMouse = (e, toggle) => {
181
+ clearTimeout(timer.current);
182
+ e.preventDefault();
183
+ timer.current = setTimeout(() => {
184
+ setOpen(toggle);
185
+ }, 300);
186
+ };
187
+ const clickEvents = context.mode === "vertical" ? {
188
+ onClick: handleClick
189
+ } : {};
190
+ const hoverEvents = context.mode !== "vertical" ? {
191
+ onMouseEnter: (e) => {
192
+ handleMouse(e, true);
193
+ },
194
+ onMouseLeave: (e) => {
195
+ handleMouse(e, false);
196
+ }
197
+ } : {};
198
+ const renderChildren = () => {
199
+ const childrenComponent = import_react2.default.Children.map(children, (child, i) => {
200
+ const childElement = child;
201
+ if (childElement.type.displayName === "MenuItem" || childElement.type.displayName === "SubMenu") {
202
+ return import_react2.default.cloneElement(childElement, {
203
+ index: `${index}-${i}`
204
+ });
205
+ } else {
206
+ console.error("Warning: SubMenu has a child which is not a MenuItem component");
207
+ }
208
+ });
209
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
210
+ transition_default,
211
+ {
212
+ in: menuOpen,
213
+ timeout: 300,
214
+ animation: "zoom-in-top",
215
+ children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("ul", { className: "viking-submenu", children: childrenComponent })
216
+ }
217
+ );
218
+ };
219
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("li", { className: classes, ...hoverEvents, children: [
220
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "submenu-title", ...clickEvents, children: [
221
+ title,
222
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(icon_default, { icon: "angle-down", className: "arrow-icon" })
223
+ ] }),
224
+ renderChildren()
225
+ ] }, index);
226
+ };
227
+ SubMenu.displayName = "SubMenu";
228
+ var subMenu_default = SubMenu;
229
+
230
+ // src/components/Menu/menuItem.tsx
231
+ var import_react3 = require("react");
232
+ var import_classnames5 = __toESM(require("classnames"));
233
+ var import_jsx_runtime6 = require("react/jsx-runtime");
234
+ var MenuItem = (props) => {
235
+ const { index, disabled, className, style, children } = props;
236
+ const context = (0, import_react3.useContext)(MenuContext);
237
+ const classes = (0, import_classnames5.default)("menu-item", className, {
238
+ "is-disabled": disabled,
239
+ "is-active": context.index === index
240
+ });
241
+ const handleClick = (e) => {
242
+ if (context.onSelect && !disabled && index) {
243
+ context.onSelect(index, e);
244
+ }
245
+ };
246
+ const handleKeyDown = (e) => {
247
+ if (e.key === "Enter" || e.key === " ") {
248
+ e.preventDefault();
249
+ if (context.onSelect && !disabled && index) {
250
+ context.onSelect(index, e);
251
+ }
252
+ }
253
+ };
254
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
255
+ "li",
256
+ {
257
+ className: classes,
258
+ style,
259
+ onClick: handleClick,
260
+ onKeyDown: handleKeyDown,
261
+ role: "menuitem",
262
+ tabIndex: disabled ? -1 : 0,
263
+ "aria-disabled": disabled,
264
+ children
265
+ }
266
+ );
267
+ };
268
+ MenuItem.displayName = "MenuItem";
269
+ var menuItem_default = MenuItem;
270
+
271
+ // src/components/Menu/index.tsx
272
+ var TransMenu = menu_default;
273
+ TransMenu.Item = menuItem_default;
274
+ TransMenu.SubMenu = subMenu_default;
275
+ var Menu_default = TransMenu;
276
+
277
+ // src/components/AutoComplete/autoComplete.tsx
278
+ var import_react7 = require("react");
279
+
280
+ // src/components/Input/input.tsx
281
+ var import_react4 = require("react");
282
+ var import_classnames6 = __toESM(require("classnames"));
283
+ var import_jsx_runtime7 = require("react/jsx-runtime");
284
+ var Input = (0, import_react4.forwardRef)((props, ref) => {
285
+ const {
286
+ disabled,
287
+ size,
288
+ icon,
289
+ prepend,
290
+ append,
291
+ style,
292
+ ...restProps
293
+ } = props;
294
+ const cnames = (0, import_classnames6.default)("viking-input-wrapper", {
295
+ [`input-size-${size}`]: size,
296
+ "is-disabled": disabled,
297
+ "input-group": prepend || append,
298
+ "input-group-append": !!append,
299
+ "input-group-prepend": !!prepend
300
+ });
301
+ const fixControlledValue = (value) => {
302
+ if (typeof value === "undefined" || value === null) {
303
+ return "";
304
+ }
305
+ return value;
306
+ };
307
+ if ("value" in props) {
308
+ delete restProps.defaultValue;
309
+ restProps.value = fixControlledValue(props.value);
310
+ }
311
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: cnames, style, children: [
312
+ prepend && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "viking-input-group-prepend", children: prepend }),
313
+ icon && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "icon-wrapper", children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(icon_default, { icon, title: `title-${icon}` }) }),
314
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
315
+ "input",
316
+ {
317
+ ref,
318
+ className: "viking-input-inner",
319
+ disabled,
320
+ ...restProps
321
+ }
322
+ ),
323
+ append && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "viking-input-group-append", children: append })
324
+ ] });
325
+ });
326
+ var input_default = Input;
327
+
328
+ // src/hooks/useDebounce.tsx
329
+ var import_react5 = require("react");
330
+ function useDebounce(value, delay = 300) {
331
+ const [debouncedValue, setDebouncedValue] = (0, import_react5.useState)(value);
332
+ (0, import_react5.useEffect)(() => {
333
+ const handler = setTimeout(() => {
334
+ setDebouncedValue(value);
335
+ }, delay);
336
+ return () => {
337
+ clearTimeout(handler);
338
+ };
339
+ }, [value, delay]);
340
+ return debouncedValue;
341
+ }
342
+ var useDebounce_default = useDebounce;
343
+
344
+ // src/components/AutoComplete/autoComplete.tsx
345
+ var import_classnames7 = __toESM(require("classnames"));
346
+
347
+ // src/hooks/useClickOutside.tsx
348
+ var import_react6 = require("react");
349
+ function useClickOutside(ref, handler) {
350
+ (0, import_react6.useEffect)(() => {
351
+ const listener = (event) => {
352
+ if (!ref.current || ref.current.contains(event.target)) {
353
+ return;
354
+ }
355
+ handler(event);
356
+ };
357
+ document.addEventListener("click", listener);
358
+ return () => {
359
+ document.removeEventListener("click", listener);
360
+ };
361
+ }, [ref, handler]);
362
+ }
363
+ var useClickOutside_default = useClickOutside;
364
+
365
+ // src/components/AutoComplete/autoComplete.tsx
366
+ var import_jsx_runtime8 = require("react/jsx-runtime");
367
+ var AutoComplete = (props) => {
368
+ const { value, fetchSuggestions, onSelect, onChange, onEnterDown, onError, renderOption, style, debounceTime = 300, expireTime = 36e5, ...restprops } = props;
369
+ const [inputValue, setInputValue] = (0, import_react7.useState)(value || "");
370
+ const [suggestions, setSuggestions] = (0, import_react7.useState)([]);
371
+ const [loading, setloading] = (0, import_react7.useState)(false);
372
+ const [highlightIndex, sethighlightIndex] = (0, import_react7.useState)(-1);
373
+ const [isFocus, setisFocus] = (0, import_react7.useState)(true);
374
+ const componentRef = (0, import_react7.useRef)(null);
375
+ const triggerSearch = (0, import_react7.useRef)(false);
376
+ const fetchId = (0, import_react7.useRef)(0);
377
+ const intialInputvalue = (0, import_react7.useRef)(value || "");
378
+ const debouncedValue = useDebounce_default(inputValue, debounceTime);
379
+ useClickOutside_default(componentRef, () => {
380
+ setisFocus(false);
381
+ });
382
+ (0, import_react7.useEffect)(() => {
383
+ function getData() {
384
+ async function fetchData() {
385
+ fetchId.current++;
386
+ if (debouncedValue) {
387
+ const Id = fetchId.current;
388
+ setloading(true);
389
+ setSuggestions([]);
390
+ try {
391
+ const results = await fetchSuggestions(debouncedValue);
392
+ if (Id === fetchId.current && results) {
393
+ setloading(false);
394
+ setSuggestions(results);
395
+ const item = {
396
+ value: results,
397
+ // 实际数据
398
+ expiry: Date.now() + expireTime
399
+ // 当前时间加上1小时的过期时间 (单位毫秒)
400
+ };
401
+ localStorage.setItem(debouncedValue, JSON.stringify(item));
402
+ }
403
+ } catch (e) {
404
+ onError == null ? void 0 : onError(e);
405
+ setloading(false);
406
+ setSuggestions([]);
407
+ }
408
+ } else {
409
+ setloading(false);
410
+ setSuggestions([]);
411
+ }
412
+ }
413
+ if (triggerSearch.current) {
414
+ if (localStorage.getItem(debouncedValue)) {
415
+ const item = JSON.parse(localStorage.getItem(debouncedValue));
416
+ if (item.expiry > (/* @__PURE__ */ new Date()).getTime()) {
417
+ fetchId.current++;
418
+ setloading(false);
419
+ setSuggestions(item.value);
420
+ } else {
421
+ localStorage.removeItem(debouncedValue);
422
+ fetchData();
423
+ }
424
+ } else {
425
+ fetchData();
426
+ }
427
+ sethighlightIndex(-1);
428
+ }
429
+ }
430
+ getData();
431
+ }, [debouncedValue, fetchSuggestions, expireTime, onError]);
432
+ const handleChange = (e) => {
433
+ const value2 = e.target.value.trim();
434
+ setInputValue(value2);
435
+ onChange == null ? void 0 : onChange(value2);
436
+ intialInputvalue.current = value2;
437
+ triggerSearch.current = true;
438
+ };
439
+ const handleSelect = (item) => {
440
+ setInputValue(item.value);
441
+ intialInputvalue.current = item.value;
442
+ setSuggestions([]);
443
+ onSelect == null ? void 0 : onSelect(item);
444
+ triggerSearch.current = false;
445
+ };
446
+ const handleUpDown = (item) => {
447
+ setInputValue(item.value);
448
+ triggerSearch.current = false;
449
+ };
450
+ const handleArrowDown = () => {
451
+ if (highlightIndex + 1 > suggestions.length - 1) {
452
+ sethighlightIndex(-1);
453
+ setInputValue(intialInputvalue.current);
454
+ triggerSearch.current = false;
455
+ } else {
456
+ sethighlightIndex(highlightIndex + 1);
457
+ if (suggestions[highlightIndex + 1]) handleUpDown(suggestions[highlightIndex + 1]);
458
+ }
459
+ };
460
+ const handleArrowUp = () => {
461
+ if (highlightIndex - 1 === -1) {
462
+ sethighlightIndex(highlightIndex - 1);
463
+ setInputValue(intialInputvalue.current);
464
+ triggerSearch.current = false;
465
+ } else if (highlightIndex - 1 < -1) {
466
+ sethighlightIndex(suggestions.length - 1);
467
+ if (suggestions[suggestions.length - 1]) handleUpDown(suggestions[suggestions.length - 1]);
468
+ } else {
469
+ sethighlightIndex(highlightIndex - 1);
470
+ handleUpDown(suggestions[highlightIndex - 1]);
471
+ }
472
+ };
473
+ const handleKeyDown = (e) => {
474
+ switch (e.key) {
475
+ case "Enter":
476
+ if (suggestions[highlightIndex]) {
477
+ handleSelect(suggestions[highlightIndex]);
478
+ onEnterDown == null ? void 0 : onEnterDown(suggestions[highlightIndex]);
479
+ } else {
480
+ onEnterDown == null ? void 0 : onEnterDown({ value: intialInputvalue.current });
481
+ }
482
+ break;
483
+ case "ArrowDown":
484
+ handleArrowDown();
485
+ break;
486
+ case "ArrowUp":
487
+ handleArrowUp();
488
+ break;
489
+ case "Escape":
490
+ setisFocus(false);
491
+ break;
492
+ default:
493
+ break;
494
+ }
495
+ };
496
+ const handleClick = (e) => {
497
+ setisFocus(true);
498
+ };
499
+ const generateDropdown = () => {
500
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("ul", { className: "viking-suggestion-list", role: "listbox", id: "suggestion-listbox", children: suggestions.map(
501
+ (item, index) => {
502
+ const cnames = (0, import_classnames7.default)("suggestion-item", {
503
+ "item-highlighted": index === highlightIndex
504
+ });
505
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
506
+ "li",
507
+ {
508
+ onClick: () => handleSelect(item),
509
+ className: cnames,
510
+ role: "option",
511
+ id: `suggestion-item-${index}`,
512
+ "aria-selected": index === highlightIndex,
513
+ children: renderOption ? renderOption(item) : item.value
514
+ },
515
+ index
516
+ );
517
+ }
518
+ ) });
519
+ };
520
+ const showSuggestions = isFocus && suggestions.length > 0;
521
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "viking-auto-complete", style, ref: componentRef, children: [
522
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
523
+ input_default,
524
+ {
525
+ value: inputValue,
526
+ onChange: handleChange,
527
+ ...restprops,
528
+ onKeyDown: handleKeyDown,
529
+ onClick: handleClick,
530
+ "aria-expanded": showSuggestions,
531
+ "aria-autocomplete": "list",
532
+ "aria-controls": showSuggestions ? "suggestion-listbox" : void 0,
533
+ "aria-activedescendant": highlightIndex >= 0 ? `suggestion-item-${highlightIndex}` : void 0,
534
+ role: "combobox"
535
+ }
536
+ ),
537
+ isFocus && loading && /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("ul", { children: [
538
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(icon_default, { icon: "spinner", spin: true }),
539
+ "loading..."
540
+ ] }),
541
+ showSuggestions && generateDropdown()
542
+ ] });
543
+ };
544
+ var autoComplete_default = AutoComplete;
545
+
546
+ // src/components/Upload/upload.tsx
547
+ var import_react9 = require("react");
548
+ var import_axios = __toESM(require("axios"));
549
+
550
+ // src/components/Progress/progress.tsx
551
+ var import_jsx_runtime9 = require("react/jsx-runtime");
552
+ var Progress = (props) => {
553
+ const {
554
+ percent,
555
+ strokeHeight = 15,
556
+ showText = true,
557
+ style,
558
+ theme = "primary"
559
+ } = props;
560
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "viking-progress-bar", style, children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "viking-progress-bar-outer", style: { height: `${strokeHeight}px` }, children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
561
+ "div",
562
+ {
563
+ className: `viking-progress-bar-inner color-${theme}`,
564
+ style: { width: `${percent}%` },
565
+ children: showText && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { className: "inner-text", children: `${percent}%` })
566
+ }
567
+ ) }) });
568
+ };
569
+ var progress_default = Progress;
570
+
571
+ // src/components/Upload/uploadList.tsx
572
+ var import_jsx_runtime10 = require("react/jsx-runtime");
573
+ var UploadList = (props) => {
574
+ const {
575
+ fileList,
576
+ onRemove,
577
+ style
578
+ } = props;
579
+ return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("ul", { className: "viking-upload-list", style, children: fileList.map((item) => {
580
+ return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("li", { className: "viking-upload-list-item", children: [
581
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("span", { className: `file-name file-name-${item.status}`, children: [
582
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(icon_default, { icon: "file-alt", theme: "secondary" }),
583
+ item.name
584
+ ] }),
585
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("span", { className: "file-status", children: [
586
+ (item.status === "uploading" || item.status === "ready") && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(icon_default, { icon: "spinner", spin: true, theme: "primary" }),
587
+ item.status === "success" && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(icon_default, { icon: "check-circle", theme: "success" }),
588
+ item.status === "error" && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(icon_default, { icon: "times-circle", theme: "danger" })
589
+ ] }),
590
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("span", { className: "file-actions", children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(icon_default, { icon: "times", onClick: () => {
591
+ onRemove(item);
592
+ } }) }),
593
+ item.status === "uploading" && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
594
+ progress_default,
595
+ {
596
+ percent: item.percent || 0
597
+ }
598
+ )
599
+ ] }, item.uid);
600
+ }) });
601
+ };
602
+ var uploadList_default = UploadList;
603
+
604
+ // src/components/Upload/dragger.tsx
605
+ var import_react8 = require("react");
606
+ var import_classnames8 = __toESM(require("classnames"));
607
+ var import_jsx_runtime11 = require("react/jsx-runtime");
608
+ var Dragger = (props) => {
609
+ const { onFile, children, style } = props;
610
+ const [dragOver, setDragOver] = (0, import_react8.useState)(false);
611
+ const fileInput = (0, import_react8.useRef)(null);
612
+ const klass = (0, import_classnames8.default)("viking-uploader-dragger", {
613
+ "is-dragover": dragOver
614
+ });
615
+ const handleDrop = (e) => {
616
+ e.preventDefault();
617
+ setDragOver(false);
618
+ onFile(e.dataTransfer.files);
619
+ };
620
+ const handleDrag = (e, over) => {
621
+ e.preventDefault();
622
+ setDragOver(over);
623
+ };
624
+ const handleKeyDown = (e) => {
625
+ var _a;
626
+ if (e.key === "Enter" || e.key === " ") {
627
+ e.preventDefault();
628
+ (_a = fileInput.current) == null ? void 0 : _a.click();
629
+ }
630
+ };
631
+ return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(
632
+ "div",
633
+ {
634
+ className: klass,
635
+ onDragOver: (e) => {
636
+ handleDrag(e, true);
637
+ },
638
+ onDragLeave: (e) => {
639
+ handleDrag(e, false);
640
+ },
641
+ onDrop: handleDrop,
642
+ style,
643
+ role: "button",
644
+ tabIndex: 0,
645
+ onKeyDown: handleKeyDown,
646
+ "aria-label": "\u62D6\u62FD\u4E0A\u4F20\u533A\u57DF",
647
+ children: [
648
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
649
+ "input",
650
+ {
651
+ type: "file",
652
+ ref: fileInput,
653
+ style: { display: "none" },
654
+ onChange: (e) => {
655
+ if (e.target.files) {
656
+ onFile(e.target.files);
657
+ e.target.value = "";
658
+ }
659
+ }
660
+ }
661
+ ),
662
+ children
663
+ ]
664
+ }
665
+ );
666
+ };
667
+ var dragger_default = Dragger;
668
+
669
+ // src/components/Upload/upload.tsx
670
+ var import_jsx_runtime12 = require("react/jsx-runtime");
671
+ var Upload = (props) => {
672
+ const {
673
+ action,
674
+ beforeUpload,
675
+ onprogress,
676
+ onSuccess,
677
+ onError,
678
+ onChange,
679
+ onRemove,
680
+ onExceed,
681
+ name = "file",
682
+ headers,
683
+ data,
684
+ withCredentials,
685
+ accept,
686
+ multiple,
687
+ children,
688
+ drag,
689
+ maxsize,
690
+ maxnum,
691
+ styleButton,
692
+ styleDrag,
693
+ styleUploadList,
694
+ failednums = 0,
695
+ limit = Infinity
696
+ } = props;
697
+ const fileInput = (0, import_react9.useRef)(null);
698
+ const abortRecord = (0, import_react9.useRef)({});
699
+ const FileRecord = (0, import_react9.useRef)(/* @__PURE__ */ new Set());
700
+ const [fileList, setFileList] = (0, import_react9.useState)([]);
701
+ const handleClick = () => {
702
+ var _a;
703
+ (_a = fileInput.current) == null ? void 0 : _a.click();
704
+ };
705
+ const uploadFiles = (files) => {
706
+ if (maxnum && files.length > maxnum) {
707
+ onExceed == null ? void 0 : onExceed(`\u6587\u4EF6\u6570\u91CF\u4E0D\u80FD\u8D85\u8FC7${maxnum}`);
708
+ return;
709
+ }
710
+ let concurrency = 0;
711
+ const queue = [];
712
+ function AskTask(task) {
713
+ return new Promise(() => {
714
+ const executeRequest = () => {
715
+ concurrency++;
716
+ task[0]().then(() => {
717
+ concurrency--;
718
+ nextTask();
719
+ });
720
+ };
721
+ if (concurrency < limit) {
722
+ executeRequest();
723
+ } else {
724
+ queue.push([executeRequest, task[1]]);
725
+ }
726
+ });
727
+ }
728
+ function nextTask() {
729
+ if (concurrency < limit && queue.length > 0) {
730
+ while (queue.length > 0) {
731
+ const [task, fileName] = queue.shift();
732
+ if (FileRecord.current.has(fileName)) {
733
+ task();
734
+ break;
735
+ }
736
+ }
737
+ }
738
+ }
739
+ let uidCounter = 0;
740
+ function dealFile(file) {
741
+ let _file = {
742
+ uid: `upload-file-${Date.now()}-${uidCounter++}`,
743
+ size: file.size,
744
+ name: file.name,
745
+ percent: 0,
746
+ status: "ready",
747
+ raw: file
748
+ };
749
+ setFileList((prevList) => {
750
+ let isSame = false;
751
+ for (let i = 0; i < prevList.length; i++) {
752
+ if (prevList[i].name === _file.name) {
753
+ prevList[i] = _file;
754
+ isSame = true;
755
+ }
756
+ }
757
+ if (isSame) return prevList;
758
+ return [_file, ...prevList];
759
+ });
760
+ const formData = new FormData();
761
+ formData.append(name || "file", file);
762
+ data && Object.keys(data).forEach((key) => formData.append(key, data[key]));
763
+ const controller = new AbortController();
764
+ abortRecord.current = { ...abortRecord.current, [_file.uid]: controller };
765
+ return [_file, formData, controller];
766
+ }
767
+ const post = (_file, formData, controller, try_nums) => {
768
+ return new Promise((resolve) => {
769
+ import_axios.default.post(action, formData, {
770
+ headers: {
771
+ ...headers,
772
+ "Content-Type": "multipart/form-data"
773
+ },
774
+ withCredentials,
775
+ signal: controller.signal,
776
+ onUploadProgress: (e) => {
777
+ let percentage = Math.floor(e.loaded * 100 / e.total || 0);
778
+ if (percentage < 100) {
779
+ updateFileList(_file, {
780
+ percent: percentage,
781
+ status: "uploading"
782
+ });
783
+ _file.status = "uploading";
784
+ _file.percent = percentage;
785
+ onprogress == null ? void 0 : onprogress(percentage, _file);
786
+ }
787
+ }
788
+ }).then((res) => {
789
+ updateFileList(_file, { status: "success", response: res.data });
790
+ _file.status = "success";
791
+ _file.response = res.data;
792
+ onSuccess == null ? void 0 : onSuccess(res.data, _file);
793
+ onChange == null ? void 0 : onChange(_file);
794
+ resolve("success");
795
+ }).catch((err) => {
796
+ if (import_axios.default.isCancel(err)) {
797
+ resolve("cancel");
798
+ } else {
799
+ if (try_nums < failednums) {
800
+ const [_file_new, formData2, controller2] = dealFile(_file.raw);
801
+ AskTask([
802
+ () => post(_file_new, formData2, controller2, try_nums + 1),
803
+ _file.name
804
+ ]);
805
+ }
806
+ updateFileList(_file, { status: "error", error: err });
807
+ _file.status = "error";
808
+ _file.error = err;
809
+ onError == null ? void 0 : onError(err, _file);
810
+ onChange == null ? void 0 : onChange(_file);
811
+ resolve("failed");
812
+ }
813
+ });
814
+ });
815
+ };
816
+ let postFiles = Array.from(files);
817
+ postFiles.forEach((file) => {
818
+ if (maxsize && file.size > maxsize * 1024 * 1024) {
819
+ onExceed == null ? void 0 : onExceed(`\u6587\u4EF6\u5927\u5C0F\u4E0D\u80FD\u8D85\u8FC7${maxsize}Mb`);
820
+ return;
821
+ }
822
+ FileRecord.current.add(file.name);
823
+ if (!beforeUpload) {
824
+ const [_file, formData, source] = dealFile(file);
825
+ AskTask([() => post(_file, formData, source, 0), file.name]);
826
+ } else {
827
+ const result = beforeUpload(file);
828
+ if (result && result instanceof Promise) {
829
+ result.then((processedFile) => {
830
+ const [_file, formData, source] = dealFile(file);
831
+ AskTask([() => post(_file, formData, source, 0), file.name]);
832
+ });
833
+ } else if (result) {
834
+ const [_file, formData, source] = dealFile(file);
835
+ AskTask([() => post(_file, formData, source, 0), file.name]);
836
+ }
837
+ }
838
+ });
839
+ };
840
+ const updateFileList = (updateFile, uploadobj) => {
841
+ setFileList((prevList) => {
842
+ return prevList.map(
843
+ (file) => file.uid === updateFile.uid ? { ...file, ...uploadobj } : file
844
+ );
845
+ });
846
+ };
847
+ const handleFileChange = (e) => {
848
+ const files = e.target.files;
849
+ if (files) {
850
+ uploadFiles(files);
851
+ if (fileInput.current) {
852
+ fileInput.current.value = "";
853
+ }
854
+ }
855
+ };
856
+ const handleRemove = (file) => {
857
+ var _a;
858
+ setFileList((prevList) => {
859
+ return prevList.filter((item) => item.uid !== file.uid);
860
+ });
861
+ (_a = abortRecord.current[file.uid]) == null ? void 0 : _a.abort();
862
+ delete abortRecord.current[file.uid];
863
+ FileRecord.current.delete(file.name);
864
+ onRemove == null ? void 0 : onRemove(file);
865
+ };
866
+ return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: "viking-upload-component", children: [
867
+ drag ? /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
868
+ dragger_default,
869
+ {
870
+ style: styleDrag,
871
+ onFile: (files) => {
872
+ uploadFiles(files);
873
+ },
874
+ children
875
+ }
876
+ ) : /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(button_default, { btnType: "default", onClick: handleClick, style: styleButton, children }),
877
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
878
+ "input",
879
+ {
880
+ type: "file",
881
+ className: "viking-file-input",
882
+ style: { display: "none" },
883
+ ref: fileInput,
884
+ onChange: handleFileChange,
885
+ accept,
886
+ multiple
887
+ }
888
+ ),
889
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
890
+ uploadList_default,
891
+ {
892
+ style: styleUploadList,
893
+ fileList,
894
+ onRemove: handleRemove
895
+ }
896
+ )
897
+ ] });
898
+ };
899
+ var upload_default = Upload;
900
+
901
+ // src/components/Signature/signature.tsx
902
+ var import_react10 = require("react");
903
+ var import_jsx_runtime13 = require("react/jsx-runtime");
904
+ var Signature = ({
905
+ width = 400,
906
+ height = 200,
907
+ style,
908
+ onSave
909
+ }) => {
910
+ const [isDrawing, setIsDrawing] = (0, import_react10.useState)(false);
911
+ const [strokeStyle, setStrokeStyle] = (0, import_react10.useState)("pen");
912
+ const [points, setPoints] = (0, import_react10.useState)({
913
+ x: 0,
914
+ y: 0
915
+ });
916
+ const canvas = (0, import_react10.useRef)(null);
917
+ const ctx = (0, import_react10.useRef)();
918
+ (0, import_react10.useEffect)(() => {
919
+ var _a;
920
+ ctx.current = (_a = canvas.current) == null ? void 0 : _a.getContext("2d");
921
+ }, []);
922
+ (0, import_react10.useEffect)(() => {
923
+ if (!ctx.current) return;
924
+ if (strokeStyle === "pen") {
925
+ ctx.current.lineWidth = 2;
926
+ ctx.current.lineCap = "round";
927
+ } else if (strokeStyle === "brush") {
928
+ ctx.current.lineWidth = 5;
929
+ ctx.current.lineCap = "round";
930
+ }
931
+ }, [strokeStyle]);
932
+ const startDrawing = (e) => {
933
+ var _a, _b;
934
+ setIsDrawing(true);
935
+ (_a = ctx.current) == null ? void 0 : _a.beginPath();
936
+ const { offsetX, offsetY } = getEventPosition(e);
937
+ setPoints({ x: offsetX, y: offsetY });
938
+ (_b = ctx.current) == null ? void 0 : _b.moveTo(offsetX, offsetY);
939
+ };
940
+ const draw = (e) => {
941
+ var _a, _b;
942
+ if (!isDrawing) return;
943
+ const { offsetX, offsetY } = getEventPosition(e);
944
+ (_a = ctx.current) == null ? void 0 : _a.quadraticCurveTo(
945
+ points["x"],
946
+ points["y"],
947
+ (points["x"] + offsetX) / 2,
948
+ (points["y"] + offsetY) / 2
949
+ );
950
+ (_b = ctx.current) == null ? void 0 : _b.stroke();
951
+ setPoints({ x: offsetX, y: offsetY });
952
+ };
953
+ const stopDrawing = (e) => {
954
+ setIsDrawing(false);
955
+ };
956
+ const getEventPosition = (e) => {
957
+ var _a, _b;
958
+ const offsetX = (_a = e.nativeEvent.offsetX) != null ? _a : e.touches[0].clientX - canvas.current.offsetLeft;
959
+ const offsetY = (_b = e.nativeEvent.offsetY) != null ? _b : e.touches[0].clientY - canvas.current.offsetTop;
960
+ return { offsetX, offsetY };
961
+ };
962
+ const handleStrokeStyle = (e) => {
963
+ setStrokeStyle(e.target.value);
964
+ };
965
+ const handleSave = () => {
966
+ var _a;
967
+ const dataURL = (_a = canvas.current) == null ? void 0 : _a.toDataURL();
968
+ onSave == null ? void 0 : onSave(dataURL);
969
+ };
970
+ return /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(import_jsx_runtime13.Fragment, { children: [
971
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
972
+ "canvas",
973
+ {
974
+ ref: canvas,
975
+ onMouseDown: startDrawing,
976
+ onMouseUp: stopDrawing,
977
+ onMouseMove: draw,
978
+ onMouseOut: stopDrawing,
979
+ onTouchStart: startDrawing,
980
+ onTouchEnd: stopDrawing,
981
+ onTouchMove: draw,
982
+ onTouchCancel: stopDrawing,
983
+ style: { border: "1px solid black", ...style },
984
+ width,
985
+ height,
986
+ className: "viking-signature",
987
+ "aria-label": "\u7B7E\u540D\u753B\u5E03",
988
+ role: "img"
989
+ }
990
+ ),
991
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: "controls", style: { width }, children: [
992
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("label", { htmlFor: "stroke-style-select", children: "\u7B14\u89E6\u6837\u5F0F" }),
993
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("select", { id: "stroke-style-select", onChange: handleStrokeStyle, children: [
994
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("option", { value: "pen", children: "\u94A2\u7B14" }),
995
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("option", { value: "brush", children: "\u6BDB\u7B14" })
996
+ ] }),
997
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
998
+ "button",
999
+ {
1000
+ type: "button",
1001
+ onClick: () => ctx.current.clearRect(
1002
+ 0,
1003
+ 0,
1004
+ canvas.current.width,
1005
+ canvas.current.height
1006
+ ),
1007
+ children: "\u6E05\u7A7A"
1008
+ }
1009
+ ),
1010
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("button", { type: "button", onClick: handleSave, children: "\u4FDD\u5B58" })
1011
+ ] })
1012
+ ] });
1013
+ };
1014
+ var signature_default = Signature;
1015
+
1016
+ // src/components/VirtualList/virtualList.tsx
1017
+ var import_react11 = require("react");
1018
+ var import_jsx_runtime14 = require("react/jsx-runtime");
1019
+ var VirtualList = ({
1020
+ containerHeight,
1021
+ itemHeight,
1022
+ itemCount,
1023
+ children
1024
+ }) => {
1025
+ if (import_react11.Children.count(children) > 1) {
1026
+ throw new Error("VirtualList only accept one child");
1027
+ }
1028
+ const contentHeight = itemHeight * itemCount;
1029
+ const [scrollTop, setScrollTop] = (0, import_react11.useState)(0);
1030
+ let startIdx = Math.floor(scrollTop / itemHeight);
1031
+ let endIdx = Math.floor((scrollTop + containerHeight) / itemHeight);
1032
+ const paddingCount = 2;
1033
+ startIdx = Math.max(startIdx - paddingCount, 0);
1034
+ endIdx = Math.min(endIdx + paddingCount, itemCount - 1);
1035
+ const top = itemHeight * startIdx;
1036
+ const items = [];
1037
+ for (let i = startIdx; i <= endIdx; i++) {
1038
+ items.push(
1039
+ (0, import_react11.cloneElement)(children, {
1040
+ index: i,
1041
+ style: { height: itemHeight }
1042
+ })
1043
+ );
1044
+ }
1045
+ return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
1046
+ "div",
1047
+ {
1048
+ style: { height: containerHeight, overflow: "auto" },
1049
+ onScroll: (e) => {
1050
+ setScrollTop(e.target.scrollTop);
1051
+ },
1052
+ children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { style: { height: contentHeight }, children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { style: { transform: `translate3d(0px, ${top}px, 0` }, children: items }) })
1053
+ }
1054
+ );
1055
+ };
1056
+ var virtualList_default = VirtualList;
1057
+
1058
+ // src/components/LazyLoad/lazyLoad.tsx
1059
+ var import_react12 = require("react");
1060
+ var import_jsx_runtime15 = require("react/jsx-runtime");
1061
+ var Lazyload = (props) => {
1062
+ const {
1063
+ className = "",
1064
+ style,
1065
+ offset = 0,
1066
+ width,
1067
+ onContentVisible,
1068
+ placeholder,
1069
+ height,
1070
+ children
1071
+ } = props;
1072
+ const containerRef = (0, import_react12.useRef)(null);
1073
+ const [visible, setVisible] = (0, import_react12.useState)(false);
1074
+ const elementObserver = (0, import_react12.useRef)();
1075
+ (0, import_react12.useEffect)(() => {
1076
+ function lazyLoadHandler(entries) {
1077
+ var _a;
1078
+ const [entry] = entries;
1079
+ const { isIntersecting } = entry;
1080
+ if (isIntersecting) {
1081
+ setVisible(true);
1082
+ onContentVisible == null ? void 0 : onContentVisible();
1083
+ const node2 = containerRef.current;
1084
+ if (node2 && node2 instanceof HTMLElement) {
1085
+ (_a = elementObserver.current) == null ? void 0 : _a.unobserve(node2);
1086
+ }
1087
+ }
1088
+ }
1089
+ const options = {
1090
+ rootMargin: typeof offset === "number" ? `${offset}px` : offset || "0px",
1091
+ threshold: 0
1092
+ };
1093
+ elementObserver.current = new IntersectionObserver(
1094
+ lazyLoadHandler,
1095
+ options
1096
+ );
1097
+ const node = containerRef.current;
1098
+ if (node instanceof HTMLElement) {
1099
+ elementObserver.current.observe(node);
1100
+ }
1101
+ return () => {
1102
+ var _a;
1103
+ if (node && node instanceof HTMLElement) {
1104
+ (_a = elementObserver.current) == null ? void 0 : _a.unobserve(node);
1105
+ }
1106
+ };
1107
+ }, [offset, onContentVisible]);
1108
+ const styles = { height, width, ...style };
1109
+ return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("div", { ref: containerRef, className, style: styles, children: visible ? children : placeholder });
1110
+ };
1111
+ var lazyLoad_default = Lazyload;
1112
+
1113
+ // src/components/Keepalive/Keepalive.tsx
1114
+ var import_react13 = require("react");
1115
+ var import_react_router_dom = require("react-router-dom");
1116
+ var import_jsx_runtime16 = require("react/jsx-runtime");
1117
+ var KeepAliveContext = (0, import_react13.createContext)({
1118
+ keepPaths: [],
1119
+ keepElements: {},
1120
+ dropByPath() {
1121
+ }
1122
+ });
1123
+ var isKeepPath = (keepPaths, path) => {
1124
+ for (let i = 0; i < keepPaths.length; i++) {
1125
+ let item = keepPaths[i];
1126
+ if (item === path) return true;
1127
+ if (item instanceof RegExp && item.test(path)) return true;
1128
+ if (typeof item === "string" && item.toLowerCase() === path) return true;
1129
+ }
1130
+ return false;
1131
+ };
1132
+ function useKeepOutlet() {
1133
+ const location = (0, import_react_router_dom.useLocation)();
1134
+ const element = (0, import_react_router_dom.useOutlet)();
1135
+ const { keepElements, keepPaths } = (0, import_react13.useContext)(KeepAliveContext);
1136
+ const isKeep = isKeepPath(keepPaths, location.pathname);
1137
+ const keepElementsRef = (0, import_react13.useRef)(keepElements);
1138
+ keepElementsRef.current = keepElements;
1139
+ (0, import_react13.useEffect)(() => {
1140
+ if (isKeep && element) {
1141
+ keepElementsRef.current[location.pathname] = element;
1142
+ }
1143
+ });
1144
+ return /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(import_jsx_runtime16.Fragment, { children: [
1145
+ Object.entries(keepElements).map(([pathname, el]) => /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
1146
+ "div",
1147
+ {
1148
+ style: {
1149
+ height: "100%",
1150
+ width: "100%",
1151
+ position: "relative",
1152
+ overflow: "hidden auto"
1153
+ },
1154
+ className: "keep-alive-page",
1155
+ hidden: !(0, import_react_router_dom.matchPath)(location.pathname, pathname),
1156
+ children: el
1157
+ },
1158
+ pathname
1159
+ )),
1160
+ !isKeep && element
1161
+ ] });
1162
+ }
1163
+ var KeepAliveLayout = (props) => {
1164
+ const { keepPaths, children } = props;
1165
+ const [keepElements] = (0, import_react13.useState)({});
1166
+ const dropByPath = (path) => {
1167
+ delete keepElements[path];
1168
+ };
1169
+ return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(KeepAliveContext.Provider, { value: { keepPaths, keepElements, dropByPath }, children });
1170
+ };
1171
+ var Keepalive_default = KeepAliveLayout;
1172
+ // Annotate the CommonJS export names for ESM import in node:
1173
+ 0 && (module.exports = {
1174
+ AutoComplete,
1175
+ Button,
1176
+ Icon,
1177
+ Input,
1178
+ KeepAliveContext,
1179
+ KeepAliveLayout,
1180
+ LazyLoad,
1181
+ Menu,
1182
+ MenuItem,
1183
+ Progress,
1184
+ Signature,
1185
+ SubMenu,
1186
+ Transition,
1187
+ Upload,
1188
+ VirtualList,
1189
+ useClickOutside,
1190
+ useDebounce,
1191
+ useKeepOutlet
1192
+ });
1193
+ //# sourceMappingURL=index.js.map