amis 1.9.1-beta.12 → 1.9.1-beta.13
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +1 -1
- package/lib/components/formula/Picker.js +1 -2
- package/lib/components/formula/Picker.js.map +2 -2
- package/lib/components/table/HeadCellFilter.js +4 -1
- package/lib/components/table/HeadCellFilter.js.map +2 -2
- package/lib/components/table/HeadCellSort.js +30 -24
- package/lib/components/table/HeadCellSort.js.map +2 -2
- package/lib/components/table/index.d.ts +6 -3
- package/lib/components/table/index.js +72 -86
- package/lib/components/table/index.js.map +2 -2
- package/lib/index.js +1 -1
- package/lib/renderers/Action.d.ts +21 -4
- package/lib/renderers/Action.js +42 -19
- package/lib/renderers/Action.js.map +2 -2
- package/lib/renderers/Breadcrumb.js +2 -2
- package/lib/renderers/Breadcrumb.js.map +2 -2
- package/lib/renderers/Form/Picker.d.ts +1 -1
- package/lib/renderers/Form/Picker.js +38 -23
- package/lib/renderers/Form/Picker.js.map +2 -2
- package/lib/renderers/Form/wrapControl.js +10 -10
- package/lib/renderers/Form/wrapControl.js.map +2 -2
- package/lib/renderers/Service.js +0 -1
- package/lib/renderers/Service.js.map +2 -2
- package/lib/renderers/Steps.d.ts +2 -2
- package/lib/renderers/Steps.js +1 -1
- package/lib/renderers/Steps.js.map +2 -2
- package/lib/renderers/Table-v2/HeadCellSearchDropdown.d.ts +1 -1
- package/lib/renderers/Table-v2/HeadCellSearchDropdown.js +38 -24
- package/lib/renderers/Table-v2/HeadCellSearchDropdown.js.map +2 -2
- package/lib/renderers/Table-v2/index.d.ts +10 -4
- package/lib/renderers/Table-v2/index.js +109 -58
- package/lib/renderers/Table-v2/index.js.map +2 -2
- package/lib/store/table-v2.d.ts +210 -4
- package/lib/store/table-v2.js +82 -5
- package/lib/store/table-v2.js.map +2 -2
- package/lib/themes/ang-ie11.css +14 -11
- package/lib/themes/ang.css +14 -6
- package/lib/themes/ang.css.map +1 -1
- package/lib/themes/antd-ie11.css +14 -11
- package/lib/themes/antd.css +14 -6
- package/lib/themes/antd.css.map +1 -1
- package/lib/themes/cxd-ie11.css +165 -162
- package/lib/themes/cxd.css +15 -7
- package/lib/themes/cxd.css.map +1 -1
- package/lib/themes/dark-ie11.css +14 -11
- package/lib/themes/dark.css +14 -6
- package/lib/themes/dark.css.map +1 -1
- package/lib/themes/default-ie11.css +165 -162
- package/lib/themes/default.css +15 -7
- package/lib/themes/default.css.map +1 -1
- package/lib/types.d.ts +1 -1
- package/lib/types.js.map +1 -1
- package/package.json +1 -1
- package/scss/components/_modal.scss +1 -1
- package/scss/components/form/_icon-picker.scss +10 -6
- package/scss/components/form/_switch.scss +1 -0
- package/scss/components/form/_text.scss +2 -0
- package/scss/themes/_cxd-variables.scss +1 -1
- package/sdk/ang-ie11.css +14 -11
- package/sdk/ang.css +14 -6
- package/sdk/antd-ie11.css +14 -11
- package/sdk/antd.css +14 -6
- 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 +165 -162
- package/sdk/cxd.css +15 -7
- package/sdk/dark-ie11.css +14 -11
- package/sdk/dark.css +14 -6
- package/sdk/exceljs.js +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 +165 -162
- package/sdk/sdk.css +15 -7
- package/sdk/sdk.js +1336 -1336
- 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/components/formula/Picker.tsx +1 -3
- package/src/components/table/HeadCellFilter.tsx +4 -1
- package/src/components/table/HeadCellSort.tsx +1 -1
- package/src/components/table/index.tsx +66 -90
- package/src/renderers/Action.tsx +62 -18
- package/src/renderers/Breadcrumb.tsx +11 -12
- package/src/renderers/Form/Picker.tsx +11 -1
- package/src/renderers/Form/wrapControl.tsx +10 -10
- package/src/renderers/Service.tsx +0 -1
- package/src/renderers/Steps.tsx +5 -5
- package/src/renderers/Table-v2/HeadCellSearchDropdown.tsx +14 -9
- package/src/renderers/Table-v2/index.tsx +130 -58
- package/src/store/table-v2.ts +104 -7
- package/src/types.ts +2 -1
@@ -237,13 +237,11 @@ export class FormulaPicker extends React.Component<
|
|
237
237
|
const {translate: __} = this.props;
|
238
238
|
|
239
239
|
try {
|
240
|
-
|
240
|
+
parse(value, {
|
241
241
|
evalMode: this.props.evalMode,
|
242
242
|
allowFilter: false
|
243
243
|
});
|
244
244
|
|
245
|
-
new Evaluator({}).evalute(ast);
|
246
|
-
|
247
245
|
return true;
|
248
246
|
} catch (e) {
|
249
247
|
if (/\s(\d+:\d+)$/.test(e.message)) {
|
@@ -180,7 +180,10 @@ export class HeadCellFilter extends React.Component<Props, State> {
|
|
180
180
|
const payload = {[column.key]: selectedKeys};
|
181
181
|
|
182
182
|
if (onFilter) {
|
183
|
-
const prevented = await onFilter(
|
183
|
+
const prevented = await onFilter({
|
184
|
+
filterName: column.key,
|
185
|
+
filterValue: selectedKeys?.join(',')
|
186
|
+
});
|
184
187
|
if (prevented) {
|
185
188
|
return;
|
186
189
|
}
|
@@ -10,7 +10,6 @@ import find from 'lodash/find';
|
|
10
10
|
import isEqual from 'lodash/isEqual';
|
11
11
|
import filter from 'lodash/filter';
|
12
12
|
import intersection from 'lodash/intersection';
|
13
|
-
import cloneDeep from 'lodash/cloneDeep';
|
14
13
|
import Sortable from 'sortablejs';
|
15
14
|
|
16
15
|
import {themeable, ClassNamesFn, ThemeProps} from '../../theme';
|
@@ -325,12 +324,15 @@ export class Table extends React.PureComponent<TableProps, TableState> {
|
|
325
324
|
constructor(props: TableProps) {
|
326
325
|
super(props);
|
327
326
|
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
327
|
+
if (props.rowSelection) {
|
328
|
+
const selectedResult = this.getSelectedRows(
|
329
|
+
props.dataSource,
|
330
|
+
props.rowSelection?.selectedRowKeys
|
331
|
+
);
|
332
|
+
|
333
|
+
this.selectedRows = selectedResult.selectedRows;
|
334
|
+
this.unSelectedRows = selectedResult.unSelectedRows;
|
335
|
+
}
|
334
336
|
|
335
337
|
this.state = {
|
336
338
|
selectedRowKeys: props.rowSelection
|
@@ -361,6 +363,8 @@ export class Table extends React.PureComponent<TableProps, TableState> {
|
|
361
363
|
tdColumns: Array<TdProps>;
|
362
364
|
// 表格当前选中行
|
363
365
|
selectedRows: Array<any>;
|
366
|
+
// 表格当前未选中行
|
367
|
+
unSelectedRows: Array<any>;
|
364
368
|
// 拖拽排序
|
365
369
|
sortable: Sortable;
|
366
370
|
// 记录点击起始横坐标
|
@@ -393,6 +397,7 @@ export class Table extends React.PureComponent<TableProps, TableState> {
|
|
393
397
|
selectedRowKeys: Array<string | number>
|
394
398
|
) {
|
395
399
|
const selectedRows: Array<any> = [];
|
400
|
+
const unSelectedRows: Array<any> = [];
|
396
401
|
dataSource.forEach(data => {
|
397
402
|
if (
|
398
403
|
find(
|
@@ -401,10 +406,12 @@ export class Table extends React.PureComponent<TableProps, TableState> {
|
|
401
406
|
)
|
402
407
|
) {
|
403
408
|
selectedRows.push(data);
|
409
|
+
} else {
|
410
|
+
unSelectedRows.push(data);
|
404
411
|
}
|
405
412
|
});
|
406
413
|
|
407
|
-
return selectedRows;
|
414
|
+
return {selectedRows, unSelectedRows};
|
408
415
|
}
|
409
416
|
|
410
417
|
updateTableBodyFixed() {
|
@@ -498,10 +505,12 @@ export class Table extends React.PureComponent<TableProps, TableState> {
|
|
498
505
|
// 选择项发生了变化触发
|
499
506
|
if (!isEqual(prevState.selectedRowKeys, this.state.selectedRowKeys)) {
|
500
507
|
// 更新保存的已选择行数据
|
501
|
-
|
508
|
+
const selectedResult = this.getSelectedRows(
|
502
509
|
this.state.dataSource,
|
503
510
|
this.state.selectedRowKeys
|
504
511
|
);
|
512
|
+
this.selectedRows = selectedResult.selectedRows;
|
513
|
+
this.unSelectedRows = selectedResult.unSelectedRows;
|
505
514
|
|
506
515
|
const {rowSelection} = this.props;
|
507
516
|
rowSelection &&
|
@@ -526,10 +535,12 @@ export class Table extends React.PureComponent<TableProps, TableState> {
|
|
526
535
|
this.setState({
|
527
536
|
selectedRowKeys: this.props.rowSelection.selectedRowKeys
|
528
537
|
});
|
529
|
-
|
538
|
+
const selectedResult = this.getSelectedRows(
|
530
539
|
this.state.dataSource,
|
531
540
|
this.state.selectedRowKeys
|
532
541
|
);
|
542
|
+
this.selectedRows = selectedResult.selectedRows;
|
543
|
+
this.unSelectedRows = selectedResult.unSelectedRows;
|
533
544
|
}
|
534
545
|
}
|
535
546
|
|
@@ -599,37 +610,6 @@ export class Table extends React.PureComponent<TableProps, TableState> {
|
|
599
610
|
this.destroyDragging();
|
600
611
|
}
|
601
612
|
|
602
|
-
exchange(fromIndex: number, toIndex: number, item: any) {
|
603
|
-
const {scroll, headSummary} = this.props;
|
604
|
-
// 如果有头部总结行 fromIndex就会+1
|
605
|
-
if ((!scroll || (scroll && !scroll.y)) && headSummary) {
|
606
|
-
fromIndex = fromIndex - 1;
|
607
|
-
}
|
608
|
-
|
609
|
-
const index = toIndex - fromIndex;
|
610
|
-
|
611
|
-
const levels = item.getAttribute('row-levels');
|
612
|
-
const rowIndex = +item.getAttribute('row-index');
|
613
|
-
|
614
|
-
const dataSource = cloneDeep(this.state.dataSource);
|
615
|
-
const levelsArray = levels ? levels.split(',') : [];
|
616
|
-
const childrenColumnName = this.getChildrenColumnName();
|
617
|
-
let data: Array<any> = dataSource;
|
618
|
-
let i = 0;
|
619
|
-
while (i < levelsArray.length) {
|
620
|
-
data = data[levelsArray[i]][childrenColumnName];
|
621
|
-
i++;
|
622
|
-
}
|
623
|
-
|
624
|
-
if (data && data.length > 0) {
|
625
|
-
const row = cloneDeep(data[rowIndex]);
|
626
|
-
data.splice(rowIndex, 1);
|
627
|
-
data.splice(rowIndex + index, 0, row);
|
628
|
-
}
|
629
|
-
|
630
|
-
return data;
|
631
|
-
}
|
632
|
-
|
633
613
|
initDragging() {
|
634
614
|
const {classnames: cx, onDrag} = this.props;
|
635
615
|
|
@@ -666,14 +646,9 @@ export class Table extends React.PureComponent<TableProps, TableState> {
|
|
666
646
|
return;
|
667
647
|
}
|
668
648
|
|
669
|
-
const
|
670
|
-
|
671
|
-
|
672
|
-
const prevented = await onDrag(data);
|
673
|
-
if (prevented) {
|
674
|
-
return;
|
675
|
-
}
|
676
|
-
}
|
649
|
+
const rowLevels = e.item.getAttribute('row-levels');
|
650
|
+
|
651
|
+
onDrag && onDrag(e.oldIndex, e.newIndex, rowLevels ? rowLevels.split(',') : []);
|
677
652
|
}
|
678
653
|
});
|
679
654
|
}
|
@@ -1037,9 +1012,8 @@ export class Table extends React.PureComponent<TableProps, TableState> {
|
|
1037
1012
|
const selectedRowKeys = value ? allRowKeys : [];
|
1038
1013
|
if (onSelectAll) {
|
1039
1014
|
const prevented = await onSelectAll(
|
1040
|
-
value,
|
1041
|
-
selectedRowKeys,
|
1042
1015
|
selectedRows,
|
1016
|
+
value ? [] : selectedRows,
|
1043
1017
|
changeRows
|
1044
1018
|
);
|
1045
1019
|
if (prevented) {
|
@@ -1152,9 +1126,16 @@ export class Table extends React.PureComponent<TableProps, TableState> {
|
|
1152
1126
|
);
|
1153
1127
|
}
|
1154
1128
|
|
1155
|
-
onRowClick(event: React.ChangeEvent<any>, record?: any, rowIndex?: number) {
|
1129
|
+
async onRowClick(event: React.ChangeEvent<any>, record?: any, rowIndex?: number) {
|
1156
1130
|
const {rowSelection, onRow} = this.props;
|
1157
1131
|
|
1132
|
+
if (onRow && onRow.onRowClick) {
|
1133
|
+
const prevented = await onRow.onRowClick(event, record, rowIndex);
|
1134
|
+
if (prevented) {
|
1135
|
+
return;
|
1136
|
+
}
|
1137
|
+
}
|
1138
|
+
|
1158
1139
|
if (rowSelection && rowSelection.type && rowSelection.rowClick) {
|
1159
1140
|
const defaultKey = this.getRowSelectionKeyField();
|
1160
1141
|
|
@@ -1165,10 +1146,6 @@ export class Table extends React.PureComponent<TableProps, TableState> {
|
|
1165
1146
|
|
1166
1147
|
this.selectedSingleRow(!isSelected, record);
|
1167
1148
|
}
|
1168
|
-
|
1169
|
-
if (record && onRow) {
|
1170
|
-
onRow.onRowClick && onRow.onRowClick(event, record, rowIndex);
|
1171
|
-
}
|
1172
1149
|
}
|
1173
1150
|
|
1174
1151
|
onRowMouseEnter(
|
@@ -1350,42 +1327,41 @@ export class Table extends React.PureComponent<TableProps, TableState> {
|
|
1350
1327
|
const defaultKey = this.getRowSelectionKeyField();
|
1351
1328
|
const isRadio = rowSelection && rowSelection.type === 'radio';
|
1352
1329
|
|
1353
|
-
|
1354
|
-
const prevented = await onSelect(
|
1355
|
-
data,
|
1356
|
-
value,
|
1357
|
-
this.selectedRows,
|
1358
|
-
this.state.selectedRowKeys
|
1359
|
-
);
|
1360
|
-
if (prevented) {
|
1361
|
-
return;
|
1362
|
-
}
|
1363
|
-
}
|
1364
|
-
|
1330
|
+
let selectedRowKeys = [];
|
1365
1331
|
if (value) {
|
1366
1332
|
if (isRadio) {
|
1367
|
-
|
1333
|
+
selectedRowKeys = [data[defaultKey]];
|
1368
1334
|
} else {
|
1369
|
-
|
1370
|
-
selectedRowKeys
|
1371
|
-
|
1372
|
-
|
1373
|
-
|
1374
|
-
].filter((key, i, a) => a.indexOf(key) === i)
|
1375
|
-
}));
|
1335
|
+
selectedRowKeys = [
|
1336
|
+
...this.state.selectedRowKeys,
|
1337
|
+
data[defaultKey],
|
1338
|
+
...this.getDataChildrenKeys(data)
|
1339
|
+
].filter((key, i, a) => a.indexOf(key) === i)
|
1376
1340
|
}
|
1377
1341
|
} else {
|
1378
1342
|
if (!isRadio) {
|
1379
|
-
this.
|
1380
|
-
|
1381
|
-
|
1382
|
-
|
1383
|
-
|
1384
|
-
|
1385
|
-
|
1386
|
-
|
1343
|
+
selectedRowKeys = this.state.selectedRowKeys.filter(
|
1344
|
+
key =>
|
1345
|
+
![data[defaultKey], ...this.getDataChildrenKeys(data)].includes(
|
1346
|
+
key
|
1347
|
+
)
|
1348
|
+
)
|
1349
|
+
}
|
1350
|
+
}
|
1351
|
+
|
1352
|
+
if (onSelect) {
|
1353
|
+
const selectedResult = this.getSelectedRows(this.state.dataSource, selectedRowKeys);
|
1354
|
+
const prevented = await onSelect(
|
1355
|
+
selectedResult.selectedRows,
|
1356
|
+
selectedRowKeys,
|
1357
|
+
selectedResult.unSelectedRows
|
1358
|
+
);
|
1359
|
+
if (prevented) {
|
1360
|
+
return;
|
1387
1361
|
}
|
1388
1362
|
}
|
1363
|
+
|
1364
|
+
this.setState({selectedRowKeys});
|
1389
1365
|
}
|
1390
1366
|
|
1391
1367
|
renderRow(data: any, rowIndex: number, levels: Array<number>) {
|
@@ -1396,6 +1372,7 @@ export class Table extends React.PureComponent<TableProps, TableState> {
|
|
1396
1372
|
draggable,
|
1397
1373
|
indentSize,
|
1398
1374
|
rowClassName,
|
1375
|
+
keyField,
|
1399
1376
|
lineHeight // 是否设置了固定行高
|
1400
1377
|
} = this.props;
|
1401
1378
|
|
@@ -1515,10 +1492,11 @@ export class Table extends React.PureComponent<TableProps, TableState> {
|
|
1515
1492
|
key => key === data[defaultKey]
|
1516
1493
|
);
|
1517
1494
|
const hasChildrenChecked = this.hasCheckedChildrenRows(data);
|
1495
|
+
const isRadio = rowSelection && rowSelection.type === 'radio';
|
1518
1496
|
|
1519
1497
|
return [
|
1520
1498
|
<tr
|
1521
|
-
key={rowIndex}
|
1499
|
+
key={`${data[keyField || 'key'] || rowIndex}`} // 可能会拖拽排序,就不能用rowIndex作为key了,否则显示会有问题
|
1522
1500
|
row-index={rowIndex}
|
1523
1501
|
row-levels={levels.join(',')}
|
1524
1502
|
className={cx(
|
@@ -1546,8 +1524,8 @@ export class Table extends React.PureComponent<TableProps, TableState> {
|
|
1546
1524
|
<CheckBox
|
1547
1525
|
name={'Table-checkbox'}
|
1548
1526
|
type={rowSelection.type || 'checkbox'}
|
1549
|
-
partial={hasChildrenChecked && !isChecked}
|
1550
|
-
checked={hasChildrenChecked || isChecked}
|
1527
|
+
partial={!isRadio && hasChildrenChecked && !isChecked}
|
1528
|
+
checked={isRadio ? isChecked : (hasChildrenChecked || isChecked)}
|
1551
1529
|
onChange={(value, shift) => {
|
1552
1530
|
if (!(rowSelection && rowSelection.rowClick)) {
|
1553
1531
|
this.selectedSingleRow(value, data);
|
@@ -1603,9 +1581,7 @@ export class Table extends React.PureComponent<TableProps, TableState> {
|
|
1603
1581
|
</Cell>
|
1604
1582
|
</tr>
|
1605
1583
|
) : (
|
1606
|
-
this.state.dataSource.map((data, index) =>
|
1607
|
-
return this.renderRow(data, index, []);
|
1608
|
-
})
|
1584
|
+
this.state.dataSource.map((data, index) => this.renderRow(data, index, []))
|
1609
1585
|
)}
|
1610
1586
|
</tbody>
|
1611
1587
|
);
|
package/src/renderers/Action.tsx
CHANGED
@@ -1,10 +1,15 @@
|
|
1
1
|
import React from 'react';
|
2
2
|
import hotkeys from 'hotkeys-js';
|
3
|
+
import omit from 'lodash/omit';
|
4
|
+
import pick from 'lodash/pick';
|
3
5
|
import {Renderer, RendererProps} from '../factory';
|
4
6
|
import {filter} from '../utils/tpl';
|
5
7
|
import Button from '../components/Button';
|
6
|
-
import
|
7
|
-
import
|
8
|
+
import {ScopedContext} from '../Scoped';
|
9
|
+
import {isObject} from '../utils/helper';
|
10
|
+
|
11
|
+
import type {IScopedContext} from '../Scoped';
|
12
|
+
import type {Action as ICmptAction} from '../types';
|
8
13
|
|
9
14
|
export interface ButtonSchema extends BaseSchema {
|
10
15
|
/**
|
@@ -431,7 +436,6 @@ import {generateIcon} from '../utils/icon';
|
|
431
436
|
import {BadgeSchema, withBadge} from '../components/Badge';
|
432
437
|
import {normalizeApi, str2AsyncFunction} from '../utils/api';
|
433
438
|
import {TooltipWrapper} from '../components/TooltipWrapper';
|
434
|
-
import handleAction from '../utils/handleAction';
|
435
439
|
|
436
440
|
// 构造一个假的 React 事件避免可能的报错,主要用于快捷键功能
|
437
441
|
// 来自 https://stackoverflow.com/questions/27062455/reactjs-can-i-create-my-own-syntheticevent
|
@@ -851,28 +855,68 @@ export class Action extends React.Component<ActionProps, ActionState> {
|
|
851
855
|
|
852
856
|
export default themeable(Action);
|
853
857
|
|
858
|
+
export type ActionRendererProps = RendererProps &
|
859
|
+
Omit<ActionProps, 'onAction' | 'isCurrentUrl' | 'tooltipContainer'> & {
|
860
|
+
onAction: (
|
861
|
+
e: React.MouseEvent<any> | string | void | null,
|
862
|
+
action: object,
|
863
|
+
data: any
|
864
|
+
) => void;
|
865
|
+
btnDisabled?: boolean;
|
866
|
+
};
|
867
|
+
|
854
868
|
@Renderer({
|
855
869
|
type: 'action'
|
856
870
|
})
|
857
871
|
// @ts-ignore 类型没搞定
|
858
872
|
@withBadge
|
859
|
-
export class ActionRenderer extends React.Component<
|
860
|
-
|
861
|
-
|
862
|
-
|
863
|
-
|
864
|
-
|
865
|
-
|
866
|
-
|
867
|
-
|
873
|
+
export class ActionRenderer extends React.Component<ActionRendererProps> {
|
874
|
+
static contextType = ScopedContext;
|
875
|
+
|
876
|
+
constructor(props: ActionRendererProps, scoped: IScopedContext) {
|
877
|
+
super(props);
|
878
|
+
|
879
|
+
scoped.registerComponent(this);
|
880
|
+
}
|
881
|
+
|
882
|
+
componentWillUnmount() {
|
883
|
+
const scoped = this.context as IScopedContext;
|
884
|
+
scoped.unRegisterComponent(this);
|
885
|
+
}
|
886
|
+
|
887
|
+
/**
|
888
|
+
* 动作处理
|
889
|
+
*/
|
890
|
+
doAction(
|
891
|
+
action: ICmptAction,
|
892
|
+
args: {
|
893
|
+
value?: string | {[key: string]: string};
|
894
|
+
}
|
895
|
+
) {
|
896
|
+
const actionType = action?.actionType;
|
897
|
+
|
898
|
+
if (actionType === 'click') {
|
899
|
+
this.handleAction(actionType, action);
|
868
900
|
}
|
869
|
-
|
901
|
+
}
|
902
|
+
|
870
903
|
@autobind
|
871
|
-
async handleAction(
|
904
|
+
async handleAction(
|
905
|
+
e: React.MouseEvent<any> | string | void | null,
|
906
|
+
action: any
|
907
|
+
) {
|
872
908
|
const {env, onAction, data, ignoreConfirm, dispatchEvent} = this.props;
|
909
|
+
let mergedData = data;
|
910
|
+
|
911
|
+
if (action?.actionType === 'click' && isObject(action?.args)) {
|
912
|
+
mergedData = createObject(data, action.args);
|
913
|
+
}
|
873
914
|
|
874
915
|
// 触发渲染器事件
|
875
|
-
const rendererEvent = await dispatchEvent(
|
916
|
+
const rendererEvent = await dispatchEvent(
|
917
|
+
e as React.MouseEvent<any> | string,
|
918
|
+
mergedData
|
919
|
+
);
|
876
920
|
|
877
921
|
// 阻止原有动作执行
|
878
922
|
if (rendererEvent?.prevented) {
|
@@ -880,14 +924,14 @@ export class ActionRenderer extends React.Component<
|
|
880
924
|
}
|
881
925
|
|
882
926
|
if (!ignoreConfirm && action.confirmText && env.confirm) {
|
883
|
-
let confirmed = await env.confirm(filter(action.confirmText,
|
927
|
+
let confirmed = await env.confirm(filter(action.confirmText, mergedData));
|
884
928
|
if (confirmed) {
|
885
|
-
await onAction(e, action,
|
929
|
+
await onAction(e, action, mergedData);
|
886
930
|
} else if (action.countDown) {
|
887
931
|
throw new Error('cancel');
|
888
932
|
}
|
889
933
|
} else {
|
890
|
-
await onAction(e, action,
|
934
|
+
await onAction(e, action, mergedData);
|
891
935
|
}
|
892
936
|
}
|
893
937
|
|
@@ -56,7 +56,7 @@ export type ItemPlace = 'start' | 'middle' | 'end';
|
|
56
56
|
* 文档:https://baidu.gitee.io/amis/docs/components/breadcrumb
|
57
57
|
*/
|
58
58
|
|
59
|
-
|
59
|
+
export interface BreadcrumbSchema extends BaseSchema {
|
60
60
|
/**
|
61
61
|
* 指定为面包屑显示控件
|
62
62
|
*/
|
@@ -103,18 +103,13 @@ export type ItemPlace = 'start' | 'middle' | 'end';
|
|
103
103
|
tooltipPosition?: TooltipPositionType;
|
104
104
|
}
|
105
105
|
|
106
|
-
export interface BreadcrumbProps
|
107
|
-
|
106
|
+
export interface BreadcrumbProps
|
107
|
+
extends RendererProps,
|
108
|
+
Omit<BreadcrumbSchema, 'type' | 'className'> {}
|
108
109
|
|
109
110
|
export class BreadcrumbField extends React.Component<BreadcrumbProps, object> {
|
110
111
|
render() {
|
111
|
-
const {
|
112
|
-
items,
|
113
|
-
source,
|
114
|
-
data,
|
115
|
-
env,
|
116
|
-
...restProps
|
117
|
-
} = this.props;
|
112
|
+
const {items, source, data, env, ...restProps} = this.props;
|
118
113
|
|
119
114
|
let crumbItems = items
|
120
115
|
? items
|
@@ -128,7 +123,7 @@ export class BreadcrumbField extends React.Component<BreadcrumbProps, object> {
|
|
128
123
|
item.label = filter(item.label, data);
|
129
124
|
}
|
130
125
|
if (item.href) {
|
131
|
-
item.href =
|
126
|
+
item.href = resolveVariableAndFilter(item.href, data, '| raw');
|
132
127
|
}
|
133
128
|
if (item.dropdown) {
|
134
129
|
item.dropdown = item.dropdown.map(dropdownItem => {
|
@@ -136,7 +131,11 @@ export class BreadcrumbField extends React.Component<BreadcrumbProps, object> {
|
|
136
131
|
dropdownItem.label = filter(dropdownItem.label, data);
|
137
132
|
}
|
138
133
|
if (dropdownItem.href) {
|
139
|
-
dropdownItem.href =
|
134
|
+
dropdownItem.href = resolveVariableAndFilter(
|
135
|
+
dropdownItem.href,
|
136
|
+
data,
|
137
|
+
'| raw'
|
138
|
+
);
|
140
139
|
}
|
141
140
|
return dropdownItem;
|
142
141
|
});
|
@@ -247,7 +247,7 @@ export default class PickerControl extends React.PureComponent<
|
|
247
247
|
}
|
248
248
|
|
249
249
|
@autobind
|
250
|
-
handleChange(items: Array<any>) {
|
250
|
+
async handleChange(items: Array<any>) {
|
251
251
|
const {
|
252
252
|
joinValues,
|
253
253
|
valueField,
|
@@ -255,6 +255,8 @@ export default class PickerControl extends React.PureComponent<
|
|
255
255
|
extractValue,
|
256
256
|
multiple,
|
257
257
|
options,
|
258
|
+
data,
|
259
|
+
dispatchEvent,
|
258
260
|
setOptions,
|
259
261
|
onChange
|
260
262
|
} = this.props;
|
@@ -286,6 +288,14 @@ export default class PickerControl extends React.PureComponent<
|
|
286
288
|
});
|
287
289
|
|
288
290
|
additionalOptions.length && setOptions(options.concat(additionalOptions));
|
291
|
+
const rendererEvent = await dispatchEvent(
|
292
|
+
'change',
|
293
|
+
createObject(data, {value, option: items[0]})
|
294
|
+
);
|
295
|
+
if (rendererEvent?.prevented) {
|
296
|
+
return;
|
297
|
+
}
|
298
|
+
|
289
299
|
onChange(value);
|
290
300
|
}
|
291
301
|
|
@@ -327,7 +327,7 @@ export function wrapControl<
|
|
327
327
|
// 此处需要同时考虑 defaultValue 和 value
|
328
328
|
if (model && typeof props.value !== 'undefined') {
|
329
329
|
// 渲染器中的 value 优先
|
330
|
-
if (props.value
|
330
|
+
if (!isEqual(props.value, prevProps.value) && !isEqual(props.value, model.tmpValue)) {
|
331
331
|
// 外部直接传入的 value 无需执行运算器
|
332
332
|
model.changeTmpValue(props.value);
|
333
333
|
}
|
@@ -338,7 +338,7 @@ export function wrapControl<
|
|
338
338
|
) {
|
339
339
|
// 渲染器中的 defaultValue 优先(备注: SchemaRenderer中会将 value 改成 defaultValue)
|
340
340
|
if (
|
341
|
-
props.defaultValue
|
341
|
+
!isEqual(props.defaultValue, prevProps.defaultValue) ||
|
342
342
|
(!isEqual(props.data, prevProps.data) &&
|
343
343
|
isNeedFormula(props.defaultValue, props.data, prevProps.data))
|
344
344
|
) {
|
@@ -350,7 +350,7 @@ export function wrapControl<
|
|
350
350
|
prevProps.defaultValue,
|
351
351
|
prevProps.data
|
352
352
|
);
|
353
|
-
if (curResult
|
353
|
+
if (!isEqual(curResult, prevResult) && !isEqual(curResult, model.tmpValue)) {
|
354
354
|
// 识别上下文变动、自身数值变动、公式运算结果变动
|
355
355
|
model.changeTmpValue(curResult);
|
356
356
|
if (props.onChange) {
|
@@ -363,29 +363,29 @@ export function wrapControl<
|
|
363
363
|
|
364
364
|
if (
|
365
365
|
valueByName !== undefined &&
|
366
|
-
props.defaultValue
|
366
|
+
isEqual(props.defaultValue, prevProps.defaultValue)
|
367
367
|
) {
|
368
368
|
// value 非公式表达式时,name 值优先,若 defaultValue 主动变动时,则使用 defaultValue
|
369
369
|
if (
|
370
370
|
// 然后才是查看关联的 name 属性值是否变化
|
371
|
-
props.data
|
372
|
-
(!model.emitedValue || model.emitedValue
|
371
|
+
!isEqual(props.data, prevProps.data) &&
|
372
|
+
(!model.emitedValue || isEqual(model.emitedValue, model.tmpValue))
|
373
373
|
) {
|
374
374
|
model.changeEmitedValue(undefined);
|
375
375
|
const prevValueByName = getVariable(props.data, model.name);
|
376
376
|
if (
|
377
|
-
(valueByName
|
377
|
+
(!isEqual(valueByName, prevValueByName) ||
|
378
378
|
getVariable(props.data, model.name, false) !==
|
379
379
|
getVariable(prevProps.data, model.name, false)) &&
|
380
|
-
|
380
|
+
!isEqual(valueByName, model.tmpValue)
|
381
381
|
) {
|
382
382
|
model.changeTmpValue(valueByName);
|
383
383
|
}
|
384
384
|
}
|
385
385
|
} else if (
|
386
386
|
typeof props.defaultValue !== 'undefined' &&
|
387
|
-
props.defaultValue
|
388
|
-
props.defaultValue
|
387
|
+
!isEqual(props.defaultValue, prevProps.defaultValue) &&
|
388
|
+
!isEqual(props.defaultValue, model.tmpValue)
|
389
389
|
) {
|
390
390
|
// 组件默认值非公式
|
391
391
|
const curValue = replaceExpression(props.defaultValue);
|
package/src/renderers/Steps.tsx
CHANGED
@@ -6,7 +6,7 @@ import {
|
|
6
6
|
RemoteOptionsProps,
|
7
7
|
withRemoteConfig
|
8
8
|
} from '../components/WithRemoteConfig';
|
9
|
-
import {resolveVariable} from '../utils/tpl-builtin';
|
9
|
+
import {resolveVariable, resolveVariableAndFilter} from '../utils/tpl-builtin';
|
10
10
|
import {filter} from '../utils/tpl';
|
11
11
|
import {getPropValue} from '../utils/helper';
|
12
12
|
|
@@ -74,12 +74,12 @@ export interface StepsSchema extends BaseSchema {
|
|
74
74
|
/**
|
75
75
|
* 标签放置位置
|
76
76
|
*/
|
77
|
-
|
77
|
+
labelPlacement?: 'horizontal' | 'vertical';
|
78
78
|
|
79
|
-
|
79
|
+
/**
|
80
80
|
* 点状步骤条
|
81
81
|
*/
|
82
|
-
|
82
|
+
progressDot?: boolean;
|
83
83
|
}
|
84
84
|
|
85
85
|
export interface StepsProps
|
@@ -102,7 +102,7 @@ export function StepsCmpt(props: StepsProps) {
|
|
102
102
|
} = props;
|
103
103
|
|
104
104
|
const stepsRow =
|
105
|
-
(
|
105
|
+
(resolveVariableAndFilter(source, data, '| raw') as Array<StepSchema>) ||
|
106
106
|
config ||
|
107
107
|
steps ||
|
108
108
|
[];
|