@lemon-fe/components 1.2.7 → 1.2.9-alpha.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.
- package/es/data-grid/hooks.js +3 -8
- package/es/data-grid/index.d.ts +3 -0
- package/es/data-grid/index.js +311 -312
- package/es/data-grid/utils.js +2 -1
- package/es/sider-tree/index.js +15 -18
- package/package.json +2 -2
package/es/data-grid/hooks.js
CHANGED
|
@@ -50,16 +50,11 @@ export function useDataGrid() {
|
|
|
50
50
|
}
|
|
51
51
|
if (ref.current !== null) {
|
|
52
52
|
var grid = ref.current;
|
|
53
|
-
|
|
53
|
+
grid.afterReady(function () {
|
|
54
54
|
if (mounted.current) {
|
|
55
|
-
|
|
56
|
-
cb(grid);
|
|
57
|
-
} else {
|
|
58
|
-
requestAnimationFrame(delay);
|
|
59
|
-
}
|
|
55
|
+
cb(grid);
|
|
60
56
|
}
|
|
61
|
-
};
|
|
62
|
-
delay();
|
|
57
|
+
});
|
|
63
58
|
}
|
|
64
59
|
};
|
|
65
60
|
return useMemo(function () {
|
package/es/data-grid/index.d.ts
CHANGED
|
@@ -45,6 +45,7 @@ declare class InternalDataGrid<TData extends Record<string, any>> extends Compon
|
|
|
45
45
|
private prevFocusedCell;
|
|
46
46
|
private fields;
|
|
47
47
|
private fieldSuffix;
|
|
48
|
+
private customColumnData;
|
|
48
49
|
constructor(props: InternaleDataGridProps<TData>);
|
|
49
50
|
setField(field: FieldCol): void;
|
|
50
51
|
getField(id: string): FieldCol | undefined;
|
|
@@ -69,6 +70,8 @@ declare class InternalDataGrid<TData extends Record<string, any>> extends Compon
|
|
|
69
70
|
private isPreserveSelected;
|
|
70
71
|
private updateRowData;
|
|
71
72
|
private getSummaryRowData;
|
|
73
|
+
private loadingTiming;
|
|
74
|
+
private loadingChange;
|
|
72
75
|
private getDataFromServer;
|
|
73
76
|
private pagination;
|
|
74
77
|
private init;
|
package/es/data-grid/index.js
CHANGED
|
@@ -161,6 +161,7 @@ var InternalDataGrid = /*#__PURE__*/function (_Component) {
|
|
|
161
161
|
_inherits(InternalDataGrid, _Component);
|
|
162
162
|
var _super = _createSuper(InternalDataGrid);
|
|
163
163
|
function InternalDataGrid(props) {
|
|
164
|
+
var _props$customColumnPa, _props$customColumnPa2;
|
|
164
165
|
var _this;
|
|
165
166
|
_classCallCheck(this, InternalDataGrid);
|
|
166
167
|
_this = _super.call(this, props);
|
|
@@ -191,6 +192,7 @@ var InternalDataGrid = /*#__PURE__*/function (_Component) {
|
|
|
191
192
|
_defineProperty(_assertThisInitialized(_this), "prevFocusedCell", null);
|
|
192
193
|
_defineProperty(_assertThisInitialized(_this), "fields", []);
|
|
193
194
|
_defineProperty(_assertThisInitialized(_this), "fieldSuffix", /(%)$/);
|
|
195
|
+
_defineProperty(_assertThisInitialized(_this), "customColumnData", null);
|
|
194
196
|
_defineProperty(_assertThisInitialized(_this), "getFieldsSummary", memoizeOne(function (dataSource, fields) {
|
|
195
197
|
var summaryField = fields.filter(function (field) {
|
|
196
198
|
return field.summary;
|
|
@@ -238,21 +240,46 @@ var InternalDataGrid = /*#__PURE__*/function (_Component) {
|
|
|
238
240
|
});
|
|
239
241
|
return summary;
|
|
240
242
|
}));
|
|
243
|
+
_defineProperty(_assertThisInitialized(_this), "loadingTiming", null);
|
|
241
244
|
_defineProperty(_assertThisInitialized(_this), "init", /*#__PURE__*/function () {
|
|
242
245
|
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(args) {
|
|
243
|
-
var api, columnApi, onGridReady;
|
|
246
|
+
var api, columnApi, _this$props, onGridReady, autoLoad, customColumnData, state, data;
|
|
244
247
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
245
248
|
while (1) switch (_context.prev = _context.next) {
|
|
246
249
|
case 0:
|
|
247
250
|
api = args.api, columnApi = args.columnApi;
|
|
248
251
|
_this.api = api;
|
|
249
252
|
_this.columnApi = columnApi;
|
|
250
|
-
_this.
|
|
251
|
-
_this.clearReadyQueue();
|
|
252
|
-
onGridReady = _this.props.onGridReady;
|
|
253
|
+
_this$props = _this.props, onGridReady = _this$props.onGridReady, autoLoad = _this$props.autoLoad;
|
|
253
254
|
if (onGridReady !== undefined) {
|
|
254
255
|
onGridReady(args);
|
|
255
256
|
}
|
|
257
|
+
_context.next = 7;
|
|
258
|
+
return _this.customColumnData;
|
|
259
|
+
case 7:
|
|
260
|
+
customColumnData = _context.sent;
|
|
261
|
+
if (customColumnData) {
|
|
262
|
+
try {
|
|
263
|
+
data = customColumnData;
|
|
264
|
+
if (data) {
|
|
265
|
+
_this.fields = data.fields;
|
|
266
|
+
state = data.columState;
|
|
267
|
+
}
|
|
268
|
+
} catch (err) {
|
|
269
|
+
console.log('获取列定制失败', err.message);
|
|
270
|
+
}
|
|
271
|
+
_this.updateColumnDefs(state, true);
|
|
272
|
+
} else {
|
|
273
|
+
_this.updateColumnDefs();
|
|
274
|
+
}
|
|
275
|
+
_this.isReady = true;
|
|
276
|
+
_this.syncColRender();
|
|
277
|
+
_this.syncSelection();
|
|
278
|
+
if (_this.isClientMode()) {
|
|
279
|
+
_this.syncRowData();
|
|
280
|
+
} else if (autoLoad) {
|
|
281
|
+
_this.getDataFromServer();
|
|
282
|
+
}
|
|
256
283
|
api.addEventListener('sortChanged', function () {
|
|
257
284
|
if (!_this.isClientMode()) {
|
|
258
285
|
_this.getDataFromServer();
|
|
@@ -292,7 +319,8 @@ var InternalDataGrid = /*#__PURE__*/function (_Component) {
|
|
|
292
319
|
});
|
|
293
320
|
}
|
|
294
321
|
});
|
|
295
|
-
|
|
322
|
+
_this.clearReadyQueue();
|
|
323
|
+
case 18:
|
|
296
324
|
case "end":
|
|
297
325
|
return _context.stop();
|
|
298
326
|
}
|
|
@@ -313,9 +341,9 @@ var InternalDataGrid = /*#__PURE__*/function (_Component) {
|
|
|
313
341
|
return String(result !== null && result !== void 0 ? result : '').toString();
|
|
314
342
|
});
|
|
315
343
|
_defineProperty(_assertThisInitialized(_this), "cellValueChanged", function (evt) {
|
|
316
|
-
var _this$
|
|
317
|
-
onDataSourceChange = _this$
|
|
318
|
-
onCellValueChanged = _this$
|
|
344
|
+
var _this$props2 = _this.props,
|
|
345
|
+
onDataSourceChange = _this$props2.onDataSourceChange,
|
|
346
|
+
onCellValueChanged = _this$props2.onCellValueChanged;
|
|
319
347
|
if (onCellValueChanged) {
|
|
320
348
|
onCellValueChanged(evt);
|
|
321
349
|
}
|
|
@@ -333,9 +361,9 @@ var InternalDataGrid = /*#__PURE__*/function (_Component) {
|
|
|
333
361
|
if (!_this.isReady) {
|
|
334
362
|
return;
|
|
335
363
|
}
|
|
336
|
-
var _this$
|
|
337
|
-
onDataSourceChange = _this$
|
|
338
|
-
onRowDataUpdated = _this$
|
|
364
|
+
var _this$props3 = _this.props,
|
|
365
|
+
onDataSourceChange = _this$props3.onDataSourceChange,
|
|
366
|
+
onRowDataUpdated = _this$props3.onRowDataUpdated;
|
|
339
367
|
var data = [];
|
|
340
368
|
if (onRowDataUpdated !== undefined) {
|
|
341
369
|
onRowDataUpdated(evt);
|
|
@@ -478,12 +506,8 @@ var InternalDataGrid = /*#__PURE__*/function (_Component) {
|
|
|
478
506
|
context: props.context,
|
|
479
507
|
grid: _assertThisInitialized(_this)
|
|
480
508
|
});
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
_props$rowSelection2$ = _props$rowSelection2.selectedRowKeys,
|
|
484
|
-
selectedRowKeys = _props$rowSelection2$ === void 0 ? [] : _props$rowSelection2$;
|
|
485
|
-
_this.selected = new Selection(selectedRowKeys);
|
|
486
|
-
_this.syncColRender();
|
|
509
|
+
_this.selected = new Selection([]);
|
|
510
|
+
_this.customColumnData = ((_props$customColumnPa = props.customColumnPanelStorage) === null || _props$customColumnPa === void 0 || (_props$customColumnPa2 = _props$customColumnPa.get) === null || _props$customColumnPa2 === void 0 ? void 0 : _props$customColumnPa2.call(_props$customColumnPa)) || null;
|
|
487
511
|
return _this;
|
|
488
512
|
}
|
|
489
513
|
_createClass(InternalDataGrid, [{
|
|
@@ -566,9 +590,9 @@ var InternalDataGrid = /*#__PURE__*/function (_Component) {
|
|
|
566
590
|
}, {
|
|
567
591
|
key: "getPagination",
|
|
568
592
|
value: function getPagination() {
|
|
569
|
-
var _this$
|
|
570
|
-
pagination = _this$
|
|
571
|
-
fetch = _this$
|
|
593
|
+
var _this$props4 = this.props,
|
|
594
|
+
pagination = _this$props4.pagination,
|
|
595
|
+
fetch = _this$props4.fetch;
|
|
572
596
|
var page = 1;
|
|
573
597
|
var pageSize = 50;
|
|
574
598
|
var total = 0;
|
|
@@ -597,25 +621,30 @@ var InternalDataGrid = /*#__PURE__*/function (_Component) {
|
|
|
597
621
|
}, {
|
|
598
622
|
key: "componentDidUpdate",
|
|
599
623
|
value: function componentDidUpdate(prevProps) {
|
|
600
|
-
var
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
624
|
+
var _prevProps$rowSelecti;
|
|
625
|
+
var _this$props5 = this.props,
|
|
626
|
+
columns = _this$props5.columns,
|
|
627
|
+
rowSelection = _this$props5.rowSelection,
|
|
628
|
+
dataSource = _this$props5.dataSource,
|
|
629
|
+
context = _this$props5.context;
|
|
630
|
+
if (!shallowEqual(context, prevProps.context)) {
|
|
631
|
+
this.store.setState({
|
|
632
|
+
context: context
|
|
633
|
+
});
|
|
634
|
+
}
|
|
635
|
+
if (!this.isReady) {
|
|
636
|
+
return;
|
|
637
|
+
}
|
|
607
638
|
if (columns !== prevProps.columns) {
|
|
608
639
|
this.syncColRender();
|
|
609
|
-
this.
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
}
|
|
618
|
-
});
|
|
640
|
+
this.updateColumnDefs(this.columnApi.getColumnState());
|
|
641
|
+
if (this.fields.length > 0) {
|
|
642
|
+
this.api.refreshCells({
|
|
643
|
+
columns: this.fields.map(function (item) {
|
|
644
|
+
return item.id;
|
|
645
|
+
})
|
|
646
|
+
});
|
|
647
|
+
}
|
|
619
648
|
}
|
|
620
649
|
if ((rowSelection === null || rowSelection === void 0 ? void 0 : rowSelection.selectedRowKeys) !== ((_prevProps$rowSelecti = prevProps.rowSelection) === null || _prevProps$rowSelecti === void 0 ? void 0 : _prevProps$rowSelecti.selectedRowKeys)) {
|
|
621
650
|
this.syncSelection();
|
|
@@ -623,11 +652,6 @@ var InternalDataGrid = /*#__PURE__*/function (_Component) {
|
|
|
623
652
|
if (dataSource !== prevProps.dataSource) {
|
|
624
653
|
this.syncRowData();
|
|
625
654
|
}
|
|
626
|
-
if (!shallowEqual(context, prevProps.context)) {
|
|
627
|
-
this.store.setState({
|
|
628
|
-
context: context
|
|
629
|
-
});
|
|
630
|
-
}
|
|
631
655
|
}
|
|
632
656
|
}, {
|
|
633
657
|
key: "componentWillUnmount",
|
|
@@ -639,50 +663,22 @@ var InternalDataGrid = /*#__PURE__*/function (_Component) {
|
|
|
639
663
|
key: "componentDidMount",
|
|
640
664
|
value: function () {
|
|
641
665
|
var _componentDidMount = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
|
|
642
|
-
var _this$props5, customColumnPanelStorage, autoLoad, state, data;
|
|
643
666
|
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
644
667
|
while (1) switch (_context3.prev = _context3.next) {
|
|
645
668
|
case 0:
|
|
646
669
|
window.addEventListener('blur', this.handleFocus);
|
|
670
|
+
this.loadingChange(true);
|
|
647
671
|
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
_context3.prev = 3;
|
|
655
|
-
_context3.next = 6;
|
|
656
|
-
return customColumnPanelStorage.get();
|
|
657
|
-
case 6:
|
|
658
|
-
data = _context3.sent;
|
|
659
|
-
if (data) {
|
|
660
|
-
this.fields = data.fields;
|
|
661
|
-
state = data.columState;
|
|
662
|
-
}
|
|
663
|
-
_context3.next = 13;
|
|
664
|
-
break;
|
|
665
|
-
case 10:
|
|
666
|
-
_context3.prev = 10;
|
|
667
|
-
_context3.t0 = _context3["catch"](3);
|
|
668
|
-
console.log('获取列定制失败', _context3.t0.message);
|
|
669
|
-
case 13:
|
|
670
|
-
this.updateColumnDefs(state, true);
|
|
671
|
-
_context3.next = 17;
|
|
672
|
-
break;
|
|
673
|
-
case 16:
|
|
674
|
-
this.updateColumnDefs();
|
|
675
|
-
case 17:
|
|
676
|
-
if (this.isClientMode()) {
|
|
677
|
-
this.syncRowData();
|
|
678
|
-
} else if (autoLoad) {
|
|
679
|
-
this.getDataFromServer();
|
|
680
|
-
}
|
|
681
|
-
case 18:
|
|
672
|
+
// 放在componentDidMount 执行时间比onGridReady早
|
|
673
|
+
_context3.next = 4;
|
|
674
|
+
return this.customColumnData;
|
|
675
|
+
case 4:
|
|
676
|
+
this.loadingChange(false);
|
|
677
|
+
case 5:
|
|
682
678
|
case "end":
|
|
683
679
|
return _context3.stop();
|
|
684
680
|
}
|
|
685
|
-
}, _callee3, this
|
|
681
|
+
}, _callee3, this);
|
|
686
682
|
}));
|
|
687
683
|
function componentDidMount() {
|
|
688
684
|
return _componentDidMount.apply(this, arguments);
|
|
@@ -736,34 +732,32 @@ var InternalDataGrid = /*#__PURE__*/function (_Component) {
|
|
|
736
732
|
}, {
|
|
737
733
|
key: "syncSelection",
|
|
738
734
|
value: function syncSelection() {
|
|
739
|
-
var
|
|
740
|
-
this.
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
}
|
|
766
|
-
});
|
|
735
|
+
var _this2 = this;
|
|
736
|
+
var _this$props$rowSelect = this.props.rowSelection,
|
|
737
|
+
_this$props$rowSelect2 = _this$props$rowSelect === void 0 ? {} : _this$props$rowSelect,
|
|
738
|
+
selectedRowKeys = _this$props$rowSelect2.selectedRowKeys;
|
|
739
|
+
if (selectedRowKeys !== undefined && !this.selected.isSameKeys(selectedRowKeys)) {
|
|
740
|
+
var newSelected = new Map();
|
|
741
|
+
this.selected.forEach(function (id) {
|
|
742
|
+
var node = _this2.api.getRowNode(id);
|
|
743
|
+
if (node !== undefined) {
|
|
744
|
+
node.setSelected(false, false, true);
|
|
745
|
+
}
|
|
746
|
+
});
|
|
747
|
+
selectedRowKeys.forEach(function (id) {
|
|
748
|
+
var node = _this2.api.getRowNode(id);
|
|
749
|
+
var data;
|
|
750
|
+
if (node !== undefined) {
|
|
751
|
+
node.setSelected(true, false, true);
|
|
752
|
+
data = node.data;
|
|
753
|
+
}
|
|
754
|
+
newSelected.set(id, data || _this2.selected.get(id) || null);
|
|
755
|
+
});
|
|
756
|
+
this.selected.clone(newSelected);
|
|
757
|
+
this.api.dispatchEvent({
|
|
758
|
+
type: 'selectionChanged'
|
|
759
|
+
});
|
|
760
|
+
}
|
|
767
761
|
}
|
|
768
762
|
}, {
|
|
769
763
|
key: "syncRowData",
|
|
@@ -776,48 +770,45 @@ var InternalDataGrid = /*#__PURE__*/function (_Component) {
|
|
|
776
770
|
}, {
|
|
777
771
|
key: "updateColumnDefs",
|
|
778
772
|
value: function updateColumnDefs(state) {
|
|
779
|
-
var _this4 = this;
|
|
780
773
|
var allState = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
781
|
-
this.
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
return item.colId === colId;
|
|
799
|
-
});
|
|
800
|
-
if (idx < 0) {
|
|
801
|
-
newState.splice(index, 0, {
|
|
802
|
-
colId: colId
|
|
803
|
-
});
|
|
804
|
-
}
|
|
774
|
+
var _this$getColumnDefs3 = this.getColumnDefs(),
|
|
775
|
+
_this$getColumnDefs4 = _slicedToArray(_this$getColumnDefs3, 2),
|
|
776
|
+
defs = _this$getColumnDefs4[0],
|
|
777
|
+
leafColIds = _this$getColumnDefs4[1];
|
|
778
|
+
this.api.setColumnDefs(defs);
|
|
779
|
+
if (state) {
|
|
780
|
+
/**
|
|
781
|
+
* 表格初始化列抖动问题:先调用setColumnDefs,后applyColumnState,会产生列移动动画,所以先禁用列移动的动画
|
|
782
|
+
*/
|
|
783
|
+
this.api.__setProperty('suppressColumnMoveAnimation', true);
|
|
784
|
+
var newState = _toConsumableArray(state);
|
|
785
|
+
leafColIds.forEach(function (colId, index) {
|
|
786
|
+
if (!colId) {
|
|
787
|
+
return;
|
|
788
|
+
}
|
|
789
|
+
var idx = state.findIndex(function (item) {
|
|
790
|
+
return item.colId === colId;
|
|
805
791
|
});
|
|
792
|
+
if (idx < 0) {
|
|
793
|
+
newState.splice(index, 0, {
|
|
794
|
+
colId: colId
|
|
795
|
+
});
|
|
796
|
+
}
|
|
797
|
+
});
|
|
806
798
|
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
});
|
|
799
|
+
/**
|
|
800
|
+
* 初始化的时候,需要使用存储的columnState,不仅仅是顺序,其他情况由于在defs里已经有列的状态控制了
|
|
801
|
+
*/
|
|
802
|
+
this.columnApi.applyColumnState({
|
|
803
|
+
state: allState ? newState : newState.map(function (item) {
|
|
804
|
+
return {
|
|
805
|
+
colId: item.colId
|
|
806
|
+
};
|
|
807
|
+
}),
|
|
808
|
+
applyOrder: true
|
|
809
|
+
});
|
|
810
|
+
this.api.__setProperty('suppressColumnMoveAnimation', !!this.props.suppressColumnMoveAnimation);
|
|
811
|
+
}
|
|
821
812
|
}
|
|
822
813
|
}, {
|
|
823
814
|
key: "getFullColumnDef",
|
|
@@ -848,7 +839,7 @@ var InternalDataGrid = /*#__PURE__*/function (_Component) {
|
|
|
848
839
|
}, {
|
|
849
840
|
key: "getColumnDefs",
|
|
850
841
|
value: function getColumnDefs() {
|
|
851
|
-
var
|
|
842
|
+
var _this3 = this,
|
|
852
843
|
_this$props$customCol;
|
|
853
844
|
var _this$props7 = this.props,
|
|
854
845
|
_this$props7$columns = _this$props7.columns,
|
|
@@ -874,7 +865,7 @@ var InternalDataGrid = /*#__PURE__*/function (_Component) {
|
|
|
874
865
|
if (field !== undefined) {
|
|
875
866
|
opts.field = getColField(item);
|
|
876
867
|
}
|
|
877
|
-
var def =
|
|
868
|
+
var def = _this3.getFullColumnDef(opts);
|
|
878
869
|
|
|
879
870
|
/** 部分列由于使用type 可能存在colId以及field都不存在, maintainColumnOrder下updateColumnDefs有问题,故从merge后的def中提取field或者colId */
|
|
880
871
|
opts.colId = def.colId || def.field;
|
|
@@ -1033,14 +1024,14 @@ var InternalDataGrid = /*#__PURE__*/function (_Component) {
|
|
|
1033
1024
|
if (suppressFieldValueGetter) {
|
|
1034
1025
|
fieldCol.field = field.id;
|
|
1035
1026
|
} else {
|
|
1036
|
-
var
|
|
1027
|
+
var _this3$fieldSuffix$ex;
|
|
1037
1028
|
/**
|
|
1038
1029
|
* 预校验是否可以进行四则运算,可能会有边界情况没考虑到
|
|
1039
1030
|
*/
|
|
1040
1031
|
var scopeMap = {};
|
|
1041
1032
|
var reg = /\$\{([^{}]+)\}/g;
|
|
1042
|
-
var expressionSuffix = ((
|
|
1043
|
-
var expression = field.expression.replace(
|
|
1033
|
+
var expressionSuffix = ((_this3$fieldSuffix$ex = _this3.fieldSuffix.exec(field.expression)) === null || _this3$fieldSuffix$ex === void 0 ? void 0 : _this3$fieldSuffix$ex[1]) || '';
|
|
1034
|
+
var expression = field.expression.replace(_this3.fieldSuffix, '').replace(reg, function (match, p1) {
|
|
1044
1035
|
if (p1) {
|
|
1045
1036
|
var mapKey = "a".concat(Object.keys(scopeMap).length);
|
|
1046
1037
|
scopeMap[mapKey] = p1;
|
|
@@ -1077,7 +1068,7 @@ var InternalDataGrid = /*#__PURE__*/function (_Component) {
|
|
|
1077
1068
|
if (isSummaryRow({
|
|
1078
1069
|
node: node
|
|
1079
1070
|
}) && field.summaryType === 1) {
|
|
1080
|
-
var summary =
|
|
1071
|
+
var summary = _this3.getFieldsSummary(_this3.dataSource, _this3.fields);
|
|
1081
1072
|
return get(summary, field.id);
|
|
1082
1073
|
}
|
|
1083
1074
|
var getValue = function getValue(colId) {
|
|
@@ -1110,7 +1101,7 @@ var InternalDataGrid = /*#__PURE__*/function (_Component) {
|
|
|
1110
1101
|
return null;
|
|
1111
1102
|
}
|
|
1112
1103
|
} else {
|
|
1113
|
-
return field.expression.replace(
|
|
1104
|
+
return field.expression.replace(_this3.fieldSuffix, '').replace(reg, function (match, p1) {
|
|
1114
1105
|
if (p1) {
|
|
1115
1106
|
return getValue(p1) || '';
|
|
1116
1107
|
}
|
|
@@ -1217,51 +1208,49 @@ var InternalDataGrid = /*#__PURE__*/function (_Component) {
|
|
|
1217
1208
|
}, {
|
|
1218
1209
|
key: "updateRowData",
|
|
1219
1210
|
value: function updateRowData() {
|
|
1220
|
-
var
|
|
1211
|
+
var _this4 = this;
|
|
1221
1212
|
var data = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
1222
|
-
this.
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1213
|
+
this.dataSource = data;
|
|
1214
|
+
this.api.setRowData(data);
|
|
1215
|
+
if (this.isPreserveSelected()) {
|
|
1216
|
+
this.api.forEachNode(function (node) {
|
|
1217
|
+
if (node.id && _this4.selected.has(node.id)) {
|
|
1218
|
+
var rowData = _this4.selected.get(node.id);
|
|
1219
|
+
if (node.data !== undefined && rowData !== node.data) {
|
|
1220
|
+
_this4.selected.set(node.id, node.data);
|
|
1221
|
+
}
|
|
1222
|
+
if (!node.isSelected()) {
|
|
1223
|
+
node.setSelected(true, false, true);
|
|
1224
|
+
}
|
|
1225
|
+
}
|
|
1226
|
+
});
|
|
1227
|
+
} else {
|
|
1228
|
+
var keys = new Map(data.map(function (item) {
|
|
1229
|
+
return [_this4.getRowId({
|
|
1230
|
+
data: item
|
|
1231
|
+
}), item];
|
|
1232
|
+
}));
|
|
1233
|
+
this.selected.forEach(function (id) {
|
|
1234
|
+
if (!keys.has(id)) {
|
|
1235
|
+
_this4.selected.delete(id);
|
|
1236
|
+
} else {
|
|
1237
|
+
var node = _this4.api.getRowNode(id);
|
|
1238
|
+
if (node !== undefined) {
|
|
1239
|
+
if (node.data !== undefined && _this4.selected.get(id) !== node.data) {
|
|
1240
|
+
_this4.selected.set(id, node.data);
|
|
1231
1241
|
}
|
|
1232
1242
|
if (!node.isSelected()) {
|
|
1233
1243
|
node.setSelected(true, false, true);
|
|
1234
1244
|
}
|
|
1235
1245
|
}
|
|
1236
|
-
}
|
|
1237
|
-
}
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
if (!keys.has(id)) {
|
|
1245
|
-
_this6.selected.delete(id);
|
|
1246
|
-
} else {
|
|
1247
|
-
var node = _this6.api.getRowNode(id);
|
|
1248
|
-
if (node !== undefined) {
|
|
1249
|
-
if (node.data !== undefined && _this6.selected.get(id) !== node.data) {
|
|
1250
|
-
_this6.selected.set(id, node.data);
|
|
1251
|
-
}
|
|
1252
|
-
if (!node.isSelected()) {
|
|
1253
|
-
node.setSelected(true, false, true);
|
|
1254
|
-
}
|
|
1255
|
-
}
|
|
1256
|
-
}
|
|
1257
|
-
});
|
|
1258
|
-
}
|
|
1259
|
-
if (_this6.selected.isDirty()) {
|
|
1260
|
-
_this6.api.dispatchEvent({
|
|
1261
|
-
type: 'selectionChanged'
|
|
1262
|
-
});
|
|
1263
|
-
}
|
|
1264
|
-
});
|
|
1246
|
+
}
|
|
1247
|
+
});
|
|
1248
|
+
}
|
|
1249
|
+
if (this.selected.isDirty()) {
|
|
1250
|
+
this.api.dispatchEvent({
|
|
1251
|
+
type: 'selectionChanged'
|
|
1252
|
+
});
|
|
1253
|
+
}
|
|
1265
1254
|
}
|
|
1266
1255
|
}, {
|
|
1267
1256
|
key: "getSummaryRowData",
|
|
@@ -1284,103 +1273,111 @@ var InternalDataGrid = /*#__PURE__*/function (_Component) {
|
|
|
1284
1273
|
return _objectSpread(_objectSpread({}, item), {}, _defineProperty({}, SummaryFlag, true));
|
|
1285
1274
|
});
|
|
1286
1275
|
}
|
|
1276
|
+
}, {
|
|
1277
|
+
key: "loadingChange",
|
|
1278
|
+
value: function loadingChange(flag) {
|
|
1279
|
+
var _this5 = this;
|
|
1280
|
+
if (this.loadingTiming) {
|
|
1281
|
+
clearTimeout(this.loadingTiming);
|
|
1282
|
+
this.loadingTiming = null;
|
|
1283
|
+
}
|
|
1284
|
+
this.loadingTiming = setTimeout(function () {
|
|
1285
|
+
var onLoading = _this5.props.onLoading;
|
|
1286
|
+
if (onLoading) {
|
|
1287
|
+
onLoading(flag);
|
|
1288
|
+
} else {
|
|
1289
|
+
_this5.setState({
|
|
1290
|
+
loading: flag
|
|
1291
|
+
});
|
|
1292
|
+
}
|
|
1293
|
+
_this5.loadingTiming = null;
|
|
1294
|
+
}, 16);
|
|
1295
|
+
}
|
|
1287
1296
|
}, {
|
|
1288
1297
|
key: "getDataFromServer",
|
|
1289
1298
|
value: function getDataFromServer() {
|
|
1290
|
-
var
|
|
1299
|
+
var _this6 = this;
|
|
1291
1300
|
var params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
1292
|
-
this.
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1301
|
+
var _this$props8 = this.props,
|
|
1302
|
+
fetch = _this$props8.fetch,
|
|
1303
|
+
onLoad = _this$props8.onLoad;
|
|
1304
|
+
if (typeof fetch === 'function') {
|
|
1305
|
+
if (this.requestId < Number.MAX_SAFE_INTEGER) {
|
|
1306
|
+
this.requestId += 1;
|
|
1307
|
+
}
|
|
1308
|
+
var _this$state2 = this.state,
|
|
1309
|
+
page = _this$state2.page,
|
|
1310
|
+
pageSize = _this$state2.pageSize;
|
|
1311
|
+
var columnState = this.columnApi.getColumnState();
|
|
1312
|
+
var id = this.requestId;
|
|
1313
|
+
this.loadingChange(true);
|
|
1314
|
+
fetch({
|
|
1315
|
+
current: page,
|
|
1316
|
+
pageSize: pageSize,
|
|
1317
|
+
sort: columnState.filter(function (item) {
|
|
1318
|
+
return item.sort !== undefined && item.sort !== null;
|
|
1319
|
+
}).map(function (item) {
|
|
1320
|
+
return {
|
|
1321
|
+
field: item.colId,
|
|
1322
|
+
order: item.sort
|
|
1323
|
+
};
|
|
1324
|
+
})
|
|
1325
|
+
}).then(function (res) {
|
|
1326
|
+
if (id !== _this6.requestId) {
|
|
1327
|
+
return;
|
|
1328
|
+
}
|
|
1329
|
+
_this6.loadingChange(false);
|
|
1330
|
+
if (res.total !== undefined) {
|
|
1331
|
+
_this6.setState({
|
|
1332
|
+
page: page,
|
|
1333
|
+
pageSize: pageSize,
|
|
1334
|
+
total: res.total
|
|
1303
1335
|
});
|
|
1304
1336
|
}
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1337
|
+
var summary = _this6.props.summary;
|
|
1338
|
+
_this6.updateRowData(res.data);
|
|
1339
|
+
_this6.api.setPinnedBottomRowData(_this6.getSummaryRowData(summary, res.summary));
|
|
1340
|
+
if (res.data.length > 0 && !params.refresh) {
|
|
1341
|
+
_this6.api.ensureIndexVisible(0);
|
|
1309
1342
|
}
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
}).map(function (item) {
|
|
1322
|
-
return {
|
|
1323
|
-
field: item.colId,
|
|
1324
|
-
order: item.sort
|
|
1325
|
-
};
|
|
1326
|
-
})
|
|
1327
|
-
}).then(function (res) {
|
|
1328
|
-
if (id !== _this7.requestId) {
|
|
1329
|
-
return;
|
|
1330
|
-
}
|
|
1331
|
-
loadingChange(false);
|
|
1332
|
-
if (res.total !== undefined) {
|
|
1333
|
-
_this7.setState({
|
|
1334
|
-
page: page,
|
|
1335
|
-
pageSize: pageSize,
|
|
1336
|
-
total: res.total
|
|
1337
|
-
});
|
|
1338
|
-
}
|
|
1339
|
-
var summary = _this7.props.summary;
|
|
1340
|
-
_this7.updateRowData(res.data);
|
|
1341
|
-
_this7.api.setPinnedBottomRowData(_this7.getSummaryRowData(summary, res.summary));
|
|
1342
|
-
if (res.data.length > 0 && !params.refresh) {
|
|
1343
|
-
_this7.api.ensureIndexVisible(0);
|
|
1344
|
-
}
|
|
1345
|
-
if (onLoad) {
|
|
1346
|
-
onLoad(res.extra);
|
|
1347
|
-
}
|
|
1348
|
-
_this7.store.setState({
|
|
1349
|
-
fetchError: undefined
|
|
1350
|
-
});
|
|
1351
|
-
}).catch(function (err) {
|
|
1352
|
-
_this7.store.setState({
|
|
1353
|
-
fetchError: err
|
|
1354
|
-
});
|
|
1355
|
-
loadingChange(false);
|
|
1343
|
+
if (onLoad) {
|
|
1344
|
+
onLoad(res.extra);
|
|
1345
|
+
}
|
|
1346
|
+
_this6.store.setState({
|
|
1347
|
+
fetchError: undefined
|
|
1348
|
+
});
|
|
1349
|
+
}).catch(function (err) {
|
|
1350
|
+
_this6.store.setState({
|
|
1351
|
+
fetchError: err
|
|
1352
|
+
});
|
|
1353
|
+
_this6.loadingChange(false);
|
|
1356
1354
|
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
});
|
|
1363
|
-
_this7.updateRowData([]);
|
|
1364
|
-
_this7.api.setPinnedBottomRowData([]);
|
|
1355
|
+
/** 如果当前是在第一页说明根本没有数据,会误杀其他情况,但不重要 */
|
|
1356
|
+
_this6.setState(function (prev) {
|
|
1357
|
+
return {
|
|
1358
|
+
total: prev.page === 1 ? 0 : prev.total
|
|
1359
|
+
};
|
|
1365
1360
|
});
|
|
1366
|
-
|
|
1367
|
-
|
|
1361
|
+
_this6.updateRowData([]);
|
|
1362
|
+
_this6.api.setPinnedBottomRowData([]);
|
|
1363
|
+
});
|
|
1364
|
+
}
|
|
1368
1365
|
}
|
|
1369
1366
|
}, {
|
|
1370
1367
|
key: "pagination",
|
|
1371
1368
|
value: function pagination(page, pageSize) {
|
|
1372
|
-
var
|
|
1369
|
+
var _this7 = this;
|
|
1373
1370
|
this.setState({
|
|
1374
1371
|
page: page,
|
|
1375
1372
|
pageSize: pageSize
|
|
1376
1373
|
}, function () {
|
|
1377
|
-
if (
|
|
1374
|
+
if (_this7.isClientMode()) {
|
|
1378
1375
|
withSyncRender(function () {
|
|
1379
|
-
|
|
1380
|
-
|
|
1376
|
+
_this7.api.paginationGoToPage(page - 1);
|
|
1377
|
+
_this7.api.paginationSetPageSize(pageSize);
|
|
1381
1378
|
});
|
|
1382
1379
|
} else {
|
|
1383
|
-
|
|
1380
|
+
_this7.getDataFromServer();
|
|
1384
1381
|
}
|
|
1385
1382
|
});
|
|
1386
1383
|
}
|
|
@@ -1403,7 +1400,7 @@ var InternalDataGrid = /*#__PURE__*/function (_Component) {
|
|
|
1403
1400
|
}, {
|
|
1404
1401
|
key: "validateRecord",
|
|
1405
1402
|
value: function validateRecord(record) {
|
|
1406
|
-
var
|
|
1403
|
+
var _this8 = this;
|
|
1407
1404
|
if (this.validator === null) {
|
|
1408
1405
|
return;
|
|
1409
1406
|
}
|
|
@@ -1411,26 +1408,26 @@ var InternalDataGrid = /*#__PURE__*/function (_Component) {
|
|
|
1411
1408
|
data: record
|
|
1412
1409
|
});
|
|
1413
1410
|
return this.validator.validate(record).then(function () {
|
|
1414
|
-
var errors = new Map(
|
|
1411
|
+
var errors = new Map(_this8.store.getState().errors);
|
|
1415
1412
|
var error = errors.get(rowId);
|
|
1416
1413
|
if (error === undefined) {
|
|
1417
1414
|
return;
|
|
1418
1415
|
}
|
|
1419
1416
|
errors.delete(rowId);
|
|
1420
|
-
|
|
1417
|
+
_this8.store.setState({
|
|
1421
1418
|
errors: errors
|
|
1422
1419
|
});
|
|
1423
1420
|
}).catch(function (res) {
|
|
1424
1421
|
var fields = res.fields;
|
|
1425
|
-
var errors = new Map(
|
|
1422
|
+
var errors = new Map(_this8.store.getState().errors);
|
|
1426
1423
|
var error = new Map();
|
|
1427
1424
|
Object.entries(fields).forEach(function (item) {
|
|
1428
1425
|
error.set(item[0], item[1].map(function (err) {
|
|
1429
|
-
return
|
|
1426
|
+
return _this8.getFieldErrMessage(err, item[0]);
|
|
1430
1427
|
}));
|
|
1431
1428
|
});
|
|
1432
1429
|
errors.set(rowId, error);
|
|
1433
|
-
|
|
1430
|
+
_this8.store.setState({
|
|
1434
1431
|
errors: errors
|
|
1435
1432
|
});
|
|
1436
1433
|
});
|
|
@@ -1439,7 +1436,7 @@ var InternalDataGrid = /*#__PURE__*/function (_Component) {
|
|
|
1439
1436
|
key: "validate",
|
|
1440
1437
|
value: function () {
|
|
1441
1438
|
var _validate = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
|
|
1442
|
-
var
|
|
1439
|
+
var _this9 = this;
|
|
1443
1440
|
var promises, result, flag, errors, failed;
|
|
1444
1441
|
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
1445
1442
|
while (1) switch (_context4.prev = _context4.next) {
|
|
@@ -1450,13 +1447,13 @@ var InternalDataGrid = /*#__PURE__*/function (_Component) {
|
|
|
1450
1447
|
if (record === undefined) {
|
|
1451
1448
|
return;
|
|
1452
1449
|
}
|
|
1453
|
-
var rowId =
|
|
1450
|
+
var rowId = _this9.getRowId({
|
|
1454
1451
|
data: record
|
|
1455
1452
|
});
|
|
1456
|
-
if (
|
|
1453
|
+
if (_this9.validator === null) {
|
|
1457
1454
|
promises.push(Promise.resolve(true));
|
|
1458
1455
|
} else {
|
|
1459
|
-
promises.push(
|
|
1456
|
+
promises.push(_this9.validator.validate(record).catch(function (_ref8) {
|
|
1460
1457
|
var fields = _ref8.fields;
|
|
1461
1458
|
return Promise.reject({
|
|
1462
1459
|
id: rowId,
|
|
@@ -1486,7 +1483,7 @@ var InternalDataGrid = /*#__PURE__*/function (_Component) {
|
|
|
1486
1483
|
field = _ref11[0],
|
|
1487
1484
|
errs = _ref11[1];
|
|
1488
1485
|
error.set(field, errs.map(function (err) {
|
|
1489
|
-
return
|
|
1486
|
+
return _this9.getFieldErrMessage(err, field);
|
|
1490
1487
|
}));
|
|
1491
1488
|
});
|
|
1492
1489
|
errors.set(id, error);
|
|
@@ -1518,12 +1515,14 @@ var InternalDataGrid = /*#__PURE__*/function (_Component) {
|
|
|
1518
1515
|
}, {
|
|
1519
1516
|
key: "fetch",
|
|
1520
1517
|
value: function fetch(page) {
|
|
1521
|
-
var
|
|
1518
|
+
var _this10 = this;
|
|
1522
1519
|
var curr = page || 1;
|
|
1523
1520
|
this.setState({
|
|
1524
1521
|
page: curr
|
|
1525
1522
|
}, function () {
|
|
1526
|
-
|
|
1523
|
+
_this10.afterReady(function () {
|
|
1524
|
+
_this10.getDataFromServer();
|
|
1525
|
+
});
|
|
1527
1526
|
});
|
|
1528
1527
|
}
|
|
1529
1528
|
}, {
|
|
@@ -1567,35 +1566,35 @@ var InternalDataGrid = /*#__PURE__*/function (_Component) {
|
|
|
1567
1566
|
}, {
|
|
1568
1567
|
key: "render",
|
|
1569
1568
|
value: function render() {
|
|
1570
|
-
var
|
|
1571
|
-
var _this$
|
|
1572
|
-
rowKey = _this$
|
|
1573
|
-
fetch = _this$
|
|
1574
|
-
dataSource = _this$
|
|
1575
|
-
rowActions = _this$
|
|
1576
|
-
columns = _this$
|
|
1577
|
-
autoLoad = _this$
|
|
1578
|
-
loadingProp = _this$
|
|
1579
|
-
summary = _this$
|
|
1580
|
-
detailCell = _this$
|
|
1581
|
-
pagination = _this$
|
|
1582
|
-
rowSelection = _this$
|
|
1583
|
-
columnTypesProp = _this$
|
|
1584
|
-
defaultColDefProp = _this$
|
|
1585
|
-
componentsProp = _this$
|
|
1586
|
-
sideBarProp = _this$
|
|
1587
|
-
detailCellRendererParams = _this$
|
|
1588
|
-
context = _this$
|
|
1589
|
-
showSearch = _this$
|
|
1590
|
-
cellDisplayFlex = _this$
|
|
1591
|
-
locale = _this$
|
|
1592
|
-
restProps = _objectWithoutProperties(_this$
|
|
1593
|
-
var _this$
|
|
1594
|
-
enablePagination = _this$
|
|
1595
|
-
page = _this$
|
|
1596
|
-
pageSize = _this$
|
|
1597
|
-
total = _this$
|
|
1598
|
-
loading = _this$
|
|
1569
|
+
var _this11 = this;
|
|
1570
|
+
var _this$props9 = this.props,
|
|
1571
|
+
rowKey = _this$props9.rowKey,
|
|
1572
|
+
fetch = _this$props9.fetch,
|
|
1573
|
+
dataSource = _this$props9.dataSource,
|
|
1574
|
+
rowActions = _this$props9.rowActions,
|
|
1575
|
+
columns = _this$props9.columns,
|
|
1576
|
+
autoLoad = _this$props9.autoLoad,
|
|
1577
|
+
loadingProp = _this$props9.loading,
|
|
1578
|
+
summary = _this$props9.summary,
|
|
1579
|
+
detailCell = _this$props9.detailCell,
|
|
1580
|
+
pagination = _this$props9.pagination,
|
|
1581
|
+
rowSelection = _this$props9.rowSelection,
|
|
1582
|
+
columnTypesProp = _this$props9.columnTypes,
|
|
1583
|
+
defaultColDefProp = _this$props9.defaultColDef,
|
|
1584
|
+
componentsProp = _this$props9.components,
|
|
1585
|
+
sideBarProp = _this$props9.sideBar,
|
|
1586
|
+
detailCellRendererParams = _this$props9.detailCellRendererParams,
|
|
1587
|
+
context = _this$props9.context,
|
|
1588
|
+
showSearch = _this$props9.showSearch,
|
|
1589
|
+
cellDisplayFlex = _this$props9.cellDisplayFlex,
|
|
1590
|
+
locale = _this$props9.locale,
|
|
1591
|
+
restProps = _objectWithoutProperties(_this$props9, _excluded4);
|
|
1592
|
+
var _this$state3 = this.state,
|
|
1593
|
+
enablePagination = _this$state3.pagination,
|
|
1594
|
+
page = _this$state3.page,
|
|
1595
|
+
pageSize = _this$state3.pageSize,
|
|
1596
|
+
total = _this$state3.total,
|
|
1597
|
+
loading = _this$state3.loading;
|
|
1599
1598
|
var mPage = _typeof(pagination) === 'object' ? pagination : {};
|
|
1600
1599
|
var footer = [];
|
|
1601
1600
|
var gridRowSelection;
|
|
@@ -1639,7 +1638,7 @@ var InternalDataGrid = /*#__PURE__*/function (_Component) {
|
|
|
1639
1638
|
current: page,
|
|
1640
1639
|
total: total,
|
|
1641
1640
|
onChange: function onChange(curr, limit) {
|
|
1642
|
-
|
|
1641
|
+
_this11.pagination(curr, limit);
|
|
1643
1642
|
if (mPage.onChange) {
|
|
1644
1643
|
mPage.onChange(curr, limit);
|
|
1645
1644
|
}
|
|
@@ -1657,7 +1656,7 @@ var InternalDataGrid = /*#__PURE__*/function (_Component) {
|
|
|
1657
1656
|
if (e.currentTarget.contains(e.relatedTarget)) {
|
|
1658
1657
|
return;
|
|
1659
1658
|
}
|
|
1660
|
-
|
|
1659
|
+
_this11.handleBlur();
|
|
1661
1660
|
},
|
|
1662
1661
|
onFocus: this.handleFocus
|
|
1663
1662
|
}, /*#__PURE__*/React.createElement(AgGridReact, _extends({
|
package/es/data-grid/utils.js
CHANGED
package/es/sider-tree/index.js
CHANGED
|
@@ -4,13 +4,13 @@ function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableTo
|
|
|
4
4
|
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
5
5
|
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
6
6
|
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
7
|
-
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); }
|
|
8
7
|
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
9
8
|
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
9
|
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); }
|
|
11
10
|
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; }
|
|
12
11
|
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
13
12
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
13
|
+
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); }
|
|
14
14
|
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; }
|
|
15
15
|
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; }
|
|
16
16
|
import { Input, Tabs, Tree } from 'antd';
|
|
@@ -25,7 +25,6 @@ import { useDebounce } from '@lemon-fe/hooks';
|
|
|
25
25
|
import ResizeObserver from 'rc-resize-observer';
|
|
26
26
|
var prefix = prefixClassName('tree');
|
|
27
27
|
function SiderTreeTabs(props) {
|
|
28
|
-
var _items$;
|
|
29
28
|
var tabs = props.tabs,
|
|
30
29
|
children = props.children,
|
|
31
30
|
restProps = _objectWithoutProperties(props, _excluded);
|
|
@@ -40,22 +39,18 @@ function SiderTreeTabs(props) {
|
|
|
40
39
|
children: child
|
|
41
40
|
};
|
|
42
41
|
});
|
|
43
|
-
var _useState = useState((_items$ = items[0]) === null || _items$ === void 0 ? void 0 : _items$.key),
|
|
44
|
-
_useState2 = _slicedToArray(_useState, 2),
|
|
45
|
-
activeKey = _useState2[0],
|
|
46
|
-
setActiveKey = _useState2[1];
|
|
47
42
|
return /*#__PURE__*/React.createElement(Tabs, _extends({
|
|
48
43
|
className: prefix('tabs')
|
|
49
44
|
}, restProps, {
|
|
50
45
|
items: items,
|
|
51
|
-
|
|
52
|
-
renderTabBar: function renderTabBar() {
|
|
46
|
+
renderTabBar: function renderTabBar(tabBarProps) {
|
|
53
47
|
return /*#__PURE__*/React.createElement("div", {
|
|
54
48
|
className: prefix('tabbar')
|
|
55
49
|
}, /*#__PURE__*/React.createElement(Select, {
|
|
56
|
-
value: activeKey,
|
|
50
|
+
value: tabBarProps.activeKey,
|
|
57
51
|
onChange: function onChange(val) {
|
|
58
|
-
|
|
52
|
+
// 这里比较难处理onTabClick的第二个参数,暂时忽略
|
|
53
|
+
tabBarProps.onTabClick(val, null);
|
|
59
54
|
},
|
|
60
55
|
options: items.map(function (item) {
|
|
61
56
|
return {
|
|
@@ -79,14 +74,14 @@ export default function SiderTree(props) {
|
|
|
79
74
|
footer = props.footer,
|
|
80
75
|
heightProp = props.height,
|
|
81
76
|
restProps = _objectWithoutProperties(props, _excluded2);
|
|
82
|
-
var
|
|
77
|
+
var _useState = useState(''),
|
|
78
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
79
|
+
keywords = _useState2[0],
|
|
80
|
+
setKeywords = _useState2[1];
|
|
81
|
+
var _useState3 = useState(heightProp !== 'auto' ? heightProp : 0),
|
|
83
82
|
_useState4 = _slicedToArray(_useState3, 2),
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
var _useState5 = useState(heightProp !== 'auto' ? heightProp : 0),
|
|
87
|
-
_useState6 = _slicedToArray(_useState5, 2),
|
|
88
|
-
height = _useState6[0],
|
|
89
|
-
setHeight = _useState6[1];
|
|
83
|
+
height = _useState4[0],
|
|
84
|
+
setHeight = _useState4[1];
|
|
90
85
|
var _useLocaleReceiver = useLocaleReceiver('SiderTree'),
|
|
91
86
|
_useLocaleReceiver2 = _slicedToArray(_useLocaleReceiver, 1),
|
|
92
87
|
SiderTreeLocale = _useLocaleReceiver2[0];
|
|
@@ -175,7 +170,9 @@ export default function SiderTree(props) {
|
|
|
175
170
|
className: prefix('header')
|
|
176
171
|
}, mHeader), heightProp === 'auto' ? /*#__PURE__*/React.createElement(ResizeObserver, {
|
|
177
172
|
onResize: function onResize(e) {
|
|
178
|
-
|
|
173
|
+
if (e.height) {
|
|
174
|
+
setHeight(e.height);
|
|
175
|
+
}
|
|
179
176
|
}
|
|
180
177
|
}, /*#__PURE__*/React.createElement("div", {
|
|
181
178
|
className: prefix('body'),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lemon-fe/components",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.9-alpha.0",
|
|
4
4
|
"description": "> TODO: description",
|
|
5
5
|
"homepage": "",
|
|
6
6
|
"license": "ISC",
|
|
@@ -67,5 +67,5 @@
|
|
|
67
67
|
"publishConfig": {
|
|
68
68
|
"registry": "https://registry.npmjs.org"
|
|
69
69
|
},
|
|
70
|
-
"gitHead": "
|
|
70
|
+
"gitHead": "9eac3b4183e52b0c97cd2864b209a3d97af08f29"
|
|
71
71
|
}
|