es-grid-template 0.0.7 → 0.0.13

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 (116) hide show
  1. package/LICENSE +21 -19
  2. package/es/{CheckboxFilter.d.ts → grid-component/CheckboxFilter.d.ts} +1 -1
  3. package/es/{CheckboxFilter.js → grid-component/CheckboxFilter.js} +7 -11
  4. package/es/grid-component/ColumnsChoose.d.ts +9 -0
  5. package/es/{ColumnsChoose.js → grid-component/ColumnsChoose.js} +66 -70
  6. package/es/grid-component/EditableCell.d.ts +19 -0
  7. package/es/grid-component/EditableCell.js +842 -0
  8. package/es/{FilterSearch.js → grid-component/FilterSearch.js} +2 -2
  9. package/es/grid-component/GridStyle.d.ts +4 -0
  10. package/es/grid-component/GridStyle.js +5 -0
  11. package/es/grid-component/InternalTable.d.ts +6 -0
  12. package/es/grid-component/InternalTable.js +283 -0
  13. package/es/grid-component/LoadingSpinner.d.ts +3 -0
  14. package/es/grid-component/LoadingSpinner.js +20 -0
  15. package/es/grid-component/Message/Message.d.ts +2 -0
  16. package/es/grid-component/Message/Message.js +16 -0
  17. package/es/grid-component/Message/index.d.ts +1 -0
  18. package/es/grid-component/Message/index.js +1 -0
  19. package/es/grid-component/TableGrid.d.ts +10 -0
  20. package/es/grid-component/TableGrid.js +375 -0
  21. package/es/grid-component/async-table-select/index.d.ts +9 -0
  22. package/es/grid-component/async-table-select/index.js +37 -0
  23. package/es/{hooks → grid-component/hooks}/constant.d.ts +14 -0
  24. package/es/{hooks → grid-component/hooks}/constant.js +17 -2
  25. package/es/grid-component/hooks/useColumns/index.d.ts +6 -0
  26. package/es/grid-component/hooks/useColumns/index.js +422 -0
  27. package/es/grid-component/hooks/utils.d.ts +35 -0
  28. package/es/{hooks → grid-component/hooks}/utils.js +147 -19
  29. package/es/grid-component/index.d.ts +2 -0
  30. package/es/grid-component/index.js +2 -0
  31. package/es/grid-component/rc-table/Grid.d.ts +8 -0
  32. package/es/grid-component/rc-table/Grid.js +99 -0
  33. package/es/grid-component/rc-table/GridEdit.d.ts +9 -0
  34. package/es/grid-component/rc-table/GridEdit.js +706 -0
  35. package/es/grid-component/type.d.ts +225 -0
  36. package/es/grid-component/useContext.d.ts +27 -0
  37. package/es/grid-component/useContext.js +4 -0
  38. package/es/index.d.ts +1 -2
  39. package/es/index.js +2 -2
  40. package/es/table-grid/styles.scss +551 -0
  41. package/lib/{CheckboxFilter.d.ts → grid-component/CheckboxFilter.d.ts} +1 -1
  42. package/lib/{CheckboxFilter.js → grid-component/CheckboxFilter.js} +11 -14
  43. package/lib/grid-component/ColumnsChoose.d.ts +9 -0
  44. package/lib/{ColumnsChoose.js → grid-component/ColumnsChoose.js} +66 -70
  45. package/lib/grid-component/EditableCell.d.ts +19 -0
  46. package/lib/grid-component/EditableCell.js +844 -0
  47. package/lib/{FilterSearch.js → grid-component/FilterSearch.js} +3 -3
  48. package/lib/grid-component/GridStyle.d.ts +4 -0
  49. package/lib/grid-component/GridStyle.js +12 -0
  50. package/lib/grid-component/InternalTable.d.ts +6 -0
  51. package/lib/grid-component/InternalTable.js +292 -0
  52. package/lib/grid-component/LoadingSpinner.d.ts +3 -0
  53. package/lib/grid-component/LoadingSpinner.js +29 -0
  54. package/lib/grid-component/Message/Message.d.ts +2 -0
  55. package/lib/grid-component/Message/Message.js +25 -0
  56. package/lib/grid-component/Message/index.d.ts +1 -0
  57. package/lib/grid-component/Message/index.js +16 -0
  58. package/lib/grid-component/TableGrid.d.ts +10 -0
  59. package/lib/grid-component/TableGrid.js +382 -0
  60. package/lib/grid-component/async-table-select/index.d.ts +9 -0
  61. package/lib/grid-component/async-table-select/index.js +46 -0
  62. package/lib/{hooks → grid-component/hooks}/constant.d.ts +14 -0
  63. package/lib/{hooks → grid-component/hooks}/constant.js +18 -3
  64. package/lib/grid-component/hooks/useColumns/index.d.ts +6 -0
  65. package/lib/grid-component/hooks/useColumns/index.js +435 -0
  66. package/lib/grid-component/hooks/utils.d.ts +35 -0
  67. package/lib/{hooks → grid-component/hooks}/utils.js +164 -22
  68. package/lib/grid-component/index.d.ts +2 -0
  69. package/lib/grid-component/index.js +9 -0
  70. package/lib/grid-component/rc-table/Grid.d.ts +8 -0
  71. package/lib/grid-component/rc-table/Grid.js +108 -0
  72. package/lib/grid-component/rc-table/GridEdit.d.ts +9 -0
  73. package/lib/grid-component/rc-table/GridEdit.js +715 -0
  74. package/lib/grid-component/type.d.ts +225 -0
  75. package/lib/grid-component/useContext.d.ts +27 -0
  76. package/lib/grid-component/useContext.js +10 -0
  77. package/lib/index.d.ts +1 -2
  78. package/lib/index.js +7 -3
  79. package/lib/table-grid/styles.scss +551 -0
  80. package/package.json +17 -6
  81. package/es/ColumnsChoose.d.ts +0 -10
  82. package/es/GridTable.d.ts +0 -7
  83. package/es/GridTable.js +0 -927
  84. package/es/hooks/useColumns/index.d.ts +0 -2
  85. package/es/hooks/useColumns/index.js +0 -25
  86. package/es/hooks/utils.d.ts +0 -18
  87. package/es/styles.scss +0 -30
  88. package/es/type.d.ts +0 -88
  89. package/lib/ColumnsChoose.d.ts +0 -10
  90. package/lib/GridTable.d.ts +0 -7
  91. package/lib/GridTable.js +0 -936
  92. package/lib/hooks/useColumns/index.d.ts +0 -2
  93. package/lib/hooks/useColumns/index.js +0 -31
  94. package/lib/hooks/utils.d.ts +0 -18
  95. package/lib/styles.scss +0 -30
  96. package/lib/type.d.ts +0 -88
  97. /package/es/{ContextMenu.d.ts → grid-component/ContextMenu.d.ts} +0 -0
  98. /package/es/{ContextMenu.js → grid-component/ContextMenu.js} +0 -0
  99. /package/es/{FilterSearch.d.ts → grid-component/FilterSearch.d.ts} +0 -0
  100. /package/es/{hooks → grid-component/hooks}/index.d.ts +0 -0
  101. /package/es/{hooks → grid-component/hooks}/index.js +0 -0
  102. /package/es/{hooks → grid-component/hooks}/useIsOverflow.d.ts +0 -0
  103. /package/es/{hooks → grid-component/hooks}/useIsOverflow.js +0 -0
  104. /package/es/{hooks → grid-component/hooks}/useOnClickOutside.d.ts +0 -0
  105. /package/es/{hooks → grid-component/hooks}/useOnClickOutside.js +0 -0
  106. /package/es/{type.js → grid-component/type.js} +0 -0
  107. /package/lib/{ContextMenu.d.ts → grid-component/ContextMenu.d.ts} +0 -0
  108. /package/lib/{ContextMenu.js → grid-component/ContextMenu.js} +0 -0
  109. /package/lib/{FilterSearch.d.ts → grid-component/FilterSearch.d.ts} +0 -0
  110. /package/lib/{hooks → grid-component/hooks}/index.d.ts +0 -0
  111. /package/lib/{hooks → grid-component/hooks}/index.js +0 -0
  112. /package/lib/{hooks → grid-component/hooks}/useIsOverflow.d.ts +0 -0
  113. /package/lib/{hooks → grid-component/hooks}/useIsOverflow.js +0 -0
  114. /package/lib/{hooks → grid-component/hooks}/useOnClickOutside.d.ts +0 -0
  115. /package/lib/{hooks → grid-component/hooks}/useOnClickOutside.js +0 -0
  116. /package/lib/{type.js → grid-component/type.js} +0 -0
package/LICENSE CHANGED
@@ -1,19 +1,21 @@
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.
1
+ MIT License
2
+
3
+ Copyright (c) 2025 taonv
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -1,5 +1,5 @@
1
1
  import * as React from "react";
2
- import type { TableLocale } from "ui-rc/dist/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;
@@ -1,14 +1,10 @@
1
1
  import * as React from "react";
2
2
  import classNames from "classnames";
3
3
  import FilterSearch from "./FilterSearch";
4
- import { Checkbox, Menu, Radio } from "ui-rc";
5
- import { Empty, Tree } from "antd";
6
-
7
- // import {flattenKeys} from "ui-rc/dist/table/hooks/useFilter";
8
-
9
- import { flattenKeys } from "antd/es/table/hooks/useFilter";
10
- // import Empty from "ui-rc/dist/empty";
11
- // import Tree from "ui-rc/dist/tree";
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";
12
8
 
13
9
  function searchValueMatched(searchValue, text) {
14
10
  if (typeof text === 'string' || typeof text === 'number') {
@@ -107,7 +103,6 @@ const CheckboxFilter = props => {
107
103
  // [`${dropdownPrefixCls}-menu-without-submenu`]: !hasSubMenu(column.filters || []),
108
104
  [`${dropdownPrefixCls}-menu-without-submenu`]: !hasSubMenu(options || [])
109
105
  });
110
- console.log('selectedKeys', selectedKeys);
111
106
  const empty = /*#__PURE__*/React.createElement(Empty, {
112
107
  image: Empty.PRESENTED_IMAGE_SIMPLE,
113
108
  description: locale.filterEmptyText,
@@ -153,10 +148,11 @@ const CheckboxFilter = props => {
153
148
  children: node.children?.map(item => getFilterData(item)) || []
154
149
  });
155
150
  const onCheckAll = e => {
156
- console.log('e.target.checked', e.target.checked);
151
+ // console.log('e.target.checked', e.target.checked)
157
152
  if (e.target.checked) {
158
153
  const allFilterKeys = flattenKeys(options).map(key => String(key));
159
- console.log('allFilterKeys', allFilterKeys);
154
+
155
+ // console.log('allFilterKeys', allFilterKeys)
160
156
  // setFilteredKeysSync(allFilterKeys);
161
157
  onSelect?.(allFilterKeys);
162
158
  } else {
@@ -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;
@@ -1,91 +1,84 @@
1
- import React, { Fragment, useMemo, useState } from "react";
1
+ import React, { Fragment, useEffect, useMemo, useState } from "react";
2
2
  import styled from "styled-components";
3
- import { Button, Input, Popover, Tooltip, Tree } from "antd";
3
+ // import type { TreeDataNode} from "antd";
4
+ import { Button, Input, Popover, Tooltip } from "antd";
4
5
  import { SettingOutlined } from "@ant-design/icons";
5
6
  import { getVisibleColumnKeys, updateColumns } from "./hooks";
6
- const {
7
- Search
8
- } = Input;
7
+ import Tree from "rc-master-ui/es/tree";
8
+ import SearchOutlined from "@ant-design/icons/SearchOutlined";
9
9
 
10
- // const RowStyle = styled.div`
11
- // padding: 6px 0;
12
- //
13
- // height: 35px;
14
- //
15
- // .ellipsis {
16
- // overflow: hidden;
17
- // white-space: nowrap;
18
- // text-overflow: ellipsis;
19
- // word-break: keep-all;
20
- // }
21
- // `
10
+ // const { Search } = Input;
22
11
 
23
12
  const BoxAction = styled.div.withConfig({
24
13
  displayName: "BoxAction",
25
- componentId: "es-grid-template__sc-1k89i9w-0"
14
+ componentId: "es-grid-template__sc-1ix8yky-0"
26
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;}}"]);
27
- export const BoxInputFilterColumn = styled.div.withConfig({
28
- displayName: "BoxInputFilterColumn",
29
- componentId: "es-grid-template__sc-1k89i9w-1"
30
- })(["display:flex;position:relative;align-items:center;.input__value{z-index:1;border-radius:0;border-top:0;border-left:0;border-right:0;&:focus{box-shadow:none !important;}&.is-clearable{padding-right:25px !important;}}.input__clear-icon{cursor:pointer;position:absolute;right:5px;z-index:10;}"]);
31
16
  export const ColumnsChoose = props => {
32
17
  const {
33
18
  columns: propsColumns,
34
19
  setColumns: changeHiddenColumn
35
20
  // t,
36
- // columnsGrouped,
37
- // onChangeDisplay
38
- // frozen
39
21
  } = props;
40
22
 
41
23
  // const dataList: { key: React.Key; title: string }[] = [];
42
24
 
43
- const defaultColumns = useMemo(() => {
44
- const rs = propsColumns.filter(it => it.key || it.dataIndex);
45
- return rs;
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);
46
39
  }, [propsColumns]);
47
40
  const defaultSelectedKeys = useMemo(() => {
48
41
  return getVisibleColumnKeys(propsColumns);
49
42
  }, [propsColumns]);
50
43
 
51
- // const columnsChooseRef: any = useRef()
52
- // const searchRef: any = useRef()
44
+ // console.log('defaultSelectedKeys', defaultSelectedKeys)
53
45
 
54
- const [columns] = useState(defaultColumns);
55
46
  const [clicked, setClicked] = useState(false);
56
47
  const [autoExpandParent, setAutoExpandParent] = useState(true);
57
48
  // const [expandedKeys, setExpandedKeys] = useState<React.Key[]>([]);
58
- const [searchValue, setSearchValue] = useState('');
59
- const [selectedKeys, setSelectedKeys] = useState(defaultSelectedKeys);
60
- const treeData = useMemo(() => {
61
- const loop = data => data.map(item => {
62
- const strTitle = item.title;
63
- const index = strTitle.indexOf(searchValue);
64
- const beforeStr = strTitle.substring(0, index);
65
- const afterStr = strTitle.slice(index + searchValue.length);
66
- const title = index > -1 ? /*#__PURE__*/React.createElement("span", {
67
- key: item.key
68
- }, beforeStr, /*#__PURE__*/React.createElement("span", {
69
- className: "site-tree-search-value"
70
- }, searchValue), afterStr) : /*#__PURE__*/React.createElement("span", {
71
- key: item.key
72
- }, strTitle);
73
- if (item.children) {
74
- return {
75
- title,
76
- key: item.key,
77
- children: loop(item.children)
78
- };
79
- }
80
- return {
81
- title,
82
- key: item.key
83
- };
84
- });
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]);
85
81
 
86
- // return loop(defaultData);
87
- return loop(columns);
88
- }, [searchValue]);
89
82
  const hide = () => {
90
83
  setClicked(false);
91
84
  };
@@ -112,10 +105,9 @@ export const ColumnsChoose = props => {
112
105
  // return parentKey!
113
106
  // }
114
107
 
115
- const onChange = e => {
116
- const {
117
- value
118
- } = e.target;
108
+ // const onChange = (e: React.ChangeEvent<HTMLInputElement>) => {
109
+ const onChange = () => {
110
+ // const { value } = e.target
119
111
  // const newExpandedKeys = dataList
120
112
  // .map((item) => {
121
113
  // if (item.title.indexOf(value) > -1) {
@@ -125,14 +117,15 @@ export const ColumnsChoose = props => {
125
117
  // })
126
118
  // .filter((item, i, self): item is React.Key => !!(item && self.indexOf(item) === i))
127
119
  // setExpandedKeys(newExpandedKeys)
128
- setSearchValue(value);
120
+
121
+ // setSearchValue(value)
129
122
  setAutoExpandParent(true);
130
123
  };
131
124
  const onCheck = keys => {
132
125
  setSelectedKeys(keys);
133
126
  };
134
127
  const handleAccept = () => {
135
- const rs1 = updateColumns(columns, selectedKeys);
128
+ const rs1 = updateColumns(propsColumns, selectedKeys);
136
129
  changeHiddenColumn(rs1);
137
130
  hide();
138
131
  };
@@ -146,18 +139,21 @@ export const ColumnsChoose = props => {
146
139
  style: {
147
140
  minWidth: 250
148
141
  }
149
- }, /*#__PURE__*/React.createElement(Search, {
142
+ }, /*#__PURE__*/React.createElement(Input, {
150
143
  style: {
151
144
  marginBottom: 8
152
145
  },
153
146
  placeholder: "Search",
147
+ prefix: /*#__PURE__*/React.createElement(SearchOutlined, null),
154
148
  onChange: onChange
155
149
  }), /*#__PURE__*/React.createElement(Tree, {
156
150
  onExpand: onExpand
157
151
  // expandedKeys={expandedKeys}
158
152
  ,
159
- autoExpandParent: autoExpandParent,
160
- treeData: treeData,
153
+ autoExpandParent: autoExpandParent
154
+ // treeData={treeData}
155
+ ,
156
+ treeData: columns,
161
157
  defaultExpandAll: true,
162
158
  checkable: true
163
159
  // onSelect={(keys, info) => {
@@ -0,0 +1,19 @@
1
+ import React from "react";
2
+ import type { ColumnEditType, IFormat } from "./type";
3
+ import type { EditType } from "rc-master-ui";
4
+ interface EditableCellProps<DataType> extends React.HTMLAttributes<HTMLElement> {
5
+ t?: any;
6
+ editing: boolean;
7
+ dataIndex: string;
8
+ title: any;
9
+ editType: EditType;
10
+ record: DataType;
11
+ index: number;
12
+ format?: IFormat;
13
+ column: ColumnEditType<DataType>;
14
+ indexRow: number;
15
+ indexCol: number;
16
+ rowKey: any;
17
+ }
18
+ declare const EditableCell: <T>(props: React.PropsWithChildren<EditableCellProps<T>>) => React.JSX.Element;
19
+ export default EditableCell;