amis 1.6.5-beta.4 → 1.8.0-beta.1
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/Avatar.d.ts +20 -20
- package/lib/components/Card.d.ts +20 -20
- package/lib/components/CityArea.js +3 -0
- package/lib/components/CityArea.js.map +2 -2
- package/lib/components/DatePicker.d.ts +3 -0
- package/lib/components/DatePicker.js +41 -7
- package/lib/components/DatePicker.js.map +2 -2
- 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/Progress.js +12 -9
- package/lib/components/Progress.js.map +2 -2
- package/lib/components/Range.js.map +2 -2
- package/lib/components/Tabs.d.ts +27 -23
- package/lib/components/Tabs.js +37 -22
- 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/calendar/Calendar.js +16 -12
- package/lib/components/calendar/Calendar.js.map +2 -2
- package/lib/components/formula/Editor.d.ts +3 -1
- package/lib/components/formula/Editor.js +20 -2
- package/lib/components/formula/Editor.js.map +2 -2
- package/lib/components/formula/Picker.d.ts +5 -0
- package/lib/components/formula/Picker.js +19 -4
- package/lib/components/formula/Picker.js.map +2 -2
- package/lib/components/icons.js +2 -0
- package/lib/components/icons.js.map +2 -2
- package/lib/factory.js +2 -2
- package/lib/factory.js.map +2 -2
- package/lib/icons/trash.js +10 -0
- package/lib/index.d.ts +1 -0
- package/lib/index.js +2 -1
- package/lib/index.js.map +2 -2
- package/lib/renderers/Action.d.ts +1 -1
- 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/Dialog.d.ts +4 -0
- package/lib/renderers/Dialog.js +4 -3
- package/lib/renderers/Dialog.js.map +2 -2
- package/lib/renderers/DropDownButton.d.ts +2 -0
- package/lib/renderers/DropDownButton.js +13 -4
- package/lib/renderers/DropDownButton.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/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 +4 -1
- package/lib/renderers/Form/InputFile.js +9 -0
- package/lib/renderers/Form/InputFile.js.map +2 -2
- package/lib/renderers/Form/InputFormula.d.ts +4 -0
- package/lib/renderers/Form/InputFormula.js +2 -2
- package/lib/renderers/Form/InputFormula.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/InputTable.js +4 -2
- package/lib/renderers/Form/InputTable.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/Page.js +2 -3
- package/lib/renderers/Page.js.map +2 -2
- package/lib/renderers/PopOver.js +1 -1
- package/lib/renderers/PopOver.js.map +2 -2
- package/lib/renderers/Progress.d.ts +1 -1
- package/lib/renderers/Progress.js +1 -1
- package/lib/renderers/Progress.js.map +2 -2
- package/lib/renderers/Table/TableRow.js +1 -1
- package/lib/renderers/Table/TableRow.js.map +2 -2
- package/lib/renderers/Tabs.d.ts +10 -2
- package/lib/renderers/Tabs.js +3 -3
- 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/table.js +1 -1
- package/lib/store/table.js.map +2 -2
- package/lib/themes/ang-ie11.css +242 -46
- package/lib/themes/ang.css +250 -41
- package/lib/themes/ang.css.map +1 -1
- package/lib/themes/antd-ie11.css +242 -46
- package/lib/themes/antd.css +250 -41
- package/lib/themes/antd.css.map +1 -1
- package/lib/themes/cxd-ie11.css +231 -35
- package/lib/themes/cxd.css +252 -42
- package/lib/themes/cxd.css.map +1 -1
- package/lib/themes/dark-ie11.css +242 -46
- package/lib/themes/dark.css +250 -41
- package/lib/themes/dark.css.map +1 -1
- package/lib/themes/default-ie11.css +231 -35
- package/lib/themes/default.css +252 -42
- package/lib/themes/default.css.map +1 -1
- package/package.json +1 -1
- package/schema.json +15871 -608
- package/scss/_properties.scss +23 -12
- package/scss/components/_alert.scss +1 -1
- package/scss/components/_button-group.scss +15 -0
- package/scss/components/_city-area.scss +2 -0
- package/scss/components/_formula.scss +18 -0
- package/scss/components/_popup.scss +13 -3
- package/scss/components/_progress.scss +3 -8
- package/scss/components/_tabs.scss +145 -13
- package/scss/components/_tooltip.scss +72 -0
- package/scss/components/form/_date.scss +13 -0
- package/scss/components/form/_number.scss +2 -0
- package/scss/components/form/_switch.scss +1 -3
- package/scss/themes/_cxd-variables.scss +2 -1
- package/sdk/ang-ie11.css +287 -48
- package/sdk/ang.css +295 -43
- package/sdk/antd-ie11.css +287 -48
- package/sdk/antd.css +295 -43
- 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 +276 -37
- package/sdk/cxd.css +297 -44
- package/sdk/dark-ie11.css +287 -48
- package/sdk/dark.css +295 -43
- 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 +276 -37
- package/sdk/sdk.css +297 -44
- package/sdk/sdk.js +1251 -1247
- 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/CityArea.tsx +3 -0
- package/src/components/DatePicker.tsx +56 -18
- package/src/components/PopUp.tsx +6 -5
- package/src/components/Progress.tsx +8 -12
- package/src/components/Range.tsx +7 -1
- package/src/components/Tabs.tsx +51 -21
- package/src/components/TooltipWrapper.tsx +4 -1
- package/src/components/calendar/Calendar.tsx +17 -12
- package/src/components/formula/Editor.tsx +34 -3
- package/src/components/formula/Picker.tsx +28 -1
- package/src/components/icons.tsx +2 -0
- package/src/factory.tsx +2 -2
- package/src/icons/trash.svg +8 -0
- package/src/index.tsx +1 -0
- package/src/renderers/Action.tsx +2 -1
- package/src/renderers/ButtonGroup.tsx +2 -2
- package/src/renderers/Dialog.tsx +17 -3
- package/src/renderers/DropDownButton.tsx +14 -3
- 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 +13 -1
- package/src/renderers/Form/InputFormula.tsx +7 -0
- package/src/renderers/Form/InputImage.tsx +32 -12
- package/src/renderers/Form/InputRange.tsx +95 -40
- package/src/renderers/Form/InputTable.tsx +6 -2
- 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/Page.tsx +1 -2
- package/src/renderers/PopOver.tsx +1 -1
- package/src/renderers/Progress.tsx +2 -2
- package/src/renderers/Table/TableRow.tsx +1 -1
- package/src/renderers/Tabs.tsx +16 -4
- package/src/renderers/TooltipWrapper.tsx +219 -0
- package/src/renderers/Video.tsx +21 -6
- package/src/store/table.ts +1 -1
package/src/Schema.ts
CHANGED
@@ -52,6 +52,7 @@ import {DialogSchema, DialogSchemaBase} from './renderers/Dialog';
|
|
52
52
|
import {DrawerSchema} from './renderers/Drawer';
|
53
53
|
import {SearchBoxSchema} from './renderers/SearchBox';
|
54
54
|
import {SparkLineSchema} from './renderers/SparkLine';
|
55
|
+
import {TooltipWrapperSchema} from './renderers/TooltipWrapper';
|
55
56
|
import {PaginationWrapperSchema} from './renderers/PaginationWrapper';
|
56
57
|
import {PaginationSchema} from './renderers/Pagination';
|
57
58
|
import {AnchorNavSchema} from './renderers/AnchorNav';
|
@@ -331,7 +332,8 @@ export type SchemaType =
|
|
331
332
|
| 'native-date'
|
332
333
|
| 'native-time'
|
333
334
|
| 'native-number'
|
334
|
-
| 'code'
|
335
|
+
| 'code'
|
336
|
+
| 'tooltip-wrapper';
|
335
337
|
|
336
338
|
export type SchemaObject =
|
337
339
|
| PageSchema
|
@@ -389,6 +391,7 @@ export type SchemaObject =
|
|
389
391
|
| VideoSchema
|
390
392
|
| WizardSchema
|
391
393
|
| WrapperSchema
|
394
|
+
| TooltipWrapperSchema
|
392
395
|
| FormSchema
|
393
396
|
| AnchorNavSchema
|
394
397
|
| StepsSchema
|
@@ -882,4 +885,4 @@ export interface ToastSchemaBase extends BaseSchema {
|
|
882
885
|
* 持续时间
|
883
886
|
*/
|
884
887
|
timeout: number;
|
885
|
-
}
|
888
|
+
}
|
@@ -5,7 +5,8 @@
|
|
5
5
|
|
6
6
|
import React from 'react';
|
7
7
|
import {ClassNamesFn, themeable} from '../theme';
|
8
|
-
import {
|
8
|
+
import {generateIcon} from '../utils/icon';
|
9
|
+
import {Icon, getIcon} from './icons';
|
9
10
|
|
10
11
|
export interface AlertProps {
|
11
12
|
level: 'danger' | 'info' | 'success' | 'warning';
|
@@ -73,16 +74,21 @@ export class Alert extends React.Component<AlertProps, AlertState> {
|
|
73
74
|
closeButtonClassName
|
74
75
|
} = this.props;
|
75
76
|
|
77
|
+
// 优先使用内置svg,其次使用icon库
|
76
78
|
const iconNode = icon ? (
|
77
79
|
typeof icon === 'string' ? (
|
78
|
-
|
80
|
+
getIcon(icon) ? (
|
81
|
+
<Icon icon={icon} className={cx(`icon`)} />
|
82
|
+
) : (
|
83
|
+
generateIcon(cx, icon, 'icon')
|
84
|
+
)
|
79
85
|
) : React.isValidElement(icon) ? (
|
80
86
|
React.cloneElement(icon, {
|
81
87
|
className: cx(`Alert-icon`, icon.props?.className)
|
82
88
|
})
|
83
89
|
) : null
|
84
90
|
) : showIcon ? (
|
85
|
-
<Icon icon={`alert-${level}`} className={cx(`
|
91
|
+
<Icon icon={`alert-${level}`} className={cx(`icon`)} />
|
86
92
|
) : null;
|
87
93
|
|
88
94
|
return this.state.show ? (
|
@@ -145,8 +145,11 @@ const CityArea = memo<AreaProps>(props => {
|
|
145
145
|
} else {
|
146
146
|
onChange({
|
147
147
|
code,
|
148
|
+
provinceCode: province,
|
148
149
|
province: db[province],
|
150
|
+
cityCode: city,
|
149
151
|
city: db[city],
|
152
|
+
districtCode: district,
|
150
153
|
district: db[district],
|
151
154
|
street
|
152
155
|
});
|
@@ -17,6 +17,7 @@ import Calendar from './calendar/Calendar';
|
|
17
17
|
import {localeable, LocaleProps, TranslateFn} from '../locale';
|
18
18
|
import {isMobile, ucFirst} from '../utils/helper';
|
19
19
|
import CalendarMobile from './CalendarMobile';
|
20
|
+
import Input from './Input';
|
20
21
|
|
21
22
|
const availableShortcuts: {[propName: string]: any} = {
|
22
23
|
now: {
|
@@ -302,6 +303,7 @@ export interface DatePickerState {
|
|
302
303
|
isOpened: boolean;
|
303
304
|
isFocused: boolean;
|
304
305
|
value: moment.Moment | undefined;
|
306
|
+
inputValue: string | undefined; // 手动输入的值
|
305
307
|
}
|
306
308
|
|
307
309
|
function normalizeValue(value: any, format?: string) {
|
@@ -329,11 +331,15 @@ export class DatePicker extends React.Component<DateProps, DatePickerState> {
|
|
329
331
|
state: DatePickerState = {
|
330
332
|
isOpened: false,
|
331
333
|
isFocused: false,
|
332
|
-
value: normalizeValue(this.props.value, this.props.format)
|
334
|
+
value: normalizeValue(this.props.value, this.props.format),
|
335
|
+
inputValue:
|
336
|
+
normalizeValue(this.props.value, this.props.format)?.format(
|
337
|
+
this.props.inputFormat
|
338
|
+
) || ''
|
333
339
|
};
|
334
340
|
constructor(props: DateProps) {
|
335
341
|
super(props);
|
336
|
-
|
342
|
+
this.inputRef = React.createRef();
|
337
343
|
this.handleChange = this.handleChange.bind(this);
|
338
344
|
this.selectRannge = this.selectRannge.bind(this);
|
339
345
|
this.checkIsValidDate = this.checkIsValidDate.bind(this);
|
@@ -348,10 +354,13 @@ export class DatePicker extends React.Component<DateProps, DatePickerState> {
|
|
348
354
|
this.getTarget = this.getTarget.bind(this);
|
349
355
|
this.handlePopOverClick = this.handlePopOverClick.bind(this);
|
350
356
|
this.renderShortCuts = this.renderShortCuts.bind(this);
|
357
|
+
this.inputChange = this.inputChange.bind(this);
|
351
358
|
}
|
352
359
|
|
353
360
|
dom: HTMLDivElement;
|
354
361
|
|
362
|
+
inputRef: React.RefObject<HTMLInputElement>;
|
363
|
+
|
355
364
|
componentDidUpdate(prevProps: DateProps) {
|
356
365
|
const props = this.props;
|
357
366
|
|
@@ -403,13 +412,17 @@ export class DatePicker extends React.Component<DateProps, DatePickerState> {
|
|
403
412
|
}
|
404
413
|
|
405
414
|
open(fn?: () => void) {
|
406
|
-
this.props.disabled
|
407
|
-
|
408
|
-
|
409
|
-
|
410
|
-
|
411
|
-
|
412
|
-
|
415
|
+
if (this.props.disabled) {
|
416
|
+
return;
|
417
|
+
}
|
418
|
+
this.setState(
|
419
|
+
{
|
420
|
+
isOpened: true
|
421
|
+
},
|
422
|
+
fn
|
423
|
+
);
|
424
|
+
const input = this.inputRef.current;
|
425
|
+
input && input.focus();
|
413
426
|
}
|
414
427
|
|
415
428
|
close() {
|
@@ -423,6 +436,7 @@ export class DatePicker extends React.Component<DateProps, DatePickerState> {
|
|
423
436
|
e.stopPropagation();
|
424
437
|
const onChange = this.props.onChange;
|
425
438
|
onChange('');
|
439
|
+
this.setState({inputValue: ''});
|
426
440
|
}
|
427
441
|
|
428
442
|
handleChange(value: moment.Moment) {
|
@@ -432,6 +446,7 @@ export class DatePicker extends React.Component<DateProps, DatePickerState> {
|
|
432
446
|
minDate,
|
433
447
|
maxDate,
|
434
448
|
dateFormat,
|
449
|
+
inputFormat,
|
435
450
|
timeFormat,
|
436
451
|
closeOnSelect,
|
437
452
|
utc,
|
@@ -453,6 +468,31 @@ export class DatePicker extends React.Component<DateProps, DatePickerState> {
|
|
453
468
|
if (closeOnSelect && dateFormat && !timeFormat) {
|
454
469
|
this.close();
|
455
470
|
}
|
471
|
+
|
472
|
+
this.setState({
|
473
|
+
inputValue: utc
|
474
|
+
? moment.utc(value).format(inputFormat)
|
475
|
+
: value.format(inputFormat)
|
476
|
+
});
|
477
|
+
}
|
478
|
+
|
479
|
+
// 手动输入日期
|
480
|
+
inputChange(e: React.ChangeEvent<HTMLInputElement>) {
|
481
|
+
const {onChange, inputFormat, format, utc} = this.props;
|
482
|
+
const value = e.currentTarget.value;
|
483
|
+
this.setState({inputValue: value});
|
484
|
+
if (value === '') {
|
485
|
+
onChange('');
|
486
|
+
} else {
|
487
|
+
const newDate = moment(value, inputFormat);
|
488
|
+
const dateValue = utc
|
489
|
+
? moment.utc(newDate).format(format)
|
490
|
+
: newDate.format(format);
|
491
|
+
// 小于 0 的日期丢弃
|
492
|
+
if (!dateValue.startsWith('-')) {
|
493
|
+
onChange(dateValue);
|
494
|
+
}
|
495
|
+
}
|
456
496
|
}
|
457
497
|
|
458
498
|
selectRannge(item: any) {
|
@@ -693,15 +733,13 @@ export class DatePicker extends React.Component<DateProps, DatePickerState> {
|
|
693
733
|
ref={this.domRef}
|
694
734
|
onClick={this.handleClick}
|
695
735
|
>
|
696
|
-
|
697
|
-
|
698
|
-
|
699
|
-
|
700
|
-
|
701
|
-
|
702
|
-
|
703
|
-
</span>
|
704
|
-
)}
|
736
|
+
<Input
|
737
|
+
onChange={this.inputChange}
|
738
|
+
ref={this.inputRef}
|
739
|
+
placeholder={__(placeholder)}
|
740
|
+
autoComplete="off"
|
741
|
+
value={this.state.inputValue}
|
742
|
+
/>
|
705
743
|
|
706
744
|
{clearable && !disabled && normalizeValue(value, format) ? (
|
707
745
|
<a className={cx(`DatePicker-clear`)} onClick={this.clearValue}>
|
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 && (
|
@@ -74,19 +74,15 @@ export class Progress extends React.Component<ProgressProps, Object> {
|
|
74
74
|
const isLineType = type === 'line';
|
75
75
|
const prefixCls = isLineType ? 'Progress-line' : 'Progress-circle';
|
76
76
|
|
77
|
-
let viewValue: React.ReactNode
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
77
|
+
let viewValue: React.ReactNode;
|
78
|
+
if (typeof value !== 'number') {
|
79
|
+
viewValue = <span className="text-muted">{placeholder}</span>;
|
80
|
+
} else if (type === 'line') {
|
81
|
+
const style: any = {};
|
82
|
+
strokeWidth && (style.height = strokeWidth);
|
82
83
|
viewValue = [
|
83
|
-
<div
|
84
|
-
|
85
|
-
className={cx(prefixCls, progressClassName, {
|
86
|
-
[`${prefixCls}-no-label`]: !showLabel
|
87
|
-
})}
|
88
|
-
>
|
89
|
-
<div className={cx(`${prefixCls}-inter`)}>
|
84
|
+
<div key="progress" className={cx(prefixCls, progressClassName)}>
|
85
|
+
<div className={cx(`${prefixCls}-inter`)} style={style}>
|
90
86
|
<div
|
91
87
|
className={cx(
|
92
88
|
`${prefixCls}-bar`,
|
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;
|
package/src/components/Tabs.tsx
CHANGED
@@ -16,6 +16,7 @@ import {Icon} from './icons';
|
|
16
16
|
import debounce from 'lodash/debounce';
|
17
17
|
import {findDOMNode} from 'react-dom';
|
18
18
|
import TooltipWrapper, {TooltipObject, Trigger} from './TooltipWrapper';
|
19
|
+
import {resizeSensor} from '../utils/resize-sensor';
|
19
20
|
|
20
21
|
import Sortable from 'sortablejs';
|
21
22
|
|
@@ -26,7 +27,7 @@ const transitionStyles: {
|
|
26
27
|
[ENTERED]: 'in'
|
27
28
|
};
|
28
29
|
|
29
|
-
export type TabsMode = '' | 'line' | 'card' | 'radio' | 'vertical' | 'chrome' | 'simple' | 'strong';
|
30
|
+
export type TabsMode = '' | 'line' | 'card' | 'radio' | 'vertical' | 'chrome' | 'simple' | 'strong' | 'tiled' |'sidebar';
|
30
31
|
|
31
32
|
export interface TabProps extends ThemeProps {
|
32
33
|
title?: string | React.ReactNode; // 标题
|
@@ -114,6 +115,8 @@ export interface TabsProps extends ThemeProps {
|
|
114
115
|
scrollable?: boolean; // 属性废弃,为了兼容暂且保留
|
115
116
|
editable?: boolean;
|
116
117
|
onEdit?: (index: number, text: string) => void;
|
118
|
+
sidePosition?: 'left' | 'right';
|
119
|
+
addBtnText?: string;
|
117
120
|
}
|
118
121
|
|
119
122
|
export interface IDragInfo {
|
@@ -122,21 +125,25 @@ export interface IDragInfo {
|
|
122
125
|
|
123
126
|
export class Tabs extends React.Component<TabsProps, any> {
|
124
127
|
static defaultProps: Pick<TabsProps,
|
125
|
-
'mode' | 'contentClassName' | 'showTip' | 'showTipClassName'
|
128
|
+
'mode' | 'contentClassName' | 'showTip' | 'showTipClassName' | 'sidePosition' | 'addBtnText'
|
126
129
|
> = {
|
127
130
|
mode: '',
|
128
131
|
contentClassName: '',
|
129
132
|
showTip: false,
|
130
|
-
showTipClassName: ''
|
133
|
+
showTipClassName: '',
|
134
|
+
sidePosition: 'left',
|
135
|
+
addBtnText: '增加'
|
131
136
|
};
|
132
137
|
|
133
138
|
static Tab = Tab;
|
134
|
-
navMain = React.createRef<
|
139
|
+
navMain = React.createRef<HTMLUListElement>(); // HTMLDivElement
|
135
140
|
scroll: boolean = false;
|
136
141
|
sortable?: Sortable;
|
137
142
|
dragTip?: HTMLElement;
|
138
143
|
id: string = guid();
|
139
144
|
draging: boolean = false;
|
145
|
+
toDispose: Array<() => void> = [];
|
146
|
+
resizeDom = React.createRef<HTMLDivElement>();
|
140
147
|
|
141
148
|
checkArrowStatus = debounce(
|
142
149
|
() => {
|
@@ -200,6 +207,12 @@ export class Tabs extends React.Component<TabsProps, any> {
|
|
200
207
|
});
|
201
208
|
this.checkArrowStatus();
|
202
209
|
}
|
210
|
+
|
211
|
+
this.resizeDom?.current && this.toDispose.push(
|
212
|
+
resizeSensor(this.resizeDom.current as HTMLElement, () =>
|
213
|
+
this.computedWidth()
|
214
|
+
)
|
215
|
+
);
|
203
216
|
}
|
204
217
|
|
205
218
|
componentDidUpdate() {
|
@@ -212,6 +225,8 @@ export class Tabs extends React.Component<TabsProps, any> {
|
|
212
225
|
|
213
226
|
componentWillUnmount() {
|
214
227
|
this.checkArrowStatus.cancel();
|
228
|
+
this.toDispose.forEach(fn => fn());
|
229
|
+
this.toDispose = [];
|
215
230
|
}
|
216
231
|
|
217
232
|
/**
|
@@ -220,7 +235,7 @@ export class Tabs extends React.Component<TabsProps, any> {
|
|
220
235
|
computedWidth() {
|
221
236
|
const {mode: dMode, tabsMode} = this.props;
|
222
237
|
const mode = tabsMode || dMode;
|
223
|
-
if (
|
238
|
+
if (['vertical', 'sidebar'].includes(mode)) {
|
224
239
|
return;
|
225
240
|
}
|
226
241
|
|
@@ -246,7 +261,7 @@ export class Tabs extends React.Component<TabsProps, any> {
|
|
246
261
|
const {mode: dMode, tabsMode} = this.props;
|
247
262
|
const {isOverflow} = this.state;
|
248
263
|
const mode = tabsMode || dMode;
|
249
|
-
if (
|
264
|
+
if (['vertical', 'sidebar'].includes(mode) || !isOverflow) {
|
250
265
|
return;
|
251
266
|
}
|
252
267
|
const {activeKey, children} = this.props;
|
@@ -254,7 +269,7 @@ export class Tabs extends React.Component<TabsProps, any> {
|
|
254
269
|
const currentIndex = (children as any[])?.findIndex(
|
255
270
|
(item: any) => item.props.eventKey === currentKey
|
256
271
|
);
|
257
|
-
const li = this.navMain.current?.children
|
272
|
+
const li = this.navMain.current?.children || [];
|
258
273
|
const currentLi = li[currentIndex] as HTMLElement;
|
259
274
|
const liOffsetLeft = currentLi?.offsetLeft;
|
260
275
|
const liClientWidth = currentLi?.clientWidth;
|
@@ -569,7 +584,7 @@ export class Tabs extends React.Component<TabsProps, any> {
|
|
569
584
|
renderArrow(type: 'left' | 'right') {
|
570
585
|
const {mode: dMode, tabsMode} = this.props;
|
571
586
|
const mode = tabsMode || dMode;
|
572
|
-
if (
|
587
|
+
if (['vertical', 'sidebar'].includes(mode)) {
|
573
588
|
return;
|
574
589
|
}
|
575
590
|
const {classnames: cx} = this.props;
|
@@ -607,7 +622,9 @@ export class Tabs extends React.Component<TabsProps, any> {
|
|
607
622
|
toolbar,
|
608
623
|
linksClassName,
|
609
624
|
addable,
|
610
|
-
draggable
|
625
|
+
draggable,
|
626
|
+
sidePosition,
|
627
|
+
addBtnText
|
611
628
|
} = this.props;
|
612
629
|
|
613
630
|
const {isOverflow} = this.state;
|
@@ -617,19 +634,35 @@ export class Tabs extends React.Component<TabsProps, any> {
|
|
617
634
|
|
618
635
|
const mode = tabsMode || dMode;
|
619
636
|
|
637
|
+
const toolButtons = (
|
638
|
+
<>
|
639
|
+
{addable && (
|
640
|
+
<div className={cx('Tabs-addable')} onClick={() => this.handleAddBtn()}>
|
641
|
+
<Icon icon="plus" className={cx('Tabs-addable-icon')} />
|
642
|
+
{addBtnText}
|
643
|
+
</div>
|
644
|
+
)}
|
645
|
+
{toolbar}
|
646
|
+
</>
|
647
|
+
);
|
648
|
+
|
620
649
|
return (
|
621
650
|
<div
|
622
651
|
className={cx(
|
623
652
|
`Tabs`,
|
624
653
|
{
|
625
|
-
[`Tabs--${mode}`]: mode
|
654
|
+
[`Tabs--${mode}`]: mode,
|
655
|
+
[`sidebar--${sidePosition}`]: mode === 'sidebar'
|
626
656
|
},
|
627
657
|
className
|
628
658
|
)}
|
629
659
|
>
|
630
660
|
{
|
631
|
-
!['vertical', 'chrome'].includes(mode) ? (
|
632
|
-
<div
|
661
|
+
!['vertical', 'sidebar', 'chrome'].includes(mode) ? (
|
662
|
+
<div
|
663
|
+
className={cx('Tabs-linksContainer-wrapper', toolbar && 'Tabs-linksContainer-wrapper--toolbar')}
|
664
|
+
ref={this.resizeDom}
|
665
|
+
>
|
633
666
|
<div
|
634
667
|
className={cx(
|
635
668
|
'Tabs-linksContainer',
|
@@ -637,22 +670,19 @@ export class Tabs extends React.Component<TabsProps, any> {
|
|
637
670
|
)}
|
638
671
|
>
|
639
672
|
{this.renderArrow('left')}
|
640
|
-
<div className={cx('Tabs-linksContainer-main')}
|
641
|
-
<ul className={cx('Tabs-links', linksClassName)} role="tablist">
|
673
|
+
<div className={cx('Tabs-linksContainer-main')}>
|
674
|
+
<ul className={cx('Tabs-links', linksClassName)} role="tablist" ref={this.navMain}>
|
642
675
|
{children.map((tab, index) => this.renderNav(tab, index))}
|
643
676
|
{additionBtns}
|
644
|
-
{
|
677
|
+
{
|
678
|
+
!isOverflow && toolButtons
|
679
|
+
}
|
645
680
|
</ul>
|
646
681
|
</div>
|
647
682
|
{this.renderArrow('right')}
|
648
683
|
</div>
|
649
684
|
{
|
650
|
-
|
651
|
-
<div className={cx('Tabs-addable')} onClick={() => this.handleAddBtn()}>
|
652
|
-
<Icon icon="plus" className={cx('Tabs-addable-icon')} />
|
653
|
-
增加
|
654
|
-
</div>
|
655
|
-
)
|
685
|
+
isOverflow && toolButtons
|
656
686
|
}
|
657
687
|
</div>
|
658
688
|
) : (
|
@@ -33,6 +33,7 @@ export interface TooltipWrapperProps {
|
|
33
33
|
delay: number;
|
34
34
|
theme?: string;
|
35
35
|
tooltipClassName?: string;
|
36
|
+
style?: React.CSSProperties;
|
36
37
|
}
|
37
38
|
|
38
39
|
interface TooltipWrapperState {
|
@@ -167,7 +168,8 @@ export class TooltipWrapper extends React.Component<
|
|
167
168
|
container,
|
168
169
|
trigger,
|
169
170
|
rootClose,
|
170
|
-
tooltipClassName
|
171
|
+
tooltipClassName,
|
172
|
+
style
|
171
173
|
} = this.props;
|
172
174
|
|
173
175
|
const child = React.Children.only(children);
|
@@ -210,6 +212,7 @@ export class TooltipWrapper extends React.Component<
|
|
210
212
|
>
|
211
213
|
<Tooltip
|
212
214
|
title={typeof tooltip !== 'string' ? tooltip.title : undefined}
|
215
|
+
style={style}
|
213
216
|
className={tooltipClassName}
|
214
217
|
onMouseEnter={~triggers.indexOf('hover') && this.handleMouseOver}
|
215
218
|
onMouseLeave={~triggers.indexOf('hover') && this.handleMouseOut}
|
@@ -161,18 +161,19 @@ class BaseDatePicker extends React.Component<
|
|
161
161
|
updatedState = this.getStateFromProps(props);
|
162
162
|
}
|
163
163
|
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
}
|
164
|
+
// open 是外部控制了
|
165
|
+
// if (updatedState.open === undefined) {
|
166
|
+
// if (typeof props.open !== 'undefined') {
|
167
|
+
// updatedState.open = props.open;
|
168
|
+
// } else if (
|
169
|
+
// prevProps.closeOnSelect &&
|
170
|
+
// this.state.currentView !== viewModes.TIME
|
171
|
+
// ) {
|
172
|
+
// updatedState.open = false;
|
173
|
+
// } else {
|
174
|
+
// updatedState.open = this.state.open;
|
175
|
+
// }
|
176
|
+
// }
|
176
177
|
|
177
178
|
if (props.viewMode !== prevProps.viewMode) {
|
178
179
|
updatedState.currentView = props.viewMode;
|
@@ -236,6 +237,10 @@ class BaseDatePicker extends React.Component<
|
|
236
237
|
updatedState.viewDate = moment(props.viewDate);
|
237
238
|
}
|
238
239
|
|
240
|
+
if (Object.keys(updatedState).length) {
|
241
|
+
this.setState(updatedState);
|
242
|
+
}
|
243
|
+
|
239
244
|
this.checkTZ(props);
|
240
245
|
}
|
241
246
|
|
@@ -10,7 +10,7 @@ import {FormulaPlugin, editorFactory} from './plugin';
|
|
10
10
|
import FuncList from './FuncList';
|
11
11
|
import {VariableList} from './VariableList';
|
12
12
|
import CodeMirrorEditor from '../CodeMirror';
|
13
|
-
import {autobind} from '../../utils/helper';
|
13
|
+
import {autobind, eachTree} from '../../utils/helper';
|
14
14
|
import {themeable, ThemeProps} from '../../theme';
|
15
15
|
import {localeable, LocaleProps} from '../../locale';
|
16
16
|
|
@@ -133,8 +133,39 @@ export class FormulaEditor extends React.Component<
|
|
133
133
|
variables: Array<VariableItem>,
|
134
134
|
functions: Array<FuncGroup>
|
135
135
|
) {
|
136
|
-
|
137
|
-
|
136
|
+
if (!Array.isArray(variables) || !variables.length || !value) {
|
137
|
+
return;
|
138
|
+
}
|
139
|
+
|
140
|
+
const varMap: {
|
141
|
+
[propname: string]: string;
|
142
|
+
} = {};
|
143
|
+
|
144
|
+
eachTree(
|
145
|
+
variables,
|
146
|
+
item => item.value && (varMap[item.value] = item.label)
|
147
|
+
);
|
148
|
+
const vars = Object.keys(varMap).sort((a, b) => b.length - a.length);
|
149
|
+
let content = value || '';
|
150
|
+
|
151
|
+
// 标记方法调用
|
152
|
+
content = content.replace(/([A-Z]+)\s*\(/g, (_, func, pos) => {
|
153
|
+
return _?.replace(func, `<span class="c-func">${func}</span>`);
|
154
|
+
});
|
155
|
+
|
156
|
+
vars.forEach(v => {
|
157
|
+
let from = 0;
|
158
|
+
let idx = -1;
|
159
|
+
while (~(idx = content.indexOf(v, from))) {
|
160
|
+
content = content.replace(
|
161
|
+
v,
|
162
|
+
`<span class="c-field">${varMap[v]}</span>`
|
163
|
+
);
|
164
|
+
from = idx + v.length;
|
165
|
+
}
|
166
|
+
});
|
167
|
+
|
168
|
+
return {html: content};
|
138
169
|
}
|
139
170
|
|
140
171
|
componentWillUnmount() {
|
@@ -69,6 +69,11 @@ export interface FormulaPickerProps extends FormulaEditorProps {
|
|
69
69
|
*/
|
70
70
|
disabled?: boolean;
|
71
71
|
|
72
|
+
/**
|
73
|
+
* 是否允许输入,否需要点击fx在弹窗中输入
|
74
|
+
*/
|
75
|
+
allowInput?: boolean;
|
76
|
+
|
72
77
|
/**
|
73
78
|
* 占位文本
|
74
79
|
*/
|
@@ -96,12 +101,28 @@ export class FormulaPicker extends React.Component<FormulaPickerProps> {
|
|
96
101
|
this.props.onChange?.(value);
|
97
102
|
}
|
98
103
|
|
104
|
+
@autobind
|
105
|
+
renderFormulaValue(item: any) {
|
106
|
+
const {allowInput, classnames: cx} = this.props;
|
107
|
+
const html = {__html: item.html};
|
108
|
+
if (allowInput) {
|
109
|
+
return '';
|
110
|
+
}
|
111
|
+
return (
|
112
|
+
<div
|
113
|
+
className={cx('FormulaPicker-ResultBox')}
|
114
|
+
dangerouslySetInnerHTML={html}
|
115
|
+
></div>
|
116
|
+
);
|
117
|
+
}
|
118
|
+
|
99
119
|
render() {
|
100
120
|
let {
|
101
121
|
classnames: cx,
|
102
122
|
value,
|
103
123
|
translate: __,
|
104
124
|
disabled,
|
125
|
+
allowInput,
|
105
126
|
className,
|
106
127
|
onChange,
|
107
128
|
size,
|
@@ -186,9 +207,15 @@ export class FormulaPicker extends React.Component<FormulaPickerProps> {
|
|
186
207
|
'FormulaPicker-input',
|
187
208
|
isOpened ? 'is-active' : ''
|
188
209
|
)}
|
189
|
-
allowInput
|
210
|
+
allowInput={allowInput}
|
190
211
|
clearable={clearable}
|
191
212
|
value={value}
|
213
|
+
result={FormulaEditor.highlightValue(
|
214
|
+
value,
|
215
|
+
variables,
|
216
|
+
functions
|
217
|
+
)}
|
218
|
+
itemRender={this.renderFormulaValue}
|
192
219
|
onResultChange={noop}
|
193
220
|
onChange={this.handleConfirm}
|
194
221
|
disabled={disabled}
|
package/src/components/icons.tsx
CHANGED
@@ -83,6 +83,7 @@ import AlertDanger from '../icons/alert-danger.svg';
|
|
83
83
|
import FunctionIcon from '../icons/function.svg';
|
84
84
|
import InputClearIcon from '../icons/input-clear.svg';
|
85
85
|
import SliderHandleIcon from '../icons/slider-handle-icon.svg';
|
86
|
+
import TrashIcon from '../icons/trash.svg';
|
86
87
|
|
87
88
|
// 兼容原来的用法,后续不直接试用。
|
88
89
|
|
@@ -192,6 +193,7 @@ registerIcon('slider-handle', SliderHandleIcon);
|
|
192
193
|
registerIcon('cloud-upload', CloudUploadIcon);
|
193
194
|
registerIcon('image', ImageIcon);
|
194
195
|
registerIcon('refresh', RefreshIcon);
|
196
|
+
registerIcon('trash', TrashIcon);
|
195
197
|
|
196
198
|
export function Icon({
|
197
199
|
icon,
|