es-grid-template 0.1.0 → 0.1.2-1
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.d.ts +3 -4
- package/es/grid-component/ColumnsChoose.js +28 -15
- package/es/grid-component/Command.d.ts +8 -0
- package/es/grid-component/Command.js +81 -0
- package/es/grid-component/ContextMenu.d.ts +2 -2
- package/es/grid-component/ContextMenu.js +1 -0
- package/es/grid-component/EditableCell.js +300 -314
- package/es/grid-component/GridStyle.js +1 -1
- package/es/grid-component/InternalTable.js +52 -28
- package/es/grid-component/TableGrid.d.ts +2 -1
- package/es/grid-component/TableGrid.js +64 -18
- 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 +7 -4
- 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 -0
- package/es/grid-component/styles.scss +282 -214
- package/es/grid-component/table/Grid.js +46 -59
- package/es/grid-component/table/GridEdit.d.ts +4 -0
- package/es/grid-component/table/GridEdit.js +106 -19
- package/es/grid-component/type.d.ts +32 -14
- package/es/grid-component/useContext.d.ts +11 -7
- package/es/grid-component/useContext.js +3 -0
- package/es/index.d.ts +1 -0
- package/lib/grid-component/ColumnsChoose.d.ts +3 -4
- package/lib/grid-component/ColumnsChoose.js +27 -14
- package/lib/grid-component/Command.d.ts +8 -0
- package/lib/grid-component/Command.js +90 -0
- package/lib/grid-component/ContextMenu.d.ts +2 -2
- package/lib/grid-component/ContextMenu.js +2 -0
- package/lib/grid-component/EditableCell.js +297 -311
- package/lib/grid-component/GridStyle.js +1 -1
- package/lib/grid-component/InternalTable.js +51 -27
- package/lib/grid-component/TableGrid.d.ts +2 -1
- package/lib/grid-component/TableGrid.js +63 -17
- 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 +7 -4
- 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 -0
- package/lib/grid-component/styles.scss +282 -214
- package/lib/grid-component/table/Grid.js +46 -59
- package/lib/grid-component/table/GridEdit.d.ts +4 -0
- package/lib/grid-component/table/GridEdit.js +106 -19
- package/lib/grid-component/type.d.ts +32 -14
- package/lib/grid-component/useContext.d.ts +11 -7
- package/lib/grid-component/useContext.js +2 -0
- package/lib/index.d.ts +1 -0
- package/package.json +102 -112
- /package/es/{grid-component/Message → Message}/Message.d.ts +0 -0
- /package/es/{grid-component/Message → Message}/Message.js +0 -0
- /package/es/{grid-component/Message → Message}/index.d.ts +0 -0
- /package/es/{grid-component/Message → Message}/index.js +0 -0
- /package/lib/{grid-component/Message → Message}/Message.d.ts +0 -0
- /package/lib/{grid-component/Message → Message}/Message.js +0 -0
- /package/lib/{grid-component/Message → Message}/index.d.ts +0 -0
- /package/lib/{grid-component/Message → Message}/index.js +0 -0
|
@@ -14,9 +14,7 @@ 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 {
|
|
18
|
-
|
|
19
|
-
// const { Search } = Input;
|
|
17
|
+
// import type {TableColumnsType} from "rc-master-ui";
|
|
20
18
|
|
|
21
19
|
const BoxAction = _styledComponents.default.div.withConfig({
|
|
22
20
|
displayName: "BoxAction",
|
|
@@ -25,7 +23,7 @@ const BoxAction = _styledComponents.default.div.withConfig({
|
|
|
25
23
|
const ColumnsChoose = props => {
|
|
26
24
|
const {
|
|
27
25
|
columns: propsColumns,
|
|
28
|
-
|
|
26
|
+
triggerChangeColumns
|
|
29
27
|
// t,
|
|
30
28
|
} = props;
|
|
31
29
|
|
|
@@ -38,20 +36,32 @@ const ColumnsChoose = props => {
|
|
|
38
36
|
// const columnsChooseRef: any = useRef()
|
|
39
37
|
// const searchRef: any = useRef()
|
|
40
38
|
|
|
41
|
-
const [columns, setColumns] =
|
|
39
|
+
// const [columns, setColumns] = useState<TableColumnsType>([])
|
|
42
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]);
|
|
43
54
|
(0, _react.useEffect)(() => {
|
|
44
|
-
const defaultColumns = propsColumns.filter(it => it.key || it.dataIndex && it.
|
|
45
|
-
const defaultSelectedKeys = (0, _hooks.getVisibleColumnKeys)(
|
|
46
|
-
|
|
47
|
-
|
|
55
|
+
const defaultColumns = propsColumns.filter(it => it.key || it.dataIndex && it.showInColumnChoose !== false);
|
|
56
|
+
const defaultSelectedKeys = (0, _hooks.getVisibleColumnKeys)(defaultColumns);
|
|
57
|
+
if (!isManualUpdate) {
|
|
58
|
+
setSelectedKeys(defaultSelectedKeys);
|
|
59
|
+
}
|
|
60
|
+
setIsManualUpdate(false);
|
|
48
61
|
}, [propsColumns]);
|
|
49
62
|
const defaultSelectedKeys = (0, _react.useMemo)(() => {
|
|
50
63
|
return (0, _hooks.getVisibleColumnKeys)(propsColumns);
|
|
51
64
|
}, [propsColumns]);
|
|
52
|
-
|
|
53
|
-
// console.log('defaultSelectedKeys', defaultSelectedKeys)
|
|
54
|
-
|
|
55
65
|
const [clicked, setClicked] = (0, _react.useState)(false);
|
|
56
66
|
const [autoExpandParent, setAutoExpandParent] = (0, _react.useState)(true);
|
|
57
67
|
// const [expandedKeys, setExpandedKeys] = useState<React.Key[]>([]);
|
|
@@ -132,10 +142,11 @@ const ColumnsChoose = props => {
|
|
|
132
142
|
};
|
|
133
143
|
const onCheck = keys => {
|
|
134
144
|
setSelectedKeys(keys);
|
|
145
|
+
setIsManualUpdate(true);
|
|
135
146
|
};
|
|
136
147
|
const handleAccept = () => {
|
|
137
148
|
const rs1 = (0, _hooks.updateColumns)(propsColumns, selectedKeys);
|
|
138
|
-
|
|
149
|
+
triggerChangeColumns?.(rs1);
|
|
139
150
|
hide();
|
|
140
151
|
};
|
|
141
152
|
const handleCancel = () => {
|
|
@@ -191,7 +202,9 @@ const ColumnsChoose = props => {
|
|
|
191
202
|
onCheck: keys => onCheck(keys),
|
|
192
203
|
multiple: true,
|
|
193
204
|
checkedKeys: selectedKeys,
|
|
194
|
-
defaultCheckedKeys: selectedKeys
|
|
205
|
+
defaultCheckedKeys: selectedKeys
|
|
206
|
+
// defaultCheckedKeys={defaultSelectedKeys}
|
|
207
|
+
,
|
|
195
208
|
selectedKeys: [],
|
|
196
209
|
height: window.innerHeight - 200
|
|
197
210
|
}), /*#__PURE__*/_react.default.createElement(BoxAction, {
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.default = void 0;
|
|
8
|
+
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
9
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
10
|
+
var _classnames = _interopRequireDefault(require("classnames"));
|
|
11
|
+
var _react2 = require("@floating-ui/react");
|
|
12
|
+
var _styledComponents = _interopRequireDefault(require("styled-components"));
|
|
13
|
+
var _hooks = require("./hooks");
|
|
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); }
|
|
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; }
|
|
16
|
+
// import {getTemplate} from "../../hooks"
|
|
17
|
+
|
|
18
|
+
// import {Button} from "antd";
|
|
19
|
+
|
|
20
|
+
const TooltipStyle = _styledComponents.default.div.withConfig({
|
|
21
|
+
displayName: "TooltipStyle",
|
|
22
|
+
componentId: "es-grid-template__sc-1iotu11-0"
|
|
23
|
+
})(["width:max-content;background-color:#444;color:white;font-size:90%;padding:4px 8px;border-radius:4px;opacity:0.9;z-index:9999;max-width:450px;"]);
|
|
24
|
+
const Command = props => {
|
|
25
|
+
const {
|
|
26
|
+
item,
|
|
27
|
+
onClick
|
|
28
|
+
} = props;
|
|
29
|
+
const [isOpen, setIsOpen] = (0, _react.useState)(false);
|
|
30
|
+
const {
|
|
31
|
+
refs,
|
|
32
|
+
floatingStyles,
|
|
33
|
+
context
|
|
34
|
+
} = (0, _react2.useFloating)({
|
|
35
|
+
open: isOpen,
|
|
36
|
+
onOpenChange: setIsOpen,
|
|
37
|
+
placement: "top",
|
|
38
|
+
whileElementsMounted: _react2.autoUpdate,
|
|
39
|
+
middleware: [(0, _react2.offset)(5), (0, _react2.flip)({
|
|
40
|
+
fallbackAxisSideDirection: "start"
|
|
41
|
+
}), (0, _react2.shift)()]
|
|
42
|
+
});
|
|
43
|
+
const hover = (0, _react2.useHover)(context, {
|
|
44
|
+
move: false
|
|
45
|
+
});
|
|
46
|
+
const focus = (0, _react2.useFocus)(context);
|
|
47
|
+
const dismiss = (0, _react2.useDismiss)(context);
|
|
48
|
+
const role = (0, _react2.useRole)(context, {
|
|
49
|
+
role: "tooltip"
|
|
50
|
+
});
|
|
51
|
+
const {
|
|
52
|
+
getReferenceProps,
|
|
53
|
+
getFloatingProps
|
|
54
|
+
} = (0, _react2.useInteractions)([hover, focus, dismiss, role]);
|
|
55
|
+
return /*#__PURE__*/_react.default.createElement(_react.Fragment, null, item.template ? /*#__PURE__*/_react.default.createElement("div", (0, _extends2.default)({
|
|
56
|
+
ref: refs.setReference
|
|
57
|
+
}, getReferenceProps(), {
|
|
58
|
+
id: item.id,
|
|
59
|
+
onClick: onClick
|
|
60
|
+
}), (0, _hooks.getTemplate)(item.template)) : /*#__PURE__*/_react.default.createElement("div", (0, _extends2.default)({
|
|
61
|
+
ref: refs.setReference
|
|
62
|
+
}, getReferenceProps(), {
|
|
63
|
+
tabIndex: -1,
|
|
64
|
+
style: {
|
|
65
|
+
padding: '3px',
|
|
66
|
+
maxWidth: 45,
|
|
67
|
+
height: '100%',
|
|
68
|
+
display: 'flex',
|
|
69
|
+
cursor: 'pointer'
|
|
70
|
+
},
|
|
71
|
+
className: (0, _classnames.default)('command-item', {
|
|
72
|
+
'btn-icon': item.title === ''
|
|
73
|
+
}),
|
|
74
|
+
color: item.color ? item.color : 'primary',
|
|
75
|
+
onClick: onClick
|
|
76
|
+
}), item.icon ? (0, _hooks.getTemplate)(item.icon) : item.title)
|
|
77
|
+
|
|
78
|
+
// <span>{item.title}</span>
|
|
79
|
+
, isOpen && item.tooltip && /*#__PURE__*/_react.default.createElement(_react2.FloatingPortal, {
|
|
80
|
+
root: document.body
|
|
81
|
+
}, /*#__PURE__*/_react.default.createElement(TooltipStyle, (0, _extends2.default)({
|
|
82
|
+
className: "Tooltip",
|
|
83
|
+
ref: refs.setFloating,
|
|
84
|
+
style: {
|
|
85
|
+
...floatingStyles,
|
|
86
|
+
zIndex: 99
|
|
87
|
+
}
|
|
88
|
+
}, getFloatingProps()), item.tooltip)));
|
|
89
|
+
};
|
|
90
|
+
var _default = exports.default = Command;
|
|
@@ -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];
|