amis 1.3.5-beta.3 → 1.4.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 -4
- package/lib/components/RichText.js +241 -27
- 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.d.ts +1 -0
- package/lib/index.js +2 -1
- package/lib/index.js.map +2 -2
- 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 +15 -1
- package/lib/renderers/Action.js +13 -6
- 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/Card.js +11 -11
- package/lib/renderers/Card.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 +3 -2
- package/lib/renderers/Dialog.js.map +2 -2
- package/lib/renderers/Drawer.js +2 -1
- package/lib/renderers/Drawer.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/Combo.d.ts +2 -0
- package/lib/renderers/Form/Combo.js +16 -1
- package/lib/renderers/Form/Combo.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/InputNumber.d.ts +19 -5
- package/lib/renderers/Form/InputNumber.js +69 -7
- package/lib/renderers/Form/InputNumber.js.map +2 -2
- package/lib/renderers/Form/InputRange.js +7 -2
- package/lib/renderers/Form/InputRange.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/Form/Options.js +3 -1
- package/lib/renderers/Form/Options.js.map +2 -2
- package/lib/renderers/Form/index.js +0 -10
- package/lib/renderers/Form/index.js.map +2 -2
- package/lib/renderers/Form/wrapControl.js +3 -3
- package/lib/renderers/Form/wrapControl.js.map +2 -2
- package/lib/renderers/Json.js +5 -1
- package/lib/renderers/Json.js.map +2 -2
- package/lib/renderers/List.d.ts +5 -0
- package/lib/renderers/List.js +20 -14
- package/lib/renderers/List.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.d.ts +6 -0
- package/lib/renderers/Page.js +11 -3
- 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 +5 -3
- package/lib/renderers/Table/TableBody.js +17 -11
- package/lib/renderers/Table/TableBody.js.map +2 -2
- package/lib/renderers/Table/TableCell.js +6 -2
- package/lib/renderers/Table/TableCell.js.map +2 -2
- package/lib/renderers/Table/TableContent.d.ts +3 -1
- package/lib/renderers/Table/TableContent.js +6 -2
- package/lib/renderers/Table/TableContent.js.map +2 -2
- package/lib/renderers/Table/TableRow.d.ts +1 -1
- package/lib/renderers/Table/TableRow.js +14 -13
- package/lib/renderers/Table/TableRow.js.map +2 -2
- package/lib/renderers/Table/index.d.ts +28 -3
- package/lib/renderers/Table/index.js +92 -52
- package/lib/renderers/Table/index.js.map +2 -2
- package/lib/schemaExtend.d.ts +1 -0
- package/lib/schemaExtend.js +59 -0
- package/lib/schemaExtend.js.map +13 -0
- 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/formItem.js +10 -6
- package/lib/store/formItem.js.map +2 -2
- 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 +624 -71
- package/lib/themes/ang.css +624 -71
- package/lib/themes/ang.css.map +1 -1
- package/lib/themes/antd-ie11.css +624 -71
- package/lib/themes/antd.css +624 -71
- package/lib/themes/antd.css.map +1 -1
- package/lib/themes/cxd-ie11.css +732 -191
- package/lib/themes/cxd.css +732 -191
- package/lib/themes/cxd.css.map +1 -1
- package/lib/themes/dark-ie11.css +624 -71
- package/lib/themes/dark.css +624 -71
- package/lib/themes/dark.css.map +1 -1
- package/lib/themes/default.css +732 -191
- 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.d.ts +2 -0
- package/lib/utils/helper.js +14 -1
- package/lib/utils/helper.js.map +2 -2
- package/lib/utils/resize-sensor.js +6 -0
- package/lib/utils/resize-sensor.js.map +2 -2
- package/lib/utils/tpl-builtin.d.ts +1 -0
- package/lib/utils/tpl-builtin.js +24 -8
- package/lib/utils/tpl-builtin.js.map +2 -2
- package/lib/utils/validations.js +62 -5
- package/lib/utils/validations.js.map +2 -2
- package/package.json +1 -2
- package/schema.json +561 -171
- package/scss/_mixins.scss +29 -0
- package/scss/_properties.scss +29 -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/_list.scss +8 -0
- package/scss/components/_markdown.scss +266 -0
- package/scss/components/_nav.scss +109 -35
- package/scss/components/_spinner.scss +6 -2
- package/scss/components/_table.scss +4 -0
- package/scss/components/form/_form.scss +3 -17
- package/scss/components/form/_group.scss +4 -0
- package/scss/components/form/_number.scss +12 -1
- package/scss/themes/_common.scss +1 -0
- package/scss/themes/_cxd-variables.scss +20 -20
- package/sdk/ang-ie11.css +769 -76
- package/sdk/ang.css +785 -76
- package/sdk/antd-ie11.css +759 -68
- package/sdk/antd.css +785 -76
- package/sdk/charts.js +13 -13
- package/sdk/color-picker.js +67 -67
- package/sdk/cropperjs.js +2 -2
- package/sdk/cxd-ie11.css +1243 -552
- package/sdk/cxd.css +893 -196
- package/sdk/dark-ie11.css +769 -76
- package/sdk/dark.css +785 -76
- 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 +1243 -552
- package/sdk/sdk.css +893 -196
- package/sdk/sdk.js +1123 -1111
- 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 +280 -24
- 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/index.tsx +2 -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 +84 -14
- package/src/renderers/CRUD.tsx +13 -33
- package/src/renderers/Card.tsx +21 -15
- package/src/renderers/Collapse.tsx +5 -1
- package/src/renderers/Dialog.tsx +3 -2
- package/src/renderers/Drawer.tsx +2 -1
- package/src/renderers/DropDownButton.tsx +21 -4
- package/src/renderers/Form/ButtonGroupSelect.tsx +3 -0
- package/src/renderers/Form/Combo.tsx +7 -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/InputNumber.tsx +113 -18
- package/src/renderers/Form/InputRange.tsx +5 -2
- package/src/renderers/Form/InputTable.tsx +88 -9
- package/src/renderers/Form/Options.tsx +3 -1
- package/src/renderers/Form/index.tsx +0 -15
- package/src/renderers/Form/wrapControl.tsx +2 -2
- package/src/renderers/Json.tsx +10 -1
- package/src/renderers/List.tsx +32 -19
- package/src/renderers/Nav.tsx +165 -36
- package/src/renderers/Page.tsx +20 -1
- package/src/renderers/Service.tsx +101 -3
- package/src/renderers/Steps.tsx +12 -9
- package/src/renderers/Table/TableBody.tsx +29 -10
- package/src/renderers/Table/TableCell.tsx +15 -1
- package/src/renderers/Table/TableContent.tsx +7 -1
- package/src/renderers/Table/TableRow.tsx +18 -17
- package/src/renderers/Table/index.tsx +112 -27
- package/src/schemaExtend.ts +66 -0
- package/src/store/crud.ts +34 -38
- package/src/store/formItem.ts +10 -6
- 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 +16 -0
- package/src/utils/resize-sensor.ts +7 -0
- package/src/utils/tpl-builtin.ts +36 -17
- package/src/utils/validations.ts +80 -12
package/src/renderers/Card.tsx
CHANGED
@@ -6,7 +6,13 @@ import {filter, evalExpression} from '../utils/tpl';
|
|
6
6
|
import cx from 'classnames';
|
7
7
|
import Checkbox from '../components/Checkbox';
|
8
8
|
import {IItem} from '../store/list';
|
9
|
-
import {
|
9
|
+
import {
|
10
|
+
padArr,
|
11
|
+
isVisible,
|
12
|
+
isDisabled,
|
13
|
+
noop,
|
14
|
+
isClickOnInput
|
15
|
+
} from '../utils/helper';
|
10
16
|
import {resolveVariable} from '../utils/tpl-builtin';
|
11
17
|
import QuickEdit, {SchemaQuickEdit} from './QuickEdit';
|
12
18
|
import PopOver, {SchemaPopOver} from './PopOver';
|
@@ -209,19 +215,11 @@ export class Card extends React.Component<CardProps> {
|
|
209
215
|
}
|
210
216
|
|
211
217
|
handleClick(e: React.MouseEvent<HTMLDivElement>) {
|
212
|
-
|
213
|
-
const ns = this.props.classPrefix;
|
214
|
-
let formItem;
|
215
|
-
|
216
|
-
if (
|
217
|
-
!e.currentTarget.contains(target) ||
|
218
|
-
~['INPUT', 'TEXTAREA'].indexOf(target.tagName) ||
|
219
|
-
((formItem = target.closest(`button, a, .${ns}Form-item`)) &&
|
220
|
-
e.currentTarget.contains(formItem))
|
221
|
-
) {
|
218
|
+
if (isClickOnInput(e)) {
|
222
219
|
return;
|
223
220
|
}
|
224
|
-
|
221
|
+
|
222
|
+
const {item, href, data, env, blank, itemAction, onAction} = this.props;
|
225
223
|
if (href) {
|
226
224
|
env.jumpTo(filter(href, data), {
|
227
225
|
type: 'button',
|
@@ -231,6 +229,11 @@ export class Card extends React.Component<CardProps> {
|
|
231
229
|
return;
|
232
230
|
}
|
233
231
|
|
232
|
+
if (itemAction) {
|
233
|
+
onAction && onAction(e, itemAction, item?.data || data);
|
234
|
+
return;
|
235
|
+
}
|
236
|
+
|
234
237
|
this.props.onCheck && this.props.onCheck(item);
|
235
238
|
}
|
236
239
|
|
@@ -447,7 +450,8 @@ export class Card extends React.Component<CardProps> {
|
|
447
450
|
classPrefix: ns,
|
448
451
|
imageClassName,
|
449
452
|
avatarTextClassName,
|
450
|
-
href
|
453
|
+
href,
|
454
|
+
itemAction
|
451
455
|
} = this.props;
|
452
456
|
|
453
457
|
let heading = null;
|
@@ -558,10 +562,12 @@ export class Card extends React.Component<CardProps> {
|
|
558
562
|
return (
|
559
563
|
<div
|
560
564
|
onClick={
|
561
|
-
(checkOnItemClick && checkable) || href
|
565
|
+
(checkOnItemClick && checkable) || href || itemAction
|
566
|
+
? this.handleClick
|
567
|
+
: undefined
|
562
568
|
}
|
563
569
|
className={cx('Card', className, {
|
564
|
-
'Card--link': href
|
570
|
+
'Card--link': href || itemAction
|
565
571
|
})}
|
566
572
|
>
|
567
573
|
{this.renderToolbar()}
|
@@ -7,6 +7,7 @@ import {
|
|
7
7
|
SchemaCollection,
|
8
8
|
SchemaTpl
|
9
9
|
} from '../Schema';
|
10
|
+
import {isClickOnInput} from '../utils/helper';
|
10
11
|
|
11
12
|
/**
|
12
13
|
* Collapse 折叠渲染器,格式说明。
|
@@ -134,7 +135,10 @@ export default class Collapse extends React.Component<
|
|
134
135
|
}
|
135
136
|
}
|
136
137
|
|
137
|
-
toggleCollapsed() {
|
138
|
+
toggleCollapsed(e: React.MouseEvent<HTMLElement>) {
|
139
|
+
if (isClickOnInput(e)) {
|
140
|
+
return;
|
141
|
+
}
|
138
142
|
this.props.collapsable !== false &&
|
139
143
|
this.setState({
|
140
144
|
collapsed: !this.state.collapsed
|
package/src/renderers/Dialog.tsx
CHANGED
@@ -318,7 +318,7 @@ export default class Dialog extends React.Component<DialogProps> {
|
|
318
318
|
handleExited() {
|
319
319
|
const {lazySchema, store} = this.props;
|
320
320
|
if (isAlive(store)) {
|
321
|
-
store.
|
321
|
+
store.reset();
|
322
322
|
store.setEntered(false);
|
323
323
|
if (typeof lazySchema === 'function') {
|
324
324
|
store.setSchema('');
|
@@ -395,7 +395,8 @@ export default class Dialog extends React.Component<DialogProps> {
|
|
395
395
|
affixOffsetTop: 0,
|
396
396
|
onChange: this.handleFormChange,
|
397
397
|
onInit: this.handleFormInit,
|
398
|
-
onSaved: this.handleFormSaved
|
398
|
+
onSaved: this.handleFormSaved,
|
399
|
+
syncLocation: false // 弹框中的 crud 一般不需要同步地址栏
|
399
400
|
};
|
400
401
|
|
401
402
|
if (!(body as Schema).type) {
|
package/src/renderers/Drawer.tsx
CHANGED
@@ -394,7 +394,8 @@ export default class Drawer extends React.Component<DrawerProps> {
|
|
394
394
|
popOverContainer: this.getPopOverContainer,
|
395
395
|
onChange: this.handleFormChange,
|
396
396
|
onInit: this.handleFormInit,
|
397
|
-
onSaved: this.handleFormSaved
|
397
|
+
onSaved: this.handleFormSaved,
|
398
|
+
syncLocation: false
|
398
399
|
};
|
399
400
|
|
400
401
|
if (schema.type === 'form') {
|
@@ -76,6 +76,15 @@ export interface DropdownButtonSchema extends BaseSchema {
|
|
76
76
|
* 是否只显示图标。
|
77
77
|
*/
|
78
78
|
iconOnly?: boolean;
|
79
|
+
|
80
|
+
/**
|
81
|
+
* 触发条件,默认是 click
|
82
|
+
*/
|
83
|
+
trigger?: 'click' | 'hover';
|
84
|
+
/**
|
85
|
+
* 是否显示下拉按钮
|
86
|
+
*/
|
87
|
+
hideCaret?: boolean;
|
79
88
|
}
|
80
89
|
|
81
90
|
export interface DropDownButtonProps
|
@@ -266,7 +275,9 @@ export default class DropDownButton extends React.Component<
|
|
266
275
|
iconOnly,
|
267
276
|
icon,
|
268
277
|
isActived,
|
269
|
-
|
278
|
+
trigger,
|
279
|
+
data,
|
280
|
+
hideCaret
|
270
281
|
} = this.props;
|
271
282
|
|
272
283
|
return (
|
@@ -281,6 +292,8 @@ export default class DropDownButton extends React.Component<
|
|
281
292
|
},
|
282
293
|
className
|
283
294
|
)}
|
295
|
+
onMouseEnter={trigger === 'hover' ? this.open : () => {}}
|
296
|
+
onMouseLeave={trigger === 'hover' ? this.close : () => {}}
|
284
297
|
ref={this.domRef}
|
285
298
|
>
|
286
299
|
<TooltipWrapper
|
@@ -317,9 +330,13 @@ export default class DropDownButton extends React.Component<
|
|
317
330
|
)
|
318
331
|
) : null}
|
319
332
|
{typeof label === 'string' ? filter(label, data) : label}
|
320
|
-
|
321
|
-
|
322
|
-
|
333
|
+
{
|
334
|
+
!hideCaret
|
335
|
+
? <span className={cx('DropDown-caret')} >
|
336
|
+
<Icon icon="caret" className="icon" />
|
337
|
+
</span>
|
338
|
+
: null
|
339
|
+
}
|
323
340
|
</button>
|
324
341
|
</TooltipWrapper>
|
325
342
|
{this.state.isOpened ? this.renderOuter() : null}
|
@@ -108,6 +108,9 @@ export default class ButtonGroupControl extends React.Component<
|
|
108
108
|
className: cx(option.className, btnClassName),
|
109
109
|
disabled: option.disabled || disabled,
|
110
110
|
onClick: (e: React.UIEvent<any>) => {
|
111
|
+
if (disabled) {
|
112
|
+
return;
|
113
|
+
}
|
111
114
|
this.handleToggle(option);
|
112
115
|
e.preventDefault(); // 禁止 onAction 触发
|
113
116
|
}
|
@@ -1452,3 +1452,10 @@ export default class ComboControl extends React.Component<ComboProps> {
|
|
1452
1452
|
extendsData: false
|
1453
1453
|
})
|
1454
1454
|
export class ComboControlRenderer extends ComboControl {}
|
1455
|
+
|
1456
|
+
@FormItem({
|
1457
|
+
type: 'input-kv',
|
1458
|
+
storeType: ComboStore.name,
|
1459
|
+
extendsData: false
|
1460
|
+
})
|
1461
|
+
export class KVControlRenderer extends ComboControl {}
|
@@ -118,7 +118,7 @@ export default class EditorControl extends React.Component<EditorProps, any> {
|
|
118
118
|
static defaultProps: Partial<EditorProps> = {
|
119
119
|
language: 'javascript',
|
120
120
|
editorTheme: 'vs',
|
121
|
-
allowFullscreen:
|
121
|
+
allowFullscreen: true,
|
122
122
|
options: {
|
123
123
|
automaticLayout: true,
|
124
124
|
selectOnLineNumbers: true,
|
@@ -294,26 +294,25 @@ export const availableLanguages = [
|
|
294
294
|
'yaml'
|
295
295
|
];
|
296
296
|
|
297
|
-
export const EditorControls: Array<
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
}
|
313
|
-
}
|
297
|
+
export const EditorControls: Array<typeof EditorControl> =
|
298
|
+
availableLanguages.map((lang: string) => {
|
299
|
+
@FormItem({
|
300
|
+
type: `${lang}-editor`,
|
301
|
+
sizeMutable: false
|
302
|
+
})
|
303
|
+
class EditorControlRenderer extends EditorControl {
|
304
|
+
static lang = lang;
|
305
|
+
static displayName = `${lang[0].toUpperCase()}${lang.substring(
|
306
|
+
1
|
307
|
+
)}EditorControlRenderer`;
|
308
|
+
static defaultProps = {
|
309
|
+
...EditorControl.defaultProps,
|
310
|
+
language: lang
|
311
|
+
};
|
312
|
+
}
|
314
313
|
|
315
|
-
|
316
|
-
});
|
314
|
+
return EditorControlRenderer;
|
315
|
+
});
|
317
316
|
|
318
317
|
@FormItem({
|
319
318
|
type: 'js-editor',
|
@@ -28,6 +28,11 @@ export interface InputExcelControlSchema extends FormBaseControl {
|
|
28
28
|
* 是否包含空内容,主要用于二维数组模式
|
29
29
|
*/
|
30
30
|
includeEmpty: boolean;
|
31
|
+
|
32
|
+
/**
|
33
|
+
* 纯文本模式
|
34
|
+
*/
|
35
|
+
plainText: boolean;
|
31
36
|
}
|
32
37
|
|
33
38
|
export interface ExcelProps
|
@@ -48,12 +53,15 @@ export default class ExcelControl extends React.PureComponent<
|
|
48
53
|
static defaultProps: Partial<ExcelProps> = {
|
49
54
|
allSheets: false,
|
50
55
|
parseMode: 'object',
|
51
|
-
includeEmpty: true
|
56
|
+
includeEmpty: true,
|
57
|
+
plainText: true
|
52
58
|
};
|
53
59
|
state: ExcelControlState = {
|
54
60
|
open: false
|
55
61
|
};
|
56
62
|
|
63
|
+
ExcelJS: any;
|
64
|
+
|
57
65
|
@autobind
|
58
66
|
handleDrop(files: File[]) {
|
59
67
|
const {allSheets, onChange} = this.props;
|
@@ -63,6 +71,7 @@ export default class ExcelControl extends React.PureComponent<
|
|
63
71
|
reader.onload = async () => {
|
64
72
|
if (reader.result) {
|
65
73
|
import('exceljs').then(async (ExcelJS: any) => {
|
74
|
+
this.ExcelJS = ExcelJS;
|
66
75
|
const workbook = new ExcelJS.Workbook();
|
67
76
|
await workbook.xlsx.load(reader.result);
|
68
77
|
if (allSheets) {
|
@@ -88,7 +97,7 @@ export default class ExcelControl extends React.PureComponent<
|
|
88
97
|
*/
|
89
98
|
readWorksheet(worksheet: any) {
|
90
99
|
const result: any[] = [];
|
91
|
-
const {parseMode} = this.props;
|
100
|
+
const {parseMode, plainText} = this.props;
|
92
101
|
|
93
102
|
if (parseMode === 'array') {
|
94
103
|
worksheet.eachRow((row: any, rowNumber: number) => {
|
@@ -107,7 +116,23 @@ export default class ExcelControl extends React.PureComponent<
|
|
107
116
|
const data: any = {};
|
108
117
|
row.eachCell((cell: any, colNumber: any) => {
|
109
118
|
if (firstRowValues[colNumber]) {
|
110
|
-
|
119
|
+
let value = cell.value;
|
120
|
+
if (plainText) {
|
121
|
+
const ExcelValueType = this.ExcelJS.ValueType;
|
122
|
+
if (cell.type === ExcelValueType.Hyperlink) {
|
123
|
+
value = cell.value.hyperlink;
|
124
|
+
} else if (cell.type === ExcelValueType.Formula) {
|
125
|
+
value = cell.value.result;
|
126
|
+
} else if (cell.type === ExcelValueType.RichText) {
|
127
|
+
value = cell.value.richText
|
128
|
+
.map((item: any) => item.text)
|
129
|
+
.join('');
|
130
|
+
} else if (cell.type === ExcelValueType.Error) {
|
131
|
+
value = '';
|
132
|
+
}
|
133
|
+
}
|
134
|
+
|
135
|
+
data[firstRowValues[colNumber]] = value;
|
111
136
|
}
|
112
137
|
});
|
113
138
|
result.push(data);
|
@@ -110,6 +110,16 @@ export interface ImageControlSchema extends FormBaseControl {
|
|
110
110
|
scalable?: boolean;
|
111
111
|
};
|
112
112
|
|
113
|
+
/**
|
114
|
+
* 裁剪后的图片类型
|
115
|
+
*/
|
116
|
+
cropFormat?: string;
|
117
|
+
|
118
|
+
/**
|
119
|
+
* 裁剪后的质量
|
120
|
+
*/
|
121
|
+
cropQuality?: number;
|
122
|
+
|
113
123
|
/**
|
114
124
|
* 是否允许二次裁剪。
|
115
125
|
*/
|
@@ -862,14 +872,19 @@ export default class ImageControl extends React.Component<
|
|
862
872
|
}
|
863
873
|
|
864
874
|
handleCrop() {
|
865
|
-
|
866
|
-
|
867
|
-
|
868
|
-
|
869
|
-
|
870
|
-
|
871
|
-
|
872
|
-
|
875
|
+
const {cropFormat, cropQuality} = this.props;
|
876
|
+
this.cropper.getCroppedCanvas().toBlob(
|
877
|
+
(file: File) => {
|
878
|
+
this.addFiles([file]);
|
879
|
+
this.setState({
|
880
|
+
cropFile: undefined,
|
881
|
+
locked: false,
|
882
|
+
lockedReason: ''
|
883
|
+
});
|
884
|
+
},
|
885
|
+
cropFormat || 'image/png',
|
886
|
+
cropQuality || 1
|
887
|
+
);
|
873
888
|
}
|
874
889
|
|
875
890
|
cancelCrop() {
|
@@ -4,7 +4,8 @@ import cx from 'classnames';
|
|
4
4
|
import {filter} from '../../utils/tpl';
|
5
5
|
import NumberInput from '../../components/NumberInput';
|
6
6
|
import {FormOptionsControl} from './Options';
|
7
|
-
|
7
|
+
import Select, {normalizeOptions, Option} from '../../components/Select';
|
8
|
+
import {PlainObject} from '../../types';
|
8
9
|
/**
|
9
10
|
* 数字输入框
|
10
11
|
* 文档:https://baidu.gitee.io/amis/docs/components/form/number
|
@@ -48,14 +49,20 @@ export interface NumberControlSchema extends FormBaseControl {
|
|
48
49
|
* 后缀
|
49
50
|
*/
|
50
51
|
suffix?: string;
|
52
|
+
|
53
|
+
/**
|
54
|
+
* 单位列表
|
55
|
+
*/
|
56
|
+
unitOptions?: string | Array<Option> | string[] | PlainObject;
|
57
|
+
|
51
58
|
/**
|
52
59
|
* 是否千分分隔
|
53
60
|
*/
|
54
61
|
kilobitSeparator?: boolean;
|
55
62
|
/**
|
56
|
-
|
57
|
-
|
58
|
-
readOnly?: boolean
|
63
|
+
* 只读
|
64
|
+
*/
|
65
|
+
readOnly?: boolean;
|
59
66
|
}
|
60
67
|
|
61
68
|
export interface NumberProps extends FormControlProps {
|
@@ -67,8 +74,8 @@ export interface NumberProps extends FormControlProps {
|
|
67
74
|
/**
|
68
75
|
* 边框模式,全边框,还是半边框,或者没边框。
|
69
76
|
*/
|
70
|
-
|
71
|
-
|
77
|
+
borderMode?: 'full' | 'half' | 'none';
|
78
|
+
/**
|
72
79
|
* 前缀
|
73
80
|
*/
|
74
81
|
prefix?: string;
|
@@ -83,10 +90,19 @@ export interface NumberProps extends FormControlProps {
|
|
83
90
|
/**
|
84
91
|
* 只读
|
85
92
|
*/
|
86
|
-
readOnly?: boolean
|
93
|
+
readOnly?: boolean;
|
94
|
+
}
|
95
|
+
|
96
|
+
interface NumberState {
|
97
|
+
// 数字单位,将会影响输出
|
98
|
+
unit?: string;
|
99
|
+
unitOptions?: Option[];
|
87
100
|
}
|
88
101
|
|
89
|
-
export default class NumberControl extends React.Component<
|
102
|
+
export default class NumberControl extends React.Component<
|
103
|
+
NumberProps,
|
104
|
+
NumberState
|
105
|
+
> {
|
90
106
|
static defaultProps: Partial<NumberProps> = {
|
91
107
|
step: 1,
|
92
108
|
resetValue: ''
|
@@ -94,17 +110,51 @@ export default class NumberControl extends React.Component<NumberProps, any> {
|
|
94
110
|
|
95
111
|
constructor(props: NumberProps) {
|
96
112
|
super(props);
|
97
|
-
|
98
113
|
this.handleChange = this.handleChange.bind(this);
|
114
|
+
this.handleChangeUnit = this.handleChangeUnit.bind(this);
|
115
|
+
const unit = this.getUnit();
|
116
|
+
const unitOptions = normalizeOptions(props.unitOptions);
|
117
|
+
this.state = {unit, unitOptions};
|
118
|
+
}
|
119
|
+
|
120
|
+
// 解析出单位
|
121
|
+
getUnit() {
|
122
|
+
const props = this.props;
|
123
|
+
if (props.unitOptions && props.unitOptions.length) {
|
124
|
+
const optionValues = normalizeOptions(props.unitOptions).map(
|
125
|
+
option => option.value
|
126
|
+
);
|
127
|
+
// 如果有值就解析出来作为单位
|
128
|
+
if (props.value && typeof props.value === 'string') {
|
129
|
+
let unit = optionValues[0];
|
130
|
+
// 先找长的字符,这样如果有 ab 和 b 两种后缀相同的也能识别
|
131
|
+
optionValues.sort((a, b) => b.length - a.length);
|
132
|
+
for (const optionValue of optionValues) {
|
133
|
+
if (props.value.endsWith(optionValue)) {
|
134
|
+
unit = optionValue;
|
135
|
+
break;
|
136
|
+
}
|
137
|
+
}
|
138
|
+
return unit;
|
139
|
+
} else {
|
140
|
+
// 没有值就使用第一个单位
|
141
|
+
return optionValues[0];
|
142
|
+
}
|
143
|
+
}
|
144
|
+
return undefined;
|
99
145
|
}
|
100
146
|
|
101
147
|
handleChange(inputValue: any) {
|
102
|
-
const {classPrefix: ns, onChange, resetValue} = this.props;
|
148
|
+
const {classPrefix: ns, onChange, resetValue, unitOptions} = this.props;
|
103
149
|
|
104
150
|
if (inputValue && typeof inputValue !== 'number') {
|
105
151
|
return;
|
106
152
|
}
|
107
153
|
|
154
|
+
if (inputValue !== null && unitOptions && this.state.unit) {
|
155
|
+
inputValue = inputValue + this.state.unit;
|
156
|
+
}
|
157
|
+
|
108
158
|
onChange(inputValue === null ? resetValue ?? null : inputValue);
|
109
159
|
}
|
110
160
|
|
@@ -116,6 +166,28 @@ export default class NumberControl extends React.Component<NumberProps, any> {
|
|
116
166
|
return value;
|
117
167
|
}
|
118
168
|
|
169
|
+
// 单位选项的变更
|
170
|
+
handleChangeUnit(option: Option) {
|
171
|
+
let value = this.props.value;
|
172
|
+
const prevUnitValue = this.state.unit;
|
173
|
+
this.setState({unit: option.value}, () => {
|
174
|
+
if (value) {
|
175
|
+
value = value.replace(prevUnitValue, '');
|
176
|
+
this.props.onChange(value + this.state.unit);
|
177
|
+
}
|
178
|
+
});
|
179
|
+
}
|
180
|
+
|
181
|
+
componentDidUpdate(prevProps: NumberProps) {
|
182
|
+
if (this.props.value !== prevProps.value) {
|
183
|
+
const unit = this.getUnit();
|
184
|
+
this.setState({unit: unit});
|
185
|
+
}
|
186
|
+
if (this.props.unitOptions !== prevProps.unitOptions) {
|
187
|
+
this.setState({unitOptions: normalizeOptions(this.props.unitOptions)});
|
188
|
+
}
|
189
|
+
}
|
190
|
+
|
119
191
|
render(): JSX.Element {
|
120
192
|
const {
|
121
193
|
className,
|
@@ -132,6 +204,7 @@ export default class NumberControl extends React.Component<NumberProps, any> {
|
|
132
204
|
suffix,
|
133
205
|
prefix,
|
134
206
|
kilobitSeparator,
|
207
|
+
unitOptions,
|
135
208
|
readOnly
|
136
209
|
} = this.props;
|
137
210
|
|
@@ -141,29 +214,43 @@ export default class NumberControl extends React.Component<NumberProps, any> {
|
|
141
214
|
if (typeof finalPrecision === 'number') {
|
142
215
|
precisionProps.precision = finalPrecision;
|
143
216
|
}
|
217
|
+
|
218
|
+
const unit = this.state?.unit;
|
144
219
|
// 数据格式化
|
145
220
|
const formatter = (value: string | number) => {
|
146
221
|
// 增加千分分隔
|
147
222
|
if (kilobitSeparator && value) {
|
148
223
|
value = (value + '').replace(/\B(?=(\d{3})+(?!\d))/g, ',');
|
149
224
|
}
|
150
|
-
return (prefix ? prefix : '')
|
151
|
-
|
152
|
-
+ (suffix ? suffix : '');
|
153
|
-
}
|
225
|
+
return (prefix ? prefix : '') + value + (suffix ? suffix : '');
|
226
|
+
};
|
154
227
|
// 将数字还原
|
155
228
|
const parser = (value: string) => {
|
156
229
|
if (value) {
|
157
230
|
prefix && (value = value.replace(prefix, ''));
|
158
231
|
suffix && (value = value.replace(suffix, ''));
|
159
|
-
kilobitSeparator &&
|
232
|
+
kilobitSeparator && (value = value.replace(/,/g, ''));
|
160
233
|
}
|
161
234
|
return value;
|
162
|
-
}
|
235
|
+
};
|
236
|
+
|
237
|
+
const finalValue =
|
238
|
+
unit && value && typeof value === 'string'
|
239
|
+
? value.replace(unit, '')
|
240
|
+
: value;
|
241
|
+
|
163
242
|
return (
|
164
|
-
<div
|
243
|
+
<div
|
244
|
+
className={cx(
|
245
|
+
`${ns}NumberControl`,
|
246
|
+
{
|
247
|
+
[`${ns}NumberControl--withUnit`]: unitOptions
|
248
|
+
},
|
249
|
+
className
|
250
|
+
)}
|
251
|
+
>
|
165
252
|
<NumberInput
|
166
|
-
value={
|
253
|
+
value={finalValue}
|
167
254
|
step={step}
|
168
255
|
max={this.filterNum(max)}
|
169
256
|
min={this.filterNum(min)}
|
@@ -177,6 +264,14 @@ export default class NumberControl extends React.Component<NumberProps, any> {
|
|
177
264
|
borderMode={borderMode}
|
178
265
|
readOnly={readOnly}
|
179
266
|
/>
|
267
|
+
{unitOptions ? (
|
268
|
+
<Select
|
269
|
+
value={unit}
|
270
|
+
clearable={false}
|
271
|
+
options={this.state.unitOptions || []}
|
272
|
+
onChange={this.handleChangeUnit}
|
273
|
+
/>
|
274
|
+
) : null}
|
180
275
|
</div>
|
181
276
|
);
|
182
277
|
}
|
@@ -7,6 +7,7 @@ import {FormItem, FormControlProps, FormBaseControl} from './Item';
|
|
7
7
|
import InputRange from '../../components/Range';
|
8
8
|
import {Icon} from '../../components/icons';
|
9
9
|
import {FormOptionsControl} from './Options';
|
10
|
+
import {stripNumber} from '../../utils/tpl-builtin';
|
10
11
|
|
11
12
|
/**
|
12
13
|
* Range
|
@@ -205,7 +206,7 @@ export default class RangeControl extends React.PureComponent<
|
|
205
206
|
|
206
207
|
handleChange(value: any) {
|
207
208
|
this.setState({
|
208
|
-
value: value,
|
209
|
+
value: stripNumber(value),
|
209
210
|
minValue: value.min,
|
210
211
|
maxValue: value.max
|
211
212
|
});
|
@@ -253,6 +254,8 @@ export default class RangeControl extends React.PureComponent<
|
|
253
254
|
min: value.min,
|
254
255
|
max: value.max
|
255
256
|
};
|
257
|
+
} else {
|
258
|
+
endValue = stripNumber(value);
|
256
259
|
}
|
257
260
|
const {onChange} = this.props;
|
258
261
|
this.setState(
|
@@ -268,7 +271,7 @@ export default class RangeControl extends React.PureComponent<
|
|
268
271
|
|
269
272
|
return typeof step !== 'number' || step >= 1 || step < 0
|
270
273
|
? 0
|
271
|
-
: step.toString().split('.')[1]
|
274
|
+
: step.toString().split('.')[1]?.length;
|
272
275
|
}
|
273
276
|
|
274
277
|
getValue(value: any, type?: string) {
|