@lemon-fe/kits 1.0.0-1 → 1.0.0-11

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.
@@ -9,6 +9,7 @@ export default class DataGrid<TData> extends Component<DataGridProps<TData>, {
9
9
  page: number;
10
10
  pageSize: number;
11
11
  total: number;
12
+ loading: boolean;
12
13
  }> {
13
14
  api: GridApi<any>;
14
15
  private selected;
@@ -19,10 +20,10 @@ export default class DataGrid<TData> extends Component<DataGridProps<TData>, {
19
20
  private validator;
20
21
  private requestId;
21
22
  private isReady;
23
+ private readyQueue;
22
24
  private emptyRowData;
23
25
  static defaultProps: {
24
26
  autoLoad: boolean;
25
- columnTypes: Record<string, ColDef<any>>;
26
27
  localeText: {
27
28
  copy: string;
28
29
  copyWithHeaders: string;
@@ -41,6 +42,9 @@ export default class DataGrid<TData> extends Component<DataGridProps<TData>, {
41
42
  expandAll: string;
42
43
  collapseAll: string;
43
44
  };
45
+ columnTypes: Record<string, ColDef<any>>;
46
+ defaultColDef: ColDef<any>;
47
+ loading: boolean;
44
48
  };
45
49
  static EmptyCol: ColumnType<any>;
46
50
  static Editors: {
@@ -58,6 +62,8 @@ export default class DataGrid<TData> extends Component<DataGridProps<TData>, {
58
62
  private syncRowData;
59
63
  private getColumDefs;
60
64
  private isClientMode;
65
+ private clearReadyQueue;
66
+ private afterReady;
61
67
  private updateRowData;
62
68
  private getDataFromServer;
63
69
  private sort;
@@ -73,5 +79,6 @@ export default class DataGrid<TData> extends Component<DataGridProps<TData>, {
73
79
  private cellEditingStop;
74
80
  fetch(page?: number): void;
75
81
  refresh(): void;
82
+ ready(): boolean;
76
83
  render(): JSX.Element;
77
84
  }
@@ -1,7 +1,7 @@
1
1
  var _excluded = ["validator"],
2
2
  _excluded2 = ["title", "key", "dataIndex", "align", "type", "fixed", "render", "ellipsis", "cellRenderer", "cellRendererParams", "className", "sorter", "editable"],
3
3
  _excluded3 = ["title", "children"],
4
- _excluded4 = ["rowSelection", "rowKey", "fetch", "dataSource", "summary", "rowActions", "context", "onGridReady", "pagination", "defaultColDef"];
4
+ _excluded4 = ["rowSelection", "rowKey", "fetch", "dataSource", "summary", "rowActions", "context", "onGridReady", "pagination", "columnTypes", "defaultColDef"];
5
5
 
6
6
  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); }
7
7
 
@@ -85,8 +85,7 @@ import empty from "./empty.png";
85
85
  ModuleRegistry.registerModules([ClientSideRowModelModule, RowGroupingModule, InfiniteRowModelModule, ClipboardModule, MenuModule, SideBarModule, ColumnsToolPanelModule, ServerSideRowModelModule], false);
86
86
  var defaultColDef = {
87
87
  resizable: true,
88
- width: 160,
89
- sortable: true,
88
+ width: 140,
90
89
  suppressMenu: true
91
90
  };
92
91
 
@@ -120,6 +119,8 @@ var DataGrid = /*#__PURE__*/function (_Component) {
120
119
 
121
120
  _defineProperty(_assertThisInitialized(_this), "isReady", false);
122
121
 
122
+ _defineProperty(_assertThisInitialized(_this), "readyQueue", []);
123
+
123
124
  _defineProperty(_assertThisInitialized(_this), "emptyRowData", []);
124
125
 
125
126
  _defineProperty(_assertThisInitialized(_this), "init", function (args) {
@@ -128,6 +129,9 @@ var DataGrid = /*#__PURE__*/function (_Component) {
128
129
  _this.api = api;
129
130
  _this.columnApi = columnApi;
130
131
  _this.isReady = true;
132
+
133
+ _this.clearReadyQueue();
134
+
131
135
  var _this$props = _this.props,
132
136
  onGridReady = _this$props.onGridReady,
133
137
  autoLoad = _this$props.autoLoad;
@@ -177,7 +181,8 @@ var DataGrid = /*#__PURE__*/function (_Component) {
177
181
 
178
182
  _defineProperty(_assertThisInitialized(_this), "getRowId", function (params) {
179
183
  var rowKey = _this.props.rowKey;
180
- return typeof rowKey === 'function' ? rowKey(params.data) : get(params.data, rowKey);
184
+ var result = typeof rowKey === 'function' ? rowKey(params.data) : get(params.data, rowKey);
185
+ return String(result !== null && result !== void 0 ? result : '').toString();
181
186
  });
182
187
 
183
188
  _defineProperty(_assertThisInitialized(_this), "cellValueChanged", function (evt) {
@@ -195,7 +200,8 @@ var DataGrid = /*#__PURE__*/function (_Component) {
195
200
  });
196
201
 
197
202
  _this.state = _objectSpread({
198
- colDefs: _this.getColumDefs()
203
+ colDefs: _this.getColumDefs(),
204
+ loading: props.loading
199
205
  }, _this.getPagination());
200
206
  _this.store = new Store({
201
207
  errors: new Map(),
@@ -221,7 +227,7 @@ var DataGrid = /*#__PURE__*/function (_Component) {
221
227
  pagination = _this$props2.pagination,
222
228
  fetch = _this$props2.fetch;
223
229
  var page = 1;
224
- var pageSize = 20;
230
+ var pageSize = 50;
225
231
  var total = 0;
226
232
  var enable = false;
227
233
 
@@ -256,7 +262,8 @@ var DataGrid = /*#__PURE__*/function (_Component) {
256
262
  columns = _this$props3.columns,
257
263
  rowSelection = _this$props3.rowSelection,
258
264
  dataSource = _this$props3.dataSource,
259
- context = _this$props3.context;
265
+ context = _this$props3.context,
266
+ loading = _this$props3.loading;
260
267
 
261
268
  if (columns !== prevProps.columns) {
262
269
  this.syncColRender();
@@ -275,6 +282,12 @@ var DataGrid = /*#__PURE__*/function (_Component) {
275
282
  context: context
276
283
  });
277
284
  }
285
+
286
+ if (loading !== prevProps.loading) {
287
+ this.setState({
288
+ loading: loading
289
+ });
290
+ }
278
291
  }
279
292
  }, {
280
293
  key: "syncColRender",
@@ -631,21 +644,43 @@ var DataGrid = /*#__PURE__*/function (_Component) {
631
644
  value: function isClientMode() {
632
645
  return this.props.dataSource !== undefined;
633
646
  }
647
+ }, {
648
+ key: "clearReadyQueue",
649
+ value: function clearReadyQueue() {
650
+ this.readyQueue.forEach(function (cb) {
651
+ cb();
652
+ });
653
+ this.readyQueue = [];
654
+ }
655
+ }, {
656
+ key: "afterReady",
657
+ value: function afterReady(cb) {
658
+ if (this.isReady) {
659
+ cb();
660
+ } else {
661
+ this.readyQueue.push(cb);
662
+ }
663
+ }
634
664
  }, {
635
665
  key: "updateRowData",
636
666
  value: function updateRowData() {
637
667
  var _this5 = this;
638
668
 
639
669
  var data = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
640
- this.dataSource = data;
641
- this.api.setRowData(data);
642
- this.api.forEachNode(function (node) {
643
- if (node.id && _this5.selected.has(node.id)) {
644
- node.setSelected(true, false, true);
645
- }
646
- });
647
- this.api.dispatchEvent({
648
- type: 'selectionChanged'
670
+ this.afterReady(function () {
671
+ _this5.dataSource = data;
672
+
673
+ _this5.api.setRowData(data);
674
+
675
+ _this5.api.forEachNode(function (node) {
676
+ if (node.id && _this5.selected.has(node.id)) {
677
+ node.setSelected(true, false, true);
678
+ }
679
+ });
680
+
681
+ _this5.api.dispatchEvent({
682
+ type: 'selectionChanged'
683
+ });
649
684
  });
650
685
  }
651
686
  }, {
@@ -665,7 +700,9 @@ var DataGrid = /*#__PURE__*/function (_Component) {
665
700
  pageSize = _this$state.pageSize;
666
701
  var columnState = this.columnApi.getColumnState();
667
702
  var id = this.requestId;
668
- this.api.showLoadingOverlay();
703
+ this.setState({
704
+ loading: true
705
+ });
669
706
  fetch({
670
707
  current: page,
671
708
  pageSize: pageSize,
@@ -678,7 +715,9 @@ var DataGrid = /*#__PURE__*/function (_Component) {
678
715
  };
679
716
  })
680
717
  }).then(function (res) {
681
- _this6.api.hideOverlay();
718
+ _this6.setState({
719
+ loading: false
720
+ });
682
721
 
683
722
  if (id !== _this6.requestId) {
684
723
  return;
@@ -710,7 +749,9 @@ var DataGrid = /*#__PURE__*/function (_Component) {
710
749
  } // 重置滚动条
711
750
 
712
751
 
713
- _this6.api.setRowData([]);
752
+ var bean = _this6.api.__getContext().getBean('ctrlsService');
753
+
754
+ bean.getGridBodyCtrl().getScrollFeature().scrollToTop();
714
755
 
715
756
  _this6.api.setPinnedBottomRowData(pinned);
716
757
 
@@ -720,7 +761,9 @@ var DataGrid = /*#__PURE__*/function (_Component) {
720
761
  onLoad(res.extra);
721
762
  }
722
763
  }).catch(function () {
723
- _this6.api.hideOverlay();
764
+ _this6.setState({
765
+ loading: false
766
+ });
724
767
  });
725
768
  }
726
769
  }
@@ -921,6 +964,11 @@ var DataGrid = /*#__PURE__*/function (_Component) {
921
964
  value: function refresh() {
922
965
  this.getDataFromServer();
923
966
  }
967
+ }, {
968
+ key: "ready",
969
+ value: function ready() {
970
+ return this.isReady;
971
+ }
924
972
  }, {
925
973
  key: "render",
926
974
  value: function render() {
@@ -936,6 +984,7 @@ var DataGrid = /*#__PURE__*/function (_Component) {
936
984
  context = _this$props6.context,
937
985
  onGridReady = _this$props6.onGridReady,
938
986
  pagination = _this$props6.pagination,
987
+ columnTypesProp = _this$props6.columnTypes,
939
988
  defaultColDefProp = _this$props6.defaultColDef,
940
989
  restProps = _objectWithoutProperties(_this$props6, _excluded4);
941
990
 
@@ -944,7 +993,8 @@ var DataGrid = /*#__PURE__*/function (_Component) {
944
993
  enablePagination = _this$state2.pagination,
945
994
  page = _this$state2.page,
946
995
  pageSize = _this$state2.pageSize,
947
- total = _this$state2.total;
996
+ total = _this$state2.total,
997
+ loading = _this$state2.loading;
948
998
  var mPage = _typeof(pagination) === 'object' ? pagination : {};
949
999
  return /*#__PURE__*/React.createElement(GridContext.Provider, {
950
1000
  value: this.store
@@ -956,6 +1006,7 @@ var DataGrid = /*#__PURE__*/function (_Component) {
956
1006
  }, /*#__PURE__*/React.createElement(AgGridReact, _extends({
957
1007
  singleClickEdit: true,
958
1008
  suppressPaginationPanel: true,
1009
+ suppressCopyRowsToClipboard: true,
959
1010
  onCellValueChanged: this.cellValueChanged,
960
1011
  onCellEditingStopped: this.cellEditingStop,
961
1012
  loadingOverlayComponent: this.LoadingOverlay,
@@ -974,6 +1025,7 @@ var DataGrid = /*#__PURE__*/function (_Component) {
974
1025
  context: context,
975
1026
  rowSelection: rowSelection !== undefined ? rowSelection.type !== 'radio' ? 'multiple' : 'single' : undefined,
976
1027
  defaultColDef: _objectSpread(_objectSpread({}, defaultColDef), defaultColDefProp),
1028
+ columnTypes: _objectSpread(_objectSpread({}, columnTypes), columnTypesProp),
977
1029
  pinnedBottomRowData: Array.isArray(summary) ? summary : summary ? [summary] : undefined
978
1030
  })), /*#__PURE__*/React.createElement("div", {
979
1031
  className: prefix('bottom')
@@ -999,7 +1051,9 @@ var DataGrid = /*#__PURE__*/function (_Component) {
999
1051
  mPage.onChange(page, pageSize);
1000
1052
  }
1001
1053
  }
1002
- })))));
1054
+ }))), loading && /*#__PURE__*/React.createElement(Spin, {
1055
+ className: prefix('spin')
1056
+ })));
1003
1057
  }
1004
1058
  }]);
1005
1059
 
@@ -1008,7 +1062,6 @@ var DataGrid = /*#__PURE__*/function (_Component) {
1008
1062
 
1009
1063
  _defineProperty(DataGrid, "defaultProps", {
1010
1064
  autoLoad: false,
1011
- columnTypes: columnTypes,
1012
1065
  localeText: {
1013
1066
  copy: '复制',
1014
1067
  copyWithHeaders: '复制(带表头)',
@@ -1026,7 +1079,10 @@ _defineProperty(DataGrid, "defaultProps", {
1026
1079
  noPin: '不固定',
1027
1080
  expandAll: '展开所有',
1028
1081
  collapseAll: '折叠所有'
1029
- }
1082
+ },
1083
+ columnTypes: {},
1084
+ defaultColDef: {},
1085
+ loading: false
1030
1086
  });
1031
1087
 
1032
1088
  _defineProperty(DataGrid, "EmptyCol", {
@@ -151,7 +151,7 @@
151
151
 
152
152
  .ag-cell-inline-editing & {
153
153
  padding: 0;
154
- box-shadow: 0 0 0 2px var(--ant-primary-5) inset;
154
+ box-shadow: 0 0 0 2px ~'var(--@{ant-prefix}-primary-5)' inset;
155
155
  }
156
156
 
157
157
  &-text {
@@ -181,7 +181,7 @@
181
181
  left: -6px;
182
182
  z-index: 10;
183
183
  border: 6px solid transparent;
184
- border-top-color: var(--ant-error-color-active);
184
+ border-top-color: ~'var(--@{ant-prefix}-error-color-active)';
185
185
  transform: rotate(135deg);
186
186
  }
187
187
 
@@ -196,6 +196,18 @@
196
196
  vertical-align: top;
197
197
  }
198
198
  }
199
+
200
+ &-spin {
201
+ position: absolute;
202
+ top: 0;
203
+ right: 0;
204
+ bottom: 0;
205
+ left: 0;
206
+ display: flex;
207
+ justify-content: center;
208
+ align-items: center;
209
+ background-color: rgba(255, 255, 255, 0.6);
210
+ }
199
211
  }
200
212
 
201
213
  .ag-theme-@{prefixCls} {
@@ -217,13 +229,13 @@
217
229
  --ag-header-column-resize-handle-color: #bbb;
218
230
  --ag-cell-horizontal-padding: 8px;
219
231
  --ag-icon-font-family: agGridAlpine;
220
- --ag-selected-row-background-color: var(--ant-primary-1);
232
+ --ag-selected-row-background-color: ~'var(--@{ant-prefix}-primary-1)';
221
233
  --ag-selected-tab-underline-width: 2px;
222
- --ag-range-selection-border-color: var(--ant-primary-5);
223
- --ag-range-selection-highlight-color: var(--ant-primary-1);
234
+ --ag-range-selection-border-color: ~'var(--@{ant-prefix}-primary-5)';
235
+ --ag-range-selection-highlight-color: ~'var(--@{ant-prefix}-primary-1)';
224
236
  --ag-checkbox-unchecked-color: #ccc;
225
237
  --ag-checkbox-background-color: var(--ag-background-color);
226
- --ag-checkbox-checked-color: var(--ant-primary-color);
238
+ --ag-checkbox-checked-color: ~'var(--@{ant-prefix}-primary-color)';
227
239
  --ag-input-border-color: transparent;
228
240
  --ag-input-focus-border-color: transparent;
229
241
 
@@ -263,7 +275,7 @@
263
275
  bottom: 0;
264
276
  left: 0;
265
277
  display: block;
266
- border: 2px solid var(--ant-primary-5);
278
+ border: 2px solid ~'var(--@{ant-prefix}-primary-5)';
267
279
  border-radius: 4px;
268
280
  content: '';
269
281
  pointer-events: none;
@@ -291,7 +303,7 @@
291
303
  }
292
304
 
293
305
  .ag-tab-selected {
294
- color: var(--ant-primary-color);
306
+ color: ~'var(--@{ant-prefix}-primary-color)';
295
307
  }
296
308
 
297
309
  .ag-tabs-header {
@@ -2,6 +2,7 @@ import type { AgGridReactProps } from '@ag-grid-community/react';
2
2
  import type { ColDef, ColGroupDef, ICellRendererParams, IHeaderParams } from '@ag-grid-community/core';
3
3
  import type { RuleItem } from 'async-validator/dist-types/interface';
4
4
  import type { ReactElement, ReactNode, RefObject } from 'react';
5
+ export type { ColDef, ColGroupDef, ColumnState } from '@ag-grid-community/core';
5
6
  export declare type GetRowKey<T> = string | ((data: T) => string);
6
7
  export declare type PathType = string | (string | number)[];
7
8
  export declare type ValidateRule<T> = Pick<RuleItem, 'required' | 'message' | 'pattern' | 'min' | 'max' | 'len' | 'type'> & {
@@ -135,4 +136,8 @@ export interface DataGridProps<TData> extends Omit<AgGridReactProps<TData>, 'row
135
136
  * @description 行操作按钮组
136
137
  */
137
138
  rowActions?: RowActionsType<TData>;
139
+ /**
140
+ * @description 加载动画
141
+ */
142
+ loading: boolean;
138
143
  }
@@ -24,6 +24,7 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.definePrope
24
24
 
25
25
  import { Subject } from '@lemon-fe/utils';
26
26
  import { get as _get, set as _set } from 'lodash';
27
+ import moment from 'moment';
27
28
  import { prefixClassName } from "../utils";
28
29
  export var prefix = prefixClassName('grid');
29
30
  export function isColumnType(col) {
@@ -215,14 +216,23 @@ export var columnTypes = {
215
216
  width: 150
216
217
  },
217
218
  date: {
218
- width: 90
219
+ width: 120,
220
+ valueFormatter: function valueFormatter(_ref) {
221
+ var value = _ref.value;
222
+
223
+ if (typeof value === 'string') {
224
+ return moment(value).format('YYYY-MM-DD');
225
+ }
226
+
227
+ return value;
228
+ }
219
229
  },
220
230
  currency: {
221
231
  headerClass: 'ag-right-aligned-header',
222
232
  cellClass: 'ag-right-aligned-cell',
223
233
  width: 120,
224
- valueFormatter: function valueFormatter(_ref) {
225
- var value = _ref.value;
234
+ valueFormatter: function valueFormatter(_ref2) {
235
+ var value = _ref2.value;
226
236
 
227
237
  if (typeof value === 'number') {
228
238
  return value.toLocaleString('en-US', {
@@ -234,7 +244,7 @@ export var columnTypes = {
234
244
  return value;
235
245
  }
236
246
  },
237
- numeric: {
247
+ number: {
238
248
  headerClass: 'ag-right-aligned-header',
239
249
  cellClass: 'ag-right-aligned-cell',
240
250
  width: 120
@@ -28,6 +28,7 @@ declare namespace Layout {
28
28
  children?: React.ReactNode;
29
29
  left?: React.ReactNode;
30
30
  tab?: string | undefined;
31
+ forceRender?: boolean | undefined;
31
32
  } & Pick<Props, "onCollapse">) => JSX.Element;
32
33
  }
33
34
  export default Layout;
@@ -156,7 +156,8 @@ function LayoutTabs(props) {
156
156
  var tab = tabs[index];
157
157
  return /*#__PURE__*/React.createElement(Tabs.TabPane, {
158
158
  tab: (_get = get(node, ['props', 'tab'])) !== null && _get !== void 0 ? _get : tab.title,
159
- key: (_get2 = get(node, 'key')) !== null && _get2 !== void 0 ? _get2 : getKey(tab)
159
+ key: (_get2 = get(node, 'key')) !== null && _get2 !== void 0 ? _get2 : getKey(tab),
160
+ forceRender: get(node, ['props', 'forceRender'])
160
161
  }, node);
161
162
  });
162
163
  return /*#__PURE__*/React.createElement(Layout, _extends({
@@ -1,6 +1,6 @@
1
1
  import { ReactElement } from 'react';
2
2
  import type { ModalProps } from 'antd/lib/modal';
3
- export interface PopupProps<ValueType> extends ModalProps {
3
+ export interface PopupProps<ValueType> extends Omit<ModalProps, 'children'> {
4
4
  value?: ValueType;
5
5
  onChange?: (value?: ValueType) => void;
6
6
  /**
@@ -12,7 +12,9 @@ export interface PopupProps<ValueType> extends ModalProps {
12
12
  }) => ReactElement | null;
13
13
  formatLabel?: (value: ValueType) => string;
14
14
  beforeOk?: (value: ValueType) => ValueType | PromiseLike<ValueType>;
15
- /** 确认事件之前校验 */
15
+ /**
16
+ * @description 确认事件之前校验
17
+ */
16
18
  beforeOkCheck?: (value?: ValueType) => boolean | PromiseLike<boolean>;
17
19
  children?: JSX.Element | ((props: {
18
20
  value?: ValueType;
@@ -30,9 +32,10 @@ export interface PopupProps<ValueType> extends ModalProps {
30
32
  */
31
33
  emptyValue?: ValueType;
32
34
  }
33
- interface ValuedPopupProps<ValueType> extends Omit<PopupProps<ValueType>, 'onChange' | 'emptyValue'> {
35
+ interface ValuedPopupProps<ValueType> extends Omit<PopupProps<ValueType>, 'onChange' | 'emptyValue' | 'beforeOkCheck'> {
34
36
  onChange?: (value: ValueType) => void;
35
37
  emptyValue: ValueType;
38
+ beforeOkCheck?: (value: ValueType) => boolean | PromiseLike<boolean>;
36
39
  }
37
40
  declare function Popup<ValueType>(props: ValuedPopupProps<ValueType>): JSX.Element;
38
41
  declare function Popup<ValueType>(props: PopupProps<ValueType>): JSX.Element;
@@ -169,7 +169,7 @@ function Popup(props) {
169
169
  }
170
170
  };
171
171
 
172
- var label = valueProp ? formatLabel ? formatLabel(valueProp) : valueProp : undefined;
172
+ var label = valueProp ? formatLabel ? formatLabel(valueProp) : valueProp : null;
173
173
  var trigger;
174
174
 
175
175
  if (typeof children === 'function') {
@@ -32,6 +32,7 @@ interface Props extends Pick<TabsProps, 'activeKey' | 'onTabClick'> {
32
32
  tabs?: {
33
33
  title?: string;
34
34
  key: string;
35
+ forceRender?: boolean;
35
36
  }[];
36
37
  /**
37
38
  * @description body元素的样式
@@ -66,12 +66,14 @@ export default function Section(props) {
66
66
  }, mapChildren(children, function (child, index) {
67
67
  var _tabs$index = tabs[index],
68
68
  tab = _tabs$index.title,
69
- key = _tabs$index.key;
69
+ key = _tabs$index.key,
70
+ forceRender = _tabs$index.forceRender;
70
71
  return /*#__PURE__*/React.createElement(Tabs.TabPane, {
71
72
  tab: tab,
72
73
  key: key,
73
74
  className: "".concat(prefixCls, "-body"),
74
- style: bodyStyle
75
+ style: bodyStyle,
76
+ forceRender: true
75
77
  }, child);
76
78
  })) : /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(TabBar, {
77
79
  activeKey: activeKey,
@@ -31,6 +31,10 @@ interface Props<RecordType, ParamsType extends Record<string, any>> {
31
31
  * @description 数据源
32
32
  */
33
33
  dataSource?: RecordType[];
34
+ /**
35
+ * @description 用来对本地数据进行筛选
36
+ */
37
+ rowFilter?: (row: RecordType, params: ParamsType) => boolean;
34
38
  rowKey: string | ((item: RecordType) => string);
35
39
  /**
36
40
  * @description 筛选器设置
@@ -33,6 +33,7 @@ import Filter from "../Filter";
33
33
  import DataGrid from "../DataGrid";
34
34
  import { PREFIX_CLS } from "../../constants";
35
35
  import { DeleteTwoTone } from '@ant-design/icons';
36
+ var defaultRows = [];
36
37
  export default function SelectView(props) {
37
38
  var emptyValue = useMemo(function () {
38
39
  return [];
@@ -47,7 +48,8 @@ export default function SelectView(props) {
47
48
  multiple = _props$multiple === void 0 ? true : _props$multiple,
48
49
  rowKey = props.rowKey,
49
50
  filter = props.filter,
50
- dataSource = props.dataSource;
51
+ dataSource = props.dataSource,
52
+ rowFilter = props.rowFilter;
51
53
  var prefixCls = "".concat(PREFIX_CLS, "-select-view");
52
54
 
53
55
  var _useState = useState(value || emptyValue),
@@ -67,21 +69,41 @@ export default function SelectView(props) {
67
69
  tabFlag = _useState6[0],
68
70
  setTabFlag = _useState6[1];
69
71
 
70
- useEffect(function () {
71
- var _list$current;
72
+ var _useState7 = useState(dataSource),
73
+ _useState8 = _slicedToArray(_useState7, 2),
74
+ rows = _useState8[0],
75
+ setRows = _useState8[1];
72
76
 
73
- (_list$current = list.current) === null || _list$current === void 0 ? void 0 : _list$current.fetch();
77
+ useEffect(function () {
78
+ setRows(dataSource);
79
+ }, [dataSource]);
80
+ useEffect(function () {
81
+ if (list.current !== null) {
82
+ if (dataSource !== undefined && rowFilter !== undefined) {
83
+ setRows(dataSource.filter(function (row) {
84
+ return rowFilter(row, params);
85
+ }));
86
+
87
+ if (list.current.ready()) {
88
+ list.current.api.paginationGoToFirstPage();
89
+ }
90
+ } else if (request !== undefined) {
91
+ list.current.fetch();
92
+ }
93
+ }
74
94
  }, [params]);
75
95
  useEffect(function () {
76
96
  setData(value || emptyValue);
77
97
  }, [value]);
78
98
 
79
99
  var getRowKey = function getRowKey(item) {
100
+ var _get;
101
+
80
102
  if (typeof rowKey === 'function') {
81
103
  return rowKey(item);
82
104
  }
83
105
 
84
- return get(item, rowKey);
106
+ return String((_get = get(item, rowKey)) !== null && _get !== void 0 ? _get : '').toString();
85
107
  };
86
108
 
87
109
  var request = fetch ? function (_ref) {
@@ -172,7 +194,7 @@ export default function SelectView(props) {
172
194
  return handleChangeData(keys, rows);
173
195
  }
174
196
  },
175
- dataSource: dataSource,
197
+ dataSource: rows,
176
198
  columns: columns,
177
199
  fetch: request,
178
200
  pagination: true
package/es/index.d.ts CHANGED
@@ -1,4 +1,7 @@
1
1
  export * from 'antd';
2
+ export * from '@lemon-fe/hooks';
3
+ export * from '@lemon-fe/utils';
4
+ export { default as zhCN } from 'antd/es/locale/zh_CN';
2
5
  export * from './constants';
3
6
  export { default as init } from './init';
4
7
  export { default as BaseTable } from './components/BaseTable';
package/es/index.js CHANGED
@@ -1,4 +1,7 @@
1
1
  export * from 'antd';
2
+ export * from '@lemon-fe/hooks';
3
+ export * from '@lemon-fe/utils';
4
+ export { default as zhCN } from 'antd/es/locale/zh_CN';
2
5
  export * from "./constants";
3
6
  export { default as init } from "./init";
4
7
  export { default as BaseTable } from "./components/BaseTable";
package/package.json CHANGED
@@ -1,17 +1,17 @@
1
1
  {
2
2
  "name": "@lemon-fe/kits",
3
- "version": "1.0.0-1",
3
+ "version": "1.0.0-11",
4
4
  "scripts": {
5
5
  "start": "dumi dev",
6
6
  "docs:build": "dumi build",
7
- "docs:deploy": "scp -r kits-docs dev@47.111.99.207:/opt/app/",
7
+ "docs:deploy": "scp -r kits-docs-next dev@47.111.99.207:/opt/app/",
8
8
  "build": "father build",
9
9
  "deploy": "npm run docs:build && npm run docs:deploy",
10
10
  "prettier": "prettier --write \"**/*.{js,jsx,tsx,ts,less,md,json}\"",
11
11
  "test": "umi-test",
12
12
  "test:coverage": "umi-test --coverage",
13
13
  "prepublishOnly": "npm run build",
14
- "prepare": "husky install"
14
+ "prerelease": "npm version prerelease --no-git-tag-version && npm publish --tag next"
15
15
  },
16
16
  "files": [
17
17
  "es"
@@ -22,9 +22,6 @@
22
22
  "module": "es/index.js",
23
23
  "typings": "es/index.d.ts",
24
24
  "main": "es/index.js",
25
- "gitHooks": {
26
- "pre-commit": "lint-staged"
27
- },
28
25
  "lint-staged": {
29
26
  "*.{js,jsx,less,md,json}": [
30
27
  "prettier --write"
@@ -54,12 +51,12 @@
54
51
  "react-color": "^2.19.3",
55
52
  "react-gcolor-picker": "^1.2.4",
56
53
  "react-resizable": "^3.0.4",
54
+ "react-router": "^5.0.0",
55
+ "react-router-dom": "^5.0.0",
57
56
  "shallowequal": "^1.1.0"
58
57
  },
59
58
  "peerDependencies": {
60
- "react": ">=16.8",
61
- "react-router": "5.x",
62
- "react-router-dom": "5.x"
59
+ "react": ">=16.8"
63
60
  },
64
61
  "devDependencies": {
65
62
  "@testing-library/jest-dom": "^5.15.1",
@@ -82,8 +79,6 @@
82
79
  "lint-staged": "^10.0.7",
83
80
  "prettier": "^2.2.1",
84
81
  "react": "^18.2.0",
85
- "react-dom": "^18.2.0",
86
- "react-router": "^5.0.0",
87
- "react-router-dom": "^5.0.0"
82
+ "react-dom": "^18.2.0"
88
83
  }
89
84
  }