@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,65 +1,74 @@
|
|
|
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-table/TableOptionRender.tsx
|
|
20
|
+
var TableOptionRender_exports = {};
|
|
21
|
+
__export(TableOptionRender_exports, {
|
|
22
|
+
TableOptionRender: () => TableOptionRender
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(TableOptionRender_exports);
|
|
25
|
+
var import_icons = require("@ant-design/icons");
|
|
26
|
+
var import_antd = require("antd");
|
|
27
|
+
var import_antd_style = require("antd-style");
|
|
28
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
29
|
+
var useStyles = (0, import_antd_style.createStyles)(({ prefixCls, token }) => {
|
|
15
30
|
return {
|
|
16
|
-
|
|
17
|
-
border:
|
|
31
|
+
"table-option-render-item": {
|
|
32
|
+
border: `1px solid ${token.colorBorder}`,
|
|
18
33
|
borderRadius: token.borderRadius,
|
|
19
|
-
padding:
|
|
20
|
-
cursor:
|
|
34
|
+
padding: "8px",
|
|
35
|
+
cursor: "pointer"
|
|
21
36
|
}
|
|
22
37
|
};
|
|
23
38
|
});
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
}), /*#__PURE__*/_jsx("span", {
|
|
61
|
-
className: styles['table-option-render-item'],
|
|
62
|
-
children: setting
|
|
63
|
-
})]
|
|
64
|
-
});
|
|
65
|
-
};
|
|
39
|
+
var TableOptionRender = (props) => {
|
|
40
|
+
const { defaultDom, importConfig, exportConfig } = props;
|
|
41
|
+
const { styles } = useStyles();
|
|
42
|
+
const [reload, dis, setting] = defaultDom || [];
|
|
43
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_antd.Space, { size: 8, children: [
|
|
44
|
+
importConfig && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
45
|
+
"span",
|
|
46
|
+
{
|
|
47
|
+
className: styles["table-option-render-item"],
|
|
48
|
+
onClick: () => {
|
|
49
|
+
var _a;
|
|
50
|
+
(_a = importConfig.onClick) == null ? void 0 : _a.call(importConfig);
|
|
51
|
+
},
|
|
52
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd.Tooltip, { title: importConfig.text || "导入", children: importConfig.icon || /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_icons.ImportOutlined, {}) })
|
|
53
|
+
}
|
|
54
|
+
),
|
|
55
|
+
exportConfig && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
56
|
+
"span",
|
|
57
|
+
{
|
|
58
|
+
className: styles["table-option-render-item"],
|
|
59
|
+
onClick: () => {
|
|
60
|
+
var _a;
|
|
61
|
+
(_a = exportConfig.onClick) == null ? void 0 : _a.call(exportConfig);
|
|
62
|
+
},
|
|
63
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd.Tooltip, { title: exportConfig.text || "导出", children: exportConfig.icon || /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_icons.ExportOutlined, {}) })
|
|
64
|
+
}
|
|
65
|
+
),
|
|
66
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: styles["table-option-render-item"], children: reload }),
|
|
67
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: styles["table-option-render-item"], children: setting })
|
|
68
|
+
] });
|
|
69
|
+
};
|
|
70
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
71
|
+
0 && (module.exports = {
|
|
72
|
+
TableOptionRender
|
|
73
|
+
});
|
|
74
|
+
//# sourceMappingURL=TableOptionRender.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/creek-table/TableOptionRender.tsx"],
|
|
4
|
+
"sourcesContent": ["import { ExportOutlined, ImportOutlined } from '@ant-design/icons';\nimport { ParamsType } from '@ant-design/pro-components';\nimport { Space, Tooltip } from 'antd';\nimport { createStyles } from 'antd-style';\n\nimport { OptionRenderCustom } from './type';\n\nconst useStyles = createStyles(({ prefixCls, token }) => {\n return {\n 'table-option-render-item': {\n border: `1px solid ${token.colorBorder}`,\n borderRadius: token.borderRadius,\n padding: '8px',\n cursor: 'pointer',\n },\n };\n});\n\nexport type TableOptionRenderProps<T extends ParamsType, U extends ParamsType, ValueType = 'text'> = {\n defaultDom?: React.ReactNode[];\n importConfig?: OptionRenderCustom;\n exportConfig?: OptionRenderCustom;\n};\n\nexport const TableOptionRender = <T extends ParamsType, U extends ParamsType, ValueType = 'text'>(props: TableOptionRenderProps<T, U, ValueType>) => {\n const { defaultDom, importConfig, exportConfig } = props;\n\n const { styles } = useStyles();\n\n const [reload, dis, setting] = defaultDom || [];\n return (\n <Space size={8}>\n {importConfig && (\n <span\n className={styles['table-option-render-item']}\n onClick={() => {\n importConfig.onClick?.();\n }}\n >\n <Tooltip title={importConfig.text || '导入'}>{importConfig.icon || <ImportOutlined />}</Tooltip>\n </span>\n )}\n {exportConfig && (\n <span\n className={styles['table-option-render-item']}\n onClick={() => {\n exportConfig.onClick?.();\n }}\n >\n <Tooltip title={exportConfig.text || '导出'}>{exportConfig.icon || <ExportOutlined />}</Tooltip>\n </span>\n )}\n <span className={styles['table-option-render-item']}>{reload}</span>\n <span className={styles['table-option-render-item']}>{setting}</span>\n </Space>\n );\n};\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAA+C;AAE/C,kBAA+B;AAC/B,wBAA6B;AA4BzB;AAxBJ,IAAM,gBAAY,gCAAa,CAAC,EA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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/creek-table/hooks/index.ts
|
|
17
|
+
var hooks_exports = {};
|
|
18
|
+
module.exports = __toCommonJS(hooks_exports);
|
|
19
|
+
__reExport(hooks_exports, require("./useAdaptiveToolBar"), module.exports);
|
|
20
|
+
__reExport(hooks_exports, require("./useAutoWidthColumns"), module.exports);
|
|
21
|
+
__reExport(hooks_exports, require("./useElementDistance"), module.exports);
|
|
22
|
+
__reExport(hooks_exports, require("./useTableScrollHeight"), module.exports);
|
|
23
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
24
|
+
0 && (module.exports = {
|
|
25
|
+
...require("./useAdaptiveToolBar"),
|
|
26
|
+
...require("./useAutoWidthColumns"),
|
|
27
|
+
...require("./useElementDistance"),
|
|
28
|
+
...require("./useTableScrollHeight")
|
|
29
|
+
});
|
|
30
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/creek-table/hooks/index.ts"],
|
|
4
|
+
"sourcesContent": ["export * from './useAdaptiveToolBar';\nexport * from './useAutoWidthColumns';\nexport * from './useElementDistance';\nexport * from './useTableScrollHeight';\n\n\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;AAAA;AAAA;AAAA,0BAAc,iCAAd;AACA,0BAAc,kCADd;AAEA,0BAAc,iCAFd;AAGA,0BAAc,mCAHd;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -1,48 +1,60 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
_options$minLeftDista = options.minLeftDistance,
|
|
19
|
-
minLeftDistance = _options$minLeftDista === void 0 ? 48 : _options$minLeftDista,
|
|
20
|
-
_options$hysteresis = options.hysteresis,
|
|
21
|
-
hysteresis = _options$hysteresis === void 0 ? 36 : _options$hysteresis;
|
|
22
|
-
useEffect(function () {
|
|
23
|
-
var _containerRef$current, _containerRef$current2;
|
|
24
|
-
element1Ref.current = (containerRef === null || containerRef === void 0 || (_containerRef$current = containerRef.current) === null || _containerRef$current === void 0 ? void 0 : _containerRef$current.querySelector(".".concat(prefixCls, "-pro-table-list-toolbar-left"))) || null;
|
|
25
|
-
element2Ref.current = (containerRef === null || containerRef === void 0 || (_containerRef$current2 = containerRef.current) === null || _containerRef$current2 === void 0 || (_containerRef$current2 = _containerRef$current2.querySelector(".".concat(prefixCls, "-pro-table-list-toolbar-right"))) === null || _containerRef$current2 === void 0 ? void 0 : _containerRef$current2.querySelector('div')) || null;
|
|
26
|
-
});
|
|
27
|
-
var distance = useElementDistance(element1Ref, element2Ref);
|
|
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);
|
|
28
18
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
19
|
+
// src/creek-table/hooks/useAdaptiveToolBar.tsx
|
|
20
|
+
var useAdaptiveToolBar_exports = {};
|
|
21
|
+
__export(useAdaptiveToolBar_exports, {
|
|
22
|
+
useAdaptiveToolBar: () => useAdaptiveToolBar
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(useAdaptiveToolBar_exports);
|
|
25
|
+
var import_react = require("react");
|
|
26
|
+
var import_useElementDistance = require("./useElementDistance");
|
|
27
|
+
var useAdaptiveToolBar = (options) => {
|
|
28
|
+
const element1Ref = (0, import_react.useRef)(null);
|
|
29
|
+
const element2Ref = (0, import_react.useRef)(null);
|
|
30
|
+
const [shouldCollapse, setShouldCollapse] = (0, import_react.useState)(false);
|
|
31
|
+
const { containerRef, prefixCls, minLeftDistance = 48, hysteresis = 36 } = options;
|
|
32
|
+
(0, import_react.useEffect)(() => {
|
|
33
|
+
var _a, _b, _c;
|
|
34
|
+
element1Ref.current = ((_a = containerRef == null ? void 0 : containerRef.current) == null ? void 0 : _a.querySelector(`.${prefixCls}-pro-table-list-toolbar-left`)) || null;
|
|
35
|
+
element2Ref.current = ((_c = (_b = containerRef == null ? void 0 : containerRef.current) == null ? void 0 : _b.querySelector(`.${prefixCls}-pro-table-list-toolbar-right`)) == null ? void 0 : _c.querySelector("div")) || null;
|
|
36
|
+
});
|
|
37
|
+
const distance = (0, import_useElementDistance.useElementDistance)(element1Ref, element2Ref);
|
|
38
|
+
(0, import_react.useEffect)(() => {
|
|
39
|
+
if (!(distance == null ? void 0 : distance.x))
|
|
40
|
+
return;
|
|
41
|
+
const currentDistance = distance.x;
|
|
33
42
|
if (shouldCollapse) {
|
|
34
|
-
// 当前是折叠状态,需要距离足够大才展开
|
|
35
43
|
if (currentDistance > minLeftDistance + hysteresis) {
|
|
36
44
|
setShouldCollapse(false);
|
|
37
45
|
}
|
|
38
46
|
} else {
|
|
39
|
-
// 当前是展开状态,距离小于阈值时折叠
|
|
40
47
|
if (currentDistance < minLeftDistance) {
|
|
41
48
|
setShouldCollapse(true);
|
|
42
49
|
}
|
|
43
50
|
}
|
|
44
|
-
}, [distance
|
|
51
|
+
}, [distance == null ? void 0 : distance.x, minLeftDistance, hysteresis, shouldCollapse]);
|
|
45
52
|
return {
|
|
46
|
-
shouldCollapse
|
|
53
|
+
shouldCollapse
|
|
47
54
|
};
|
|
48
|
-
};
|
|
55
|
+
};
|
|
56
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
57
|
+
0 && (module.exports = {
|
|
58
|
+
useAdaptiveToolBar
|
|
59
|
+
});
|
|
60
|
+
//# sourceMappingURL=useAdaptiveToolBar.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/creek-table/hooks/useAdaptiveToolBar.tsx"],
|
|
4
|
+
"sourcesContent": ["import { MutableRefObject, useEffect, useRef, useState } from 'react';\nimport { useElementDistance } from './useElementDistance';\n\nexport const useAdaptiveToolBar = (options: {\n containerRef: MutableRefObject<HTMLElement | null>;\n prefixCls: string;\n minLeftDistance?: number;\n hysteresis?: number; // 滞回差值\n}) => {\n const element1Ref = useRef<HTMLElement>(null) as MutableRefObject<HTMLElement | null>;\n const element2Ref = useRef<HTMLElement>(null) as MutableRefObject<HTMLElement | null>;\n const [shouldCollapse, setShouldCollapse] = useState(false);\n\n const { containerRef, prefixCls, minLeftDistance = 48, hysteresis = 36 } = options;\n\n useEffect(() => {\n element1Ref.current = containerRef?.current?.querySelector(`.${prefixCls}-pro-table-list-toolbar-left`) || null;\n element2Ref.current = containerRef?.current?.querySelector(`.${prefixCls}-pro-table-list-toolbar-right`)?.querySelector('div') || null;\n });\n\n const distance = useElementDistance(element1Ref, element2Ref);\n\n // 方案一:使用滞回逻辑防止震荡\n useEffect(() => {\n if (!distance?.x) return;\n\n const currentDistance = distance.x;\n\n if (shouldCollapse) {\n // 当前是折叠状态,需要距离足够大才展开\n if (currentDistance > minLeftDistance + hysteresis) {\n setShouldCollapse(false);\n }\n } else {\n // 当前是展开状态,距离小于阈值时折叠\n if (currentDistance < minLeftDistance) {\n setShouldCollapse(true);\n }\n }\n }, [distance?.x, minLeftDistance, hysteresis, shouldCollapse]);\n\n return {\n shouldCollapse,\n };\n};\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAA8D;AAC9D,gCAAmC;AAE5B,IAAM,qBAAqB,CAAC,YAK7B;AACJ,QAAM,kBAAc,qBAAoB,IAAI;AAC5C,QAAM,kBAAc,qBAAoB,IAAI;AAC5C,QAAM,CAAC,gBAAgB,iBAAiB,QAAI,uBAAS,KAAK;AAE1D,QAAM,EAAE,cAAc,WAAW,kBAAkB,IAAI,aAAa,GAAG,IAAI;AAE3E,8BAAU,MAAM;AAflB;AAgBI,gBAAY,YAAU,kDAAc,YAAd,mBAAuB,cAAc,IAAI,6CAA4C;AAC3G,gBAAY,YAAU,wDAAc,YAAd,mBAAuB,cAAc,IAAI,8CAAzC,mBAAoF,cAAc,WAAU;AAAA,EACpI,CAAC;AAED,QAAM,eAAW,8CAAmB,aAAa,WAAW;AAG5D,8BAAU,MAAM;AACd,QAAI,EAAC,qCAAU;AAAG;AAElB,UAAM,kBAAkB,SAAS;AAEjC,QAAI,gBAAgB;AAElB,UAAI,kBAAkB,kBAAkB,YAAY;AAClD,0BAAkB,KAAK;AAAA,MACzB;AAAA,IACF,OAAO;AAEL,UAAI,kBAAkB,iBAAiB;AACrC,0BAAkB,IAAI;AAAA,MACxB;AAAA,IACF;AAAA,EACF,GAAG,CAAC,qCAAU,GAAG,iBAAiB,YAAY,cAAc,CAAC;AAE7D,SAAO;AAAA,IACL;AAAA,EACF;AACF;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { ProColumns } from '@ant-design/pro-components';
|
|
2
|
+
import { RefObject } from 'react';
|
|
3
|
+
export declare const useAutoWidthColumns: <T, ValueType>(columns: ProColumns<T, ValueType>[] | undefined, tableRef: RefObject<HTMLDivElement>) => {
|
|
4
|
+
columns: ProColumns<T, ValueType>[] | undefined;
|
|
5
|
+
totalWidth: number | undefined;
|
|
6
|
+
};
|
|
@@ -0,0 +1,187 @@
|
|
|
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/useAutoWidthColumns.tsx
|
|
20
|
+
var useAutoWidthColumns_exports = {};
|
|
21
|
+
__export(useAutoWidthColumns_exports, {
|
|
22
|
+
useAutoWidthColumns: () => useAutoWidthColumns
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(useAutoWidthColumns_exports);
|
|
25
|
+
var import_ahooks = require("ahooks");
|
|
26
|
+
var import_antd = require("antd");
|
|
27
|
+
var import_react = require("react");
|
|
28
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
29
|
+
var DEFAULT_PADDING_WIDTH = 16;
|
|
30
|
+
var estimateWidth = (text) => {
|
|
31
|
+
let width = 0;
|
|
32
|
+
for (const char of text) {
|
|
33
|
+
if (/[\u4e00-\u9fa5]/.test(char)) {
|
|
34
|
+
width += 14;
|
|
35
|
+
} else {
|
|
36
|
+
width += 8;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
return width + DEFAULT_PADDING_WIDTH;
|
|
40
|
+
};
|
|
41
|
+
var getValueTypeWidth = (valueType) => {
|
|
42
|
+
switch (valueType) {
|
|
43
|
+
case "date":
|
|
44
|
+
case "dateRange":
|
|
45
|
+
return 120;
|
|
46
|
+
case "dateTime":
|
|
47
|
+
case "dateTimeRange":
|
|
48
|
+
return 180;
|
|
49
|
+
case "time":
|
|
50
|
+
case "timeRange":
|
|
51
|
+
return 100;
|
|
52
|
+
case "index":
|
|
53
|
+
case "indexBorder":
|
|
54
|
+
return 60;
|
|
55
|
+
case "money":
|
|
56
|
+
return 100;
|
|
57
|
+
case "digit":
|
|
58
|
+
return 100;
|
|
59
|
+
case "select":
|
|
60
|
+
return 120;
|
|
61
|
+
default:
|
|
62
|
+
return 80;
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
var MeasureWrapper = ({ children, onResize }) => {
|
|
66
|
+
const ref = (0, import_react.useRef)(null);
|
|
67
|
+
(0, import_react.useEffect)(() => {
|
|
68
|
+
if (!ref.current)
|
|
69
|
+
return;
|
|
70
|
+
onResize(ref.current.offsetWidth);
|
|
71
|
+
const observer = new ResizeObserver((entries) => {
|
|
72
|
+
for (const entry of entries) {
|
|
73
|
+
onResize(entry.target.offsetWidth);
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
observer.observe(ref.current);
|
|
77
|
+
return () => {
|
|
78
|
+
observer.disconnect();
|
|
79
|
+
};
|
|
80
|
+
}, []);
|
|
81
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd.Space, { ref, children });
|
|
82
|
+
};
|
|
83
|
+
var useAutoWidthColumns = (columns, tableRef) => {
|
|
84
|
+
const [columnWidths, setColumnWidths] = (0, import_react.useState)({});
|
|
85
|
+
const [tableWidth, setTableWidth] = (0, import_react.useState)(0);
|
|
86
|
+
(0, import_react.useEffect)(() => {
|
|
87
|
+
if (!tableRef.current)
|
|
88
|
+
return;
|
|
89
|
+
setTableWidth(tableRef.current.offsetWidth);
|
|
90
|
+
let rafId;
|
|
91
|
+
let timerId;
|
|
92
|
+
const updateWidth = (width) => {
|
|
93
|
+
cancelAnimationFrame(rafId);
|
|
94
|
+
clearTimeout(timerId);
|
|
95
|
+
rafId = requestAnimationFrame(() => {
|
|
96
|
+
timerId = setTimeout(() => {
|
|
97
|
+
setTableWidth(width);
|
|
98
|
+
}, 500);
|
|
99
|
+
});
|
|
100
|
+
};
|
|
101
|
+
const observer = new ResizeObserver((entries) => {
|
|
102
|
+
for (const entry of entries) {
|
|
103
|
+
updateWidth(entry.contentRect.width);
|
|
104
|
+
}
|
|
105
|
+
});
|
|
106
|
+
observer.observe(tableRef.current);
|
|
107
|
+
const handleWindowResize = () => {
|
|
108
|
+
if (tableRef.current) {
|
|
109
|
+
updateWidth(tableRef.current.offsetWidth);
|
|
110
|
+
}
|
|
111
|
+
};
|
|
112
|
+
window.addEventListener("resize", handleWindowResize);
|
|
113
|
+
return () => {
|
|
114
|
+
observer.disconnect();
|
|
115
|
+
window.removeEventListener("resize", handleWindowResize);
|
|
116
|
+
cancelAnimationFrame(rafId);
|
|
117
|
+
clearTimeout(timerId);
|
|
118
|
+
};
|
|
119
|
+
}, [tableRef]);
|
|
120
|
+
const handleResize = (0, import_ahooks.useMemoizedFn)((key, width) => {
|
|
121
|
+
setColumnWidths((prev) => {
|
|
122
|
+
const currentMax = prev[key] || 0;
|
|
123
|
+
if (width > currentMax) {
|
|
124
|
+
return { ...prev, [key]: width };
|
|
125
|
+
}
|
|
126
|
+
return prev;
|
|
127
|
+
});
|
|
128
|
+
});
|
|
129
|
+
const { columns: finalColumns, totalWidth } = (0, import_react.useMemo)(() => {
|
|
130
|
+
if (!columns)
|
|
131
|
+
return { columns: void 0, totalWidth: void 0 };
|
|
132
|
+
const calculatedColumns = columns.map((col, index) => {
|
|
133
|
+
const colKey = col.dataIndex || col.key || `col-${index}`;
|
|
134
|
+
const measuredWidth = columnWidths[colKey];
|
|
135
|
+
let width;
|
|
136
|
+
if (col.width) {
|
|
137
|
+
width = typeof col.width === "number" ? col.width : 100;
|
|
138
|
+
} else if (col.valueType === "option" && measuredWidth) {
|
|
139
|
+
width = measuredWidth + DEFAULT_PADDING_WIDTH;
|
|
140
|
+
} else {
|
|
141
|
+
width = Math.max(estimateWidth(col.title), getValueTypeWidth(col.valueType));
|
|
142
|
+
}
|
|
143
|
+
return {
|
|
144
|
+
...col,
|
|
145
|
+
_calculatedWidth: width,
|
|
146
|
+
_colKey: colKey
|
|
147
|
+
};
|
|
148
|
+
});
|
|
149
|
+
const totalCalculatedWidth = calculatedColumns.reduce((acc, col) => acc + col._calculatedWidth, 0);
|
|
150
|
+
const isOverflow = totalCalculatedWidth > tableWidth;
|
|
151
|
+
const processedColumns = calculatedColumns.map((col) => {
|
|
152
|
+
const { _calculatedWidth, _colKey, ...originalCol } = col;
|
|
153
|
+
if (col.valueType === "option") {
|
|
154
|
+
const originalRender = col.render;
|
|
155
|
+
return {
|
|
156
|
+
...originalCol,
|
|
157
|
+
// 始终设置 option 列宽度
|
|
158
|
+
width: _calculatedWidth,
|
|
159
|
+
fixed: col.fixed ?? "right",
|
|
160
|
+
render: (dom, entity, index, action, schema) => {
|
|
161
|
+
const originalRenderResult = originalRender ? originalRender(dom, entity, index, action, schema) : dom;
|
|
162
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(MeasureWrapper, { onResize: (width) => handleResize(_colKey, width), children: originalRenderResult });
|
|
163
|
+
}
|
|
164
|
+
};
|
|
165
|
+
}
|
|
166
|
+
return {
|
|
167
|
+
...originalCol,
|
|
168
|
+
// 只有当内容溢出(需要滚动)或者手动设置了宽度时,才应用计算出的宽度
|
|
169
|
+
// 否则不设置 width,让 Antd Table 自动布局占满剩余空间
|
|
170
|
+
width: isOverflow || col.width ? _calculatedWidth : void 0
|
|
171
|
+
};
|
|
172
|
+
});
|
|
173
|
+
return {
|
|
174
|
+
columns: processedColumns,
|
|
175
|
+
totalWidth: isOverflow ? totalCalculatedWidth : void 0
|
|
176
|
+
};
|
|
177
|
+
}, [columns, columnWidths, tableWidth]);
|
|
178
|
+
return {
|
|
179
|
+
columns: finalColumns,
|
|
180
|
+
totalWidth
|
|
181
|
+
};
|
|
182
|
+
};
|
|
183
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
184
|
+
0 && (module.exports = {
|
|
185
|
+
useAutoWidthColumns
|
|
186
|
+
});
|
|
187
|
+
//# sourceMappingURL=useAutoWidthColumns.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/creek-table/hooks/useAutoWidthColumns.tsx"],
|
|
4
|
+
"sourcesContent": ["import { ProColumns } from '@ant-design/pro-components';\nimport { useMemoizedFn } from 'ahooks';\nimport { Space } from 'antd';\nimport { RefObject, useEffect, useMemo, useRef, useState } from 'react';\n\nconst DEFAULT_PADDING_WIDTH = 16;\n\n/**\n * 估算字符串宽度(简单估算:汉字 14px,非汉字 8px,左右 padding 16px)\n */\nconst estimateWidth = (text: string) => {\n let width = 0;\n for (const char of text) {\n if (/[\\u4e00-\\u9fa5]/.test(char)) {\n width += 14;\n } else {\n width += 8;\n }\n }\n return width + DEFAULT_PADDING_WIDTH; // padding\n};\n\n/**\n * 根据 valueType 获取默认宽度\n */\nconst getValueTypeWidth = (valueType: string | undefined): number => {\n switch (valueType) {\n case 'date':\n case 'dateRange':\n return 120;\n case 'dateTime':\n case 'dateTimeRange':\n return 180;\n case 'time':\n case 'timeRange':\n return 100;\n case 'index':\n case 'indexBorder':\n return 60;\n case 'money':\n return 100;\n case 'digit':\n return 100;\n case 'select':\n return 120;\n default:\n return 80; // 默认给 80\n }\n};\n\n/**\n * 一个用于测量的包裹组件\n */\nconst MeasureWrapper = ({ children, onResize }: { children: React.ReactNode; onResize: (width: number) => void }) => {\n const ref = useRef<HTMLDivElement>(null);\n\n useEffect(() => {\n if (!ref.current) return;\n\n // 初次测量\n onResize(ref.current.offsetWidth);\n\n // 监听变化\n const observer = new ResizeObserver((entries) => {\n for (const entry of entries) {\n onResize((entry.target as HTMLElement).offsetWidth);\n }\n });\n\n observer.observe(ref.current);\n\n return () => {\n observer.disconnect();\n };\n }, []); // 依赖为空,只在挂载时设置监听\n\n return <Space ref={ref}>{children}</Space>;\n};\n\nexport const useAutoWidthColumns = <T, ValueType>(\n columns: ProColumns<T, ValueType>[] | undefined,\n tableRef: RefObject<HTMLDivElement>,\n): { columns: ProColumns<T, ValueType>[] | undefined; totalWidth: number | undefined } => {\n // 存储每个列的最大宽度:key 是 dataIndex 或 title,value 是最大宽度\n const [columnWidths, setColumnWidths] = useState<Record<string, number>>({});\n const [tableWidth, setTableWidth] = useState<number>(0);\n\n // 监听 table 容器宽度变化\n useEffect(() => {\n if (!tableRef.current) return;\n\n // 立即获取一次宽度\n setTableWidth(tableRef.current.offsetWidth);\n\n // 使用 requestAnimationFrame + setTimeout 防抖\n let rafId: number;\n let timerId: NodeJS.Timeout;\n\n const updateWidth = (width: number) => {\n cancelAnimationFrame(rafId);\n clearTimeout(timerId);\n\n rafId = requestAnimationFrame(() => {\n timerId = setTimeout(() => {\n setTableWidth(width);\n }, 500);\n });\n };\n\n const observer = new ResizeObserver((entries) => {\n for (const entry of entries) {\n updateWidth(entry.contentRect.width);\n }\n });\n\n observer.observe(tableRef.current);\n\n // 监听 window resize 作为后备\n const handleWindowResize = () => {\n if (tableRef.current) {\n updateWidth(tableRef.current.offsetWidth);\n }\n };\n window.addEventListener('resize', handleWindowResize);\n\n return () => {\n observer.disconnect();\n window.removeEventListener('resize', handleWindowResize);\n cancelAnimationFrame(rafId);\n clearTimeout(timerId);\n };\n }, [tableRef]);\n\n const handleResize = useMemoizedFn((key: string, width: number) => {\n setColumnWidths((prev) => {\n const currentMax = prev[key] || 0;\n if (width > currentMax) {\n return { ...prev, [key]: width };\n }\n return prev;\n });\n });\n\n const { columns: finalColumns, totalWidth } = useMemo(() => {\n if (!columns) return { columns: undefined, totalWidth: undefined };\n\n // 1. 先计算所有列的理想宽度(不考虑 table 宽度)\n const calculatedColumns = columns.map((col, index) => {\n const colKey = (col.dataIndex as string) || (col.key as string) || `col-${index}`;\n const measuredWidth = columnWidths[colKey];\n let width: number;\n if (col.width) {\n width = typeof col.width === 'number' ? col.width : 100; // 暂时给个默认值如果手动设了 string width\n } else if (col.valueType === 'option' && measuredWidth) {\n width = measuredWidth + DEFAULT_PADDING_WIDTH;\n } else {\n width = Math.max(estimateWidth(col.title as string), getValueTypeWidth(col.valueType as string));\n }\n\n return {\n ...col,\n _calculatedWidth: width,\n _colKey: colKey,\n };\n });\n\n // 2. 计算所有列的总宽度\n const totalCalculatedWidth = calculatedColumns.reduce((acc, col) => acc + col._calculatedWidth, 0);\n\n // 3. 判断是否需要自适应\n // 如果总宽度小于 table 宽度,说明空间足够,除了 option 列,其他列可以不设宽度让 table 自动撑开\n const isOverflow = totalCalculatedWidth > tableWidth;\n\n const processedColumns = calculatedColumns.map((col) => {\n // 提取内部使用的字段\n const { _calculatedWidth, _colKey, ...originalCol } = col;\n\n // 针对 valueType === 'option' (操作列),始终需要特殊处理(包裹测量组件)\n if (col.valueType === 'option') {\n const originalRender = col.render;\n return {\n ...originalCol,\n // 始终设置 option 列宽度\n width: _calculatedWidth,\n fixed: col.fixed ?? 'right',\n render: (dom: any, entity: any, index: any, action: any, schema: any) => {\n const originalRenderResult = originalRender ? (originalRender(dom, entity, index, action, schema) as React.ReactNode) : dom;\n return <MeasureWrapper onResize={(width) => handleResize(_colKey, width)}>{originalRenderResult}</MeasureWrapper>;\n },\n } as ProColumns<T, ValueType>;\n }\n\n // 非 option 列\n return {\n ...originalCol,\n // 只有当内容溢出(需要滚动)或者手动设置了宽度时,才应用计算出的宽度\n // 否则不设置 width,让 Antd Table 自动布局占满剩余空间\n width: isOverflow || col.width ? _calculatedWidth : undefined,\n };\n });\n\n return {\n columns: processedColumns,\n totalWidth: isOverflow ? totalCalculatedWidth : undefined,\n };\n }, [columns, columnWidths, tableWidth]);\n\n return {\n columns: finalColumns,\n totalWidth,\n };\n};\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,oBAA8B;AAC9B,kBAAsB;AACtB,mBAAgE;AAyEvD;AAvET,IAAM,wBAAwB;AAK9B,IAAM,gBAAgB,CAAC,SAAiB;AACtC,MAAI,QAAQ;AACZ,aAAW,QAAQ,MAAM;AACvB,QAAI,kBAAkB,KAAK,IAAI,GAAG;AAChC,eAAS;AAAA,IACX,OAAO;AACL,eAAS;AAAA,IACX;AAAA,EACF;AACA,SAAO,QAAQ;AACjB;AAKA,IAAM,oBAAoB,CAAC,cAA0C;AACnE,UAAQ,WAAW;AAAA,IACjB,KAAK;AAAA,IACL,KAAK;AACH,aAAO;AAAA,IACT,KAAK;AAAA,IACL,KAAK;AACH,aAAO;AAAA,IACT,KAAK;AAAA,IACL,KAAK;AACH,aAAO;AAAA,IACT,KAAK;AAAA,IACL,KAAK;AACH,aAAO;A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