es-grid-template 1.8.71 → 1.8.73

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 (251) hide show
  1. package/es/grid-component/TempTable.js +2 -1
  2. package/es/grid-component/type.d.ts +1 -3
  3. package/es/group-component/ColumnsChoose.d.ts +13 -0
  4. package/es/group-component/ColumnsChoose.js +211 -0
  5. package/es/group-component/ColumnsGroup/ColumnsGroup.d.ts +12 -0
  6. package/es/group-component/ColumnsGroup/ColumnsGroup.js +230 -0
  7. package/es/group-component/ColumnsGroup/index.d.ts +1 -0
  8. package/es/group-component/ColumnsGroup/index.js +1 -0
  9. package/es/group-component/ContextMenu.d.ts +19 -0
  10. package/es/group-component/ContextMenu.js +74 -0
  11. package/es/group-component/InternalTable.d.ts +8 -0
  12. package/es/group-component/InternalTable.js +224 -0
  13. package/es/group-component/TableContainer.d.ts +49 -0
  14. package/es/group-component/TableContainer.js +375 -0
  15. package/es/group-component/TableContainerEdit.d.ts +48 -0
  16. package/es/group-component/TableContainerEdit.js +2068 -0
  17. package/es/group-component/body/EditableCell.d.ts +16 -0
  18. package/es/group-component/body/EditableCell.js +1066 -0
  19. package/es/group-component/body/TableBody.d.ts +14 -0
  20. package/es/group-component/body/TableBody.js +82 -0
  21. package/es/group-component/body/TableBodyCell.d.ts +12 -0
  22. package/es/group-component/body/TableBodyCell.js +587 -0
  23. package/es/group-component/body/TableBodyCellEdit.d.ts +17 -0
  24. package/es/group-component/body/TableBodyCellEdit.js +1398 -0
  25. package/es/group-component/body/TableBodyCellEmpty.d.ts +12 -0
  26. package/es/group-component/body/TableBodyCellEmpty.js +149 -0
  27. package/es/group-component/body/TableBodyRow.d.ts +21 -0
  28. package/es/group-component/body/TableBodyRow.js +199 -0
  29. package/es/group-component/body/TableBodyRowGroupCell.d.ts +12 -0
  30. package/es/group-component/body/TableBodyRowGroupCell.js +567 -0
  31. package/es/group-component/components/ControlCheckbox.d.ts +13 -0
  32. package/es/group-component/components/ControlCheckbox.js +84 -0
  33. package/es/group-component/components/EditForm/EditForm.d.ts +27 -0
  34. package/es/group-component/components/EditForm/EditForm.js +394 -0
  35. package/es/group-component/components/EditForm/index.d.ts +1 -0
  36. package/es/group-component/components/EditForm/index.js +1 -0
  37. package/es/group-component/components/InputControl/InputControl.d.ts +27 -0
  38. package/es/group-component/components/InputControl/InputControl.js +118 -0
  39. package/es/group-component/components/InputControl/index.d.ts +1 -0
  40. package/es/group-component/components/InputControl/index.js +1 -0
  41. package/es/group-component/components/async-select/index.d.ts +11 -0
  42. package/es/group-component/components/async-select/index.js +38 -0
  43. package/es/group-component/components/async-table-select/index.d.ts +11 -0
  44. package/es/group-component/components/async-table-select/index.js +40 -0
  45. package/es/group-component/components/checkbox-control/index.d.ts +13 -0
  46. package/es/group-component/components/checkbox-control/index.js +40 -0
  47. package/es/group-component/components/checkbox-filter/CheckboxFilter.d.ts +18 -0
  48. package/es/group-component/components/checkbox-filter/CheckboxFilter.js +258 -0
  49. package/es/group-component/components/checkbox-filter/FilterSearch.d.ts +12 -0
  50. package/es/group-component/components/checkbox-filter/FilterSearch.js +36 -0
  51. package/es/group-component/components/command/Command.d.ts +10 -0
  52. package/es/group-component/components/command/Command.js +35 -0
  53. package/es/group-component/components/number/index.d.ts +12 -0
  54. package/es/group-component/components/number/index.js +42 -0
  55. package/es/group-component/components/number-range/index.d.ts +13 -0
  56. package/es/group-component/components/number-range/index.js +79 -0
  57. package/es/group-component/features/operator.d.ts +24 -0
  58. package/es/group-component/features/operator.js +62 -0
  59. package/es/group-component/footer/TableFooter.d.ts +7 -0
  60. package/es/group-component/footer/TableFooter.js +34 -0
  61. package/es/group-component/footer/TableFooterCell.d.ts +7 -0
  62. package/es/group-component/footer/TableFooterCell.js +66 -0
  63. package/es/group-component/footer/TableFooterRow.d.ts +8 -0
  64. package/es/group-component/footer/TableFooterRow.js +30 -0
  65. package/es/group-component/header/TableHead.d.ts +15 -0
  66. package/es/group-component/header/TableHead.js +98 -0
  67. package/es/group-component/header/TableHeadCell.d.ts +15 -0
  68. package/es/group-component/header/TableHeadCell.js +310 -0
  69. package/es/group-component/header/TableHeadCell2.d.ts +17 -0
  70. package/es/group-component/header/TableHeadCell2.js +321 -0
  71. package/es/group-component/header/TableHeadGroupCell.d.ts +17 -0
  72. package/es/group-component/header/TableHeadGroupCell.js +94 -0
  73. package/es/group-component/header/TableHeadRow.d.ts +15 -0
  74. package/es/group-component/header/TableHeadRow.js +52 -0
  75. package/es/group-component/header/renderFilter.d.ts +20 -0
  76. package/es/group-component/header/renderFilter.js +291 -0
  77. package/es/group-component/hook/convert.d.ts +1 -0
  78. package/es/group-component/hook/convert.js +28 -0
  79. package/es/group-component/hook/useColumns.d.ts +28 -0
  80. package/es/group-component/hook/useColumns.js +306 -0
  81. package/es/group-component/hook/useFilterOperator.d.ts +7 -0
  82. package/es/group-component/hook/useFilterOperator.js +33 -0
  83. package/es/group-component/hook/utils.d.ts +220 -0
  84. package/es/group-component/hook/utils.js +2340 -0
  85. package/es/group-component/index.d.ts +2 -0
  86. package/es/group-component/index.js +2 -0
  87. package/es/group-component/style.d.ts +22 -0
  88. package/es/group-component/style.js +48 -0
  89. package/es/group-component/style.scss +1438 -0
  90. package/es/group-component/table/Grid.d.ts +33 -0
  91. package/es/group-component/table/Grid.js +439 -0
  92. package/es/group-component/table/TableWrapper.d.ts +33 -0
  93. package/es/group-component/table/TableWrapper.js +250 -0
  94. package/es/group-component/useContext.d.ts +100 -0
  95. package/es/group-component/useContext.js +21 -0
  96. package/es/table-component/InternalTable.js +9 -2
  97. package/es/table-component/TableContainer.d.ts +1 -0
  98. package/es/table-component/TableContainer.js +6 -2
  99. package/es/table-component/TableContainerEdit.d.ts +1 -0
  100. package/es/table-component/TableContainerEdit.js +4 -2
  101. package/es/table-component/body/TableBodyCell.js +49 -40
  102. package/es/table-component/body/TableBodyCellEdit.js +9 -6
  103. package/es/table-component/body/TableBodyRow.js +4 -1
  104. package/es/table-component/header/TableHeadCell2.js +39 -3
  105. package/es/table-component/hook/utils.d.ts +1 -0
  106. package/es/table-component/hook/utils.js +15 -7
  107. package/es/table-component/style.js +1 -1
  108. package/es/table-component/table/Grid.d.ts +1 -0
  109. package/es/table-component/table/Grid.js +10 -3
  110. package/es/table-component/useContext.d.ts +6 -0
  111. package/es/table-component/useContext.js +2 -1
  112. package/es/table-virtuoso/InternalTable.js +2 -2
  113. package/es/table-virtuoso/body/TableBodyCell.js +2 -7
  114. package/es/table-virtuoso/body/TableBodyCellRowGroup.d.ts +14 -0
  115. package/es/table-virtuoso/body/TableBodyCellRowGroup.js +196 -0
  116. package/es/table-virtuoso/body/TableBodyRow.d.ts +1 -1
  117. package/es/table-virtuoso/body/TableBodyRow.js +43 -1
  118. package/es/table-virtuoso/hook/utils.d.ts +1 -0
  119. package/es/table-virtuoso/hook/utils.js +29 -0
  120. package/es/table-virtuoso/style.js +3 -1
  121. package/es/table-virtuoso/table/Grid.js +2 -2
  122. package/es/table-virtuoso/table/TableWrapper.d.ts +7 -1
  123. package/es/table-virtuoso/table/TableWrapper.js +24 -5
  124. package/es/table-virtuoso/useContext.d.ts +6 -3
  125. package/es/table-virtuoso/useContext.js +18 -0
  126. package/lib/grid-component/TempTable.js +2 -1
  127. package/lib/grid-component/type.d.ts +1 -3
  128. package/lib/group-component/ColumnsChoose.d.ts +13 -0
  129. package/lib/group-component/ColumnsChoose.js +221 -0
  130. package/lib/group-component/ColumnsGroup/ColumnsGroup.d.ts +12 -0
  131. package/lib/group-component/ColumnsGroup/ColumnsGroup.js +241 -0
  132. package/lib/group-component/ColumnsGroup/index.d.ts +1 -0
  133. package/lib/group-component/ColumnsGroup/index.js +16 -0
  134. package/lib/group-component/ContextMenu.d.ts +19 -0
  135. package/lib/group-component/ContextMenu.js +83 -0
  136. package/lib/group-component/InternalTable.d.ts +8 -0
  137. package/lib/group-component/InternalTable.js +233 -0
  138. package/lib/group-component/TableContainer.d.ts +49 -0
  139. package/lib/group-component/TableContainer.js +382 -0
  140. package/lib/group-component/TableContainerEdit.d.ts +48 -0
  141. package/lib/group-component/TableContainerEdit.js +2075 -0
  142. package/lib/group-component/body/EditableCell.d.ts +16 -0
  143. package/lib/group-component/body/EditableCell.js +1075 -0
  144. package/lib/group-component/body/TableBody.d.ts +14 -0
  145. package/lib/group-component/body/TableBody.js +91 -0
  146. package/lib/group-component/body/TableBodyCell.d.ts +12 -0
  147. package/lib/group-component/body/TableBodyCell.js +595 -0
  148. package/lib/group-component/body/TableBodyCellEdit.d.ts +17 -0
  149. package/lib/group-component/body/TableBodyCellEdit.js +1405 -0
  150. package/lib/group-component/body/TableBodyCellEmpty.d.ts +12 -0
  151. package/lib/group-component/body/TableBodyCellEmpty.js +156 -0
  152. package/lib/group-component/body/TableBodyRow.d.ts +21 -0
  153. package/lib/group-component/body/TableBodyRow.js +206 -0
  154. package/lib/group-component/body/TableBodyRowGroupCell.d.ts +12 -0
  155. package/lib/group-component/body/TableBodyRowGroupCell.js +575 -0
  156. package/lib/group-component/components/ControlCheckbox.d.ts +13 -0
  157. package/lib/group-component/components/ControlCheckbox.js +92 -0
  158. package/lib/group-component/components/EditForm/EditForm.d.ts +27 -0
  159. package/lib/group-component/components/EditForm/EditForm.js +404 -0
  160. package/lib/group-component/components/EditForm/index.d.ts +1 -0
  161. package/lib/group-component/components/EditForm/index.js +16 -0
  162. package/lib/group-component/components/InputControl/InputControl.d.ts +27 -0
  163. package/lib/group-component/components/InputControl/InputControl.js +127 -0
  164. package/lib/group-component/components/InputControl/index.d.ts +1 -0
  165. package/lib/group-component/components/InputControl/index.js +16 -0
  166. package/lib/group-component/components/async-select/index.d.ts +11 -0
  167. package/lib/group-component/components/async-select/index.js +47 -0
  168. package/lib/group-component/components/async-table-select/index.d.ts +11 -0
  169. package/lib/group-component/components/async-table-select/index.js +49 -0
  170. package/lib/group-component/components/checkbox-control/index.d.ts +13 -0
  171. package/lib/group-component/components/checkbox-control/index.js +48 -0
  172. package/lib/group-component/components/checkbox-filter/CheckboxFilter.d.ts +18 -0
  173. package/lib/group-component/components/checkbox-filter/CheckboxFilter.js +267 -0
  174. package/lib/group-component/components/checkbox-filter/FilterSearch.d.ts +12 -0
  175. package/lib/group-component/components/checkbox-filter/FilterSearch.js +44 -0
  176. package/lib/group-component/components/command/Command.d.ts +10 -0
  177. package/lib/group-component/components/command/Command.js +44 -0
  178. package/lib/group-component/components/number/index.d.ts +12 -0
  179. package/lib/group-component/components/number/index.js +50 -0
  180. package/lib/group-component/components/number-range/index.d.ts +13 -0
  181. package/lib/group-component/components/number-range/index.js +87 -0
  182. package/lib/group-component/features/operator.d.ts +24 -0
  183. package/lib/group-component/features/operator.js +67 -0
  184. package/lib/group-component/footer/TableFooter.d.ts +7 -0
  185. package/lib/group-component/footer/TableFooter.js +44 -0
  186. package/lib/group-component/footer/TableFooterCell.d.ts +7 -0
  187. package/lib/group-component/footer/TableFooterCell.js +75 -0
  188. package/lib/group-component/footer/TableFooterRow.d.ts +8 -0
  189. package/lib/group-component/footer/TableFooterRow.js +37 -0
  190. package/lib/group-component/header/TableHead.d.ts +15 -0
  191. package/lib/group-component/header/TableHead.js +107 -0
  192. package/lib/group-component/header/TableHeadCell.d.ts +15 -0
  193. package/lib/group-component/header/TableHeadCell.js +319 -0
  194. package/lib/group-component/header/TableHeadCell2.d.ts +17 -0
  195. package/lib/group-component/header/TableHeadCell2.js +330 -0
  196. package/lib/group-component/header/TableHeadGroupCell.d.ts +17 -0
  197. package/lib/group-component/header/TableHeadGroupCell.js +103 -0
  198. package/lib/group-component/header/TableHeadRow.d.ts +15 -0
  199. package/lib/group-component/header/TableHeadRow.js +59 -0
  200. package/lib/group-component/header/renderFilter.d.ts +20 -0
  201. package/lib/group-component/header/renderFilter.js +301 -0
  202. package/lib/group-component/hook/convert.d.ts +1 -0
  203. package/lib/group-component/hook/convert.js +34 -0
  204. package/lib/group-component/hook/useColumns.d.ts +28 -0
  205. package/lib/group-component/hook/useColumns.js +318 -0
  206. package/lib/group-component/hook/useFilterOperator.d.ts +7 -0
  207. package/lib/group-component/hook/useFilterOperator.js +40 -0
  208. package/lib/group-component/hook/utils.d.ts +220 -0
  209. package/lib/group-component/hook/utils.js +2468 -0
  210. package/lib/group-component/index.d.ts +2 -0
  211. package/lib/group-component/index.js +9 -0
  212. package/lib/group-component/style.d.ts +22 -0
  213. package/lib/group-component/style.js +55 -0
  214. package/lib/group-component/style.scss +1438 -0
  215. package/lib/group-component/table/Grid.d.ts +33 -0
  216. package/lib/group-component/table/Grid.js +444 -0
  217. package/lib/group-component/table/TableWrapper.d.ts +33 -0
  218. package/lib/group-component/table/TableWrapper.js +259 -0
  219. package/lib/group-component/useContext.d.ts +100 -0
  220. package/lib/group-component/useContext.js +27 -0
  221. package/lib/table-component/InternalTable.js +9 -2
  222. package/lib/table-component/TableContainer.d.ts +1 -0
  223. package/lib/table-component/TableContainer.js +6 -2
  224. package/lib/table-component/TableContainerEdit.d.ts +1 -0
  225. package/lib/table-component/TableContainerEdit.js +4 -2
  226. package/lib/table-component/body/TableBodyCell.js +49 -40
  227. package/lib/table-component/body/TableBodyCellEdit.js +9 -6
  228. package/lib/table-component/body/TableBodyRow.js +4 -1
  229. package/lib/table-component/header/TableHeadCell2.js +38 -2
  230. package/lib/table-component/hook/utils.d.ts +1 -0
  231. package/lib/table-component/hook/utils.js +16 -7
  232. package/lib/table-component/style.js +1 -1
  233. package/lib/table-component/table/Grid.d.ts +1 -0
  234. package/lib/table-component/table/Grid.js +10 -3
  235. package/lib/table-component/useContext.d.ts +6 -0
  236. package/lib/table-component/useContext.js +2 -1
  237. package/lib/table-virtuoso/InternalTable.js +2 -2
  238. package/lib/table-virtuoso/body/TableBodyCell.js +2 -7
  239. package/lib/table-virtuoso/body/TableBodyCellRowGroup.d.ts +14 -0
  240. package/lib/table-virtuoso/body/TableBodyCellRowGroup.js +203 -0
  241. package/lib/table-virtuoso/body/TableBodyRow.d.ts +1 -1
  242. package/lib/table-virtuoso/body/TableBodyRow.js +43 -1
  243. package/lib/table-virtuoso/hook/utils.d.ts +1 -0
  244. package/lib/table-virtuoso/hook/utils.js +32 -1
  245. package/lib/table-virtuoso/style.js +3 -1
  246. package/lib/table-virtuoso/table/Grid.js +2 -2
  247. package/lib/table-virtuoso/table/TableWrapper.d.ts +7 -1
  248. package/lib/table-virtuoso/table/TableWrapper.js +24 -5
  249. package/lib/table-virtuoso/useContext.d.ts +6 -3
  250. package/lib/table-virtuoso/useContext.js +18 -0
  251. package/package.json +1 -1
@@ -0,0 +1,40 @@
1
+ import React, { useMemo } from "react";
2
+ import { Checkbox } from "rc-master-ui";
3
+ const CheckboxControl = props => {
4
+ const {
5
+ options,
6
+ value,
7
+ onChange
8
+ } = props;
9
+ const selected = useMemo(() => {
10
+ return value ? value : [];
11
+ }, [value]);
12
+ const list = useMemo(() => {
13
+ return options ? options : [];
14
+ }, [options]);
15
+ const onChangeValue = val => {
16
+ const findIndex = selected.findIndex(it => it === val);
17
+ if (findIndex > -1) {
18
+ const newVal = selected.filter(it => it !== val);
19
+ onChange?.(newVal);
20
+ } else {
21
+ const newVal = [...selected, val];
22
+ onChange?.(newVal);
23
+ }
24
+ };
25
+ return /*#__PURE__*/React.createElement("div", {
26
+ className: "d-flex flex-column gap-50",
27
+ style: {}
28
+ }, list.map((it, index) => {
29
+ return /*#__PURE__*/React.createElement("div", {
30
+ key: index,
31
+ className: "d-flex align-items-center"
32
+ }, /*#__PURE__*/React.createElement(Checkbox, {
33
+ checked: selected.includes(it.value),
34
+ type: "checkbox",
35
+ className: "cursor-pointer me-50",
36
+ onChange: () => onChangeValue(it.value)
37
+ }), /*#__PURE__*/React.createElement("span", null, it.label));
38
+ }));
39
+ };
40
+ export default CheckboxControl;
@@ -0,0 +1,18 @@
1
+ import * as React from "react";
2
+ import type { TableLocale } from "rc-master-ui/es/table/interface";
3
+ type Props = {
4
+ options: any[];
5
+ filterSearch?: boolean;
6
+ open?: boolean;
7
+ tablePrefixCls?: string;
8
+ prefixCls?: string;
9
+ dropdownPrefixCls?: string;
10
+ filterMultiple: boolean;
11
+ showFilter?: boolean;
12
+ onSelect?: (value: any) => void;
13
+ selectedKeys: string[];
14
+ locale?: TableLocale;
15
+ filterMode?: 'menu' | 'tree';
16
+ };
17
+ declare const CheckboxFilter: (props: Props) => React.JSX.Element;
18
+ export default CheckboxFilter;
@@ -0,0 +1,258 @@
1
+ import * as React from "react";
2
+ import classNames from "classnames";
3
+ import { Checkbox, Menu, Radio, Empty } from "rc-master-ui";
4
+ import { Tree } from "antd";
5
+ import { flattenKeys } from "rc-master-ui/es/table/hooks/useFilter";
6
+ import FilterSearch from "./FilterSearch";
7
+ function searchValueMatched(searchValue, text) {
8
+ if (typeof text === 'string' || typeof text === 'number') {
9
+ return text?.toString().toLowerCase().includes(searchValue.trim().toLowerCase());
10
+ }
11
+ return false;
12
+ }
13
+ function renderFilterItems({
14
+ filters,
15
+ prefixCls,
16
+ filteredKeys,
17
+ filterMultiple,
18
+ searchValue,
19
+ filterSearch
20
+ }) {
21
+ return filters.map((filter, index) => {
22
+ const key = String(filter.value);
23
+ if (filter.children) {
24
+ return {
25
+ key: key || index,
26
+ label: filter.text,
27
+ popupClassName: `${prefixCls}-dropdown-submenu`,
28
+ children: renderFilterItems({
29
+ filters: filter.children,
30
+ prefixCls,
31
+ filteredKeys,
32
+ filterMultiple,
33
+ searchValue,
34
+ filterSearch
35
+ })
36
+ };
37
+ }
38
+ const Component = filterMultiple ? Checkbox : Radio;
39
+ const item = {
40
+ key: filter.value !== undefined ? key : index,
41
+ label: /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Component, {
42
+ checked: filteredKeys.includes(key)
43
+ }), /*#__PURE__*/React.createElement("span", null, filter.text))
44
+ };
45
+ if (searchValue.trim()) {
46
+ if (typeof filterSearch === 'function') {
47
+ return filterSearch(searchValue, filter) ? item : null;
48
+ }
49
+ return searchValueMatched(searchValue, filter.text) ? item : null;
50
+ }
51
+ return item;
52
+ });
53
+ }
54
+ function hasSubMenu(filters) {
55
+ return filters.some(({
56
+ children
57
+ }) => children);
58
+ }
59
+ const CheckboxFilter = props => {
60
+ const {
61
+ // column,
62
+ filterSearch = true,
63
+ tablePrefixCls = 'ui-rc-table',
64
+ prefixCls = 'ui-rc-table-filter',
65
+ dropdownPrefixCls = 'ui-rc-dropdown',
66
+ filterMultiple,
67
+ selectedKeys: propsSelectedKeys,
68
+ locale,
69
+ options,
70
+ filterMode = 'tree',
71
+ // open,
72
+ // searchValue,
73
+ showFilter,
74
+ // setSearchValue,
75
+ onSelect
76
+ } = props;
77
+ const selectedKeys = React.useMemo(() => {
78
+ if (propsSelectedKeys) {
79
+ return propsSelectedKeys.map(it => String(it));
80
+ }
81
+ return [];
82
+ }, [propsSelectedKeys]);
83
+ const [searchValue, setSearchValue] = React.useState('');
84
+ const [openKeys, setOpenKeys] = React.useState([]);
85
+
86
+ // clear search value after close filter dropdown
87
+ // React.useEffect(() => {
88
+ // // if (visible) {
89
+ // setSearchValue('');
90
+ // // }
91
+ // }, [open]);
92
+
93
+ const onOpenChange = keys => {
94
+ setOpenKeys(keys);
95
+ };
96
+ const items = renderFilterItems({
97
+ // filters: column.filters || [],
98
+ filters: options || [],
99
+ filterSearch,
100
+ prefixCls,
101
+ filteredKeys: selectedKeys ?? [],
102
+ filterMultiple,
103
+ searchValue
104
+ });
105
+ const dropdownMenuClass = classNames({
106
+ // [`${dropdownPrefixCls}-menu-without-submenu`]: !hasSubMenu(column.filters || []),
107
+ [`${dropdownPrefixCls}-menu-without-submenu`]: !hasSubMenu(options || [])
108
+ });
109
+ const empty = /*#__PURE__*/React.createElement(Empty, {
110
+ image: Empty.PRESENTED_IMAGE_SIMPLE,
111
+ description: locale?.filterEmptyText,
112
+ imageStyle: {
113
+ height: 24
114
+ },
115
+ style: {
116
+ margin: 0,
117
+ padding: '16px 0'
118
+ }
119
+ });
120
+ const isEmpty = items.every(item => item === null);
121
+ const onSearch = e => {
122
+ const {
123
+ value
124
+ } = e.target;
125
+ setSearchValue(value);
126
+ };
127
+
128
+ // if ((column.filters || []).length === 0) {
129
+ // return empty;
130
+ // }
131
+
132
+ const getTreeData = ({
133
+ filters
134
+ }) => (filters || []).map((filter, index) => {
135
+ const key = String(filter.value);
136
+ const item = {
137
+ title: filter.label,
138
+ id: filter.value !== undefined ? filter.value : index,
139
+ key: filter.value !== undefined ? key : String(index)
140
+ };
141
+ if (filter.children) {
142
+ item.children = getTreeData({
143
+ filters: filter.children
144
+ });
145
+ }
146
+ return item;
147
+ });
148
+ const getFilterData = node => ({
149
+ ...node,
150
+ text: node.title,
151
+ value: node.key,
152
+ children: node.children?.map(item => getFilterData(item)) || []
153
+ });
154
+ const onCheckAll = e => {
155
+ if (e.target.checked) {
156
+ const allFilterKeys = flattenKeys(options).map(key => key);
157
+
158
+ // setFilteredKeysSync(allFilterKeys);
159
+ onSelect?.(allFilterKeys);
160
+ } else {
161
+ onSelect?.([]);
162
+ // setFilteredKeysSync([]);
163
+ }
164
+ };
165
+ const onCheck = (keys, {
166
+ node,
167
+ checked
168
+ }) => {
169
+ if (!filterMultiple) {
170
+ // onSelectKeys({ selectedKeys: checked && node.key ? [node.key] : [] });
171
+
172
+ onSelect?.(checked && node.key ? [node.id] : []);
173
+ } else {
174
+ if (!checked) {
175
+ const rs = propsSelectedKeys.filter(it => it !== node.id);
176
+ onSelect?.(rs);
177
+ } else {
178
+ const rs = [...propsSelectedKeys, node.id];
179
+ onSelect?.(rs);
180
+ }
181
+ // onSelectKeys({ selectedKeys: keys });
182
+ }
183
+ };
184
+ if (filterMode === 'tree') {
185
+ return /*#__PURE__*/React.createElement(React.Fragment, null, showFilter && /*#__PURE__*/React.createElement(FilterSearch, {
186
+ filterSearch: filterSearch,
187
+ value: searchValue,
188
+ onChange: onSearch,
189
+ tablePrefixCls: tablePrefixCls,
190
+ locale: locale
191
+ }), /*#__PURE__*/React.createElement("div", {
192
+ className: `${tablePrefixCls}-filter-dropdown-tree`
193
+ }, filterMultiple && options.length > 0 ? /*#__PURE__*/React.createElement(Checkbox
194
+ // checked={selectedKeys.length === flattenKeys(column.filters).length}
195
+ , {
196
+ checked: selectedKeys.length === flattenKeys(options).length
197
+ // indeterminate={
198
+ // selectedKeys.length > 0 &&
199
+ // selectedKeys.length < flattenKeys(column.filters).length
200
+ // }
201
+ ,
202
+
203
+ indeterminate: selectedKeys.length > 0 && selectedKeys.length < flattenKeys(options).length,
204
+ className: `${tablePrefixCls}-filter-dropdown-checkall`,
205
+ onChange: onCheckAll
206
+ }, locale?.filterCheckall) : /*#__PURE__*/React.createElement(Empty, null), /*#__PURE__*/React.createElement(Tree, {
207
+ checkable: true,
208
+ selectable: false,
209
+ blockNode: true,
210
+ multiple: filterMultiple,
211
+ checkStrictly: !filterMultiple,
212
+ className: `${dropdownPrefixCls}-menu`,
213
+ onCheck: onCheck,
214
+ checkedKeys: selectedKeys,
215
+ selectedKeys: selectedKeys,
216
+ showIcon: false
217
+ // treeData={getTreeData({ filters: column.filters })}
218
+ ,
219
+ treeData: getTreeData({
220
+ filters: options
221
+ }),
222
+ autoExpandParent: true,
223
+ defaultExpandAll: true,
224
+ filterTreeNode: searchValue.trim() ? node => {
225
+ if (typeof filterSearch === 'function') {
226
+ // @ts-ignore
227
+ return filterSearch(searchValue, getFilterData(node));
228
+ }
229
+ return searchValueMatched(searchValue, node.title);
230
+ } : undefined,
231
+ rootStyle: {
232
+ background: 'none',
233
+ boxShadow: 'none'
234
+ }
235
+ })));
236
+ }
237
+ return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(FilterSearch, {
238
+ filterSearch: filterSearch,
239
+ value: searchValue,
240
+ onChange: onSearch,
241
+ tablePrefixCls: tablePrefixCls,
242
+ locale: locale
243
+ }), isEmpty ? empty : /*#__PURE__*/React.createElement(Menu, {
244
+ selectable: true,
245
+ multiple: filterMultiple,
246
+ prefixCls: `${dropdownPrefixCls}-menu`,
247
+ className: dropdownMenuClass,
248
+ onSelect: onSelect,
249
+ onDeselect: onSelect,
250
+ selectedKeys: selectedKeys
251
+ // getPopupContainer={getPopupContainer}
252
+ ,
253
+ openKeys: openKeys,
254
+ onOpenChange: onOpenChange,
255
+ items: items
256
+ }));
257
+ };
258
+ export default CheckboxFilter;
@@ -0,0 +1,12 @@
1
+ import * as React from 'react';
2
+ import type { FilterSearchType, TableLocale } from "antd/es/table/interface";
3
+ import type { AnyObject } from '../../../grid-component/type';
4
+ interface FilterSearchProps<RecordType = AnyObject> {
5
+ value: string;
6
+ onChange: (e: React.ChangeEvent<HTMLInputElement>) => void;
7
+ filterSearch: FilterSearchType<RecordType>;
8
+ tablePrefixCls: string;
9
+ locale?: TableLocale;
10
+ }
11
+ declare const FilterSearch: <RecordType extends AnyObject = AnyObject>(props: FilterSearchProps<RecordType>) => React.JSX.Element;
12
+ export default FilterSearch;
@@ -0,0 +1,36 @@
1
+ import * as React from 'react';
2
+ import SearchOutlined from '@ant-design/icons/SearchOutlined';
3
+ import { Input } from 'rc-master-ui';
4
+
5
+ // import type {AnyObject} from "./../grid-component/type"
6
+
7
+ const FilterSearch = props => {
8
+ const {
9
+ value,
10
+ filterSearch,
11
+ tablePrefixCls,
12
+ locale,
13
+ onChange
14
+ } = props;
15
+ if (!filterSearch) {
16
+ return null;
17
+ }
18
+ return /*#__PURE__*/React.createElement("div", {
19
+ className: `${tablePrefixCls}-filter-dropdown-search`,
20
+ style: {
21
+ paddingLeft: 0,
22
+ paddingRight: 0
23
+ }
24
+ }, /*#__PURE__*/React.createElement(Input, {
25
+ suffix: /*#__PURE__*/React.createElement(SearchOutlined, null),
26
+ placeholder: locale?.filterSearchPlaceholder,
27
+ onChange: onChange,
28
+ value: value,
29
+ autoFocus: true
30
+ // for skip min-width of input
31
+ ,
32
+ htmlSize: 1,
33
+ className: `${tablePrefixCls}-filter-dropdown-search-input`
34
+ }));
35
+ };
36
+ export default FilterSearch;
@@ -0,0 +1,10 @@
1
+ import React from "react";
2
+ import type { CommandItem } from "../../../grid-component/type";
3
+ type Props<T> = {
4
+ id: string;
5
+ record: T;
6
+ item: CommandItem;
7
+ onClick: (e: any) => void;
8
+ };
9
+ declare const Command: <T extends object>(props: Props<T>) => React.JSX.Element;
10
+ export default Command;
@@ -0,0 +1,35 @@
1
+ import React, { Fragment } from "react";
2
+ import classnames from "classnames";
3
+ const Command = props => {
4
+ const {
5
+ item,
6
+ onClick,
7
+ record,
8
+ id
9
+ } = props;
10
+ return /*#__PURE__*/React.createElement(Fragment, null, item.template ? /*#__PURE__*/React.createElement("div", {
11
+ "data-tooltip-id": `${id}-tooltip-content`,
12
+ "data-tooltip-content": item.tooltip || item.title,
13
+ "data-tooltip-delay-show": 500,
14
+ id: item.id,
15
+ onClick: onClick
16
+ }, typeof item.template === 'function' ? item.template(record) : item.template) : /*#__PURE__*/React.createElement("div", {
17
+ tabIndex: -1,
18
+ "data-tooltip-id": `${id}-tooltip-content`,
19
+ "data-tooltip-delay-show": 500,
20
+ "data-tooltip-content": item.tooltip || item.title,
21
+ style: {
22
+ padding: '3px',
23
+ maxWidth: 45,
24
+ height: '100%',
25
+ display: 'flex',
26
+ cursor: 'pointer'
27
+ },
28
+ className: classnames('command-item', {
29
+ 'btn-icon': item.title === ''
30
+ }),
31
+ color: item.color ? item.color : 'primary',
32
+ onClick: onClick
33
+ }, typeof item.icon === 'function' ? item.icon() : item.icon));
34
+ };
35
+ export default Command;
@@ -0,0 +1,12 @@
1
+ import type { KeyboardEventHandler } from "react";
2
+ import React from "react";
3
+ import type { IFormat } from "../../../grid-component/type";
4
+ type Props = {
5
+ t?: any;
6
+ format?: IFormat;
7
+ value: number | string | undefined;
8
+ onChange?: (values: any[]) => void;
9
+ onPressEnter?: KeyboardEventHandler<HTMLInputElement>;
10
+ };
11
+ declare const NumberInput: (props: Props) => React.JSX.Element;
12
+ export default NumberInput;
@@ -0,0 +1,42 @@
1
+ import React, { Fragment } from "react";
2
+ import { NumericFormat } from "react-numeric-component";
3
+ import { Input } from "rc-master-ui";
4
+ import { checkDecimalSeparator, checkThousandSeparator } from "../../hook/utils";
5
+ const NumberInput = props => {
6
+ const {
7
+ t,
8
+ value,
9
+ format,
10
+ onChange,
11
+ onPressEnter
12
+ } = props;
13
+ const values = React.useMemo(() => [value], [value]);
14
+ return /*#__PURE__*/React.createElement(Fragment, null, /*#__PURE__*/React.createElement(NumericFormat, {
15
+ value: values[0] ?? ''
16
+ // value={min}
17
+ ,
18
+ thousandSeparator: checkThousandSeparator(format?.thousandSeparator, format?.decimalSeparator),
19
+ decimalSeparator: checkDecimalSeparator(format?.thousandSeparator, format?.decimalSeparator),
20
+ allowNegative: true,
21
+ customInput: Input,
22
+ className: 'input-element',
23
+ classNames: {
24
+ input: 'filter-input'
25
+ },
26
+ onValueChange: vals => {
27
+ // onChangeValueFilter(type, values.floatValue, 'min')
28
+
29
+ // setValues([vals.floatValue, values[1]])
30
+ onChange?.([vals.floatValue]);
31
+ },
32
+ onPressEnter: onPressEnter
33
+ // placeholder={t ? t('Min') : 'Min'}
34
+ ,
35
+ placeholder: t ? t('Enter') : 'Enter'
36
+ // autoFocus={true}
37
+ ,
38
+
39
+ allowClear: true
40
+ }));
41
+ };
42
+ export default NumberInput;
@@ -0,0 +1,13 @@
1
+ import type { KeyboardEventHandler } from "react";
2
+ import React from "react";
3
+ import type { IFormat } from "../../../grid-component/type";
4
+ type Props = {
5
+ t?: any;
6
+ format?: IFormat;
7
+ min: number | string | undefined;
8
+ max: number | string | undefined;
9
+ onChange?: (values: any[]) => void;
10
+ onPressEnter?: KeyboardEventHandler<HTMLInputElement>;
11
+ };
12
+ declare const NumberRange: (props: Props) => React.JSX.Element;
13
+ export default NumberRange;
@@ -0,0 +1,79 @@
1
+ import React, { Fragment } from "react";
2
+ import { NumericFormat } from "react-numeric-component";
3
+ import { Input } from "rc-master-ui";
4
+ import { checkDecimalSeparator, checkThousandSeparator } from "../../hook/utils";
5
+ const NumberRange = props => {
6
+ const {
7
+ t,
8
+ max,
9
+ min,
10
+ format,
11
+ onChange,
12
+ onPressEnter
13
+ } = props;
14
+ const values = React.useMemo(() => [min, max], [min, max]);
15
+
16
+ // const [values, setValues] = React.useState<any[]>(() =>
17
+ // mergedValues,
18
+ // );
19
+
20
+ return /*#__PURE__*/React.createElement(Fragment, null, /*#__PURE__*/React.createElement("div", {
21
+ className: '',
22
+ style: {
23
+ display: 'flex',
24
+ alignItems: 'center',
25
+ columnGap: 5
26
+ }
27
+ }, /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(NumericFormat, {
28
+ value: values[0] ?? ''
29
+ // value={min}
30
+ ,
31
+ thousandSeparator: checkThousandSeparator(format?.thousandSeparator, format?.decimalSeparator),
32
+ decimalSeparator: checkDecimalSeparator(format?.thousandSeparator, format?.decimalSeparator),
33
+ allowNegative: true,
34
+ customInput: Input,
35
+ className: 'input-element',
36
+ onValueChange: vals => {
37
+ // onChangeValueFilter(type, values.floatValue, 'min')
38
+
39
+ // setValues([vals.floatValue, values[1]])
40
+ onChange?.([vals.floatValue, max]);
41
+ }
42
+ // placeholder={t ? t('Min') : 'Min'}
43
+ ,
44
+ placeholder: t ? t('From') : 'From'
45
+ // autoFocus={true}
46
+ ,
47
+ allowClear: true,
48
+ classNames: {
49
+ input: 'filter-input'
50
+ },
51
+ onPressEnter: () => {
52
+ const maxInput = document.querySelector('.number-max-input');
53
+ if (maxInput) {
54
+ maxInput.focus();
55
+ }
56
+ }
57
+ })), /*#__PURE__*/React.createElement("span", null, " - "), /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(NumericFormat, {
58
+ value: values[1] ?? ''
59
+ // value={max}
60
+ ,
61
+ thousandSeparator: checkThousandSeparator(format?.thousandSeparator, format?.decimalSeparator),
62
+ decimalSeparator: checkDecimalSeparator(format?.thousandSeparator, format?.decimalSeparator),
63
+ allowNegative: true,
64
+ customInput: Input,
65
+ className: 'input-element',
66
+ onValueChange: vals => {
67
+ // setValues([values[0], vals.floatValue])
68
+ onChange?.([min, vals.floatValue]);
69
+ }
70
+ // placeholder={t ? t('Max') : 'Max'}
71
+ ,
72
+ placeholder: t ? t('To') : 'To',
73
+ onPressEnter: onPressEnter,
74
+ classNames: {
75
+ input: 'number-max-input'
76
+ }
77
+ }))));
78
+ };
79
+ export default NumberRange;
@@ -0,0 +1,24 @@
1
+ import { OnChangeFn, RowData, TableFeature } from '@tanstack/react-table';
2
+ export type ColumnOperatorState = ColumnOperator[];
3
+ export interface OperatorTableState {
4
+ operator: ColumnOperatorState;
5
+ }
6
+ export interface ColumnOperator {
7
+ id: string;
8
+ operator: string;
9
+ }
10
+ export interface OperatorOptions {
11
+ enableOperator?: boolean;
12
+ onColumnOperatorChange?: OnChangeFn<ColumnOperatorState>;
13
+ }
14
+ declare module '@tanstack/react-table' {
15
+ interface TableState extends OperatorTableState {
16
+ }
17
+ interface TableOptionsResolved<TData extends RowData> extends OperatorOptions {
18
+ }
19
+ interface Column<TData extends RowData, TValue> {
20
+ getFilterOperator: () => string;
21
+ setFilterOperator: (operator: string) => void;
22
+ }
23
+ }
24
+ export declare const OperatorFeature: TableFeature<any>;
@@ -0,0 +1,62 @@
1
+ // TypeScript setup for our new feature with all of the same type-safety as stock TanStack Table features
2
+
3
+ import { makeStateUpdater } from '@tanstack/react-table';
4
+
5
+ // define types for our new feature's table options
6
+
7
+ // Define types for our new feature's table APIs
8
+ // export interface OperatorInstance {
9
+ // setDensity: (updater: Updater<OpetorState>) => void
10
+
11
+ // toggleDensity: (value?: OpetorState) => void
12
+ // }
13
+
14
+ // Use declaration merging to add our new feature APIs and state types to TanStack Table's existing types.
15
+
16
+ export const OperatorFeature = {
17
+ // define the new feature's initial state
18
+ getInitialState: state => {
19
+ return {
20
+ operator: [],
21
+ ...state
22
+ };
23
+ },
24
+ // define the new feature's default options
25
+ getDefaultOptions: table => {
26
+ return {
27
+ enableOperator: true,
28
+ onColumnOperatorChange: makeStateUpdater('operator', table)
29
+ };
30
+ },
31
+ // if you need to add a default column definition...
32
+ // getDefaultColumnDef: <TData extends RowData>(): Partial<ColumnDef<TData>> => {
33
+ // return { meta: {} } //use meta instead of directly adding to the columnDef to avoid typescript stuff that's hard to workaround
34
+ // },
35
+
36
+ // define the new feature's table instance methods
37
+
38
+ // if you need to add row instance APIs...
39
+ // createRow: <TData extends RowData>(row, table): void => {},
40
+ // if you need to add cell instance APIs...
41
+ // createCell: <TData extends RowData>(cell, column, row, table): void => {},
42
+ // if you need to add column instance APIs...
43
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
44
+ createColumn: (column, table) => {
45
+ column.getFilterOperator = () => {
46
+ return table.getState().operator?.find(op => op.id === column.id)?.operator ?? undefined;
47
+ };
48
+ column.setFilterOperator = updater => {
49
+ const safeUpdater = old => {
50
+ const others = old.filter(op => op.id !== column.id);
51
+ return [...others, {
52
+ id: column.id,
53
+ operator: updater
54
+ }];
55
+ };
56
+ return table.options.onColumnOperatorChange?.(safeUpdater);
57
+ };
58
+ }
59
+
60
+ // if you need to add header instance APIs...
61
+ // createHeader: <TData extends RowData>(header, table): void => {},
62
+ };
@@ -0,0 +1,7 @@
1
+ import type { Table } from "@tanstack/react-table";
2
+ import React from "react";
3
+ interface TableFooterProps<T> {
4
+ table: Table<T>;
5
+ }
6
+ declare const TableFooter: <RecordType extends object>({ table, }: TableFooterProps<RecordType>) => React.JSX.Element;
7
+ export default TableFooter;