amis 1.8.0-beta.0 → 1.8.0-beta.3
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/SchemaRenderer.js +19 -3
- package/lib/SchemaRenderer.js.map +2 -2
- package/lib/WithRootStore.d.ts +18 -0
- package/lib/WithStore.js +2 -1
- package/lib/WithStore.js.map +2 -2
- package/lib/actions/CmptAction.js +14 -3
- package/lib/actions/CmptAction.js.map +2 -2
- package/lib/components/BarCode.js +1 -1
- package/lib/components/BarCode.js.map +2 -2
- package/lib/components/DatePicker.d.ts +3 -0
- package/lib/components/DatePicker.js +56 -11
- package/lib/components/DatePicker.js.map +2 -2
- package/lib/components/DateRangePicker.d.ts +92 -84
- package/lib/components/DateRangePicker.js +198 -5
- package/lib/components/DateRangePicker.js.map +2 -2
- package/lib/components/MonthRangePicker.d.ts +84 -84
- package/lib/components/Progress.js +12 -9
- package/lib/components/Progress.js.map +2 -2
- package/lib/components/Radios.d.ts +1 -1
- package/lib/components/Radios.js +3 -5
- package/lib/components/Radios.js.map +2 -2
- package/lib/components/Range.d.ts +2 -2
- package/lib/components/Range.js +24 -11
- package/lib/components/Range.js.map +2 -2
- package/lib/components/Steps.d.ts +6 -0
- package/lib/components/Steps.js +13 -9
- package/lib/components/Steps.js.map +2 -2
- package/lib/components/calendar/Calendar.js +16 -12
- package/lib/components/calendar/Calendar.js.map +2 -2
- package/lib/components/calendar/YearsView.js +3 -3
- package/lib/components/calendar/YearsView.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/factory.d.ts +4 -0
- package/lib/factory.js +8 -2
- package/lib/factory.js.map +2 -2
- package/lib/index.js +1 -1
- package/lib/locale/de-DE.js +13 -0
- package/lib/locale/de-DE.js.map +2 -2
- package/lib/locale/en-US.js +13 -0
- package/lib/locale/en-US.js.map +2 -2
- package/lib/locale/zh-CN.js +13 -0
- package/lib/locale/zh-CN.js.map +2 -2
- package/lib/renderers/Action.d.ts +2 -0
- package/lib/renderers/Action.js +23 -5
- package/lib/renderers/Action.js.map +2 -2
- package/lib/renderers/Carousel.d.ts +1 -0
- package/lib/renderers/Carousel.js +13 -1
- package/lib/renderers/Carousel.js.map +2 -2
- 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/Checkboxes.d.ts +2 -2
- package/lib/renderers/Form/Checkboxes.js +2 -6
- package/lib/renderers/Form/Checkboxes.js.map +2 -2
- package/lib/renderers/Form/Combo.js +3 -2
- package/lib/renderers/Form/Combo.js.map +2 -2
- package/lib/renderers/Form/InputCity.d.ts +3 -0
- package/lib/renderers/Form/InputCity.js +44 -2
- package/lib/renderers/Form/InputCity.js.map +2 -2
- package/lib/renderers/Form/InputDateRange.d.ts +5 -0
- package/lib/renderers/Form/InputDateRange.js.map +2 -2
- package/lib/renderers/Form/InputFile.js +6 -3
- 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.js +6 -3
- package/lib/renderers/Form/InputImage.js.map +2 -2
- package/lib/renderers/Form/InputRange.js +13 -14
- 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/Item.d.ts +11 -6
- package/lib/renderers/Form/index.js +1 -1
- package/lib/renderers/Form/index.js.map +2 -2
- package/lib/renderers/Form/wrapControl.d.ts +9 -0
- package/lib/renderers/Form/wrapControl.js +1 -1
- package/lib/renderers/Form/wrapControl.js.map +2 -2
- package/lib/renderers/Nav.js +2 -2
- package/lib/renderers/Nav.js.map +2 -2
- package/lib/renderers/Page.js +2 -3
- package/lib/renderers/Page.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/Steps.d.ts +8 -0
- package/lib/renderers/Steps.js +2 -2
- package/lib/renderers/Steps.js.map +2 -2
- package/lib/renderers/Table/TableRow.js +1 -1
- package/lib/renderers/Table/TableRow.js.map +2 -2
- package/lib/renderers/Table/index.js +7 -3
- package/lib/renderers/Table/index.js.map +2 -2
- package/lib/renderers/Tabs.d.ts +4 -0
- package/lib/renderers/Tabs.js +22 -6
- package/lib/renderers/Tabs.js.map +2 -2
- package/lib/renderers/Wizard.d.ts +6 -3
- package/lib/renderers/Wizard.js +257 -152
- package/lib/renderers/Wizard.js.map +2 -2
- package/lib/store/index.d.ts +5 -0
- package/lib/store/index.js +14 -0
- package/lib/store/index.js.map +2 -2
- package/lib/store/table.js +4 -4
- package/lib/store/table.js.map +2 -2
- package/lib/themes/ang-ie11.css +194 -23
- package/lib/themes/ang.css +193 -22
- package/lib/themes/ang.css.map +1 -1
- package/lib/themes/antd-ie11.css +194 -23
- package/lib/themes/antd.css +193 -22
- package/lib/themes/antd.css.map +1 -1
- package/lib/themes/cxd-ie11.css +194 -23
- package/lib/themes/cxd.css +193 -22
- package/lib/themes/cxd.css.map +1 -1
- package/lib/themes/dark-ie11.css +194 -23
- package/lib/themes/dark.css +193 -22
- package/lib/themes/dark.css.map +1 -1
- package/lib/themes/default-ie11.css +194 -23
- package/lib/themes/default.css +193 -22
- package/lib/themes/default.css.map +1 -1
- package/lib/types.d.ts +1 -1
- package/lib/types.js.map +1 -1
- package/lib/utils/columnsSplit.d.ts +1 -0
- package/lib/utils/columnsSplit.js +40 -0
- package/lib/utils/columnsSplit.js.map +13 -0
- package/lib/utils/debug.d.ts +1 -1
- package/lib/utils/debug.js +16 -22
- package/lib/utils/debug.js.map +2 -2
- package/package.json +1 -1
- package/schema.json +181 -30
- package/scss/_properties.scss +2 -2
- package/scss/components/_barcode.scss +1 -1
- package/scss/components/_carousel.scss +1 -0
- package/scss/components/_debug.scss +3 -3
- package/scss/components/_formula.scss +18 -0
- package/scss/components/_progress.scss +3 -8
- package/scss/components/_steps.scss +199 -8
- package/scss/components/form/_date.scss +14 -0
- package/scss/components/form/_editor.scss +2 -1
- package/sdk/ang-ie11.css +234 -25
- package/sdk/ang.css +233 -24
- package/sdk/antd-ie11.css +234 -25
- package/sdk/antd.css +233 -24
- 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 +234 -25
- package/sdk/cxd.css +233 -24
- package/sdk/dark-ie11.css +234 -25
- package/sdk/dark.css +233 -24
- package/sdk/exceljs.js +1 -1
- package/sdk/locale/de-DE.js +13 -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 +17 -17
- package/sdk/rich-text.js +62 -62
- package/sdk/sdk-ie11.css +234 -25
- package/sdk/sdk.css +233 -24
- package/sdk/sdk.js +1290 -1288
- 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/SchemaRenderer.tsx +32 -14
- package/src/WithStore.tsx +3 -1
- package/src/actions/CmptAction.ts +18 -0
- package/src/components/BarCode.tsx +2 -2
- package/src/components/DatePicker.tsx +77 -22
- package/src/components/DateRangePicker.tsx +198 -4
- package/src/components/Progress.tsx +8 -12
- package/src/components/Radios.tsx +6 -17
- package/src/components/Range.tsx +26 -12
- package/src/components/Steps.tsx +28 -27
- package/src/components/calendar/Calendar.tsx +17 -12
- package/src/components/calendar/YearsView.tsx +3 -4
- package/src/components/formula/Editor.tsx +34 -3
- package/src/components/formula/Picker.tsx +28 -1
- package/src/factory.tsx +15 -2
- package/src/locale/de-DE.ts +13 -0
- package/src/locale/en-US.ts +13 -0
- package/src/locale/zh-CN.ts +13 -0
- package/src/renderers/Action.tsx +22 -1
- package/src/renderers/Carousel.tsx +8 -0
- package/src/renderers/Dialog.tsx +17 -3
- package/src/renderers/DropDownButton.tsx +14 -3
- package/src/renderers/Form/Checkboxes.tsx +5 -18
- package/src/renderers/Form/Combo.tsx +2 -3
- package/src/renderers/Form/InputCity.tsx +33 -4
- package/src/renderers/Form/InputDateRange.tsx +8 -1
- package/src/renderers/Form/InputFile.tsx +7 -3
- package/src/renderers/Form/InputFormula.tsx +7 -0
- package/src/renderers/Form/InputImage.tsx +7 -3
- package/src/renderers/Form/InputRange.tsx +18 -16
- package/src/renderers/Form/InputTable.tsx +6 -2
- package/src/renderers/Form/index.tsx +1 -1
- package/src/renderers/Form/wrapControl.tsx +1 -1
- package/src/renderers/Nav.tsx +1 -1
- package/src/renderers/Page.tsx +1 -2
- package/src/renderers/Progress.tsx +2 -2
- package/src/renderers/Steps.tsx +14 -0
- package/src/renderers/Table/TableRow.tsx +1 -1
- package/src/renderers/Table/index.tsx +11 -2
- package/src/renderers/Tabs.tsx +75 -28
- package/src/renderers/Wizard.tsx +154 -93
- package/src/store/index.ts +20 -0
- package/src/store/table.ts +4 -4
- package/src/types.ts +3 -1
- package/src/utils/columnsSplit.tsx +57 -0
- package/src/utils/debug.tsx +17 -24
package/src/SchemaRenderer.tsx
CHANGED
@@ -15,12 +15,14 @@ import {asFormItem} from './renderers/Form/Item';
|
|
15
15
|
import {renderChild, renderChildren} from './Root';
|
16
16
|
import {IScopedContext, ScopedContext} from './Scoped';
|
17
17
|
import {Schema, SchemaNode} from './types';
|
18
|
-
import {DebugWrapper
|
18
|
+
import {DebugWrapper} from './utils/debug';
|
19
19
|
import getExprProperties from './utils/filter-schema';
|
20
20
|
import {anyChanged, chainEvents, autobind} from './utils/helper';
|
21
21
|
import {SimpleMap} from './utils/SimpleMap';
|
22
22
|
|
23
23
|
import type {RendererEvent} from './utils/renderer-event';
|
24
|
+
import {observer} from 'mobx-react';
|
25
|
+
import {isAlive} from 'mobx-state-tree';
|
24
26
|
|
25
27
|
interface SchemaRendererProps extends Partial<RendererProps> {
|
26
28
|
schema: Schema;
|
@@ -59,6 +61,7 @@ const defaultOmitList = [
|
|
59
61
|
|
60
62
|
const componentCache: SimpleMap = new SimpleMap();
|
61
63
|
|
64
|
+
@observer
|
62
65
|
class BroadcastCmpt extends React.Component<BroadcastCmptProps> {
|
63
66
|
ref: any;
|
64
67
|
unbindEvent: (() => void) | undefined = undefined;
|
@@ -99,21 +102,36 @@ class BroadcastCmpt extends React.Component<BroadcastCmptProps> {
|
|
99
102
|
}
|
100
103
|
|
101
104
|
render() {
|
102
|
-
const {component: Component, ...rest} = this.props;
|
103
|
-
|
105
|
+
const {component: Component, rootStore, ...rest} = this.props;
|
106
|
+
const visible = isAlive(rootStore)
|
107
|
+
? rootStore.visibleState[rest.$schema.id || rest.$path]
|
108
|
+
: true;
|
109
|
+
const disable = isAlive(rootStore)
|
110
|
+
? rootStore.disableState[rest.$schema.id || rest.$path]
|
111
|
+
: false;
|
104
112
|
const isClassComponent = Component.prototype?.isReactComponent;
|
105
113
|
|
106
|
-
|
114
|
+
if (disable) {
|
115
|
+
(rest as any).disabled = true;
|
116
|
+
}
|
107
117
|
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
118
|
+
// 函数组件不支持 ref https://reactjs.org/docs/refs-and-the-dom.html#refs-and-function-components
|
119
|
+
return visible !== false ? (
|
120
|
+
isClassComponent ? (
|
121
|
+
<Component
|
122
|
+
ref={this.childRef}
|
123
|
+
{...rest}
|
124
|
+
rootStore={rootStore}
|
125
|
+
dispatchEvent={this.dispatchEvent}
|
126
|
+
/>
|
127
|
+
) : (
|
128
|
+
<Component
|
129
|
+
{...rest}
|
130
|
+
rootStore={rootStore}
|
131
|
+
dispatchEvent={this.dispatchEvent}
|
132
|
+
/>
|
133
|
+
)
|
134
|
+
) : null;
|
117
135
|
}
|
118
136
|
}
|
119
137
|
|
@@ -399,7 +417,7 @@ export class SchemaRenderer extends React.Component<SchemaRendererProps, any> {
|
|
399
417
|
/>
|
400
418
|
);
|
401
419
|
|
402
|
-
return enableAMISDebug ? (
|
420
|
+
return this.props.env.enableAMISDebug ? (
|
403
421
|
<DebugWrapper renderer={renderer}>{component}</DebugWrapper>
|
404
422
|
) : (
|
405
423
|
component
|
package/src/WithStore.tsx
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
import hoistNonReactStatic from 'hoist-non-react-statics';
|
2
2
|
import {observer} from 'mobx-react';
|
3
|
+
import {isAlive} from 'mobx-state-tree';
|
3
4
|
import React from 'react';
|
4
5
|
import {RendererProps} from './factory';
|
5
6
|
import {IIRendererStore, IRendererStore} from './store';
|
@@ -257,7 +258,8 @@ export function HocStoreFactory(renderer: {
|
|
257
258
|
componentWillUnmount() {
|
258
259
|
const rootStore = this.context as IRendererStore;
|
259
260
|
const store = this.store;
|
260
|
-
|
261
|
+
|
262
|
+
isAlive(store) && rootStore.removeStore(store);
|
261
263
|
|
262
264
|
// @ts-ignore
|
263
265
|
delete this.store;
|
@@ -21,6 +21,19 @@ export class CmptAction implements Action {
|
|
21
21
|
renderer: ListenerContext,
|
22
22
|
event: RendererEvent<any>
|
23
23
|
) {
|
24
|
+
// 显隐&状态控制
|
25
|
+
if (['show', 'hidden'].includes(action.actionType)) {
|
26
|
+
return renderer.props.rootStore.setVisible(
|
27
|
+
action.componentId,
|
28
|
+
action.actionType === 'show'
|
29
|
+
);
|
30
|
+
} else if (['enabled', 'disabled'].includes(action.actionType)) {
|
31
|
+
return renderer.props.rootStore.setDisable(
|
32
|
+
action.componentId,
|
33
|
+
action.actionType === 'disabled'
|
34
|
+
);
|
35
|
+
}
|
36
|
+
|
24
37
|
/**
|
25
38
|
* 根据唯一ID查找指定组件
|
26
39
|
* 触发组件未指定id或未指定响应组件componentId,则使用触发组件响应
|
@@ -30,6 +43,11 @@ export class CmptAction implements Action {
|
|
30
43
|
? event.context.scoped?.getComponentById(action.componentId)
|
31
44
|
: renderer;
|
32
45
|
|
46
|
+
// 刷新
|
47
|
+
if (action.actionType === 'reload') {
|
48
|
+
return component.reload?.(undefined, action.args);
|
49
|
+
}
|
50
|
+
|
33
51
|
// 执行组件动作
|
34
52
|
return component.doAction?.(action, action.args);
|
35
53
|
}
|
@@ -20,7 +20,7 @@ export class BarCode extends React.Component<BarCodeProps> {
|
|
20
20
|
|
21
21
|
constructor(props: BarCodeProps) {
|
22
22
|
super(props);
|
23
|
-
this.dom = React.createRef<
|
23
|
+
this.dom = React.createRef<HTMLImageElement>();
|
24
24
|
}
|
25
25
|
|
26
26
|
componentDidUpdate(prevProps: BarCodeProps) {
|
@@ -43,7 +43,7 @@ export class BarCode extends React.Component<BarCodeProps> {
|
|
43
43
|
}
|
44
44
|
|
45
45
|
render() {
|
46
|
-
return <
|
46
|
+
return <img ref={this.dom} />;
|
47
47
|
}
|
48
48
|
}
|
49
49
|
|
@@ -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,17 +354,35 @@ 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
|
|
358
|
-
|
359
|
-
|
367
|
+
const prevValue = prevProps.value;
|
368
|
+
|
369
|
+
if (prevValue !== props.value) {
|
370
|
+
const newState: any = {
|
360
371
|
value: normalizeValue(props.value, props.format)
|
361
|
-
}
|
372
|
+
};
|
373
|
+
// 相对值和公式是 didUpdate 的时候才更新
|
374
|
+
if (
|
375
|
+
typeof prevValue === 'string' &&
|
376
|
+
(prevValue.startsWith('+') ||
|
377
|
+
prevValue.startsWith('-') ||
|
378
|
+
prevValue.startsWith('$'))
|
379
|
+
) {
|
380
|
+
newState.inputValue =
|
381
|
+
normalizeValue(this.props.value, this.props.format)?.format(
|
382
|
+
this.props.inputFormat
|
383
|
+
) || '';
|
384
|
+
}
|
385
|
+
this.setState(newState);
|
362
386
|
}
|
363
387
|
}
|
364
388
|
|
@@ -403,13 +427,17 @@ export class DatePicker extends React.Component<DateProps, DatePickerState> {
|
|
403
427
|
}
|
404
428
|
|
405
429
|
open(fn?: () => void) {
|
406
|
-
this.props.disabled
|
407
|
-
|
408
|
-
|
409
|
-
|
410
|
-
|
411
|
-
|
412
|
-
|
430
|
+
if (this.props.disabled) {
|
431
|
+
return;
|
432
|
+
}
|
433
|
+
this.setState(
|
434
|
+
{
|
435
|
+
isOpened: true
|
436
|
+
},
|
437
|
+
fn
|
438
|
+
);
|
439
|
+
const input = this.inputRef.current;
|
440
|
+
input && input.focus();
|
413
441
|
}
|
414
442
|
|
415
443
|
close() {
|
@@ -423,6 +451,7 @@ export class DatePicker extends React.Component<DateProps, DatePickerState> {
|
|
423
451
|
e.stopPropagation();
|
424
452
|
const onChange = this.props.onChange;
|
425
453
|
onChange('');
|
454
|
+
this.setState({inputValue: ''});
|
426
455
|
}
|
427
456
|
|
428
457
|
handleChange(value: moment.Moment) {
|
@@ -432,6 +461,7 @@ export class DatePicker extends React.Component<DateProps, DatePickerState> {
|
|
432
461
|
minDate,
|
433
462
|
maxDate,
|
434
463
|
dateFormat,
|
464
|
+
inputFormat,
|
435
465
|
timeFormat,
|
436
466
|
closeOnSelect,
|
437
467
|
utc,
|
@@ -453,6 +483,31 @@ export class DatePicker extends React.Component<DateProps, DatePickerState> {
|
|
453
483
|
if (closeOnSelect && dateFormat && !timeFormat) {
|
454
484
|
this.close();
|
455
485
|
}
|
486
|
+
|
487
|
+
this.setState({
|
488
|
+
inputValue: utc
|
489
|
+
? moment.utc(value).format(inputFormat)
|
490
|
+
: value.format(inputFormat)
|
491
|
+
});
|
492
|
+
}
|
493
|
+
|
494
|
+
// 手动输入日期
|
495
|
+
inputChange(e: React.ChangeEvent<HTMLInputElement>) {
|
496
|
+
const {onChange, inputFormat, format, utc} = this.props;
|
497
|
+
const value = e.currentTarget.value;
|
498
|
+
this.setState({inputValue: value});
|
499
|
+
if (value === '') {
|
500
|
+
onChange('');
|
501
|
+
} else {
|
502
|
+
const newDate = moment(value, inputFormat);
|
503
|
+
const dateValue = utc
|
504
|
+
? moment.utc(newDate).format(format)
|
505
|
+
: newDate.format(format);
|
506
|
+
// 小于 0 的日期丢弃
|
507
|
+
if (!dateValue.startsWith('-')) {
|
508
|
+
onChange(dateValue);
|
509
|
+
}
|
510
|
+
}
|
456
511
|
}
|
457
512
|
|
458
513
|
selectRannge(item: any) {
|
@@ -684,7 +739,7 @@ export class DatePicker extends React.Component<DateProps, DatePickerState> {
|
|
684
739
|
`DatePicker`,
|
685
740
|
{
|
686
741
|
'is-disabled': disabled,
|
687
|
-
'is-focused': this.state.isFocused,
|
742
|
+
'is-focused': !disabled && this.state.isFocused,
|
688
743
|
[`DatePicker--border${ucFirst(borderMode)}`]: borderMode,
|
689
744
|
'is-mobile': useMobileUI && isMobile()
|
690
745
|
},
|
@@ -693,15 +748,15 @@ export class DatePicker extends React.Component<DateProps, DatePickerState> {
|
|
693
748
|
ref={this.domRef}
|
694
749
|
onClick={this.handleClick}
|
695
750
|
>
|
696
|
-
|
697
|
-
|
698
|
-
|
699
|
-
|
700
|
-
|
701
|
-
|
702
|
-
|
703
|
-
|
704
|
-
|
751
|
+
<Input
|
752
|
+
className={cx('DatePicker-input')}
|
753
|
+
onChange={this.inputChange}
|
754
|
+
ref={this.inputRef}
|
755
|
+
placeholder={__(placeholder)}
|
756
|
+
autoComplete="off"
|
757
|
+
value={this.state.inputValue}
|
758
|
+
disabled={disabled}
|
759
|
+
/>
|
705
760
|
|
706
761
|
{clearable && !disabled && normalizeValue(value, format) ? (
|
707
762
|
<a className={cx(`DatePicker-clear`)} onClick={this.clearValue}>
|
@@ -82,8 +82,19 @@ export const availableRanges: {[propName: string]: any} = {
|
|
82
82
|
}
|
83
83
|
},
|
84
84
|
|
85
|
-
'
|
86
|
-
label: '
|
85
|
+
'tomorrow': {
|
86
|
+
label: 'Date.tomorrow',
|
87
|
+
startDate: (now: moment.Moment) => {
|
88
|
+
return now.add(1, 'days').startOf('day');
|
89
|
+
},
|
90
|
+
endDate: (now: moment.Moment) => {
|
91
|
+
return now.add(1, 'days').endOf('day');
|
92
|
+
}
|
93
|
+
},
|
94
|
+
|
95
|
+
// 兼容一下错误的用法
|
96
|
+
'1daysago': {
|
97
|
+
label: 'DateRange.1daysago',
|
87
98
|
startDate: (now: moment.Moment) => {
|
88
99
|
return now.add(-1, 'days');
|
89
100
|
},
|
@@ -203,6 +214,177 @@ export const availableRanges: {[propName: string]: any} = {
|
|
203
214
|
}
|
204
215
|
};
|
205
216
|
|
217
|
+
export const advancedRanges = [
|
218
|
+
{
|
219
|
+
regexp: /^(\d+)hoursago$/,
|
220
|
+
resolve: (__: any, _: string, hours: string) => {
|
221
|
+
return {
|
222
|
+
label: __('DateRange.hoursago', {hours}),
|
223
|
+
startDate: (now: moment.Moment) => {
|
224
|
+
return now.add(-hours, 'hours').startOf('hour');
|
225
|
+
},
|
226
|
+
endDate: (now: moment.Moment) => {
|
227
|
+
return now.add(-1, 'hours').endOf('hours');
|
228
|
+
}
|
229
|
+
};
|
230
|
+
}
|
231
|
+
},
|
232
|
+
{
|
233
|
+
regexp: /^(\d+)hourslater$/,
|
234
|
+
resolve: (__: any, _: string, hours: string) => {
|
235
|
+
return {
|
236
|
+
label: __('DateRange.hourslater', {hours}),
|
237
|
+
startDate: (now: moment.Moment) => {
|
238
|
+
return now.startOf('hour');
|
239
|
+
},
|
240
|
+
endDate: (now: moment.Moment) => {
|
241
|
+
return now.add(hours, 'hours').endOf('hour');
|
242
|
+
}
|
243
|
+
};
|
244
|
+
}
|
245
|
+
},
|
246
|
+
{
|
247
|
+
regexp: /^(\d+)daysago$/,
|
248
|
+
resolve: (__: any, _: string, days: string) => {
|
249
|
+
return {
|
250
|
+
label: __('DateRange.daysago', {days}),
|
251
|
+
startDate: (now: moment.Moment) => {
|
252
|
+
return now.add(-days, 'days').startOf('day');
|
253
|
+
},
|
254
|
+
endDate: (now: moment.Moment) => {
|
255
|
+
return now.add(-1, 'days').endOf('day');
|
256
|
+
}
|
257
|
+
};
|
258
|
+
}
|
259
|
+
},
|
260
|
+
{
|
261
|
+
regexp: /^(\d+)dayslater$/,
|
262
|
+
resolve: (__: any, _: string, days: string) => {
|
263
|
+
return {
|
264
|
+
label: __('DateRange.dayslater', {days}),
|
265
|
+
startDate: (now: moment.Moment) => {
|
266
|
+
return now.startOf('day');
|
267
|
+
},
|
268
|
+
endDate: (now: moment.Moment) => {
|
269
|
+
return now.add(days, 'days').endOf('day');
|
270
|
+
}
|
271
|
+
};
|
272
|
+
}
|
273
|
+
},
|
274
|
+
{
|
275
|
+
regexp: /^(\d+)weeksago$/,
|
276
|
+
resolve: (__: any, _: string, weeks: string) => {
|
277
|
+
return {
|
278
|
+
label: __('DateRange.weeksago', {weeks}),
|
279
|
+
startDate: (now: moment.Moment) => {
|
280
|
+
return now.startOf('week').add(-weeks, 'weeks');
|
281
|
+
},
|
282
|
+
endDate: (now: moment.Moment) => {
|
283
|
+
return now.startOf('week').add(-1, 'days').endOf('day');
|
284
|
+
}
|
285
|
+
};
|
286
|
+
}
|
287
|
+
},
|
288
|
+
{
|
289
|
+
regexp: /^(\d+)weekslater$/,
|
290
|
+
resolve: (__: any, _: string, weeks: string) => {
|
291
|
+
return {
|
292
|
+
label: __('DateRange.weekslater', {weeks}),
|
293
|
+
startDate: (now: moment.Moment) => {
|
294
|
+
return now.startOf('week');
|
295
|
+
},
|
296
|
+
endDate: (now: moment.Moment) => {
|
297
|
+
return now.startOf('week').add(weeks, 'weeks').endOf('day');
|
298
|
+
}
|
299
|
+
};
|
300
|
+
}
|
301
|
+
},
|
302
|
+
{
|
303
|
+
regexp: /^(\d+)monthsago$/,
|
304
|
+
resolve: (__: any, _: string, months: string) => {
|
305
|
+
return {
|
306
|
+
label: __('DateRange.monthsago', {months}),
|
307
|
+
startDate: (now: moment.Moment) => {
|
308
|
+
return now.startOf('months').add(-months, 'months');
|
309
|
+
},
|
310
|
+
endDate: (now: moment.Moment) => {
|
311
|
+
return now.startOf('month').add(-1, 'days').endOf('day');
|
312
|
+
}
|
313
|
+
};
|
314
|
+
}
|
315
|
+
},
|
316
|
+
{
|
317
|
+
regexp: /^(\d+)monthslater$/,
|
318
|
+
resolve: (__: any, _: string, months: string) => {
|
319
|
+
return {
|
320
|
+
label: __('DateRange.monthslater', {months}),
|
321
|
+
startDate: (now: moment.Moment) => {
|
322
|
+
return now.startOf('month');
|
323
|
+
},
|
324
|
+
endDate: (now: moment.Moment) => {
|
325
|
+
return now.startOf('month').add(months, 'months').endOf('day');
|
326
|
+
}
|
327
|
+
};
|
328
|
+
}
|
329
|
+
},
|
330
|
+
{
|
331
|
+
regexp: /^(\d+)quartersago$/,
|
332
|
+
resolve: (__: any, _: string, quarters: string) => {
|
333
|
+
return {
|
334
|
+
label: __('DateRange.quartersago', {quarters}),
|
335
|
+
startDate: (now: moment.Moment) => {
|
336
|
+
return now.startOf('quarters').add(-quarters, 'quarters');
|
337
|
+
},
|
338
|
+
endDate: (now: moment.Moment) => {
|
339
|
+
return now.startOf('quarter').add(-1, 'days').endOf('day');
|
340
|
+
}
|
341
|
+
};
|
342
|
+
}
|
343
|
+
},
|
344
|
+
{
|
345
|
+
regexp: /^(\d+)quarterslater$/,
|
346
|
+
resolve: (__: any, _: string, quarters: string) => {
|
347
|
+
return {
|
348
|
+
label: __('DateRange.quarterslater', {quarters}),
|
349
|
+
startDate: (now: moment.Moment) => {
|
350
|
+
return now.startOf('quarter');
|
351
|
+
},
|
352
|
+
endDate: (now: moment.Moment) => {
|
353
|
+
return now.startOf('quarter').add(quarters, 'quarters').endOf('day');
|
354
|
+
}
|
355
|
+
};
|
356
|
+
}
|
357
|
+
},
|
358
|
+
{
|
359
|
+
regexp: /^(\d+)yearsago$/,
|
360
|
+
resolve: (__: any, _: string, years: string) => {
|
361
|
+
return {
|
362
|
+
label: __('DateRange.yearsago', {years}),
|
363
|
+
startDate: (now: moment.Moment) => {
|
364
|
+
return now.startOf('years').add(-years, 'years');
|
365
|
+
},
|
366
|
+
endDate: (now: moment.Moment) => {
|
367
|
+
return now.startOf('year').add(-1, 'days').endOf('day');
|
368
|
+
}
|
369
|
+
};
|
370
|
+
}
|
371
|
+
},
|
372
|
+
{
|
373
|
+
regexp: /^(\d+)yearslater$/,
|
374
|
+
resolve: (__: any, _: string, years: string) => {
|
375
|
+
return {
|
376
|
+
label: __('DateRange.yearslater', {years}),
|
377
|
+
startDate: (now: moment.Moment) => {
|
378
|
+
return now.startOf('year');
|
379
|
+
},
|
380
|
+
endDate: (now: moment.Moment) => {
|
381
|
+
return now.startOf('year').add(years, 'years').endOf('day');
|
382
|
+
}
|
383
|
+
};
|
384
|
+
}
|
385
|
+
}
|
386
|
+
];
|
387
|
+
|
206
388
|
export class DateRangePicker extends React.Component<
|
207
389
|
DateRangePickerProps,
|
208
390
|
DateRangePickerState
|
@@ -528,8 +710,20 @@ export class DateRangePicker extends React.Component<
|
|
528
710
|
}
|
529
711
|
let range: PlainObject = {};
|
530
712
|
if (typeof item === 'string') {
|
531
|
-
|
532
|
-
|
713
|
+
if (availableRanges[item]) {
|
714
|
+
range = availableRanges[item];
|
715
|
+
range.key = item;
|
716
|
+
} else {
|
717
|
+
// 通过正则尝试匹配
|
718
|
+
for (let i = 0, len = advancedRanges.length; i < len; i++) {
|
719
|
+
let value = advancedRanges[i];
|
720
|
+
const m = value.regexp.exec(item);
|
721
|
+
if (m) {
|
722
|
+
range = value.resolve.apply(item, [__, ...m]);
|
723
|
+
range.key = item;
|
724
|
+
}
|
725
|
+
}
|
726
|
+
}
|
533
727
|
} else if (
|
534
728
|
(item as ShortCutDateRange).startDate &&
|
535
729
|
(item as ShortCutDateRange).endDate
|
@@ -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`,
|
@@ -21,11 +21,12 @@ import Button from './Button';
|
|
21
21
|
import {value2array, OptionProps, Option} from './Select';
|
22
22
|
import chunk from 'lodash/chunk';
|
23
23
|
import {ClassNamesFn, themeable} from '../theme';
|
24
|
+
import {columnsSplit} from '../utils/columnsSplit';
|
24
25
|
|
25
26
|
interface RadioProps extends OptionProps {
|
26
27
|
id?: string;
|
27
28
|
type: string;
|
28
|
-
optionType?: string
|
29
|
+
optionType?: string;
|
29
30
|
value?: string;
|
30
31
|
className?: string;
|
31
32
|
style?: React.CSSProperties;
|
@@ -34,7 +35,7 @@ interface RadioProps extends OptionProps {
|
|
34
35
|
btnActiveLevel?: string;
|
35
36
|
disabled?: boolean;
|
36
37
|
onChange?: Function;
|
37
|
-
columnsCount: number;
|
38
|
+
columnsCount: number | number[];
|
38
39
|
itemClassName?: string;
|
39
40
|
labelField?: string;
|
40
41
|
labelClassName?: string;
|
@@ -78,7 +79,7 @@ export class Radios extends React.Component<RadioProps, any> {
|
|
78
79
|
}
|
79
80
|
|
80
81
|
renderGroup(option: Option, index: number, valueArray: Array<Option>) {
|
81
|
-
const {classnames: cx, optionType, classPrefix: ns
|
82
|
+
const {classnames: cx, optionType, classPrefix: ns} = this.props;
|
82
83
|
|
83
84
|
return (
|
84
85
|
<div key={index} className={cx('RadiosControl-group', option.className)}>
|
@@ -178,20 +179,8 @@ export class Radios extends React.Component<RadioProps, any> {
|
|
178
179
|
);
|
179
180
|
}
|
180
181
|
|
181
|
-
if (!inline
|
182
|
-
|
183
|
-
let cellClassName = `Grid-col--sm${
|
184
|
-
weight === Math.round(weight) ? weight : ''
|
185
|
-
}`;
|
186
|
-
body = chunk(body, columnsCount).map((group, groupIndex) => (
|
187
|
-
<div className={cx('Grid')} key={groupIndex}>
|
188
|
-
{Array.from({length: columnsCount as number}).map((_, index) => (
|
189
|
-
<div key={index} className={cx(cellClassName)}>
|
190
|
-
{group[index]}
|
191
|
-
</div>
|
192
|
-
))}
|
193
|
-
</div>
|
194
|
-
));
|
182
|
+
if (!inline) {
|
183
|
+
body = columnsSplit(body, cx, columnsCount);
|
195
184
|
}
|
196
185
|
|
197
186
|
return (
|