es-grid-template 0.0.5 → 0.0.8

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.
Files changed (73) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/LICENSE +19 -0
  3. package/README.md +1 -6
  4. package/{dist/components/GridTable → es}/CheckboxFilter.d.ts +1 -1
  5. package/es/CheckboxFilter.js +246 -0
  6. package/es/ColumnsChoose.d.ts +9 -0
  7. package/es/ColumnsChoose.js +209 -0
  8. package/{dist/components/GridTable → es}/ContextMenu.d.ts +1 -1
  9. package/es/ContextMenu.js +126 -0
  10. package/{dist/components/GridTable → es}/FilterSearch.d.ts +3 -3
  11. package/es/FilterSearch.js +33 -0
  12. package/es/InternalTable.d.ts +7 -0
  13. package/es/InternalTable.js +185 -0
  14. package/es/LoadingSpinner.d.ts +3 -0
  15. package/es/LoadingSpinner.js +20 -0
  16. package/es/TableGrid.d.ts +10 -0
  17. package/es/TableGrid.js +1055 -0
  18. package/es/hooks/constant.js +214 -0
  19. package/es/hooks/index.js +5 -0
  20. package/{dist → es}/hooks/useColumns/index.d.ts +1 -1
  21. package/es/hooks/useColumns/index.js +25 -0
  22. package/{dist → es}/hooks/useIsOverflow.d.ts +1 -1
  23. package/es/hooks/useIsOverflow.js +17 -0
  24. package/es/hooks/useOnClickOutside.js +28 -0
  25. package/{dist → es}/hooks/utils.d.ts +7 -6
  26. package/es/hooks/utils.js +212 -0
  27. package/es/index.d.ts +2 -0
  28. package/es/index.js +2 -0
  29. package/es/styles.scss +296 -0
  30. package/es/type.d.ts +100 -0
  31. package/es/type.js +1 -0
  32. package/lib/CheckboxFilter.d.ts +19 -0
  33. package/lib/CheckboxFilter.js +255 -0
  34. package/lib/ColumnsChoose.d.ts +9 -0
  35. package/lib/ColumnsChoose.js +219 -0
  36. package/lib/ContextMenu.d.ts +20 -0
  37. package/lib/ContextMenu.js +135 -0
  38. package/lib/FilterSearch.d.ts +12 -0
  39. package/lib/FilterSearch.js +42 -0
  40. package/lib/InternalTable.d.ts +7 -0
  41. package/lib/InternalTable.js +194 -0
  42. package/lib/LoadingSpinner.d.ts +3 -0
  43. package/lib/LoadingSpinner.js +29 -0
  44. package/lib/TableGrid.d.ts +10 -0
  45. package/lib/TableGrid.js +1063 -0
  46. package/lib/hooks/constant.d.ts +48 -0
  47. package/lib/hooks/constant.js +221 -0
  48. package/lib/hooks/index.d.ts +4 -0
  49. package/lib/hooks/index.js +49 -0
  50. package/lib/hooks/useColumns/index.d.ts +2 -0
  51. package/lib/hooks/useColumns/index.js +31 -0
  52. package/lib/hooks/useIsOverflow.d.ts +1 -0
  53. package/lib/hooks/useIsOverflow.js +26 -0
  54. package/lib/hooks/useOnClickOutside.d.ts +1 -0
  55. package/lib/hooks/useOnClickOutside.js +36 -0
  56. package/lib/hooks/utils.d.ts +19 -0
  57. package/lib/hooks/utils.js +236 -0
  58. package/lib/index.d.ts +2 -0
  59. package/lib/index.js +9 -0
  60. package/lib/styles.scss +296 -0
  61. package/lib/type.d.ts +100 -0
  62. package/lib/type.js +5 -0
  63. package/package.json +77 -94
  64. package/dist/components/GridTable/ColumnsChoose.d.ts +0 -9
  65. package/dist/components/GridTable/GridTable.d.ts +0 -6
  66. package/dist/components/GridTable/index.d.ts +0 -1
  67. package/dist/components/index.d.ts +0 -1
  68. package/dist/index.d.ts +0 -2
  69. package/dist/index.js +0 -53
  70. package/dist/type.d.ts +0 -44
  71. /package/{dist → es}/hooks/constant.d.ts +0 -0
  72. /package/{dist → es}/hooks/index.d.ts +0 -0
  73. /package/{dist → es}/hooks/useOnClickOutside.d.ts +0 -0
package/CHANGELOG.md ADDED
@@ -0,0 +1,6 @@
1
+ # Changelog
2
+
3
+
4
+ ## 0.0.1 / 20-02-2025
5
+
6
+ add package
package/LICENSE ADDED
@@ -0,0 +1,19 @@
1
+ The MIT License (MIT)
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ of this software and associated documentation files (the "Software"), to deal
5
+ in the Software without restriction, including without limitation the rights
6
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ copies of the Software, and to permit persons to whom the Software is
8
+ furnished to do so, subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included in
11
+ all copies or substantial portions of the Software.
12
+
13
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
14
+ OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
15
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
16
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
17
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
18
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
19
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
package/README.md CHANGED
@@ -1,6 +1 @@
1
- #
2
-
3
- ## Quick Features
4
-
5
-
6
- <!-- Force 1 -->
1
+ # es-grid-template
@@ -1,5 +1,5 @@
1
1
  import * as React from "react";
2
- import { TableLocale } from "antd/es/table/interface";
2
+ import type { TableLocale } from "rc-master-ui/es/table/interface";
3
3
  type Props = {
4
4
  options: any[];
5
5
  filterSearch?: boolean;
@@ -0,0 +1,246 @@
1
+ import * as React from "react";
2
+ import classNames from "classnames";
3
+ import FilterSearch from "./FilterSearch";
4
+ import { Checkbox, Menu, Radio, Empty } from "rc-master-ui";
5
+ import { Tree } from "antd";
6
+ import { flattenKeys } from "rc-master-ui/es/table/hooks/useFilter";
7
+ // import Tree from "rc-master-ui/es/tree";
8
+
9
+ function searchValueMatched(searchValue, text) {
10
+ if (typeof text === 'string' || typeof text === 'number') {
11
+ return text?.toString().toLowerCase().includes(searchValue.trim().toLowerCase());
12
+ }
13
+ return false;
14
+ }
15
+ function renderFilterItems({
16
+ filters,
17
+ prefixCls,
18
+ filteredKeys,
19
+ filterMultiple,
20
+ searchValue,
21
+ filterSearch
22
+ }) {
23
+ return filters.map((filter, index) => {
24
+ const key = String(filter.value);
25
+ if (filter.children) {
26
+ return {
27
+ key: key || index,
28
+ label: filter.text,
29
+ popupClassName: `${prefixCls}-dropdown-submenu`,
30
+ children: renderFilterItems({
31
+ filters: filter.children,
32
+ prefixCls,
33
+ filteredKeys,
34
+ filterMultiple,
35
+ searchValue,
36
+ filterSearch
37
+ })
38
+ };
39
+ }
40
+ const Component = filterMultiple ? Checkbox : Radio;
41
+ const item = {
42
+ key: filter.value !== undefined ? key : index,
43
+ label: /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Component, {
44
+ checked: filteredKeys.includes(key)
45
+ }), /*#__PURE__*/React.createElement("span", null, filter.text))
46
+ };
47
+ if (searchValue.trim()) {
48
+ if (typeof filterSearch === 'function') {
49
+ return filterSearch(searchValue, filter) ? item : null;
50
+ }
51
+ return searchValueMatched(searchValue, filter.text) ? item : null;
52
+ }
53
+ return item;
54
+ });
55
+ }
56
+ function hasSubMenu(filters) {
57
+ return filters.some(({
58
+ children
59
+ }) => children);
60
+ }
61
+ const CheckboxFilter = props => {
62
+ const {
63
+ // column,
64
+ filterSearch = true,
65
+ tablePrefixCls = 'ui-rc-table',
66
+ prefixCls = 'ui-rc-table-filter',
67
+ dropdownPrefixCls = 'ui-rc-dropdown',
68
+ filterMultiple,
69
+ selectedKeys,
70
+ locale,
71
+ options,
72
+ filterMode = 'tree',
73
+ // open,
74
+ searchValue,
75
+ setSearchValue,
76
+ onSelect
77
+ } = props;
78
+
79
+ // const [searchValue, setSearchValue] = React.useState('');
80
+
81
+ const [openKeys, setOpenKeys] = React.useState([]);
82
+
83
+ // clear search value after close filter dropdown
84
+ // React.useEffect(() => {
85
+ // // if (visible) {
86
+ // setSearchValue('');
87
+ // // }
88
+ // }, [open]);
89
+
90
+ const onOpenChange = keys => {
91
+ setOpenKeys(keys);
92
+ };
93
+ const items = renderFilterItems({
94
+ // filters: column.filters || [],
95
+ filters: options || [],
96
+ filterSearch,
97
+ prefixCls,
98
+ filteredKeys: selectedKeys ?? [],
99
+ filterMultiple,
100
+ searchValue
101
+ });
102
+ const dropdownMenuClass = classNames({
103
+ // [`${dropdownPrefixCls}-menu-without-submenu`]: !hasSubMenu(column.filters || []),
104
+ [`${dropdownPrefixCls}-menu-without-submenu`]: !hasSubMenu(options || [])
105
+ });
106
+ console.log('selectedKeys', selectedKeys);
107
+ const empty = /*#__PURE__*/React.createElement(Empty, {
108
+ image: Empty.PRESENTED_IMAGE_SIMPLE,
109
+ description: locale.filterEmptyText,
110
+ imageStyle: {
111
+ height: 24
112
+ },
113
+ style: {
114
+ margin: 0,
115
+ padding: '16px 0'
116
+ }
117
+ });
118
+ const isEmpty = items.every(item => item === null);
119
+ const onSearch = e => {
120
+ const {
121
+ value
122
+ } = e.target;
123
+ setSearchValue(value);
124
+ };
125
+
126
+ // if ((column.filters || []).length === 0) {
127
+ // return empty;
128
+ // }
129
+
130
+ const getTreeData = ({
131
+ filters
132
+ }) => (filters || []).map((filter, index) => {
133
+ const key = String(filter.value);
134
+ const item = {
135
+ title: filter.text,
136
+ key: filter.value !== undefined ? key : String(index)
137
+ };
138
+ if (filter.children) {
139
+ item.children = getTreeData({
140
+ filters: filter.children
141
+ });
142
+ }
143
+ return item;
144
+ });
145
+ const getFilterData = node => ({
146
+ ...node,
147
+ text: node.title,
148
+ value: node.key,
149
+ children: node.children?.map(item => getFilterData(item)) || []
150
+ });
151
+ const onCheckAll = e => {
152
+ // console.log('e.target.checked', e.target.checked)
153
+ if (e.target.checked) {
154
+ const allFilterKeys = flattenKeys(options).map(key => String(key));
155
+
156
+ // console.log('allFilterKeys', allFilterKeys)
157
+ // setFilteredKeysSync(allFilterKeys);
158
+ onSelect?.(allFilterKeys);
159
+ } else {
160
+ onSelect?.([]);
161
+ // setFilteredKeysSync([]);
162
+ }
163
+ };
164
+ const onCheck = (keys, {
165
+ node,
166
+ checked
167
+ }) => {
168
+ if (!filterMultiple) {
169
+ // onSelectKeys({ selectedKeys: checked && node.key ? [node.key] : [] });
170
+ onSelect?.(checked && node.key ? [node.key] : []);
171
+ } else {
172
+ // onSelectKeys({ selectedKeys: keys });
173
+ onSelect?.(keys);
174
+ }
175
+ };
176
+ if (filterMode === 'tree') {
177
+ return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(FilterSearch, {
178
+ filterSearch: filterSearch,
179
+ value: searchValue,
180
+ onChange: onSearch,
181
+ tablePrefixCls: tablePrefixCls,
182
+ locale: locale
183
+ }), /*#__PURE__*/React.createElement("div", {
184
+ className: `${tablePrefixCls}-filter-dropdown-tree`
185
+ }, filterMultiple ? /*#__PURE__*/React.createElement(Checkbox
186
+ // checked={selectedKeys.length === flattenKeys(column.filters).length}
187
+ , {
188
+ checked: selectedKeys.length === flattenKeys(options).length
189
+ // indeterminate={
190
+ // selectedKeys.length > 0 &&
191
+ // selectedKeys.length < flattenKeys(column.filters).length
192
+ // }
193
+ ,
194
+
195
+ indeterminate: selectedKeys.length > 0 && selectedKeys.length < flattenKeys(options).length,
196
+ className: `${tablePrefixCls}-filter-dropdown-checkall`,
197
+ onChange: onCheckAll
198
+ }, locale.filterCheckall) : null, /*#__PURE__*/React.createElement(Tree, {
199
+ checkable: true,
200
+ selectable: false,
201
+ blockNode: true,
202
+ multiple: filterMultiple,
203
+ checkStrictly: !filterMultiple,
204
+ className: `${dropdownPrefixCls}-menu`,
205
+ onCheck: onCheck,
206
+ checkedKeys: selectedKeys,
207
+ selectedKeys: selectedKeys,
208
+ showIcon: false
209
+ // treeData={getTreeData({ filters: column.filters })}
210
+ ,
211
+ treeData: getTreeData({
212
+ filters: options
213
+ }),
214
+ autoExpandParent: true,
215
+ defaultExpandAll: true,
216
+ filterTreeNode: searchValue.trim() ? node => {
217
+ if (typeof filterSearch === 'function') {
218
+ // @ts-ignore
219
+ return filterSearch(searchValue, getFilterData(node));
220
+ }
221
+ return searchValueMatched(searchValue, node.title);
222
+ } : undefined
223
+ })));
224
+ }
225
+ return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(FilterSearch, {
226
+ filterSearch: filterSearch,
227
+ value: searchValue,
228
+ onChange: onSearch,
229
+ tablePrefixCls: tablePrefixCls,
230
+ locale: locale
231
+ }), isEmpty ? empty : /*#__PURE__*/React.createElement(Menu, {
232
+ selectable: true,
233
+ multiple: filterMultiple,
234
+ prefixCls: `${dropdownPrefixCls}-menu`,
235
+ className: dropdownMenuClass,
236
+ onSelect: onSelect,
237
+ onDeselect: onSelect,
238
+ selectedKeys: selectedKeys
239
+ // getPopupContainer={getPopupContainer}
240
+ ,
241
+ openKeys: openKeys,
242
+ onOpenChange: onOpenChange,
243
+ items: items
244
+ }));
245
+ };
246
+ export default CheckboxFilter;
@@ -0,0 +1,9 @@
1
+ import type { Dispatch, SetStateAction } from "react";
2
+ import React from "react";
3
+ import type { ColumnsType } from "./type";
4
+ export type IColumnsChoose<RecordType> = {
5
+ columns: any[];
6
+ setColumns: Dispatch<SetStateAction<ColumnsType<RecordType>>>;
7
+ t?: any;
8
+ };
9
+ export declare const ColumnsChoose: <RecordType extends object>(props: IColumnsChoose<RecordType>) => React.JSX.Element;
@@ -0,0 +1,209 @@
1
+ import React, { Fragment, useEffect, useMemo, useState } from "react";
2
+ import styled from "styled-components";
3
+ // import type { TreeDataNode} from "antd";
4
+ import { Button, Input, Popover, Tooltip } from "antd";
5
+ import { SettingOutlined } from "@ant-design/icons";
6
+ import { getVisibleColumnKeys, updateColumns } from "./hooks";
7
+ import Tree from "rc-master-ui/es/tree";
8
+ import SearchOutlined from "@ant-design/icons/SearchOutlined";
9
+
10
+ // const { Search } = Input;
11
+
12
+ const BoxAction = styled.div.withConfig({
13
+ displayName: "BoxAction",
14
+ componentId: "es-grid-template__sc-1k89i9w-0"
15
+ })(["border-top:1px solid #c4c4c4;padding-top:.75rem;display:flex;justify-content:end;gap:10px;.btn-action{background:none !important;border:none !important;&.btn-action-submit{color:#df4318;&:disabled{background-color:#f0f0f0 !important;}&:hover{color:#df4318 !important;}}&:hover{background-color:#f0f0f0 !important;}}"]);
16
+ export const ColumnsChoose = props => {
17
+ const {
18
+ columns: propsColumns,
19
+ setColumns: changeHiddenColumn
20
+ // t,
21
+ } = props;
22
+
23
+ // const dataList: { key: React.Key; title: string }[] = [];
24
+
25
+ // const defaultColumns = useMemo(() => {
26
+ // return propsColumns.filter((it) => it.key || it.dataIndex && it.showColumnChoose !== false)
27
+ // }, [propsColumns])
28
+
29
+ // const columnsChooseRef: any = useRef()
30
+ // const searchRef: any = useRef()
31
+
32
+ const [columns, setColumns] = useState([]);
33
+ const [selectedKeys, setSelectedKeys] = useState([]);
34
+ useEffect(() => {
35
+ const defaultColumns = propsColumns.filter(it => it.key || it.dataIndex && it.showColumnChoose !== false);
36
+ const defaultSelectedKeys = getVisibleColumnKeys(propsColumns);
37
+ setSelectedKeys(defaultSelectedKeys);
38
+ setColumns(defaultColumns);
39
+ }, [propsColumns]);
40
+ const defaultSelectedKeys = useMemo(() => {
41
+ return getVisibleColumnKeys(propsColumns);
42
+ }, [propsColumns]);
43
+
44
+ // console.log('defaultSelectedKeys', defaultSelectedKeys)
45
+
46
+ const [clicked, setClicked] = useState(false);
47
+ const [autoExpandParent, setAutoExpandParent] = useState(true);
48
+ // const [expandedKeys, setExpandedKeys] = useState<React.Key[]>([]);
49
+ // const [searchValue, setSearchValue] = useState('');
50
+
51
+ // const treeData = useMemo(() => {
52
+ // const loop = (data: TreeDataNode[]): TreeDataNode[] =>
53
+ // data.map((item) => {
54
+ // const strTitle = item.title as string;
55
+ // const index = strTitle.indexOf(searchValue);
56
+ // const beforeStr = strTitle.substring(0, index);
57
+ // const afterStr = strTitle.slice(index + searchValue.length);
58
+ // const title =
59
+ // index > -1 ? (
60
+ // <span key={item.key}>
61
+ // {beforeStr}
62
+ // <span className="site-tree-search-value">{searchValue}</span>
63
+ // {afterStr}
64
+ // </span>
65
+ // ) : (
66
+ // <span key={item.key}>{strTitle}</span>
67
+ // );
68
+ // if (item.children) {
69
+ // return { title, key: item.key, children: loop(item.children) };
70
+ // }
71
+ //
72
+ // return {
73
+ // title,
74
+ // key: item.key,
75
+ // };
76
+ // });
77
+ //
78
+ // // return loop(defaultData);
79
+ // return loop(columns as any);
80
+ // }, [searchValue, columns]);
81
+
82
+ const hide = () => {
83
+ setClicked(false);
84
+ };
85
+ const handleClickChange = open => {
86
+ setClicked(open);
87
+ };
88
+ const onExpand = () => {
89
+ // setExpandedKeys(newExpandedKeys)
90
+ setAutoExpandParent(false);
91
+ };
92
+
93
+ // const getParentKey = (key: React.Key, tree: TreeDataNode[]): React.Key => {
94
+ // let parentKey: React.Key
95
+ // for (let i = 0; i < tree.length; i++) {
96
+ // const node = tree[i]
97
+ // if (node.children) {
98
+ // if (node.children.some((item) => item.key === key)) {
99
+ // parentKey = node.key
100
+ // } else if (getParentKey(key, node.children)) {
101
+ // parentKey = getParentKey(key, node.children)
102
+ // }
103
+ // }
104
+ // }
105
+ // return parentKey!
106
+ // }
107
+
108
+ // const onChange = (e: React.ChangeEvent<HTMLInputElement>) => {
109
+ const onChange = () => {
110
+ // const { value } = e.target
111
+ // const newExpandedKeys = dataList
112
+ // .map((item) => {
113
+ // if (item.title.indexOf(value) > -1) {
114
+ // return getParentKey(item.key, defaultData)
115
+ // }
116
+ // return null
117
+ // })
118
+ // .filter((item, i, self): item is React.Key => !!(item && self.indexOf(item) === i))
119
+ // setExpandedKeys(newExpandedKeys)
120
+
121
+ // setSearchValue(value)
122
+ setAutoExpandParent(true);
123
+ };
124
+ const onCheck = keys => {
125
+ setSelectedKeys(keys);
126
+ };
127
+ const handleAccept = () => {
128
+ const rs1 = updateColumns(propsColumns, selectedKeys);
129
+ changeHiddenColumn(rs1);
130
+ hide();
131
+ };
132
+ const handleCancel = () => {
133
+ setSelectedKeys(defaultSelectedKeys);
134
+ hide();
135
+ };
136
+ return /*#__PURE__*/React.createElement(Fragment, null, /*#__PURE__*/React.createElement(Popover, {
137
+ placement: 'bottomLeft',
138
+ content: /*#__PURE__*/React.createElement("div", {
139
+ style: {
140
+ minWidth: 250
141
+ }
142
+ }, /*#__PURE__*/React.createElement(Input, {
143
+ style: {
144
+ marginBottom: 8
145
+ },
146
+ placeholder: "Search",
147
+ prefix: /*#__PURE__*/React.createElement(SearchOutlined, null),
148
+ onChange: onChange
149
+ }), /*#__PURE__*/React.createElement(Tree, {
150
+ onExpand: onExpand
151
+ // expandedKeys={expandedKeys}
152
+ ,
153
+ autoExpandParent: autoExpandParent
154
+ // treeData={treeData}
155
+ ,
156
+ treeData: columns,
157
+ defaultExpandAll: true,
158
+ checkable: true
159
+ // onSelect={(keys, info) => {
160
+ // const key = info.node.key
161
+ // console.log('selectedKeys', keys)
162
+ // console.log('info', info)
163
+ //
164
+ // const find = findItemByKey(columns, 'key', key)
165
+ //
166
+ // // const tmpColumn
167
+ //
168
+ // // if (selectedKeys.includes(key as string)) {
169
+ // // const rssss = findKeyPath(columns, key as string)
170
+ // // const rs = selectedKeys.filter(item => !rssss.includes(item));
171
+ // //
172
+ // // setSelectedKeys(rs)
173
+ // // } else {
174
+ //
175
+ // // const rs = [...selectedKeys, keys[0]]
176
+ //
177
+ // // console.log('rs', rs)
178
+ // // setSelectedKeys(keys)
179
+ // // }
180
+ // }}
181
+ ,
182
+ onCheck: keys => onCheck(keys),
183
+ multiple: true,
184
+ checkedKeys: selectedKeys,
185
+ defaultCheckedKeys: selectedKeys,
186
+ selectedKeys: [],
187
+ height: window.innerHeight - 200
188
+ }), /*#__PURE__*/React.createElement(BoxAction, {
189
+ className: 'px-1'
190
+ }, /*#__PURE__*/React.createElement(Button
191
+ // className={classnames('btn-action btn-action-submit', {
192
+ // // disable: !columns.find((item) => item.visible !== false || item.visible)
193
+ // })}
194
+ , {
195
+ onClick: handleAccept
196
+ // disabled={!columns.find((item) => item.visible !== false || item.visible)}
197
+ }, 'OK'), /*#__PURE__*/React.createElement(Button, {
198
+ className: 'btn-action btn-action-cancel',
199
+ onClick: handleCancel
200
+ }, 'Cancel'))),
201
+ trigger: "click",
202
+ open: clicked,
203
+ onOpenChange: handleClickChange,
204
+ arrow: false
205
+ }, /*#__PURE__*/React.createElement(Tooltip, {
206
+ arrow: false,
207
+ title: 'Cài đặt'
208
+ }, /*#__PURE__*/React.createElement(SettingOutlined, null))));
209
+ };
@@ -1,6 +1,6 @@
1
1
  import * as React from "react";
2
2
  import type { MenuProps } from "antd";
3
- import { ContextInfo } from "../../type";
3
+ import type { ContextInfo } 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;
@@ -0,0 +1,126 @@
1
+ import * as React from "react";
2
+ import { Dropdown, Menu } from "antd";
3
+ export const findItemByKey = (array, key, value) => {
4
+ for (let i = 0; i < array.length; i++) {
5
+ const item = array[i];
6
+ if (item[key] === value) {
7
+ return item;
8
+ }
9
+ if (item.children && item.children.length > 0) {
10
+ const foundInChildren = findItemByKey(item.children, key, value);
11
+ if (foundInChildren) {
12
+ return foundInChildren;
13
+ }
14
+ }
15
+ }
16
+ return null;
17
+ };
18
+ const ContextMenu = props => {
19
+ const {
20
+ menuRef,
21
+ open,
22
+ setOpen,
23
+ pos,
24
+ contextMenuClick,
25
+ contextMenuItems,
26
+ rowData
27
+ } = props;
28
+
29
+ // const addPopupOffset = (items: MenuProps["items"]) : any => {
30
+ // return items?.map(item =>
31
+ // item && "children" in item
32
+ // ? {
33
+ // ...item,
34
+ // // popupOffset: [0, 30],
35
+ // children: addPopupOffset(item.children) }
36
+ // : item
37
+ // );
38
+ // };
39
+
40
+ // const newItems = React.useMemo(() => {
41
+ // return addPopupOffset(items)
42
+ // }, [items])
43
+
44
+ return (
45
+ /*#__PURE__*/
46
+ // <div>
47
+ // {open && (
48
+ // <div
49
+ // ref={menuRef}
50
+ // style={{
51
+ // position: "absolute",
52
+ // top: pos.y,
53
+ // left: pos.x,
54
+ // zIndex: 1000,
55
+ // background: "white",
56
+ // border: "1px solid #ddd",
57
+ // boxShadow: "2px 2px 5px rgba(0,0,0,0.2)",
58
+ // }}
59
+ // // onClick={() => setOpen(false)}
60
+ // >
61
+ // <Menu
62
+ // items={contextMenuItems}
63
+ // style={{ minWidth: 200, maxWidth: 400, maxHeight: pos.viewportHeight - 20 , width: 200 }}
64
+ // rootClassName={'popup-context-menu'}
65
+ //
66
+ // onClick={(e) => {
67
+ // contextMenuClick?.({
68
+ // rowInfo: {
69
+ // rowData
70
+ // },
71
+ // event: e.domEvent,
72
+ // item: {
73
+ // ...findItemByKey(contextMenuItems as any[], 'key', e.key ),
74
+ // id: e.key
75
+ // }
76
+ // })
77
+ // }} >
78
+ // </Menu>
79
+ // </div>
80
+ // )}
81
+ // </div>
82
+ React.createElement(Dropdown, {
83
+ placement: 'topRight',
84
+ open: open,
85
+ overlayStyle: {
86
+ left: `${pos.x}px`,
87
+ top: `${pos.y}px`
88
+ },
89
+ dropdownRender: () => {
90
+ return /*#__PURE__*/React.createElement("div", {
91
+ ref: menuRef
92
+ }, /*#__PURE__*/React.createElement(Menu, {
93
+ items: contextMenuItems,
94
+ style: {
95
+ minWidth: 200,
96
+ maxWidth: 400,
97
+ maxHeight: pos.viewportHeight - 20,
98
+ width: 200
99
+ },
100
+ rootClassName: 'popup-context-menu',
101
+ onClick: e => {
102
+ setOpen(false);
103
+ contextMenuClick?.({
104
+ rowInfo: {
105
+ rowData
106
+ },
107
+ event: e.domEvent,
108
+ item: {
109
+ ...findItemByKey(contextMenuItems, 'key', e.key),
110
+ id: e.key
111
+ }
112
+ });
113
+
114
+ // if (!open) {
115
+ // document.addEventListener(`click`, function onClickOutside() {
116
+ // setOpen(false);
117
+ // document.removeEventListener(`click`, onClickOutside);
118
+ // });
119
+ // }
120
+ }
121
+ }));
122
+ }
123
+ }, /*#__PURE__*/React.createElement(React.Fragment, null))
124
+ );
125
+ };
126
+ export default ContextMenu;
@@ -1,6 +1,6 @@
1
1
  import * as React from 'react';
2
- import { AnyObject } from "../../type";
3
- import { FilterSearchType, TableLocale } from "antd/es/table/interface";
2
+ import type { FilterSearchType, TableLocale } from "antd/es/table/interface";
3
+ import type { AnyObject } from "./type";
4
4
  interface FilterSearchProps<RecordType = AnyObject> {
5
5
  value: string;
6
6
  onChange: (e: React.ChangeEvent<HTMLInputElement>) => void;
@@ -8,5 +8,5 @@ interface FilterSearchProps<RecordType = AnyObject> {
8
8
  tablePrefixCls: string;
9
9
  locale: TableLocale;
10
10
  }
11
- declare const FilterSearch: <RecordType extends AnyObject = AnyObject>(props: FilterSearchProps<RecordType>) => React.JSX.Element | null;
11
+ declare const FilterSearch: <RecordType extends AnyObject = AnyObject>(props: FilterSearchProps<RecordType>) => React.JSX.Element;
12
12
  export default FilterSearch;
@@ -0,0 +1,33 @@
1
+ import * as React from 'react';
2
+ import SearchOutlined from '@ant-design/icons/SearchOutlined';
3
+ import { Input } from 'rc-master-ui';
4
+ const FilterSearch = props => {
5
+ const {
6
+ value,
7
+ filterSearch,
8
+ tablePrefixCls,
9
+ locale,
10
+ onChange
11
+ } = props;
12
+ if (!filterSearch) {
13
+ return null;
14
+ }
15
+ return /*#__PURE__*/React.createElement("div", {
16
+ className: `${tablePrefixCls}-filter-dropdown-search`,
17
+ style: {
18
+ paddingLeft: 0,
19
+ paddingRight: 0
20
+ }
21
+ }, /*#__PURE__*/React.createElement(Input, {
22
+ prefix: /*#__PURE__*/React.createElement(SearchOutlined, null),
23
+ placeholder: locale.filterSearchPlaceholder,
24
+ onChange: onChange,
25
+ value: value,
26
+ autoFocus: true
27
+ // for skip min-width of input
28
+ ,
29
+ htmlSize: 1,
30
+ className: `${tablePrefixCls}-filter-dropdown-search-input`
31
+ }));
32
+ };
33
+ export default FilterSearch;