@creekjs/web-components 1.0.2 → 1.0.4
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/.fatherrc.ts +1 -5
- package/.turbo/turbo-father$colon$build.log +39 -0
- package/.turbo/turbo-father$colon$dev.log +33 -0
- package/dist/creek-config-provider/CreekConfigContext.js +31 -2
- package/dist/creek-config-provider/CreekConfigContext.js.map +7 -0
- package/dist/creek-config-provider/index.js +35 -13
- package/dist/creek-config-provider/index.js.map +7 -0
- package/dist/creek-hooks/index.d.ts +1 -0
- package/dist/creek-hooks/index.js +26 -1
- package/dist/creek-hooks/index.js.map +7 -0
- package/dist/creek-hooks/useApp/DrawerHelper.d.ts +9 -0
- package/dist/creek-hooks/useApp/DrawerHelper.js +62 -0
- package/dist/creek-hooks/useApp/DrawerHelper.js.map +7 -0
- package/dist/creek-hooks/useApp/ModalHelper.d.ts +9 -0
- package/dist/creek-hooks/useApp/ModalHelper.js +62 -0
- package/dist/creek-hooks/useApp/ModalHelper.js.map +7 -0
- package/dist/creek-hooks/useApp/index.d.ts +25 -0
- package/dist/creek-hooks/useApp/index.js +118 -0
- package/dist/creek-hooks/useApp/index.js.map +7 -0
- package/dist/creek-hooks/useApp/types.d.ts +26 -0
- package/dist/creek-hooks/useApp/types.js +18 -0
- package/dist/creek-hooks/useApp/types.js.map +7 -0
- package/dist/creek-hooks/useViewportHeight.js +99 -97
- package/dist/creek-hooks/useViewportHeight.js.map +7 -0
- package/dist/creek-icon/index.js +53 -31
- package/dist/creek-icon/index.js.map +7 -0
- package/dist/creek-keep-alive/index.js +36 -18
- package/dist/creek-keep-alive/index.js.map +7 -0
- package/dist/creek-layout/CollapseButton.js +69 -47
- package/dist/creek-layout/CollapseButton.js.map +7 -0
- package/dist/creek-layout/Exception/NotFound.js +42 -13
- package/dist/creek-layout/Exception/NotFound.js.map +7 -0
- package/dist/creek-layout/Exception/NotFoundPage.js +30 -5
- package/dist/creek-layout/Exception/NotFoundPage.js.map +7 -0
- package/dist/creek-layout/Exception/index.js +37 -8
- package/dist/creek-layout/Exception/index.js.map +7 -0
- package/dist/creek-layout/HeaderContent/FullScreen.js +45 -39
- package/dist/creek-layout/HeaderContent/FullScreen.js.map +7 -0
- package/dist/creek-layout/HeaderContent/UserInfo.js +75 -53
- package/dist/creek-layout/HeaderContent/UserInfo.js.map +7 -0
- package/dist/creek-layout/HeaderContent/index.js +48 -28
- package/dist/creek-layout/HeaderContent/index.js.map +7 -0
- package/dist/creek-layout/index.js +117 -81
- package/dist/creek-layout/index.js.map +7 -0
- package/dist/creek-loading/index.js +55 -48
- package/dist/creek-loading/index.js.map +7 -0
- package/dist/creek-table/SearchTable.js +118 -114
- package/dist/creek-table/SearchTable.js.map +7 -0
- package/dist/creek-table/TableOptionRender.js +69 -60
- package/dist/creek-table/TableOptionRender.js.map +7 -0
- package/dist/creek-table/hooks/index.d.ts +2 -1
- package/dist/creek-table/hooks/index.js +30 -3
- package/dist/creek-table/hooks/index.js.map +7 -0
- package/dist/creek-table/hooks/useAdaptiveToolBar.js +48 -36
- package/dist/creek-table/hooks/useAdaptiveToolBar.js.map +7 -0
- package/dist/creek-table/hooks/useAutoWidthColumns.d.ts +6 -0
- package/dist/creek-table/hooks/useAutoWidthColumns.js +187 -0
- package/dist/creek-table/hooks/useAutoWidthColumns.js.map +7 -0
- package/dist/creek-table/hooks/useElementDistance.js +51 -39
- package/dist/creek-table/hooks/useElementDistance.js.map +7 -0
- package/dist/creek-table/hooks/useTableScrollHeight.d.ts +1 -0
- package/dist/creek-table/hooks/useTableScrollHeight.js +72 -0
- package/dist/creek-table/hooks/useTableScrollHeight.js.map +7 -0
- package/dist/creek-table/index.js +35 -25
- package/dist/creek-table/index.js.map +7 -0
- package/dist/creek-table/toolBarRender.d.ts +1 -0
- package/dist/creek-table/toolBarRender.js +55 -33
- package/dist/creek-table/toolBarRender.js.map +7 -0
- package/dist/creek-table/type.d.ts +1 -1
- package/dist/creek-table/type.js +18 -1
- package/dist/creek-table/type.js.map +7 -0
- package/dist/index.d.ts +1 -2
- package/dist/index.js +34 -7
- package/dist/index.js.map +7 -0
- package/package.json +2 -2
- package/src/creek-hooks/index.ts +2 -0
- package/src/creek-hooks/useApp/DrawerHelper.tsx +43 -0
- package/src/creek-hooks/useApp/ModalHelper.tsx +43 -0
- package/src/creek-hooks/useApp/index.tsx +119 -0
- package/src/creek-hooks/useApp/types.ts +25 -0
- package/src/creek-hooks/useViewportHeight.tsx +34 -5
- package/src/creek-layout/index.tsx +2 -2
- package/src/creek-table/SearchTable.tsx +69 -77
- package/src/creek-table/hooks/index.ts +3 -1
- package/src/creek-table/hooks/useAutoWidthColumns.tsx +212 -0
- package/src/creek-table/hooks/useTableScrollHeight.tsx +63 -0
- package/src/creek-table/index.tsx +2 -6
- package/src/creek-table/toolBarRender.tsx +3 -3
- package/src/creek-table/type.ts +1 -1
- package/src/index.tsx +2 -2
- package/dist/bg-center/index.d.ts +0 -5
- package/dist/bg-center/index.d.ts.map +0 -1
- package/dist/bg-center/index.js +0 -28
- package/dist/creek-config-provider/CreekConfigContext.d.ts.map +0 -1
- package/dist/creek-config-provider/index.d.ts.map +0 -1
- package/dist/creek-hooks/index.d.ts.map +0 -1
- package/dist/creek-hooks/useViewportHeight.d.ts.map +0 -1
- package/dist/creek-icon/index.d.ts.map +0 -1
- package/dist/creek-keep-alive/index.d.ts.map +0 -1
- package/dist/creek-layout/CollapseButton.d.ts.map +0 -1
- package/dist/creek-layout/Exception/NotFound.d.ts.map +0 -1
- package/dist/creek-layout/Exception/NotFoundPage.d.ts.map +0 -1
- package/dist/creek-layout/Exception/index.d.ts.map +0 -1
- package/dist/creek-layout/HeaderContent/FullScreen.d.ts.map +0 -1
- package/dist/creek-layout/HeaderContent/UserInfo.d.ts.map +0 -1
- package/dist/creek-layout/HeaderContent/index.d.ts.map +0 -1
- package/dist/creek-layout/index.d.ts.map +0 -1
- package/dist/creek-loading/index.d.ts.map +0 -1
- package/dist/creek-search/CreekSearch.d.ts +0 -7
- package/dist/creek-search/CreekSearch.d.ts.map +0 -1
- package/dist/creek-search/CreekSearch.js +0 -51
- package/dist/creek-search/CreekSearchContext.d.ts +0 -54
- package/dist/creek-search/CreekSearchContext.d.ts.map +0 -1
- package/dist/creek-search/CreekSearchContext.js +0 -546
- package/dist/creek-search/CreekSearchFilterDisplay.d.ts +0 -5
- package/dist/creek-search/CreekSearchFilterDisplay.d.ts.map +0 -1
- package/dist/creek-search/CreekSearchFilterDisplay.js +0 -97
- package/dist/creek-search/CreekSearchInput.d.ts +0 -4
- package/dist/creek-search/CreekSearchInput.d.ts.map +0 -1
- package/dist/creek-search/CreekSearchInput.js +0 -96
- package/dist/creek-search/CreekSearchValueSelector.d.ts +0 -5
- package/dist/creek-search/CreekSearchValueSelector.d.ts.map +0 -1
- package/dist/creek-search/CreekSearchValueSelector.js +0 -422
- package/dist/creek-search/index.d.ts +0 -5
- package/dist/creek-search/index.d.ts.map +0 -1
- package/dist/creek-search/index.js +0 -5
- package/dist/creek-search/type.d.ts +0 -8
- package/dist/creek-search/type.d.ts.map +0 -1
- package/dist/creek-search/type.js +0 -1
- package/dist/creek-table/SearchTable.d.ts.map +0 -1
- package/dist/creek-table/TableOptionRender.d.ts.map +0 -1
- package/dist/creek-table/TableViewContent.d.ts +0 -4
- package/dist/creek-table/TableViewContent.d.ts.map +0 -1
- package/dist/creek-table/TableViewContent.js +0 -47
- package/dist/creek-table/hooks/index.d.ts.map +0 -1
- package/dist/creek-table/hooks/useAdaptiveToolBar.d.ts.map +0 -1
- package/dist/creek-table/hooks/useAutoAddFilterToColumns.d.ts +0 -12
- package/dist/creek-table/hooks/useAutoAddFilterToColumns.d.ts.map +0 -1
- package/dist/creek-table/hooks/useAutoAddFilterToColumns.js +0 -96
- package/dist/creek-table/hooks/useElementDistance.d.ts.map +0 -1
- package/dist/creek-table/index.d.ts.map +0 -1
- package/dist/creek-table/toolBarRender.d.ts.map +0 -1
- package/dist/creek-table/type.d.ts.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/src/bg-center/index.tsx +0 -26
- package/src/creek-search/CreekSearch.tsx +0 -60
- package/src/creek-search/CreekSearchContext.tsx +0 -593
- package/src/creek-search/CreekSearchFilterDisplay.tsx +0 -84
- package/src/creek-search/CreekSearchInput.tsx +0 -75
- package/src/creek-search/CreekSearchValueSelector.tsx +0 -324
- package/src/creek-search/index.tsx +0 -5
- package/src/creek-search/type.ts +0 -9
- package/src/creek-table/TableViewContent.tsx +0 -46
- package/src/creek-table/hooks/useAutoAddFilterToColumns.tsx +0 -90
|
@@ -1,54 +1,44 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
_options$margin = options.margin,
|
|
19
|
-
margin = _options$margin === void 0 ? 0 : _options$margin,
|
|
20
|
-
_options$minHeight = options.minHeight,
|
|
21
|
-
minHeight = _options$minHeight === void 0 ? 0 : _options$minHeight,
|
|
22
|
-
maxHeight = options.maxHeight,
|
|
23
|
-
_options$debug = options.debug,
|
|
24
|
-
debug = _options$debug === void 0 ? false : _options$debug,
|
|
25
|
-
_options$debounceDela = options.debounceDelay,
|
|
26
|
-
debounceDelay = _options$debounceDela === void 0 ? 200 : _options$debounceDela,
|
|
27
|
-
_options$deps = options.deps,
|
|
28
|
-
deps = _options$deps === void 0 ? [] : _options$deps,
|
|
29
|
-
isObserverParent = options.isObserverParent;
|
|
30
|
-
var _useState = useState(undefined),
|
|
31
|
-
_useState2 = _slicedToArray(_useState, 2),
|
|
32
|
-
viewPortHeight = _useState2[0],
|
|
33
|
-
setHeight = _useState2[1];
|
|
34
|
-
var containerRef = useRef(null);
|
|
35
|
-
var resizeObserverRef = useRef(null);
|
|
36
|
-
var mutationObserverRef = useRef(null);
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
37
18
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
19
|
+
// src/creek-hooks/useViewportHeight.tsx
|
|
20
|
+
var useViewportHeight_exports = {};
|
|
21
|
+
__export(useViewportHeight_exports, {
|
|
22
|
+
useViewportHeight: () => useViewportHeight
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(useViewportHeight_exports);
|
|
25
|
+
var import_ahooks = require("ahooks");
|
|
26
|
+
var import_react = require("react");
|
|
27
|
+
var useViewportHeight = (options = {}) => {
|
|
28
|
+
const { bottomOffset = 0, topOffset, margin = 0, minHeight = 0, maxHeight, debug = false, debounceDelay = 500, deps = [], isObserverParent } = options;
|
|
29
|
+
const [viewPortHeight, setHeight] = (0, import_react.useState)(void 0);
|
|
30
|
+
let containerRef = (0, import_react.useRef)(null);
|
|
31
|
+
const resizeObserverRef = (0, import_react.useRef)(null);
|
|
32
|
+
const mutationObserverRef = (0, import_react.useRef)(null);
|
|
33
|
+
const lastHeightRef = (0, import_react.useRef)(window.innerHeight);
|
|
34
|
+
const calculateHeight = (0, import_ahooks.useMemoizedFn)(() => {
|
|
35
|
+
if (!containerRef.current)
|
|
36
|
+
return;
|
|
37
|
+
const container = containerRef.current;
|
|
38
|
+
const rect = container.getBoundingClientRect();
|
|
39
|
+
const calculatedTopOffset = topOffset ?? rect.top;
|
|
40
|
+
const viewportHeight = window.innerHeight;
|
|
41
|
+
let availableHeight = viewportHeight - calculatedTopOffset - bottomOffset - margin;
|
|
52
42
|
if (minHeight > 0) {
|
|
53
43
|
availableHeight = Math.max(availableHeight, minHeight);
|
|
54
44
|
}
|
|
@@ -56,53 +46,65 @@ export var useViewportHeight = function useViewportHeight() {
|
|
|
56
46
|
availableHeight = Math.min(availableHeight, maxHeight);
|
|
57
47
|
}
|
|
58
48
|
if (debug) {
|
|
59
|
-
console.log(
|
|
60
|
-
viewportHeight
|
|
61
|
-
calculatedTopOffset
|
|
62
|
-
bottomOffset
|
|
63
|
-
margin
|
|
64
|
-
minHeight
|
|
65
|
-
maxHeight
|
|
66
|
-
availableHeight
|
|
49
|
+
console.log("计算可视区域高度:", {
|
|
50
|
+
viewportHeight,
|
|
51
|
+
calculatedTopOffset,
|
|
52
|
+
bottomOffset,
|
|
53
|
+
margin,
|
|
54
|
+
minHeight,
|
|
55
|
+
maxHeight,
|
|
56
|
+
availableHeight,
|
|
67
57
|
containerRect: rect
|
|
68
58
|
});
|
|
69
59
|
}
|
|
70
60
|
setHeight(availableHeight);
|
|
71
61
|
});
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
useEventListener('resize', calculateHeight, {
|
|
75
|
-
target: function target() {
|
|
76
|
-
return window;
|
|
77
|
-
}
|
|
78
|
-
});
|
|
79
|
-
|
|
80
|
-
// 使用 useDebounceEffect 处理依赖项变化时的防抖计算
|
|
81
|
-
useDebounceEffect(function () {
|
|
82
|
-
if (containerRef.current) {
|
|
62
|
+
const { run: debouncedCalculateHeight } = (0, import_ahooks.useDebounceFn)(
|
|
63
|
+
() => {
|
|
83
64
|
calculateHeight();
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
65
|
+
},
|
|
66
|
+
{ wait: debounceDelay }
|
|
67
|
+
);
|
|
68
|
+
(0, import_ahooks.useEventListener)(
|
|
69
|
+
"resize",
|
|
70
|
+
() => {
|
|
71
|
+
const currentHeight = window.innerHeight;
|
|
72
|
+
if (Math.abs(currentHeight - lastHeightRef.current) > 1) {
|
|
73
|
+
lastHeightRef.current = currentHeight;
|
|
74
|
+
if (debounceDelay > 0) {
|
|
75
|
+
debouncedCalculateHeight();
|
|
76
|
+
} else {
|
|
77
|
+
calculateHeight();
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
},
|
|
81
|
+
{ target: () => window }
|
|
82
|
+
);
|
|
83
|
+
(0, import_ahooks.useDebounceEffect)(
|
|
84
|
+
() => {
|
|
85
|
+
if (containerRef.current) {
|
|
86
|
+
calculateHeight();
|
|
87
|
+
}
|
|
88
|
+
},
|
|
89
|
+
[...deps, topOffset, bottomOffset, margin, minHeight, maxHeight],
|
|
90
|
+
{ wait: debounceDelay }
|
|
91
|
+
);
|
|
92
|
+
(0, import_ahooks.useMount)(() => {
|
|
91
93
|
calculateHeight();
|
|
92
94
|
});
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
95
|
+
const setupObservers = (0, import_ahooks.useMemoizedFn)(() => {
|
|
96
|
+
if (!containerRef.current)
|
|
97
|
+
return;
|
|
98
|
+
const container = containerRef.current;
|
|
99
|
+
const observerParent = isObserverParent ? container.parentElement : container;
|
|
100
|
+
if (!observerParent)
|
|
101
|
+
return;
|
|
100
102
|
cleanupObservers();
|
|
101
|
-
resizeObserverRef.current = new ResizeObserver(
|
|
103
|
+
resizeObserverRef.current = new ResizeObserver(() => {
|
|
102
104
|
calculateHeight();
|
|
103
105
|
});
|
|
104
106
|
resizeObserverRef.current.observe(container);
|
|
105
|
-
mutationObserverRef.current = new MutationObserver(
|
|
107
|
+
mutationObserverRef.current = new MutationObserver(() => {
|
|
106
108
|
setTimeout(calculateHeight, 0);
|
|
107
109
|
});
|
|
108
110
|
mutationObserverRef.current.observe(observerParent, {
|
|
@@ -112,9 +114,7 @@ export var useViewportHeight = function useViewportHeight() {
|
|
|
112
114
|
attributes: false
|
|
113
115
|
});
|
|
114
116
|
});
|
|
115
|
-
|
|
116
|
-
// 清理观察器
|
|
117
|
-
var cleanupObservers = useMemoizedFn(function () {
|
|
117
|
+
const cleanupObservers = (0, import_ahooks.useMemoizedFn)(() => {
|
|
118
118
|
if (resizeObserverRef.current) {
|
|
119
119
|
resizeObserverRef.current.disconnect();
|
|
120
120
|
resizeObserverRef.current = null;
|
|
@@ -124,25 +124,27 @@ export var useViewportHeight = function useViewportHeight() {
|
|
|
124
124
|
mutationObserverRef.current = null;
|
|
125
125
|
}
|
|
126
126
|
});
|
|
127
|
-
|
|
128
|
-
// 组件卸载时清理
|
|
129
|
-
useUnmount(function () {
|
|
127
|
+
(0, import_ahooks.useUnmount)(() => {
|
|
130
128
|
cleanupObservers();
|
|
131
129
|
});
|
|
132
|
-
|
|
130
|
+
(0, import_ahooks.useDeepCompareEffect)(() => {
|
|
133
131
|
if (containerRef.current) {
|
|
134
132
|
setupObservers();
|
|
135
133
|
}
|
|
136
134
|
}, [containerRef.current]);
|
|
137
|
-
console.log(viewPortHeight, 'viewPortHeight');
|
|
138
135
|
return {
|
|
139
136
|
/** 容器引用,需要绑定到目标元素的容器 */
|
|
140
|
-
containerRef
|
|
137
|
+
containerRef,
|
|
141
138
|
/** 计算得出的可视区域高度 */
|
|
142
|
-
viewPortHeight
|
|
139
|
+
viewPortHeight,
|
|
143
140
|
/** 手动重新计算高度的方法 */
|
|
144
141
|
recalculate: calculateHeight,
|
|
145
142
|
/** 是否已完成高度计算 */
|
|
146
|
-
isCalculated: viewPortHeight !==
|
|
143
|
+
isCalculated: viewPortHeight !== void 0
|
|
147
144
|
};
|
|
148
|
-
};
|
|
145
|
+
};
|
|
146
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
147
|
+
0 && (module.exports = {
|
|
148
|
+
useViewportHeight
|
|
149
|
+
});
|
|
150
|
+
//# sourceMappingURL=useViewportHeight.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/creek-hooks/useViewportHeight.tsx"],
|
|
4
|
+
"sourcesContent": ["import { useDebounceEffect, useDebounceFn, useDeepCompareEffect, useEventListener, useMemoizedFn, useMount, useUnmount } from 'ahooks';\nimport { useRef, useState } from 'react';\n\ninterface UseViewportHeightOptions {\n /** 底部保留空间(如固定在底部的元素高度),默认 0 */\n bottomOffset?: number;\n /** 顶部保留空间,默认自动计算到容器顶部的距离 */\n topOffset?: number;\n /** 额外的边距,默认 0 */\n margin?: number;\n /** 最小高度,默认 0 */\n minHeight?: number;\n /** 最大高度,不设置则无限制 */\n maxHeight?: number;\n /** 是否启用调试模式,会在控制台输出计算信息 */\n debug?: boolean;\n /** 防抖延迟时间(毫秒),默认 16ms */\n debounceDelay?: number;\n /** 依赖项数组,当这些值变化时会重新计算高度(比如搜索条件) */\n deps?: React.DependencyList;\n\n isObserverParent?: boolean;\n}\n\nexport const useViewportHeight = (options: UseViewportHeightOptions = {}) => {\n const { bottomOffset = 0, topOffset, margin = 0, minHeight = 0, maxHeight, debug = false, debounceDelay = 500, deps = [], isObserverParent } = options;\n\n const [viewPortHeight, setHeight] = useState<number | undefined>(undefined);\n let containerRef = useRef<HTMLDivElement| null>(null);\n const resizeObserverRef = useRef<ResizeObserver | null>(null);\n const mutationObserverRef = useRef<MutationObserver | null>(null);\n const lastHeightRef = useRef<number>(window.innerHeight);\n\n // 使用 useMemoizedFn 缓存计算函数,避免不必要的重新创建\n const calculateHeight = useMemoizedFn(() => {\n if (!containerRef.current) return;\n\n const container = containerRef.current;\n const rect = container.getBoundingClientRect();\n\n // 计算顶部偏移量\n const calculatedTopOffset = topOffset ?? rect.top;\n\n // 计算可用高度\n const viewportHeight = window.innerHeight;\n let availableHeight = viewportHeight - calculatedTopOffset - bottomOffset - margin;\n\n // 应用最小/最大高度限制\n if (minHeight > 0) {\n availableHeight = Math.max(availableHeight, minHeight);\n }\n\n if (maxHeight && maxHeight > 0) {\n availableHeight = Math.min(availableHeight, maxHeight);\n }\n\n if (debug) {\n console.log('计算可视区域高度:', {\n viewportHeight,\n calculatedTopOffset,\n bottomOffset,\n margin,\n minHeight,\n maxHeight,\n availableHeight,\n containerRect: rect,\n });\n }\n\n setHeight(availableHeight);\n });\n\n const { run: debouncedCalculateHeight } = useDebounceFn(\n () => {\n calculateHeight();\n },\n { wait: debounceDelay },\n );\n\n // 使用 ahooks 的 useEventListener 监听窗口 resize 事件\n useEventListener(\n 'resize',\n () => {\n const currentHeight = window.innerHeight;\n // 只有高度发生变化时才重新计算\n if (Math.abs(currentHeight - lastHeightRef.current) > 1) {\n lastHeightRef.current = currentHeight;\n // 防抖调用 calculateHeight\n if (debounceDelay > 0) {\n // 清除之前的定时器(如果有)\n // 注意:这里需要一个 ref 来存储 timer,但为了简化,我们依赖 useDebounceEffect 的重新触发\n // 或者更直接地,我们可以在这里直接调用 debouncedCalculateHeight\n // 但由于 calculateHeight 本身是同步的,我们可以利用 ahooks 的 run 方法如果它是 useDebounceFn 返回的\n \n // 简单起见,我们在这里直接触发一个状态更新或者调用防抖函数\n // 由于 calculateHeight 被用在多个地方,我们给它包一层 debounce\n debouncedCalculateHeight();\n } else {\n calculateHeight();\n }\n }\n },\n { target: () => window },\n );\n\n // 使用 useDebounceEffect 处理依赖项变化时的防抖计算\n useDebounceEffect(\n () => {\n if (containerRef.current) {\n calculateHeight();\n }\n },\n [...deps, topOffset, bottomOffset, margin, minHeight, maxHeight],\n { wait: debounceDelay },\n );\n\n // 初始化计算\n useMount(() => {\n calculateHeight();\n });\n\n // 设置观察器\n const setupObservers = useMemoizedFn(() => {\n if (!containerRef.current) return;\n\n const container = containerRef.current;\n const observerParent = isObserverParent ? container.parentElement : container;\n\n if(!observerParent) return;\n\n cleanupObservers();\n\n resizeObserverRef.current = new ResizeObserver(() => {\n calculateHeight();\n });\n \n resizeObserverRef.current.observe(container);\n\n mutationObserverRef.current = new MutationObserver(() => {\n setTimeout(calculateHeight, 0);\n });\n\n mutationObserverRef.current.observe(observerParent, {\n childList: true,\n subtree: false, // 只监听直接子节点变化\n attributes: false,\n });\n });\n\n // 清理观察器\n const cleanupObservers = useMemoizedFn(() => {\n if (resizeObserverRef.current) {\n resizeObserverRef.current.disconnect();\n resizeObserverRef.current = null;\n }\n\n if (mutationObserverRef.current) {\n mutationObserverRef.current.disconnect();\n mutationObserverRef.current = null;\n }\n });\n\n\n // 组件卸载时清理\n useUnmount(() => {\n cleanupObservers();\n });\n\n useDeepCompareEffect(() => {\n if(containerRef.current) {\n setupObservers();\n }\n }, [containerRef.current])\n\n return {\n /** 容器引用,需要绑定到目标元素的容器 */\n containerRef,\n /** 计算得出的可视区域高度 */\n viewPortHeight,\n /** 手动重新计算高度的方法 */\n recalculate: calculateHeight,\n /** 是否已完成高度计算 */\n isCalculated: viewPortHeight !== undefined,\n };\n};\n"],
|
|
5
|
+
"mappings": "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",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
package/dist/creek-icon/index.js
CHANGED
|
@@ -1,37 +1,59 @@
|
|
|
1
|
-
|
|
2
|
-
var
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
+
mod
|
|
26
|
+
));
|
|
27
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
+
|
|
29
|
+
// src/creek-icon/index.tsx
|
|
30
|
+
var creek_icon_exports = {};
|
|
31
|
+
__export(creek_icon_exports, {
|
|
32
|
+
CreekIcon: () => CreekIcon
|
|
33
|
+
});
|
|
34
|
+
module.exports = __toCommonJS(creek_icon_exports);
|
|
35
|
+
var import_icons = __toESM(require("@ant-design/icons"));
|
|
36
|
+
var import_lodash = require("lodash");
|
|
37
|
+
var import_react = require("react");
|
|
38
|
+
var import_creek_config_provider = require("../creek-config-provider");
|
|
39
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
40
|
+
var CreekIcon = (props) => {
|
|
41
|
+
const { iconFontCNs: iconFontCNsContext } = (0, import_react.useContext)(import_creek_config_provider.CreekConfigProvider.CreekConfigContext);
|
|
42
|
+
const { component, type, iconFontCNs, ...more } = props;
|
|
43
|
+
const _iconFontCNs = iconFontCNs || iconFontCNsContext;
|
|
23
44
|
if (component) {
|
|
24
|
-
return
|
|
25
|
-
component: component
|
|
26
|
-
}, more));
|
|
45
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_icons.default, { component, ...more });
|
|
27
46
|
}
|
|
28
|
-
if (type && !isEmpty(_iconFontCNs)) {
|
|
29
|
-
|
|
47
|
+
if (type && !(0, import_lodash.isEmpty)(_iconFontCNs)) {
|
|
48
|
+
const IconFont = (0, import_icons.createFromIconfontCN)({
|
|
30
49
|
scriptUrl: _iconFontCNs
|
|
31
50
|
});
|
|
32
|
-
return
|
|
33
|
-
type: type
|
|
34
|
-
}, more));
|
|
51
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(IconFont, { type, ...more });
|
|
35
52
|
}
|
|
36
53
|
return null;
|
|
37
|
-
};
|
|
54
|
+
};
|
|
55
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
56
|
+
0 && (module.exports = {
|
|
57
|
+
CreekIcon
|
|
58
|
+
});
|
|
59
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/creek-icon/index.tsx"],
|
|
4
|
+
"sourcesContent": ["import Icon, { createFromIconfontCN } from '@ant-design/icons';\nimport type { GetProps } from 'antd';\nimport { isEmpty } from 'lodash';\nimport { useContext } from 'react';\n\nimport { CreekConfigProvider, CreekConfigProviderProps } from '../creek-config-provider';\n\ntype CustomIconComponentProps = GetProps<typeof Icon>;\n\nexport type CreekIconProps = CustomIconComponentProps & {\n iconFontCNs?: CreekConfigProviderProps['iconFontCNs'];\n type?: string;\n component?: CustomIconComponentProps['component'];\n};\n\nexport const CreekIcon = (props: CreekIconProps) => {\n const { iconFontCNs: iconFontCNsContext } = useContext(CreekConfigProvider.CreekConfigContext);\n const { component, type, iconFontCNs, ...more } = props;\n\n const _iconFontCNs = iconFontCNs || iconFontCNsContext;\n\n if (component) {\n return <Icon component={component} {...more} />;\n }\n\n if (type && !isEmpty(_iconFontCNs)) {\n const IconFont = createFromIconfontCN({\n scriptUrl: _iconFontCNs,\n });\n return <IconFont type={type} {...more} />;\n }\n\n return null;\n};\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAA2C;AAE3C,oBAAwB;AACxB,mBAA2B;AAE3B,mCAA8D;AAiBnD;AAPJ,IAAM,YAAY,CAAC,UAA0B;AAClD,QAAM,EAAE,aAAa,mBAAmB,QAAI,yBAAW,iDAAoB,kBAAkB;AAC7F,QAAM,EAAE,WAAW,MAAM,aAAa,GAAG,KAAK,IAAI;AAElD,QAAM,eAAe,eAAe;AAEpC,MAAI,WAAW;AACb,WAAO,4CAAC,aAAAA,SAAA,EAAK,WAAuB,GAAG,MAAM;AAAA,EAC/C;AAEA,MAAI,QAAQ,KAAC,uBAAQ,YAAY,GAAG;AAClC,UAAM,eAAW,mCAAqB;AAAA,MACpC,WAAW;AAAA,IACb,CAAC;AACD,WAAO,4CAAC,YAAS,MAAa,GAAG,MAAM;AAAA,EACzC;AAEA,SAAO;AACT;",
|
|
6
|
+
"names": ["Icon"]
|
|
7
|
+
}
|
|
@@ -1,20 +1,38 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
|
|
19
|
+
// src/creek-keep-alive/index.tsx
|
|
20
|
+
var creek_keep_alive_exports = {};
|
|
21
|
+
__export(creek_keep_alive_exports, {
|
|
22
|
+
CreekKeepAlive: () => CreekKeepAlive
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(creek_keep_alive_exports);
|
|
25
|
+
var import_react = require("react");
|
|
26
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
27
|
+
var CreekKeepAlive = () => {
|
|
28
|
+
const [isMounted, setIsMounted] = (0, import_react.useState)(false);
|
|
29
|
+
(0, import_react.useEffect)(() => {
|
|
15
30
|
setIsMounted(true);
|
|
16
31
|
}, []);
|
|
17
|
-
return
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
32
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { children: "KeepAlive" });
|
|
33
|
+
};
|
|
34
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
35
|
+
0 && (module.exports = {
|
|
36
|
+
CreekKeepAlive
|
|
37
|
+
});
|
|
38
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/creek-keep-alive/index.tsx"],
|
|
4
|
+
"sourcesContent": ["import { useEffect, useState } from 'react';\n\nexport const CreekKeepAlive = () => {\n const [isMounted, setIsMounted] = useState(false);\n\n useEffect(() => {\n setIsMounted(true);\n }, []);\n\n return <div>KeepAlive</div>;\n};"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAoC;AAS3B;AAPF,IAAM,iBAAiB,MAAM;AAClC,QAAM,CAAC,WAAW,YAAY,QAAI,uBAAS,KAAK;AAEhD,8BAAU,MAAM;AACd,iBAAa,IAAI;AAAA,EACnB,GAAG,CAAC,CAAC;AAEL,SAAO,4CAAC,SAAI,uBAAS;AACvB;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -1,59 +1,81 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
var
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
|
|
19
|
+
// src/creek-layout/CollapseButton.tsx
|
|
20
|
+
var CollapseButton_exports = {};
|
|
21
|
+
__export(CollapseButton_exports, {
|
|
22
|
+
CollapsedButton: () => CollapsedButton,
|
|
23
|
+
useCollapsedStore: () => useCollapsedStore
|
|
22
24
|
});
|
|
23
|
-
|
|
25
|
+
module.exports = __toCommonJS(CollapseButton_exports);
|
|
26
|
+
var import_icons = require("@ant-design/icons");
|
|
27
|
+
var import_antd_style = require("antd-style");
|
|
28
|
+
var import_react = require("react");
|
|
29
|
+
var import_zustand = require("zustand");
|
|
30
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
31
|
+
var useStyles = (0, import_antd_style.createStyles)(({ token }) => ({
|
|
32
|
+
buttonContainer: {
|
|
33
|
+
padding: token.padding
|
|
34
|
+
},
|
|
35
|
+
iconContainer: {
|
|
36
|
+
width: "24px",
|
|
37
|
+
height: "24px",
|
|
38
|
+
background: "#f3f3f3",
|
|
39
|
+
display: "flex",
|
|
40
|
+
alignItems: "center",
|
|
41
|
+
justifyContent: "center",
|
|
42
|
+
cursor: "pointer"
|
|
43
|
+
}
|
|
44
|
+
}));
|
|
45
|
+
var useCollapsedStore = (0, import_zustand.create)((set, get) => {
|
|
24
46
|
return {
|
|
25
47
|
collapsed: false,
|
|
26
|
-
changeCollapsed:
|
|
27
|
-
|
|
48
|
+
changeCollapsed: () => {
|
|
49
|
+
const _collapsed = get().collapsed;
|
|
28
50
|
set({
|
|
29
51
|
collapsed: !_collapsed
|
|
30
52
|
});
|
|
31
53
|
}
|
|
32
54
|
};
|
|
33
55
|
});
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
var _useCollapsedStore$ge = useCollapsedStore.getState(),
|
|
40
|
-
collapsed = _useCollapsedStore$ge.collapsed,
|
|
41
|
-
changeCollapsed = _useCollapsedStore$ge.changeCollapsed;
|
|
42
|
-
useEffect(function () {
|
|
56
|
+
var CollapsedButton = (props) => {
|
|
57
|
+
const { collapsed: defaultCollapsed = false } = props;
|
|
58
|
+
const { styles } = useStyles();
|
|
59
|
+
const { collapsed, changeCollapsed } = useCollapsedStore.getState();
|
|
60
|
+
(0, import_react.useEffect)(() => {
|
|
43
61
|
if (defaultCollapsed !== collapsed) {
|
|
44
|
-
useCollapsedStore.setState({
|
|
45
|
-
collapsed: defaultCollapsed
|
|
46
|
-
});
|
|
62
|
+
useCollapsedStore.setState({ collapsed: defaultCollapsed });
|
|
47
63
|
}
|
|
48
64
|
}, [defaultCollapsed]);
|
|
49
|
-
return
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
children: collapsed ?
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
};
|
|
65
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
66
|
+
"div",
|
|
67
|
+
{
|
|
68
|
+
className: styles.buttonContainer,
|
|
69
|
+
onClick: () => {
|
|
70
|
+
changeCollapsed();
|
|
71
|
+
},
|
|
72
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: styles.iconContainer, children: collapsed ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_icons.ArrowRightOutlined, {}) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_icons.ArrowLeftOutlined, {}) })
|
|
73
|
+
}
|
|
74
|
+
);
|
|
75
|
+
};
|
|
76
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
77
|
+
0 && (module.exports = {
|
|
78
|
+
CollapsedButton,
|
|
79
|
+
useCollapsedStore
|
|
80
|
+
});
|
|
81
|
+
//# sourceMappingURL=CollapseButton.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/creek-layout/CollapseButton.tsx"],
|
|
4
|
+
"sourcesContent": ["import { ArrowLeftOutlined, ArrowRightOutlined } from \"@ant-design/icons\";\nimport { createStyles } from \"antd-style\";\nimport { useEffect } from \"react\";\nimport { create } from \"zustand\";\n\nexport type CollapsedButtonProps = {\n collapsed?: boolean;\n};\n\nexport type CollapsedButtonStore = {\n collapsed: boolean;\n changeCollapsed: () => void;\n};\n\nconst useStyles = createStyles(({ token }) => ({\n buttonContainer: {\n padding: token.padding,\n },\n iconContainer: {\n width: \"24px\",\n height: \"24px\",\n background: \"#f3f3f3\",\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n cursor: \"pointer\",\n },\n}));\n\nexport const useCollapsedStore = create<CollapsedButtonStore>((set, get) => {\n return {\n collapsed: false,\n changeCollapsed: () => {\n const _collapsed = get().collapsed;\n set({\n collapsed: !_collapsed,\n });\n },\n };\n});\n\nexport const CollapsedButton = (props: CollapsedButtonProps) => {\n const { collapsed: defaultCollapsed = false } = props;\n const { styles } = useStyles();\n\n const { collapsed, changeCollapsed } = useCollapsedStore.getState();\n\n useEffect(() => {\n if (defaultCollapsed !== collapsed) {\n useCollapsedStore.setState({ collapsed: defaultCollapsed });\n }\n }, [defaultCollapsed]);\n\n return (\n <div\n className={styles.buttonContainer}\n onClick={() => {\n changeCollapsed();\n }}\n >\n <div className={styles.iconContainer}>\n {collapsed ? <ArrowRightOutlined /> : <ArrowLeftOutlined />}\n </div>\n </div>\n );\n};\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAsD;AACtD,wBAA6B;AAC7B,mBAA0B;AAC1B,qBAAuB;AA0DF;AA/CrB,IAAM,gBAAY,gCAAa,CAAC,EAAE,MAAM,OAAO;AAAA,EAC7C,iBAAiB;AAAA,IACf,SAAS,MAAM;AAAA,EACjB;AAAA,EACA,eAAe;AAAA,IACb,OAAO;AAAA,IACP,QAAQ;AAAA,IACR,YAAY;AAAA,IACZ,SAAS;AAAA,IACT,YAAY;AAAA,IACZ,gBAAgB;AAAA,IAChB,QAAQ;AAAA,EACV;AACF,EAAE;AAEK,IAAM,wBAAoB,uBAA6B,CAAC,KAAK,QAAQ;AAC1E,SAAO;AAAA,IACL,WAAW;AAAA,IACX,iBAAiB,MAAM;AACrB,YAAM,aAAa,IAAI,EAAE;AACzB,UAAI;AAAA,QACF,WAAW,CAAC;AAAA,MACd,CAAC;AAAA,IACH;AAAA,EACF;AACF,CAAC;AAEM,IAAM,kBAAkB,CAAC,UAAgC;AAC9D,QAAM,EAAE,WAAW,mBAAmB,MAAM,IAAI;AAChD,QAAM,EAAE,OAAO,IAAI,UAAU;AAE7B,QAAM,EAAE,WAAW,gBAAgB,IAAI,kBAAkB,SAAS;AAElE,8BAAU,MAAM;AACd,QAAI,qBAAqB,WAAW;AAClC,wBAAkB,SAAS,EAAE,WAAW,iBAAiB,CAAC;AAAA,IAC5D;AAAA,EACF,GAAG,CAAC,gBAAgB,CAAC;AAErB,SACE;AAAA,IAAC;AAAA;AAAA,MACC,WAAW,OAAO;AAAA,MAClB,SAAS,MAAM;AACb,wBAAgB;AAAA,MAClB;AAAA,MAEA,sDAAC,SAAI,WAAW,OAAO,eACpB,sBAAY,4CAAC,mCAAmB,IAAK,4CAAC,kCAAkB,GAC3D;AAAA;AAAA,EACF;AAEJ;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|