szld-libs 0.2.31 → 0.2.33
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/szld-components.es.js +981 -974
- package/dist/szld-components.umd.js +26 -26
- package/es/components/SearchTable/index.js +49 -36
- package/es/index.js +32 -3
- package/lib/components/SearchTable/index.js +48 -35
- package/lib/index.js +30 -1
- package/package.json +1 -1
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { jsxs, Fragment, jsx } from "react/jsx-runtime";
|
|
2
2
|
import { Table } from "antd";
|
|
3
3
|
import classNames from "classnames";
|
|
4
|
-
import
|
|
5
|
-
import { useState, useMemo } from "react";
|
|
4
|
+
import { useState, useEffect } from "react";
|
|
6
5
|
import { Resizable } from "react-resizable";
|
|
7
6
|
import { getLocalStorage } from "../../utils";
|
|
8
7
|
import CreateForm from "../CreateForm";
|
|
@@ -28,26 +27,7 @@ function SearchTable(props) {
|
|
|
28
27
|
storageKey = "szld_table_cell_width",
|
|
29
28
|
...rest
|
|
30
29
|
} = tableProps;
|
|
31
|
-
const [columns, setColumns] = useState(
|
|
32
|
-
const handleResize = (column, size) => {
|
|
33
|
-
const list = _.cloneDeep(columns);
|
|
34
|
-
const index = list.findIndex((v) => v.dataIndex === column.dataIndex);
|
|
35
|
-
list[index] = {
|
|
36
|
-
...list[index],
|
|
37
|
-
width: size.width
|
|
38
|
-
};
|
|
39
|
-
if (tableId) {
|
|
40
|
-
const obj = getLocalStorage(storageKey) || {};
|
|
41
|
-
obj[tableId] = obj[tableId] || {};
|
|
42
|
-
list == null ? void 0 : list.forEach((v) => {
|
|
43
|
-
if (typeof v.dataIndex === "string") {
|
|
44
|
-
obj[tableId][v.dataIndex] = v.width;
|
|
45
|
-
}
|
|
46
|
-
});
|
|
47
|
-
localStorage.setItem(storageKey, JSON.stringify(obj));
|
|
48
|
-
}
|
|
49
|
-
setColumns(list);
|
|
50
|
-
};
|
|
30
|
+
const [columns, setColumns] = useState([]);
|
|
51
31
|
const getWidth = (v) => {
|
|
52
32
|
var _a, _b;
|
|
53
33
|
let width = v.width || minColumnWidth;
|
|
@@ -59,21 +39,54 @@ function SearchTable(props) {
|
|
|
59
39
|
}
|
|
60
40
|
return width;
|
|
61
41
|
};
|
|
62
|
-
|
|
63
|
-
const
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
42
|
+
useEffect(() => {
|
|
43
|
+
const list = tableProps.columns || [];
|
|
44
|
+
if (list.length === 0) {
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
const result = list == null ? void 0 : list.filter((v) => !v.hidden).map((v) => {
|
|
48
|
+
if (v.dataIndex) {
|
|
49
|
+
return {
|
|
50
|
+
...v,
|
|
51
|
+
width: getWidth(v),
|
|
52
|
+
onHeaderCell: (column) => ({
|
|
53
|
+
width: column.width,
|
|
54
|
+
resizeable,
|
|
55
|
+
onResize: (_e, { size }) => handleResize(column, size)
|
|
56
|
+
})
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
return v;
|
|
60
|
+
});
|
|
72
61
|
if (result.length > 0) {
|
|
73
62
|
result[result.length - 1].width = void 0;
|
|
74
63
|
}
|
|
75
|
-
|
|
76
|
-
}, [
|
|
64
|
+
setColumns(result);
|
|
65
|
+
}, [tableProps.columns, tableId, minColumnWidth]);
|
|
66
|
+
const handleResize = (column, size) => {
|
|
67
|
+
setColumns((prevColumns) => {
|
|
68
|
+
const list = prevColumns == null ? void 0 : prevColumns.map((v) => {
|
|
69
|
+
if (v.dataIndex === column.dataIndex) {
|
|
70
|
+
return {
|
|
71
|
+
...v,
|
|
72
|
+
width: size.width
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
return v;
|
|
76
|
+
});
|
|
77
|
+
if (tableId) {
|
|
78
|
+
const obj = getLocalStorage(storageKey) || {};
|
|
79
|
+
obj[tableId] = obj[tableId] || {};
|
|
80
|
+
list == null ? void 0 : list.forEach((v) => {
|
|
81
|
+
if (typeof v.dataIndex === "string") {
|
|
82
|
+
obj[tableId][v.dataIndex] = v.width;
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
localStorage.setItem(storageKey, JSON.stringify(obj));
|
|
86
|
+
}
|
|
87
|
+
return list;
|
|
88
|
+
});
|
|
89
|
+
};
|
|
77
90
|
const components = {
|
|
78
91
|
header: {
|
|
79
92
|
cell: ResizeableTitle
|
|
@@ -85,9 +98,9 @@ function SearchTable(props) {
|
|
|
85
98
|
Table,
|
|
86
99
|
{
|
|
87
100
|
...rest,
|
|
88
|
-
columns
|
|
101
|
+
columns,
|
|
89
102
|
scroll: {
|
|
90
|
-
x:
|
|
103
|
+
x: columns == null ? void 0 : columns.reduce((a, b) => a + (typeof b.width === "number" ? b.width : minColumnWidth), 0)
|
|
91
104
|
},
|
|
92
105
|
components,
|
|
93
106
|
className: classNames(classes.table, tableProps == null ? void 0 : tableProps.className),
|
package/es/index.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { jsx } from "react/jsx-runtime";
|
|
2
|
-
import { useEffect } from "react";
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useEffect, useState } from "react";
|
|
3
3
|
import ReactDOM from "react-dom/client";
|
|
4
4
|
import { BrowserRouter } from "react-router-dom";
|
|
5
|
+
import { Table, Button } from "antd";
|
|
5
6
|
import useConfig from "./hooks/useConfig";
|
|
6
7
|
import { AES, SearchTable } from "./main";
|
|
7
8
|
let key = "U2FsdGVkX1/dG1NSXNR9hnp3Ech/v6Gh8CDDJxgBm1EPFQel12ySIf84ARXCPwTae7TzwgPvjOyE3S5rAEzl/wAZmId6pbezpFeFcJqxdmIl3FeluYHFxJzQHDETTvrr3G/REvv00kHptOVwg6ecjPH6yk7PNit0sWTBLorROxLxMD8lVDmOA66p7Zp4QnYzqScYJGFbutmfHYXfBRBe1Q2UKummJ798svNY5SIwEwl4spzgyWmhARtuyq4zhysFrj/xODuNDjtwitA6XfX566WcZkj3F+2P+mkYzDYOhXXaomnlybjrZ2hEHfcczQhUfJd89O8PNIuEWo24wjYRgMdKlw5CWSeocFCqV7ZJ/CV/7vNRcaO4awKlFNobLikkwDznxpcX+4UEej+ED+pgfmPQLsKedcfEscStkSAZXaD5pBRTiFU9xGLfDt6seUrEnMBeXkpMIY9j1SZDDK18/G7lSHjDQMZYZP6sfLdBdwY=";
|
|
@@ -28,17 +29,45 @@ const Demo = () => {
|
|
|
28
29
|
dataIndex: "a",
|
|
29
30
|
title: "a"
|
|
30
31
|
},
|
|
32
|
+
Table.EXPAND_COLUMN,
|
|
31
33
|
{
|
|
32
34
|
dataIndex: "b",
|
|
33
35
|
title: "b",
|
|
34
36
|
width: 400
|
|
35
37
|
},
|
|
38
|
+
Table.SELECTION_COLUMN,
|
|
36
39
|
{
|
|
37
40
|
dataIndex: "c",
|
|
38
41
|
title: "c"
|
|
39
42
|
}
|
|
40
43
|
];
|
|
41
|
-
|
|
44
|
+
const [list, setList] = useState([]);
|
|
45
|
+
return /* @__PURE__ */ jsxs("div", { style: { height: "100vh" }, children: [
|
|
46
|
+
/* @__PURE__ */ jsx(Button, { onClick: () => setList(columns), children: "test" }),
|
|
47
|
+
/* @__PURE__ */ jsx(
|
|
48
|
+
SearchTable,
|
|
49
|
+
{
|
|
50
|
+
tableProps: {
|
|
51
|
+
columns: list,
|
|
52
|
+
dataSource: [
|
|
53
|
+
{ a: 1, b: 2, c: 3, id: 1 },
|
|
54
|
+
{ a: 1, b: 2, c: 3, id: 2 },
|
|
55
|
+
{ a: 1, b: 2, c: 3, id: 3 }
|
|
56
|
+
],
|
|
57
|
+
resizeable: true,
|
|
58
|
+
rowKey: "id",
|
|
59
|
+
rowSelection: {},
|
|
60
|
+
expandable: {
|
|
61
|
+
expandedRowRender: () => {
|
|
62
|
+
return /* @__PURE__ */ jsx("div", { children: "123" });
|
|
63
|
+
}
|
|
64
|
+
},
|
|
65
|
+
tableId: "demo1",
|
|
66
|
+
storageKey: "szld-libs-test"
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
)
|
|
70
|
+
] });
|
|
42
71
|
};
|
|
43
72
|
ReactDOM.createRoot(document.getElementById("root")).render(
|
|
44
73
|
/* @__PURE__ */ jsx(BrowserRouter, { children: /* @__PURE__ */ jsx(Demo, {}) })
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
const jsxRuntime = require("react/jsx-runtime");
|
|
3
3
|
const antd = require("antd");
|
|
4
4
|
const classNames = require("classnames");
|
|
5
|
-
const _ = require("lodash");
|
|
6
5
|
const react = require("react");
|
|
7
6
|
const reactResizable = require("react-resizable");
|
|
8
7
|
const utils = require("../../utils");
|
|
@@ -29,26 +28,7 @@ function SearchTable(props) {
|
|
|
29
28
|
storageKey = "szld_table_cell_width",
|
|
30
29
|
...rest
|
|
31
30
|
} = tableProps;
|
|
32
|
-
const [columns, setColumns] = react.useState(
|
|
33
|
-
const handleResize = (column, size) => {
|
|
34
|
-
const list = _.cloneDeep(columns);
|
|
35
|
-
const index = list.findIndex((v) => v.dataIndex === column.dataIndex);
|
|
36
|
-
list[index] = {
|
|
37
|
-
...list[index],
|
|
38
|
-
width: size.width
|
|
39
|
-
};
|
|
40
|
-
if (tableId) {
|
|
41
|
-
const obj = utils.getLocalStorage(storageKey) || {};
|
|
42
|
-
obj[tableId] = obj[tableId] || {};
|
|
43
|
-
list == null ? void 0 : list.forEach((v) => {
|
|
44
|
-
if (typeof v.dataIndex === "string") {
|
|
45
|
-
obj[tableId][v.dataIndex] = v.width;
|
|
46
|
-
}
|
|
47
|
-
});
|
|
48
|
-
localStorage.setItem(storageKey, JSON.stringify(obj));
|
|
49
|
-
}
|
|
50
|
-
setColumns(list);
|
|
51
|
-
};
|
|
31
|
+
const [columns, setColumns] = react.useState([]);
|
|
52
32
|
const getWidth = (v) => {
|
|
53
33
|
var _a, _b;
|
|
54
34
|
let width = v.width || minColumnWidth;
|
|
@@ -60,21 +40,54 @@ function SearchTable(props) {
|
|
|
60
40
|
}
|
|
61
41
|
return width;
|
|
62
42
|
};
|
|
63
|
-
|
|
64
|
-
const
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
43
|
+
react.useEffect(() => {
|
|
44
|
+
const list = tableProps.columns || [];
|
|
45
|
+
if (list.length === 0) {
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
const result = list == null ? void 0 : list.filter((v) => !v.hidden).map((v) => {
|
|
49
|
+
if (v.dataIndex) {
|
|
50
|
+
return {
|
|
51
|
+
...v,
|
|
52
|
+
width: getWidth(v),
|
|
53
|
+
onHeaderCell: (column) => ({
|
|
54
|
+
width: column.width,
|
|
55
|
+
resizeable,
|
|
56
|
+
onResize: (_e, { size }) => handleResize(column, size)
|
|
57
|
+
})
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
return v;
|
|
61
|
+
});
|
|
73
62
|
if (result.length > 0) {
|
|
74
63
|
result[result.length - 1].width = void 0;
|
|
75
64
|
}
|
|
76
|
-
|
|
77
|
-
}, [
|
|
65
|
+
setColumns(result);
|
|
66
|
+
}, [tableProps.columns, tableId, minColumnWidth]);
|
|
67
|
+
const handleResize = (column, size) => {
|
|
68
|
+
setColumns((prevColumns) => {
|
|
69
|
+
const list = prevColumns == null ? void 0 : prevColumns.map((v) => {
|
|
70
|
+
if (v.dataIndex === column.dataIndex) {
|
|
71
|
+
return {
|
|
72
|
+
...v,
|
|
73
|
+
width: size.width
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
return v;
|
|
77
|
+
});
|
|
78
|
+
if (tableId) {
|
|
79
|
+
const obj = utils.getLocalStorage(storageKey) || {};
|
|
80
|
+
obj[tableId] = obj[tableId] || {};
|
|
81
|
+
list == null ? void 0 : list.forEach((v) => {
|
|
82
|
+
if (typeof v.dataIndex === "string") {
|
|
83
|
+
obj[tableId][v.dataIndex] = v.width;
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
localStorage.setItem(storageKey, JSON.stringify(obj));
|
|
87
|
+
}
|
|
88
|
+
return list;
|
|
89
|
+
});
|
|
90
|
+
};
|
|
78
91
|
const components = {
|
|
79
92
|
header: {
|
|
80
93
|
cell: ResizeableTitle
|
|
@@ -86,9 +99,9 @@ function SearchTable(props) {
|
|
|
86
99
|
antd.Table,
|
|
87
100
|
{
|
|
88
101
|
...rest,
|
|
89
|
-
columns
|
|
102
|
+
columns,
|
|
90
103
|
scroll: {
|
|
91
|
-
x:
|
|
104
|
+
x: columns == null ? void 0 : columns.reduce((a, b) => a + (typeof b.width === "number" ? b.width : minColumnWidth), 0)
|
|
92
105
|
},
|
|
93
106
|
components,
|
|
94
107
|
className: classNames(classes.table, tableProps == null ? void 0 : tableProps.className),
|
package/lib/index.js
CHANGED
|
@@ -3,6 +3,7 @@ const jsxRuntime = require("react/jsx-runtime");
|
|
|
3
3
|
const react = require("react");
|
|
4
4
|
const ReactDOM = require("react-dom/client");
|
|
5
5
|
const reactRouterDom = require("react-router-dom");
|
|
6
|
+
const antd = require("antd");
|
|
6
7
|
const useConfig = require("./hooks/useConfig");
|
|
7
8
|
const main = require("./main");
|
|
8
9
|
let key = "U2FsdGVkX1/dG1NSXNR9hnp3Ech/v6Gh8CDDJxgBm1EPFQel12ySIf84ARXCPwTae7TzwgPvjOyE3S5rAEzl/wAZmId6pbezpFeFcJqxdmIl3FeluYHFxJzQHDETTvrr3G/REvv00kHptOVwg6ecjPH6yk7PNit0sWTBLorROxLxMD8lVDmOA66p7Zp4QnYzqScYJGFbutmfHYXfBRBe1Q2UKummJ798svNY5SIwEwl4spzgyWmhARtuyq4zhysFrj/xODuNDjtwitA6XfX566WcZkj3F+2P+mkYzDYOhXXaomnlybjrZ2hEHfcczQhUfJd89O8PNIuEWo24wjYRgMdKlw5CWSeocFCqV7ZJ/CV/7vNRcaO4awKlFNobLikkwDznxpcX+4UEej+ED+pgfmPQLsKedcfEscStkSAZXaD5pBRTiFU9xGLfDt6seUrEnMBeXkpMIY9j1SZDDK18/G7lSHjDQMZYZP6sfLdBdwY=";
|
|
@@ -29,17 +30,45 @@ const Demo = () => {
|
|
|
29
30
|
dataIndex: "a",
|
|
30
31
|
title: "a"
|
|
31
32
|
},
|
|
33
|
+
antd.Table.EXPAND_COLUMN,
|
|
32
34
|
{
|
|
33
35
|
dataIndex: "b",
|
|
34
36
|
title: "b",
|
|
35
37
|
width: 400
|
|
36
38
|
},
|
|
39
|
+
antd.Table.SELECTION_COLUMN,
|
|
37
40
|
{
|
|
38
41
|
dataIndex: "c",
|
|
39
42
|
title: "c"
|
|
40
43
|
}
|
|
41
44
|
];
|
|
42
|
-
|
|
45
|
+
const [list, setList] = react.useState([]);
|
|
46
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { height: "100vh" }, children: [
|
|
47
|
+
/* @__PURE__ */ jsxRuntime.jsx(antd.Button, { onClick: () => setList(columns), children: "test" }),
|
|
48
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
49
|
+
main.SearchTable,
|
|
50
|
+
{
|
|
51
|
+
tableProps: {
|
|
52
|
+
columns: list,
|
|
53
|
+
dataSource: [
|
|
54
|
+
{ a: 1, b: 2, c: 3, id: 1 },
|
|
55
|
+
{ a: 1, b: 2, c: 3, id: 2 },
|
|
56
|
+
{ a: 1, b: 2, c: 3, id: 3 }
|
|
57
|
+
],
|
|
58
|
+
resizeable: true,
|
|
59
|
+
rowKey: "id",
|
|
60
|
+
rowSelection: {},
|
|
61
|
+
expandable: {
|
|
62
|
+
expandedRowRender: () => {
|
|
63
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { children: "123" });
|
|
64
|
+
}
|
|
65
|
+
},
|
|
66
|
+
tableId: "demo1",
|
|
67
|
+
storageKey: "szld-libs-test"
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
)
|
|
71
|
+
] });
|
|
43
72
|
};
|
|
44
73
|
ReactDOM.createRoot(document.getElementById("root")).render(
|
|
45
74
|
/* @__PURE__ */ jsxRuntime.jsx(reactRouterDom.BrowserRouter, { children: /* @__PURE__ */ jsxRuntime.jsx(Demo, {}) })
|