amis 1.5.8-beta.2 → 1.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/components/CalendarMobile.js +5 -5
- package/lib/components/CalendarMobile.js.map +2 -2
- package/lib/components/Card.d.ts +20 -20
- package/lib/components/Cascader.d.ts +123 -0
- package/lib/components/Cascader.js +487 -0
- package/lib/components/Cascader.js.map +13 -0
- package/lib/components/CityArea.d.ts +527 -0
- package/lib/components/CityArea.js +177 -0
- package/lib/components/CityArea.js.map +13 -0
- package/lib/components/ColorPicker.js +4 -3
- package/lib/components/ColorPicker.js.map +2 -2
- package/lib/components/DatePicker.d.ts +85 -84
- package/lib/components/DatePicker.js +7 -6
- package/lib/components/DatePicker.js.map +2 -2
- package/lib/components/DateRangePicker.js +8 -11
- package/lib/components/DateRangePicker.js.map +2 -2
- package/lib/components/MonthRangePicker.js +5 -8
- package/lib/components/MonthRangePicker.js.map +2 -2
- package/lib/components/Picker.d.ts +1 -0
- package/lib/components/Picker.js +10 -6
- package/lib/components/Picker.js.map +2 -2
- package/lib/components/PickerColumn.d.ts +1 -0
- package/lib/components/PickerColumn.js +21 -17
- package/lib/components/PickerColumn.js.map +2 -2
- package/lib/components/PopOverContainer.d.ts +1 -0
- package/lib/components/PopOverContainer.js +5 -3
- package/lib/components/PopOverContainer.js.map +2 -2
- package/lib/components/PopUp.d.ts +1040 -28
- package/lib/components/PopUp.js +32 -8
- package/lib/components/PopUp.js.map +2 -2
- package/lib/components/ResultBox.d.ts +85 -84
- package/lib/components/ResultBox.js +7 -3
- package/lib/components/ResultBox.js.map +2 -2
- package/lib/components/Select.js +9 -6
- package/lib/components/Select.js.map +2 -2
- package/lib/components/TransferDropDown.d.ts +85 -84
- package/lib/components/TransferDropDown.js +9 -6
- package/lib/components/TransferDropDown.js.map +2 -2
- package/lib/components/calendar/Calendar.d.ts +14 -0
- package/lib/components/calendar/Calendar.js +62 -5
- package/lib/components/calendar/Calendar.js.map +2 -2
- package/lib/components/calendar/DaysView.d.ts +20 -0
- package/lib/components/calendar/DaysView.js +51 -4
- package/lib/components/calendar/DaysView.js.map +2 -2
- package/lib/components/calendar/MonthsView.d.ts +7 -1
- package/lib/components/calendar/MonthsView.js +41 -52
- package/lib/components/calendar/MonthsView.js.map +2 -2
- package/lib/components/calendar/TimeView.d.ts +27 -20
- package/lib/components/calendar/TimeView.js +40 -4
- package/lib/components/calendar/TimeView.js.map +2 -2
- package/lib/components/calendar/YearsView.d.ts +6 -0
- package/lib/components/calendar/YearsView.js +15 -6
- package/lib/components/calendar/YearsView.js.map +2 -2
- package/lib/index.js +1 -1
- package/lib/locale/de-DE.js +4 -0
- package/lib/locale/de-DE.js.map +2 -2
- package/lib/locale/en-US.js +4 -0
- package/lib/locale/en-US.js.map +2 -2
- package/lib/locale/zh-CN.js +4 -0
- package/lib/locale/zh-CN.js.map +2 -2
- package/lib/renderers/DropDownButton.d.ts +11 -2
- package/lib/renderers/DropDownButton.js +30 -12
- package/lib/renderers/DropDownButton.js.map +2 -2
- package/lib/renderers/Form/CityDB.js +526 -2
- package/lib/renderers/Form/CityDB.js.map +2 -2
- package/lib/renderers/Form/InputCity.d.ts +85 -84
- package/lib/renderers/Form/InputCity.js +4 -2
- package/lib/renderers/Form/InputCity.js.map +2 -2
- package/lib/renderers/Form/InputColor.js +6 -2
- package/lib/renderers/Form/InputColor.js.map +2 -2
- package/lib/renderers/Form/InputDate.js +5 -2
- package/lib/renderers/Form/InputDate.js.map +2 -2
- package/lib/renderers/Form/InputDateRange.js +6 -2
- package/lib/renderers/Form/InputDateRange.js.map +2 -2
- package/lib/renderers/Form/Item.d.ts +10 -14
- package/lib/renderers/Form/Item.js +7 -5
- package/lib/renderers/Form/Item.js.map +2 -2
- package/lib/renderers/Form/NestedSelect.d.ts +1 -0
- package/lib/renderers/Form/NestedSelect.js +7 -3
- package/lib/renderers/Form/NestedSelect.js.map +2 -2
- package/lib/renderers/Form/Select.d.ts +2 -0
- package/lib/renderers/Form/Select.js +7 -4
- package/lib/renderers/Form/Select.js.map +2 -2
- package/lib/renderers/Form/TreeSelect.js +4 -4
- package/lib/renderers/Form/TreeSelect.js.map +2 -2
- package/lib/renderers/Remark.js +2 -1
- package/lib/renderers/Remark.js.map +2 -2
- package/lib/schemaExtend.js +23 -9
- package/lib/schemaExtend.js.map +2 -2
- package/lib/themes/ang-ie11.css +312 -29
- package/lib/themes/ang.css +312 -29
- package/lib/themes/ang.css.map +1 -1
- package/lib/themes/antd-ie11.css +312 -29
- package/lib/themes/antd.css +312 -29
- package/lib/themes/antd.css.map +1 -1
- package/lib/themes/cxd-ie11.css +315 -41
- package/lib/themes/cxd.css +315 -41
- package/lib/themes/cxd.css.map +1 -1
- package/lib/themes/dark-ie11.css +312 -29
- package/lib/themes/dark.css +312 -29
- package/lib/themes/dark.css.map +1 -1
- package/lib/themes/default.css +315 -41
- package/lib/themes/default.css.map +1 -1
- package/lib/utils/helper.d.ts +1 -6
- package/lib/utils/helper.js +6 -17
- package/lib/utils/helper.js.map +2 -2
- package/package.json +1 -2
- package/schema.json +2192 -20
- package/scss/_properties.scss +10 -6
- package/scss/components/_calendar.scss +9 -2
- package/scss/components/_cascader.scss +102 -0
- package/scss/components/_city-area.scss +27 -0
- package/scss/components/_dropdown.scss +39 -9
- package/scss/components/_picker-columns.scss +15 -5
- package/scss/components/_popup.scss +35 -12
- package/scss/components/_result-box.scss +31 -0
- package/scss/components/form/_checks.scss +2 -0
- package/scss/components/form/_color.scss +2 -2
- package/scss/components/form/_date-range.scss +1 -1
- package/scss/components/form/_date.scss +46 -1
- package/scss/components/form/_nested-select.scss +3 -0
- package/scss/components/form/_select.scss +32 -3
- package/scss/components/form/_transfer.scss +3 -0
- package/scss/components/form/_tree-select.scss +1 -1
- package/scss/themes/_common.scss +2 -0
- package/scss/themes/_cxd-variables.scss +3 -3
- package/scss/themes/cxd.scss +0 -12
- package/sdk/ang-ie11.css +368 -29
- package/sdk/ang.css +367 -30
- package/sdk/antd-ie11.css +368 -29
- package/sdk/antd.css +367 -30
- package/sdk/charts.js +18 -18
- package/sdk/codemirror.js +7 -7
- package/sdk/color-picker.js +65 -65
- package/sdk/cropperjs.js +3 -3
- package/sdk/cxd-ie11.css +370 -42
- package/sdk/cxd.css +370 -44
- package/sdk/dark-ie11.css +368 -29
- package/sdk/dark.css +367 -30
- package/sdk/exceljs.js +1 -1
- package/sdk/locale/de-DE.js +4 -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 +18 -18
- package/sdk/rich-text.js +62 -62
- package/sdk/sdk-ie11.css +370 -42
- package/sdk/sdk.css +370 -44
- package/sdk/sdk.js +1309 -1227
- package/sdk/thirds/hls.js/hls.js +18 -18
- package/sdk/thirds/mpegts.js/mpegts.js +2 -2
- package/sdk/tinymce.js +57 -57
- package/src/components/CalendarMobile.tsx +5 -5
- package/src/components/Cascader.tsx +564 -0
- package/src/components/CityArea.tsx +315 -0
- package/src/components/ColorPicker.tsx +5 -2
- package/src/components/DatePicker.tsx +15 -5
- package/src/components/DateRangePicker.tsx +52 -43
- package/src/components/MonthRangePicker.tsx +44 -38
- package/src/components/Picker.tsx +27 -12
- package/src/components/PickerColumn.tsx +28 -18
- package/src/components/PopOverContainer.tsx +31 -17
- package/src/components/PopUp.tsx +55 -13
- package/src/components/ResultBox.tsx +10 -1
- package/src/components/Select.tsx +20 -23
- package/src/components/TransferDropDown.tsx +19 -5
- package/src/components/calendar/Calendar.tsx +86 -9
- package/src/components/calendar/DaysView.tsx +86 -2
- package/src/components/calendar/MonthsView.tsx +56 -63
- package/src/components/calendar/TimeView.tsx +82 -29
- package/src/components/calendar/YearsView.tsx +25 -6
- package/src/locale/de-DE.ts +4 -0
- package/src/locale/en-US.ts +4 -0
- package/src/locale/zh-CN.ts +4 -0
- package/src/renderers/DropDownButton.tsx +69 -35
- package/src/renderers/Form/CityDB.ts +526 -2
- package/src/renderers/Form/InputCity.tsx +23 -3
- package/src/renderers/Form/InputColor.tsx +21 -2
- package/src/renderers/Form/InputDate.tsx +10 -1
- package/src/renderers/Form/InputDateRange.tsx +9 -1
- package/src/renderers/Form/Item.tsx +14 -4
- package/src/renderers/Form/NestedSelect.tsx +31 -3
- package/src/renderers/Form/Select.tsx +15 -2
- package/src/renderers/Form/TreeSelect.tsx +10 -6
- package/src/renderers/Remark.tsx +2 -1
- package/src/schemaExtend.ts +22 -10
- package/src/utils/helper.ts +6 -16
@@ -2,7 +2,12 @@
|
|
2
2
|
* @file Picker
|
3
3
|
* @description 移动端列滚动选择器
|
4
4
|
*/
|
5
|
-
import React, {
|
5
|
+
import React, {
|
6
|
+
memo,
|
7
|
+
ReactNode,
|
8
|
+
useState,
|
9
|
+
useEffect
|
10
|
+
} from 'react';
|
6
11
|
import {uncontrollable} from 'uncontrollable';
|
7
12
|
|
8
13
|
import {themeable, ThemeProps} from '../theme';
|
@@ -16,6 +21,7 @@ export type PickerValue = string | number;
|
|
16
21
|
export interface PickerProps extends ThemeProps, LocaleProps {
|
17
22
|
title?: String | ReactNode;
|
18
23
|
labelField?: string;
|
24
|
+
valueField?: string;
|
19
25
|
className?: string;
|
20
26
|
showToolbar?: boolean;
|
21
27
|
defaultValue?: PickerValue[];
|
@@ -38,12 +44,14 @@ function fixToArray(data: any) {
|
|
38
44
|
|
39
45
|
const Picker = memo<PickerProps>(props => {
|
40
46
|
const {
|
47
|
+
title,
|
41
48
|
labelField,
|
49
|
+
valueField,
|
42
50
|
visibleItemCount = 5,
|
43
51
|
value = [],
|
44
52
|
swipeDuration = 1000,
|
45
53
|
columns = [],
|
46
|
-
itemHeight =
|
54
|
+
itemHeight = 48,
|
47
55
|
showToolbar = true,
|
48
56
|
className = '',
|
49
57
|
classnames: cx,
|
@@ -55,9 +63,11 @@ const Picker = memo<PickerProps>(props => {
|
|
55
63
|
const [innerValue, setInnerValue] = useState<PickerValue[]>(
|
56
64
|
fixToArray(props.value === undefined ? props.defaultValue || [] : value)
|
57
65
|
);
|
66
|
+
|
58
67
|
useEffect(() => {
|
59
|
-
|
60
|
-
|
68
|
+
if (value === innerValue) return
|
69
|
+
setInnerValue(fixToArray(value));
|
70
|
+
}, [value])
|
61
71
|
|
62
72
|
const close = () => {
|
63
73
|
if (props.onClose) {
|
@@ -90,7 +100,8 @@ const Picker = memo<PickerProps>(props => {
|
|
90
100
|
{...item}
|
91
101
|
classnames={cx}
|
92
102
|
classPrefix={ns}
|
93
|
-
labelField={labelField}
|
103
|
+
labelField={labelField || item.labelField}
|
104
|
+
valueField={valueField || item.valueField}
|
94
105
|
itemHeight={itemHeight}
|
95
106
|
swipeDuration={swipeDuration}
|
96
107
|
visibleItemCount={visibleItemCount}
|
@@ -109,25 +120,29 @@ const Picker = memo<PickerProps>(props => {
|
|
109
120
|
const maskStyle = {
|
110
121
|
backgroundSize: `100% ${(wrapHeight - itemHeight) / 2}px`
|
111
122
|
};
|
112
|
-
|
123
|
+
const hasHeader = showToolbar || title;
|
113
124
|
return (
|
114
125
|
<div className={cx(className, 'PickerColumns', 'PickerColumns-popOver')}>
|
115
|
-
{
|
116
|
-
|
117
|
-
<Button
|
126
|
+
{hasHeader && (<div className={cx('PickerColumns-header')}>
|
127
|
+
{showToolbar && (<Button
|
118
128
|
className="PickerColumns-cancel"
|
119
129
|
level="default"
|
120
130
|
onClick={close}
|
121
131
|
>
|
122
132
|
{__('cancel')}
|
123
|
-
</Button>
|
124
|
-
|
133
|
+
</Button>)}
|
134
|
+
{title && (
|
135
|
+
<div className={cx('PickerColumns-title')}>
|
136
|
+
{title}
|
137
|
+
</div>
|
138
|
+
)}
|
139
|
+
{showToolbar && (<Button
|
125
140
|
className="PickerColumns-confirm"
|
126
141
|
level="primary"
|
127
142
|
onClick={confirm}
|
128
143
|
>
|
129
144
|
{__('confirm')}
|
130
|
-
</Button>
|
145
|
+
</Button>)}
|
131
146
|
</div>
|
132
147
|
)}
|
133
148
|
<div className={cx('PickerColumns-columns')} style={columnsStyle}>
|
@@ -21,6 +21,7 @@ import useTouch from '../hooks/use-touch';
|
|
21
21
|
|
22
22
|
export interface PickerColumnItem {
|
23
23
|
labelField?: string;
|
24
|
+
valueField?: string;
|
24
25
|
readonly?: boolean;
|
25
26
|
value?: PickerOption;
|
26
27
|
swipeDuration?: number;
|
@@ -68,8 +69,9 @@ function isOptionDisabled(option: PickerOption) {
|
|
68
69
|
const PickerColumn = forwardRef<{}, PickerColumnProps>((props, ref) => {
|
69
70
|
const {
|
70
71
|
visibleItemCount = 5,
|
71
|
-
itemHeight =
|
72
|
+
itemHeight = 48,
|
72
73
|
value,
|
74
|
+
valueField = 'value',
|
73
75
|
swipeDuration = 1000,
|
74
76
|
labelField = 'text',
|
75
77
|
options = [],
|
@@ -88,7 +90,24 @@ const PickerColumn = forwardRef<{}, PickerColumnProps>((props, ref) => {
|
|
88
90
|
|
89
91
|
const touch = useTouch();
|
90
92
|
const count = options.length;
|
91
|
-
|
93
|
+
|
94
|
+
const getOptionText = (option: [] | PickerOption) => {
|
95
|
+
if (isObject(option) && labelField in option) {
|
96
|
+
//@ts-ignore
|
97
|
+
return option[labelField];
|
98
|
+
}
|
99
|
+
return option;
|
100
|
+
};
|
101
|
+
|
102
|
+
const getOptionValue = (option: [] | PickerOption) => {
|
103
|
+
if (isObject(option) && valueField in option) {
|
104
|
+
//@ts-ignore
|
105
|
+
return option[valueField];
|
106
|
+
}
|
107
|
+
return option;
|
108
|
+
};
|
109
|
+
|
110
|
+
const defaultIndex = options.findIndex(item => getOptionValue(item) === value);
|
92
111
|
|
93
112
|
const baseOffset = useMemo(() => {
|
94
113
|
// 默认转入第一个选项的位置
|
@@ -132,12 +151,11 @@ const PickerColumn = forwardRef<{}, PickerColumnProps>((props, ref) => {
|
|
132
151
|
updateState({index});
|
133
152
|
|
134
153
|
if (emitChange && props.onChange) {
|
135
|
-
requestAnimationFrame(
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
// }, 0);
|
154
|
+
requestAnimationFrame(
|
155
|
+
() => {
|
156
|
+
props.onChange?.(getOptionValue(options[index]), index, confirm);
|
157
|
+
}
|
158
|
+
);
|
141
159
|
}
|
142
160
|
};
|
143
161
|
|
@@ -154,7 +172,7 @@ const PickerColumn = forwardRef<{}, PickerColumnProps>((props, ref) => {
|
|
154
172
|
const setOptions = (options: Array<PickerOption>) => {
|
155
173
|
if (JSON.stringify(options) !== JSON.stringify(state.options)) {
|
156
174
|
updateState({options});
|
157
|
-
const index = options.findIndex(item => item === value) || 0;
|
175
|
+
const index = options.findIndex(item => getOptionValue(item) === value) || 0;
|
158
176
|
setIndex(index, true, true);
|
159
177
|
}
|
160
178
|
};
|
@@ -168,14 +186,6 @@ const PickerColumn = forwardRef<{}, PickerColumnProps>((props, ref) => {
|
|
168
186
|
setIndex(index, true, true);
|
169
187
|
};
|
170
188
|
|
171
|
-
const getOptionText = (option: [] | PickerOption) => {
|
172
|
-
if (isObject(option) && labelField in option) {
|
173
|
-
//@ts-ignore
|
174
|
-
return option[labelField];
|
175
|
-
}
|
176
|
-
return option;
|
177
|
-
};
|
178
|
-
|
179
189
|
const getIndexByOffset = (offset: number) =>
|
180
190
|
range(Math.round(-offset / itemHeight), 0, count - 1);
|
181
191
|
|
@@ -379,7 +389,7 @@ PickerColumn.defaultProps = {
|
|
379
389
|
options: [],
|
380
390
|
visibleItemCount: 5,
|
381
391
|
swipeDuration: 1000,
|
382
|
-
itemHeight:
|
392
|
+
itemHeight: 48
|
383
393
|
};
|
384
394
|
|
385
395
|
export default themeable(
|
@@ -1,7 +1,8 @@
|
|
1
1
|
import React from 'react';
|
2
|
-
import {autobind} from '../utils/helper';
|
2
|
+
import {autobind, isMobile} from '../utils/helper';
|
3
3
|
import Overlay from './Overlay';
|
4
4
|
import PopOver from './PopOver';
|
5
|
+
import PopUp from './PopUp';
|
5
6
|
import {findDOMNode} from 'react-dom';
|
6
7
|
|
7
8
|
export interface PopOverContainerProps {
|
@@ -13,6 +14,7 @@ export interface PopOverContainerProps {
|
|
13
14
|
popOverRender: (props: {onClose: () => void}) => JSX.Element;
|
14
15
|
popOverContainer?: any;
|
15
16
|
popOverClassName?: string;
|
17
|
+
useMobileUI?: boolean;
|
16
18
|
}
|
17
19
|
|
18
20
|
export interface PopOverContainerState {
|
@@ -60,11 +62,13 @@ export class PopOverContainer extends React.Component<
|
|
60
62
|
|
61
63
|
render() {
|
62
64
|
const {
|
65
|
+
useMobileUI,
|
63
66
|
children,
|
64
67
|
popOverContainer,
|
65
68
|
popOverClassName,
|
66
69
|
popOverRender: dropdownRender
|
67
70
|
} = this.props;
|
71
|
+
const mobileUI = useMobileUI && isMobile();
|
68
72
|
return (
|
69
73
|
<>
|
70
74
|
{children({
|
@@ -72,26 +76,36 @@ export class PopOverContainer extends React.Component<
|
|
72
76
|
onClick: this.handleClick,
|
73
77
|
ref: this.targetRef
|
74
78
|
})}
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
placement={'auto'}
|
80
|
-
show={this.state.isOpened}
|
81
|
-
>
|
82
|
-
<PopOver
|
83
|
-
overlay
|
79
|
+
{mobileUI ? (
|
80
|
+
<PopUp
|
81
|
+
isShow={this.state.isOpened}
|
82
|
+
container={popOverContainer}
|
84
83
|
className={popOverClassName}
|
85
|
-
style={{
|
86
|
-
minWidth: this.target
|
87
|
-
? Math.max(this.target.offsetWidth, 100)
|
88
|
-
: 'auto'
|
89
|
-
}}
|
90
84
|
onHide={this.close}
|
91
85
|
>
|
92
86
|
{dropdownRender({onClose: this.close})}
|
93
|
-
</
|
94
|
-
|
87
|
+
</PopUp>
|
88
|
+
) : (
|
89
|
+
<Overlay
|
90
|
+
container={popOverContainer || this.getParent}
|
91
|
+
target={this.getTarget}
|
92
|
+
placement={'auto'}
|
93
|
+
show={this.state.isOpened}
|
94
|
+
>
|
95
|
+
<PopOver
|
96
|
+
overlay
|
97
|
+
className={popOverClassName}
|
98
|
+
style={{
|
99
|
+
minWidth: this.target
|
100
|
+
? Math.max(this.target.offsetWidth, 100)
|
101
|
+
: 'auto'
|
102
|
+
}}
|
103
|
+
onHide={this.close}
|
104
|
+
>
|
105
|
+
{dropdownRender({onClose: this.close})}
|
106
|
+
</PopOver>
|
107
|
+
</Overlay>
|
108
|
+
)}
|
95
109
|
</>
|
96
110
|
);
|
97
111
|
}
|
package/src/components/PopUp.tsx
CHANGED
@@ -5,7 +5,8 @@
|
|
5
5
|
*/
|
6
6
|
|
7
7
|
import React from 'react';
|
8
|
-
import {
|
8
|
+
import {themeable, ThemeProps} from '../theme';
|
9
|
+
import {localeable, LocaleProps} from '../locale';
|
9
10
|
import Transition, {
|
10
11
|
ENTERED,
|
11
12
|
EXITING,
|
@@ -14,20 +15,21 @@ import Transition, {
|
|
14
15
|
} from 'react-transition-group/Transition';
|
15
16
|
import Portal from 'react-overlays/Portal';
|
16
17
|
import {Icon} from './icons';
|
18
|
+
import Button from './Button';
|
17
19
|
|
18
|
-
export interface PopUpPorps {
|
20
|
+
export interface PopUpPorps extends ThemeProps, LocaleProps {
|
21
|
+
title?: string;
|
19
22
|
className?: string;
|
20
23
|
style?: {
|
21
24
|
[styleName: string]: string;
|
22
25
|
};
|
23
26
|
overlay?: boolean;
|
24
27
|
onHide?: () => void;
|
25
|
-
classPrefix: string;
|
26
|
-
classnames: ClassNamesFn;
|
27
|
-
[propName: string]: any;
|
28
28
|
isShow?: boolean;
|
29
29
|
container?: any;
|
30
|
-
|
30
|
+
showConfirm?: boolean;
|
31
|
+
onConfirm?: (value: any) => void;
|
32
|
+
showClose?: boolean;
|
31
33
|
placement?: 'left' | 'center' | 'right';
|
32
34
|
header?: JSX.Element;
|
33
35
|
}
|
@@ -41,15 +43,29 @@ const fadeStyles: {
|
|
41
43
|
[ENTERING]: 'in'
|
42
44
|
};
|
43
45
|
export class PopUp extends React.PureComponent<PopUpPorps> {
|
46
|
+
scrollTop: number = 0;
|
44
47
|
static defaultProps = {
|
45
48
|
className: '',
|
46
49
|
overlay: true,
|
47
50
|
isShow: false,
|
48
51
|
container: document.body,
|
49
|
-
|
52
|
+
showClose: true,
|
53
|
+
onConfirm: () => {}
|
50
54
|
};
|
51
|
-
|
52
|
-
|
55
|
+
componentDidUpdate() {
|
56
|
+
if (this.props.isShow) {
|
57
|
+
this.scrollTop =
|
58
|
+
document.body.scrollTop || document.documentElement.scrollTop;
|
59
|
+
document.body.style.overflow = 'hidden';
|
60
|
+
} else {
|
61
|
+
document.body.style.overflow = 'auto';
|
62
|
+
document.body.scrollTop = this.scrollTop;
|
63
|
+
}
|
64
|
+
}
|
65
|
+
componentWillUnmount() {
|
66
|
+
document.body.style.overflow = 'auto';
|
67
|
+
document.body.scrollTop = this.scrollTop;
|
68
|
+
}
|
53
69
|
handleClick(e: React.MouseEvent) {
|
54
70
|
e.stopPropagation();
|
55
71
|
}
|
@@ -57,15 +73,19 @@ export class PopUp extends React.PureComponent<PopUpPorps> {
|
|
57
73
|
render() {
|
58
74
|
const {
|
59
75
|
style,
|
76
|
+
title,
|
60
77
|
children,
|
61
78
|
overlay,
|
62
79
|
onHide,
|
80
|
+
onConfirm,
|
63
81
|
classPrefix: ns,
|
64
82
|
classnames: cx,
|
65
83
|
className,
|
66
84
|
isShow,
|
67
85
|
container,
|
68
|
-
|
86
|
+
showConfirm,
|
87
|
+
translate: __,
|
88
|
+
showClose,
|
69
89
|
header,
|
70
90
|
placement = 'center',
|
71
91
|
...rest
|
@@ -90,7 +110,7 @@ export class PopUp extends React.PureComponent<PopUpPorps> {
|
|
90
110
|
<div className={`${ns}PopUp-overlay`} onClick={onHide} />
|
91
111
|
)}
|
92
112
|
<div className={cx(`${ns}PopUp-inner`)}>
|
93
|
-
{!
|
113
|
+
{!showConfirm && showClose ? (
|
94
114
|
<div className={cx(`${ns}PopUp-closeWrap`)}>
|
95
115
|
{header}
|
96
116
|
<Icon
|
@@ -99,12 +119,34 @@ export class PopUp extends React.PureComponent<PopUpPorps> {
|
|
99
119
|
onClick={onHide}
|
100
120
|
/>
|
101
121
|
</div>
|
122
|
+
) : null}
|
123
|
+
{showConfirm && (
|
124
|
+
<div className={cx(`${ns}PopUp-toolbar`)}>
|
125
|
+
<Button
|
126
|
+
className={cx(`${ns}PopUp-cancel`)}
|
127
|
+
level="text"
|
128
|
+
onClick={onHide}
|
129
|
+
>
|
130
|
+
{__('cancel')}
|
131
|
+
</Button>
|
132
|
+
{title && (
|
133
|
+
<span className={cx(`${ns}PopUp-title`)}>{title}</span>
|
134
|
+
)}
|
135
|
+
<Button
|
136
|
+
className={cx(`${ns}PopUp-confirm`)}
|
137
|
+
level="text"
|
138
|
+
onClick={onConfirm}
|
139
|
+
>
|
140
|
+
{__('confirm')}
|
141
|
+
</Button>
|
142
|
+
</div>
|
102
143
|
)}
|
103
144
|
<div
|
104
145
|
className={cx(`${ns}PopUp-content`, `justify-${placement}`)}
|
105
146
|
>
|
106
|
-
{children}
|
147
|
+
{isShow ? children : null}
|
107
148
|
</div>
|
149
|
+
<div className={cx(`PopUp-safearea`)}></div>
|
108
150
|
</div>
|
109
151
|
</div>
|
110
152
|
);
|
@@ -115,4 +157,4 @@ export class PopUp extends React.PureComponent<PopUpPorps> {
|
|
115
157
|
}
|
116
158
|
}
|
117
159
|
|
118
|
-
export default themeable(PopUp);
|
160
|
+
export default themeable(localeable(PopUp));
|
@@ -4,7 +4,7 @@ import {InputBoxProps} from './InputBox';
|
|
4
4
|
import {uncontrollable} from 'uncontrollable';
|
5
5
|
import {Icon} from './icons';
|
6
6
|
import Input from './Input';
|
7
|
-
import {autobind, ucFirst} from '../utils/helper';
|
7
|
+
import {autobind, isMobile, ucFirst} from '../utils/helper';
|
8
8
|
import {LocaleProps, localeable} from '../locale';
|
9
9
|
import isPlainObject = require('lodash/isPlainObject');
|
10
10
|
|
@@ -19,6 +19,7 @@ export interface ResultBoxProps
|
|
19
19
|
onResultChange?: (value: Array<any>) => void;
|
20
20
|
allowInput?: boolean;
|
21
21
|
inputPlaceholder: string;
|
22
|
+
useMobileUI?: boolean;
|
22
23
|
}
|
23
24
|
|
24
25
|
export class ResultBox extends React.Component<ResultBoxProps> {
|
@@ -115,9 +116,11 @@ export class ResultBox extends React.Component<ResultBoxProps> {
|
|
115
116
|
onFocus,
|
116
117
|
onBlur,
|
117
118
|
borderMode,
|
119
|
+
useMobileUI,
|
118
120
|
...rest
|
119
121
|
} = this.props;
|
120
122
|
const isFocused = this.state.isFocused;
|
123
|
+
const mobileUI = useMobileUI && isMobile();
|
121
124
|
|
122
125
|
return (
|
123
126
|
<div
|
@@ -126,6 +129,7 @@ export class ResultBox extends React.Component<ResultBoxProps> {
|
|
126
129
|
'is-disabled': disabled,
|
127
130
|
'is-error': hasError,
|
128
131
|
'is-clickable': onResultClick,
|
132
|
+
'is-mobile': mobileUI,
|
129
133
|
[`ResultBox--border${ucFirst(borderMode)}`]: borderMode
|
130
134
|
})}
|
131
135
|
onClick={onResultClick}
|
@@ -183,6 +187,11 @@ export class ResultBox extends React.Component<ResultBoxProps> {
|
|
183
187
|
<Icon icon="close" className="icon" />
|
184
188
|
</a>
|
185
189
|
) : null}
|
190
|
+
{!allowInput && mobileUI ? (
|
191
|
+
<span className={cx('ResultBox-arrow')}>
|
192
|
+
<Icon icon="caret" className="icon" />
|
193
|
+
</span>
|
194
|
+
) : null}
|
186
195
|
</div>
|
187
196
|
);
|
188
197
|
}
|
@@ -37,6 +37,7 @@ import Spinner from './Spinner';
|
|
37
37
|
import {Option, Options} from '../Schema';
|
38
38
|
import {RemoteOptionsProps, withRemoteConfig} from './WithRemoteConfig';
|
39
39
|
import Picker from './Picker';
|
40
|
+
import PopUp from './PopUp';
|
40
41
|
|
41
42
|
export {Option, Options};
|
42
43
|
|
@@ -923,23 +924,13 @@ export class Select extends React.Component<SelectProps, SelectState> {
|
|
923
924
|
labelField: 'label',
|
924
925
|
options: filtedOptions
|
925
926
|
};
|
926
|
-
const menu =
|
927
|
-
<Picker
|
928
|
-
className={cx('PickerColumns-column', mobileClassName)}
|
929
|
-
labelField="label"
|
930
|
-
value={value[0]}
|
931
|
-
translate={this.props.translate}
|
932
|
-
locale={this.props.locale}
|
933
|
-
columns={[column]}
|
934
|
-
onChange={checkAll ? noop : this.handlePickerChange}
|
935
|
-
onClose={this.close}
|
936
|
-
onConfirm={this.confirm}
|
937
|
-
/>
|
938
|
-
) : (
|
927
|
+
const menu = (
|
939
928
|
<div
|
940
929
|
ref={this.menu}
|
941
930
|
className={cx('Select-menu', {
|
942
|
-
'Select--longlist':
|
931
|
+
'Select--longlist':
|
932
|
+
filtedOptions.length && filtedOptions.length > 100,
|
933
|
+
'is-mobile': mobileUI
|
943
934
|
})}
|
944
935
|
>
|
945
936
|
{searchable ? (
|
@@ -1021,8 +1012,16 @@ export class Select extends React.Component<SelectProps, SelectState> {
|
|
1021
1012
|
)}
|
1022
1013
|
</div>
|
1023
1014
|
);
|
1024
|
-
|
1025
|
-
|
1015
|
+
return mobileUI ? (
|
1016
|
+
<PopUp
|
1017
|
+
className={cx(`Select-popup`)}
|
1018
|
+
container={popOverContainer}
|
1019
|
+
isShow={this.state.isOpen}
|
1020
|
+
onHide={this.close}
|
1021
|
+
>
|
1022
|
+
{menu}
|
1023
|
+
</PopUp>
|
1024
|
+
) : (
|
1026
1025
|
<Overlay
|
1027
1026
|
container={popOverContainer || this.getTarget}
|
1028
1027
|
target={this.getTarget}
|
@@ -1031,11 +1030,7 @@ export class Select extends React.Component<SelectProps, SelectState> {
|
|
1031
1030
|
>
|
1032
1031
|
<PopOver
|
1033
1032
|
overlay
|
1034
|
-
className={cx(
|
1035
|
-
'Select-popover',
|
1036
|
-
popoverClassName,
|
1037
|
-
mobileUI ? 'PopOver-isMobile' : ''
|
1038
|
-
)}
|
1033
|
+
className={cx('Select-popover')}
|
1039
1034
|
style={{
|
1040
1035
|
minWidth: this.target ? this.target.offsetWidth : 'auto'
|
1041
1036
|
}}
|
@@ -1061,13 +1056,14 @@ export class Select extends React.Component<SelectProps, SelectState> {
|
|
1061
1056
|
labelField,
|
1062
1057
|
disabled,
|
1063
1058
|
checkAll,
|
1064
|
-
borderMode
|
1059
|
+
borderMode,
|
1060
|
+
useMobileUI
|
1065
1061
|
} = this.props;
|
1066
1062
|
|
1067
1063
|
const selection = this.state.selection;
|
1068
1064
|
const inputValue = this.state.inputValue;
|
1069
1065
|
const resetValue = this.props.resetValue;
|
1070
|
-
|
1066
|
+
const mobileUI = useMobileUI && isMobile();
|
1071
1067
|
return (
|
1072
1068
|
<Downshift
|
1073
1069
|
selectedItem={selection}
|
@@ -1101,6 +1097,7 @@ export class Select extends React.Component<SelectProps, SelectState> {
|
|
1101
1097
|
'is-opened': isOpen,
|
1102
1098
|
'is-focused': this.state.isFocused,
|
1103
1099
|
'is-disabled': disabled,
|
1100
|
+
'is-mobile': mobileUI,
|
1104
1101
|
[`Select--border${ucFirst(borderMode)}`]: borderMode
|
1105
1102
|
},
|
1106
1103
|
className
|
@@ -7,11 +7,13 @@ import ResultBox from './ResultBox';
|
|
7
7
|
import {Icon} from './icons';
|
8
8
|
import InputBox from './InputBox';
|
9
9
|
import PopOverContainer from './PopOverContainer';
|
10
|
+
import {isMobile} from '../utils/helper';
|
10
11
|
|
11
12
|
export interface TransferDropDownProps extends TransferProps {
|
12
13
|
// 新的属性?
|
13
14
|
multiple?: boolean;
|
14
15
|
borderMode?: 'full' | 'half' | 'none';
|
16
|
+
useMobileUI?: boolean;
|
15
17
|
}
|
16
18
|
|
17
19
|
export class TransferDropDown extends Transfer<TransferDropDownProps> {
|
@@ -25,15 +27,22 @@ export class TransferDropDown extends Transfer<TransferDropDownProps> {
|
|
25
27
|
onChange,
|
26
28
|
onSearch,
|
27
29
|
multiple,
|
28
|
-
borderMode
|
30
|
+
borderMode,
|
31
|
+
useMobileUI
|
29
32
|
} = this.props;
|
30
33
|
const {inputValue, searchResult} = this.state;
|
31
34
|
|
35
|
+
const mobileUI = useMobileUI && isMobile();
|
32
36
|
return (
|
33
37
|
<PopOverContainer
|
38
|
+
useMobileUI={useMobileUI}
|
34
39
|
popOverClassName={cx('TransferDropDown-popover')}
|
35
40
|
popOverRender={({onClose}) => (
|
36
|
-
<div
|
41
|
+
<div
|
42
|
+
className={cx('TransferDropDown-content', {
|
43
|
+
'is-mobile': mobileUI
|
44
|
+
})}
|
45
|
+
>
|
37
46
|
{onSearch ? (
|
38
47
|
<div className={cx('Transfer-search')}>
|
39
48
|
<InputBox
|
@@ -94,10 +103,15 @@ export class TransferDropDown extends Transfer<TransferDropDownProps> {
|
|
94
103
|
placeholder={__('Select.placeholder')}
|
95
104
|
disabled={disabled}
|
96
105
|
ref={ref}
|
106
|
+
useMobileUI={useMobileUI}
|
97
107
|
>
|
98
|
-
|
99
|
-
<
|
100
|
-
|
108
|
+
{!mobileUI ? (
|
109
|
+
<span className={cx('TransferDropDown-icon')}>
|
110
|
+
<Icon icon="caret" className="icon" />
|
111
|
+
</span>
|
112
|
+
) : (
|
113
|
+
<></>
|
114
|
+
)}
|
101
115
|
</ResultBox>
|
102
116
|
)}
|
103
117
|
</PopOverContainer>
|