@pisell/materials 1.0.63 → 1.0.65
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/build/lowcode/assets-daily.json +11 -11
- package/build/lowcode/assets-dev.json +2 -2
- package/build/lowcode/assets-prod.json +11 -11
- package/build/lowcode/index.js +1 -1
- package/build/lowcode/meta.js +2 -2
- package/build/lowcode/preview.js +142 -142
- package/build/lowcode/render/default/view.css +1 -1
- package/build/lowcode/render/default/view.js +11 -159
- package/build/lowcode/view.css +1 -1
- package/build/lowcode/view.js +7 -155
- package/dist/umd/materials.min.css +1 -0
- package/dist/umd/materials.min.js +1 -0
- package/dist/umd/static/DotsSix.57d66266.svg +1 -0
- package/dist/umd/static/arrow-left.e542294f.svg +1 -0
- package/dist/umd/static/arrow-right.763f03e0.svg +1 -0
- package/dist/umd/static/filter-lines.04a54ae9.svg +1 -0
- package/dist/umd/static/help-circle.31c9be40.svg +1 -0
- package/dist/umd/static/switch-vertical-01.7ebe3ba8.svg +1 -0
- package/es/components/drawer/index.js +0 -1
- package/es/components/filter/components/FilterItem/index.js +3 -2
- package/es/components/table/BasicTable/index.js +49 -8
- package/es/components/table/Table/AddFieldModal/index.js +0 -1
- package/es/components/table/Table/fields/rangePicker/Edit/index.js +0 -1
- package/es/components/table/Table/index.js +34 -1
- package/es/components/table/Table/tableConfig/header/CellProvider/index.less +1 -1
- package/es/components/table/Table/tableConfig/summary/index.js +0 -1
- package/es/components/table/Table/utils.d.ts +1 -0
- package/es/components/table/Table/utils.js +70 -0
- package/es/components/table/TableFilter/SortIcon.d.ts +6 -0
- package/es/components/table/TableFilter/SortIcon.js +30 -0
- package/es/components/table/TableFilter/index.less +14 -0
- package/es/components/table/TableFilter/numberFilter.d.ts +6 -0
- package/es/components/table/TableFilter/numberFilter.js +95 -0
- package/es/components/table/TableFilter/selectFilter.d.ts +10 -0
- package/es/components/table/TableFilter/selectFilter.js +126 -0
- package/es/components/table/TableFilter/stringFilter.d.ts +6 -0
- package/es/components/table/TableFilter/stringFilter.js +73 -0
- package/es/components/table/index.js +2 -1
- package/es/components/table/index.less +49 -1
- package/lib/components/drawer/index.js +0 -1
- package/lib/components/filter/components/FilterItem/index.js +1 -1
- package/lib/components/table/BasicTable/index.js +44 -8
- package/lib/components/table/Table/AddFieldModal/index.js +0 -1
- package/lib/components/table/Table/fields/rangePicker/Edit/index.js +0 -1
- package/lib/components/table/Table/index.js +25 -0
- package/lib/components/table/Table/tableConfig/header/CellProvider/index.less +1 -1
- package/lib/components/table/Table/tableConfig/summary/index.js +0 -1
- package/lib/components/table/Table/utils.d.ts +1 -0
- package/lib/components/table/Table/utils.js +108 -0
- package/lib/components/table/TableFilter/SortIcon.d.ts +6 -0
- package/lib/components/table/TableFilter/SortIcon.js +59 -0
- package/lib/components/table/TableFilter/index.less +14 -0
- package/lib/components/table/TableFilter/numberFilter.d.ts +6 -0
- package/lib/components/table/TableFilter/numberFilter.js +110 -0
- package/lib/components/table/TableFilter/selectFilter.d.ts +10 -0
- package/lib/components/table/TableFilter/selectFilter.js +123 -0
- package/lib/components/table/TableFilter/stringFilter.d.ts +6 -0
- package/lib/components/table/TableFilter/stringFilter.js +99 -0
- package/lib/components/table/index.js +1 -1
- package/lib/components/table/index.less +49 -1
- package/package.json +4 -4
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { Button, Input, Space } from "antd";
|
|
3
|
+
import { SearchLg } from "@pisell/icon";
|
|
4
|
+
import "./index.less";
|
|
5
|
+
var getColumnStringProps = function getColumnStringProps(_ref) {
|
|
6
|
+
var dataIndex = _ref.dataIndex;
|
|
7
|
+
return {
|
|
8
|
+
filterDropdown: function filterDropdown(_ref2) {
|
|
9
|
+
var setSelectedKeys = _ref2.setSelectedKeys,
|
|
10
|
+
selectedKeys = _ref2.selectedKeys,
|
|
11
|
+
confirm = _ref2.confirm,
|
|
12
|
+
clearFilters = _ref2.clearFilters,
|
|
13
|
+
close = _ref2.close;
|
|
14
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
15
|
+
onKeyDown: function onKeyDown(e) {
|
|
16
|
+
return e.stopPropagation();
|
|
17
|
+
},
|
|
18
|
+
className: "pisell-table-filter-dropdown"
|
|
19
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
20
|
+
className: "pisell-table-filter-dropdown-top"
|
|
21
|
+
}, /*#__PURE__*/React.createElement(Input, {
|
|
22
|
+
prefix: /*#__PURE__*/React.createElement(SearchLg, null),
|
|
23
|
+
placeholder: "Search",
|
|
24
|
+
value: selectedKeys[0],
|
|
25
|
+
onChange: function onChange(e) {
|
|
26
|
+
return setSelectedKeys(e.target.value ? [e.target.value] : []);
|
|
27
|
+
},
|
|
28
|
+
onPressEnter: function onPressEnter() {
|
|
29
|
+
return confirm();
|
|
30
|
+
},
|
|
31
|
+
style: {
|
|
32
|
+
width: 240
|
|
33
|
+
}
|
|
34
|
+
})), /*#__PURE__*/React.createElement(Space, {
|
|
35
|
+
className: "pisell-table-filter-dropdown-bottom",
|
|
36
|
+
styles: {
|
|
37
|
+
item: {
|
|
38
|
+
flex: 1
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}, /*#__PURE__*/React.createElement(Button, {
|
|
42
|
+
onClick: function onClick() {
|
|
43
|
+
clearFilters && clearFilters();
|
|
44
|
+
confirm({
|
|
45
|
+
closeDropdown: false
|
|
46
|
+
});
|
|
47
|
+
},
|
|
48
|
+
block: true,
|
|
49
|
+
style: {
|
|
50
|
+
flex: 1
|
|
51
|
+
}
|
|
52
|
+
}, "Reset"), /*#__PURE__*/React.createElement(Button, {
|
|
53
|
+
type: "primary",
|
|
54
|
+
onClick: function onClick() {
|
|
55
|
+
return confirm();
|
|
56
|
+
},
|
|
57
|
+
block: true,
|
|
58
|
+
style: {
|
|
59
|
+
flex: 1
|
|
60
|
+
}
|
|
61
|
+
}, "Filter")));
|
|
62
|
+
},
|
|
63
|
+
filterIcon: function filterIcon(filtered) {
|
|
64
|
+
return /*#__PURE__*/React.createElement(SearchLg, {
|
|
65
|
+
style: {
|
|
66
|
+
color: filtered ? "#7f56d9" : undefined,
|
|
67
|
+
fontSize: 16
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
};
|
|
73
|
+
export default getColumnStringProps;
|
|
@@ -78,7 +78,8 @@ var GridView = Provider(function (props) {
|
|
|
78
78
|
});
|
|
79
79
|
} else {
|
|
80
80
|
var _other$pagination;
|
|
81
|
-
|
|
81
|
+
// 如果使用本地分页 不执行onValuesChange
|
|
82
|
+
if (other !== null && other !== void 0 && (_other$pagination = other.pagination) !== null && _other$pagination !== void 0 && _other$pagination.localPagination) {
|
|
82
83
|
return;
|
|
83
84
|
}
|
|
84
85
|
}
|
|
@@ -3,5 +3,53 @@
|
|
|
3
3
|
height: 100%;
|
|
4
4
|
display: flex;
|
|
5
5
|
flex-direction: column;
|
|
6
|
-
|
|
6
|
+
.pisell-lowcode-table-filter-column {
|
|
7
|
+
align-items: center;
|
|
8
|
+
.pisell-lowcode-dropdown-trigger {
|
|
9
|
+
width: 25px;
|
|
10
|
+
height: 25px;
|
|
11
|
+
justify-content: center;
|
|
12
|
+
}
|
|
13
|
+
.pisell-lowcode-table-filter-trigger.active {
|
|
14
|
+
background: var(--primary-100, #F4EBFF);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
.pisell-lowcode-table-column-sorters {
|
|
18
|
+
cursor: pointer;
|
|
19
|
+
}
|
|
20
|
+
.pisell-table-sorter-inner {
|
|
21
|
+
width: 25px;
|
|
22
|
+
height: 25px;
|
|
23
|
+
display: inline-flex;
|
|
24
|
+
flex-direction: column;
|
|
25
|
+
align-items: center;
|
|
26
|
+
margin-inline-start: 4px;
|
|
27
|
+
color: rgba(0, 0, 0, 0.29);
|
|
28
|
+
font-size: 12px;
|
|
29
|
+
transition: color 0.3s;
|
|
30
|
+
border-radius: 8px;
|
|
31
|
+
justify-content: center;
|
|
32
|
+
&:hover {
|
|
33
|
+
background: var(--primary-100, #F4EBFF);
|
|
34
|
+
}
|
|
35
|
+
.pisell-table-column-sorter-up,.pisell-table-column-sorter-down {
|
|
36
|
+
color: rgba(102, 112, 133, 0.65);
|
|
37
|
+
font-size: 12px;
|
|
38
|
+
}
|
|
39
|
+
.pisell-table-column-sorter-down {
|
|
40
|
+
margin-top: -0.3em;
|
|
41
|
+
}
|
|
42
|
+
.pisell-table-column-up {
|
|
43
|
+
font-size: 20px;
|
|
44
|
+
}
|
|
45
|
+
.pisell-table-column-down {
|
|
46
|
+
font-size: 20px;
|
|
47
|
+
transform: rotate(180deg);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
.pisell-table-sorter-inner.active {
|
|
51
|
+
background: var(--primary-100, #F4EBFF);
|
|
52
|
+
cursor: pointer;
|
|
53
|
+
color: #7F56D9
|
|
54
|
+
}
|
|
7
55
|
}
|
|
@@ -39,7 +39,6 @@ var Drawer = (props) => {
|
|
|
39
39
|
if (props.__designMode === "design") {
|
|
40
40
|
innerProps.open = true;
|
|
41
41
|
}
|
|
42
|
-
console.log(props, "Drawer props", innerProps);
|
|
43
42
|
return /* @__PURE__ */ import_react.default.createElement(import_antd.Drawer, { ...props, ...innerProps });
|
|
44
43
|
};
|
|
45
44
|
var drawer_default = Drawer;
|
|
@@ -42,6 +42,6 @@ var FilterItem = (props) => {
|
|
|
42
42
|
var _a;
|
|
43
43
|
return (_a = import_fields.fieldMaps[type]) == null ? void 0 : _a.edit;
|
|
44
44
|
}, [type]);
|
|
45
|
-
return /* @__PURE__ */ import_react.default.createElement(import_antd.Form.Item, { label, name }, /* @__PURE__ */ import_react.default.createElement(Com, { ...other }));
|
|
45
|
+
return /* @__PURE__ */ import_react.default.createElement(import_antd.Form.Item, { label, name, ...(other == null ? void 0 : other.formItemProps) || {} }, /* @__PURE__ */ import_react.default.createElement(Com, { ...other }));
|
|
46
46
|
};
|
|
47
47
|
var FilterItem_default = FilterItem;
|
|
@@ -35,29 +35,37 @@ module.exports = __toCommonJS(BasicTable_exports);
|
|
|
35
35
|
var import_antd = require("antd");
|
|
36
36
|
var import_react = __toESM(require("react"));
|
|
37
37
|
var import_Pagination = require("../../Pagination");
|
|
38
|
+
var import_utils = require("../Table/utils");
|
|
38
39
|
var BasicTable = (props) => {
|
|
39
40
|
var _a;
|
|
40
41
|
const { dataSource, pagination, value, ...other } = props;
|
|
42
|
+
const [filter, setFilter] = (0, import_react.useState)();
|
|
43
|
+
const [sort, setSort] = (0, import_react.useState)();
|
|
41
44
|
const form = import_antd.Form.useFormInstance();
|
|
42
45
|
const formPagination = import_antd.Form.useWatch("pagination", form) || {
|
|
43
46
|
page: 1,
|
|
44
47
|
size: 10
|
|
45
48
|
};
|
|
46
|
-
const { showTotal } = pagination;
|
|
49
|
+
const { showTotal, localPagination } = pagination;
|
|
47
50
|
const _showTotal = (0, import_react.useCallback)(
|
|
48
51
|
(total2, range) => {
|
|
49
|
-
let _size = formPagination.size;
|
|
52
|
+
let _size = formPagination.size || 10;
|
|
50
53
|
return showTotal(total2, range, _size);
|
|
51
54
|
},
|
|
52
55
|
[showTotal, formPagination == null ? void 0 : formPagination.page, formPagination == null ? void 0 : formPagination.size]
|
|
53
56
|
);
|
|
54
57
|
const _dataSource = (0, import_react.useMemo)(() => {
|
|
55
58
|
let _page = formPagination.page;
|
|
56
|
-
let _size = formPagination.size;
|
|
59
|
+
let _size = formPagination.size || 10;
|
|
57
60
|
let list = [];
|
|
58
61
|
let _total = total;
|
|
59
|
-
if (
|
|
60
|
-
list =
|
|
62
|
+
if (localPagination) {
|
|
63
|
+
list = (0, import_utils.calcFilterSort)({
|
|
64
|
+
dataSource,
|
|
65
|
+
columns: other.columns,
|
|
66
|
+
sort,
|
|
67
|
+
filter
|
|
68
|
+
});
|
|
61
69
|
_total = list.length;
|
|
62
70
|
list = list.slice((_page - 1) * _size, _page * _size);
|
|
63
71
|
} else {
|
|
@@ -67,11 +75,39 @@ var BasicTable = (props) => {
|
|
|
67
75
|
list,
|
|
68
76
|
total: _total
|
|
69
77
|
};
|
|
70
|
-
}, [
|
|
78
|
+
}, [
|
|
79
|
+
localPagination,
|
|
80
|
+
dataSource,
|
|
81
|
+
formPagination == null ? void 0 : formPagination.page,
|
|
82
|
+
formPagination == null ? void 0 : formPagination.size,
|
|
83
|
+
filter,
|
|
84
|
+
sort,
|
|
85
|
+
other.columns
|
|
86
|
+
]);
|
|
71
87
|
const total = (0, import_react.useMemo)(() => {
|
|
88
|
+
if (dataSource.length > formPagination.size) {
|
|
89
|
+
return (_dataSource == null ? void 0 : _dataSource.total) || 0;
|
|
90
|
+
}
|
|
72
91
|
return (pagination == null ? void 0 : pagination.total) || (_dataSource == null ? void 0 : _dataSource.total) || 0;
|
|
73
|
-
}, [
|
|
74
|
-
return /* @__PURE__ */ import_react.default.createElement("div", null, /* @__PURE__ */ import_react.default.createElement(
|
|
92
|
+
}, [_dataSource, pagination]);
|
|
93
|
+
return /* @__PURE__ */ import_react.default.createElement("div", null, /* @__PURE__ */ import_react.default.createElement(
|
|
94
|
+
import_antd.Table,
|
|
95
|
+
{
|
|
96
|
+
...other,
|
|
97
|
+
onChange: (pagination2, filters, sorter) => {
|
|
98
|
+
form.setFieldsValue({
|
|
99
|
+
pagination: {
|
|
100
|
+
...formPagination,
|
|
101
|
+
page: 1
|
|
102
|
+
}
|
|
103
|
+
});
|
|
104
|
+
setFilter(filters);
|
|
105
|
+
setSort(sorter);
|
|
106
|
+
},
|
|
107
|
+
pagination: false,
|
|
108
|
+
dataSource: _dataSource == null ? void 0 : _dataSource.list
|
|
109
|
+
}
|
|
110
|
+
), total > (((_a = pagination == null ? void 0 : pagination.pageSizeOptions) == null ? void 0 : _a[0]) || 10) ? /* @__PURE__ */ import_react.default.createElement(import_antd.Form.Item, { name: "pagination" }, /* @__PURE__ */ import_react.default.createElement(
|
|
75
111
|
import_Pagination.FormPagination,
|
|
76
112
|
{
|
|
77
113
|
...pagination,
|
|
@@ -46,7 +46,6 @@ var AddFieldModal = () => {
|
|
|
46
46
|
const [count, setCount] = (0, import_react.useState)(2);
|
|
47
47
|
const [openModal, setOpenModal] = (0, import_react.useState)(false);
|
|
48
48
|
const addField = (values) => {
|
|
49
|
-
console.log(values);
|
|
50
49
|
let field_name = values.field_name;
|
|
51
50
|
if (defaultColumns.find((d) => d.dataIndex === field_name)) {
|
|
52
51
|
import_antd.message.warning("This field already exists");
|
|
@@ -42,6 +42,10 @@ var import_SortRow = __toESM(require("./tableConfig/SortRow"));
|
|
|
42
42
|
var import_body = __toESM(require("./tableConfig/body"));
|
|
43
43
|
var import_header = __toESM(require("./tableConfig/header"));
|
|
44
44
|
var import_Pagination = require("../../Pagination");
|
|
45
|
+
var import_stringFilter = __toESM(require("../TableFilter/stringFilter"));
|
|
46
|
+
var import_numberFilter = __toESM(require("../TableFilter/numberFilter"));
|
|
47
|
+
var import_selectFilter = __toESM(require("../TableFilter/selectFilter"));
|
|
48
|
+
var import_SortIcon = __toESM(require("../TableFilter/SortIcon"));
|
|
45
49
|
var GridViewTable = ({ tableProps }) => {
|
|
46
50
|
const responsive = (0, import_hooks.useResponsive)();
|
|
47
51
|
const { state, dispatch } = (0, import_hooks.useSharedState)(import_model.Context);
|
|
@@ -72,6 +76,7 @@ var GridViewTable = ({ tableProps }) => {
|
|
|
72
76
|
};
|
|
73
77
|
const columns = (0, import_react.useMemo)(() => {
|
|
74
78
|
return defaultColumns.map((col, index) => {
|
|
79
|
+
var _a;
|
|
75
80
|
if (!col.editable) {
|
|
76
81
|
return col;
|
|
77
82
|
}
|
|
@@ -83,8 +88,28 @@ var GridViewTable = ({ tableProps }) => {
|
|
|
83
88
|
lock: col.lock,
|
|
84
89
|
width: col.width || 0
|
|
85
90
|
};
|
|
91
|
+
let filterObj = {};
|
|
92
|
+
if (col.defaultFilters) {
|
|
93
|
+
if (col.field_type === "number") {
|
|
94
|
+
filterObj = (0, import_numberFilter.default)({ dataIndex: col.dataIndex });
|
|
95
|
+
}
|
|
96
|
+
if (col.field_type === "text") {
|
|
97
|
+
filterObj = (0, import_stringFilter.default)({ dataIndex: col.dataIndex });
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
if (((_a = col.filters) == null ? void 0 : _a.length) > 0) {
|
|
101
|
+
filterObj = {
|
|
102
|
+
...(0, import_selectFilter.default)({
|
|
103
|
+
dataIndex: col.dataIndex,
|
|
104
|
+
filters: col.filters
|
|
105
|
+
}),
|
|
106
|
+
filters: col.filters
|
|
107
|
+
};
|
|
108
|
+
}
|
|
86
109
|
return {
|
|
87
110
|
...col,
|
|
111
|
+
...filterObj,
|
|
112
|
+
sortIcon: (props) => /* @__PURE__ */ import_react.default.createElement(import_SortIcon.default, { ...props }),
|
|
88
113
|
onCell: (record) => ({
|
|
89
114
|
record,
|
|
90
115
|
...item,
|
|
@@ -35,7 +35,6 @@ module.exports = __toCommonJS(summary_exports);
|
|
|
35
35
|
var import_antd = require("antd");
|
|
36
36
|
var import_react = __toESM(require("react"));
|
|
37
37
|
var summary = (props) => {
|
|
38
|
-
console.log("summary", props);
|
|
39
38
|
return /* @__PURE__ */ import_react.default.createElement(import_antd.Table.Summary, { fixed: true }, /* @__PURE__ */ import_react.default.createElement(import_antd.Table.Summary.Row, null, /* @__PURE__ */ import_react.default.createElement(import_antd.Table.Summary.Cell, { index: 0, colSpan: 24 }, /* @__PURE__ */ import_react.default.createElement(
|
|
40
39
|
"span",
|
|
41
40
|
{
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const calcFilterSort: ({ dataSource, filter, sort, columns }: any) => any;
|
|
@@ -0,0 +1,108 @@
|
|
|
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/components/table/Table/utils.ts
|
|
30
|
+
var utils_exports = {};
|
|
31
|
+
__export(utils_exports, {
|
|
32
|
+
calcFilterSort: () => calcFilterSort
|
|
33
|
+
});
|
|
34
|
+
module.exports = __toCommonJS(utils_exports);
|
|
35
|
+
var import_dayjs = __toESM(require("dayjs"));
|
|
36
|
+
var transColumnsMap = (columns) => {
|
|
37
|
+
return columns.reduce((p, c) => {
|
|
38
|
+
return {
|
|
39
|
+
...p,
|
|
40
|
+
[c.dataIndex]: c
|
|
41
|
+
};
|
|
42
|
+
}, {});
|
|
43
|
+
};
|
|
44
|
+
var filterFnMap = {
|
|
45
|
+
text: (value, record, dataIndex) => {
|
|
46
|
+
var _a;
|
|
47
|
+
return (_a = record[dataIndex]) == null ? void 0 : _a.toString().toLowerCase().includes(value.toLowerCase());
|
|
48
|
+
},
|
|
49
|
+
number: (value, record, dataIndex) => record[dataIndex] >= value.min && record[dataIndex] <= value.max,
|
|
50
|
+
filters: (value, record, dataIndex) => {
|
|
51
|
+
var _a;
|
|
52
|
+
return value.map((item) => item.toLowerCase()).includes((_a = record[dataIndex]) == null ? void 0 : _a.toString().toLowerCase());
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
var sorter = (item) => (a, b) => {
|
|
56
|
+
if (item.field_type === "date") {
|
|
57
|
+
return (0, import_dayjs.default)(a[item.dataIndex]).valueOf() - (0, import_dayjs.default)(b[item.dataIndex]).valueOf();
|
|
58
|
+
}
|
|
59
|
+
return a[item.dataIndex] - b[item.dataIndex];
|
|
60
|
+
};
|
|
61
|
+
var calcFilterSort = ({ dataSource, filter, sort, columns }) => {
|
|
62
|
+
const columnMap = transColumnsMap(columns);
|
|
63
|
+
const newDataSource = dataSource.filter((item) => {
|
|
64
|
+
return Object.keys(filter || {}).every((f) => {
|
|
65
|
+
var _a, _b;
|
|
66
|
+
if (!((_a = filter[f]) == null ? void 0 : _a.length))
|
|
67
|
+
return true;
|
|
68
|
+
const columnDetail = columnMap[f];
|
|
69
|
+
if (((_b = columnDetail.filters) == null ? void 0 : _b.length) > 0) {
|
|
70
|
+
return filterFnMap["filters"](
|
|
71
|
+
filter[f][0],
|
|
72
|
+
item,
|
|
73
|
+
columnDetail.dataIndex
|
|
74
|
+
);
|
|
75
|
+
}
|
|
76
|
+
if (columnDetail.field_type === "text") {
|
|
77
|
+
return filterFnMap[columnDetail.field_type](
|
|
78
|
+
filter[f][0],
|
|
79
|
+
item,
|
|
80
|
+
columnDetail.dataIndex
|
|
81
|
+
);
|
|
82
|
+
} else if (columnDetail.field_type === "number") {
|
|
83
|
+
return filterFnMap[columnDetail.field_type](
|
|
84
|
+
filter[f][0],
|
|
85
|
+
item,
|
|
86
|
+
columnDetail.dataIndex
|
|
87
|
+
);
|
|
88
|
+
}
|
|
89
|
+
return true;
|
|
90
|
+
});
|
|
91
|
+
});
|
|
92
|
+
if (sort == null ? void 0 : sort.order) {
|
|
93
|
+
newDataSource.sort((a, b) => {
|
|
94
|
+
const { order } = sort;
|
|
95
|
+
if (order === "descend") {
|
|
96
|
+
return sorter(sort.column)(b, a);
|
|
97
|
+
}
|
|
98
|
+
if (order === "ascend") {
|
|
99
|
+
return sorter(sort.column)(a, b);
|
|
100
|
+
}
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
return newDataSource;
|
|
104
|
+
};
|
|
105
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
106
|
+
0 && (module.exports = {
|
|
107
|
+
calcFilterSort
|
|
108
|
+
});
|
|
@@ -0,0 +1,59 @@
|
|
|
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/components/table/TableFilter/SortIcon.tsx
|
|
30
|
+
var SortIcon_exports = {};
|
|
31
|
+
__export(SortIcon_exports, {
|
|
32
|
+
default: () => SortIcon_default
|
|
33
|
+
});
|
|
34
|
+
module.exports = __toCommonJS(SortIcon_exports);
|
|
35
|
+
var import_react = __toESM(require("react"));
|
|
36
|
+
var import_icon = require("@pisell/icon");
|
|
37
|
+
var import_classnames = __toESM(require("classnames"));
|
|
38
|
+
var SortIcon = (props) => {
|
|
39
|
+
const { sortOrder } = props;
|
|
40
|
+
const content = (0, import_react.useMemo)(() => {
|
|
41
|
+
if (sortOrder === "ascend") {
|
|
42
|
+
return /* @__PURE__ */ import_react.default.createElement(import_icon.ArrowUp, { className: "pisell-table-column-up" });
|
|
43
|
+
}
|
|
44
|
+
if (sortOrder === "descend") {
|
|
45
|
+
return /* @__PURE__ */ import_react.default.createElement(import_icon.ArrowUp, { className: "pisell-table-column-down" });
|
|
46
|
+
}
|
|
47
|
+
return /* @__PURE__ */ import_react.default.createElement(import_react.default.Fragment, null, /* @__PURE__ */ import_react.default.createElement(import_icon.ChevronSelectorVertical, { style: { fontSize: 18, color: "#98A2B3" } }));
|
|
48
|
+
}, [sortOrder]);
|
|
49
|
+
return /* @__PURE__ */ import_react.default.createElement(
|
|
50
|
+
"span",
|
|
51
|
+
{
|
|
52
|
+
className: (0, import_classnames.default)("pisell-table-sorter-inner", {
|
|
53
|
+
active: !!sortOrder
|
|
54
|
+
})
|
|
55
|
+
},
|
|
56
|
+
content
|
|
57
|
+
);
|
|
58
|
+
};
|
|
59
|
+
var SortIcon_default = SortIcon;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
.pisell-table-filter-dropdown {
|
|
2
|
+
.pisell-table-filter-dropdown-top {
|
|
3
|
+
padding: 16px;
|
|
4
|
+
border-bottom: 1px solid var(--gray-200, #EAECF0);
|
|
5
|
+
}
|
|
6
|
+
.pisell-table-filter-dropdown-bottom {
|
|
7
|
+
padding: 16px;
|
|
8
|
+
display: flex;
|
|
9
|
+
width: 272px;
|
|
10
|
+
}
|
|
11
|
+
.pisell-table-filter-dropdown-item {
|
|
12
|
+
padding: 10px;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
@@ -0,0 +1,110 @@
|
|
|
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/components/table/TableFilter/numberFilter.tsx
|
|
30
|
+
var numberFilter_exports = {};
|
|
31
|
+
__export(numberFilter_exports, {
|
|
32
|
+
default: () => numberFilter_default
|
|
33
|
+
});
|
|
34
|
+
module.exports = __toCommonJS(numberFilter_exports);
|
|
35
|
+
var import_react = __toESM(require("react"));
|
|
36
|
+
var import_antd = require("antd");
|
|
37
|
+
var import_icon = require("@pisell/icon");
|
|
38
|
+
var import_index = require("./index.less");
|
|
39
|
+
var getColumnNumberProps = ({
|
|
40
|
+
dataIndex
|
|
41
|
+
}) => ({
|
|
42
|
+
filterDropdown: ({
|
|
43
|
+
setSelectedKeys,
|
|
44
|
+
selectedKeys,
|
|
45
|
+
confirm,
|
|
46
|
+
clearFilters,
|
|
47
|
+
close
|
|
48
|
+
}) => {
|
|
49
|
+
var _a, _b;
|
|
50
|
+
return /* @__PURE__ */ import_react.default.createElement(
|
|
51
|
+
"div",
|
|
52
|
+
{
|
|
53
|
+
onKeyDown: (e) => e.stopPropagation(),
|
|
54
|
+
className: "pisell-table-filter-dropdown"
|
|
55
|
+
},
|
|
56
|
+
/* @__PURE__ */ import_react.default.createElement(import_antd.Space, { split: "-", className: "pisell-table-filter-dropdown-top" }, /* @__PURE__ */ import_react.default.createElement(
|
|
57
|
+
import_antd.InputNumber,
|
|
58
|
+
{
|
|
59
|
+
value: (_a = selectedKeys == null ? void 0 : selectedKeys[0]) == null ? void 0 : _a.min,
|
|
60
|
+
onChange: (value) => {
|
|
61
|
+
const newVal = {
|
|
62
|
+
...(selectedKeys == null ? void 0 : selectedKeys[0]) || {},
|
|
63
|
+
min: value
|
|
64
|
+
};
|
|
65
|
+
setSelectedKeys([newVal]);
|
|
66
|
+
},
|
|
67
|
+
placeholder: "Min",
|
|
68
|
+
onPressEnter: () => confirm(),
|
|
69
|
+
style: { width: 105 }
|
|
70
|
+
}
|
|
71
|
+
), /* @__PURE__ */ import_react.default.createElement(
|
|
72
|
+
import_antd.InputNumber,
|
|
73
|
+
{
|
|
74
|
+
value: (_b = selectedKeys == null ? void 0 : selectedKeys[0]) == null ? void 0 : _b.max,
|
|
75
|
+
placeholder: "Max",
|
|
76
|
+
onChange: (value) => {
|
|
77
|
+
const newVal = {
|
|
78
|
+
...(selectedKeys == null ? void 0 : selectedKeys[0]) || {},
|
|
79
|
+
max: value
|
|
80
|
+
};
|
|
81
|
+
setSelectedKeys([newVal]);
|
|
82
|
+
},
|
|
83
|
+
onPressEnter: () => confirm(),
|
|
84
|
+
style: { width: 105 }
|
|
85
|
+
}
|
|
86
|
+
)),
|
|
87
|
+
/* @__PURE__ */ import_react.default.createElement(
|
|
88
|
+
import_antd.Space,
|
|
89
|
+
{
|
|
90
|
+
className: "pisell-table-filter-dropdown-bottom",
|
|
91
|
+
styles: { item: { flex: 1 } }
|
|
92
|
+
},
|
|
93
|
+
/* @__PURE__ */ import_react.default.createElement(
|
|
94
|
+
import_antd.Button,
|
|
95
|
+
{
|
|
96
|
+
onClick: () => {
|
|
97
|
+
clearFilters && clearFilters();
|
|
98
|
+
confirm();
|
|
99
|
+
},
|
|
100
|
+
block: true
|
|
101
|
+
},
|
|
102
|
+
"Clear"
|
|
103
|
+
),
|
|
104
|
+
/* @__PURE__ */ import_react.default.createElement(import_antd.Button, { type: "primary", onClick: () => confirm(), block: true }, "Filter")
|
|
105
|
+
)
|
|
106
|
+
);
|
|
107
|
+
},
|
|
108
|
+
filterIcon: (filtered) => filtered ? /* @__PURE__ */ import_react.default.createElement(import_icon.FilterFunnel01Fill, { style: { color: "#7f56d9", fontSize: 14 } }) : /* @__PURE__ */ import_react.default.createElement(import_icon.FilterFunnel01, { style: { color: "#98A2B3", fontSize: 14 } })
|
|
109
|
+
});
|
|
110
|
+
var numberFilter_default = getColumnNumberProps;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { ColumnType } from "antd/es/table";
|
|
2
|
+
import "./index.less";
|
|
3
|
+
declare const getColumnSelectProps: ({ dataIndex, filters, }: {
|
|
4
|
+
dataIndex: string;
|
|
5
|
+
filters: {
|
|
6
|
+
text: string;
|
|
7
|
+
value: string;
|
|
8
|
+
}[];
|
|
9
|
+
}) => ColumnType<any>;
|
|
10
|
+
export default getColumnSelectProps;
|