@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,58 +1,70 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
var
|
|
10
|
-
|
|
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-table/hooks/useElementDistance.tsx
|
|
20
|
+
var useElementDistance_exports = {};
|
|
21
|
+
__export(useElementDistance_exports, {
|
|
22
|
+
useElementDistance: () => useElementDistance
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(useElementDistance_exports);
|
|
25
|
+
var import_ahooks = require("ahooks");
|
|
26
|
+
var import_react = require("react");
|
|
27
|
+
var getElementCenter = (element) => {
|
|
28
|
+
const rect = element.getBoundingClientRect();
|
|
11
29
|
return {
|
|
12
30
|
left: rect.left,
|
|
13
31
|
width: rect.width
|
|
14
32
|
};
|
|
15
33
|
};
|
|
16
|
-
var calculateDistance =
|
|
17
|
-
|
|
18
|
-
return {
|
|
19
|
-
x: x
|
|
20
|
-
};
|
|
34
|
+
var calculateDistance = (pos1, pos2) => {
|
|
35
|
+
const x = Math.abs(pos2.left - pos1.left - pos1.width);
|
|
36
|
+
return { x };
|
|
21
37
|
};
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
var distanceRef = useLatest(distance);
|
|
28
|
-
var _useDebounceFn = useDebounceFn(function () {
|
|
38
|
+
var useElementDistance = (element1Ref, element2Ref) => {
|
|
39
|
+
const [distance, setDistance] = (0, import_react.useState)(null);
|
|
40
|
+
const distanceRef = (0, import_ahooks.useLatest)(distance);
|
|
41
|
+
const { run: calculateAndUpdateDistance } = (0, import_ahooks.useDebounceFn)(
|
|
42
|
+
() => {
|
|
29
43
|
if (!element1Ref.current || !element2Ref.current) {
|
|
30
44
|
if (distanceRef.current !== null) {
|
|
31
45
|
setDistance(null);
|
|
32
46
|
}
|
|
33
47
|
return;
|
|
34
48
|
}
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
// 只有当距离发生变化时才更新,避免不必要的重渲染
|
|
49
|
+
const pos1 = getElementCenter(element1Ref.current);
|
|
50
|
+
const pos2 = getElementCenter(element2Ref.current);
|
|
51
|
+
const newDistance = calculateDistance(pos1, pos2);
|
|
40
52
|
if (!distanceRef.current || distanceRef.current.x !== newDistance.x) {
|
|
41
53
|
setDistance(newDistance);
|
|
42
54
|
}
|
|
43
|
-
},
|
|
55
|
+
},
|
|
56
|
+
{
|
|
44
57
|
wait: 100
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
// 初始计算
|
|
49
|
-
useEffect(function () {
|
|
58
|
+
}
|
|
59
|
+
);
|
|
60
|
+
(0, import_react.useEffect)(() => {
|
|
50
61
|
calculateAndUpdateDistance();
|
|
51
62
|
}, [element1Ref, element2Ref]);
|
|
52
|
-
|
|
53
|
-
// 监听 window 的 resize 和 scroll 事件
|
|
54
|
-
useEventListener('resize', calculateAndUpdateDistance, {
|
|
55
|
-
target: window
|
|
56
|
-
});
|
|
63
|
+
(0, import_ahooks.useEventListener)("resize", calculateAndUpdateDistance, { target: window });
|
|
57
64
|
return distance;
|
|
58
|
-
};
|
|
65
|
+
};
|
|
66
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
67
|
+
0 && (module.exports = {
|
|
68
|
+
useElementDistance
|
|
69
|
+
});
|
|
70
|
+
//# sourceMappingURL=useElementDistance.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/creek-table/hooks/useElementDistance.tsx"],
|
|
4
|
+
"sourcesContent": ["import { useDebounceFn, useEventListener, useLatest } from 'ahooks';\nimport { useEffect, useState } from 'react';\n\ntype ElementRef = React.RefObject<HTMLElement>;\n\ninterface Position {\n left: number;\n width: number;\n}\n\ninterface Distance {\n x: number;\n}\n\nconst getElementCenter = (element: HTMLElement): Position => {\n const rect = element.getBoundingClientRect();\n return {\n left: rect.left,\n width: rect.width,\n };\n};\n\nconst calculateDistance = (pos1: Position, pos2: Position): Distance => {\n const x = Math.abs(pos2.left - pos1.left - pos1.width);\n return { x };\n};\n\nexport const useElementDistance = (element1Ref: ElementRef, element2Ref: ElementRef): Distance | null => {\n const [distance, setDistance] = useState<Distance | null>(null);\n const distanceRef = useLatest(distance);\n\n const { run: calculateAndUpdateDistance } = useDebounceFn(\n () => {\n if (!element1Ref.current || !element2Ref.current) {\n if (distanceRef.current !== null) {\n setDistance(null);\n }\n return;\n }\n\n const pos1 = getElementCenter(element1Ref.current);\n const pos2 = getElementCenter(element2Ref.current);\n const newDistance = calculateDistance(pos1, pos2);\n\n // 只有当距离发生变化时才更新,避免不必要的重渲染\n if (!distanceRef.current || distanceRef.current.x !== newDistance.x) {\n setDistance(newDistance);\n }\n },\n {\n wait: 100,\n },\n );\n\n // 初始计算\n useEffect(() => {\n calculateAndUpdateDistance();\n }, [element1Ref, element2Ref]);\n\n // 监听 window 的 resize 和 scroll 事件\n useEventListener('resize', calculateAndUpdateDistance, { target: window });\n\n return distance;\n};\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAA2D;AAC3D,mBAAoC;AAapC,IAAM,mBAAmB,CAAC,YAAmC;AAC3D,QAAM,OAAO,QAAQ,sBAAsB;AAC3C,SAAO;AAAA,IACL,MAAM,KAAK;AAAA,IACX,OAAO,KAAK;AAAA,EACd;AACF;AAEA,IAAM,oBAAoB,CAAC,MAAgB,SAA6B;AACtE,QAAM,IAAI,KAAK,IAAI,KAAK,OAAO,KAAK,OAAO,KAAK,KAAK;AACrD,SAAO,EAAE,EAAE;AACb;AAEO,IAAM,qBAAqB,CAAC,aAAyB,gBAA6C;AACvG,QAAM,CAAC,UAAU,WAAW,QAAI,uBAA0B,IAAI;AAC9D,QAAM,kBAAc,yBAAU,QAAQ;AAEtC,QAAM,EAAE,KAAK,2BAA2B,QAAI;AAAA,IAC1C,MAAM;AACJ,UAAI,CAAC,YAAY,WAAW,CAAC,YAAY,SAAS;AAChD,YAAI,YAAY,YAAY,MAAM;AAChC,sBAAY,IAAI;AAAA,QAClB;AACA;AAAA,MACF;AAEA,YAAM,OAAO,iBAAiB,YAAY,OAAO;AACjD,YAAM,OAAO,iBAAiB,YAAY,OAAO;AACjD,YAAM,cAAc,kBAAkB,MAAM,IAAI;AAGhD,UAAI,CAAC,YAAY,WAAW,YAAY,QAAQ,MAAM,YAAY,GAAG;AACnE,oBAAY,WAAW;AAAA,MACzB;AAAA,IACF;AAAA,IACA;AAAA,MACE,MAAM;AAAA,IACR;AAAA,EACF;AAGA,8BAAU,MAAM;AACd,+BAA2B;AAAA,EAC7B,GAAG,CAAC,aAAa,WAAW,CAAC;AAG7B,sCAAiB,UAAU,4BAA4B,EAAE,QAAQ,OAAO,CAAC;AAEzE,SAAO;AACT;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const useTableScrollHeight: (prefixCls: string, tableRef: React.RefObject<HTMLDivElement>, pageFixedBottom?: boolean, contentPadding?: number, offsetBottom?: number) => number | undefined;
|
|
@@ -0,0 +1,72 @@
|
|
|
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-table/hooks/useTableScrollHeight.tsx
|
|
20
|
+
var useTableScrollHeight_exports = {};
|
|
21
|
+
__export(useTableScrollHeight_exports, {
|
|
22
|
+
useTableScrollHeight: () => useTableScrollHeight
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(useTableScrollHeight_exports);
|
|
25
|
+
var import_ahooks = require("ahooks");
|
|
26
|
+
var import_react = require("react");
|
|
27
|
+
var useTableScrollHeight = (prefixCls, tableRef, pageFixedBottom = true, contentPadding = 16, offsetBottom = 16) => {
|
|
28
|
+
const [scrollY, setScrollY] = (0, import_react.useState)(void 0);
|
|
29
|
+
const { run: calcHeight } = (0, import_ahooks.useDebounceFn)(
|
|
30
|
+
() => {
|
|
31
|
+
if (!pageFixedBottom || !tableRef.current)
|
|
32
|
+
return;
|
|
33
|
+
const tableEl = tableRef.current;
|
|
34
|
+
const tableHeader = tableEl.querySelector(`.${prefixCls}-table-thead`);
|
|
35
|
+
const tableBody = tableEl.querySelector(`.${prefixCls}-table-body`);
|
|
36
|
+
let top = 0;
|
|
37
|
+
if (tableHeader) {
|
|
38
|
+
top = tableHeader.getBoundingClientRect().bottom;
|
|
39
|
+
} else if (tableBody) {
|
|
40
|
+
top = tableBody.getBoundingClientRect().top;
|
|
41
|
+
}
|
|
42
|
+
const windowHeight = window.innerHeight;
|
|
43
|
+
let height = windowHeight - top - contentPadding - offsetBottom;
|
|
44
|
+
const pagination = tableEl.querySelector(`.${prefixCls}-pagination`);
|
|
45
|
+
if (pagination) {
|
|
46
|
+
const paginationHeight = pagination.clientHeight;
|
|
47
|
+
const styles = window.getComputedStyle(pagination);
|
|
48
|
+
const totalPaginationMargin = parseFloat(styles.marginTop) + parseFloat(styles.marginBottom);
|
|
49
|
+
height = height - paginationHeight - totalPaginationMargin;
|
|
50
|
+
} else {
|
|
51
|
+
height = height - 40;
|
|
52
|
+
}
|
|
53
|
+
setScrollY(height);
|
|
54
|
+
},
|
|
55
|
+
{ wait: 100 }
|
|
56
|
+
);
|
|
57
|
+
(0, import_react.useEffect)(() => {
|
|
58
|
+
calcHeight();
|
|
59
|
+
const observer = new MutationObserver(calcHeight);
|
|
60
|
+
if (tableRef.current) {
|
|
61
|
+
observer.observe(tableRef.current, { childList: true, subtree: true });
|
|
62
|
+
}
|
|
63
|
+
return () => observer.disconnect();
|
|
64
|
+
}, [tableRef, pageFixedBottom, prefixCls]);
|
|
65
|
+
(0, import_ahooks.useEventListener)("resize", calcHeight);
|
|
66
|
+
return scrollY;
|
|
67
|
+
};
|
|
68
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
69
|
+
0 && (module.exports = {
|
|
70
|
+
useTableScrollHeight
|
|
71
|
+
});
|
|
72
|
+
//# sourceMappingURL=useTableScrollHeight.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/creek-table/hooks/useTableScrollHeight.tsx"],
|
|
4
|
+
"sourcesContent": ["import { useDebounceFn, useEventListener } from 'ahooks';\nimport { useEffect, useState } from 'react';\n\nexport const useTableScrollHeight = (prefixCls: string, tableRef: React.RefObject<HTMLDivElement>, pageFixedBottom: boolean = true, contentPadding: number = 16, offsetBottom: number = 16) => {\n const [scrollY, setScrollY] = useState<number | undefined>(undefined);\n\n const { run: calcHeight } = useDebounceFn(\n () => {\n if (!pageFixedBottom || !tableRef.current) return;\n\n const tableEl = tableRef.current;\n\n const tableHeader = tableEl.querySelector(`.${prefixCls}-table-thead`);\n const tableBody = tableEl.querySelector(`.${prefixCls}-table-body`);\n\n let top = 0;\n if (tableHeader) {\n top = tableHeader.getBoundingClientRect().bottom;\n } else if (tableBody) {\n top = tableBody.getBoundingClientRect().top;\n }\n\n const windowHeight = window.innerHeight;\n \n let height = windowHeight - top - contentPadding - offsetBottom;\n\n const pagination = tableEl.querySelector(`.${prefixCls}-pagination`);\n\n if (pagination) {\n const paginationHeight = pagination.clientHeight;\n\n const styles = window.getComputedStyle(pagination);\n const totalPaginationMargin = parseFloat(styles.marginTop) + parseFloat(styles.marginBottom);\n\n height = height - paginationHeight - totalPaginationMargin;\n } else {\n // 如果没有找到分页,预留一个高度(假设分页高度为 24px + margin 16px = 40px)\n // 这样可以避免初始加载时高度过大,导致出现滚动条,然后分页出现后高度又变小\n height = height - 40;\n }\n\n // Minimum height to avoid crashes or ugly rendering\n setScrollY(height);\n },\n { wait: 100 },\n );\n\n useEffect(() => {\n // Initial calculation\n calcHeight();\n\n // Observer for DOM changes that might affect position\n const observer = new MutationObserver(calcHeight);\n if (tableRef.current) {\n observer.observe(tableRef.current, { childList: true, subtree: true });\n }\n return () => observer.disconnect();\n }, [tableRef, pageFixedBottom, prefixCls]);\n\n useEventListener('resize', calcHeight);\n\n return scrollY;\n};\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAAgD;AAChD,mBAAoC;AAE7B,IAAM,uBAAuB,CAAC,WAAmB,UAA2C,kBAA2B,MAAM,iBAAyB,IAAI,eAAuB,OAAO;AAC7L,QAAM,CAAC,SAAS,UAAU,QAAI,uBAA6B,MAAS;AAEpE,QAAM,EAAE,KAAK,WAAW,QAAI;AAAA,IAC1B,MAAM;AACJ,UAAI,CAAC,mBAAmB,CAAC,SAAS;AAAS;AAE3C,YAAM,UAAU,SAAS;AAEzB,YAAM,cAAc,QAAQ,cAAc,IAAI,uBAAuB;AACrE,YAAM,YAAY,QAAQ,cAAc,IAAI,sBAAsB;AAElE,UAAI,MAAM;AACV,UAAI,aAAa;AACf,cAAM,YAAY,sBAAsB,EAAE;AAAA,MAC5C,WAAW,WAAW;AACpB,cAAM,UAAU,sBAAsB,EAAE;AAAA,MAC1C;AAEA,YAAM,eAAe,OAAO;AAE5B,UAAI,SAAS,eAAe,MAAO,iBAAiB;AAEpD,YAAM,aAAa,QAAQ,cAAc,IAAI,sBAAsB;AAEnE,UAAI,YAAY;AACd,cAAM,mBAAmB,WAAW;AAEpC,cAAM,SAAS,OAAO,iBAAiB,UAAU;AACjD,cAAM,wBAAwB,WAAW,OAAO,SAAS,IAAI,WAAW,OAAO,YAAY;AAE3F,iBAAS,SAAS,mBAAmB;AAAA,MACvC,OAAO;AAGL,iBAAS,SAAS;AAAA,MACpB;AAGA,iBAAW,MAAM;AAAA,IACnB;AAAA,IACA,EAAE,MAAM,IAAI;AAAA,EACd;AAEA,8BAAU,MAAM;AAEd,eAAW;AAGX,UAAM,WAAW,IAAI,iBAAiB,UAAU;AAChD,QAAI,SAAS,SAAS;AACpB,eAAS,QAAQ,SAAS,SAAS,EAAE,WAAW,MAAM,SAAS,KAAK,CAAC;AAAA,IACvE;AACA,WAAO,MAAM,SAAS,WAAW;AAAA,EACnC,GAAG,CAAC,UAAU,iBAAiB,SAAS,CAAC;AAEzC,sCAAiB,UAAU,UAAU;AAErC,SAAO;AACT;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -1,25 +1,35 @@
|
|
|
1
|
-
|
|
2
|
-
var
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
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-table/index.tsx
|
|
20
|
+
var creek_table_exports = {};
|
|
21
|
+
__export(creek_table_exports, {
|
|
22
|
+
CreekTable: () => CreekTable
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(creek_table_exports);
|
|
25
|
+
var import_SearchTable = require("./SearchTable");
|
|
26
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
27
|
+
var CreekTable = (props) => {
|
|
28
|
+
const { columns = [], ...restProps } = props;
|
|
29
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_SearchTable.SearchProTable, { columns, ...restProps });
|
|
30
|
+
};
|
|
31
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
32
|
+
0 && (module.exports = {
|
|
33
|
+
CreekTable
|
|
34
|
+
});
|
|
35
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/creek-table/index.tsx"],
|
|
4
|
+
"sourcesContent": ["import { ParamsType } from '@ant-design/pro-components';\n\nimport { SearchProTable } from './SearchTable';\nimport { CreekTableProps } from './type';\n\nexport const CreekTable = <T extends ParamsType, U extends ParamsType, ValueType = 'text'>(props: CreekTableProps<T, U, ValueType>) => {\n const { columns = [], ...restProps } = props;\n\n return (\n <SearchProTable columns={columns} {...restProps} />\n );\n};\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,yBAA+B;AAO1B;AAJE,IAAM,aAAa,CAAiE,UAA4C;AACrI,QAAM,EAAE,UAAU,CAAC,GAAI,GAAG,UAAU,IAAI;AAExC,SACG,4CAAC,qCAAe,SAAmB,GAAG,WAAW;AAEtD;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -1,36 +1,58 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
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-table/toolBarRender.tsx
|
|
20
|
+
var toolBarRender_exports = {};
|
|
21
|
+
__export(toolBarRender_exports, {
|
|
22
|
+
toolBarRender: () => toolBarRender
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(toolBarRender_exports);
|
|
25
|
+
var import_icons = require("@ant-design/icons");
|
|
26
|
+
var import_antd = require("antd");
|
|
27
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
28
|
+
var toolBarRender = (options) => {
|
|
29
|
+
var _a;
|
|
30
|
+
const { shouldCollapse, restProps, args = [] } = options;
|
|
31
|
+
const baseActions = ((_a = restProps.toolBarRender) == null ? void 0 : _a.call(restProps, ...args)) || [];
|
|
16
32
|
if (!shouldCollapse || baseActions.length <= 1) {
|
|
17
33
|
return baseActions;
|
|
18
34
|
}
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
key: index,
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
35
|
+
const [first, ...rest] = baseActions;
|
|
36
|
+
return [
|
|
37
|
+
first,
|
|
38
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
39
|
+
import_antd.Dropdown,
|
|
40
|
+
{
|
|
41
|
+
menu: {
|
|
42
|
+
items: rest.map((item, index) => ({ key: index, label: item }))
|
|
43
|
+
},
|
|
44
|
+
trigger: ["click"],
|
|
45
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_antd.Button, { children: [
|
|
46
|
+
"更多 ",
|
|
47
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_icons.DownOutlined, {})
|
|
48
|
+
] })
|
|
49
|
+
},
|
|
50
|
+
"more"
|
|
51
|
+
)
|
|
52
|
+
];
|
|
53
|
+
};
|
|
54
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
55
|
+
0 && (module.exports = {
|
|
56
|
+
toolBarRender
|
|
57
|
+
});
|
|
58
|
+
//# sourceMappingURL=toolBarRender.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/creek-table/toolBarRender.tsx"],
|
|
4
|
+
"sourcesContent": ["import { DownOutlined } from '@ant-design/icons';\nimport { Button, Dropdown } from 'antd';\n\nexport const toolBarRender = (options: { shouldCollapse: boolean; restProps: any; args?: any[] }) => {\n const { shouldCollapse, restProps, args = [] } = options;\n\n const baseActions = restProps.toolBarRender?.(...args) || [];\n if (!shouldCollapse || baseActions.length <= 1) {\n return baseActions;\n }\n\n const [first, ...rest] = baseActions;\n\n return [\n first,\n <Dropdown\n key=\"more\"\n menu={{\n items: rest.map((item: React.ReactDOM, index: number) => ({ key: index, label: item })),\n }}\n trigger={['click']}\n >\n <Button>\n 更多 <DownOutlined />\n </Button>\n </Dropdown>,\n ];\n};\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAA6B;AAC7B,kBAAiC;AAqB3B;AAnBC,IAAM,gBAAgB,CAAC,YAAuE;AAHrG;AAIE,QAAM,EAAE,gBAAgB,WAAW,OAAO,CAAC,EAAE,IAAI;AAEjD,QAAM,gBAAc,eAAU,kBAAV,mCAA0B,GAAG,UAAS,CAAC;AAC3D,MAAI,CAAC,kBAAkB,YAAY,UAAU,GAAG;AAC9C,WAAO;AAAA,EACT;AAEA,QAAM,CAAC,OAAO,GAAG,IAAI,IAAI;AAEzB,SAAO;AAAA,IACL;AAAA,IACA;AAAA,MAAC;AAAA;AAAA,QAEC,MAAM;AAAA,UACJ,OAAO,KAAK,IAAI,CAAC,MAAsB,WAAmB,EAAE,KAAK,OAAO,OAAO,KAAK,EAAE;AAAA,QACxF;AAAA,QACA,SAAS,CAAC,OAAO;AAAA,QAEjB,uDAAC,sBAAO;AAAA;AAAA,UACH,4CAAC,6BAAa;AAAA,WACnB;AAAA;AAAA,MARI;AAAA,IASN;AAAA,EACF;AACF;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -5,7 +5,7 @@ export type OptionRenderCustom = {
|
|
|
5
5
|
icon?: React.ReactNode;
|
|
6
6
|
onClick?: () => void;
|
|
7
7
|
};
|
|
8
|
-
export type CreekTableProps<T extends ParamsType, U extends ParamsType, ValueType = 'text'> = Omit<ProTableProps<T, U, ValueType>, '
|
|
8
|
+
export type CreekTableProps<T extends ParamsType, U extends ParamsType, ValueType = 'text'> = Omit<ProTableProps<T, U, ValueType>, 'options'> & {
|
|
9
9
|
pageFixedBottom?: boolean;
|
|
10
10
|
pageFixedBottomConfig?: {
|
|
11
11
|
/** 底部保留空间(如固定在底部的元素高度),默认 0 */
|
package/dist/creek-table/type.js
CHANGED
|
@@ -1 +1,18 @@
|
|
|
1
|
-
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __copyProps = (to, from, except, desc) => {
|
|
6
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
7
|
+
for (let key of __getOwnPropNames(from))
|
|
8
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
9
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
10
|
+
}
|
|
11
|
+
return to;
|
|
12
|
+
};
|
|
13
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
14
|
+
|
|
15
|
+
// src/creek-table/type.ts
|
|
16
|
+
var type_exports = {};
|
|
17
|
+
module.exports = __toCommonJS(type_exports);
|
|
18
|
+
//# sourceMappingURL=type.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/creek-table/type.ts"],
|
|
4
|
+
"sourcesContent": ["import { ParamsType, ProTableProps } from '@ant-design/pro-components';\n\nexport type OptionRenderCustom = {\n text?: string;\n icon?: React.ReactNode;\n onClick?: () => void;\n};\n\nexport type CreekTableProps<T extends ParamsType, U extends ParamsType, ValueType = 'text'> = Omit<ProTableProps<T, U, ValueType>, 'options'> & {\n pageFixedBottom?: boolean; // 是否固定分页在底部\n pageFixedBottomConfig?: {\n /** 底部保留空间(如固定在底部的元素高度),默认 0 */\n bottomFix?: number;\n };\n options?: ProTableProps<T, U, ValueType>['options'] & {\n importConfig?: OptionRenderCustom;\n exportConfig?: OptionRenderCustom;\n };\n // 是否自动为列添加筛选功能,默认 true\n autoAddFilterForColumn?: boolean;\n};\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;AAAA;AAAA;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
export * from './bg-center';
|
|
2
1
|
export * from './creek-config-provider';
|
|
2
|
+
export * from './creek-hooks';
|
|
3
3
|
export * from './creek-icon';
|
|
4
4
|
export * from './creek-layout';
|
|
5
5
|
export * from './creek-loading';
|
|
6
|
-
export * from './creek-search';
|
|
7
6
|
export * from './creek-table';
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,34 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __copyProps = (to, from, except, desc) => {
|
|
6
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
7
|
+
for (let key of __getOwnPropNames(from))
|
|
8
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
9
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
10
|
+
}
|
|
11
|
+
return to;
|
|
12
|
+
};
|
|
13
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
14
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
15
|
+
|
|
16
|
+
// src/index.tsx
|
|
17
|
+
var src_exports = {};
|
|
18
|
+
module.exports = __toCommonJS(src_exports);
|
|
19
|
+
__reExport(src_exports, require("./creek-config-provider"), module.exports);
|
|
20
|
+
__reExport(src_exports, require("./creek-hooks"), module.exports);
|
|
21
|
+
__reExport(src_exports, require("./creek-icon"), module.exports);
|
|
22
|
+
__reExport(src_exports, require("./creek-layout"), module.exports);
|
|
23
|
+
__reExport(src_exports, require("./creek-loading"), module.exports);
|
|
24
|
+
__reExport(src_exports, require("./creek-table"), module.exports);
|
|
25
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
26
|
+
0 && (module.exports = {
|
|
27
|
+
...require("./creek-config-provider"),
|
|
28
|
+
...require("./creek-hooks"),
|
|
29
|
+
...require("./creek-icon"),
|
|
30
|
+
...require("./creek-layout"),
|
|
31
|
+
...require("./creek-loading"),
|
|
32
|
+
...require("./creek-table")
|
|
33
|
+
});
|
|
34
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/index.tsx"],
|
|
4
|
+
"sourcesContent": ["\nexport * from './creek-config-provider';\nexport * from './creek-hooks';\nexport * from './creek-icon';\nexport * from './creek-layout';\nexport * from './creek-loading';\nexport * from './creek-table';\n\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;AAAA;AAAA;AACA,wBAAc,oCADd;AAEA,wBAAc,0BAFd;AAGA,wBAAc,yBAHd;AAIA,wBAAc,2BAJd;AAKA,wBAAc,4BALd;AAMA,wBAAc,0BANd;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@creekjs/web-components",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.4",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"father:build": "father build",
|
|
8
|
-
"father:dev": "father dev"
|
|
8
|
+
"father:dev": "father dev --no-clean"
|
|
9
9
|
},
|
|
10
10
|
"keywords": [],
|
|
11
11
|
"author": "",
|
package/src/creek-hooks/index.ts
CHANGED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { DrawerForm } from '@ant-design/pro-components';
|
|
2
|
+
import { Drawer } from 'antd';
|
|
3
|
+
import { omit } from 'lodash';
|
|
4
|
+
import React from 'react';
|
|
5
|
+
import { DrawerConfig, FormDrawerConfig, NormalDrawerConfig } from './types';
|
|
6
|
+
|
|
7
|
+
interface DrawerHelperProps {
|
|
8
|
+
open: boolean;
|
|
9
|
+
config: DrawerConfig;
|
|
10
|
+
onClose: () => void;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export const DrawerHelper: React.FC<DrawerHelperProps> = ({ open, config, onClose }) => {
|
|
14
|
+
const { content, type, ...restConfig } = config;
|
|
15
|
+
|
|
16
|
+
if (type === 'form') {
|
|
17
|
+
return (
|
|
18
|
+
<DrawerForm
|
|
19
|
+
open={open}
|
|
20
|
+
onOpenChange={(visible) => !visible && onClose()}
|
|
21
|
+
drawerProps={{
|
|
22
|
+
destroyOnHidden: true,
|
|
23
|
+
onClose,
|
|
24
|
+
...((config as FormDrawerConfig).drawerProps || {}),
|
|
25
|
+
}}
|
|
26
|
+
{...(omit(restConfig, 'drawerProps') as any)}
|
|
27
|
+
>
|
|
28
|
+
{content}
|
|
29
|
+
</DrawerForm>
|
|
30
|
+
);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
return (
|
|
34
|
+
<Drawer
|
|
35
|
+
open={open}
|
|
36
|
+
onClose={onClose}
|
|
37
|
+
destroyOnHidden
|
|
38
|
+
{...(restConfig as NormalDrawerConfig)}
|
|
39
|
+
>
|
|
40
|
+
{content}
|
|
41
|
+
</Drawer>
|
|
42
|
+
);
|
|
43
|
+
};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { ModalForm } from '@ant-design/pro-components';
|
|
2
|
+
import { Modal } from 'antd';
|
|
3
|
+
import { omit } from 'lodash';
|
|
4
|
+
import React from 'react';
|
|
5
|
+
import { FormModalConfig, ModalConfig, NormalModalConfig } from './types';
|
|
6
|
+
|
|
7
|
+
interface ModalHelperProps {
|
|
8
|
+
open: boolean;
|
|
9
|
+
config: ModalConfig;
|
|
10
|
+
onClose: () => void;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export const ModalHelper: React.FC<ModalHelperProps> = ({ open, config, onClose }) => {
|
|
14
|
+
const { content, type, ...restConfig } = config;
|
|
15
|
+
|
|
16
|
+
if (type === 'form') {
|
|
17
|
+
return (
|
|
18
|
+
<ModalForm
|
|
19
|
+
open={open}
|
|
20
|
+
onOpenChange={(visible) => !visible && onClose()}
|
|
21
|
+
modalProps={{
|
|
22
|
+
destroyOnHidden: true,
|
|
23
|
+
onCancel: onClose,
|
|
24
|
+
...((config as FormModalConfig).modalProps || {}),
|
|
25
|
+
}}
|
|
26
|
+
{...(omit(restConfig, 'modalProps') as any)}
|
|
27
|
+
>
|
|
28
|
+
{content}
|
|
29
|
+
</ModalForm>
|
|
30
|
+
);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
return (
|
|
34
|
+
<Modal
|
|
35
|
+
open={open}
|
|
36
|
+
onCancel={onClose}
|
|
37
|
+
destroyOnHidden
|
|
38
|
+
{...(restConfig as NormalModalConfig)}
|
|
39
|
+
>
|
|
40
|
+
{content}
|
|
41
|
+
</Modal>
|
|
42
|
+
);
|
|
43
|
+
};
|