amis 1.3.5-beta.6 → 1.4.1-echarts-5.3.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/components/Badge.d.ts +15 -2
- package/lib/components/Badge.js +47 -4
- package/lib/components/Badge.js.map +2 -2
- package/lib/components/Button.d.ts +24 -22
- package/lib/components/Button.js +13 -7
- package/lib/components/Button.js.map +2 -2
- package/lib/components/Checkbox.d.ts +1 -1
- package/lib/components/Checkbox.js +1 -1
- package/lib/components/Checkbox.js.map +2 -2
- package/lib/components/Drawer.js +1 -1
- package/lib/components/Drawer.js.map +2 -2
- package/lib/components/Modal.js +1 -1
- package/lib/components/Modal.js.map +2 -2
- package/lib/components/RichText.d.ts +6 -1
- package/lib/components/RichText.js +243 -8
- package/lib/components/RichText.js.map +2 -2
- package/lib/components/Select.d.ts +7 -0
- package/lib/components/Select.js.map +2 -2
- package/lib/components/Steps.d.ts +3 -3
- package/lib/components/Steps.js.map +1 -1
- package/lib/components/WithRemoteConfig.d.ts +8 -0
- package/lib/components/WithRemoteConfig.js +28 -2
- package/lib/components/WithRemoteConfig.js.map +2 -2
- package/lib/components/calendar/DaysView.js +2 -2
- package/lib/components/calendar/DaysView.js.map +2 -2
- package/lib/components/condition-builder/Field.js +0 -1
- package/lib/components/condition-builder/Field.js.map +2 -2
- package/lib/components/condition-builder/Value.js +2 -1
- package/lib/components/condition-builder/Value.js.map +2 -2
- package/lib/components/condition-builder/types.d.ts +5 -0
- package/lib/components/condition-builder/types.js.map +1 -1
- package/lib/components/icons.js +2 -0
- package/lib/components/icons.js.map +2 -2
- package/lib/factory.d.ts +5 -1
- package/lib/factory.js +9 -4
- package/lib/factory.js.map +2 -2
- package/lib/helper.css.map +1 -1
- package/lib/icons/loading-outline.js +7 -0
- package/lib/index.js +1 -1
- package/lib/locale/de-DE.js +1 -0
- package/lib/locale/de-DE.js.map +2 -2
- package/lib/locale/en-US.js +2 -1
- package/lib/locale/en-US.js.map +2 -2
- package/lib/locale/zh-CN.js +2 -1
- package/lib/locale/zh-CN.js.map +2 -2
- package/lib/renderers/Action.d.ts +9 -1
- package/lib/renderers/Action.js +5 -5
- package/lib/renderers/Action.js.map +2 -2
- package/lib/renderers/CRUD.d.ts +2 -2
- package/lib/renderers/CRUD.js +11 -20
- package/lib/renderers/CRUD.js.map +2 -2
- package/lib/renderers/Collapse.d.ts +1 -1
- package/lib/renderers/Collapse.js +5 -1
- package/lib/renderers/Collapse.js.map +2 -2
- package/lib/renderers/Dialog.d.ts +0 -252
- package/lib/renderers/Dialog.js +1 -1
- package/lib/renderers/Dialog.js.map +2 -2
- package/lib/renderers/DropDownButton.d.ts +8 -0
- package/lib/renderers/DropDownButton.js +6 -4
- package/lib/renderers/DropDownButton.js.map +2 -2
- package/lib/renderers/Form/ButtonGroupSelect.js +3 -0
- package/lib/renderers/Form/ButtonGroupSelect.js.map +2 -2
- package/lib/renderers/Form/DiffEditor.d.ts +0 -2
- package/lib/renderers/Form/Editor.d.ts +0 -2
- package/lib/renderers/Form/Editor.js +1 -1
- package/lib/renderers/Form/Editor.js.map +2 -2
- package/lib/renderers/Form/InputExcel.d.ts +5 -0
- package/lib/renderers/Form/InputExcel.js +24 -3
- package/lib/renderers/Form/InputExcel.js.map +2 -2
- package/lib/renderers/Form/InputImage.d.ts +8 -0
- package/lib/renderers/Form/InputImage.js +2 -1
- package/lib/renderers/Form/InputImage.js.map +2 -2
- package/lib/renderers/Form/InputTable.d.ts +23 -5
- package/lib/renderers/Form/InputTable.js +32 -3
- package/lib/renderers/Form/InputTable.js.map +2 -2
- package/lib/renderers/Json.js +5 -1
- package/lib/renderers/Json.js.map +2 -2
- package/lib/renderers/Nav.d.ts +52 -22
- package/lib/renderers/Nav.js +100 -15
- package/lib/renderers/Nav.js.map +2 -2
- package/lib/renderers/Page.js +4 -1
- package/lib/renderers/Page.js.map +2 -2
- package/lib/renderers/Service.d.ts +10 -1
- package/lib/renderers/Service.js +85 -3
- package/lib/renderers/Service.js.map +2 -2
- package/lib/renderers/Steps.d.ts +4 -4
- package/lib/renderers/Steps.js +5 -2
- package/lib/renderers/Steps.js.map +2 -2
- package/lib/renderers/Table/TableBody.d.ts +1 -1
- package/lib/renderers/Table/TableBody.js +5 -1
- package/lib/renderers/Table/TableBody.js.map +2 -2
- package/lib/renderers/Table/TableContent.d.ts +1 -1
- package/lib/renderers/Table/TableContent.js +4 -0
- package/lib/renderers/Table/TableContent.js.map +2 -2
- package/lib/renderers/Table/index.d.ts +8 -3
- package/lib/renderers/Table/index.js +80 -45
- package/lib/renderers/Table/index.js.map +2 -2
- package/lib/store/app.d.ts +0 -1
- package/lib/store/combo.d.ts +0 -2
- package/lib/store/crud.d.ts +3 -3
- package/lib/store/crud.js +41 -36
- package/lib/store/crud.js.map +2 -2
- package/lib/store/form.d.ts +0 -1
- package/lib/store/modal.d.ts +1 -1
- package/lib/store/modal.js +4 -0
- package/lib/store/modal.js.map +2 -2
- package/lib/store/root.d.ts +0 -1
- package/lib/store/service.d.ts +0 -1
- package/lib/store/service.js +0 -13
- package/lib/store/service.js.map +2 -2
- package/lib/store/table.d.ts +1 -2
- package/lib/store/table.js +44 -3
- package/lib/store/table.js.map +2 -2
- package/lib/themes/ang-ie11.css +597 -57
- package/lib/themes/ang.css +597 -57
- package/lib/themes/ang.css.map +1 -1
- package/lib/themes/antd-ie11.css +597 -57
- package/lib/themes/antd.css +597 -57
- package/lib/themes/antd.css.map +1 -1
- package/lib/themes/cxd-ie11.css +705 -177
- package/lib/themes/cxd.css +705 -177
- package/lib/themes/cxd.css.map +1 -1
- package/lib/themes/dark-ie11.css +597 -57
- package/lib/themes/dark.css +597 -57
- package/lib/themes/dark.css.map +1 -1
- package/lib/themes/default.css +705 -177
- package/lib/themes/default.css.map +1 -1
- package/lib/utils/api.js +12 -0
- package/lib/utils/api.js.map +2 -2
- package/lib/utils/attachmentAdpator.d.ts +7 -0
- package/lib/utils/attachmentAdpator.js +82 -0
- package/lib/utils/attachmentAdpator.js.map +13 -0
- package/lib/utils/helper.js.map +2 -2
- package/lib/utils/validations.js +62 -5
- package/lib/utils/validations.js.map +2 -2
- package/package.json +46 -39
- package/schema.json +343 -44
- package/scss/_mixins.scss +29 -0
- package/scss/_properties.scss +27 -11
- package/scss/components/_badge.scss +67 -2
- package/scss/components/_button.scss +35 -3
- package/scss/components/_image-gallery.scss +1 -1
- package/scss/components/_markdown.scss +266 -0
- package/scss/components/_nav.scss +109 -35
- package/scss/components/_spinner.scss +6 -2
- package/scss/components/form/_group.scss +4 -0
- package/scss/themes/_common.scss +1 -0
- package/scss/themes/_cxd-variables.scss +20 -20
- package/sdk/ang-ie11.css +741 -59
- package/sdk/ang.css +755 -59
- package/sdk/antd-ie11.css +731 -51
- package/sdk/antd.css +755 -59
- package/sdk/charts.js +13 -13
- package/sdk/color-picker.js +67 -67
- package/sdk/cropperjs.js +2 -2
- package/sdk/cxd-ie11.css +1200 -520
- package/sdk/cxd.css +863 -179
- package/sdk/dark-ie11.css +741 -59
- package/sdk/dark.css +755 -59
- package/sdk/exceljs.js +1 -1
- package/sdk/helper.css.map +1 -1
- package/sdk/locale/de-DE.js +1 -0
- package/sdk/markdown.js +69 -69
- package/sdk/papaparse.js +1 -1
- package/sdk/renderers/Form/CityDB.js +1 -1
- package/sdk/rest.js +22 -24
- package/sdk/rich-text.js +62 -64
- package/sdk/sdk-ie11.css +1200 -520
- package/sdk/sdk.css +863 -179
- package/sdk/sdk.js +1118 -1112
- 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/sdk.zip +0 -0
- package/src/components/Badge.tsx +111 -20
- package/src/components/Button.tsx +23 -7
- package/src/components/Checkbox.tsx +5 -2
- package/src/components/Drawer.tsx +3 -2
- package/src/components/Modal.tsx +3 -2
- package/src/components/RichText.tsx +284 -3
- package/src/components/Select.tsx +1 -0
- package/src/components/Steps.tsx +3 -3
- package/src/components/WithRemoteConfig.tsx +37 -2
- package/src/components/calendar/DaysView.tsx +2 -2
- package/src/components/condition-builder/Field.tsx +1 -2
- package/src/components/condition-builder/Value.tsx +3 -0
- package/src/components/condition-builder/types.ts +6 -0
- package/src/components/icons.tsx +2 -0
- package/src/factory.tsx +13 -3
- package/src/icons/loading-outline.svg +4 -0
- package/src/locale/de-DE.ts +1 -0
- package/src/locale/en-US.ts +2 -1
- package/src/locale/zh-CN.ts +2 -1
- package/src/renderers/Action.tsx +66 -13
- package/src/renderers/CRUD.tsx +13 -33
- package/src/renderers/Collapse.tsx +5 -1
- package/src/renderers/Dialog.tsx +1 -1
- package/src/renderers/DropDownButton.tsx +21 -4
- package/src/renderers/Form/ButtonGroupSelect.tsx +3 -0
- package/src/renderers/Form/Editor.tsx +19 -20
- package/src/renderers/Form/InputExcel.tsx +28 -3
- package/src/renderers/Form/InputImage.tsx +23 -8
- package/src/renderers/Form/InputTable.tsx +88 -9
- package/src/renderers/Json.tsx +10 -1
- package/src/renderers/Nav.tsx +165 -36
- package/src/renderers/Page.tsx +3 -1
- package/src/renderers/Service.tsx +101 -3
- package/src/renderers/Steps.tsx +12 -9
- package/src/renderers/Table/TableBody.tsx +3 -2
- package/src/renderers/Table/TableContent.tsx +3 -1
- package/src/renderers/Table/index.tsx +61 -13
- package/src/store/crud.ts +34 -38
- package/src/store/modal.ts +4 -0
- package/src/store/service.ts +0 -19
- package/src/store/table.ts +48 -0
- package/src/utils/api.ts +11 -0
- package/src/utils/attachmentAdpator.ts +90 -0
- package/src/utils/helper.ts +1 -0
- package/src/utils/validations.ts +80 -12
package/sdk.zip
ADDED
Binary file
|
package/src/components/Badge.tsx
CHANGED
@@ -17,7 +17,7 @@ export interface BadgeSchema extends BaseSchema {
|
|
17
17
|
/**
|
18
18
|
* 文本内容
|
19
19
|
*/
|
20
|
-
text?: string;
|
20
|
+
text?: string | number;
|
21
21
|
|
22
22
|
/**
|
23
23
|
* 大小
|
@@ -27,13 +27,23 @@ export interface BadgeSchema extends BaseSchema {
|
|
27
27
|
/**
|
28
28
|
* 角标类型
|
29
29
|
*/
|
30
|
-
mode?: 'text' | 'dot';
|
30
|
+
mode?: 'text' | 'dot' | 'ribbon';
|
31
|
+
|
32
|
+
/**
|
33
|
+
* 角标位置,优先级大于position
|
34
|
+
*/
|
35
|
+
offset?: [number | string, number | string];
|
31
36
|
|
32
37
|
/**
|
33
38
|
* 角标位置
|
34
39
|
*/
|
35
40
|
position?: 'top-right' | 'top-left' | 'bottom-right' | 'bottom-left';
|
36
41
|
|
42
|
+
/**
|
43
|
+
* 封顶的数字值
|
44
|
+
*/
|
45
|
+
overflowCount?: number;
|
46
|
+
|
37
47
|
/**
|
38
48
|
* 动态控制是否显示
|
39
49
|
*/
|
@@ -50,6 +60,11 @@ export interface BadgeSchema extends BaseSchema {
|
|
50
60
|
style?: {
|
51
61
|
[propName: string]: any;
|
52
62
|
};
|
63
|
+
|
64
|
+
/**
|
65
|
+
* 提示类型
|
66
|
+
*/
|
67
|
+
level?: 'info' | 'warning' | 'success' | 'danger';
|
53
68
|
}
|
54
69
|
|
55
70
|
export interface BadgeProps {
|
@@ -65,6 +80,62 @@ export class Badge extends React.Component<BadgeProps, object> {
|
|
65
80
|
super(props);
|
66
81
|
}
|
67
82
|
|
83
|
+
renderBadge(
|
84
|
+
text: any,
|
85
|
+
size: number,
|
86
|
+
position: any,
|
87
|
+
offsetStyle: any,
|
88
|
+
sizeStyle: any,
|
89
|
+
animationElement: any
|
90
|
+
) {
|
91
|
+
const {classnames: cx, badge} = this.props;
|
92
|
+
const {
|
93
|
+
mode = 'dot',
|
94
|
+
level = 'danger',
|
95
|
+
style
|
96
|
+
} = badge as BadgeSchema;
|
97
|
+
switch(mode) {
|
98
|
+
case 'dot':
|
99
|
+
return (
|
100
|
+
<span
|
101
|
+
className={cx('Badge-dot', `Badge--${position}`, `Badge--${level}`)}
|
102
|
+
style={{...offsetStyle, ...sizeStyle, ...style}}
|
103
|
+
>
|
104
|
+
{animationElement}
|
105
|
+
</span>
|
106
|
+
);
|
107
|
+
case 'text':
|
108
|
+
return (
|
109
|
+
<span
|
110
|
+
className={cx('Badge-text', `Badge--${position}`, `Badge--${level}`)}
|
111
|
+
style={{...offsetStyle, ...sizeStyle, ...style}}
|
112
|
+
>
|
113
|
+
{text}
|
114
|
+
{animationElement}
|
115
|
+
</span>
|
116
|
+
);
|
117
|
+
case 'ribbon':
|
118
|
+
const outSize = size * Math.sqrt(2) + 5;
|
119
|
+
return (
|
120
|
+
<div
|
121
|
+
className={cx('Badge-ribbon-out', `Badge-ribbon-out--${position}`)}
|
122
|
+
style={{width: outSize, height: outSize}}
|
123
|
+
>
|
124
|
+
<span
|
125
|
+
className={cx('Badge-ribbon', `Badge-ribbon--${position}`, `Badge--${level}`)}
|
126
|
+
style={{...sizeStyle, ...style}}
|
127
|
+
>
|
128
|
+
{text}
|
129
|
+
{animationElement}
|
130
|
+
</span>
|
131
|
+
</div>
|
132
|
+
|
133
|
+
);
|
134
|
+
default:
|
135
|
+
return null;
|
136
|
+
}
|
137
|
+
}
|
138
|
+
|
68
139
|
render() {
|
69
140
|
const badge = this.props.badge;
|
70
141
|
if (!badge) {
|
@@ -81,7 +152,9 @@ export class Badge extends React.Component<BadgeProps, object> {
|
|
81
152
|
text,
|
82
153
|
size,
|
83
154
|
style,
|
155
|
+
offset,
|
84
156
|
position = 'top-right',
|
157
|
+
overflowCount = 99,
|
85
158
|
visibleOn,
|
86
159
|
className,
|
87
160
|
animation
|
@@ -99,6 +172,8 @@ export class Badge extends React.Component<BadgeProps, object> {
|
|
99
172
|
if (typeof size === 'undefined') {
|
100
173
|
if (mode === 'dot') {
|
101
174
|
size = 6;
|
175
|
+
} else if (mode === 'ribbon'){
|
176
|
+
size = 12;
|
102
177
|
} else {
|
103
178
|
size = 16;
|
104
179
|
}
|
@@ -111,6 +186,12 @@ export class Badge extends React.Component<BadgeProps, object> {
|
|
111
186
|
height: size,
|
112
187
|
lineHeight: size + 'px'
|
113
188
|
};
|
189
|
+
// 当text、overflowCount都为number类型时,进行封顶值处理
|
190
|
+
if (typeof text === 'number' && typeof overflowCount === 'number') {
|
191
|
+
text = (
|
192
|
+
(text as number) > (overflowCount as number) ? `${overflowCount}+` : text
|
193
|
+
) as string | number;
|
194
|
+
}
|
114
195
|
|
115
196
|
if (!text) {
|
116
197
|
isDisplay = false;
|
@@ -121,6 +202,25 @@ export class Badge extends React.Component<BadgeProps, object> {
|
|
121
202
|
sizeStyle = {width: size, height: size};
|
122
203
|
}
|
123
204
|
|
205
|
+
if (mode === 'ribbon') {
|
206
|
+
sizeStyle = {
|
207
|
+
height: size,
|
208
|
+
lineHeight: size + 'px',
|
209
|
+
fontSize: size
|
210
|
+
};
|
211
|
+
}
|
212
|
+
|
213
|
+
let offsetStyle = {};
|
214
|
+
// 如果设置了offset属性,offset在position为'top-right'的基础上进行translate定位
|
215
|
+
if (offset && offset.length) {
|
216
|
+
position = 'top-right';
|
217
|
+
const left = `calc(50% + ${parseInt(offset[0] as string, 10)}px)`;
|
218
|
+
const right = `calc(-50% + ${parseInt(offset[1] as string, 10)}px)`;
|
219
|
+
offsetStyle = {
|
220
|
+
transform: `translate(${left}, ${right})`,
|
221
|
+
};
|
222
|
+
}
|
223
|
+
|
124
224
|
let animationBackground = 'var(--danger)';
|
125
225
|
|
126
226
|
if (style && style.background) {
|
@@ -145,24 +245,15 @@ export class Badge extends React.Component<BadgeProps, object> {
|
|
145
245
|
return (
|
146
246
|
<div className={cx('Badge', className)}>
|
147
247
|
{children}
|
148
|
-
{isDisplay ?
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
) :
|
157
|
-
<span
|
158
|
-
className={cx('Badge-text', `Badge--${position}`)}
|
159
|
-
style={{...sizeStyle, ...style}}
|
160
|
-
>
|
161
|
-
{text}
|
162
|
-
{animationElement}
|
163
|
-
</span>
|
164
|
-
)
|
165
|
-
) : null}
|
248
|
+
{isDisplay ?
|
249
|
+
this.renderBadge(
|
250
|
+
text,
|
251
|
+
size,
|
252
|
+
position,
|
253
|
+
offsetStyle,
|
254
|
+
sizeStyle,
|
255
|
+
animationElement
|
256
|
+
) : null}
|
166
257
|
</div>
|
167
258
|
);
|
168
259
|
}
|
@@ -7,7 +7,7 @@ import React from 'react';
|
|
7
7
|
import TooltipWrapper, {TooltipObject, Trigger} from './TooltipWrapper';
|
8
8
|
import {pickEventsProps} from '../utils/helper';
|
9
9
|
import {ClassNamesFn, themeable} from '../theme';
|
10
|
-
|
10
|
+
import {Icon} from './icons';
|
11
11
|
interface ButtonProps extends React.DOMAttributes<HTMLButtonElement> {
|
12
12
|
id?: string;
|
13
13
|
className?: string;
|
@@ -16,7 +16,7 @@ interface ButtonProps extends React.DOMAttributes<HTMLButtonElement> {
|
|
16
16
|
type: 'button' | 'reset' | 'submit';
|
17
17
|
level: string; // 'link' | 'primary' | 'secondary' | 'info' | 'success' | 'warning' | 'danger' | 'light' | 'dark' | 'default';
|
18
18
|
tooltip?: string | TooltipObject;
|
19
|
-
|
19
|
+
tooltipPlacement: 'top' | 'right' | 'bottom' | 'left';
|
20
20
|
tooltipContainer?: any;
|
21
21
|
tooltipTrigger: Trigger | Array<Trigger>;
|
22
22
|
tooltipRootClose: boolean;
|
@@ -29,6 +29,8 @@ interface ButtonProps extends React.DOMAttributes<HTMLButtonElement> {
|
|
29
29
|
classnames: ClassNamesFn;
|
30
30
|
componentClass: React.ReactType;
|
31
31
|
overrideClassName?: boolean;
|
32
|
+
loading?: boolean;
|
33
|
+
loadingClassName?: string;
|
32
34
|
}
|
33
35
|
|
34
36
|
export class Button extends React.Component<ButtonProps> {
|
@@ -37,14 +39,14 @@ export class Button extends React.Component<ButtonProps> {
|
|
37
39
|
| 'componentClass'
|
38
40
|
| 'level'
|
39
41
|
| 'type'
|
40
|
-
| '
|
42
|
+
| 'tooltipPlacement'
|
41
43
|
| 'tooltipTrigger'
|
42
44
|
| 'tooltipRootClose'
|
43
45
|
> = {
|
44
46
|
componentClass: 'button',
|
45
47
|
level: 'default',
|
46
48
|
type: 'button',
|
47
|
-
|
49
|
+
tooltipPlacement: 'top',
|
48
50
|
tooltipTrigger: ['hover', 'focus'],
|
49
51
|
tooltipRootClose: false
|
50
52
|
};
|
@@ -64,13 +66,15 @@ export class Button extends React.Component<ButtonProps> {
|
|
64
66
|
active,
|
65
67
|
iconOnly,
|
66
68
|
href,
|
69
|
+
loading,
|
70
|
+
loadingClassName,
|
67
71
|
overrideClassName,
|
68
72
|
...rest
|
69
73
|
} = this.props;
|
70
74
|
|
71
75
|
if (href) {
|
72
76
|
Comp = 'a';
|
73
|
-
} else if (Comp === 'button' && disabled) {
|
77
|
+
} else if ((Comp === 'button' && disabled) || loading) {
|
74
78
|
Comp = 'div';
|
75
79
|
}
|
76
80
|
|
@@ -95,6 +99,18 @@ export class Button extends React.Component<ButtonProps> {
|
|
95
99
|
)}
|
96
100
|
disabled={disabled}
|
97
101
|
>
|
102
|
+
{loading && !disabled ? (
|
103
|
+
<span
|
104
|
+
className={cx(
|
105
|
+
overrideClassName
|
106
|
+
? ''
|
107
|
+
: {[`Button--loading Button--loading--${level}`]: level},
|
108
|
+
loadingClassName
|
109
|
+
)}
|
110
|
+
>
|
111
|
+
<Icon icon="loading-outline" className="icon" />
|
112
|
+
</span>
|
113
|
+
) : null}
|
98
114
|
{children}
|
99
115
|
</Comp>
|
100
116
|
);
|
@@ -103,7 +119,7 @@ export class Button extends React.Component<ButtonProps> {
|
|
103
119
|
render() {
|
104
120
|
const {
|
105
121
|
tooltip,
|
106
|
-
|
122
|
+
tooltipPlacement,
|
107
123
|
tooltipContainer,
|
108
124
|
tooltipTrigger,
|
109
125
|
tooltipRootClose,
|
@@ -114,7 +130,7 @@ export class Button extends React.Component<ButtonProps> {
|
|
114
130
|
|
115
131
|
return (
|
116
132
|
<TooltipWrapper
|
117
|
-
placement={
|
133
|
+
placement={tooltipPlacement}
|
118
134
|
tooltip={disabled ? disabledTip : tooltip}
|
119
135
|
container={tooltipContainer}
|
120
136
|
trigger={tooltipTrigger}
|
@@ -15,7 +15,7 @@ interface CheckboxProps {
|
|
15
15
|
label?: string;
|
16
16
|
labelClassName?: string;
|
17
17
|
className?: string;
|
18
|
-
onChange?: (value: any) => void;
|
18
|
+
onChange?: (value: any, shift?: boolean) => void;
|
19
19
|
value?: any;
|
20
20
|
inline?: boolean;
|
21
21
|
trueValue?: any;
|
@@ -48,7 +48,10 @@ export class Checkbox extends React.Component<CheckboxProps, any> {
|
|
48
48
|
return;
|
49
49
|
}
|
50
50
|
|
51
|
-
onChange(
|
51
|
+
onChange(
|
52
|
+
e.currentTarget.checked ? trueValue : falseValue,
|
53
|
+
(e.nativeEvent as MouseEvent).shiftKey
|
54
|
+
);
|
52
55
|
}
|
53
56
|
|
54
57
|
render() {
|
@@ -8,7 +8,8 @@ import React from 'react';
|
|
8
8
|
import Transition, {
|
9
9
|
ENTERED,
|
10
10
|
ENTERING,
|
11
|
-
EXITING
|
11
|
+
EXITING,
|
12
|
+
EXITED
|
12
13
|
} from 'react-transition-group/Transition';
|
13
14
|
import Portal from 'react-overlays/Portal';
|
14
15
|
import {Icon} from './icons';
|
@@ -230,7 +231,7 @@ export class Drawer extends React.Component<DrawerProps, DrawerState> {
|
|
230
231
|
>
|
231
232
|
<Icon icon="close" className="icon" />
|
232
233
|
</a>
|
233
|
-
{children}
|
234
|
+
{status === EXITED ? null : children}
|
234
235
|
</div>
|
235
236
|
</div>
|
236
237
|
);
|
package/src/components/Modal.tsx
CHANGED
@@ -8,7 +8,8 @@ import React from 'react';
|
|
8
8
|
import Transition, {
|
9
9
|
ENTERED,
|
10
10
|
ENTERING,
|
11
|
-
EXITING
|
11
|
+
EXITING,
|
12
|
+
EXITED
|
12
13
|
} from 'react-transition-group/Transition';
|
13
14
|
import Portal from 'react-overlays/Portal';
|
14
15
|
import {current, addModal, removeModal} from './ModalManager';
|
@@ -264,7 +265,7 @@ export class Modal extends React.Component<ModalProps, ModalState> {
|
|
264
265
|
fadeStyles[status]
|
265
266
|
)}
|
266
267
|
>
|
267
|
-
{children}
|
268
|
+
{status === EXITED ? null : children}
|
268
269
|
</div>
|
269
270
|
</div>
|
270
271
|
</Portal>
|
@@ -7,7 +7,7 @@
|
|
7
7
|
import React from 'react';
|
8
8
|
|
9
9
|
// @ts-ignore
|
10
|
-
import
|
10
|
+
import FroalaEditor from 'froala-editor';
|
11
11
|
// @ts-ignore
|
12
12
|
import Froala from 'froala-editor/js/froala_editor.min.js';
|
13
13
|
import 'froala-editor/js/plugins/align.min';
|
@@ -45,7 +45,289 @@ import 'froala-editor/js/languages/zh_cn.js';
|
|
45
45
|
import 'froala-editor/css/froala_style.min.css';
|
46
46
|
import 'froala-editor/css/froala_editor.pkgd.min.css';
|
47
47
|
|
48
|
-
export
|
48
|
+
export interface FroalaEditorComponentProps {
|
49
|
+
config: any;
|
50
|
+
model: string;
|
51
|
+
onModelChange: (value: string) => void;
|
52
|
+
}
|
53
|
+
|
54
|
+
// 代码来源于:https://github.com/froala/react-froala-wysiwyg/blob/master/lib/FroalaEditorFunctionality.jsx
|
55
|
+
// 改动原因是model 同步有些问题,有时候不更新,所以基于官方代码改造一下。
|
56
|
+
// 目前发现的问题是,如果 model 数据修改,如果此时 editor 还没有初始化完成则不会同步成功
|
57
|
+
class FroalaEditorComponent extends React.Component<FroalaEditorComponentProps> {
|
58
|
+
listeningEvents: any;
|
59
|
+
element: any;
|
60
|
+
editor: any;
|
61
|
+
config: any;
|
62
|
+
editorInitialized: any;
|
63
|
+
INNER_HTML_ATTR: any;
|
64
|
+
hasSpecialTag: any;
|
65
|
+
oldModel: any;
|
66
|
+
el: any;
|
67
|
+
_initEvents: any;
|
68
|
+
|
69
|
+
constructor(props: FroalaEditorComponentProps) {
|
70
|
+
super(props);
|
71
|
+
|
72
|
+
this.listeningEvents = [];
|
73
|
+
this.element = null;
|
74
|
+
this.editor = null;
|
75
|
+
this.config = {
|
76
|
+
immediateReactModelUpdate: false,
|
77
|
+
reactIgnoreAttrs: null
|
78
|
+
};
|
79
|
+
|
80
|
+
this.editorInitialized = false;
|
81
|
+
this.INNER_HTML_ATTR = 'innerHTML';
|
82
|
+
|
83
|
+
this.oldModel = null;
|
84
|
+
}
|
85
|
+
|
86
|
+
// After first time render.
|
87
|
+
componentDidMount() {
|
88
|
+
this.createEditor();
|
89
|
+
}
|
90
|
+
|
91
|
+
componentWillUnmount() {
|
92
|
+
this.destroyEditor();
|
93
|
+
}
|
94
|
+
|
95
|
+
componentDidUpdate() {
|
96
|
+
if (JSON.stringify(this.oldModel) == JSON.stringify(this.props.model)) {
|
97
|
+
return;
|
98
|
+
}
|
99
|
+
|
100
|
+
this.setContent();
|
101
|
+
}
|
102
|
+
|
103
|
+
// Return cloned object
|
104
|
+
clone(item: any) {
|
105
|
+
const me = this;
|
106
|
+
if (!item) {
|
107
|
+
return item;
|
108
|
+
} // null, undefined values check
|
109
|
+
|
110
|
+
let types = [Number, String, Boolean],
|
111
|
+
result: any;
|
112
|
+
|
113
|
+
// normalizing primitives if someone did new String('aaa'), or new Number('444');
|
114
|
+
types.forEach(function (type) {
|
115
|
+
if (item instanceof type) {
|
116
|
+
result = type(item);
|
117
|
+
}
|
118
|
+
});
|
119
|
+
|
120
|
+
if (typeof result == 'undefined') {
|
121
|
+
if (Object.prototype.toString.call(item) === '[object Array]') {
|
122
|
+
result = [];
|
123
|
+
item.forEach(function (child: any, index: number, array: Array<any>) {
|
124
|
+
result[index] = me.clone(child);
|
125
|
+
});
|
126
|
+
} else if (typeof item == 'object') {
|
127
|
+
// testing that this is DOM
|
128
|
+
if (item.nodeType && typeof item.cloneNode == 'function') {
|
129
|
+
result = item.cloneNode(true);
|
130
|
+
} else if (!item.prototype) {
|
131
|
+
// check that this is a literal
|
132
|
+
if (item instanceof Date) {
|
133
|
+
result = new Date(item);
|
134
|
+
} else {
|
135
|
+
// it is an object literal
|
136
|
+
result = {};
|
137
|
+
for (var i in item) {
|
138
|
+
result[i] = me.clone(item[i]);
|
139
|
+
}
|
140
|
+
}
|
141
|
+
} else {
|
142
|
+
if (false && item.constructor) {
|
143
|
+
result = new item.constructor();
|
144
|
+
} else {
|
145
|
+
result = item;
|
146
|
+
}
|
147
|
+
}
|
148
|
+
} else {
|
149
|
+
result = item;
|
150
|
+
}
|
151
|
+
}
|
152
|
+
return result;
|
153
|
+
}
|
154
|
+
|
155
|
+
createEditor() {
|
156
|
+
if (this.editorInitialized) {
|
157
|
+
return;
|
158
|
+
}
|
159
|
+
|
160
|
+
this.config = this.clone(this.props.config || this.config);
|
161
|
+
this.config = {...this.config};
|
162
|
+
|
163
|
+
this.element = this.el;
|
164
|
+
|
165
|
+
if (this.props.model) {
|
166
|
+
this.element.innerHTML = this.props.model;
|
167
|
+
}
|
168
|
+
|
169
|
+
this.setContent(true);
|
170
|
+
|
171
|
+
// Default initialized.
|
172
|
+
this.registerEvent(
|
173
|
+
'initialized',
|
174
|
+
this.config.events && this.config.events.initialized
|
175
|
+
);
|
176
|
+
|
177
|
+
// Check if events are set.
|
178
|
+
if (!this.config.events) this.config.events = {};
|
179
|
+
this.config.events.initialized = () => this.initListeners();
|
180
|
+
|
181
|
+
this.editor = new FroalaEditor(this.element, this.config);
|
182
|
+
}
|
183
|
+
|
184
|
+
setContent(firstTime?: boolean) {
|
185
|
+
if (this.props.model || this.props.model == '') {
|
186
|
+
this.oldModel = this.props.model;
|
187
|
+
|
188
|
+
if (this.editorInitialized) {
|
189
|
+
this.setNormalTagContent(firstTime);
|
190
|
+
} else {
|
191
|
+
if (!this._initEvents) this._initEvents = [];
|
192
|
+
this._initEvents.push(() => this.setNormalTagContent());
|
193
|
+
}
|
194
|
+
}
|
195
|
+
}
|
196
|
+
|
197
|
+
setNormalTagContent(firstTime?: boolean) {
|
198
|
+
let self = this;
|
199
|
+
|
200
|
+
function htmlSet() {
|
201
|
+
self.editor.html && self.editor.html.set(self.props.model || '');
|
202
|
+
if (self.editorInitialized && self.editor.undo) {
|
203
|
+
//This will reset the undo stack everytime the model changes externally. Can we fix this?
|
204
|
+
self.editor.undo.reset();
|
205
|
+
self.editor.undo.saveStep();
|
206
|
+
}
|
207
|
+
}
|
208
|
+
|
209
|
+
if (firstTime) {
|
210
|
+
if (this.config.initOnClick) {
|
211
|
+
this.registerEvent('initializationDelayed', () => {
|
212
|
+
htmlSet();
|
213
|
+
});
|
214
|
+
|
215
|
+
this.registerEvent('initialized', () => {
|
216
|
+
this.editorInitialized = true;
|
217
|
+
});
|
218
|
+
} else {
|
219
|
+
this.registerEvent('initialized', () => {
|
220
|
+
this.editorInitialized = true;
|
221
|
+
htmlSet();
|
222
|
+
});
|
223
|
+
}
|
224
|
+
} else {
|
225
|
+
htmlSet();
|
226
|
+
}
|
227
|
+
}
|
228
|
+
|
229
|
+
destroyEditor() {
|
230
|
+
if (this.element) {
|
231
|
+
this.editor.destroy && this.editor.destroy();
|
232
|
+
this.listeningEvents.length = 0;
|
233
|
+
this.element = null;
|
234
|
+
this.editorInitialized = false;
|
235
|
+
}
|
236
|
+
}
|
237
|
+
|
238
|
+
getEditor() {
|
239
|
+
if (this.element) {
|
240
|
+
return this.editor;
|
241
|
+
}
|
242
|
+
|
243
|
+
return null;
|
244
|
+
}
|
245
|
+
|
246
|
+
updateModel() {
|
247
|
+
if (!this.props.onModelChange) {
|
248
|
+
return;
|
249
|
+
}
|
250
|
+
|
251
|
+
let modelContent = '';
|
252
|
+
|
253
|
+
if (this.hasSpecialTag) {
|
254
|
+
let attributeNodes = this.element.attributes;
|
255
|
+
let attrs: any = {};
|
256
|
+
|
257
|
+
for (let i = 0; i < attributeNodes.length; i++) {
|
258
|
+
let attrName = attributeNodes[i].name;
|
259
|
+
if (
|
260
|
+
this.config.reactIgnoreAttrs &&
|
261
|
+
this.config.reactIgnoreAttrs.indexOf(attrName) != -1
|
262
|
+
) {
|
263
|
+
continue;
|
264
|
+
}
|
265
|
+
attrs[attrName] = attributeNodes[i].value;
|
266
|
+
}
|
267
|
+
|
268
|
+
if (this.element.innerHTML) {
|
269
|
+
attrs[this.INNER_HTML_ATTR] = this.element.innerHTML;
|
270
|
+
}
|
271
|
+
|
272
|
+
modelContent = attrs;
|
273
|
+
} else {
|
274
|
+
let returnedHtml = this.editor.html.get();
|
275
|
+
if (typeof returnedHtml === 'string') {
|
276
|
+
modelContent = returnedHtml;
|
277
|
+
}
|
278
|
+
}
|
279
|
+
|
280
|
+
this.oldModel = modelContent;
|
281
|
+
this.props.onModelChange(modelContent);
|
282
|
+
}
|
283
|
+
|
284
|
+
initListeners() {
|
285
|
+
let self = this;
|
286
|
+
|
287
|
+
// bind contentChange and keyup event to froalaModel
|
288
|
+
this.editor.events.on('contentChanged', function () {
|
289
|
+
self.updateModel();
|
290
|
+
});
|
291
|
+
if (this.config.immediateReactModelUpdate) {
|
292
|
+
this.editor.events.on('keyup', function () {
|
293
|
+
self.updateModel();
|
294
|
+
});
|
295
|
+
}
|
296
|
+
|
297
|
+
// Call init events.
|
298
|
+
if (this._initEvents) {
|
299
|
+
for (let i = 0; i < this._initEvents.length; i++) {
|
300
|
+
this._initEvents[i].call(this.editor);
|
301
|
+
}
|
302
|
+
}
|
303
|
+
}
|
304
|
+
|
305
|
+
// register event on jquery editor element
|
306
|
+
registerEvent(eventName: string, callback: Function) {
|
307
|
+
if (!eventName || !callback) {
|
308
|
+
return;
|
309
|
+
}
|
310
|
+
|
311
|
+
if (eventName == 'initialized') {
|
312
|
+
if (!this._initEvents) this._initEvents = [];
|
313
|
+
this._initEvents.push(callback);
|
314
|
+
} else {
|
315
|
+
if (!this.config.events) {
|
316
|
+
this.config.events = {};
|
317
|
+
}
|
318
|
+
|
319
|
+
this.config.events[eventName] = callback;
|
320
|
+
}
|
321
|
+
}
|
322
|
+
|
323
|
+
render() {
|
324
|
+
return (
|
325
|
+
<textarea ref={el => (this.el = el)}>{this.props.children}</textarea>
|
326
|
+
);
|
327
|
+
}
|
328
|
+
}
|
329
|
+
|
330
|
+
export default class extends React.Component<any, any> {
|
49
331
|
constructor(props: any) {
|
50
332
|
super(props);
|
51
333
|
Froala.VIDEO_PROVIDERS = [
|
@@ -61,7 +343,6 @@ export default class FroalaEditor extends React.Component<any, any> {
|
|
61
343
|
render() {
|
62
344
|
return (
|
63
345
|
<FroalaEditorComponent
|
64
|
-
tag="textarea"
|
65
346
|
config={this.props.config}
|
66
347
|
model={this.props.model}
|
67
348
|
onModelChange={this.props.onModelChange}
|
package/src/components/Steps.tsx
CHANGED
@@ -14,12 +14,12 @@ export type StepSchema = {
|
|
14
14
|
/**
|
15
15
|
* 标题
|
16
16
|
*/
|
17
|
-
title
|
17
|
+
title?: string | JSX.Element;
|
18
18
|
|
19
19
|
/**
|
20
20
|
* 子标题
|
21
21
|
*/
|
22
|
-
subTitle?: string;
|
22
|
+
subTitle?: string | JSX.Element;
|
23
23
|
|
24
24
|
/**
|
25
25
|
* 图标
|
@@ -31,7 +31,7 @@ export type StepSchema = {
|
|
31
31
|
/**
|
32
32
|
* 描述
|
33
33
|
*/
|
34
|
-
description?: string;
|
34
|
+
description?: string | JSX.Element;
|
35
35
|
|
36
36
|
status?: StepStatus;
|
37
37
|
} & Omit<BaseSchema, 'type'>;
|