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/renderers/Nav.tsx
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
import React from 'react';
|
2
2
|
import {findDOMNode} from 'react-dom';
|
3
|
+
import Overflow from 'rc-overflow';
|
3
4
|
import {Renderer, RendererEnv, RendererProps} from '../factory';
|
4
5
|
import getExprProperties from '../utils/filter-schema';
|
5
6
|
import {filter, evalExpression} from '../utils/tpl';
|
@@ -7,32 +8,36 @@ import {
|
|
7
8
|
guid,
|
8
9
|
autobind,
|
9
10
|
createObject,
|
10
|
-
findTree,
|
11
11
|
isUnfolded,
|
12
12
|
mapTree,
|
13
13
|
someTree,
|
14
14
|
spliceTree,
|
15
|
-
findTreeIndex
|
15
|
+
findTreeIndex,
|
16
|
+
isObject
|
16
17
|
} from '../utils/helper';
|
17
|
-
import {
|
18
|
+
import {generateIcon} from '../utils/icon';
|
19
|
+
import {isEffectiveApi} from '../utils/api';
|
18
20
|
import {themeable, ThemeProps} from '../theme';
|
19
|
-
import {Icon} from '../components/icons';
|
21
|
+
import {Icon, getIcon} from '../components/icons';
|
22
|
+
import {Badge, BadgeSchema} from '../components/Badge';
|
20
23
|
import {
|
24
|
+
RemoteOptionsProps,
|
25
|
+
withRemoteConfig
|
26
|
+
} from '../components/WithRemoteConfig';
|
27
|
+
import Spinner from '../components/Spinner';
|
28
|
+
import PopOverContainer from '../components/PopOverContainer';
|
29
|
+
import {ScopedContext, IScopedContext} from '../Scoped';
|
30
|
+
|
31
|
+
import type {Payload} from '../types';
|
32
|
+
import type {
|
21
33
|
BaseSchema,
|
34
|
+
SchemaObject,
|
22
35
|
SchemaApi,
|
23
36
|
SchemaIcon,
|
24
37
|
SchemaUrlPath,
|
25
|
-
SchemaCollection
|
38
|
+
SchemaCollection,
|
39
|
+
SchemaClassName
|
26
40
|
} from '../Schema';
|
27
|
-
import {generateIcon} from '../utils/icon';
|
28
|
-
import {
|
29
|
-
RemoteOptionsProps,
|
30
|
-
withRemoteConfig
|
31
|
-
} from '../components/WithRemoteConfig';
|
32
|
-
import {Payload} from '../types';
|
33
|
-
import Spinner from '../components/Spinner';
|
34
|
-
import {isEffectiveApi} from '../utils/api';
|
35
|
-
import {Badge, BadgeSchema} from '../components/Badge';
|
36
41
|
|
37
42
|
export type NavItemSchema = {
|
38
43
|
/**
|
@@ -58,6 +63,71 @@ export type NavItemSchema = {
|
|
58
63
|
children?: Array<NavItemSchema>;
|
59
64
|
} & Omit<BaseSchema, 'type'>;
|
60
65
|
|
66
|
+
export interface NavOverflow {
|
67
|
+
/**
|
68
|
+
* 是否开启响应式收纳
|
69
|
+
*/
|
70
|
+
enable: boolean;
|
71
|
+
|
72
|
+
/**
|
73
|
+
* 菜单触发按钮的文字
|
74
|
+
*/
|
75
|
+
overflowLabel?: string | SchemaObject;
|
76
|
+
|
77
|
+
/**
|
78
|
+
* 菜单触发按钮的图标
|
79
|
+
* @default "fa fa-ellipsis"
|
80
|
+
*/
|
81
|
+
overflowIndicator?: SchemaIcon;
|
82
|
+
|
83
|
+
/**
|
84
|
+
* 菜单触发按钮CSS类名
|
85
|
+
*/
|
86
|
+
overflowClassName?: SchemaClassName;
|
87
|
+
|
88
|
+
/**
|
89
|
+
* Popover浮层CSS类名
|
90
|
+
*/
|
91
|
+
overflowPopoverClassName?: SchemaClassName;
|
92
|
+
|
93
|
+
/**
|
94
|
+
* 菜单外层CSS类名
|
95
|
+
*/
|
96
|
+
overflowListClassName?: SchemaClassName;
|
97
|
+
|
98
|
+
/**
|
99
|
+
* 导航横向布局时,开启开启响应式收纳后最大可显示数量,超出此数量的导航将被收纳到下拉菜单中
|
100
|
+
*/
|
101
|
+
maxVisibleCount?: number;
|
102
|
+
|
103
|
+
/**
|
104
|
+
* 包裹导航的外层标签名,可以使用其他标签渲染
|
105
|
+
* @default "ul"
|
106
|
+
*/
|
107
|
+
wrapperComponent?: string;
|
108
|
+
|
109
|
+
/**
|
110
|
+
* 导航项目宽度
|
111
|
+
* @default 160
|
112
|
+
*/
|
113
|
+
itemWidth?: number;
|
114
|
+
|
115
|
+
/**
|
116
|
+
* 导航列表后缀节点
|
117
|
+
*/
|
118
|
+
overflowSuffix?: SchemaCollection;
|
119
|
+
|
120
|
+
/**
|
121
|
+
* 自定义样式
|
122
|
+
*/
|
123
|
+
style?: React.CSSProperties;
|
124
|
+
|
125
|
+
/**
|
126
|
+
* 菜单DOM挂载点
|
127
|
+
*/
|
128
|
+
popOverContainer?: any;
|
129
|
+
}
|
130
|
+
|
61
131
|
/**
|
62
132
|
* Nav 导航渲染器
|
63
133
|
* 文档:https://baidu.gitee.io/amis/docs/components/nav
|
@@ -117,6 +187,11 @@ export interface NavSchema extends BaseSchema {
|
|
117
187
|
* 仅允许同层级拖拽
|
118
188
|
*/
|
119
189
|
dragOnSameLevel?: boolean;
|
190
|
+
|
191
|
+
/**
|
192
|
+
* 横向导航时自动收纳配置
|
193
|
+
*/
|
194
|
+
overflow?: NavOverflow;
|
120
195
|
}
|
121
196
|
|
122
197
|
export interface Link {
|
@@ -162,6 +237,7 @@ export interface NavigationProps
|
|
162
237
|
env: RendererEnv;
|
163
238
|
data: Object;
|
164
239
|
reload?: any;
|
240
|
+
overflow?: NavOverflow;
|
165
241
|
}
|
166
242
|
|
167
243
|
export interface IDropInfo {
|
@@ -177,7 +253,7 @@ export class Navigation extends React.Component<
|
|
177
253
|
NavigationProps,
|
178
254
|
NavigationState
|
179
255
|
> {
|
180
|
-
static defaultProps = {
|
256
|
+
static defaultProps: Pick<NavigationProps, 'indentSize'> = {
|
181
257
|
indentSize: 24
|
182
258
|
};
|
183
259
|
|
@@ -369,6 +445,7 @@ export class Navigation extends React.Component<
|
|
369
445
|
} = this.props;
|
370
446
|
const hasSub =
|
371
447
|
(link.defer && !link.loaded) || (link.children && link.children.length);
|
448
|
+
|
372
449
|
return (
|
373
450
|
<li
|
374
451
|
key={link.__id}
|
@@ -389,6 +466,7 @@ export class Navigation extends React.Component<
|
|
389
466
|
<a
|
390
467
|
data-id={link.__id}
|
391
468
|
data-depth={depth}
|
469
|
+
title={link?.label?.toString()}
|
392
470
|
onClick={this.handleClick.bind(this, link)}
|
393
471
|
style={{
|
394
472
|
paddingLeft: depth * (parseInt(indentSize as any, 10) ?? 24)
|
@@ -452,27 +530,147 @@ export class Navigation extends React.Component<
|
|
452
530
|
);
|
453
531
|
}
|
454
532
|
|
533
|
+
renderOverflowNavs(overflowConfig: NavOverflow) {
|
534
|
+
const {render, classnames: cx, className, loading, links = []} = this.props;
|
535
|
+
const {
|
536
|
+
overflowClassName,
|
537
|
+
overflowPopoverClassName,
|
538
|
+
overflowListClassName,
|
539
|
+
overflowLabel,
|
540
|
+
overflowIndicator,
|
541
|
+
itemWidth = 160,
|
542
|
+
overflowSuffix,
|
543
|
+
popOverContainer,
|
544
|
+
style,
|
545
|
+
maxVisibleCount,
|
546
|
+
wrapperComponent = 'ul'
|
547
|
+
} = overflowConfig;
|
548
|
+
|
549
|
+
return (
|
550
|
+
<>
|
551
|
+
<Spinner show={!!loading} overlay icon="reload" />
|
552
|
+
|
553
|
+
<Overflow<Link>
|
554
|
+
className={cx('Nav-list--tabs', className)}
|
555
|
+
prefixCls={cx('Nav-list')}
|
556
|
+
itemWidth={itemWidth}
|
557
|
+
style={style}
|
558
|
+
component={wrapperComponent as any}
|
559
|
+
data={links}
|
560
|
+
suffix={
|
561
|
+
overflowSuffix
|
562
|
+
? render('nav-overflow-suffix', overflowSuffix)
|
563
|
+
: null
|
564
|
+
}
|
565
|
+
renderRawItem={(item, index) =>
|
566
|
+
this.renderItem(item, index) as JSX.Element
|
567
|
+
}
|
568
|
+
renderRawRest={overFlowedItems => {
|
569
|
+
return (
|
570
|
+
<PopOverContainer
|
571
|
+
popOverContainer={popOverContainer}
|
572
|
+
popOverClassName={cx(
|
573
|
+
'Nav-item-overflow-popover',
|
574
|
+
overflowPopoverClassName
|
575
|
+
)}
|
576
|
+
popOverRender={({onClose}) => (
|
577
|
+
<div
|
578
|
+
className={cx(
|
579
|
+
'Nav-list',
|
580
|
+
'Nav-list--stacked', // 浮层菜单为垂直布局
|
581
|
+
'Nav-list-overflow',
|
582
|
+
overflowListClassName
|
583
|
+
)}
|
584
|
+
>
|
585
|
+
{overFlowedItems.map((item, index) =>
|
586
|
+
React.cloneElement(
|
587
|
+
this.renderItem(item, index) as JSX.Element,
|
588
|
+
{
|
589
|
+
onClick: onClose
|
590
|
+
}
|
591
|
+
)
|
592
|
+
)}
|
593
|
+
</div>
|
594
|
+
)}
|
595
|
+
>
|
596
|
+
{({onClick, ref, isOpened}) => (
|
597
|
+
<li
|
598
|
+
ref={ref}
|
599
|
+
className={cx(
|
600
|
+
'Nav-item',
|
601
|
+
'Nav-item-overflow',
|
602
|
+
{
|
603
|
+
'is-overflow-opened': isOpened
|
604
|
+
},
|
605
|
+
overflowClassName
|
606
|
+
)}
|
607
|
+
onClick={onClick}
|
608
|
+
>
|
609
|
+
<a data-id={guid()} data-depth={1}>
|
610
|
+
{getIcon(overflowIndicator!) ? (
|
611
|
+
<Icon icon={overflowIndicator} className="icon" />
|
612
|
+
) : (
|
613
|
+
generateIcon(cx, overflowIndicator, 'Nav-itemIcon')
|
614
|
+
)}
|
615
|
+
{overflowLabel && isObject
|
616
|
+
? render('nav-overflow-label', overflowLabel)
|
617
|
+
: overflowLabel}
|
618
|
+
</a>
|
619
|
+
</li>
|
620
|
+
)}
|
621
|
+
</PopOverContainer>
|
622
|
+
);
|
623
|
+
}}
|
624
|
+
maxCount={
|
625
|
+
maxVisibleCount && Number.isInteger(maxVisibleCount)
|
626
|
+
? maxVisibleCount
|
627
|
+
: 'responsive'
|
628
|
+
}
|
629
|
+
/>
|
630
|
+
</>
|
631
|
+
);
|
632
|
+
}
|
633
|
+
|
455
634
|
render(): JSX.Element {
|
456
|
-
const {
|
635
|
+
const {
|
636
|
+
className,
|
637
|
+
stacked,
|
638
|
+
classnames: cx,
|
639
|
+
links,
|
640
|
+
loading,
|
641
|
+
overflow
|
642
|
+
} = this.props;
|
457
643
|
const {dropIndicator} = this.state;
|
644
|
+
|
458
645
|
return (
|
459
646
|
<div className={cx('Nav')}>
|
460
|
-
|
461
|
-
|
462
|
-
'
|
463
|
-
|
464
|
-
|
465
|
-
|
466
|
-
|
467
|
-
|
468
|
-
|
469
|
-
|
470
|
-
|
471
|
-
|
472
|
-
|
473
|
-
|
474
|
-
|
475
|
-
|
647
|
+
{overflow && isObject(overflow) && overflow.enable ? (
|
648
|
+
this.renderOverflowNavs({
|
649
|
+
overflowIndicator: 'fa fa-ellipsis',
|
650
|
+
wrapperComponent: 'ul',
|
651
|
+
itemWidth: 160,
|
652
|
+
...overflow
|
653
|
+
})
|
654
|
+
) : (
|
655
|
+
<>
|
656
|
+
<ul
|
657
|
+
className={cx(
|
658
|
+
'Nav-list',
|
659
|
+
className,
|
660
|
+
stacked ? 'Nav-list--stacked' : 'Nav-list--tabs'
|
661
|
+
)}
|
662
|
+
>
|
663
|
+
{Array.isArray(links)
|
664
|
+
? links.map((item, index) => this.renderItem(item, index))
|
665
|
+
: null}
|
666
|
+
|
667
|
+
<Spinner show={!!loading} overlay icon="reload" />
|
668
|
+
</ul>
|
669
|
+
{dropIndicator ? (
|
670
|
+
<div className={cx('Nav-dropIndicator')} style={dropIndicator} />
|
671
|
+
) : null}
|
672
|
+
</>
|
673
|
+
)}
|
476
674
|
</div>
|
477
675
|
);
|
478
676
|
}
|
package/src/renderers/Page.tsx
CHANGED
@@ -32,6 +32,7 @@ import {onAction} from 'mobx-state-tree';
|
|
32
32
|
import mapValues from 'lodash/mapValues';
|
33
33
|
import {resolveVariable} from '../utils/tpl-builtin';
|
34
34
|
import {buildStyle} from '../utils/style';
|
35
|
+
import PullRefresh from '../components/PullRefresh';
|
35
36
|
|
36
37
|
/**
|
37
38
|
* 样式属性名及值
|
@@ -91,6 +92,13 @@ export interface PageSchema extends BaseSchema {
|
|
91
92
|
*/
|
92
93
|
asideResizor?: boolean;
|
93
94
|
|
95
|
+
/**
|
96
|
+
* 边栏内容是否粘住,即不跟随滚动。
|
97
|
+
*
|
98
|
+
* @default true
|
99
|
+
*/
|
100
|
+
asideSticky?: boolean;
|
101
|
+
|
94
102
|
/**
|
95
103
|
* 边栏最小宽度
|
96
104
|
*/
|
@@ -200,6 +208,15 @@ export interface PageSchema extends BaseSchema {
|
|
200
208
|
style?: {
|
201
209
|
[propName: string]: any;
|
202
210
|
};
|
211
|
+
|
212
|
+
/**
|
213
|
+
* 下拉刷新配置
|
214
|
+
*/
|
215
|
+
pullRefresh?: {
|
216
|
+
disabled?: boolean;
|
217
|
+
pullingText?: string;
|
218
|
+
loosingText?: string;
|
219
|
+
};
|
203
220
|
}
|
204
221
|
|
205
222
|
export interface PageProps
|
@@ -218,6 +235,7 @@ export default class Page extends React.Component<PageProps> {
|
|
218
235
|
startX: number;
|
219
236
|
startWidth: number;
|
220
237
|
codeWrap: HTMLElement;
|
238
|
+
asideInner = React.createRef<HTMLDivElement>();
|
221
239
|
|
222
240
|
static defaultProps = {
|
223
241
|
asideClassName: '',
|
@@ -226,7 +244,11 @@ export default class Page extends React.Component<PageProps> {
|
|
226
244
|
initFetch: true,
|
227
245
|
// primaryField: 'id',
|
228
246
|
toolbarClassName: '',
|
229
|
-
messages: {}
|
247
|
+
messages: {},
|
248
|
+
asideSticky: true,
|
249
|
+
pullRefresh: {
|
250
|
+
disabled: true
|
251
|
+
}
|
230
252
|
};
|
231
253
|
|
232
254
|
static propsList: Array<keyof PageProps> = [
|
@@ -347,7 +369,8 @@ export default class Page extends React.Component<PageProps> {
|
|
347
369
|
}
|
348
370
|
|
349
371
|
componentDidMount() {
|
350
|
-
const {initApi, initFetch, initFetchOn, store, messages} =
|
372
|
+
const {initApi, initFetch, initFetchOn, store, messages, asideSticky} =
|
373
|
+
this.props;
|
351
374
|
|
352
375
|
this.mounted = true;
|
353
376
|
|
@@ -359,6 +382,12 @@ export default class Page extends React.Component<PageProps> {
|
|
359
382
|
})
|
360
383
|
.then(this.initInterval);
|
361
384
|
}
|
385
|
+
|
386
|
+
if (asideSticky && this.asideInner.current) {
|
387
|
+
const dom = this.asideInner.current!;
|
388
|
+
const rect = dom.getBoundingClientRect();
|
389
|
+
dom.style.cssText += `position: sticky; top: ${rect.top}px;`;
|
390
|
+
}
|
362
391
|
}
|
363
392
|
|
364
393
|
componentDidUpdate(prevProps: PageProps) {
|
@@ -603,6 +632,16 @@ export default class Page extends React.Component<PageProps> {
|
|
603
632
|
return value;
|
604
633
|
}
|
605
634
|
|
635
|
+
@autobind
|
636
|
+
async handleRefresh() {
|
637
|
+
const {dispatchEvent, data} = this.props;
|
638
|
+
const rendererEvent = await dispatchEvent('pullRefresh', data);
|
639
|
+
if (rendererEvent?.prevented) {
|
640
|
+
return;
|
641
|
+
}
|
642
|
+
this.reload();
|
643
|
+
}
|
644
|
+
|
606
645
|
handleChange(
|
607
646
|
value: any,
|
608
647
|
name: string,
|
@@ -709,6 +748,7 @@ export default class Page extends React.Component<PageProps> {
|
|
709
748
|
style,
|
710
749
|
data,
|
711
750
|
asideResizor,
|
751
|
+
pullRefresh,
|
712
752
|
translate: __
|
713
753
|
} = this.props;
|
714
754
|
|
@@ -725,6 +765,31 @@ export default class Page extends React.Component<PageProps> {
|
|
725
765
|
|
726
766
|
const styleVar = buildStyle(style, data);
|
727
767
|
|
768
|
+
const pageContent = (
|
769
|
+
<div className={cx('Page-content')}>
|
770
|
+
<div className={cx('Page-main')}>
|
771
|
+
{this.renderHeader()}
|
772
|
+
<div className={cx(`Page-body`, bodyClassName)}>
|
773
|
+
<Spinner size="lg" overlay key="info" show={store.loading} />
|
774
|
+
|
775
|
+
{store.error && showErrorMsg !== false ? (
|
776
|
+
<Alert
|
777
|
+
level="danger"
|
778
|
+
showCloseButton
|
779
|
+
onClose={store.clearMessage}
|
780
|
+
>
|
781
|
+
{store.msg}
|
782
|
+
</Alert>
|
783
|
+
) : null}
|
784
|
+
|
785
|
+
{(Array.isArray(regions) ? ~regions.indexOf('body') : body)
|
786
|
+
? render('body', body || '', subProps)
|
787
|
+
: null}
|
788
|
+
</div>
|
789
|
+
</div>
|
790
|
+
</div>
|
791
|
+
);
|
792
|
+
|
728
793
|
return (
|
729
794
|
<div
|
730
795
|
className={cx(`Page`, hasAside ? `Page--withSidebar` : '', className)}
|
@@ -739,15 +804,17 @@ export default class Page extends React.Component<PageProps> {
|
|
739
804
|
asideClassName
|
740
805
|
)}
|
741
806
|
>
|
742
|
-
{
|
743
|
-
|
744
|
-
|
745
|
-
|
746
|
-
|
747
|
-
|
748
|
-
|
749
|
-
|
750
|
-
|
807
|
+
<div className={cx(`Page-asideInner`)} ref={this.asideInner}>
|
808
|
+
{render('aside', aside || '', {
|
809
|
+
...subProps,
|
810
|
+
...(typeof aside === 'string'
|
811
|
+
? {
|
812
|
+
inline: false,
|
813
|
+
className: `Page-asideTplWrapper`
|
814
|
+
}
|
815
|
+
: null)
|
816
|
+
})}
|
817
|
+
</div>
|
751
818
|
{asideResizor ? (
|
752
819
|
<div
|
753
820
|
onMouseDown={this.handleResizeMouseDown}
|
@@ -757,28 +824,17 @@ export default class Page extends React.Component<PageProps> {
|
|
757
824
|
</div>
|
758
825
|
) : null}
|
759
826
|
|
760
|
-
|
761
|
-
<
|
762
|
-
{
|
763
|
-
|
764
|
-
|
765
|
-
|
766
|
-
|
767
|
-
|
768
|
-
|
769
|
-
|
770
|
-
|
771
|
-
>
|
772
|
-
{store.msg}
|
773
|
-
</Alert>
|
774
|
-
) : null}
|
775
|
-
|
776
|
-
{(Array.isArray(regions) ? ~regions.indexOf('body') : body)
|
777
|
-
? render('body', body || '', subProps)
|
778
|
-
: null}
|
779
|
-
</div>
|
780
|
-
</div>
|
781
|
-
</div>
|
827
|
+
{pullRefresh && !pullRefresh.disabled ? (
|
828
|
+
<PullRefresh
|
829
|
+
{...pullRefresh}
|
830
|
+
translate={__}
|
831
|
+
onRefresh={this.handleRefresh}
|
832
|
+
>
|
833
|
+
{pageContent}
|
834
|
+
</PullRefresh>
|
835
|
+
) : (
|
836
|
+
pageContent
|
837
|
+
)}
|
782
838
|
|
783
839
|
{render(
|
784
840
|
'dialog',
|
@@ -251,12 +251,18 @@ export default class Service extends React.Component<ServiceProps> {
|
|
251
251
|
let dataProviderFunc = dataProvider;
|
252
252
|
|
253
253
|
if (typeof dataProvider === 'string' && dataProvider) {
|
254
|
-
dataProviderFunc = str2AsyncFunction(
|
254
|
+
dataProviderFunc = str2AsyncFunction(
|
255
|
+
dataProvider,
|
256
|
+
'data',
|
257
|
+
'setData',
|
258
|
+
'env'
|
259
|
+
)!;
|
255
260
|
}
|
256
261
|
if (typeof dataProviderFunc === 'function') {
|
257
262
|
const unsubscribe = await dataProviderFunc(
|
258
263
|
store.data,
|
259
|
-
this.dataProviderSetData
|
264
|
+
this.dataProviderSetData,
|
265
|
+
this.props.env
|
260
266
|
);
|
261
267
|
if (typeof unsubscribe === 'function') {
|
262
268
|
this.dataProviderUnsubscribe = unsubscribe;
|
@@ -363,6 +369,7 @@ export default class Service extends React.Component<ServiceProps> {
|
|
363
369
|
initFetch,
|
364
370
|
initFetchOn,
|
365
371
|
store,
|
372
|
+
dataProvider,
|
366
373
|
messages: {fetchSuccess, fetchFailed}
|
367
374
|
} = this.props;
|
368
375
|
|
@@ -386,6 +393,10 @@ export default class Service extends React.Component<ServiceProps> {
|
|
386
393
|
})
|
387
394
|
.then(this.afterDataFetch);
|
388
395
|
}
|
396
|
+
|
397
|
+
if (dataProvider) {
|
398
|
+
this.runDataProvider();
|
399
|
+
}
|
389
400
|
}
|
390
401
|
|
391
402
|
silentReload(target?: string, query?: any) {
|
@@ -411,22 +422,35 @@ export default class Service extends React.Component<ServiceProps> {
|
|
411
422
|
// 会被覆写
|
412
423
|
}
|
413
424
|
|
425
|
+
@autobind
|
426
|
+
handleDialogConfirm(
|
427
|
+
values: object[],
|
428
|
+
action: Action,
|
429
|
+
ctx: any,
|
430
|
+
targets: Array<any>
|
431
|
+
) {
|
432
|
+
const {store} = this.props;
|
433
|
+
store.closeDialog(true);
|
434
|
+
}
|
435
|
+
|
436
|
+
@autobind
|
437
|
+
handleDialogClose(confirmed = false) {
|
438
|
+
const {store} = this.props;
|
439
|
+
store.closeDialog(confirmed);
|
440
|
+
}
|
441
|
+
|
414
442
|
openFeedback(dialog: any, ctx: any) {
|
415
443
|
return new Promise(resolve => {
|
416
444
|
const {store} = this.props;
|
417
|
-
|
418
|
-
|
419
|
-
|
420
|
-
|
421
|
-
|
422
|
-
|
423
|
-
|
424
|
-
|
425
|
-
|
426
|
-
store.openDialog(ctx, undefined, confirmed => {
|
427
|
-
resolve(confirmed);
|
428
|
-
});
|
429
|
-
}
|
445
|
+
|
446
|
+
store.setCurrentAction({
|
447
|
+
type: 'button',
|
448
|
+
actionType: 'dialog',
|
449
|
+
dialog: dialog
|
450
|
+
});
|
451
|
+
store.openDialog(ctx, undefined, confirmed => {
|
452
|
+
resolve(confirmed);
|
453
|
+
});
|
430
454
|
});
|
431
455
|
}
|
432
456
|
|
@@ -486,18 +510,12 @@ export default class Service extends React.Component<ServiceProps> {
|
|
486
510
|
renderBody() {
|
487
511
|
const {render, store, body: schema, classnames: cx} = this.props;
|
488
512
|
|
489
|
-
return (
|
490
|
-
|
491
|
-
|
492
|
-
|
493
|
-
|
494
|
-
|
495
|
-
onAction: this.handleAction,
|
496
|
-
onChange: this.handleChange
|
497
|
-
}) as JSX.Element
|
498
|
-
}
|
499
|
-
</div>
|
500
|
-
);
|
513
|
+
return render('body', store.schema || schema, {
|
514
|
+
key: store.schemaKey || 'body',
|
515
|
+
onQuery: this.handleQuery,
|
516
|
+
onAction: this.handleAction,
|
517
|
+
onChange: this.handleChange
|
518
|
+
}) as JSX.Element;
|
501
519
|
}
|
502
520
|
|
503
521
|
render() {
|
@@ -527,6 +545,23 @@ export default class Service extends React.Component<ServiceProps> {
|
|
527
545
|
{this.renderBody()}
|
528
546
|
|
529
547
|
<Spinner size="lg" overlay key="info" show={store.loading} />
|
548
|
+
|
549
|
+
{render(
|
550
|
+
// 单独给 feedback 服务的,handleAction 里面先不要处理弹窗
|
551
|
+
'modal',
|
552
|
+
{
|
553
|
+
...((store.action as Action) &&
|
554
|
+
((store.action as Action).dialog as object)),
|
555
|
+
type: 'dialog'
|
556
|
+
},
|
557
|
+
{
|
558
|
+
key: 'dialog',
|
559
|
+
data: store.dialogData,
|
560
|
+
onConfirm: this.handleDialogConfirm,
|
561
|
+
onClose: this.handleDialogClose,
|
562
|
+
show: store.dialogOpen
|
563
|
+
}
|
564
|
+
)}
|
530
565
|
</div>
|
531
566
|
);
|
532
567
|
}
|