amis 1.8.0-beta.5 → 1.8.0-beta.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/Schema.d.ts +9 -2
- package/lib/Schema.js.map +1 -1
- package/lib/actions/PageAction.d.ts +32 -0
- package/lib/actions/PageAction.js +72 -0
- package/lib/actions/PageAction.js.map +13 -0
- package/lib/actions/index.d.ts +1 -0
- package/lib/actions/index.js +1 -0
- package/lib/actions/index.js.map +2 -2
- package/lib/components/CalendarMobile.d.ts +84 -84
- package/lib/components/Cascader.d.ts +2 -0
- package/lib/components/Cascader.js +28 -12
- package/lib/components/Cascader.js.map +2 -2
- package/lib/components/Checkbox.js +2 -2
- package/lib/components/Checkbox.js.map +2 -2
- package/lib/components/Collapse.d.ts +20 -20
- package/lib/components/DatePicker.d.ts +84 -84
- package/lib/components/DatePicker.js +5 -5
- package/lib/components/DatePicker.js.map +2 -2
- package/lib/components/Drawer.js +1 -1
- package/lib/components/Drawer.js.map +2 -2
- package/lib/components/ListGroup.d.ts +21 -21
- package/lib/components/Modal.js +1 -1
- package/lib/components/Modal.js.map +2 -2
- package/lib/components/Overlay.d.ts +1 -0
- package/lib/components/Overlay.js +4 -3
- package/lib/components/Overlay.js.map +2 -2
- package/lib/components/PullRefresh.d.ts +86 -0
- package/lib/components/PullRefresh.js +135 -0
- package/lib/components/PullRefresh.js.map +13 -0
- package/lib/components/Spinner.d.ts +200 -107
- package/lib/components/Spinner.js +30 -26
- package/lib/components/Spinner.js.map +2 -2
- package/lib/components/Tooltip.d.ts +4 -0
- package/lib/components/Tooltip.js +6 -4
- package/lib/components/Tooltip.js.map +2 -2
- package/lib/components/TooltipWrapper.d.ts +60 -4
- package/lib/components/TooltipWrapper.js +27 -8
- package/lib/components/TooltipWrapper.js.map +2 -2
- package/lib/components/Transfer.d.ts +84 -84
- package/lib/components/TransferDropDown.d.ts +84 -84
- package/lib/components/Tree.d.ts +87 -85
- package/lib/components/Tree.js +13 -5
- package/lib/components/Tree.js.map +2 -2
- package/lib/components/TreeSelection.d.ts +84 -84
- package/lib/components/calendar/TimeView.d.ts +1 -0
- package/lib/components/calendar/TimeView.js +7 -0
- package/lib/components/calendar/TimeView.js.map +2 -2
- package/lib/components/condition-builder/Expression.d.ts +1 -0
- package/lib/components/condition-builder/Expression.js +4 -4
- package/lib/components/condition-builder/Expression.js.map +2 -2
- package/lib/components/condition-builder/Field.d.ts +1 -0
- package/lib/components/condition-builder/Field.js +3 -2
- package/lib/components/condition-builder/Field.js.map +2 -2
- package/lib/components/condition-builder/Group.d.ts +1 -0
- package/lib/components/condition-builder/Group.js +2 -2
- package/lib/components/condition-builder/Group.js.map +2 -2
- package/lib/components/condition-builder/GroupOrItem.d.ts +1 -0
- package/lib/components/condition-builder/GroupOrItem.js +2 -2
- package/lib/components/condition-builder/GroupOrItem.js.map +2 -2
- package/lib/components/condition-builder/InputSwitch.d.ts +2 -1
- package/lib/components/condition-builder/InputSwitch.js +2 -2
- package/lib/components/condition-builder/InputSwitch.js.map +2 -2
- package/lib/components/condition-builder/Item.d.ts +1 -0
- package/lib/components/condition-builder/Item.js +9 -8
- package/lib/components/condition-builder/Item.js.map +2 -2
- package/lib/components/condition-builder/Value.d.ts +1 -0
- package/lib/components/condition-builder/Value.js +5 -5
- package/lib/components/condition-builder/Value.js.map +2 -2
- package/lib/components/condition-builder/index.d.ts +1 -0
- package/lib/components/condition-builder/index.js +2 -2
- package/lib/components/condition-builder/index.js.map +2 -2
- package/lib/components/formula/Editor.d.ts +87 -85
- package/lib/components/formula/Editor.js +10 -6
- package/lib/components/formula/Editor.js.map +2 -2
- package/lib/components/formula/Picker.js +3 -1
- package/lib/components/formula/Picker.js.map +2 -2
- package/lib/index.js +1 -1
- package/lib/locale/de-DE.js +5 -1
- package/lib/locale/de-DE.js.map +2 -2
- package/lib/locale/en-US.js +5 -1
- package/lib/locale/en-US.js.map +2 -2
- package/lib/locale/zh-CN.js +5 -1
- package/lib/locale/zh-CN.js.map +2 -2
- package/lib/renderers/CRUD.js +1 -1
- package/lib/renderers/CRUD.js.map +2 -2
- package/lib/renderers/Form/Combo.d.ts +2 -1
- package/lib/renderers/Form/Combo.js +51 -14
- package/lib/renderers/Form/Combo.js.map +2 -2
- package/lib/renderers/Form/DiffEditor.d.ts +1 -0
- package/lib/renderers/Form/InputCity.d.ts +84 -84
- package/lib/renderers/Form/InputDate.js +10 -3
- package/lib/renderers/Form/InputDate.js.map +2 -2
- package/lib/renderers/Form/InputDateRange.js +12 -3
- package/lib/renderers/Form/InputDateRange.js.map +2 -2
- package/lib/renderers/Form/InputFile.js +13 -5
- package/lib/renderers/Form/InputFile.js.map +2 -2
- package/lib/renderers/Form/InputImage.js +12 -4
- package/lib/renderers/Form/InputImage.js.map +2 -2
- package/lib/renderers/Form/InputMonthRange.js +5 -1
- package/lib/renderers/Form/InputMonthRange.js.map +2 -2
- package/lib/renderers/Form/InputText.js +8 -4
- package/lib/renderers/Form/InputText.js.map +2 -2
- package/lib/renderers/Form/InputTree.d.ts +5 -0
- package/lib/renderers/Form/InputTree.js +51 -2
- package/lib/renderers/Form/InputTree.js.map +2 -2
- package/lib/renderers/Form/Item.d.ts +68 -70
- package/lib/renderers/Form/Item.js.map +2 -2
- package/lib/renderers/Form/NestedSelect.d.ts +4 -0
- package/lib/renderers/Form/NestedSelect.js +14 -5
- package/lib/renderers/Form/NestedSelect.js.map +2 -2
- package/lib/renderers/Form/Options.js +61 -27
- package/lib/renderers/Form/Options.js.map +2 -2
- package/lib/renderers/Form/Select.js +4 -2
- package/lib/renderers/Form/Select.js.map +2 -2
- package/lib/renderers/Form/TreeSelect.d.ts +11 -2
- package/lib/renderers/Form/TreeSelect.js +56 -10
- package/lib/renderers/Form/TreeSelect.js.map +2 -2
- package/lib/renderers/Form/wrapControl.js +3 -3
- package/lib/renderers/Form/wrapControl.js.map +2 -2
- package/lib/renderers/Nav.d.ts +82 -67
- package/lib/renderers/Nav.js +47 -11
- package/lib/renderers/Nav.js.map +2 -2
- package/lib/renderers/Page.d.ts +20 -0
- package/lib/renderers/Page.js +51 -14
- package/lib/renderers/Page.js.map +2 -2
- package/lib/renderers/Service.d.ts +2 -0
- package/lib/renderers/Service.js +52 -20
- package/lib/renderers/Service.js.map +2 -2
- package/lib/renderers/Spinner.d.ts +58 -2
- package/lib/renderers/Spinner.js +8 -1
- package/lib/renderers/Spinner.js.map +2 -2
- package/lib/renderers/Table/ColumnToggler.d.ts +4 -0
- package/lib/renderers/Table/ColumnToggler.js +11 -6
- package/lib/renderers/Table/ColumnToggler.js.map +2 -2
- package/lib/renderers/Table/TableCell.js +27 -1
- package/lib/renderers/Table/TableCell.js.map +2 -2
- package/lib/renderers/Table/index.d.ts +1 -0
- package/lib/renderers/Table/index.js +19 -11
- package/lib/renderers/Table/index.js.map +2 -2
- package/lib/renderers/TooltipWrapper.d.ts +31 -6
- package/lib/renderers/TooltipWrapper.js +18 -8
- package/lib/renderers/TooltipWrapper.js.map +2 -2
- package/lib/renderers/Wizard.js +23 -14
- package/lib/renderers/Wizard.js.map +2 -2
- package/lib/store/crud.js +23 -13
- package/lib/store/crud.js.map +2 -2
- package/lib/themes/ang-ie11.css +313 -100
- package/lib/themes/ang.css +322 -103
- package/lib/themes/ang.css.map +1 -1
- package/lib/themes/antd-ie11.css +429 -216
- package/lib/themes/antd.css +323 -104
- package/lib/themes/antd.css.map +1 -1
- package/lib/themes/cxd-ie11.css +424 -211
- package/lib/themes/cxd.css +324 -105
- package/lib/themes/cxd.css.map +1 -1
- package/lib/themes/dark-ie11.css +313 -100
- package/lib/themes/dark.css +322 -103
- package/lib/themes/dark.css.map +1 -1
- package/lib/themes/default-ie11.css +424 -211
- package/lib/themes/default.css +324 -105
- package/lib/themes/default.css.map +1 -1
- package/lib/types.d.ts +3 -1
- package/lib/types.js.map +1 -1
- package/lib/utils/ColorScale.d.ts +19 -0
- package/lib/utils/ColorScale.js +104 -0
- package/lib/utils/ColorScale.js.map +13 -0
- package/lib/utils/api.js +20 -4
- package/lib/utils/api.js.map +2 -2
- package/lib/utils/dom.d.ts +1 -1
- package/lib/utils/dom.js +7 -5
- package/lib/utils/dom.js.map +2 -2
- package/package.json +3 -2
- package/schema.json +29645 -29137
- package/scss/_properties.scss +33 -15
- package/scss/components/_column-toggler.scss +21 -11
- package/scss/components/_formula.scss +1 -1
- package/scss/components/_nav.scss +51 -6
- package/scss/components/_pull-refresh.scss +25 -0
- package/scss/components/_spinner.scss +134 -56
- package/scss/components/_tooltip.scss +4 -9
- package/scss/components/form/_checks.scss +1 -0
- package/scss/components/form/_combo.scss +13 -1
- package/scss/components/form/_date-range.scss +11 -2
- package/scss/components/form/_date.scss +11 -0
- package/scss/components/form/_file.scss +4 -0
- package/scss/components/form/_form.scss +15 -8
- package/scss/components/form/_transfer.scss +3 -2
- package/scss/themes/_antd-variables.scss +1 -1
- package/scss/themes/_common.scss +1 -0
- package/scss/themes/_cxd-variables.scss +2 -2
- package/sdk/ang-ie11.css +286 -80
- package/sdk/ang.css +294 -82
- package/sdk/antd-ie11.css +402 -196
- package/sdk/antd.css +295 -83
- 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 +397 -191
- package/sdk/cxd.css +296 -84
- package/sdk/dark-ie11.css +286 -80
- package/sdk/dark.css +294 -82
- package/sdk/exceljs.js +1 -1
- package/sdk/locale/de-DE.js +5 -1
- package/sdk/markdown.js +69 -69
- package/sdk/papaparse.js +1 -1
- package/sdk/renderers/Form/CityDB.js +1 -1
- package/sdk/rest.js +17 -17
- package/sdk/rich-text.js +62 -62
- package/sdk/sdk-ie11.css +397 -191
- package/sdk/sdk.css +296 -84
- package/sdk/sdk.js +1300 -1260
- package/sdk/thirds/hls.js/hls.js +1 -1
- package/sdk/thirds/mpegts.js/mpegts.js +1 -1
- package/sdk/tinymce.js +57 -57
- package/src/Schema.ts +10 -0
- package/src/actions/PageAction.ts +62 -0
- package/src/actions/index.ts +1 -0
- package/src/components/Cascader.tsx +37 -11
- package/src/components/Checkbox.tsx +1 -1
- package/src/components/DatePicker.tsx +7 -5
- package/src/components/Drawer.tsx +1 -0
- package/src/components/Modal.tsx +1 -0
- package/src/components/Overlay.tsx +6 -3
- package/src/components/PullRefresh.tsx +197 -0
- package/src/components/Spinner.tsx +77 -42
- package/src/components/Tooltip.tsx +12 -3
- package/src/components/TooltipWrapper.tsx +120 -33
- package/src/components/Tree.tsx +19 -5
- package/src/components/calendar/TimeView.tsx +12 -0
- package/src/components/condition-builder/Expression.tsx +6 -1
- package/src/components/condition-builder/Field.tsx +5 -1
- package/src/components/condition-builder/Group.tsx +4 -1
- package/src/components/condition-builder/GroupOrItem.tsx +4 -1
- package/src/components/condition-builder/InputSwitch.tsx +4 -1
- package/src/components/condition-builder/Item.tsx +28 -4
- package/src/components/condition-builder/Value.tsx +7 -1
- package/src/components/condition-builder/index.tsx +4 -2
- package/src/components/formula/Editor.tsx +20 -15
- package/src/components/formula/Picker.tsx +9 -5
- package/src/locale/de-DE.ts +5 -1
- package/src/locale/en-US.ts +5 -1
- package/src/locale/zh-CN.ts +5 -1
- package/src/renderers/CRUD.tsx +1 -1
- package/src/renderers/Form/Combo.tsx +102 -46
- package/src/renderers/Form/InputDate.tsx +18 -4
- package/src/renderers/Form/InputDateRange.tsx +19 -2
- package/src/renderers/Form/InputFile.tsx +16 -4
- package/src/renderers/Form/InputImage.tsx +15 -3
- package/src/renderers/Form/InputMonthRange.tsx +7 -1
- package/src/renderers/Form/InputText.tsx +14 -2
- package/src/renderers/Form/InputTree.tsx +40 -2
- package/src/renderers/Form/Item.tsx +6 -0
- package/src/renderers/Form/NestedSelect.tsx +23 -4
- package/src/renderers/Form/Options.tsx +26 -7
- package/src/renderers/Form/Select.tsx +5 -3
- package/src/renderers/Form/TreeSelect.tsx +47 -9
- package/src/renderers/Form/wrapControl.tsx +2 -2
- package/src/renderers/Nav.tsx +230 -32
- package/src/renderers/Page.tsx +89 -33
- package/src/renderers/Service.tsx +62 -27
- package/src/renderers/Spinner.tsx +85 -3
- package/src/renderers/Table/ColumnToggler.tsx +36 -11
- package/src/renderers/Table/TableCell.tsx +39 -1
- package/src/renderers/Table/index.tsx +34 -21
- package/src/renderers/TooltipWrapper.tsx +64 -28
- package/src/renderers/Wizard.tsx +36 -25
- package/src/store/crud.ts +10 -0
- package/src/types.ts +4 -0
- package/src/utils/ColorScale.ts +138 -0
- package/src/utils/api.ts +26 -4
- package/src/utils/dom.tsx +7 -6
package/src/Schema.ts
CHANGED
@@ -58,6 +58,7 @@ import {PaginationSchema} from './renderers/Pagination';
|
|
58
58
|
import {AnchorNavSchema} from './renderers/AnchorNav';
|
59
59
|
import {AvatarSchema} from './renderers/Avatar';
|
60
60
|
import {StepsSchema} from './renderers/Steps';
|
61
|
+
import {SpinnerSchema} from './renderers/Spinner';
|
61
62
|
import {TimelineSchema} from './renderers/Timeline';
|
62
63
|
import {ArrayControlSchema} from './renderers/Form/InputArray';
|
63
64
|
import {ButtonGroupControlSchema} from './renderers/Form/ButtonGroupSelect';
|
@@ -150,6 +151,7 @@ export type SchemaType =
|
|
150
151
|
| 'month'
|
151
152
|
| 'static-month' // 这个几个跟表单项同名,再form下面用必须带前缀 static-
|
152
153
|
| 'dialog'
|
154
|
+
| 'spinner'
|
153
155
|
| 'divider'
|
154
156
|
| 'dropdown-button'
|
155
157
|
| 'drawer'
|
@@ -384,6 +386,7 @@ export type SchemaObject =
|
|
384
386
|
| ServiceSchema
|
385
387
|
| SparkLineSchema
|
386
388
|
| StatusSchema
|
389
|
+
| SpinnerSchema
|
387
390
|
| TableSchema
|
388
391
|
| TabsSchema
|
389
392
|
| TasksSchema
|
@@ -596,6 +599,13 @@ export interface SchemaApiObject {
|
|
596
599
|
*/
|
597
600
|
cache?: number;
|
598
601
|
|
602
|
+
/**
|
603
|
+
* 强制将数据附加在 query,默认只有 api 地址中没有用变量的时候 crud 查询接口才会
|
604
|
+
* 自动附加数据到 query 部分,如果想强制附加请设置这个属性。
|
605
|
+
* 对于那种临时加了个变量但是又不想全部参数写一遍的时候配置很有用。
|
606
|
+
*/
|
607
|
+
forceAppendDataToQuery?: boolean;
|
608
|
+
|
599
609
|
/**
|
600
610
|
* qs 配置项
|
601
611
|
*/
|
@@ -0,0 +1,62 @@
|
|
1
|
+
import {RendererEvent} from '../utils/renderer-event';
|
2
|
+
import {
|
3
|
+
Action,
|
4
|
+
ListenerAction,
|
5
|
+
ListenerContext,
|
6
|
+
registerAction
|
7
|
+
} from './Action';
|
8
|
+
|
9
|
+
/**
|
10
|
+
* 返回上个页面
|
11
|
+
*
|
12
|
+
* @export
|
13
|
+
* @class PageGoBackAction
|
14
|
+
* @implements {Action}
|
15
|
+
*/
|
16
|
+
export class PageGoBackAction implements Action {
|
17
|
+
async run(
|
18
|
+
action: ListenerAction,
|
19
|
+
renderer: ListenerContext,
|
20
|
+
event: RendererEvent<any>
|
21
|
+
) {
|
22
|
+
window.history.back();
|
23
|
+
}
|
24
|
+
}
|
25
|
+
|
26
|
+
/**
|
27
|
+
* 到指定页面
|
28
|
+
*
|
29
|
+
* @export
|
30
|
+
* @class PageGoAction
|
31
|
+
* @implements {Action}
|
32
|
+
*/
|
33
|
+
export class PageGoAction implements Action {
|
34
|
+
async run(
|
35
|
+
action: ListenerAction,
|
36
|
+
renderer: ListenerContext,
|
37
|
+
event: RendererEvent<any>
|
38
|
+
) {
|
39
|
+
window.history.go(action.delta || 0);
|
40
|
+
}
|
41
|
+
}
|
42
|
+
|
43
|
+
/**
|
44
|
+
* 浏览器刷新
|
45
|
+
*
|
46
|
+
* @export
|
47
|
+
* @class PageRefreshAction
|
48
|
+
* @implements {Action}
|
49
|
+
*/
|
50
|
+
export class PageRefreshAction implements Action {
|
51
|
+
async run(
|
52
|
+
action: ListenerAction,
|
53
|
+
renderer: ListenerContext,
|
54
|
+
event: RendererEvent<any>
|
55
|
+
) {
|
56
|
+
window.location.reload();
|
57
|
+
}
|
58
|
+
}
|
59
|
+
|
60
|
+
registerAction('goBack', new PageGoBackAction());
|
61
|
+
registerAction('refresh', new PageRefreshAction());
|
62
|
+
registerAction('goPage', new PageGoAction());
|
package/src/actions/index.ts
CHANGED
@@ -48,6 +48,8 @@ export interface CascaderState {
|
|
48
48
|
tabs: Array<{
|
49
49
|
options: Options;
|
50
50
|
}>;
|
51
|
+
// 用于在只选择子节点模式的时候禁用按钮
|
52
|
+
disableConfirm: boolean;
|
51
53
|
}
|
52
54
|
|
53
55
|
export class Cascader extends React.Component<CascaderProps, CascaderState> {
|
@@ -66,7 +68,8 @@ export class Cascader extends React.Component<CascaderProps, CascaderState> {
|
|
66
68
|
{
|
67
69
|
options: this.props.options.slice() || []
|
68
70
|
}
|
69
|
-
]
|
71
|
+
],
|
72
|
+
disableConfirm: false
|
70
73
|
};
|
71
74
|
}
|
72
75
|
componentDidMount() {
|
@@ -288,7 +291,7 @@ export class Cascader extends React.Component<CascaderProps, CascaderState> {
|
|
288
291
|
|
289
292
|
@autobind
|
290
293
|
onSelect(option: CascaderOption, tabIndex: number) {
|
291
|
-
const {multiple, valueField = 'value', cascade} = this.props;
|
294
|
+
const {multiple, valueField = 'value', cascade, onlyLeaf} = this.props;
|
292
295
|
|
293
296
|
let tabs = this.state.tabs.slice();
|
294
297
|
let {activeTab} = this.state;
|
@@ -364,10 +367,15 @@ export class Cascader extends React.Component<CascaderProps, CascaderState> {
|
|
364
367
|
}
|
365
368
|
activeTab += 1;
|
366
369
|
}
|
370
|
+
let disableConfirm = false;
|
371
|
+
if (onlyLeaf && selectedOptions.length && selectedOptions[0].children) {
|
372
|
+
disableConfirm = true;
|
373
|
+
}
|
367
374
|
this.setState({
|
368
375
|
tabs,
|
369
376
|
activeTab,
|
370
|
-
selectedOptions
|
377
|
+
selectedOptions,
|
378
|
+
disableConfirm
|
371
379
|
});
|
372
380
|
}
|
373
381
|
|
@@ -428,23 +436,39 @@ export class Cascader extends React.Component<CascaderProps, CascaderState> {
|
|
428
436
|
|
429
437
|
@autobind
|
430
438
|
confirm() {
|
431
|
-
const {
|
432
|
-
|
433
|
-
|
434
|
-
|
435
|
-
|
439
|
+
const {
|
440
|
+
onChange,
|
441
|
+
joinValues,
|
442
|
+
delimiter,
|
443
|
+
extractValue,
|
444
|
+
valueField,
|
445
|
+
onClose,
|
446
|
+
onlyLeaf
|
447
|
+
} = this.props;
|
448
|
+
const selectedOptions = this.getSelectedOptions();
|
449
|
+
if (onlyLeaf && selectedOptions.length && selectedOptions[0].children) {
|
450
|
+
return;
|
451
|
+
}
|
436
452
|
onChange(
|
437
453
|
joinValues
|
438
|
-
?
|
454
|
+
? selectedOptions
|
439
455
|
.map(item => item[valueField as string])
|
440
456
|
.join(delimiter)
|
441
457
|
: extractValue
|
442
|
-
?
|
443
|
-
:
|
458
|
+
? selectedOptions.map(item => item[valueField as string])
|
459
|
+
: selectedOptions
|
444
460
|
);
|
445
461
|
onClose && onClose();
|
446
462
|
}
|
447
463
|
|
464
|
+
@autobind
|
465
|
+
getSelectedOptions() {
|
466
|
+
return uniqBy(
|
467
|
+
this.getSubmitOptions(this.state.selectedOptions),
|
468
|
+
this.props.valueField
|
469
|
+
);
|
470
|
+
}
|
471
|
+
|
448
472
|
@autobind
|
449
473
|
renderOption(option: CascaderOption, tabIndex: number) {
|
450
474
|
const {
|
@@ -534,6 +558,7 @@ export class Cascader extends React.Component<CascaderProps, CascaderState> {
|
|
534
558
|
classnames: cx,
|
535
559
|
className,
|
536
560
|
onClose,
|
561
|
+
valueField,
|
537
562
|
translate: __
|
538
563
|
} = this.props;
|
539
564
|
|
@@ -551,6 +576,7 @@ export class Cascader extends React.Component<CascaderProps, CascaderState> {
|
|
551
576
|
className={cx(`Cascader-btnConfirm`)}
|
552
577
|
level="text"
|
553
578
|
onClick={this.confirm}
|
579
|
+
disabled={this.state.disableConfirm}
|
554
580
|
>
|
555
581
|
{__('confirm')}
|
556
582
|
</Button>
|
@@ -79,7 +79,7 @@ export class Checkbox extends React.Component<CheckboxProps, any> {
|
|
79
79
|
<label
|
80
80
|
className={cx(`Checkbox Checkbox--${type}`, className, {
|
81
81
|
'Checkbox--full': !partial,
|
82
|
-
'Checkbox--partial': partial
|
82
|
+
// 'Checkbox--partial': partial
|
83
83
|
[`Checkbox--${size}`]: size,
|
84
84
|
'Checkbox--button': optionType === 'button',
|
85
85
|
'Checkbox--button--checked': optionType === 'button' && checked,
|
@@ -370,18 +370,20 @@ export class DatePicker extends React.Component<DateProps, DatePickerState> {
|
|
370
370
|
const newState: any = {
|
371
371
|
value: normalizeValue(props.value, props.format)
|
372
372
|
};
|
373
|
-
|
373
|
+
|
374
374
|
if (
|
375
|
-
typeof prevValue === '
|
376
|
-
(prevValue
|
377
|
-
prevValue.startsWith('
|
378
|
-
|
375
|
+
typeof prevValue === 'undefined' || // initApi 的情况
|
376
|
+
(typeof prevValue === 'string' && // 公式的情况
|
377
|
+
(prevValue.startsWith('+') ||
|
378
|
+
prevValue.startsWith('-') ||
|
379
|
+
prevValue.startsWith('$')))
|
379
380
|
) {
|
380
381
|
newState.inputValue =
|
381
382
|
normalizeValue(this.props.value, this.props.format)?.format(
|
382
383
|
this.props.inputFormat
|
383
384
|
) || '';
|
384
385
|
}
|
386
|
+
|
385
387
|
this.setState(newState);
|
386
388
|
}
|
387
389
|
}
|
package/src/components/Modal.tsx
CHANGED
@@ -97,7 +97,8 @@ class Position extends React.Component<any, any> {
|
|
97
97
|
overlay,
|
98
98
|
target,
|
99
99
|
container,
|
100
|
-
this.props.containerPadding
|
100
|
+
this.props.containerPadding,
|
101
|
+
this.props.offset
|
101
102
|
)
|
102
103
|
);
|
103
104
|
}
|
@@ -173,7 +174,7 @@ interface OverlayProps {
|
|
173
174
|
container?: React.ReactNode | Function;
|
174
175
|
target?: React.ReactNode | Function;
|
175
176
|
watchTargetSizeChange?: boolean;
|
176
|
-
|
177
|
+
offset?: [number, number];
|
177
178
|
onEnter?(node: HTMLElement): any;
|
178
179
|
onEntering?(node: HTMLElement): any;
|
179
180
|
onEntered?(node: HTMLElement): any;
|
@@ -238,6 +239,7 @@ export default class Overlay extends React.Component<
|
|
238
239
|
children,
|
239
240
|
watchTargetSizeChange,
|
240
241
|
transition: Transition,
|
242
|
+
offset,
|
241
243
|
...props
|
242
244
|
} = this.props;
|
243
245
|
|
@@ -259,7 +261,8 @@ export default class Overlay extends React.Component<
|
|
259
261
|
containerPadding,
|
260
262
|
target,
|
261
263
|
placement,
|
262
|
-
shouldUpdatePosition
|
264
|
+
shouldUpdatePosition,
|
265
|
+
offset
|
263
266
|
}}
|
264
267
|
ref={this.positionRef}
|
265
268
|
>
|
@@ -0,0 +1,197 @@
|
|
1
|
+
/**
|
2
|
+
* @file PullRefresh.tsx
|
3
|
+
* @description 下拉刷新
|
4
|
+
* @author hongyang03
|
5
|
+
*/
|
6
|
+
|
7
|
+
import React, {forwardRef, useEffect} from 'react';
|
8
|
+
import {ClassNamesFn, themeable} from '../theme';
|
9
|
+
import {useSetState} from '../hooks';
|
10
|
+
import useTouch from '../hooks/use-touch';
|
11
|
+
import {Icon} from './icons';
|
12
|
+
import {TranslateFn} from '../locale';
|
13
|
+
|
14
|
+
export interface PullRefreshProps {
|
15
|
+
classnames: ClassNamesFn;
|
16
|
+
classPrefix: string;
|
17
|
+
translate: TranslateFn;
|
18
|
+
disabled?: boolean;
|
19
|
+
pullingText?: string;
|
20
|
+
loosingText?: string;
|
21
|
+
loadingText?: string;
|
22
|
+
successText?: string;
|
23
|
+
onRefresh?: () => void;
|
24
|
+
loading?: boolean;
|
25
|
+
successDuration?: number;
|
26
|
+
loadingDuration?: number;
|
27
|
+
}
|
28
|
+
|
29
|
+
type statusText = 'normal' | 'pulling' | 'loosing' | 'success' | 'loading';
|
30
|
+
|
31
|
+
export interface PullRefreshState {
|
32
|
+
status: statusText;
|
33
|
+
offsetY: number;
|
34
|
+
}
|
35
|
+
|
36
|
+
const defaultProps = {
|
37
|
+
successDuration: 0,
|
38
|
+
loadingDuration: 0
|
39
|
+
};
|
40
|
+
|
41
|
+
const defaultHeaderHeight = 28;
|
42
|
+
|
43
|
+
const PullRefresh = forwardRef<{}, PullRefreshProps>((props, ref) => {
|
44
|
+
const {
|
45
|
+
classnames: cx,
|
46
|
+
translate: __,
|
47
|
+
children,
|
48
|
+
successDuration,
|
49
|
+
loadingDuration
|
50
|
+
} = props;
|
51
|
+
|
52
|
+
const refreshText = {
|
53
|
+
pullingText: __('pullRefresh.pullingText'),
|
54
|
+
loosingText: __('pullRefresh.loosingText'),
|
55
|
+
loadingText: __('pullRefresh.loadingText'),
|
56
|
+
successText: __('pullRefresh.successText')
|
57
|
+
};
|
58
|
+
|
59
|
+
const touch = useTouch();
|
60
|
+
|
61
|
+
useEffect(() => {
|
62
|
+
if (props.loading === false) {
|
63
|
+
loadSuccess();
|
64
|
+
}
|
65
|
+
}, [props.loading]);
|
66
|
+
|
67
|
+
const [state, updateState] = useSetState({
|
68
|
+
status: 'normal',
|
69
|
+
offsetY: 0
|
70
|
+
} as PullRefreshState);
|
71
|
+
|
72
|
+
const isTouchable = () => {
|
73
|
+
return (
|
74
|
+
!props.disabled &&
|
75
|
+
state.status !== 'loading' &&
|
76
|
+
state.status !== 'success'
|
77
|
+
);
|
78
|
+
};
|
79
|
+
|
80
|
+
const ease = (distance: number) => {
|
81
|
+
const pullDistance = defaultHeaderHeight;
|
82
|
+
|
83
|
+
if (distance > pullDistance) {
|
84
|
+
if (distance < pullDistance * 2) {
|
85
|
+
distance = pullDistance + (distance - pullDistance) / 2;
|
86
|
+
} else {
|
87
|
+
distance = pullDistance * 1.5 + (distance - pullDistance * 2) / 4;
|
88
|
+
}
|
89
|
+
}
|
90
|
+
|
91
|
+
return Math.round(distance);
|
92
|
+
};
|
93
|
+
|
94
|
+
const setStatus = (distance: number, isLoading?: boolean) => {
|
95
|
+
const pullDistance = defaultHeaderHeight;
|
96
|
+
let status: statusText = 'normal';
|
97
|
+
|
98
|
+
if (isLoading) {
|
99
|
+
status = 'loading';
|
100
|
+
} else if (distance === 0) {
|
101
|
+
status = 'normal';
|
102
|
+
} else if (distance < pullDistance) {
|
103
|
+
status = 'pulling';
|
104
|
+
} else {
|
105
|
+
status = 'loosing';
|
106
|
+
}
|
107
|
+
|
108
|
+
updateState({offsetY: distance, status});
|
109
|
+
};
|
110
|
+
|
111
|
+
const loadSuccess = () => {
|
112
|
+
if (!successDuration) {
|
113
|
+
setStatus(0);
|
114
|
+
return;
|
115
|
+
}
|
116
|
+
updateState({status: 'success'});
|
117
|
+
|
118
|
+
setTimeout(() => {
|
119
|
+
setStatus(0);
|
120
|
+
}, successDuration);
|
121
|
+
};
|
122
|
+
|
123
|
+
const onTouchStart = (event: any) => {
|
124
|
+
event.stopPropagation();
|
125
|
+
|
126
|
+
if (isTouchable() && state.offsetY === 0) {
|
127
|
+
touch.start(event);
|
128
|
+
updateState({});
|
129
|
+
}
|
130
|
+
};
|
131
|
+
|
132
|
+
const onTouchMove = (event: any) => {
|
133
|
+
event.stopPropagation();
|
134
|
+
|
135
|
+
if (isTouchable()) {
|
136
|
+
touch.move(event);
|
137
|
+
updateState({});
|
138
|
+
if (touch.isVertical() && touch.deltaY > 0) {
|
139
|
+
setStatus(ease(touch.deltaY));
|
140
|
+
}
|
141
|
+
}
|
142
|
+
return false;
|
143
|
+
};
|
144
|
+
|
145
|
+
const onTouchEnd = (event: any) => {
|
146
|
+
event.stopPropagation();
|
147
|
+
|
148
|
+
if (isTouchable() && state.offsetY > 0) {
|
149
|
+
if (state.status === 'loosing') {
|
150
|
+
if (loadingDuration) {
|
151
|
+
setStatus(defaultHeaderHeight, true);
|
152
|
+
} else {
|
153
|
+
setStatus(0);
|
154
|
+
}
|
155
|
+
props.onRefresh && props.onRefresh();
|
156
|
+
} else {
|
157
|
+
setStatus(0);
|
158
|
+
}
|
159
|
+
}
|
160
|
+
};
|
161
|
+
|
162
|
+
const transformStyle = {
|
163
|
+
transform: `translate3d(0, ${state.offsetY}px, 0)`,
|
164
|
+
touchAction: 'none'
|
165
|
+
};
|
166
|
+
|
167
|
+
const getStatusText = (status: statusText) => {
|
168
|
+
if (status === 'normal') {
|
169
|
+
return '';
|
170
|
+
}
|
171
|
+
return props[`${status}Text`] || refreshText[`${status}Text`];
|
172
|
+
};
|
173
|
+
|
174
|
+
return (
|
175
|
+
<div
|
176
|
+
className={cx('PullRefresh')}
|
177
|
+
onTouchStart={onTouchStart}
|
178
|
+
onTouchMove={onTouchMove}
|
179
|
+
onTouchEnd={onTouchEnd}
|
180
|
+
onTouchCancel={onTouchEnd}
|
181
|
+
>
|
182
|
+
<div className={cx('PullRefresh-wrap')} style={transformStyle}>
|
183
|
+
<div className={cx('PullRefresh-header')}>
|
184
|
+
{state.status === 'loading' && (
|
185
|
+
<Icon icon="loading-outline" className="icon loading-icon" />
|
186
|
+
)}
|
187
|
+
{getStatusText(state.status)}
|
188
|
+
</div>
|
189
|
+
{children}
|
190
|
+
</div>
|
191
|
+
</div>
|
192
|
+
);
|
193
|
+
});
|
194
|
+
|
195
|
+
PullRefresh.defaultProps = defaultProps;
|
196
|
+
|
197
|
+
export default themeable(PullRefresh);
|
@@ -7,77 +7,112 @@
|
|
7
7
|
|
8
8
|
import React from 'react';
|
9
9
|
import {themeable, ThemeProps} from '../theme';
|
10
|
-
import Transition, {ENTERED
|
11
|
-
import {Icon} from './icons';
|
10
|
+
import Transition, {ENTERED} from 'react-transition-group/Transition';
|
11
|
+
import {Icon, hasIcon} from './icons';
|
12
|
+
import {generateIcon} from '../utils/icon';
|
12
13
|
|
13
14
|
const fadeStyles: {
|
14
15
|
[propName: string]: string;
|
15
16
|
} = {
|
16
|
-
[ENTERING]: 'in',
|
17
17
|
[ENTERED]: 'in'
|
18
18
|
};
|
19
19
|
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
20
|
+
// Spinner Props
|
21
|
+
export interface SpinnerProps extends ThemeProps {
|
22
|
+
show: boolean; // 控制Spinner显示与隐藏
|
23
|
+
className?: string; // 自定义最外层元素class
|
24
|
+
spinnerClassName?: string; // spin图标位置包裹元素的自定义class
|
25
|
+
/**
|
26
|
+
* @deprecated 已废弃,没有作用
|
27
|
+
*/
|
28
|
+
mode?: string;
|
29
|
+
size?: 'sm' | 'lg' | ''; // spinner Icon 大小
|
30
|
+
icon?: string | React.ReactNode; // 自定义icon
|
31
|
+
tip?: string; // spinner文案
|
32
|
+
tipPlacement?: 'top' | 'right' | 'bottom' | 'left'; // spinner文案位置
|
33
|
+
delay?: number; // 延迟显示
|
34
|
+
overlay?: boolean; // 是否显示遮罩层,有children属性才生效
|
27
35
|
}
|
28
36
|
|
29
|
-
export class Spinner extends React.Component<SpinnerProps
|
37
|
+
export class Spinner extends React.Component<SpinnerProps> {
|
30
38
|
static defaultProps = {
|
31
|
-
|
39
|
+
show: true,
|
40
|
+
className: '',
|
32
41
|
spinnerClassName: '',
|
33
|
-
mode: '',
|
34
42
|
size: '' as '',
|
35
|
-
|
43
|
+
icon: '',
|
44
|
+
tip: '',
|
45
|
+
tipPlacement: 'bottom' as 'bottom',
|
46
|
+
delay: 0,
|
47
|
+
overlay: false
|
36
48
|
};
|
37
49
|
|
38
|
-
div: React.RefObject<HTMLDivElement> = React.createRef();
|
39
|
-
overlay: React.RefObject<HTMLDivElement> = React.createRef();
|
40
|
-
|
41
50
|
render() {
|
42
51
|
const {
|
43
|
-
show,
|
44
52
|
classnames: cx,
|
53
|
+
show,
|
54
|
+
className,
|
45
55
|
spinnerClassName,
|
46
|
-
|
47
|
-
size,
|
56
|
+
size = '',
|
48
57
|
overlay,
|
49
|
-
|
58
|
+
delay,
|
59
|
+
icon,
|
60
|
+
tip,
|
61
|
+
tipPlacement = ''
|
50
62
|
} = this.props;
|
63
|
+
const isCustomIcon = icon && React.isValidElement(icon);
|
64
|
+
const timeout = {enter: delay, exit: 0};
|
65
|
+
|
51
66
|
return (
|
52
|
-
<Transition mountOnEnter unmountOnExit in={show} timeout={
|
67
|
+
<Transition mountOnEnter unmountOnExit in={show} timeout={timeout}>
|
53
68
|
{(status: string) => {
|
54
|
-
if (status === ENTERING) {
|
55
|
-
// force reflow
|
56
|
-
// 由于从 mount 进来到加上 in 这个 class 估计是时间太短,上次的样式还没应用进去,所以这里强制reflow一把。
|
57
|
-
// 否则看不到动画。
|
58
|
-
// this.div.current!.offsetWidth;
|
59
|
-
this.overlay.current && this.overlay.current.offsetWidth;
|
60
|
-
}
|
61
|
-
|
62
69
|
return (
|
63
70
|
<>
|
71
|
+
{/* 遮罩层 */}
|
64
72
|
{overlay ? (
|
65
|
-
<div
|
66
|
-
ref={this.overlay}
|
67
|
-
className={cx(`Spinner-overlay`, fadeStyles[status])}
|
68
|
-
/>
|
73
|
+
<div className={cx(`Spinner-overlay`, fadeStyles[status])} />
|
69
74
|
) : null}
|
70
75
|
|
76
|
+
{/* spinner图标和文案 */}
|
71
77
|
<div
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
78
|
+
className={cx(
|
79
|
+
`Spinner`,
|
80
|
+
tip && {
|
81
|
+
[`Spinner-tip--${tipPlacement}`]: [
|
82
|
+
'top',
|
83
|
+
'right',
|
84
|
+
'bottom',
|
85
|
+
'left'
|
86
|
+
].includes(tipPlacement)
|
87
|
+
},
|
88
|
+
{[`Spinner--overlay`]: overlay},
|
89
|
+
fadeStyles[status],
|
90
|
+
className
|
91
|
+
)}
|
79
92
|
>
|
80
|
-
|
93
|
+
<div
|
94
|
+
className={cx(
|
95
|
+
`Spinner-icon`,
|
96
|
+
{
|
97
|
+
[`Spinner-icon--${size}`]: ['lg', 'sm'].includes(size),
|
98
|
+
[`Spinner-icon--default`]: !icon,
|
99
|
+
[`Spinner-icon--simple`]: !isCustomIcon && icon,
|
100
|
+
[`Spinner-icon--custom`]: isCustomIcon
|
101
|
+
},
|
102
|
+
spinnerClassName
|
103
|
+
)}
|
104
|
+
>
|
105
|
+
{icon ? (
|
106
|
+
isCustomIcon ? (
|
107
|
+
icon
|
108
|
+
) : hasIcon(icon as string) ? (
|
109
|
+
<Icon icon={icon} className="icon" />
|
110
|
+
) : (
|
111
|
+
generateIcon(cx, icon as string, 'icon')
|
112
|
+
)
|
113
|
+
) : null}
|
114
|
+
</div>
|
115
|
+
{tip ? <span className={cx(`Spinner-tip`)}>{tip}</span> : ''}
|
81
116
|
</div>
|
82
117
|
</>
|
83
118
|
);
|