amis 1.6.5-beta.4 → 1.7.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/components/PopUp.js +2 -1
- package/lib/components/PopUp.js.map +2 -2
- package/lib/components/Range.js.map +2 -2
- package/lib/index.js +1 -1
- 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 +4 -1
- package/lib/renderers/Form/InputFile.js +9 -0
- package/lib/renderers/Form/InputFile.js.map +2 -2
- package/lib/renderers/Form/InputImage.d.ts +4 -1
- package/lib/renderers/Form/InputImage.js +12 -2
- 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/Select.js +3 -1
- 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.js +1 -1
- package/lib/renderers/Tabs.js.map +2 -2
- 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/table.js +1 -1
- package/lib/store/table.js.map +2 -2
- package/lib/themes/ang-ie11.css +16 -6
- package/lib/themes/ang.css +16 -6
- package/lib/themes/ang.css.map +1 -1
- package/lib/themes/antd-ie11.css +16 -6
- package/lib/themes/antd.css +16 -6
- package/lib/themes/antd.css.map +1 -1
- package/lib/themes/cxd-ie11.css +16 -6
- package/lib/themes/cxd.css +16 -6
- package/lib/themes/cxd.css.map +1 -1
- package/lib/themes/dark-ie11.css +16 -6
- package/lib/themes/dark.css +16 -6
- package/lib/themes/dark.css.map +1 -1
- package/lib/themes/default-ie11.css +16 -6
- package/lib/themes/default.css +16 -6
- package/lib/themes/default.css.map +1 -1
- package/package.json +1 -1
- package/schema.json +15521 -504
- package/scss/components/_city-area.scss +2 -0
- package/scss/components/_popup.scss +13 -3
- package/scss/components/form/_switch.scss +1 -3
- package/sdk/ang-ie11.css +18 -6
- package/sdk/ang.css +18 -6
- package/sdk/antd-ie11.css +18 -6
- package/sdk/antd.css +18 -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 +18 -6
- package/sdk/cxd.css +18 -6
- package/sdk/dark-ie11.css +18 -6
- package/sdk/dark.css +18 -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 +17 -17
- package/sdk/rich-text.js +62 -62
- package/sdk/sdk-ie11.css +18 -6
- package/sdk/sdk.css +18 -6
- package/sdk/sdk.js +1246 -1246
- 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/PopUp.tsx +6 -5
- package/src/components/Range.tsx +7 -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 +13 -1
- package/src/renderers/Form/InputImage.tsx +32 -12
- package/src/renderers/Form/InputRange.tsx +99 -40
- package/src/renderers/Form/Select.tsx +2 -0
- 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 +1 -1
- package/src/renderers/Video.tsx +21 -6
- package/src/store/table.ts +1 -1
package/src/components/PopUp.tsx
CHANGED
@@ -113,11 +113,12 @@ export class PopUp extends React.PureComponent<PopUpPorps> {
|
|
113
113
|
{!showConfirm && showClose ? (
|
114
114
|
<div className={cx(`${ns}PopUp-closeWrap`)}>
|
115
115
|
{header}
|
116
|
-
<
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
116
|
+
<span className={cx(`PopUp-closeBox`)} onClick={onHide}>
|
117
|
+
<Icon
|
118
|
+
icon="close"
|
119
|
+
className={cx('icon', `${ns}PopUp-close`)}
|
120
|
+
/>
|
121
|
+
</span>
|
121
122
|
</div>
|
122
123
|
) : null}
|
123
124
|
{showConfirm && (
|
package/src/components/Range.tsx
CHANGED
@@ -19,13 +19,19 @@ import {
|
|
19
19
|
MultipleValue,
|
20
20
|
Value,
|
21
21
|
FormatValue,
|
22
|
-
MarksType,
|
23
22
|
RangeItemProps
|
24
23
|
} from '../renderers/Form/InputRange';
|
25
24
|
import {stripNumber} from '../utils/tpl-builtin';
|
26
25
|
import {findDOMNode} from 'react-dom';
|
27
26
|
import {Icon} from './icons';
|
28
27
|
|
28
|
+
type MarksType = {
|
29
|
+
[index: number | string]: Record<
|
30
|
+
number,
|
31
|
+
React.ReactNode | {style?: React.CSSProperties; label?: string}
|
32
|
+
>;
|
33
|
+
};
|
34
|
+
|
29
35
|
interface HandleItemState {
|
30
36
|
isDrag: boolean;
|
31
37
|
labelActive: boolean;
|
@@ -215,6 +215,8 @@ export default class DateRangeControl extends React.Component<DateRangeProps> {
|
|
215
215
|
popOverContainer={
|
216
216
|
mobileUI && env && env.getModalContainer
|
217
217
|
? env.getModalContainer
|
218
|
+
: mobileUI
|
219
|
+
? undefined
|
218
220
|
: rest.popOverContainer
|
219
221
|
}
|
220
222
|
data={data}
|
@@ -2,7 +2,7 @@ import React, {Suspense} from 'react';
|
|
2
2
|
import Dropzone from 'react-dropzone';
|
3
3
|
import {FileRejection} from 'react-dropzone';
|
4
4
|
import {Icon} from '../../components/icons';
|
5
|
-
import {autobind} from '../../utils/helper';
|
5
|
+
import {autobind, createObject} from '../../utils/helper';
|
6
6
|
import {FormItem, FormControlProps, FormBaseControl} from './Item';
|
7
7
|
|
8
8
|
/**
|
@@ -47,6 +47,8 @@ export interface ExcelControlState {
|
|
47
47
|
filename: string;
|
48
48
|
}
|
49
49
|
|
50
|
+
export type InputExcelRendererEvent = 'change';
|
51
|
+
export type InputExcelRendererAction = 'clear';
|
50
52
|
export default class ExcelControl extends React.PureComponent<
|
51
53
|
ExcelProps,
|
52
54
|
ExcelControlState
|
@@ -66,7 +68,7 @@ export default class ExcelControl extends React.PureComponent<
|
|
66
68
|
|
67
69
|
@autobind
|
68
70
|
handleDrop(files: File[]) {
|
69
|
-
const {allSheets, onChange} = this.props;
|
71
|
+
const {allSheets, onChange, dispatchEvent, data} = this.props;
|
70
72
|
const excel = files[0];
|
71
73
|
const reader = new FileReader();
|
72
74
|
reader.readAsArrayBuffer(excel);
|
@@ -76,25 +78,38 @@ export default class ExcelControl extends React.PureComponent<
|
|
76
78
|
this.ExcelJS = ExcelJS;
|
77
79
|
const workbook = new ExcelJS.Workbook();
|
78
80
|
await workbook.xlsx.load(reader.result);
|
81
|
+
let sheetsResult: any[] = [];
|
79
82
|
if (allSheets) {
|
80
|
-
const sheetsResult: any[] = [];
|
81
83
|
workbook.eachSheet((worksheet: any) => {
|
82
84
|
sheetsResult.push({
|
83
85
|
sheetName: worksheet.name,
|
84
86
|
data: this.readWorksheet(worksheet)
|
85
87
|
});
|
86
|
-
onChange(sheetsResult);
|
87
88
|
});
|
88
89
|
} else {
|
89
90
|
const worksheet = workbook.worksheets[0];
|
90
|
-
|
91
|
+
sheetsResult = this.readWorksheet(worksheet);
|
91
92
|
}
|
93
|
+
const dispatcher = await this.dispatchEvent('change', sheetsResult);
|
94
|
+
if (dispatcher?.prevented) {
|
95
|
+
return;
|
96
|
+
}
|
97
|
+
onChange(sheetsResult);
|
92
98
|
this.setState({filename: files[0].name});
|
93
99
|
});
|
94
100
|
}
|
95
101
|
};
|
96
102
|
}
|
97
103
|
|
104
|
+
async dispatchEvent(eventName: string, eventData?: Record<string, any>) {
|
105
|
+
const {dispatchEvent, data} = this.props;
|
106
|
+
return await dispatchEvent(
|
107
|
+
eventName,
|
108
|
+
createObject(data, {
|
109
|
+
value: eventData
|
110
|
+
})
|
111
|
+
);
|
112
|
+
}
|
98
113
|
/**
|
99
114
|
* 读取单个 sheet 的内容
|
100
115
|
*/
|
@@ -145,6 +160,13 @@ export default class ExcelControl extends React.PureComponent<
|
|
145
160
|
}
|
146
161
|
}
|
147
162
|
|
163
|
+
doAction(action: any, data: object, throwErrors: boolean) {
|
164
|
+
const {onChange} = this.props;
|
165
|
+
if (action.actionType === 'clear') {
|
166
|
+
onChange('');
|
167
|
+
}
|
168
|
+
}
|
169
|
+
|
148
170
|
render() {
|
149
171
|
const {
|
150
172
|
className,
|
@@ -5,7 +5,7 @@ import isPlainObject from 'lodash/isPlainObject';
|
|
5
5
|
// @ts-ignore
|
6
6
|
import mapLimit from 'async/mapLimit';
|
7
7
|
import ImageControl from './InputImage';
|
8
|
-
import {Payload, ApiObject, ApiString} from '../../types';
|
8
|
+
import {Payload, ApiObject, ApiString, Action} from '../../types';
|
9
9
|
import {filter} from '../../utils/tpl';
|
10
10
|
import Alert from '../../components/Alert2';
|
11
11
|
import {qsstringify, createObject, guid, isEmpty} from '../../utils/helper';
|
@@ -281,6 +281,8 @@ export function getNameFromUrl(url: string) {
|
|
281
281
|
|
282
282
|
return url;
|
283
283
|
}
|
284
|
+
export type InputFileRendererEvent = 'change' | 'success' | 'fail' | 'remove';
|
285
|
+
export type InputFileRendererAction = 'clear';
|
284
286
|
|
285
287
|
export default class FileControl extends React.Component<FileProps, FileState> {
|
286
288
|
static defaultProps: Partial<FileProps> = {
|
@@ -1223,6 +1225,16 @@ export default class FileControl extends React.Component<FileProps, FileState> {
|
|
1223
1225
|
);
|
1224
1226
|
}
|
1225
1227
|
|
1228
|
+
// 动作
|
1229
|
+
doAction(action: Action, data: object, throwErrors: boolean) {
|
1230
|
+
const {onChange} = this.props;
|
1231
|
+
if (action.actionType === 'clear') {
|
1232
|
+
this.setState({files: []}, () => {
|
1233
|
+
onChange('');
|
1234
|
+
});
|
1235
|
+
}
|
1236
|
+
}
|
1237
|
+
|
1226
1238
|
render() {
|
1227
1239
|
const {
|
1228
1240
|
btnLabel,
|
@@ -6,7 +6,7 @@ import DropZone from 'react-dropzone';
|
|
6
6
|
import {FileRejection} from 'react-dropzone';
|
7
7
|
import 'blueimp-canvastoblob';
|
8
8
|
import find from 'lodash/find';
|
9
|
-
import {Payload} from '../../types';
|
9
|
+
import {Payload, Action} from '../../types';
|
10
10
|
import {buildApi} from '../../utils/api';
|
11
11
|
import {
|
12
12
|
createObject,
|
@@ -244,7 +244,7 @@ export interface ImageControlSchema extends FormBaseControl {
|
|
244
244
|
/**
|
245
245
|
* 初始化时是否把其他字段同步到表单内部。
|
246
246
|
*/
|
247
|
-
initAutoFill?: boolean
|
247
|
+
initAutoFill?: boolean;
|
248
248
|
|
249
249
|
/**
|
250
250
|
* 默认占位图图片地址
|
@@ -314,6 +314,9 @@ export interface FileX extends File {
|
|
314
314
|
[propName: string]: any;
|
315
315
|
}
|
316
316
|
|
317
|
+
export type InputImageRendererEvent = 'change' | 'success' | 'fail' | 'remove';
|
318
|
+
export type InputImageRendererAction = 'clear';
|
319
|
+
|
317
320
|
export default class ImageControl extends React.Component<
|
318
321
|
ImageProps,
|
319
322
|
ImageState
|
@@ -501,8 +504,8 @@ export default class ImageControl extends React.Component<
|
|
501
504
|
this.syncAutoFill
|
502
505
|
);
|
503
506
|
} else if (prevProps.value !== props.value && !this.initAutoFill) {
|
504
|
-
this.initAutoFill = true
|
505
|
-
this.syncAutoFill()
|
507
|
+
this.initAutoFill = true;
|
508
|
+
this.syncAutoFill();
|
506
509
|
}
|
507
510
|
|
508
511
|
if (prevProps.crop !== props.crop) {
|
@@ -1245,10 +1248,19 @@ export default class ImageControl extends React.Component<
|
|
1245
1248
|
|
1246
1249
|
async dispatchEvent(e: string, data?: Record<string, any>) {
|
1247
1250
|
const {dispatchEvent} = this.props;
|
1248
|
-
data = data ? data : this.
|
1251
|
+
data = data ? data : this.files;
|
1249
1252
|
return dispatchEvent(e, createObject(this.props.data, {file: data}));
|
1250
1253
|
}
|
1251
1254
|
|
1255
|
+
// 动作
|
1256
|
+
doAction(action: Action, data: object, throwErrors: boolean) {
|
1257
|
+
const {onChange} = this.props;
|
1258
|
+
if (action.actionType === 'clear') {
|
1259
|
+
this.files = [];
|
1260
|
+
onChange('');
|
1261
|
+
}
|
1262
|
+
}
|
1263
|
+
|
1252
1264
|
render() {
|
1253
1265
|
const {
|
1254
1266
|
className,
|
@@ -1382,10 +1394,21 @@ export default class ImageControl extends React.Component<
|
|
1382
1394
|
file.state === 'error' ? (
|
1383
1395
|
<div className={cx('Image--thumb')}>
|
1384
1396
|
<div className={cx('Image-thumbWrap')}>
|
1385
|
-
<div
|
1397
|
+
<div
|
1398
|
+
className={cx(
|
1399
|
+
'Image-thumb',
|
1400
|
+
'ImageControl-filename'
|
1401
|
+
)}
|
1402
|
+
>
|
1386
1403
|
<Icon icon="image" className="icon" />
|
1387
|
-
<span
|
1388
|
-
{
|
1404
|
+
<span
|
1405
|
+
title={
|
1406
|
+
file.name ||
|
1407
|
+
getNameFromUrl(file.value || file.url)
|
1408
|
+
}
|
1409
|
+
>
|
1410
|
+
{file.name ||
|
1411
|
+
getNameFromUrl(file.value || file.url)}
|
1389
1412
|
</span>
|
1390
1413
|
</div>
|
1391
1414
|
|
@@ -1393,10 +1416,7 @@ export default class ImageControl extends React.Component<
|
|
1393
1416
|
<a
|
1394
1417
|
data-tooltip={__('File.repick')}
|
1395
1418
|
data-position="bottom"
|
1396
|
-
onClick={this.handleRetry.bind(
|
1397
|
-
this,
|
1398
|
-
key
|
1399
|
-
)}
|
1419
|
+
onClick={this.handleRetry.bind(this, key)}
|
1400
1420
|
>
|
1401
1421
|
<Icon icon="refresh" className="icon" />
|
1402
1422
|
</a>
|
@@ -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,12 @@ 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 InputTextRendererEvent =
|
26
|
+
| 'change'
|
27
|
+
| 'afterChange'
|
28
|
+
| 'blur'
|
29
|
+
| 'focus';
|
30
|
+
export type InputTextRendererAction = 'clear';
|
22
31
|
export interface RangeControlSchema extends FormBaseControl {
|
23
32
|
type: 'input-range';
|
24
33
|
|
@@ -60,7 +69,7 @@ export interface RangeControlSchema extends FormBaseControl {
|
|
60
69
|
/**
|
61
70
|
* 刻度
|
62
71
|
*/
|
63
|
-
|
72
|
+
marks?: MarksType;
|
64
73
|
|
65
74
|
/**
|
66
75
|
* 是否展示标签
|
@@ -98,13 +107,15 @@ export interface RangeControlSchema extends FormBaseControl {
|
|
98
107
|
disabled?: boolean;
|
99
108
|
}
|
100
109
|
|
101
|
-
|
102
|
-
[index: number | string]:
|
103
|
-
number,
|
104
|
-
{style?: React.CSSProperties; label?: string} | any
|
105
|
-
>;
|
110
|
+
type MarksType = {
|
111
|
+
[index: number | string]: MarksValue;
|
106
112
|
};
|
107
113
|
|
114
|
+
type MarksValue = Record<
|
115
|
+
number,
|
116
|
+
SchemaObject | {style?: React.CSSProperties; label?: string}
|
117
|
+
>;
|
118
|
+
|
108
119
|
export interface RangeProps extends FormControlProps {
|
109
120
|
/**
|
110
121
|
* 滑块值
|
@@ -138,11 +149,8 @@ export interface RangeProps extends FormControlProps {
|
|
138
149
|
|
139
150
|
/**
|
140
151
|
* 刻度
|
141
|
-
*
|
142
|
-
* todo 这里面存在 React.Compnonent 复杂定义,不能转成 json schema
|
143
|
-
* 需要简化类型定义,json 中是不能定义复杂类型的,如 function
|
144
152
|
*/
|
145
|
-
|
153
|
+
marks?: MarksType;
|
146
154
|
|
147
155
|
/**
|
148
156
|
* 是否展示标签
|
@@ -362,6 +370,24 @@ export class Input extends React.Component<RangeItemProps, any> {
|
|
362
370
|
}
|
363
371
|
}
|
364
372
|
|
373
|
+
/**
|
374
|
+
* 失焦事件
|
375
|
+
*/
|
376
|
+
@autobind
|
377
|
+
onBlur() {
|
378
|
+
const {data, dispatchEvent} = this.props;
|
379
|
+
dispatchEvent('blur', data);
|
380
|
+
}
|
381
|
+
|
382
|
+
/**
|
383
|
+
* 聚焦事件
|
384
|
+
*/
|
385
|
+
@autobind
|
386
|
+
onFocus() {
|
387
|
+
const {data, dispatchEvent} = this.props;
|
388
|
+
dispatchEvent('focus', data);
|
389
|
+
}
|
390
|
+
|
365
391
|
render() {
|
366
392
|
const {
|
367
393
|
classnames: cx,
|
@@ -388,6 +414,8 @@ export class Input extends React.Component<RangeItemProps, any> {
|
|
388
414
|
min={this.checkNum(min)}
|
389
415
|
onChange={this.onChange}
|
390
416
|
disabled={disabled}
|
417
|
+
onBlur={this.onBlur}
|
418
|
+
onFocus={this.onFocus}
|
391
419
|
/>
|
392
420
|
</div>
|
393
421
|
);
|
@@ -455,6 +483,12 @@ export default class RangeControl extends React.PureComponent<
|
|
455
483
|
}
|
456
484
|
}
|
457
485
|
|
486
|
+
doAction(action: Action, data: object, throwErrors: boolean) {
|
487
|
+
if (action.actionType === 'clear') {
|
488
|
+
this.clearValue();
|
489
|
+
}
|
490
|
+
}
|
491
|
+
|
458
492
|
@autobind
|
459
493
|
clearValue() {
|
460
494
|
const {multiple, min, max} = this.props;
|
@@ -481,21 +515,23 @@ export default class RangeControl extends React.PureComponent<
|
|
481
515
|
* @param value
|
482
516
|
*/
|
483
517
|
@autobind
|
484
|
-
updateValue(value: FormatValue) {
|
518
|
+
async updateValue(value: FormatValue) {
|
485
519
|
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
|
520
|
+
const {onChange, data, dispatchEvent} = this.props;
|
521
|
+
const result = this.getFormatValue(value);
|
522
|
+
|
523
|
+
const rendererEvent = await dispatchEvent(
|
524
|
+
'change',
|
525
|
+
createObject(data, {
|
526
|
+
value: result
|
527
|
+
})
|
498
528
|
);
|
529
|
+
|
530
|
+
if (rendererEvent?.prevented) {
|
531
|
+
return;
|
532
|
+
}
|
533
|
+
|
534
|
+
onChange && onChange(result);
|
499
535
|
}
|
500
536
|
|
501
537
|
/**
|
@@ -504,20 +540,27 @@ export default class RangeControl extends React.PureComponent<
|
|
504
540
|
@autobind
|
505
541
|
onAfterChange() {
|
506
542
|
const {value} = this.state;
|
507
|
-
const {
|
508
|
-
|
509
|
-
|
510
|
-
|
511
|
-
|
512
|
-
|
513
|
-
|
514
|
-
|
515
|
-
|
516
|
-
|
517
|
-
|
518
|
-
|
519
|
-
|
520
|
-
|
543
|
+
const {onAfterChange, dispatchEvent, data} = this.props;
|
544
|
+
const result = this.getFormatValue(value);
|
545
|
+
onAfterChange && onAfterChange(result);
|
546
|
+
}
|
547
|
+
|
548
|
+
/**
|
549
|
+
* 获取导出格式数据
|
550
|
+
*/
|
551
|
+
@autobind
|
552
|
+
getFormatValue(value: FormatValue) {
|
553
|
+
const {multiple, joinValues, delimiter} = this.props;
|
554
|
+
return multiple
|
555
|
+
? joinValues
|
556
|
+
? [(value as MultipleValue).min, (value as MultipleValue).max].join(
|
557
|
+
delimiter || ','
|
558
|
+
)
|
559
|
+
: {
|
560
|
+
min: (value as MultipleValue).min,
|
561
|
+
max: (value as MultipleValue).max
|
562
|
+
}
|
563
|
+
: value;
|
521
564
|
}
|
522
565
|
|
523
566
|
render() {
|
@@ -539,7 +582,10 @@ export default class RangeControl extends React.PureComponent<
|
|
539
582
|
disabled,
|
540
583
|
clearable,
|
541
584
|
min,
|
542
|
-
max
|
585
|
+
max,
|
586
|
+
render,
|
587
|
+
marks,
|
588
|
+
region
|
543
589
|
} = props;
|
544
590
|
|
545
591
|
// 指定parts -> 重新计算步长
|
@@ -548,6 +594,19 @@ export default class RangeControl extends React.PureComponent<
|
|
548
594
|
props.showSteps = true;
|
549
595
|
}
|
550
596
|
|
597
|
+
// 处理自定义json配置
|
598
|
+
let renderMarks:
|
599
|
+
| MarksType
|
600
|
+
| {[index: number | string]: ReactNode}
|
601
|
+
| undefined = marks ? {...marks} : marks;
|
602
|
+
marks &&
|
603
|
+
forEach(marks, (item, key) => {
|
604
|
+
if (isObject(item) && (item as SchemaObject).type) {
|
605
|
+
renderMarks &&
|
606
|
+
(renderMarks[key] = render(region, item as SchemaObject));
|
607
|
+
}
|
608
|
+
});
|
609
|
+
|
551
610
|
return (
|
552
611
|
<div
|
553
612
|
className={cx(
|
@@ -558,7 +617,7 @@ export default class RangeControl extends React.PureComponent<
|
|
558
617
|
)}
|
559
618
|
>
|
560
619
|
{showInput && multiple && <Input {...props} type="min" />}
|
561
|
-
<InputRange {...props} />
|
620
|
+
<InputRange {...props} marks={renderMarks} />
|
562
621
|
{showInput && <Input {...props} type="max" />}
|
563
622
|
{clearable && !disabled && showInput ? (
|
564
623
|
<a
|
@@ -390,6 +390,8 @@ export default class SelectControl extends React.Component<SelectProps, any> {
|
|
390
390
|
popOverContainer={
|
391
391
|
mobileUI && env && env.getModalContainer
|
392
392
|
? env.getModalContainer
|
393
|
+
: mobileUI
|
394
|
+
? undefined
|
393
395
|
: rest.popOverContainer
|
394
396
|
}
|
395
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;
|
package/src/renderers/Tabs.tsx
CHANGED
@@ -335,7 +335,7 @@ export default class Tabs extends React.Component<TabsProps, TabsState> {
|
|
335
335
|
localTabs = newLocalTabs;
|
336
336
|
}
|
337
337
|
|
338
|
-
if (props.location && props.location.hash !== preProps.location.hash) {
|
338
|
+
if (props.location && preProps.location && props.location.hash !== preProps.location.hash) {
|
339
339
|
const hash = props.location.hash.substring(1);
|
340
340
|
if (!hash) {
|
341
341
|
return;
|