amis 1.6.5-beta.3 → 1.8.0-beta.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/lib/Schema.d.ts +3 -2
- package/lib/Schema.js +0 -1
- package/lib/Schema.js.map +2 -2
- package/lib/components/Alert2.js +4 -2
- package/lib/components/Alert2.js.map +2 -2
- package/lib/components/AssociatedSelection.d.ts +84 -84
- package/lib/components/Avatar.d.ts +20 -20
- package/lib/components/Breadcrumb.d.ts +130 -0
- package/lib/components/Breadcrumb.js +161 -0
- package/lib/components/Breadcrumb.js.map +13 -0
- package/lib/components/Card.d.ts +20 -20
- package/lib/components/ChainedSelection.d.ts +84 -84
- package/lib/components/CityArea.js +3 -0
- package/lib/components/CityArea.js.map +2 -2
- package/lib/components/Collapse.d.ts +20 -20
- package/lib/components/CollapseGroup.d.ts +20 -20
- package/lib/components/DatePicker.d.ts +84 -84
- package/lib/components/DateRangePicker.d.ts +2 -2
- package/lib/components/DateRangePicker.js +36 -45
- package/lib/components/DateRangePicker.js.map +2 -2
- package/lib/components/GroupedSelection.d.ts +84 -84
- package/lib/components/Layout.d.ts +21 -21
- package/lib/components/ListGroup.d.ts +21 -21
- package/lib/components/PopUp.js +2 -1
- package/lib/components/PopUp.js.map +2 -2
- package/lib/components/Radios.d.ts +21 -21
- package/lib/components/Range.js.map +2 -2
- package/lib/components/Selection.d.ts +84 -84
- package/lib/components/TableSelection.d.ts +84 -84
- package/lib/components/Tabs.d.ts +52 -23
- package/lib/components/Tabs.js +198 -46
- package/lib/components/Tabs.js.map +2 -2
- package/lib/components/TooltipWrapper.d.ts +21 -20
- package/lib/components/TooltipWrapper.js +2 -2
- package/lib/components/TooltipWrapper.js.map +2 -2
- package/lib/components/Transfer.d.ts +84 -84
- package/lib/components/TransferDropDown.d.ts +84 -84
- package/lib/components/Tree.d.ts +84 -84
- package/lib/components/TreeSelection.d.ts +84 -84
- package/lib/components/calendar/Calendar.js +5 -0
- package/lib/components/calendar/Calendar.js.map +2 -2
- package/lib/components/calendar/DaysView.js.map +1 -1
- package/lib/components/icons.js +8 -0
- package/lib/components/icons.js.map +2 -2
- package/lib/components/index.d.ts +2 -1
- package/lib/components/index.js +4 -2
- package/lib/components/index.js.map +2 -2
- package/lib/icons/cloud-upload.js +17 -0
- package/lib/icons/image.js +7 -0
- package/lib/icons/refresh.js +9 -0
- package/lib/icons/trash.js +10 -0
- package/lib/icons/upload.js +3 -8
- package/lib/index.d.ts +1 -0
- package/lib/index.js +2 -1
- package/lib/index.js.map +2 -2
- package/lib/locale/en-US.js +3 -1
- package/lib/locale/en-US.js.map +2 -2
- package/lib/locale/zh-CN.js +4 -2
- package/lib/locale/zh-CN.js.map +2 -2
- package/lib/renderers/Action.d.ts +1 -1
- package/lib/renderers/Action.js.map +2 -2
- package/lib/renderers/Breadcrumb.d.ts +41 -6
- package/lib/renderers/Breadcrumb.js +23 -19
- package/lib/renderers/Breadcrumb.js.map +2 -2
- package/lib/renderers/ButtonGroup.d.ts +2 -2
- package/lib/renderers/ButtonGroup.js.map +1 -1
- package/lib/renderers/Form/ChainedSelect.d.ts +4 -1
- package/lib/renderers/Form/ChainedSelect.js +83 -34
- package/lib/renderers/Form/ChainedSelect.js.map +2 -2
- package/lib/renderers/Form/Checkbox.d.ts +3 -0
- package/lib/renderers/Form/Checkbox.js +38 -1
- package/lib/renderers/Form/Checkbox.js.map +2 -2
- package/lib/renderers/Form/Combo.d.ts +4 -3
- package/lib/renderers/Form/Combo.js +81 -32
- package/lib/renderers/Form/Combo.js.map +2 -2
- package/lib/renderers/Form/DiffEditor.d.ts +1 -1
- package/lib/renderers/Form/InputCity.d.ts +84 -84
- package/lib/renderers/Form/InputCity.js +4 -1
- package/lib/renderers/Form/InputCity.js.map +2 -2
- package/lib/renderers/Form/InputColor.js +3 -1
- package/lib/renderers/Form/InputColor.js.map +2 -2
- package/lib/renderers/Form/InputDate.js +3 -1
- package/lib/renderers/Form/InputDate.js.map +2 -2
- package/lib/renderers/Form/InputDateRange.js +3 -1
- package/lib/renderers/Form/InputDateRange.js.map +2 -2
- package/lib/renderers/Form/InputExcel.d.ts +4 -0
- package/lib/renderers/Form/InputExcel.js +33 -6
- package/lib/renderers/Form/InputExcel.js.map +2 -2
- package/lib/renderers/Form/InputFile.d.ts +8 -1
- package/lib/renderers/Form/InputFile.js +71 -42
- package/lib/renderers/Form/InputFile.js.map +2 -2
- package/lib/renderers/Form/InputImage.d.ts +4 -1
- package/lib/renderers/Form/InputImage.js +21 -9
- package/lib/renderers/Form/InputImage.js.map +2 -2
- package/lib/renderers/Form/InputRange.d.ts +27 -9
- package/lib/renderers/Form/InputRange.js +88 -23
- package/lib/renderers/Form/InputRange.js.map +2 -2
- package/lib/renderers/Form/InputSubForm.js +2 -1
- package/lib/renderers/Form/InputSubForm.js.map +2 -2
- package/lib/renderers/Form/InputTag.js +2 -1
- package/lib/renderers/Form/InputTag.js.map +2 -2
- package/lib/renderers/Form/MatrixCheckboxes.js +2 -1
- package/lib/renderers/Form/MatrixCheckboxes.js.map +2 -2
- package/lib/renderers/Form/NestedSelect.d.ts +9 -6
- package/lib/renderers/Form/NestedSelect.js +247 -130
- package/lib/renderers/Form/NestedSelect.js.map +2 -2
- package/lib/renderers/Form/Options.js +2 -1
- package/lib/renderers/Form/Options.js.map +2 -2
- package/lib/renderers/Form/Radios.js +2 -1
- package/lib/renderers/Form/Radios.js.map +2 -2
- package/lib/renderers/Form/Select.js +6 -3
- package/lib/renderers/Form/Select.js.map +2 -2
- package/lib/renderers/Form/Switch.d.ts +7 -6
- package/lib/renderers/Form/Switch.js +4 -1
- package/lib/renderers/Form/Switch.js.map +2 -2
- package/lib/renderers/Log.js +2 -1
- package/lib/renderers/Log.js.map +2 -2
- package/lib/renderers/PopOver.js +1 -1
- package/lib/renderers/PopOver.js.map +2 -2
- package/lib/renderers/Tabs.d.ts +58 -5
- package/lib/renderers/Tabs.js +170 -58
- package/lib/renderers/Tabs.js.map +2 -2
- package/lib/renderers/TooltipWrapper.d.ts +104 -0
- package/lib/renderers/TooltipWrapper.js +59 -0
- package/lib/renderers/TooltipWrapper.js.map +13 -0
- package/lib/renderers/Video.d.ts +6 -0
- package/lib/renderers/Video.js +13 -6
- package/lib/renderers/Video.js.map +2 -2
- package/lib/store/form.js +4 -13
- package/lib/store/form.js.map +2 -2
- package/lib/store/table.js +1 -1
- package/lib/store/table.js.map +2 -2
- package/lib/themes/ang-ie11.css +742 -160
- package/lib/themes/ang.css +793 -163
- package/lib/themes/ang.css.map +1 -1
- package/lib/themes/antd-ie11.css +757 -175
- package/lib/themes/antd.css +793 -163
- package/lib/themes/antd.css.map +1 -1
- package/lib/themes/cxd-ie11.css +1249 -667
- package/lib/themes/cxd.css +970 -321
- package/lib/themes/cxd.css.map +1 -1
- package/lib/themes/dark-ie11.css +742 -160
- package/lib/themes/dark.css +793 -163
- package/lib/themes/dark.css.map +1 -1
- package/lib/themes/default-ie11.css +1249 -667
- package/lib/themes/default.css +970 -321
- package/lib/themes/default.css.map +1 -1
- package/package.json +1 -1
- package/schema.json +16012 -736
- package/scss/_properties.scss +56 -2
- package/scss/components/_alert.scss +1 -1
- package/scss/components/_breadcrumb.scss +90 -1
- package/scss/components/_button-group.scss +15 -0
- package/scss/components/_city-area.scss +2 -0
- package/scss/components/_popup.scss +13 -3
- package/scss/components/_tabs.scss +629 -132
- package/scss/components/_tooltip.scss +72 -0
- package/scss/components/form/_file.scss +82 -24
- package/scss/components/form/_image.scss +30 -25
- package/scss/components/form/_number.scss +2 -0
- package/scss/components/form/_switch.scss +1 -3
- package/scss/themes/_cxd-colors.scss +47 -47
- package/scss/themes/_cxd-variables.scss +20 -0
- package/sdk/ang-ie11.css +879 -196
- package/sdk/ang.css +931 -200
- package/sdk/antd-ie11.css +951 -268
- package/sdk/antd.css +931 -200
- 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 +1386 -703
- package/sdk/cxd.css +1107 -357
- package/sdk/dark-ie11.css +879 -196
- package/sdk/dark.css +931 -200
- 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 +17 -17
- package/sdk/rich-text.js +62 -62
- package/sdk/sdk-ie11.css +1386 -703
- package/sdk/sdk.css +1107 -357
- package/sdk/sdk.js +1260 -1248
- 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 +5 -2
- package/src/components/Alert2.tsx +9 -3
- package/src/components/Breadcrumb.tsx +294 -0
- package/src/components/CityArea.tsx +3 -0
- package/src/components/DateRangePicker.tsx +40 -68
- package/src/components/PopUp.tsx +6 -5
- package/src/components/Range.tsx +7 -1
- package/src/components/Tabs.tsx +300 -54
- package/src/components/TooltipWrapper.tsx +4 -1
- package/src/components/calendar/Calendar.tsx +5 -0
- package/src/components/calendar/DaysView.tsx +2 -2
- package/src/components/icons.tsx +8 -0
- package/src/components/index.tsx +2 -0
- package/src/icons/cloud-upload.svg +22 -0
- package/src/icons/image.svg +1 -0
- package/src/icons/refresh.svg +7 -0
- package/src/icons/trash.svg +8 -0
- package/src/icons/upload.svg +4 -9
- package/src/index.tsx +1 -0
- package/src/locale/en-US.ts +3 -1
- package/src/locale/zh-CN.ts +4 -2
- package/src/renderers/Action.tsx +2 -1
- package/src/renderers/Breadcrumb.tsx +89 -45
- package/src/renderers/ButtonGroup.tsx +2 -2
- package/src/renderers/Form/ChainedSelect.tsx +56 -12
- package/src/renderers/Form/Checkbox.tsx +30 -1
- package/src/renderers/Form/Combo.tsx +84 -26
- package/src/renderers/Form/InputCity.tsx +13 -1
- package/src/renderers/Form/InputColor.tsx +2 -0
- package/src/renderers/Form/InputDate.tsx +2 -0
- package/src/renderers/Form/InputDateRange.tsx +2 -0
- package/src/renderers/Form/InputExcel.tsx +27 -5
- package/src/renderers/Form/InputFile.tsx +167 -115
- package/src/renderers/Form/InputImage.tsx +61 -35
- package/src/renderers/Form/InputRange.tsx +95 -40
- package/src/renderers/Form/InputSubForm.tsx +2 -1
- package/src/renderers/Form/InputTag.tsx +3 -1
- package/src/renderers/Form/MatrixCheckboxes.tsx +3 -1
- package/src/renderers/Form/NestedSelect.tsx +75 -26
- package/src/renderers/Form/Options.tsx +3 -1
- package/src/renderers/Form/Radios.tsx +3 -1
- package/src/renderers/Form/Select.tsx +6 -2
- package/src/renderers/Form/Switch.tsx +16 -9
- package/src/renderers/Log.tsx +2 -1
- package/src/renderers/PopOver.tsx +1 -1
- package/src/renderers/Tabs.tsx +254 -93
- package/src/renderers/TooltipWrapper.tsx +219 -0
- package/src/renderers/Video.tsx +21 -6
- package/src/store/form.ts +0 -9
- package/src/store/table.ts +1 -1
@@ -2,14 +2,17 @@ import React, {CSSProperties, ReactNode} from 'react';
|
|
2
2
|
import isNumber from 'lodash/isNumber';
|
3
3
|
import isObject from 'lodash/isObject';
|
4
4
|
import isEqual from 'lodash/isEqual';
|
5
|
+
import forEach from 'lodash/forEach';
|
5
6
|
|
6
7
|
import {FormItem, FormControlProps, FormBaseControl} from './Item';
|
7
8
|
import InputRange from '../../components/Range';
|
8
9
|
import NumberInput from '../../components/NumberInput';
|
9
10
|
import {Icon} from '../../components/icons';
|
10
11
|
import {stripNumber} from '../../utils/tpl-builtin';
|
11
|
-
import {autobind} from '../../utils/helper';
|
12
|
+
import {autobind, createObject} from '../../utils/helper';
|
12
13
|
import {filter} from '../../utils/tpl';
|
14
|
+
import {SchemaObject} from '../../Schema';
|
15
|
+
import {Action} from '../../types';
|
13
16
|
|
14
17
|
/**
|
15
18
|
* Range
|
@@ -19,6 +22,8 @@ import {filter} from '../../utils/tpl';
|
|
19
22
|
export type Value = string | MultipleValue | number | [number, number];
|
20
23
|
export type FormatValue = MultipleValue | number;
|
21
24
|
export type TooltipPosType = 'auto' | 'top' | 'right' | 'bottom' | 'left';
|
25
|
+
export type InputRangeRendererEvent = 'change' | 'blur' | 'focus';
|
26
|
+
export type InputRangeRendererAction = 'clear';
|
22
27
|
export interface RangeControlSchema extends FormBaseControl {
|
23
28
|
type: 'input-range';
|
24
29
|
|
@@ -60,7 +65,7 @@ export interface RangeControlSchema extends FormBaseControl {
|
|
60
65
|
/**
|
61
66
|
* 刻度
|
62
67
|
*/
|
63
|
-
|
68
|
+
marks?: MarksType;
|
64
69
|
|
65
70
|
/**
|
66
71
|
* 是否展示标签
|
@@ -98,13 +103,15 @@ export interface RangeControlSchema extends FormBaseControl {
|
|
98
103
|
disabled?: boolean;
|
99
104
|
}
|
100
105
|
|
101
|
-
|
102
|
-
[index: number | string]:
|
103
|
-
number,
|
104
|
-
{style?: React.CSSProperties; label?: string} | any
|
105
|
-
>;
|
106
|
+
type MarksType = {
|
107
|
+
[index: number | string]: MarksValue;
|
106
108
|
};
|
107
109
|
|
110
|
+
type MarksValue = Record<
|
111
|
+
number,
|
112
|
+
SchemaObject | {style?: React.CSSProperties; label?: string}
|
113
|
+
>;
|
114
|
+
|
108
115
|
export interface RangeProps extends FormControlProps {
|
109
116
|
/**
|
110
117
|
* 滑块值
|
@@ -138,11 +145,8 @@ export interface RangeProps extends FormControlProps {
|
|
138
145
|
|
139
146
|
/**
|
140
147
|
* 刻度
|
141
|
-
*
|
142
|
-
* todo 这里面存在 React.Compnonent 复杂定义,不能转成 json schema
|
143
|
-
* 需要简化类型定义,json 中是不能定义复杂类型的,如 function
|
144
148
|
*/
|
145
|
-
|
149
|
+
marks?: MarksType;
|
146
150
|
|
147
151
|
/**
|
148
152
|
* 是否展示标签
|
@@ -362,6 +366,24 @@ export class Input extends React.Component<RangeItemProps, any> {
|
|
362
366
|
}
|
363
367
|
}
|
364
368
|
|
369
|
+
/**
|
370
|
+
* 失焦事件
|
371
|
+
*/
|
372
|
+
@autobind
|
373
|
+
onBlur() {
|
374
|
+
const {data, dispatchEvent} = this.props;
|
375
|
+
dispatchEvent('blur', data);
|
376
|
+
}
|
377
|
+
|
378
|
+
/**
|
379
|
+
* 聚焦事件
|
380
|
+
*/
|
381
|
+
@autobind
|
382
|
+
onFocus() {
|
383
|
+
const {data, dispatchEvent} = this.props;
|
384
|
+
dispatchEvent('focus', data);
|
385
|
+
}
|
386
|
+
|
365
387
|
render() {
|
366
388
|
const {
|
367
389
|
classnames: cx,
|
@@ -388,6 +410,8 @@ export class Input extends React.Component<RangeItemProps, any> {
|
|
388
410
|
min={this.checkNum(min)}
|
389
411
|
onChange={this.onChange}
|
390
412
|
disabled={disabled}
|
413
|
+
onBlur={this.onBlur}
|
414
|
+
onFocus={this.onFocus}
|
391
415
|
/>
|
392
416
|
</div>
|
393
417
|
);
|
@@ -455,6 +479,12 @@ export default class RangeControl extends React.PureComponent<
|
|
455
479
|
}
|
456
480
|
}
|
457
481
|
|
482
|
+
doAction(action: Action, data: object, throwErrors: boolean) {
|
483
|
+
if (action.actionType === 'clear') {
|
484
|
+
this.clearValue();
|
485
|
+
}
|
486
|
+
}
|
487
|
+
|
458
488
|
@autobind
|
459
489
|
clearValue() {
|
460
490
|
const {multiple, min, max} = this.props;
|
@@ -481,21 +511,23 @@ export default class RangeControl extends React.PureComponent<
|
|
481
511
|
* @param value
|
482
512
|
*/
|
483
513
|
@autobind
|
484
|
-
updateValue(value: FormatValue) {
|
514
|
+
async updateValue(value: FormatValue) {
|
485
515
|
this.setState({value: this.getValue(value)});
|
486
|
-
const {
|
487
|
-
|
488
|
-
|
489
|
-
|
490
|
-
|
491
|
-
|
492
|
-
|
493
|
-
|
494
|
-
min: (value as MultipleValue).min,
|
495
|
-
max: (value as MultipleValue).max
|
496
|
-
}
|
497
|
-
: value
|
516
|
+
const {onChange, data, dispatchEvent} = this.props;
|
517
|
+
const result = this.getFormatValue(value);
|
518
|
+
|
519
|
+
const rendererEvent = await dispatchEvent(
|
520
|
+
'change',
|
521
|
+
createObject(data, {
|
522
|
+
value: result
|
523
|
+
})
|
498
524
|
);
|
525
|
+
|
526
|
+
if (rendererEvent?.prevented) {
|
527
|
+
return;
|
528
|
+
}
|
529
|
+
|
530
|
+
onChange && onChange(result);
|
499
531
|
}
|
500
532
|
|
501
533
|
/**
|
@@ -504,20 +536,27 @@ export default class RangeControl extends React.PureComponent<
|
|
504
536
|
@autobind
|
505
537
|
onAfterChange() {
|
506
538
|
const {value} = this.state;
|
507
|
-
const {
|
508
|
-
|
509
|
-
|
510
|
-
|
511
|
-
|
512
|
-
|
513
|
-
|
514
|
-
|
515
|
-
|
516
|
-
|
517
|
-
|
518
|
-
|
519
|
-
|
520
|
-
|
539
|
+
const {onAfterChange, dispatchEvent, data} = this.props;
|
540
|
+
const result = this.getFormatValue(value);
|
541
|
+
onAfterChange && onAfterChange(result);
|
542
|
+
}
|
543
|
+
|
544
|
+
/**
|
545
|
+
* 获取导出格式数据
|
546
|
+
*/
|
547
|
+
@autobind
|
548
|
+
getFormatValue(value: FormatValue) {
|
549
|
+
const {multiple, joinValues, delimiter} = this.props;
|
550
|
+
return multiple
|
551
|
+
? joinValues
|
552
|
+
? [(value as MultipleValue).min, (value as MultipleValue).max].join(
|
553
|
+
delimiter || ','
|
554
|
+
)
|
555
|
+
: {
|
556
|
+
min: (value as MultipleValue).min,
|
557
|
+
max: (value as MultipleValue).max
|
558
|
+
}
|
559
|
+
: value;
|
521
560
|
}
|
522
561
|
|
523
562
|
render() {
|
@@ -539,7 +578,10 @@ export default class RangeControl extends React.PureComponent<
|
|
539
578
|
disabled,
|
540
579
|
clearable,
|
541
580
|
min,
|
542
|
-
max
|
581
|
+
max,
|
582
|
+
render,
|
583
|
+
marks,
|
584
|
+
region
|
543
585
|
} = props;
|
544
586
|
|
545
587
|
// 指定parts -> 重新计算步长
|
@@ -548,6 +590,19 @@ export default class RangeControl extends React.PureComponent<
|
|
548
590
|
props.showSteps = true;
|
549
591
|
}
|
550
592
|
|
593
|
+
// 处理自定义json配置
|
594
|
+
let renderMarks:
|
595
|
+
| MarksType
|
596
|
+
| {[index: number | string]: ReactNode}
|
597
|
+
| undefined = marks ? {...marks} : marks;
|
598
|
+
marks &&
|
599
|
+
forEach(marks, (item, key) => {
|
600
|
+
if (isObject(item) && (item as SchemaObject).type) {
|
601
|
+
renderMarks &&
|
602
|
+
(renderMarks[key] = render(region, item as SchemaObject));
|
603
|
+
}
|
604
|
+
});
|
605
|
+
|
551
606
|
return (
|
552
607
|
<div
|
553
608
|
className={cx(
|
@@ -558,7 +613,7 @@ export default class RangeControl extends React.PureComponent<
|
|
558
613
|
)}
|
559
614
|
>
|
560
615
|
{showInput && multiple && <Input {...props} type="min" />}
|
561
|
-
<InputRange {...props} />
|
616
|
+
<InputRange {...props} marks={renderMarks} />
|
562
617
|
{showInput && <Input {...props} type="max" />}
|
563
618
|
{clearable && !disabled && showInput ? (
|
564
619
|
<a
|
@@ -524,6 +524,7 @@ export default class SubFormControl extends React.PureComponent<
|
|
524
524
|
|
525
525
|
@FormItem({
|
526
526
|
type: 'input-sub-form',
|
527
|
-
sizeMutable: false
|
527
|
+
sizeMutable: false,
|
528
|
+
strictMode: false
|
528
529
|
})
|
529
530
|
export class SubFormControlRenderer extends SubFormControl {}
|
@@ -83,7 +83,9 @@ export default class TagControl extends React.PureComponent<
|
|
83
83
|
|
84
84
|
doAction(action: Action, data: object, throwErrors: boolean) {
|
85
85
|
const {resetValue, onChange} = this.props;
|
86
|
-
|
86
|
+
const actionType = action?.actionType as string;
|
87
|
+
|
88
|
+
if (!!~['clear', 'reset'].indexOf(actionType)) {
|
87
89
|
onChange(resetValue ?? '');
|
88
90
|
}
|
89
91
|
}
|
@@ -149,7 +149,9 @@ export default class MatrixCheckbox extends React.Component<
|
|
149
149
|
|
150
150
|
doAction(action: Action, data: object, throwErrors: boolean) {
|
151
151
|
const {resetValue, onChange} = this.props;
|
152
|
-
|
152
|
+
const actionType = action?.actionType as string;
|
153
|
+
|
154
|
+
if (!!~['clear', 'reset'].indexOf(actionType)) {
|
153
155
|
onChange(resetValue ?? '');
|
154
156
|
}
|
155
157
|
}
|
@@ -12,7 +12,8 @@ import {
|
|
12
12
|
getTreeAncestors,
|
13
13
|
getTreeParent,
|
14
14
|
ucFirst,
|
15
|
-
isMobile
|
15
|
+
isMobile,
|
16
|
+
createObject
|
16
17
|
} from '../../utils/helper';
|
17
18
|
import {
|
18
19
|
FormOptionsControl,
|
@@ -27,6 +28,7 @@ import union from 'lodash/union';
|
|
27
28
|
import compact from 'lodash/compact';
|
28
29
|
import {RootClose} from '../../utils/RootClose';
|
29
30
|
import Cascader from '../../components/Cascader';
|
31
|
+
import {Action} from '../../types';
|
30
32
|
|
31
33
|
/**
|
32
34
|
* Nested Select
|
@@ -117,6 +119,28 @@ export default class NestedSelectControl extends React.Component<
|
|
117
119
|
}
|
118
120
|
}
|
119
121
|
|
122
|
+
doAction(action: Action, data: object, throwErrors: boolean) {
|
123
|
+
const {resetValue, onChange} = this.props;
|
124
|
+
const actionType = action?.actionType as string;
|
125
|
+
|
126
|
+
if (!!~['clear', 'reset'].indexOf(actionType)) {
|
127
|
+
onChange(resetValue ?? '');
|
128
|
+
}
|
129
|
+
}
|
130
|
+
|
131
|
+
@autobind
|
132
|
+
async dispatchEvent(eventName: string, eventData: any = {}) {
|
133
|
+
const {dispatchEvent, data} = this.props;
|
134
|
+
const rendererEvent = await dispatchEvent(
|
135
|
+
eventName,
|
136
|
+
createObject(data, {
|
137
|
+
...eventData
|
138
|
+
})
|
139
|
+
);
|
140
|
+
// 返回阻塞标识
|
141
|
+
return !!rendererEvent?.prevented;
|
142
|
+
}
|
143
|
+
|
120
144
|
@autobind
|
121
145
|
handleOutClick(e: React.MouseEvent<any>) {
|
122
146
|
const {options} = this.props;
|
@@ -140,7 +164,7 @@ export default class NestedSelectControl extends React.Component<
|
|
140
164
|
});
|
141
165
|
}
|
142
166
|
|
143
|
-
removeItem(index: number, e?: React.MouseEvent<HTMLElement>) {
|
167
|
+
async removeItem(index: number, e?: React.MouseEvent<HTMLElement>) {
|
144
168
|
let {
|
145
169
|
onChange,
|
146
170
|
selectedOptions,
|
@@ -165,7 +189,10 @@ export default class NestedSelectControl extends React.Component<
|
|
165
189
|
);
|
166
190
|
}
|
167
191
|
|
168
|
-
|
192
|
+
const isPrevented = await this.dispatchEvent('change', {
|
193
|
+
value
|
194
|
+
});
|
195
|
+
isPrevented || onChange(value);
|
169
196
|
}
|
170
197
|
|
171
198
|
@autobind
|
@@ -224,7 +251,7 @@ export default class NestedSelectControl extends React.Component<
|
|
224
251
|
}
|
225
252
|
|
226
253
|
@autobind
|
227
|
-
handleOptionClick(option: Option) {
|
254
|
+
async handleOptionClick(option: Option) {
|
228
255
|
const {multiple, onChange, joinValues, extractValue, valueField} =
|
229
256
|
this.props;
|
230
257
|
|
@@ -232,18 +259,21 @@ export default class NestedSelectControl extends React.Component<
|
|
232
259
|
return;
|
233
260
|
}
|
234
261
|
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
262
|
+
const value = joinValues
|
263
|
+
? option[valueField || 'value']
|
264
|
+
: extractValue
|
265
|
+
? option[valueField || 'value']
|
266
|
+
: option;
|
267
|
+
|
268
|
+
const isPrevented = await this.dispatchEvent('change', {
|
269
|
+
value
|
270
|
+
});
|
271
|
+
isPrevented || onChange(value);
|
242
272
|
!multiple && this.close();
|
243
273
|
}
|
244
274
|
|
245
275
|
@autobind
|
246
|
-
handleCheck(option: Option | Options, index?: number) {
|
276
|
+
async handleCheck(option: Option | Options, index?: number) {
|
247
277
|
const {
|
248
278
|
onChange,
|
249
279
|
selectedOptions,
|
@@ -343,13 +373,16 @@ export default class NestedSelectControl extends React.Component<
|
|
343
373
|
}
|
344
374
|
}
|
345
375
|
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
|
352
|
-
|
376
|
+
const newValue = joinValues
|
377
|
+
? value.map(item => item[valueField as string]).join(delimiter)
|
378
|
+
: extractValue
|
379
|
+
? value.map(item => item[valueField as string])
|
380
|
+
: value;
|
381
|
+
|
382
|
+
const isPrevented = await this.dispatchEvent('change', {
|
383
|
+
value: newValue
|
384
|
+
});
|
385
|
+
isPrevented || onChange(newValue);
|
353
386
|
}
|
354
387
|
|
355
388
|
allChecked(options: Options): boolean {
|
@@ -379,19 +412,29 @@ export default class NestedSelectControl extends React.Component<
|
|
379
412
|
}
|
380
413
|
|
381
414
|
@autobind
|
382
|
-
onFocus(e: any) {
|
383
|
-
this.props
|
384
|
-
|
415
|
+
async onFocus(e: any) {
|
416
|
+
const {onFocus, disabled} = this.props;
|
417
|
+
|
418
|
+
if (!disabled && !this.state.isOpened) {
|
385
419
|
this.setState({
|
386
420
|
isFocused: true
|
387
421
|
});
|
422
|
+
|
423
|
+
const isPrevented = await this.dispatchEvent('focus', e);
|
424
|
+
isPrevented || onFocus && onFocus(e);
|
425
|
+
}
|
388
426
|
}
|
389
427
|
|
390
428
|
@autobind
|
391
|
-
onBlur(e: any) {
|
429
|
+
async onBlur(e: any) {
|
430
|
+
const {onBlur} = this.props;
|
431
|
+
|
392
432
|
this.setState({
|
393
433
|
isFocused: false
|
394
434
|
});
|
435
|
+
|
436
|
+
const isPrevented = await this.dispatchEvent('blur', e);
|
437
|
+
isPrevented || onBlur && onBlur(e);
|
395
438
|
}
|
396
439
|
|
397
440
|
@autobind
|
@@ -451,7 +494,7 @@ export default class NestedSelectControl extends React.Component<
|
|
451
494
|
}
|
452
495
|
|
453
496
|
@autobind
|
454
|
-
handleResultChange(value: Array<Option>) {
|
497
|
+
async handleResultChange(value: Array<Option>) {
|
455
498
|
const {
|
456
499
|
joinValues,
|
457
500
|
extractValue,
|
@@ -464,7 +507,10 @@ export default class NestedSelectControl extends React.Component<
|
|
464
507
|
let newValue: any = Array.isArray(value) ? value.concat() : [];
|
465
508
|
|
466
509
|
if (!multiple && !newValue.length) {
|
467
|
-
|
510
|
+
const isPrevented = await this.dispatchEvent('change', {
|
511
|
+
value: ''
|
512
|
+
});
|
513
|
+
isPrevented || onChange('');
|
468
514
|
return;
|
469
515
|
}
|
470
516
|
|
@@ -476,7 +522,10 @@ export default class NestedSelectControl extends React.Component<
|
|
476
522
|
newValue = newValue.join(delimiter || ',');
|
477
523
|
}
|
478
524
|
|
479
|
-
|
525
|
+
const isPrevented = await this.dispatchEvent('change', {
|
526
|
+
value: newValue
|
527
|
+
});
|
528
|
+
isPrevented || onChange(newValue);
|
480
529
|
}
|
481
530
|
|
482
531
|
renderOptions() {
|
@@ -469,7 +469,9 @@ export function registerOptionsControl(config: OptionsConfig) {
|
|
469
469
|
|
470
470
|
doAction(action: Action, data: object, throwErrors: boolean) {
|
471
471
|
const {resetValue, onChange} = this.props;
|
472
|
-
|
472
|
+
const actionType = action?.actionType as string;
|
473
|
+
|
474
|
+
if (!!~['clear', 'reset'].indexOf(actionType)) {
|
473
475
|
onChange(resetValue ?? '');
|
474
476
|
}
|
475
477
|
}
|
@@ -39,7 +39,9 @@ export default class RadiosControl extends React.Component<RadiosProps, any> {
|
|
39
39
|
|
40
40
|
doAction(action: Action, data: object, throwErrors: boolean) {
|
41
41
|
const {resetValue, onChange} = this.props;
|
42
|
-
|
42
|
+
const actionType = action?.actionType as string;
|
43
|
+
|
44
|
+
if (!!~['clear', 'reset'].indexOf(actionType)) {
|
43
45
|
onChange(resetValue ?? '');
|
44
46
|
}
|
45
47
|
}
|
@@ -336,8 +336,10 @@ export default class SelectControl extends React.Component<SelectProps, any> {
|
|
336
336
|
}
|
337
337
|
|
338
338
|
doAction(action: Action, data: object, throwErrors: boolean): any {
|
339
|
-
const {
|
340
|
-
|
339
|
+
const {resetValue} = this.props;
|
340
|
+
const actionType = action?.actionType as string;
|
341
|
+
|
342
|
+
if (!!~['clear', 'reset'].indexOf(actionType)) {
|
341
343
|
this.changeValue(resetValue ?? '');
|
342
344
|
}
|
343
345
|
}
|
@@ -388,6 +390,8 @@ export default class SelectControl extends React.Component<SelectProps, any> {
|
|
388
390
|
popOverContainer={
|
389
391
|
mobileUI && env && env.getModalContainer
|
390
392
|
? env.getModalContainer
|
393
|
+
: mobileUI
|
394
|
+
? undefined
|
391
395
|
: rest.popOverContainer
|
392
396
|
}
|
393
397
|
borderMode={borderMode}
|
@@ -1,12 +1,16 @@
|
|
1
1
|
import React from 'react';
|
2
2
|
import {FormItem, FormControlProps, FormBaseControl} from './Item';
|
3
3
|
import Switch from '../../components/Switch';
|
4
|
-
import {createObject, autobind} from '../../utils/helper';
|
4
|
+
import {createObject, autobind, isObject} from '../../utils/helper';
|
5
|
+
import {generateIcon} from "../../utils/icon";
|
6
|
+
import {IconSchema} from "../Icon";
|
5
7
|
|
6
8
|
/**
|
7
9
|
* Switch
|
8
10
|
* 文档:https://baidu.gitee.io/amis/docs/components/form/switch
|
9
11
|
*/
|
12
|
+
|
13
|
+
|
10
14
|
export interface SwitchControlSchema extends FormBaseControl {
|
11
15
|
/**
|
12
16
|
* 指定为多行文本输入框
|
@@ -16,12 +20,12 @@ export interface SwitchControlSchema extends FormBaseControl {
|
|
16
20
|
/**
|
17
21
|
* 勾选值
|
18
22
|
*/
|
19
|
-
trueValue?:
|
23
|
+
trueValue?: boolean | string | number;
|
20
24
|
|
21
25
|
/**
|
22
26
|
* 未勾选值
|
23
27
|
*/
|
24
|
-
falseValue?:
|
28
|
+
falseValue?: boolean | string | number;
|
25
29
|
|
26
30
|
/**
|
27
31
|
* 选项说明
|
@@ -29,14 +33,14 @@ export interface SwitchControlSchema extends FormBaseControl {
|
|
29
33
|
option?: string;
|
30
34
|
|
31
35
|
/**
|
32
|
-
*
|
36
|
+
* 开启时显示的内容
|
33
37
|
*/
|
34
|
-
onText?: string;
|
38
|
+
onText?: string | IconSchema;
|
35
39
|
|
36
40
|
/**
|
37
|
-
*
|
41
|
+
* 关闭时显示的内容
|
38
42
|
*/
|
39
|
-
offText?: string;
|
43
|
+
offText?: string | IconSchema;
|
40
44
|
}
|
41
45
|
|
42
46
|
export interface SwitchProps extends FormControlProps {
|
@@ -83,6 +87,9 @@ export default class SwitchControl extends React.Component<SwitchProps, any> {
|
|
83
87
|
optionAtLeft
|
84
88
|
} = this.props;
|
85
89
|
|
90
|
+
const on = isObject(onText) ? generateIcon(cx, onText.icon, 'Switch-icon') : onText;
|
91
|
+
const off = isObject(offText) ? generateIcon(cx, offText.icon, 'Switch-icon') :offText;
|
92
|
+
|
86
93
|
return (
|
87
94
|
<div className={cx(`SwitchControl`, className)}>
|
88
95
|
{optionAtLeft ? (
|
@@ -94,8 +101,8 @@ export default class SwitchControl extends React.Component<SwitchProps, any> {
|
|
94
101
|
value={value}
|
95
102
|
trueValue={trueValue}
|
96
103
|
falseValue={falseValue}
|
97
|
-
onText={
|
98
|
-
offText={
|
104
|
+
onText={on}
|
105
|
+
offText={off}
|
99
106
|
disabled={disabled}
|
100
107
|
onChange={this.handleChange}
|
101
108
|
/>
|
package/src/renderers/Log.tsx
CHANGED
@@ -134,7 +134,8 @@ export class Log extends React.Component<LogProps, LogState> {
|
|
134
134
|
const res = await fetch(api.url, {
|
135
135
|
method: api.method?.toLocaleUpperCase() || 'GET',
|
136
136
|
headers: (api.headers as Record<string, string>) || undefined,
|
137
|
-
body: api.data ? JSON.stringify(api.data) : undefined
|
137
|
+
body: api.data ? JSON.stringify(api.data) : undefined,
|
138
|
+
credentials: 'include'
|
138
139
|
});
|
139
140
|
if (res.status === 200) {
|
140
141
|
const body = res.body;
|