es-grid-template 0.1.1 → 0.1.2-2
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/es/grid-component/ColumnsChoose.js +25 -8
- package/es/grid-component/Command.js +6 -5
- package/es/grid-component/ContextMenu.d.ts +2 -2
- package/es/grid-component/ContextMenu.js +1 -0
- package/es/grid-component/EditableCell.js +265 -248
- package/es/grid-component/GridStyle.js +1 -1
- package/es/grid-component/InternalTable.js +24 -16
- package/es/grid-component/TableGrid.js +4 -2
- package/es/grid-component/async-select/index.d.ts +9 -0
- package/es/grid-component/async-select/index.js +35 -0
- package/es/grid-component/hooks/constant.d.ts +10 -0
- package/es/grid-component/hooks/constant.js +11 -1
- package/es/grid-component/hooks/useColumns/index.js +11 -7
- package/es/grid-component/hooks/utils.d.ts +2 -0
- package/es/grid-component/hooks/utils.js +11 -0
- package/es/grid-component/index.d.ts +3 -2
- package/es/grid-component/styles.scss +101 -30
- package/es/grid-component/table/Grid.js +7 -7
- package/es/grid-component/table/GridEdit.d.ts +1 -1
- package/es/grid-component/table/GridEdit.js +21 -16
- package/es/grid-component/type.d.ts +6 -3
- package/es/grid-component/useContext.d.ts +2 -1
- package/es/index.d.ts +1 -1
- package/lib/grid-component/ColumnsChoose.js +25 -8
- package/lib/grid-component/Command.js +7 -5
- package/lib/grid-component/ContextMenu.d.ts +2 -2
- package/lib/grid-component/ContextMenu.js +2 -0
- package/lib/grid-component/EditableCell.js +262 -245
- package/lib/grid-component/GridStyle.js +1 -1
- package/lib/grid-component/InternalTable.js +24 -16
- package/lib/grid-component/TableGrid.js +4 -2
- package/lib/grid-component/async-select/index.d.ts +9 -0
- package/lib/grid-component/async-select/index.js +44 -0
- package/lib/grid-component/hooks/constant.d.ts +10 -0
- package/lib/grid-component/hooks/constant.js +12 -2
- package/lib/grid-component/hooks/useColumns/index.js +11 -7
- package/lib/grid-component/hooks/utils.d.ts +2 -0
- package/lib/grid-component/hooks/utils.js +16 -3
- package/lib/grid-component/index.d.ts +3 -2
- package/lib/grid-component/styles.scss +101 -30
- package/lib/grid-component/table/Grid.js +7 -7
- package/lib/grid-component/table/GridEdit.d.ts +1 -1
- package/lib/grid-component/table/GridEdit.js +21 -16
- package/lib/grid-component/type.d.ts +6 -3
- package/lib/grid-component/useContext.d.ts +2 -1
- package/lib/index.d.ts +1 -1
- package/package.json +4 -15
|
@@ -16,12 +16,13 @@ export interface IContext<RecordType> {
|
|
|
16
16
|
handleSubmit?: any;
|
|
17
17
|
onSubmit?: SubmitHandler<any>;
|
|
18
18
|
getValues?: any;
|
|
19
|
-
handleCellChange?: (
|
|
19
|
+
handleCellChange?: (args: ContextCellChange<RecordType>) => void;
|
|
20
20
|
getRowKey?: GetRowKey<RecordType>;
|
|
21
21
|
}
|
|
22
22
|
export type ContextCellChange<RecordType = AnyObject> = {
|
|
23
23
|
key: string | keyof RecordType | GetRowKey<RecordType>;
|
|
24
24
|
record: any;
|
|
25
|
+
field: string | undefined;
|
|
25
26
|
option: any;
|
|
26
27
|
newState?: any;
|
|
27
28
|
prevState?: any;
|
package/es/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export { default as GridComponent } from './grid-component';
|
|
2
|
-
export type { ColumnsTable, TableProps, ColumnTable } from './grid-component';
|
|
2
|
+
export type { ColumnsTable, TableProps, ColumnTable, CommandItem, ToolbarItem, ContextMenuItem } from './grid-component';
|
|
@@ -14,6 +14,8 @@ var _tree = _interopRequireDefault(require("rc-master-ui/es/tree"));
|
|
|
14
14
|
var _SearchOutlined = _interopRequireDefault(require("@ant-design/icons/SearchOutlined"));
|
|
15
15
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
16
16
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
17
|
+
// import type {TableColumnsType} from "rc-master-ui";
|
|
18
|
+
|
|
17
19
|
const BoxAction = _styledComponents.default.div.withConfig({
|
|
18
20
|
displayName: "BoxAction",
|
|
19
21
|
componentId: "es-grid-template__sc-1ix8yky-0"
|
|
@@ -34,20 +36,32 @@ const ColumnsChoose = props => {
|
|
|
34
36
|
// const columnsChooseRef: any = useRef()
|
|
35
37
|
// const searchRef: any = useRef()
|
|
36
38
|
|
|
37
|
-
const [columns, setColumns] =
|
|
39
|
+
// const [columns, setColumns] = useState<TableColumnsType>([])
|
|
38
40
|
const [selectedKeys, setSelectedKeys] = (0, _react.useState)([]);
|
|
41
|
+
const [isManualUpdate, setIsManualUpdate] = (0, _react.useState)(false);
|
|
42
|
+
|
|
43
|
+
// useEffect(() => {
|
|
44
|
+
//
|
|
45
|
+
// const defaultColumns = propsColumns.filter((it) => it.key || it.dataIndex && it.showInColumnChoose !== false)
|
|
46
|
+
// setColumns(defaultColumns as TableColumnsType)
|
|
47
|
+
//
|
|
48
|
+
// }, [propsColumns])
|
|
49
|
+
|
|
50
|
+
const columns = (0, _react.useMemo)(() => {
|
|
51
|
+
return propsColumns.filter(it => it.key || it.dataIndex && it.showInColumnChoose !== false);
|
|
52
|
+
// setColumns(defaultColumns as TableColumnsType)
|
|
53
|
+
}, [propsColumns]);
|
|
39
54
|
(0, _react.useEffect)(() => {
|
|
40
55
|
const defaultColumns = propsColumns.filter(it => it.key || it.dataIndex && it.showInColumnChoose !== false);
|
|
41
|
-
const defaultSelectedKeys = (0, _hooks.getVisibleColumnKeys)(
|
|
42
|
-
|
|
43
|
-
|
|
56
|
+
const defaultSelectedKeys = (0, _hooks.getVisibleColumnKeys)(defaultColumns);
|
|
57
|
+
if (!isManualUpdate) {
|
|
58
|
+
setSelectedKeys(defaultSelectedKeys);
|
|
59
|
+
}
|
|
60
|
+
setIsManualUpdate(false);
|
|
44
61
|
}, [propsColumns]);
|
|
45
62
|
const defaultSelectedKeys = (0, _react.useMemo)(() => {
|
|
46
63
|
return (0, _hooks.getVisibleColumnKeys)(propsColumns);
|
|
47
64
|
}, [propsColumns]);
|
|
48
|
-
|
|
49
|
-
// console.log('defaultSelectedKeys', defaultSelectedKeys)
|
|
50
|
-
|
|
51
65
|
const [clicked, setClicked] = (0, _react.useState)(false);
|
|
52
66
|
const [autoExpandParent, setAutoExpandParent] = (0, _react.useState)(true);
|
|
53
67
|
// const [expandedKeys, setExpandedKeys] = useState<React.Key[]>([]);
|
|
@@ -128,6 +142,7 @@ const ColumnsChoose = props => {
|
|
|
128
142
|
};
|
|
129
143
|
const onCheck = keys => {
|
|
130
144
|
setSelectedKeys(keys);
|
|
145
|
+
setIsManualUpdate(true);
|
|
131
146
|
};
|
|
132
147
|
const handleAccept = () => {
|
|
133
148
|
const rs1 = (0, _hooks.updateColumns)(propsColumns, selectedKeys);
|
|
@@ -187,7 +202,9 @@ const ColumnsChoose = props => {
|
|
|
187
202
|
onCheck: keys => onCheck(keys),
|
|
188
203
|
multiple: true,
|
|
189
204
|
checkedKeys: selectedKeys,
|
|
190
|
-
defaultCheckedKeys: selectedKeys
|
|
205
|
+
defaultCheckedKeys: selectedKeys
|
|
206
|
+
// defaultCheckedKeys={defaultSelectedKeys}
|
|
207
|
+
,
|
|
191
208
|
selectedKeys: [],
|
|
192
209
|
height: window.innerHeight - 200
|
|
193
210
|
}), /*#__PURE__*/_react.default.createElement(BoxAction, {
|
|
@@ -9,13 +9,14 @@ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends")
|
|
|
9
9
|
var _react = _interopRequireWildcard(require("react"));
|
|
10
10
|
var _classnames = _interopRequireDefault(require("classnames"));
|
|
11
11
|
var _react2 = require("@floating-ui/react");
|
|
12
|
-
var _antd = require("antd");
|
|
13
12
|
var _styledComponents = _interopRequireDefault(require("styled-components"));
|
|
14
13
|
var _hooks = require("./hooks");
|
|
15
14
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
16
15
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
17
16
|
// import {getTemplate} from "../../hooks"
|
|
18
17
|
|
|
18
|
+
// import {Button} from "antd";
|
|
19
|
+
|
|
19
20
|
const TooltipStyle = _styledComponents.default.div.withConfig({
|
|
20
21
|
displayName: "TooltipStyle",
|
|
21
22
|
componentId: "es-grid-template__sc-1iotu11-0"
|
|
@@ -58,20 +59,21 @@ const Command = props => {
|
|
|
58
59
|
onClick: onClick
|
|
59
60
|
}), (0, _hooks.getTemplate)(item.template)) : /*#__PURE__*/_react.default.createElement("div", (0, _extends2.default)({
|
|
60
61
|
ref: refs.setReference
|
|
61
|
-
}, getReferenceProps()
|
|
62
|
-
id: 'tooltip',
|
|
62
|
+
}, getReferenceProps(), {
|
|
63
63
|
tabIndex: -1,
|
|
64
64
|
style: {
|
|
65
65
|
padding: '3px',
|
|
66
66
|
maxWidth: 45,
|
|
67
|
-
height: '100%'
|
|
67
|
+
height: '100%',
|
|
68
|
+
display: 'flex',
|
|
69
|
+
cursor: 'pointer'
|
|
68
70
|
},
|
|
69
71
|
className: (0, _classnames.default)('command-item', {
|
|
70
72
|
'btn-icon': item.title === ''
|
|
71
73
|
}),
|
|
72
74
|
color: item.color ? item.color : 'primary',
|
|
73
75
|
onClick: onClick
|
|
74
|
-
}, item.icon ? (0, _hooks.getTemplate)(item.icon) : item.title)
|
|
76
|
+
}), item.icon ? (0, _hooks.getTemplate)(item.icon) : item.title)
|
|
75
77
|
|
|
76
78
|
// <span>{item.title}</span>
|
|
77
79
|
, isOpen && item.tooltip && /*#__PURE__*/_react.default.createElement(_react2.FloatingPortal, {
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
-
import type { MenuProps } from "antd";
|
|
3
2
|
import type { ContextInfo } from "./type";
|
|
3
|
+
import type { ContextMenuItem } from "./type";
|
|
4
4
|
export declare const findItemByKey: (array: any[], key: string, value: any) => any;
|
|
5
5
|
type Props<RecordType> = {
|
|
6
6
|
rowData: RecordType | null;
|
|
7
|
-
contextMenuItems:
|
|
7
|
+
contextMenuItems: ContextMenuItem[];
|
|
8
8
|
contextMenuClick?: (args: ContextInfo<RecordType>) => void;
|
|
9
9
|
open: boolean;
|
|
10
10
|
menuRef?: any;
|
|
@@ -8,6 +8,8 @@ var React = _interopRequireWildcard(require("react"));
|
|
|
8
8
|
var _antd = require("antd");
|
|
9
9
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
10
10
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
11
|
+
// import type { MenuProps } from "antd";
|
|
12
|
+
|
|
11
13
|
const findItemByKey = (array, key, value) => {
|
|
12
14
|
for (let i = 0; i < array.length; i++) {
|
|
13
15
|
const item = array[i];
|