@lemon-fe/kits 1.0.0-99 → 1.0.2-0

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 (104) hide show
  1. package/README.md +5 -0
  2. package/es/components/Actions/index.js +4 -6
  3. package/es/components/Alert/index.d.ts +3 -0
  4. package/es/components/Alert/index.js +23 -0
  5. package/es/components/DataGrid/cell-editors/Date.d.ts +3 -2
  6. package/es/components/DataGrid/cell-editors/Date.js +6 -3
  7. package/es/components/DataGrid/cell-editors/Number.d.ts +3 -2
  8. package/es/components/DataGrid/cell-editors/Number.js +5 -1
  9. package/es/components/DataGrid/cell-editors/Row.js +1 -1
  10. package/es/components/DataGrid/cell-editors/Text.d.ts +7 -5
  11. package/es/components/DataGrid/cell-editors/Text.js +18 -1
  12. package/es/components/DataGrid/components/Search.d.ts +4 -0
  13. package/es/components/DataGrid/components/Search.js +186 -0
  14. package/es/components/DataGrid/hooks.d.ts +2 -2
  15. package/es/components/DataGrid/index.d.ts +14 -8
  16. package/es/components/DataGrid/index.js +187 -104
  17. package/es/components/DataGrid/index.less +71 -11
  18. package/es/components/DataGrid/renderer/CellDeleteRenderer.d.ts +5 -0
  19. package/es/components/DataGrid/renderer/CellDeleteRenderer.js +27 -0
  20. package/es/components/DataGrid/renderer/CellIndexRenderer.d.ts +3 -1
  21. package/es/components/DataGrid/renderer/CellIndexRenderer.js +13 -6
  22. package/es/components/DataGrid/renderer/CellRenderer.js +5 -2
  23. package/es/components/DataGrid/renderer/DetailCellRenderer.d.ts +1 -1
  24. package/es/components/DataGrid/renderer/HeaderRenderer.js +34 -13
  25. package/es/components/DataGrid/typings.d.ts +31 -5
  26. package/es/components/DataGrid/utils.d.ts +1 -1
  27. package/es/components/DataGrid/utils.js +38 -8
  28. package/es/components/DurationPicker/index.d.ts +4 -3
  29. package/es/components/DurationPicker/index.js +56 -48
  30. package/es/components/DurationPicker/index.less +3 -52
  31. package/es/components/EditableTable/Table.js +3 -3
  32. package/es/components/Filter/index.d.ts +1 -1
  33. package/es/components/Filter/index.js +82 -69
  34. package/es/components/Filter/index.less +1 -1
  35. package/es/components/Filter/typings.d.ts +17 -1
  36. package/es/components/FormLayout/index.d.ts +5 -1
  37. package/es/components/FormLayout/index.js +5 -4
  38. package/es/components/FormLayout/index.less +8 -6
  39. package/es/components/GreyPanel/index.d.ts +6 -0
  40. package/es/components/GreyPanel/index.js +20 -0
  41. package/es/components/GreyPanel/index.less +6 -0
  42. package/es/components/Icons/Add.d.ts +6 -0
  43. package/es/components/Icons/Add.js +42 -0
  44. package/es/components/Icons/Calendar.js +12 -17
  45. package/es/components/Icons/Clear.d.ts +3 -0
  46. package/es/components/Icons/Clear.js +22 -0
  47. package/es/components/Icons/Clock.d.ts +5 -0
  48. package/es/components/Icons/Clock.js +30 -0
  49. package/es/components/Icons/CloseLight.d.ts +5 -0
  50. package/es/components/Icons/CloseLight.js +34 -0
  51. package/es/components/Icons/Delete.d.ts +3 -0
  52. package/es/components/Icons/Delete.js +40 -0
  53. package/es/components/Icons/Down.d.ts +3 -5
  54. package/es/components/Icons/Down.js +5 -15
  55. package/es/components/Icons/More.d.ts +3 -5
  56. package/es/components/Icons/Question.d.ts +3 -0
  57. package/es/components/Icons/Question.js +21 -0
  58. package/es/components/Icons/Search.d.ts +3 -5
  59. package/es/components/Icons/Search.js +7 -17
  60. package/es/components/Icons/Tip.d.ts +3 -4
  61. package/es/components/Icons/Tip.js +58 -68
  62. package/es/components/Icons/index.d.ts +19 -7
  63. package/es/components/Icons/index.js +21 -9
  64. package/es/components/InputCompact/index.d.ts +10 -0
  65. package/es/components/InputCompact/index.js +69 -0
  66. package/es/components/InputCompact/index.less +18 -0
  67. package/es/components/InputNumber/index.d.ts +8 -0
  68. package/es/components/InputNumber/index.js +36 -0
  69. package/es/components/InputNumber/index.less +58 -0
  70. package/es/components/Layout/index.d.ts +18 -7
  71. package/es/components/Layout/index.js +126 -35
  72. package/es/components/Layout/index.less +53 -26
  73. package/es/components/Popup/index.d.ts +1 -1
  74. package/es/components/Popup/index.js +9 -5
  75. package/es/components/Popup/index.less +21 -2
  76. package/es/components/Portal/index.d.ts +7 -6
  77. package/es/components/Portal/index.js +57 -12
  78. package/es/components/Section/TabBar.d.ts +2 -1
  79. package/es/components/Section/index.d.ts +5 -1
  80. package/es/components/Section/index.js +30 -23
  81. package/es/components/Section/index.less +5 -1
  82. package/es/components/SelectView/index.d.ts +7 -1
  83. package/es/components/SelectView/index.js +15 -25
  84. package/es/components/SelectView/index.less +8 -20
  85. package/es/components/SiderTree/TreeNodeTitle.js +2 -2
  86. package/es/components/SiderTree/index.d.ts +3 -2
  87. package/es/components/SiderTree/index.js +43 -62
  88. package/es/components/SiderTree/index.less +33 -67
  89. package/es/components/State/index.d.ts +8 -0
  90. package/es/components/State/index.js +15 -0
  91. package/es/components/State/index.less +126 -0
  92. package/es/components/TipMark/index.d.ts +8 -0
  93. package/es/components/TipMark/index.js +53 -0
  94. package/es/hooks/useBatchOperator/index.d.ts +44 -7
  95. package/es/hooks/useBatchOperator/index.js +243 -133
  96. package/es/index.d.ts +10 -2
  97. package/es/index.js +7 -0
  98. package/es/index.less +4 -0
  99. package/es/init.js +42 -25
  100. package/es/layouts/BasicLayout/components/Main.js +37 -4
  101. package/es/layouts/BasicLayout/components/MainFramework/index.less +19 -0
  102. package/es/styles/overrides.less +156 -54
  103. package/es/styles/utils.less +7 -1
  104. package/package.json +21 -15
package/README.md CHANGED
@@ -31,3 +31,8 @@ Build library via `father-build`,
31
31
  ```bash
32
32
  $ npm run build
33
33
  ```
34
+
35
+ ## Break Changes
36
+
37
+ - Layout Tab 属性 key 必须,title 可选
38
+ - Section Tab 属性 Key 必须,title 可选
@@ -53,7 +53,7 @@ function Actions(props) {
53
53
  return item;
54
54
  }
55
55
 
56
- if ( /*#__PURE__*/React.isValidElement(item)) {
56
+ if ( /*#__PURE__*/isValidElement(item)) {
57
57
  return /*#__PURE__*/React.createElement(Fragment, {
58
58
  key: index
59
59
  }, item);
@@ -67,7 +67,7 @@ function Actions(props) {
67
67
  action = item.action,
68
68
  rest = _objectWithoutProperties(item, _excluded);
69
69
 
70
- if ( /*#__PURE__*/React.isValidElement(text)) {
70
+ if ( /*#__PURE__*/isValidElement(text)) {
71
71
  return /*#__PURE__*/React.createElement(Fragment, {
72
72
  key: index
73
73
  }, text);
@@ -134,9 +134,7 @@ function Actions(props) {
134
134
  icon: icon
135
135
  }, rest), text, /*#__PURE__*/React.createElement(Icons.Down, {
136
136
  style: {
137
- opacity: 0.7,
138
- fontSize: 16,
139
- verticalAlign: -3
137
+ opacity: 0.7
140
138
  }
141
139
  })));
142
140
  }
@@ -158,7 +156,7 @@ function Actions(props) {
158
156
  return item;
159
157
  }
160
158
 
161
- if ( /*#__PURE__*/React.isValidElement(item)) {
159
+ if ( /*#__PURE__*/isValidElement(item)) {
162
160
  return /*#__PURE__*/React.createElement(Fragment, {
163
161
  key: index
164
162
  }, item);
@@ -0,0 +1,3 @@
1
+ /// <reference types="react" />
2
+ import { type AlertProps } from 'antd';
3
+ export default function Alert(props: AlertProps): JSX.Element;
@@ -0,0 +1,23 @@
1
+ var _excluded = ["icon", "type"];
2
+
3
+ function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
4
+
5
+ function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
6
+
7
+ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
8
+
9
+ import { Alert as AntdAlert } from 'antd';
10
+ import React from 'react';
11
+ import Icons from "../Icons";
12
+ export default function Alert(props) {
13
+ var icon = props.icon,
14
+ type = props.type,
15
+ restProps = _objectWithoutProperties(props, _excluded);
16
+
17
+ return /*#__PURE__*/React.createElement(AntdAlert, _extends({}, restProps, {
18
+ type: type,
19
+ icon: icon || /*#__PURE__*/React.createElement(Icons.Tip, {
20
+ type: type
21
+ })
22
+ }));
23
+ }
@@ -1,11 +1,12 @@
1
- import React from 'react';
2
- import type { ICellEditorReactComp } from '@ag-grid-community/react';
3
1
  import type { ICellEditorParams } from '@ag-grid-community/core';
2
+ import type { ICellEditorReactComp } from '@ag-grid-community/react';
4
3
  import { type Moment } from 'moment';
4
+ import React from 'react';
5
5
  export interface DateEditorParams {
6
6
  format: string;
7
7
  disabled?: boolean;
8
8
  disabledDate?: (current: Moment) => boolean;
9
+ allowClear?: boolean;
9
10
  }
10
11
  declare const _default: React.ForwardRefExoticComponent<ICellEditorParams<any, any, any> & DateEditorParams & React.RefAttributes<ICellEditorReactComp>>;
11
12
  export default _default;
@@ -16,10 +16,10 @@ function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Sy
16
16
 
17
17
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
18
18
 
19
+ import { DatePicker } from 'antd';
20
+ import moment from 'moment';
19
21
  import React, { useEffect, useRef } from 'react';
20
22
  import { forwardRef, useImperativeHandle, useState } from 'react';
21
- import moment from 'moment';
22
- import { DatePicker } from 'antd';
23
23
  import EditorWrapper from "./Wrapper";
24
24
  import { editorPrefixClass, navigateCell } from "./utils";
25
25
  export default /*#__PURE__*/forwardRef(function DateEditor(props, ref) {
@@ -27,7 +27,9 @@ export default /*#__PURE__*/forwardRef(function DateEditor(props, ref) {
27
27
  format = _props$format === void 0 ? 'YYYY-MM-DD' : _props$format,
28
28
  disabled = props.disabled,
29
29
  api = props.api,
30
- disabledDate = props.disabledDate;
30
+ disabledDate = props.disabledDate,
31
+ _props$allowClear = props.allowClear,
32
+ allowClear = _props$allowClear === void 0 ? false : _props$allowClear;
31
33
 
32
34
  var _useState = useState(props.value ? moment(props.value, format) : null),
33
35
  _useState2 = _slicedToArray(_useState, 2),
@@ -64,6 +66,7 @@ export default /*#__PURE__*/forwardRef(function DateEditor(props, ref) {
64
66
  paddingTop: 0,
65
67
  paddingBottom: 0
66
68
  },
69
+ allowClear: allowClear,
67
70
  disabled: disabled,
68
71
  className: editorPrefixClass('date'),
69
72
  value: value,
@@ -12,9 +12,10 @@ export interface NumberEditorParams<TData = any> {
12
12
  */
13
13
  max?: number;
14
14
  /**
15
- * @description 空值
15
+ * @description 空值 如果为null则可以是空值
16
+ * @default 0
16
17
  */
17
- emptyValue?: number;
18
+ emptyValue?: number | null;
18
19
  /**
19
20
  * @description 精度
20
21
  */
@@ -52,7 +52,7 @@ export default /*#__PURE__*/forwardRef(function NumberEditor(props, ref) {
52
52
  setValue = _useState2[1];
53
53
 
54
54
  var elm = useRef(null);
55
- var dirty = useRef(false);
55
+ var dirty = useRef(!!props.charPress);
56
56
  useEffect(function () {
57
57
  if (elm.current === null) {
58
58
  return;
@@ -93,6 +93,10 @@ export default /*#__PURE__*/forwardRef(function NumberEditor(props, ref) {
93
93
 
94
94
  var val = getFormatedValue();
95
95
 
96
+ if (emptyValue === null && val === null) {
97
+ return false;
98
+ }
99
+
96
100
  if (val === null || val < min || val > max) {
97
101
  return true;
98
102
  }
@@ -138,7 +138,7 @@ export default /*#__PURE__*/forwardRef(function RowEditor(props, ref) {
138
138
  api.tabToNextCell();
139
139
  }
140
140
  }
141
- }, render(field ? get(value, field) : prevValue, data, _objectSpread(_objectSpread({}, props), {}, {
141
+ }, render(field ? get(value, field) : prevValue, value === data ? data : _objectSpread(_objectSpread({}, data), value), _objectSpread(_objectSpread({}, props), {}, {
142
142
  context: context,
143
143
  ref: elm,
144
144
  onChange: handleChange
@@ -1,8 +1,10 @@
1
- import React from 'react';
2
- import type { ICellEditorReactComp } from '@ag-grid-community/react';
3
1
  import type { ICellEditorParams } from '@ag-grid-community/core';
4
- export interface TextEditorParams {
5
- disabled: boolean;
2
+ import type { ICellEditorReactComp } from '@ag-grid-community/react';
3
+ import React from 'react';
4
+ export interface TextEditorParams<TData = any> {
5
+ disabled?: boolean;
6
+ maxLength?: number;
7
+ isCancelAfterEnd?: (newValue: string, data: TData) => boolean;
6
8
  }
7
- declare const _default: React.ForwardRefExoticComponent<ICellEditorParams<any, any, any> & TextEditorParams & React.RefAttributes<ICellEditorReactComp>>;
9
+ declare const _default: React.ForwardRefExoticComponent<ICellEditorParams<any, any, any> & TextEditorParams<any> & React.RefAttributes<ICellEditorReactComp>>;
8
10
  export default _default;
@@ -16,12 +16,17 @@ function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Sy
16
16
 
17
17
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
18
18
 
19
+ import { message } from 'antd';
19
20
  import React, { useEffect, useMemo, useRef } from 'react';
20
21
  import { forwardRef, useImperativeHandle, useState } from 'react';
21
22
  import EditorWrapper from "./Wrapper";
22
23
  import { editorPrefixClass, navigateCell } from "./utils";
23
24
  export default /*#__PURE__*/forwardRef(function TextEditor(props, ref) {
24
- var disabled = props.disabled;
25
+ var disabled = props.disabled,
26
+ maxLength = props.maxLength,
27
+ _isCancelAfterEnd = props.isCancelAfterEnd,
28
+ data = props.data,
29
+ headerName = props.colDef.headerName;
25
30
 
26
31
  var _useMemo = useMemo(function () {
27
32
  if (props.eventKey === 'BackSpace') {
@@ -57,6 +62,18 @@ export default /*#__PURE__*/forwardRef(function TextEditor(props, ref) {
57
62
  }, []);
58
63
  useImperativeHandle(ref, function () {
59
64
  return {
65
+ isCancelAfterEnd: function isCancelAfterEnd() {
66
+ if (maxLength && (value || '').length > maxLength) {
67
+ message.warning("".concat(headerName || '', "\u6700\u591A").concat(maxLength, "\u4E2A\u5B57\u7B26"));
68
+ return true;
69
+ }
70
+
71
+ if (_isCancelAfterEnd !== undefined) {
72
+ return _isCancelAfterEnd(value, data);
73
+ }
74
+
75
+ return false;
76
+ },
60
77
  getValue: function getValue() {
61
78
  return value;
62
79
  }
@@ -0,0 +1,4 @@
1
+ import React from 'react';
2
+ import type { DataGridSearch, DataGridSearchRef } from '../typings';
3
+ declare const _default: React.MemoExoticComponent<React.ForwardRefExoticComponent<DataGridSearch & React.RefAttributes<DataGridSearchRef>>>;
4
+ export default _default;
@@ -0,0 +1,186 @@
1
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
2
+
3
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
4
+
5
+ function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
6
+
7
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
8
+
9
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
10
+
11
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
12
+
13
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
14
+
15
+ function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
16
+
17
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
18
+
19
+ import { useDebounce } from '@lemon-fe/hooks';
20
+ import { Button, Input, Space } from 'antd';
21
+ import React, { forwardRef, memo, useState, useImperativeHandle, useMemo } from 'react';
22
+ import { useGridStore } from "../hooks";
23
+ export default /*#__PURE__*/memo( /*#__PURE__*/forwardRef(function Search(props, ref) {
24
+ var placeholder = props.placeholder,
25
+ searchFields = props.searchFields,
26
+ focusColumn = props.focusColumn;
27
+ var defaultState = useMemo(function () {
28
+ return {
29
+ keywords: '',
30
+ nodes: [],
31
+ index: -1
32
+ };
33
+ }, []);
34
+ var grid = useGridStore(function (state) {
35
+ return state.grid;
36
+ });
37
+
38
+ var _useState = useState(defaultState),
39
+ _useState2 = _slicedToArray(_useState, 2),
40
+ state = _useState2[0],
41
+ setState = _useState2[1];
42
+
43
+ var handleSearch = useDebounce(function (keywords) {
44
+ if (keywords.length <= 0) {
45
+ setState(defaultState);
46
+ return;
47
+ }
48
+
49
+ var cols = [];
50
+
51
+ if (searchFields) {
52
+ searchFields.forEach(function (col) {
53
+ var result = grid.columnApi.getColumn(col);
54
+
55
+ if (result) {
56
+ cols.push(result);
57
+ } else {
58
+ cols.push(col);
59
+ }
60
+ });
61
+ } else {
62
+ cols = grid.columnApi.getColumns() || [];
63
+ }
64
+
65
+ if (cols.length <= 0) {
66
+ return;
67
+ }
68
+
69
+ var nodes = [];
70
+ grid.api.forEachNodeAfterFilterAndSort(function (node) {
71
+ var idx = node.rowIndex;
72
+
73
+ if (idx === null) {
74
+ return;
75
+ }
76
+
77
+ for (var i = 0; i < cols.length; i++) {
78
+ var col = cols[i];
79
+ var value = grid.api.getValue(col, node);
80
+
81
+ if (value !== undefined && value !== null && typeof value === 'string' && value.includes(keywords)) {
82
+ nodes.push({
83
+ index: idx,
84
+ id: node.id
85
+ });
86
+ break;
87
+ }
88
+ }
89
+ });
90
+ setState(function (prev) {
91
+ return _objectSpread(_objectSpread({}, prev), {}, {
92
+ nodes: nodes,
93
+ index: -1
94
+ });
95
+ });
96
+ }, 300);
97
+
98
+ var focusCell = function focusCell(index) {
99
+ var node = grid.api.getModel().getRow(index);
100
+
101
+ if (node === undefined) {
102
+ return;
103
+ }
104
+
105
+ grid.api.ensureIndexVisible(index);
106
+ var col = grid.columnApi.getAllDisplayedColumns()[0];
107
+
108
+ if (focusColumn) {
109
+ col = grid.columnApi.getColumn(focusColumn);
110
+
111
+ if (col !== null) {
112
+ grid.api.setFocusedCell(index, col);
113
+
114
+ if (col.isCellEditable(node)) {
115
+ grid.api.startEditingCell({
116
+ rowIndex: index,
117
+ colKey: col
118
+ });
119
+ }
120
+ }
121
+ } else {
122
+ node.setSelected(true);
123
+ }
124
+ };
125
+
126
+ var handlePrev = function handlePrev() {
127
+ if (state.nodes.length <= 0) {
128
+ return;
129
+ }
130
+
131
+ var idx = (state.index - 1 + state.nodes.length) % state.nodes.length;
132
+ focusCell(state.nodes[idx].index);
133
+ setState(function (prev) {
134
+ return _objectSpread(_objectSpread({}, prev), {}, {
135
+ index: idx
136
+ });
137
+ });
138
+ };
139
+
140
+ var handleNext = function handleNext() {
141
+ if (state.nodes.length <= 0) {
142
+ return;
143
+ }
144
+
145
+ var idx = (state.index + 1) % state.nodes.length;
146
+ focusCell(state.nodes[idx].index);
147
+ setState(function (prev) {
148
+ return _objectSpread(_objectSpread({}, prev), {}, {
149
+ index: idx
150
+ });
151
+ });
152
+ };
153
+
154
+ useImperativeHandle(ref, function () {
155
+ return {
156
+ reset: function reset() {
157
+ setState(defaultState);
158
+ }
159
+ };
160
+ });
161
+ return /*#__PURE__*/React.createElement(Space, null, /*#__PURE__*/React.createElement(Input, {
162
+ placeholder: placeholder || '输入关键字搜索',
163
+ value: state.keywords,
164
+ size: "small",
165
+ onChange: function onChange(e) {
166
+ setState(function (prev) {
167
+ return _objectSpread(_objectSpread({}, prev), {}, {
168
+ keywords: e.target.value
169
+ });
170
+ });
171
+ handleSearch(e.target.value);
172
+ },
173
+ suffix: /*#__PURE__*/React.createElement("span", null, "".concat(state.index + 1, "/").concat(state.nodes.length)),
174
+ onKeyUp: function onKeyUp(e) {
175
+ if (e.key === 'Enter') {
176
+ handleNext();
177
+ }
178
+ }
179
+ }), /*#__PURE__*/React.createElement(Button, {
180
+ size: "small",
181
+ onClick: handlePrev
182
+ }, "\u4E0A\u4E00\u4E2A"), /*#__PURE__*/React.createElement(Button, {
183
+ size: "small",
184
+ onClick: handleNext
185
+ }, "\u4E0B\u4E00\u4E2A"));
186
+ }));
@@ -2,7 +2,7 @@
2
2
  import type { GridStore } from './typings';
3
3
  import type DataGrid from './';
4
4
  export declare function useGridStore<T>(getter: (state: GridStore) => T): T;
5
- interface UseGrid<TData> {
5
+ interface UseGrid<TData extends Record<string, any>> {
6
6
  /**
7
7
  * @param 执行函数
8
8
  */
@@ -13,7 +13,7 @@ interface UseGrid<TData> {
13
13
  */
14
14
  (cb: (curr: DataGrid<TData>) => void, isAsync?: boolean): void;
15
15
  }
16
- export declare function useDataGrid<TData>(): {
16
+ export declare function useDataGrid<TData extends Record<string, any>>(): {
17
17
  ref: import("react").MutableRefObject<DataGrid<TData> | null>;
18
18
  use: UseGrid<TData>;
19
19
  };
@@ -1,8 +1,8 @@
1
- import React, { Component } from 'react';
2
- import type { ColDef } from '@ag-grid-community/core';
1
+ import type { ColDef, IRowNode } from '@ag-grid-community/core';
3
2
  import { GridApi, ColumnApi } from '@ag-grid-community/core';
4
- import type { ColType, DataGridProps, DataGridState } from './typings';
3
+ import React, { Component } from 'react';
5
4
  import EditorWrapper from './cell-editors/Wrapper';
5
+ import type { ColType, DataGridProps, DataGridState } from './typings';
6
6
  export default class DataGrid<TData extends Record<string, any>> extends Component<DataGridProps<TData>, DataGridState<TData>> {
7
7
  api: GridApi<TData>;
8
8
  columnApi: ColumnApi;
@@ -15,6 +15,7 @@ export default class DataGrid<TData extends Record<string, any>> extends Compone
15
15
  private readyQueue;
16
16
  private emptyRowData;
17
17
  private sideBarDef;
18
+ private searchRef;
18
19
  private prevFocusedCell;
19
20
  static defaultProps: {
20
21
  stopEditingWhenCellsLoseFocus: boolean;
@@ -41,14 +42,15 @@ export default class DataGrid<TData extends Record<string, any>> extends Compone
41
42
  columnTypes: Record<string, ColDef<any>>;
42
43
  defaultColDef: ColDef<any>;
43
44
  components: Record<string, any>;
44
- loading: boolean;
45
45
  };
46
+ static SummaryFlag: symbol;
47
+ static IndexColId: string;
46
48
  static EmptyCol: ColType<any>;
47
49
  static Editors: {
48
- Text: React.ForwardRefExoticComponent<import("@ag-grid-community/core").ICellEditorParams<any, any, any> & import("./typings").TextEditorParams & React.RefAttributes<import("@ag-grid-community/react").ICellEditorReactComp>>;
50
+ Text: React.ForwardRefExoticComponent<import("@ag-grid-community/core").ICellEditorParams<any, any, any> & import("./typings").TextEditorParams<any> & React.RefAttributes<import("@ag-grid-community/react").ICellEditorReactComp>>;
49
51
  Date: React.ForwardRefExoticComponent<import("@ag-grid-community/core").ICellEditorParams<any, any, any> & import("./typings").DateEditorParams & React.RefAttributes<import("@ag-grid-community/react").ICellEditorReactComp>>;
50
52
  Number: React.ForwardRefExoticComponent<import("@ag-grid-community/core").ICellEditorParams<any, any, any> & import("./typings").NumberEditorParams<any> & React.RefAttributes<import("@ag-grid-community/react").ICellEditorReactComp>>;
51
- Select: React.ForwardRefExoticComponent<import("@ag-grid-community/core").ICellEditorParams<any, any, any> & Pick<import("antd").SelectProps<any, import("antd/lib/select").BaseOptionType>, "disabled" | "mode" | "allowClear" | "options" | "virtual" | "showSearch" | "listHeight"> & {
53
+ Select: React.ForwardRefExoticComponent<import("@ag-grid-community/core").ICellEditorParams<any, any, any> & Pick<import("antd").SelectProps<any, import("antd/lib/select").BaseOptionType>, "disabled" | "allowClear" | "mode" | "options" | "virtual" | "showSearch" | "listHeight"> & {
52
54
  fieldNames?: {
53
55
  label: string;
54
56
  value: string;
@@ -66,12 +68,16 @@ export default class DataGrid<TData extends Record<string, any>> extends Compone
66
68
  private syncColRender;
67
69
  private syncSelection;
68
70
  private syncRowData;
69
- private getColumDefs;
71
+ private getColumnDefs;
70
72
  private isClientMode;
71
73
  private clearReadyQueue;
72
- private afterReady;
74
+ afterReady(cb: () => void): void;
73
75
  private isPreserveSelected;
74
76
  private updateRowData;
77
+ isSummaryRow({ node }: {
78
+ node?: IRowNode<any>;
79
+ }): boolean;
80
+ private getSummaryRowData;
75
81
  private getDataFromServer;
76
82
  private pagination;
77
83
  private init;