amis 1.10.1-beta.0 → 1.10.2
Sign up to get free protection for your applications and to get access to all the features.
- package/lib/Schema.d.ts +1 -1
- package/lib/Schema.js.map +1 -1
- package/lib/components/Avatar.d.ts +10 -10
- package/lib/components/ListGroup.d.ts +10 -10
- package/lib/components/Range.js +8 -2
- package/lib/components/Range.js.map +2 -2
- package/lib/components/ResultBox.d.ts +41 -40
- package/lib/components/ResultBox.js +23 -19
- package/lib/components/ResultBox.js.map +2 -2
- package/lib/components/Select.js +5 -3
- package/lib/components/Select.js.map +2 -2
- package/lib/components/Steps.d.ts +1 -0
- package/lib/components/Steps.js +8 -6
- package/lib/components/Steps.js.map +2 -2
- package/lib/components/condition-builder/index.d.ts +12 -2
- package/lib/components/condition-builder/index.js +40 -4
- package/lib/components/condition-builder/index.js.map +2 -2
- package/lib/components/formula/Editor.js +1 -1
- package/lib/components/formula/Editor.js.map +2 -2
- package/lib/components/formula/VariableList.js +2 -2
- package/lib/components/formula/VariableList.js.map +2 -2
- package/lib/components/table/index.d.ts +9 -7
- package/lib/components/table/index.js +102 -102
- package/lib/components/table/index.js.map +2 -2
- package/lib/helper.css.map +1 -1
- package/lib/index.d.ts +1 -0
- package/lib/index.js +2 -1
- package/lib/index.js.map +2 -2
- package/lib/renderers/Action.js +18 -11
- package/lib/renderers/Action.js.map +2 -2
- package/lib/renderers/ButtonGroup.d.ts +2 -2
- package/lib/renderers/ButtonGroup.js.map +1 -1
- package/lib/renderers/CRUD.js +2 -2
- package/lib/renderers/CRUD.js.map +2 -2
- package/lib/renderers/CRUD2.d.ts +213 -0
- package/lib/renderers/CRUD2.js +724 -0
- package/lib/renderers/CRUD2.js.map +13 -0
- package/lib/renderers/Card2.d.ts +1 -1
- package/lib/renderers/Card2.js +1 -2
- package/lib/renderers/Card2.js.map +2 -2
- package/lib/renderers/Cards.d.ts +3 -0
- package/lib/renderers/Cards.js +52 -5
- package/lib/renderers/Cards.js.map +2 -2
- package/lib/renderers/Form/ConditionBuilder.d.ts +10 -0
- package/lib/renderers/Form/ConditionBuilder.js +6 -2
- package/lib/renderers/Form/ConditionBuilder.js.map +2 -2
- package/lib/renderers/Form/DiffEditor.d.ts +66 -20
- package/lib/renderers/Form/Editor.d.ts +66 -20
- package/lib/renderers/Form/Item.d.ts +4 -0
- package/lib/renderers/Form/Item.js +1 -1
- package/lib/renderers/Form/Item.js.map +2 -2
- package/lib/renderers/Form/TreeSelect.d.ts +0 -1
- package/lib/renderers/Form/TreeSelect.js +1 -9
- package/lib/renderers/Form/TreeSelect.js.map +2 -2
- package/lib/renderers/Form/index.js +8 -4
- package/lib/renderers/Form/index.js.map +2 -2
- package/lib/renderers/Icon.d.ts +1 -1
- package/lib/renderers/Icon.js +13 -8
- package/lib/renderers/Icon.js.map +2 -2
- package/lib/renderers/Table/index.d.ts +1 -0
- package/lib/renderers/Table/index.js +19 -5
- package/lib/renderers/Table/index.js.map +2 -2
- package/lib/renderers/Table-v2/index.d.ts +8 -5
- package/lib/renderers/Table-v2/index.js +83 -54
- package/lib/renderers/Table-v2/index.js.map +2 -2
- package/lib/store/combo.d.ts +72 -22
- package/lib/store/crud.d.ts +2 -0
- package/lib/store/crud.js +21 -1
- package/lib/store/crud.js.map +2 -2
- package/lib/store/form.d.ts +30 -9
- package/lib/store/form.js +28 -10
- package/lib/store/form.js.map +2 -2
- package/lib/store/formItem.d.ts +3 -1
- package/lib/store/formItem.js +3 -5
- package/lib/store/formItem.js.map +2 -2
- package/lib/store/list.d.ts +2 -0
- package/lib/store/list.js +8 -0
- package/lib/store/list.js.map +2 -2
- package/lib/store/table.d.ts +60 -18
- package/lib/themes/ang-ie11.css +166 -19
- package/lib/themes/ang.css +166 -19
- package/lib/themes/ang.css.map +1 -1
- package/lib/themes/antd-ie11.css +166 -19
- package/lib/themes/antd.css +166 -19
- package/lib/themes/antd.css.map +1 -1
- package/lib/themes/cxd-ie11.css +166 -19
- package/lib/themes/cxd.css +166 -19
- package/lib/themes/cxd.css.map +1 -1
- package/lib/themes/dark-ie11.css +166 -19
- package/lib/themes/dark.css +166 -19
- package/lib/themes/dark.css.map +1 -1
- package/lib/themes/default-ie11.css +166 -19
- package/lib/themes/default.css +166 -19
- package/lib/themes/default.css.map +1 -1
- package/lib/types.d.ts +1 -1
- package/lib/types.js.map +1 -1
- package/lib/utils/icon.js +7 -0
- package/lib/utils/icon.js.map +2 -2
- package/package.json +1 -1
- package/schema.json +28 -25
- package/scss/_mixins.scss +1 -1
- package/scss/components/_condition-builder.scss +11 -0
- package/scss/components/_crud.scss +8 -3
- package/scss/components/_crud2.scss +148 -0
- package/scss/components/_result-box.scss +27 -8
- package/scss/components/_steps.scss +21 -26
- package/scss/components/_table-v2.scss +1 -3
- package/scss/components/form/_select.scss +4 -0
- package/scss/themes/_common.scss +1 -0
- package/sdk/ang-ie11.css +203 -20
- package/sdk/ang.css +203 -20
- package/sdk/antd-ie11.css +203 -20
- package/sdk/antd.css +203 -20
- package/sdk/barcode.js +51 -51
- package/sdk/charts.js +14 -14
- package/sdk/codemirror.js +7 -7
- package/sdk/color-picker.js +65 -65
- package/sdk/cropperjs.js +2 -2
- package/sdk/cxd-ie11.css +203 -20
- package/sdk/cxd.css +203 -20
- package/sdk/dark-ie11.css +203 -20
- package/sdk/dark.css +203 -20
- package/sdk/exceljs.js +1 -1
- package/sdk/helper.css.map +1 -1
- package/sdk/markdown.js +69 -69
- package/sdk/papaparse.js +1 -1
- package/sdk/renderers/Form/CityDB.js +1 -1
- package/sdk/rest.js +16 -16
- package/sdk/rich-text.js +62 -62
- package/sdk/sdk-ie11.css +203 -20
- package/sdk/sdk.css +203 -20
- package/sdk/sdk.js +1344 -1340
- package/sdk/thirds/hls.js/hls.js +1 -1
- package/sdk/thirds/mpegts.js/mpegts.js +1 -1
- package/sdk/tinymce.js +57 -57
- package/src/Schema.ts +1 -0
- package/src/components/Range.tsx +14 -7
- package/src/components/ResultBox.tsx +65 -54
- package/src/components/Select.tsx +6 -5
- package/src/components/Steps.tsx +60 -18
- package/src/components/condition-builder/index.tsx +107 -8
- package/src/components/formula/Editor.tsx +1 -1
- package/src/components/formula/VariableList.tsx +2 -2
- package/src/components/table/index.tsx +190 -193
- package/src/index.tsx +1 -0
- package/src/renderers/Action.tsx +22 -11
- package/src/renderers/ButtonGroup.tsx +2 -2
- package/src/renderers/CRUD.tsx +2 -1
- package/src/renderers/CRUD2.tsx +1213 -0
- package/src/renderers/Card2.tsx +2 -3
- package/src/renderers/Cards.tsx +55 -10
- package/src/renderers/Form/ConditionBuilder.tsx +19 -2
- package/src/renderers/Form/Item.tsx +11 -1
- package/src/renderers/Form/TreeSelect.tsx +14 -16
- package/src/renderers/Form/index.tsx +11 -2
- package/src/renderers/Icon.tsx +8 -1
- package/src/renderers/Table/index.tsx +21 -5
- package/src/renderers/Table-v2/index.tsx +92 -72
- package/src/store/crud.ts +23 -1
- package/src/store/form.ts +31 -24
- package/src/store/formItem.ts +65 -52
- package/src/store/list.ts +10 -0
- package/src/types.ts +2 -1
- package/src/utils/icon.tsx +9 -0
@@ -14,7 +14,7 @@ import Sortable from 'sortablejs';
|
|
14
14
|
|
15
15
|
import {themeable, ClassNamesFn, ThemeProps} from '../../theme';
|
16
16
|
import {localeable, LocaleProps} from '../../locale';
|
17
|
-
import {isObject, isBreakpoint, guid} from '../../utils/helper';
|
17
|
+
import {isObject, isBreakpoint, guid, autobind} from '../../utils/helper';
|
18
18
|
import {Icon} from '../icons';
|
19
19
|
import CheckBox from '../Checkbox';
|
20
20
|
import Spinner from '../Spinner';
|
@@ -158,9 +158,9 @@ export interface TableState {
|
|
158
158
|
expandedRowKeys: Array<string | number>;
|
159
159
|
colWidths: Array<number>;
|
160
160
|
hoverRow: {
|
161
|
-
rowIndex?: number
|
162
|
-
record: any
|
163
|
-
target: HTMLTableRowElement
|
161
|
+
rowIndex?: number;
|
162
|
+
record: any;
|
163
|
+
target: HTMLTableRowElement;
|
164
164
|
} | null;
|
165
165
|
}
|
166
166
|
|
@@ -349,7 +349,6 @@ export class Table extends React.PureComponent<TableProps, TableState> {
|
|
349
349
|
hoverRow: null
|
350
350
|
};
|
351
351
|
|
352
|
-
this.onTableContentScroll = this.onTableContentScroll.bind(this);
|
353
352
|
this.getPopOverContainer = this.getPopOverContainer.bind(this);
|
354
353
|
}
|
355
354
|
|
@@ -366,10 +365,14 @@ export class Table extends React.PureComponent<TableProps, TableState> {
|
|
366
365
|
// 表格当前未选中行
|
367
366
|
unSelectedRows: Array<any>;
|
368
367
|
// 拖拽排序
|
369
|
-
sortable: Sortable;
|
368
|
+
sortable: Sortable | null;
|
370
369
|
// 记录点击起始横坐标
|
371
370
|
resizeStart: number;
|
372
371
|
resizeKey: string;
|
372
|
+
resizeTarget: HTMLElement | null;
|
373
|
+
resizeWidth: number;
|
374
|
+
// 可以拖拽的最长距离
|
375
|
+
resizeMaxDistance: number;
|
373
376
|
|
374
377
|
tableDom: React.RefObject<HTMLDivElement> = React.createRef();
|
375
378
|
theadDom: React.RefObject<HTMLTableSectionElement> = React.createRef();
|
@@ -417,6 +420,9 @@ export class Table extends React.PureComponent<TableProps, TableState> {
|
|
417
420
|
updateTableBodyFixed() {
|
418
421
|
const tbodyDom = this.tbodyDom && (this.tbodyDom.current as HTMLElement);
|
419
422
|
const tdColumns = [...this.tdColumns];
|
423
|
+
if (!tbodyDom) {
|
424
|
+
return;
|
425
|
+
}
|
420
426
|
this.updateTbodyFixedRow(tbodyDom, tdColumns);
|
421
427
|
this.updateHeadSummaryFixedRow(tbodyDom);
|
422
428
|
}
|
@@ -433,11 +439,7 @@ export class Table extends React.PureComponent<TableProps, TableState> {
|
|
433
439
|
});
|
434
440
|
}
|
435
441
|
|
436
|
-
|
437
|
-
if (this.props.loading) {
|
438
|
-
return;
|
439
|
-
}
|
440
|
-
|
442
|
+
updateTableFixedRows() {
|
441
443
|
if (hasFixedColumn(this.props.columns)) {
|
442
444
|
const headerDom =
|
443
445
|
this.headerDom && (this.headerDom.current as HTMLElement);
|
@@ -451,14 +453,17 @@ export class Table extends React.PureComponent<TableProps, TableState> {
|
|
451
453
|
const tfootDom = this.tfootDom && (this.tfootDom.current as HTMLElement);
|
452
454
|
tfootDom && this.updateFootSummaryFixedRow(tfootDom);
|
453
455
|
}
|
456
|
+
}
|
454
457
|
|
455
|
-
|
456
|
-
if (this.
|
457
|
-
|
458
|
-
|
459
|
-
|
460
|
-
|
458
|
+
componentDidMount() {
|
459
|
+
if (this.props.loading) {
|
460
|
+
return;
|
461
|
+
}
|
462
|
+
|
463
|
+
this.updateTableFixedRows();
|
461
464
|
|
465
|
+
let current = this.contentDom?.current;
|
466
|
+
if (this.headerDom?.current) {
|
462
467
|
// overflow设置为hidden的情况
|
463
468
|
const hiddenDomRefs = [this.headerDom, this.footDom];
|
464
469
|
hiddenDomRefs.forEach(
|
@@ -467,14 +472,6 @@ export class Table extends React.PureComponent<TableProps, TableState> {
|
|
467
472
|
ref.current &&
|
468
473
|
ref.current.addEventListener('wheel', this.onWheel.bind(this))
|
469
474
|
);
|
470
|
-
// 横向同步滚动
|
471
|
-
const scrollDomRefs = [this.bodyDom];
|
472
|
-
scrollDomRefs.forEach(
|
473
|
-
ref =>
|
474
|
-
ref &&
|
475
|
-
ref.current &&
|
476
|
-
ref.current.addEventListener('scroll', this.onTableScroll.bind(this))
|
477
|
-
);
|
478
475
|
}
|
479
476
|
current && this.updateTableDom(current);
|
480
477
|
|
@@ -482,13 +479,6 @@ export class Table extends React.PureComponent<TableProps, TableState> {
|
|
482
479
|
this.initDragging();
|
483
480
|
}
|
484
481
|
|
485
|
-
if (this.props.resizable) {
|
486
|
-
this.theadDom.current?.addEventListener(
|
487
|
-
'mouseup',
|
488
|
-
this.onResizeMouseUp.bind(this)
|
489
|
-
);
|
490
|
-
}
|
491
|
-
|
492
482
|
this.updateStickyHeader();
|
493
483
|
|
494
484
|
this.updateColWidths();
|
@@ -497,9 +487,19 @@ export class Table extends React.PureComponent<TableProps, TableState> {
|
|
497
487
|
componentDidUpdate(prevProps: TableProps, prevState: TableState) {
|
498
488
|
// 数据源发生了变化
|
499
489
|
if (!isEqual(prevProps.dataSource, this.props.dataSource)) {
|
500
|
-
this.setState({dataSource: [...this.props.dataSource]}, () =>
|
501
|
-
this.
|
502
|
-
|
490
|
+
this.setState({dataSource: [...this.props.dataSource]}, () => {
|
491
|
+
if (this.props.draggable) {
|
492
|
+
if (this.sortable) {
|
493
|
+
this.destroyDragging();
|
494
|
+
}
|
495
|
+
|
496
|
+
this.initDragging();
|
497
|
+
}
|
498
|
+
|
499
|
+
this.updateTableFixedRows();
|
500
|
+
|
501
|
+
this.updateColWidths();
|
502
|
+
}); // 异步加载数据需求再更新一次
|
503
503
|
}
|
504
504
|
|
505
505
|
// 选择项发生了变化触发
|
@@ -584,13 +584,6 @@ export class Table extends React.PureComponent<TableProps, TableState> {
|
|
584
584
|
}
|
585
585
|
|
586
586
|
componentWillUnmount() {
|
587
|
-
this.contentDom &&
|
588
|
-
this.contentDom.current &&
|
589
|
-
this.contentDom.current.removeEventListener(
|
590
|
-
'scroll',
|
591
|
-
this.onTableContentScroll.bind(this)
|
592
|
-
);
|
593
|
-
|
594
587
|
const hiddenDomRefs = [this.headerDom, this.footDom];
|
595
588
|
hiddenDomRefs.forEach(
|
596
589
|
ref =>
|
@@ -599,14 +592,6 @@ export class Table extends React.PureComponent<TableProps, TableState> {
|
|
599
592
|
ref.current.removeEventListener('wheel', this.onWheel.bind(this))
|
600
593
|
);
|
601
594
|
|
602
|
-
const scrollDomRefs = [this.bodyDom];
|
603
|
-
scrollDomRefs.forEach(
|
604
|
-
ref =>
|
605
|
-
ref &&
|
606
|
-
ref.current &&
|
607
|
-
ref.current.removeEventListener('scroll', this.onTableScroll.bind(this))
|
608
|
-
);
|
609
|
-
|
610
595
|
this.destroyDragging();
|
611
596
|
}
|
612
597
|
|
@@ -648,13 +633,15 @@ export class Table extends React.PureComponent<TableProps, TableState> {
|
|
648
633
|
|
649
634
|
const rowLevels = e.item.getAttribute('row-levels');
|
650
635
|
|
651
|
-
onDrag &&
|
636
|
+
onDrag &&
|
637
|
+
onDrag(e.oldIndex, e.newIndex, rowLevels ? rowLevels.split(',') : []);
|
652
638
|
}
|
653
639
|
});
|
654
640
|
}
|
655
641
|
|
656
642
|
destroyDragging() {
|
657
643
|
this.sortable && this.sortable.destroy();
|
644
|
+
this.sortable = null;
|
658
645
|
}
|
659
646
|
|
660
647
|
updateStickyHeader() {
|
@@ -840,73 +827,61 @@ export class Table extends React.PureComponent<TableProps, TableState> {
|
|
840
827
|
);
|
841
828
|
}
|
842
829
|
|
843
|
-
onResizeMouseDown(event:
|
830
|
+
onResizeMouseDown(event: any, key: string) {
|
844
831
|
// 点击记录起始坐标
|
845
832
|
this.resizeStart = event.clientX;
|
846
|
-
// 记录点击的列名
|
847
833
|
this.resizeKey = key;
|
834
|
+
|
835
|
+
let index =
|
836
|
+
this.tdColumns.findIndex(c => c.key === key) + this.getExtraColumnCount();
|
837
|
+
|
838
|
+
const colGroup = this.tableDom.current?.getElementsByTagName('colgroup')[0];
|
839
|
+
let currentWidth = 0;
|
840
|
+
let child = null;
|
841
|
+
if (colGroup && colGroup.children[index]) {
|
842
|
+
child = colGroup.children[index] as HTMLElement;
|
843
|
+
currentWidth = child.offsetWidth;
|
844
|
+
}
|
845
|
+
this.resizeWidth = currentWidth;
|
846
|
+
this.resizeTarget = child;
|
847
|
+
|
848
|
+
if (colGroup) {
|
849
|
+
let maxDistance = 0;
|
850
|
+
for (let i = 0; i < colGroup.children.length; i++) {
|
851
|
+
const child = colGroup.children[i] as HTMLElement;
|
852
|
+
// 自适应列 保证有一个最小宽度
|
853
|
+
// 如果都设置了固定宽度 那一个都拖不动
|
854
|
+
if (!this.tdColumns[i].width) {
|
855
|
+
maxDistance += child.offsetWidth - DefaultCellWidth;
|
856
|
+
}
|
857
|
+
}
|
858
|
+
this.resizeMaxDistance = maxDistance;
|
859
|
+
}
|
860
|
+
|
861
|
+
document.addEventListener('mousemove', this.onResizeMouseMove);
|
862
|
+
document.addEventListener('mouseup', this.onResizeMouseUp);
|
863
|
+
|
848
864
|
event && event.stopPropagation();
|
849
865
|
}
|
850
866
|
|
851
|
-
|
867
|
+
@autobind
|
868
|
+
onResizeMouseMove(event: any) {
|
852
869
|
// 点击了调整列宽
|
853
|
-
if (this.resizeStart && this.
|
870
|
+
if (this.resizeStart && this.resizeTarget) {
|
854
871
|
// 计算横向移动距离
|
855
872
|
const distance = event.clientX - this.resizeStart;
|
856
873
|
const tdColumns = [...this.tdColumns];
|
857
|
-
let index =
|
858
|
-
tdColumns.findIndex(c => c.key === this.resizeKey) +
|
859
|
-
this.getExtraColumnCount();
|
860
|
-
|
861
|
-
const colGroup =
|
862
|
-
this.tableDom.current?.getElementsByTagName('colgroup')[0];
|
863
|
-
let currentWidth = 0;
|
864
|
-
if (colGroup && colGroup.children[index]) {
|
865
|
-
const child = colGroup.children[index] as HTMLElement;
|
866
|
-
currentWidth = child.offsetWidth;
|
867
|
-
}
|
868
874
|
|
869
875
|
let newWidth = 0;
|
870
|
-
|
871
|
-
|
872
|
-
|
873
|
-
|
874
|
-
|
875
|
-
|
876
|
-
|
877
|
-
|
878
|
-
|
879
|
-
maxDistance += child.offsetWidth - DefaultCellWidth;
|
880
|
-
}
|
881
|
-
}
|
882
|
-
if (colGroup.children[index]) {
|
883
|
-
const child = colGroup.children[index] as HTMLElement;
|
884
|
-
newWidth = currentWidth + Math.min(distance, maxDistance);
|
885
|
-
child.style.width = newWidth + 'px';
|
886
|
-
}
|
887
|
-
} else {
|
888
|
-
// 缩短列
|
889
|
-
const autoColumns = [];
|
890
|
-
for (let i = 0; i < colGroup.children.length; i++) {
|
891
|
-
const child = colGroup.children[i] as HTMLElement;
|
892
|
-
// 自适应列 保证有一个最小宽度
|
893
|
-
// 如果都设置了固定宽度 那一个都拖不动
|
894
|
-
if (!this.tdColumns[i].width) {
|
895
|
-
autoColumns.push(child);
|
896
|
-
}
|
897
|
-
}
|
898
|
-
maxDistance = DefaultCellWidth - currentWidth;
|
899
|
-
if (colGroup.children[index]) {
|
900
|
-
const child = colGroup.children[index] as HTMLElement;
|
901
|
-
newWidth = currentWidth + Math.max(distance, maxDistance);
|
902
|
-
child.style.width = newWidth + 'px';
|
903
|
-
}
|
904
|
-
const gap =
|
905
|
-
Math.abs(Math.max(distance, maxDistance)) / autoColumns.length;
|
906
|
-
autoColumns.forEach(c => {
|
907
|
-
c.style.width = c.offsetWidth + gap + 'px';
|
908
|
-
});
|
909
|
-
}
|
876
|
+
// 调宽列
|
877
|
+
if (distance > 0) {
|
878
|
+
newWidth =
|
879
|
+
this.resizeWidth + Math.min(distance, this.resizeMaxDistance);
|
880
|
+
this.resizeTarget.style.width = newWidth + 'px';
|
881
|
+
} else {
|
882
|
+
// 缩短列
|
883
|
+
newWidth = Math.max(this.resizeWidth + distance, DefaultCellWidth);
|
884
|
+
this.resizeTarget.style.width = newWidth + 'px';
|
910
885
|
}
|
911
886
|
|
912
887
|
const column = find(tdColumns, c => c.key === this.resizeKey);
|
@@ -918,13 +893,22 @@ export class Table extends React.PureComponent<TableProps, TableState> {
|
|
918
893
|
}
|
919
894
|
|
920
895
|
this.tdColumns = tdColumns;
|
921
|
-
|
922
|
-
this.resizeStart = 0;
|
923
|
-
this.resizeKey = '';
|
924
896
|
}
|
925
897
|
event && event.stopPropagation();
|
926
898
|
}
|
927
899
|
|
900
|
+
@autobind
|
901
|
+
onResizeMouseUp(event: MouseEvent) {
|
902
|
+
document.removeEventListener('mousemove', this.onResizeMouseMove);
|
903
|
+
document.removeEventListener('mouseup', this.onResizeMouseUp);
|
904
|
+
|
905
|
+
this.resizeStart = 0;
|
906
|
+
this.resizeKey = '';
|
907
|
+
this.resizeWidth = 0;
|
908
|
+
this.resizeTarget = null;
|
909
|
+
this.resizeMaxDistance = 0;
|
910
|
+
}
|
911
|
+
|
928
912
|
renderTHead() {
|
929
913
|
const {
|
930
914
|
rowSelection,
|
@@ -1086,47 +1070,51 @@ export class Table extends React.PureComponent<TableProps, TableState> {
|
|
1086
1070
|
);
|
1087
1071
|
}
|
1088
1072
|
|
1089
|
-
|
1090
|
-
|
1091
|
-
|
1092
|
-
|
1093
|
-
|
1094
|
-
|
1095
|
-
|
1096
|
-
|
1097
|
-
|
1098
|
-
|
1099
|
-
|
1100
|
-
|
1101
|
-
|
1102
|
-
|
1103
|
-
|
1104
|
-
|
1105
|
-
|
1106
|
-
|
1107
|
-
|
1108
|
-
|
1109
|
-
|
1110
|
-
|
1111
|
-
|
1112
|
-
|
1113
|
-
|
1114
|
-
|
1115
|
-
|
1116
|
-
|
1117
|
-
|
1118
|
-
|
1119
|
-
|
1120
|
-
|
1121
|
-
|
1122
|
-
|
1123
|
-
|
1124
|
-
|
1125
|
-
|
1073
|
+
const children = (
|
1074
|
+
<span>
|
1075
|
+
{sort}
|
1076
|
+
{filter}
|
1077
|
+
{resizable ? (
|
1078
|
+
<i
|
1079
|
+
className={cx('Table-thead-resizable')}
|
1080
|
+
onMouseDown={e => this.onResizeMouseDown(e, item.key)}
|
1081
|
+
></i>
|
1082
|
+
) : null}
|
1083
|
+
</span>
|
1084
|
+
);
|
1085
|
+
|
1086
|
+
return (
|
1087
|
+
<Cell
|
1088
|
+
wrapperComponent="th"
|
1089
|
+
rowSpan={item.rowSpan}
|
1090
|
+
colSpan={item.colSpan}
|
1091
|
+
key={`cell-${i}`}
|
1092
|
+
fixed={item.fixed === true ? 'left' : item.fixed}
|
1093
|
+
className={cx({
|
1094
|
+
'Table-cell-last':
|
1095
|
+
i === maxCount - 1 && i === data.length - 1
|
1096
|
+
})}
|
1097
|
+
groupId={item.groupId}
|
1098
|
+
depth={item.depth}
|
1099
|
+
>
|
1100
|
+
{typeof item.title === 'function'
|
1101
|
+
? item.title(children)
|
1102
|
+
: item.title}
|
1103
|
+
</Cell>
|
1104
|
+
);
|
1105
|
+
})}
|
1106
|
+
</tr>
|
1107
|
+
);
|
1108
|
+
})}
|
1109
|
+
</thead>
|
1126
1110
|
);
|
1127
1111
|
}
|
1128
1112
|
|
1129
|
-
async onRowClick(
|
1113
|
+
async onRowClick(
|
1114
|
+
event: React.ChangeEvent<any>,
|
1115
|
+
record?: any,
|
1116
|
+
rowIndex?: number
|
1117
|
+
) {
|
1130
1118
|
const {rowSelection, onRow} = this.props;
|
1131
1119
|
|
1132
1120
|
if (onRow && onRow.onRowClick) {
|
@@ -1175,7 +1163,8 @@ export class Table extends React.PureComponent<TableProps, TableState> {
|
|
1175
1163
|
|
1176
1164
|
this.setState({hoverRow: {target, rowIndex, record}}, () => {
|
1177
1165
|
if (onRow) {
|
1178
|
-
onRow.onRowMouseEnter &&
|
1166
|
+
onRow.onRowMouseEnter &&
|
1167
|
+
onRow.onRowMouseEnter(event, record, rowIndex);
|
1179
1168
|
}
|
1180
1169
|
});
|
1181
1170
|
}
|
@@ -1336,21 +1325,22 @@ export class Table extends React.PureComponent<TableProps, TableState> {
|
|
1336
1325
|
...this.state.selectedRowKeys,
|
1337
1326
|
data[defaultKey],
|
1338
1327
|
...this.getDataChildrenKeys(data)
|
1339
|
-
].filter((key, i, a) => a.indexOf(key) === i)
|
1328
|
+
].filter((key, i, a) => a.indexOf(key) === i);
|
1340
1329
|
}
|
1341
1330
|
} else {
|
1342
1331
|
if (!isRadio) {
|
1343
1332
|
selectedRowKeys = this.state.selectedRowKeys.filter(
|
1344
1333
|
key =>
|
1345
|
-
![data[defaultKey], ...this.getDataChildrenKeys(data)].includes(
|
1346
|
-
|
1347
|
-
)
|
1348
|
-
)
|
1334
|
+
![data[defaultKey], ...this.getDataChildrenKeys(data)].includes(key)
|
1335
|
+
);
|
1349
1336
|
}
|
1350
1337
|
}
|
1351
1338
|
|
1352
1339
|
if (onSelect) {
|
1353
|
-
const selectedResult = this.getSelectedRows(
|
1340
|
+
const selectedResult = this.getSelectedRows(
|
1341
|
+
this.state.dataSource,
|
1342
|
+
selectedRowKeys
|
1343
|
+
);
|
1354
1344
|
const prevented = await onSelect(
|
1355
1345
|
selectedResult.selectedRows,
|
1356
1346
|
selectedRowKeys,
|
@@ -1396,8 +1386,11 @@ export class Table extends React.PureComponent<TableProps, TableState> {
|
|
1396
1386
|
levels.length > 0 ? (
|
1397
1387
|
<span
|
1398
1388
|
className={cx('Table-row-indent', `indent-level-${levels.length}`)}
|
1399
|
-
style={
|
1400
|
-
|
1389
|
+
style={
|
1390
|
+
levels.length > 0
|
1391
|
+
? {paddingLeft: indentSize * levels.length + 'px'}
|
1392
|
+
: {}
|
1393
|
+
}
|
1401
1394
|
></span>
|
1402
1395
|
) : null;
|
1403
1396
|
|
@@ -1417,8 +1410,10 @@ export class Table extends React.PureComponent<TableProps, TableState> {
|
|
1417
1410
|
}
|
1418
1411
|
}
|
1419
1412
|
|
1420
|
-
const className =
|
1421
|
-
|
1413
|
+
const className =
|
1414
|
+
typeof item.className === 'function'
|
1415
|
+
? item.className(data, rowIndex)
|
1416
|
+
: '';
|
1422
1417
|
return props.rowSpan === 0 || props.colSpan === 0 ? null : (
|
1423
1418
|
<Cell
|
1424
1419
|
key={i}
|
@@ -1430,12 +1425,14 @@ export class Table extends React.PureComponent<TableProps, TableState> {
|
|
1430
1425
|
[`${className}`]: !!className
|
1431
1426
|
})}
|
1432
1427
|
>
|
1433
|
-
<div
|
1434
|
-
|
1435
|
-
|
1436
|
-
|
1437
|
-
|
1438
|
-
|
1428
|
+
<div
|
1429
|
+
className={cx('Table-cell-wrapper', {
|
1430
|
+
[cx('Table-cell-wrapper-prefix')]:
|
1431
|
+
i === 0 &&
|
1432
|
+
(!!indentDom || (levels.length === 0 && hasChildrenRow)),
|
1433
|
+
[cx(`Table-cell-height-${lineHeight}`)]: !!lineHeight
|
1434
|
+
})}
|
1435
|
+
>
|
1439
1436
|
{i === 0 && levels.length > 0 ? indentDom : null}
|
1440
1437
|
{i === 0 && hasChildrenRow
|
1441
1438
|
? this.getExpandedIcons(isExpanded, data)
|
@@ -1525,7 +1522,7 @@ export class Table extends React.PureComponent<TableProps, TableState> {
|
|
1525
1522
|
name={'Table-checkbox'}
|
1526
1523
|
type={rowSelection.type || 'checkbox'}
|
1527
1524
|
partial={!isRadio && hasChildrenChecked && !isChecked}
|
1528
|
-
checked={isRadio ? isChecked :
|
1525
|
+
checked={isRadio ? isChecked : hasChildrenChecked || isChecked}
|
1529
1526
|
onChange={(value, shift) => {
|
1530
1527
|
if (!(rowSelection && rowSelection.rowClick)) {
|
1531
1528
|
this.selectedSingleRow(value, data);
|
@@ -1581,7 +1578,9 @@ export class Table extends React.PureComponent<TableProps, TableState> {
|
|
1581
1578
|
</Cell>
|
1582
1579
|
</tr>
|
1583
1580
|
) : (
|
1584
|
-
this.state.dataSource.map((data, index) =>
|
1581
|
+
this.state.dataSource.map((data, index) =>
|
1582
|
+
this.renderRow(data, index, [])
|
1583
|
+
)
|
1585
1584
|
)}
|
1586
1585
|
</tbody>
|
1587
1586
|
);
|
@@ -1723,6 +1722,7 @@ export class Table extends React.PureComponent<TableProps, TableState> {
|
|
1723
1722
|
onWheel(event: WheelEvent) {
|
1724
1723
|
const {currentTarget, deltaX} =
|
1725
1724
|
event as unknown as React.WheelEvent<HTMLDivElement>;
|
1725
|
+
|
1726
1726
|
if (deltaX) {
|
1727
1727
|
this.onTableScroll({
|
1728
1728
|
target: currentTarget,
|
@@ -1733,7 +1733,7 @@ export class Table extends React.PureComponent<TableProps, TableState> {
|
|
1733
1733
|
}
|
1734
1734
|
}
|
1735
1735
|
|
1736
|
-
onTableScroll(event:
|
1736
|
+
onTableScroll(event: any) {
|
1737
1737
|
const scrollDomRefs = [this.headerDom, this.bodyDom, this.footDom];
|
1738
1738
|
|
1739
1739
|
const {target, scrollLeft} = event;
|
@@ -1777,14 +1777,15 @@ export class Table extends React.PureComponent<TableProps, TableState> {
|
|
1777
1777
|
className={cx('Table-content')}
|
1778
1778
|
style={hasScrollX ? {overflow: 'auto hidden'} : {}}
|
1779
1779
|
onMouseLeave={this.onMouseLeave.bind(this)}
|
1780
|
+
onScroll={this.onTableContentScroll.bind(this)}
|
1780
1781
|
>
|
1781
|
-
{itemActions && hoverRow
|
1782
|
-
|
1783
|
-
|
1784
|
-
|
1785
|
-
|
1786
|
-
|
1787
|
-
|
1782
|
+
{itemActions && hoverRow ? (
|
1783
|
+
<ItemActionsWrapper dom={hoverRow.target} classnames={cx}>
|
1784
|
+
{typeof itemActions === 'function'
|
1785
|
+
? itemActions(hoverRow.record, hoverRow.rowIndex)
|
1786
|
+
: null}
|
1787
|
+
</ItemActionsWrapper>
|
1788
|
+
) : null}
|
1788
1789
|
<table
|
1789
1790
|
style={
|
1790
1791
|
hasScrollX
|
@@ -1845,11 +1846,7 @@ export class Table extends React.PureComponent<TableProps, TableState> {
|
|
1845
1846
|
}
|
1846
1847
|
|
1847
1848
|
renderScrollTableBody() {
|
1848
|
-
const {
|
1849
|
-
scroll,
|
1850
|
-
itemActions,
|
1851
|
-
classnames: cx
|
1852
|
-
} = this.props;
|
1849
|
+
const {scroll, itemActions, classnames: cx} = this.props;
|
1853
1850
|
|
1854
1851
|
const style = {};
|
1855
1852
|
const tableStyle = {};
|
@@ -1872,20 +1869,20 @@ export class Table extends React.PureComponent<TableProps, TableState> {
|
|
1872
1869
|
ref={this.bodyDom}
|
1873
1870
|
className={cx('Table-body')}
|
1874
1871
|
style={style}
|
1875
|
-
onMouseLeave={this.onMouseLeave.bind(this)}
|
1876
|
-
{
|
1877
|
-
|
1878
|
-
|
1879
|
-
|
1880
|
-
|
1881
|
-
|
1882
|
-
|
1883
|
-
|
1884
|
-
|
1885
|
-
|
1886
|
-
|
1887
|
-
|
1888
|
-
|
1872
|
+
onMouseLeave={this.onMouseLeave.bind(this)}
|
1873
|
+
onScroll={this.onTableScroll.bind(this)}
|
1874
|
+
>
|
1875
|
+
{itemActions && hoverRow ? (
|
1876
|
+
<ItemActionsWrapper dom={hoverRow.target} classnames={cx}>
|
1877
|
+
{typeof itemActions === 'function'
|
1878
|
+
? itemActions(hoverRow.record, hoverRow.rowIndex)
|
1879
|
+
: null}
|
1880
|
+
</ItemActionsWrapper>
|
1881
|
+
) : null}
|
1882
|
+
<table className={cx('Table-table')} style={tableStyle}>
|
1883
|
+
{this.renderColGroup()}
|
1884
|
+
{this.renderTBody()}
|
1885
|
+
</table>
|
1889
1886
|
</div>
|
1890
1887
|
);
|
1891
1888
|
}
|
package/src/index.tsx
CHANGED
package/src/renderers/Action.tsx
CHANGED
@@ -913,25 +913,36 @@ export class ActionRenderer extends React.Component<ActionRendererProps> {
|
|
913
913
|
mergedData = createObject(data, action.args);
|
914
914
|
}
|
915
915
|
|
916
|
-
// 触发渲染器事件
|
917
|
-
const rendererEvent = await dispatchEvent(
|
918
|
-
e as React.MouseEvent<any> | string,
|
919
|
-
mergedData
|
920
|
-
);
|
921
|
-
|
922
|
-
// 阻止原有动作执行
|
923
|
-
if (rendererEvent?.prevented) {
|
924
|
-
return;
|
925
|
-
}
|
926
|
-
|
927
916
|
if (!ignoreConfirm && action.confirmText && env.confirm) {
|
928
917
|
let confirmed = await env.confirm(filter(action.confirmText, mergedData));
|
929
918
|
if (confirmed) {
|
919
|
+
// 触发渲染器事件
|
920
|
+
const rendererEvent = await dispatchEvent(
|
921
|
+
e as React.MouseEvent<any> | string,
|
922
|
+
mergedData
|
923
|
+
);
|
924
|
+
|
925
|
+
// 阻止原有动作执行
|
926
|
+
if (rendererEvent?.prevented) {
|
927
|
+
return;
|
928
|
+
}
|
929
|
+
|
930
930
|
await onAction(e, action, mergedData);
|
931
931
|
} else if (action.countDown) {
|
932
932
|
throw new Error('cancel');
|
933
933
|
}
|
934
934
|
} else {
|
935
|
+
// 触发渲染器事件
|
936
|
+
const rendererEvent = await dispatchEvent(
|
937
|
+
e as React.MouseEvent<any> | string,
|
938
|
+
mergedData
|
939
|
+
);
|
940
|
+
|
941
|
+
// 阻止原有动作执行
|
942
|
+
if (rendererEvent?.prevented) {
|
943
|
+
return;
|
944
|
+
}
|
945
|
+
|
935
946
|
await onAction(e, action, mergedData);
|
936
947
|
}
|
937
948
|
}
|
@@ -22,7 +22,7 @@ export interface ButtonGroupSchema extends BaseSchema {
|
|
22
22
|
/**
|
23
23
|
* @deprecated 给选中态 Button 配置 className。建议用btnActiveLevel
|
24
24
|
*/
|
25
|
-
btnActiveClassName
|
25
|
+
btnActiveClassName?: string;
|
26
26
|
|
27
27
|
/**
|
28
28
|
* 按钮集合
|
@@ -32,7 +32,7 @@ export interface ButtonGroupSchema extends BaseSchema {
|
|
32
32
|
/**
|
33
33
|
* 按钮样式级别
|
34
34
|
*/
|
35
|
-
btnLevel
|
35
|
+
btnLevel?: string;
|
36
36
|
|
37
37
|
/**
|
38
38
|
* 按钮选中的样式级别
|