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
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import type { Dispatch, SetStateAction } from "react";
|
|
2
1
|
import React from "react";
|
|
3
|
-
import type {
|
|
2
|
+
import type { ColumnsTable } from "./type";
|
|
4
3
|
export type IColumnsChoose<RecordType> = {
|
|
5
|
-
columns:
|
|
6
|
-
|
|
4
|
+
columns: ColumnsTable<RecordType>;
|
|
5
|
+
triggerChangeColumns?: (columns: ColumnsTable<RecordType>) => void;
|
|
7
6
|
t?: any;
|
|
8
7
|
};
|
|
9
8
|
export declare const ColumnsChoose: <RecordType extends object>(props: IColumnsChoose<RecordType>) => React.JSX.Element;
|
|
@@ -1,14 +1,12 @@
|
|
|
1
1
|
import React, { Fragment, useEffect, useMemo, useState } from "react";
|
|
2
2
|
import styled from "styled-components";
|
|
3
|
-
// import type { TreeDataNode} from "antd";
|
|
4
3
|
import { Button, Input, Popover, Tooltip } from "antd";
|
|
5
4
|
import { SettingOutlined } from "@ant-design/icons";
|
|
6
5
|
import { getVisibleColumnKeys, updateColumns } from "./hooks";
|
|
6
|
+
|
|
7
|
+
// import type {TableColumnsType} from "rc-master-ui";
|
|
7
8
|
import Tree from "rc-master-ui/es/tree";
|
|
8
9
|
import SearchOutlined from "@ant-design/icons/SearchOutlined";
|
|
9
|
-
|
|
10
|
-
// const { Search } = Input;
|
|
11
|
-
|
|
12
10
|
const BoxAction = styled.div.withConfig({
|
|
13
11
|
displayName: "BoxAction",
|
|
14
12
|
componentId: "es-grid-template__sc-1ix8yky-0"
|
|
@@ -16,7 +14,7 @@ const BoxAction = styled.div.withConfig({
|
|
|
16
14
|
export const ColumnsChoose = props => {
|
|
17
15
|
const {
|
|
18
16
|
columns: propsColumns,
|
|
19
|
-
|
|
17
|
+
triggerChangeColumns
|
|
20
18
|
// t,
|
|
21
19
|
} = props;
|
|
22
20
|
|
|
@@ -29,20 +27,32 @@ export const ColumnsChoose = props => {
|
|
|
29
27
|
// const columnsChooseRef: any = useRef()
|
|
30
28
|
// const searchRef: any = useRef()
|
|
31
29
|
|
|
32
|
-
const [columns, setColumns] = useState([])
|
|
30
|
+
// const [columns, setColumns] = useState<TableColumnsType>([])
|
|
33
31
|
const [selectedKeys, setSelectedKeys] = useState([]);
|
|
32
|
+
const [isManualUpdate, setIsManualUpdate] = useState(false);
|
|
33
|
+
|
|
34
|
+
// useEffect(() => {
|
|
35
|
+
//
|
|
36
|
+
// const defaultColumns = propsColumns.filter((it) => it.key || it.dataIndex && it.showInColumnChoose !== false)
|
|
37
|
+
// setColumns(defaultColumns as TableColumnsType)
|
|
38
|
+
//
|
|
39
|
+
// }, [propsColumns])
|
|
40
|
+
|
|
41
|
+
const columns = useMemo(() => {
|
|
42
|
+
return propsColumns.filter(it => it.key || it.dataIndex && it.showInColumnChoose !== false);
|
|
43
|
+
// setColumns(defaultColumns as TableColumnsType)
|
|
44
|
+
}, [propsColumns]);
|
|
34
45
|
useEffect(() => {
|
|
35
|
-
const defaultColumns = propsColumns.filter(it => it.key || it.dataIndex && it.
|
|
36
|
-
const defaultSelectedKeys = getVisibleColumnKeys(
|
|
37
|
-
|
|
38
|
-
|
|
46
|
+
const defaultColumns = propsColumns.filter(it => it.key || it.dataIndex && it.showInColumnChoose !== false);
|
|
47
|
+
const defaultSelectedKeys = getVisibleColumnKeys(defaultColumns);
|
|
48
|
+
if (!isManualUpdate) {
|
|
49
|
+
setSelectedKeys(defaultSelectedKeys);
|
|
50
|
+
}
|
|
51
|
+
setIsManualUpdate(false);
|
|
39
52
|
}, [propsColumns]);
|
|
40
53
|
const defaultSelectedKeys = useMemo(() => {
|
|
41
54
|
return getVisibleColumnKeys(propsColumns);
|
|
42
55
|
}, [propsColumns]);
|
|
43
|
-
|
|
44
|
-
// console.log('defaultSelectedKeys', defaultSelectedKeys)
|
|
45
|
-
|
|
46
56
|
const [clicked, setClicked] = useState(false);
|
|
47
57
|
const [autoExpandParent, setAutoExpandParent] = useState(true);
|
|
48
58
|
// const [expandedKeys, setExpandedKeys] = useState<React.Key[]>([]);
|
|
@@ -123,10 +133,11 @@ export const ColumnsChoose = props => {
|
|
|
123
133
|
};
|
|
124
134
|
const onCheck = keys => {
|
|
125
135
|
setSelectedKeys(keys);
|
|
136
|
+
setIsManualUpdate(true);
|
|
126
137
|
};
|
|
127
138
|
const handleAccept = () => {
|
|
128
139
|
const rs1 = updateColumns(propsColumns, selectedKeys);
|
|
129
|
-
|
|
140
|
+
triggerChangeColumns?.(rs1);
|
|
130
141
|
hide();
|
|
131
142
|
};
|
|
132
143
|
const handleCancel = () => {
|
|
@@ -182,7 +193,9 @@ export const ColumnsChoose = props => {
|
|
|
182
193
|
onCheck: keys => onCheck(keys),
|
|
183
194
|
multiple: true,
|
|
184
195
|
checkedKeys: selectedKeys,
|
|
185
|
-
defaultCheckedKeys: selectedKeys
|
|
196
|
+
defaultCheckedKeys: selectedKeys
|
|
197
|
+
// defaultCheckedKeys={defaultSelectedKeys}
|
|
198
|
+
,
|
|
186
199
|
selectedKeys: [],
|
|
187
200
|
height: window.innerHeight - 200
|
|
188
201
|
}), /*#__PURE__*/React.createElement(BoxAction, {
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
+
import React, { Fragment, useState } from "react";
|
|
3
|
+
// import {getTemplate} from "../../hooks"
|
|
4
|
+
import classnames from "classnames";
|
|
5
|
+
import { useFloating, autoUpdate, offset, flip, shift, useHover, useFocus, useDismiss, useRole, useInteractions, FloatingPortal
|
|
6
|
+
// useClick
|
|
7
|
+
} from "@floating-ui/react";
|
|
8
|
+
// import {Button} from "antd";
|
|
9
|
+
import styled from "styled-components";
|
|
10
|
+
import { getTemplate } from "./hooks";
|
|
11
|
+
const TooltipStyle = styled.div.withConfig({
|
|
12
|
+
displayName: "TooltipStyle",
|
|
13
|
+
componentId: "es-grid-template__sc-1iotu11-0"
|
|
14
|
+
})(["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;"]);
|
|
15
|
+
const Command = props => {
|
|
16
|
+
const {
|
|
17
|
+
item,
|
|
18
|
+
onClick
|
|
19
|
+
} = props;
|
|
20
|
+
const [isOpen, setIsOpen] = useState(false);
|
|
21
|
+
const {
|
|
22
|
+
refs,
|
|
23
|
+
floatingStyles,
|
|
24
|
+
context
|
|
25
|
+
} = useFloating({
|
|
26
|
+
open: isOpen,
|
|
27
|
+
onOpenChange: setIsOpen,
|
|
28
|
+
placement: "top",
|
|
29
|
+
whileElementsMounted: autoUpdate,
|
|
30
|
+
middleware: [offset(5), flip({
|
|
31
|
+
fallbackAxisSideDirection: "start"
|
|
32
|
+
}), shift()]
|
|
33
|
+
});
|
|
34
|
+
const hover = useHover(context, {
|
|
35
|
+
move: false
|
|
36
|
+
});
|
|
37
|
+
const focus = useFocus(context);
|
|
38
|
+
const dismiss = useDismiss(context);
|
|
39
|
+
const role = useRole(context, {
|
|
40
|
+
role: "tooltip"
|
|
41
|
+
});
|
|
42
|
+
const {
|
|
43
|
+
getReferenceProps,
|
|
44
|
+
getFloatingProps
|
|
45
|
+
} = useInteractions([hover, focus, dismiss, role]);
|
|
46
|
+
return /*#__PURE__*/React.createElement(Fragment, null, item.template ? /*#__PURE__*/React.createElement("div", _extends({
|
|
47
|
+
ref: refs.setReference
|
|
48
|
+
}, getReferenceProps(), {
|
|
49
|
+
id: item.id,
|
|
50
|
+
onClick: onClick
|
|
51
|
+
}), getTemplate(item.template)) : /*#__PURE__*/React.createElement("div", _extends({
|
|
52
|
+
ref: refs.setReference
|
|
53
|
+
}, getReferenceProps(), {
|
|
54
|
+
tabIndex: -1,
|
|
55
|
+
style: {
|
|
56
|
+
padding: '3px',
|
|
57
|
+
maxWidth: 45,
|
|
58
|
+
height: '100%',
|
|
59
|
+
display: 'flex',
|
|
60
|
+
cursor: 'pointer'
|
|
61
|
+
},
|
|
62
|
+
className: classnames('command-item', {
|
|
63
|
+
'btn-icon': item.title === ''
|
|
64
|
+
}),
|
|
65
|
+
color: item.color ? item.color : 'primary',
|
|
66
|
+
onClick: onClick
|
|
67
|
+
}), item.icon ? getTemplate(item.icon) : item.title)
|
|
68
|
+
|
|
69
|
+
// <span>{item.title}</span>
|
|
70
|
+
, isOpen && item.tooltip && /*#__PURE__*/React.createElement(FloatingPortal, {
|
|
71
|
+
root: document.body
|
|
72
|
+
}, /*#__PURE__*/React.createElement(TooltipStyle, _extends({
|
|
73
|
+
className: "Tooltip",
|
|
74
|
+
ref: refs.setFloating,
|
|
75
|
+
style: {
|
|
76
|
+
...floatingStyles,
|
|
77
|
+
zIndex: 99
|
|
78
|
+
}
|
|
79
|
+
}, getFloatingProps()), item.tooltip)));
|
|
80
|
+
};
|
|
81
|
+
export 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;
|