amis 1.5.3 → 1.5.4

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.
Files changed (119) hide show
  1. package/README.md +5 -0
  2. package/lib/components/Card.d.ts +96 -0
  3. package/lib/components/Card.js +85 -0
  4. package/lib/components/Card.js.map +13 -0
  5. package/lib/components/DatePicker.d.ts +85 -84
  6. package/lib/components/DatePicker.js.map +2 -2
  7. package/lib/components/DateRangePicker.d.ts +84 -84
  8. package/lib/components/MonthRangePicker.d.ts +84 -84
  9. package/lib/components/Picker.d.ts +503 -0
  10. package/lib/components/Picker.js +65 -0
  11. package/lib/components/Picker.js.map +13 -0
  12. package/lib/components/PickerColumn.d.ts +29 -459
  13. package/lib/components/PickerColumn.js +35 -44
  14. package/lib/components/PickerColumn.js.map +2 -2
  15. package/lib/components/Select.d.ts +238 -238
  16. package/lib/components/Select.js +9 -2
  17. package/lib/components/Select.js.map +2 -2
  18. package/lib/components/Selection.js +1 -4
  19. package/lib/components/Selection.js.map +2 -2
  20. package/lib/components/Switch.d.ts +6 -6
  21. package/lib/components/Switch.js.map +2 -2
  22. package/lib/components/calendar/Calendar.js +15 -0
  23. package/lib/components/calendar/Calendar.js.map +2 -2
  24. package/lib/components/calendar/DaysView.js +4 -4
  25. package/lib/components/calendar/DaysView.js.map +2 -2
  26. package/lib/components/calendar/TimeView.d.ts +10 -0
  27. package/lib/components/calendar/TimeView.js +55 -2
  28. package/lib/components/calendar/TimeView.js.map +2 -2
  29. package/lib/components/calendar/YearsView.d.ts +9 -0
  30. package/lib/components/calendar/YearsView.js +19 -0
  31. package/lib/components/calendar/YearsView.js.map +2 -2
  32. package/lib/index.js +1 -1
  33. package/lib/renderers/Card.d.ts +81 -13
  34. package/lib/renderers/Card.js +178 -81
  35. package/lib/renderers/Card.js.map +2 -2
  36. package/lib/renderers/Form/DiffEditor.d.ts +145 -37
  37. package/lib/renderers/Form/Editor.d.ts +144 -36
  38. package/lib/renderers/Form/Formula.js +5 -5
  39. package/lib/renderers/Form/Formula.js.map +2 -2
  40. package/lib/renderers/Form/InputCity.d.ts +84 -84
  41. package/lib/renderers/Form/InputFile.js +2 -2
  42. package/lib/renderers/Form/InputFile.js.map +2 -2
  43. package/lib/renderers/Form/index.js +10 -0
  44. package/lib/renderers/Form/index.js.map +2 -2
  45. package/lib/renderers/Form/wrapControl.js +3 -2
  46. package/lib/renderers/Form/wrapControl.js.map +2 -2
  47. package/lib/store/combo.d.ts +160 -40
  48. package/lib/store/form.d.ts +64 -16
  49. package/lib/store/formItem.d.ts +4 -2
  50. package/lib/store/formItem.js +11 -6
  51. package/lib/store/formItem.js.map +2 -2
  52. package/lib/store/table.d.ts +128 -32
  53. package/lib/themes/ang-ie11.css +177 -30
  54. package/lib/themes/ang.css +177 -30
  55. package/lib/themes/ang.css.map +1 -1
  56. package/lib/themes/antd-ie11.css +177 -30
  57. package/lib/themes/antd.css +177 -30
  58. package/lib/themes/antd.css.map +1 -1
  59. package/lib/themes/cxd-ie11.css +177 -30
  60. package/lib/themes/cxd.css +177 -30
  61. package/lib/themes/cxd.css.map +1 -1
  62. package/lib/themes/dark-ie11.css +177 -30
  63. package/lib/themes/dark.css +177 -30
  64. package/lib/themes/dark.css.map +1 -1
  65. package/lib/themes/default.css +177 -30
  66. package/lib/themes/default.css.map +1 -1
  67. package/lib/utils/helper.d.ts +7 -0
  68. package/lib/utils/helper.js +33 -1
  69. package/lib/utils/helper.js.map +2 -2
  70. package/package.json +2 -2
  71. package/schema.json +157 -13
  72. package/scss/_properties.scss +13 -2
  73. package/scss/components/_card.scss +155 -15
  74. package/scss/components/_nav.scss +1 -1
  75. package/scss/components/_picker-columns.scss +20 -14
  76. package/scss/components/form/_file.scss +2 -2
  77. package/scss/components/form/_selection.scss +4 -0
  78. package/scss/components/form/_switch.scss +6 -0
  79. package/sdk/ang-ie11.css +214 -40
  80. package/sdk/ang.css +216 -32
  81. package/sdk/antd-ie11.css +214 -40
  82. package/sdk/antd.css +216 -32
  83. package/sdk/charts.js +14 -14
  84. package/sdk/color-picker.js +65 -65
  85. package/sdk/cropperjs.js +2 -2
  86. package/sdk/cxd-ie11.css +206 -32
  87. package/sdk/cxd.css +216 -32
  88. package/sdk/dark-ie11.css +214 -40
  89. package/sdk/dark.css +216 -32
  90. package/sdk/exceljs.js +1 -1
  91. package/sdk/markdown.js +69 -69
  92. package/sdk/papaparse.js +1 -1
  93. package/sdk/renderers/Form/CityDB.js +1 -1
  94. package/sdk/rest.js +18 -18
  95. package/sdk/rich-text.js +62 -62
  96. package/sdk/sdk-ie11.css +206 -32
  97. package/sdk/sdk.css +216 -32
  98. package/sdk/sdk.js +1190 -1186
  99. package/sdk/thirds/hls.js/hls.js +1 -1
  100. package/sdk/thirds/mpegts.js/mpegts.js +1 -1
  101. package/sdk/tinymce.js +57 -57
  102. package/src/components/Card.tsx +203 -0
  103. package/src/components/DatePicker.tsx +3 -0
  104. package/src/components/Picker.tsx +145 -0
  105. package/src/components/PickerColumn.tsx +58 -95
  106. package/src/components/Select.tsx +17 -12
  107. package/src/components/Selection.tsx +1 -4
  108. package/src/components/Switch.tsx +7 -7
  109. package/src/components/calendar/Calendar.tsx +18 -0
  110. package/src/components/calendar/DaysView.tsx +6 -4
  111. package/src/components/calendar/TimeView.tsx +80 -5
  112. package/src/components/calendar/YearsView.tsx +44 -1
  113. package/src/renderers/Card.tsx +299 -191
  114. package/src/renderers/Form/Formula.tsx +7 -5
  115. package/src/renderers/Form/InputFile.tsx +6 -2
  116. package/src/renderers/Form/index.tsx +12 -0
  117. package/src/renderers/Form/wrapControl.tsx +5 -2
  118. package/src/store/formItem.ts +12 -6
  119. package/src/utils/helper.ts +34 -0
@@ -0,0 +1,203 @@
1
+ import React from 'react';
2
+ import {isClickOnInput} from '../utils/helper';
3
+ import {ClassNamesFn, themeable, ThemeProps} from '../theme';
4
+ export interface CardProps extends ThemeProps {
5
+ className?: string;
6
+ headerClassName?: string;
7
+ titleClassName?: string;
8
+ subTitleClassName?: string;
9
+ descriptionClassName?: string;
10
+ avatarTextStyle?: object;
11
+ avatarTextClassName?: string;
12
+ avatarClassName?: string;
13
+ secondaryClassName?: string;
14
+ imageClassName?: string;
15
+ bodyClassName?: string;
16
+ footerClassName?: string;
17
+ media?: React.ReactNode;
18
+ mediaPosition?: 'top' | 'left' | 'right' | 'bottom';
19
+ toolbar?: React.ReactNode;
20
+ children?: React.ReactNode;
21
+ actions?: React.ReactNode;
22
+ title?: string | JSX.Element;
23
+ subTitle?: string | JSX.Element;
24
+ subTitlePlaceholder?: string | JSX.Element;
25
+ description?: string | JSX.Element;
26
+ descriptionPlaceholder?: string | JSX.Element;
27
+ avatar?: string;
28
+ avatarText?: string | JSX.Element;
29
+ secondary?: string | JSX.Element;
30
+ onClick?: (e: React.MouseEvent<HTMLDivElement>) => void;
31
+ classnames: ClassNamesFn;
32
+ }
33
+
34
+ export class Card extends React.Component<CardProps> {
35
+ static defaultProps: Partial<CardProps> = {
36
+ className: '',
37
+ avatarClassName: '',
38
+ headerClassName: '',
39
+ footerClassName: '',
40
+ secondaryClassName: '',
41
+ avatarTextClassName: '',
42
+ bodyClassName: '',
43
+ titleClassName: '',
44
+ subTitleClassName: '',
45
+ descriptionClassName: '',
46
+ imageClassName: '',
47
+ mediaPosition: 'left'
48
+ };
49
+
50
+ constructor(props: CardProps) {
51
+ super(props);
52
+ this.handleClick = this.handleClick.bind(this);
53
+ }
54
+
55
+ handleClick(e: React.MouseEvent<HTMLDivElement>) {
56
+ if (isClickOnInput(e)) {
57
+ return;
58
+ }
59
+
60
+ this.props.onClick && this.props.onClick(e);
61
+ }
62
+
63
+ render() {
64
+ const {
65
+ classnames: cx,
66
+ className,
67
+ headerClassName,
68
+ bodyClassName,
69
+ titleClassName,
70
+ subTitleClassName,
71
+ descriptionClassName,
72
+ avatarClassName,
73
+ avatarTextStyle,
74
+ imageClassName,
75
+ avatarTextClassName,
76
+ secondaryClassName,
77
+ footerClassName,
78
+ media,
79
+ mediaPosition,
80
+ actions,
81
+ children,
82
+ onClick,
83
+ toolbar,
84
+ title,
85
+ subTitle,
86
+ subTitlePlaceholder,
87
+ description,
88
+ descriptionPlaceholder,
89
+ secondary,
90
+ avatar,
91
+ avatarText
92
+ } = this.props;
93
+
94
+ let heading = null;
95
+ const isShowHeading =
96
+ avatar ||
97
+ avatarText ||
98
+ title ||
99
+ subTitle ||
100
+ subTitlePlaceholder ||
101
+ description ||
102
+ descriptionPlaceholder ||
103
+ toolbar;
104
+ if (isShowHeading) {
105
+ heading = (
106
+ <div className={cx('Card-heading', headerClassName)}>
107
+ {avatar ? (
108
+ <span className={cx('Card-avtar', avatarClassName)}>
109
+ <img className={cx('Card-img', imageClassName)} src={avatar} />
110
+ </span>
111
+ ) : avatarText ? (
112
+ <span
113
+ className={cx('Card-avtarText', avatarTextClassName)}
114
+ style={avatarTextStyle}
115
+ >
116
+ {avatarText}
117
+ </span>
118
+ ) : null}
119
+ <div className={cx('Card-meta')}>
120
+ {title ? (
121
+ <div className={cx('Card-title', titleClassName)}>{title}</div>
122
+ ) : null}
123
+ {subTitle || subTitlePlaceholder ? (
124
+ <div className={cx('Card-subTitle', subTitleClassName)}>
125
+ {subTitle
126
+ ? subTitle
127
+ : subTitlePlaceholder
128
+ ? subTitlePlaceholder
129
+ : null}
130
+ </div>
131
+ ) : null}
132
+ {description || descriptionPlaceholder ? (
133
+ <div className={cx('Card-desc', descriptionClassName)}>
134
+ {description
135
+ ? description
136
+ : descriptionPlaceholder
137
+ ? descriptionPlaceholder
138
+ : null}
139
+ </div>
140
+ ) : null}
141
+ </div>
142
+ {toolbar}
143
+ </div>
144
+ );
145
+ }
146
+
147
+ const body = children;
148
+
149
+ return (
150
+ <div
151
+ onClick={this.handleClick}
152
+ className={cx('Card', className, {
153
+ 'Card--link': onClick
154
+ })}
155
+ >
156
+ {media ? (
157
+ <div className={cx(`Card-multiMedia--${mediaPosition}`)}>
158
+ {media}
159
+ <div className={cx('Card-multiMedia-flex')}>
160
+ {heading}
161
+ {body ? (
162
+ <div className={cx('Card-body', bodyClassName)}>{body}</div>
163
+ ) : null}
164
+ {secondary || actions ? (
165
+ <div className={cx('Card-footer-wrapper', footerClassName)}>
166
+ {secondary ? (
167
+ <div className={cx('Card-secondary', secondaryClassName)}>
168
+ {secondary}
169
+ </div>
170
+ ) : null}
171
+ {actions ? (
172
+ <div className={cx('Card-actions-wrapper')}>{actions}</div>
173
+ ) : null}
174
+ </div>
175
+ ) : null}
176
+ </div>
177
+ </div>
178
+ ) : (
179
+ <div>
180
+ {heading}
181
+ {body ? (
182
+ <div className={cx('Card-body', bodyClassName)}>{body}</div>
183
+ ) : null}
184
+ {secondary || actions ? (
185
+ <div className={cx('Card-footer-wrapper', footerClassName)}>
186
+ {secondary ? (
187
+ <div className={cx('Card-secondary', secondaryClassName)}>
188
+ {secondary}
189
+ </div>
190
+ ) : null}
191
+ {actions ? (
192
+ <div className={cx('Card-actions-wrapper')}>{actions}</div>
193
+ ) : null}
194
+ </div>
195
+ ) : null}
196
+ </div>
197
+ )}
198
+ </div>
199
+ );
200
+ }
201
+ }
202
+
203
+ export default themeable(Card);
@@ -288,6 +288,8 @@ export interface DateProps extends LocaleProps, ThemeProps {
288
288
  largeMode?: boolean;
289
289
  onScheduleClick?: (scheduleData: any) => void;
290
290
 
291
+ useMobileUI?: boolean;
292
+
291
293
  // 下面那个千万不要写,写了就会导致 keyof DateProps 得到的结果是 string | number;
292
294
  // [propName: string]: any;
293
295
  }
@@ -567,6 +569,7 @@ export class DatePicker extends React.Component<DateProps, DatePickerState> {
567
569
  const isOpened = this.state.isOpened;
568
570
  let date: moment.Moment | undefined = this.state.value;
569
571
 
572
+
570
573
  if (embed) {
571
574
  let schedulesData: DateProps['schedules'] = undefined;
572
575
  if (schedules && Array.isArray(schedules)) {
@@ -0,0 +1,145 @@
1
+ /**
2
+ * @file Picker
3
+ * @description 移动端列滚动选择器
4
+ */
5
+ import React, {
6
+ memo,
7
+ ReactNode,
8
+ useState
9
+ } from 'react';
10
+ import {uncontrollable} from 'uncontrollable';
11
+
12
+ import {themeable, ThemeProps} from '../theme';
13
+ import {localeable, LocaleProps} from '../locale';
14
+
15
+ import Button from './Button';
16
+ import {PickerColumnItem, default as Column} from './PickerColumn';
17
+
18
+ export type PickerValue = string | number;
19
+
20
+ export interface PickerProps extends ThemeProps, LocaleProps {
21
+ title?: String | ReactNode,
22
+ labelField?: string;
23
+ className?: string;
24
+ showToolbar?: boolean;
25
+ defaultValue?: PickerValue[];
26
+ value?: PickerValue[];
27
+ swipeDuration?: number;
28
+ visibleItemCount?: number;
29
+ itemHeight?: number;
30
+ columns: PickerColumnItem[] | PickerColumnItem;
31
+ onChange?: (
32
+ value?: PickerValue[],
33
+ index?: number,
34
+ confirm?: boolean
35
+ ) => void;
36
+ onClose?: (
37
+ value?: PickerValue[]
38
+ ) => void;
39
+ onConfirm?: (
40
+ value?: PickerValue[]
41
+ ) => void;
42
+ }
43
+
44
+ function fixToArray(data: any) {
45
+ if (!Array.isArray(data)) {
46
+ return [data];
47
+ }
48
+ return data;
49
+ }
50
+
51
+ const Picker = memo<PickerProps>((props) => {
52
+ const {
53
+ labelField,
54
+ visibleItemCount = 5,
55
+ value = [],
56
+ swipeDuration = 1000,
57
+ columns = [],
58
+ itemHeight = 30,
59
+ showToolbar = true,
60
+ className='',
61
+ classnames: cx,
62
+ classPrefix: ns,
63
+ translate: __
64
+ } = props;
65
+
66
+ const _columns = fixToArray(columns);
67
+ const [innerValue, setInnerValue] = useState<PickerValue[]>(
68
+ fixToArray(props.value === undefined ? props.defaultValue || [] : value )
69
+ );
70
+
71
+ const close = () => {
72
+ if (props.onClose) {
73
+ props.onClose(innerValue);
74
+ }
75
+ };
76
+
77
+ const confirm = () => {
78
+ if (props.onConfirm) {
79
+ props.onConfirm(innerValue);
80
+ }
81
+ };
82
+
83
+ const onChange = (itemValue: PickerValue, columnIndex: number, confirm?: boolean) => {
84
+ const nextInnerValue = [...innerValue];
85
+ nextInnerValue[columnIndex] = itemValue;
86
+ setInnerValue(nextInnerValue);
87
+ if (props.onChange) {
88
+ props.onChange(nextInnerValue, columnIndex, confirm);
89
+ }
90
+ };
91
+
92
+ const renderColumnItem = (item: PickerColumnItem, index: number) => {
93
+ return (
94
+ <Column
95
+ {...item}
96
+ classnames={cx}
97
+ classPrefix={ns}
98
+ labelField={labelField}
99
+ itemHeight={itemHeight}
100
+ swipeDuration={swipeDuration}
101
+ visibleItemCount={visibleItemCount}
102
+ value={innerValue[index]}
103
+ onChange={(val: string | number, i, confirm) => {
104
+ onChange(val, index, confirm);
105
+ }}
106
+ />)
107
+ };
108
+
109
+ const wrapHeight = itemHeight * +visibleItemCount;
110
+ const frameStyle = {height: `${itemHeight}px`};
111
+ const columnsStyle = {height: `${wrapHeight}px`};
112
+ const maskStyle = {
113
+ backgroundSize: `100% ${(wrapHeight - itemHeight) / 2}px`
114
+ };
115
+
116
+ return (
117
+ <div
118
+ className={cx(className, 'PickerColumns', 'PickerColumns-popOver')}
119
+ >
120
+ {showToolbar && <div className={cx('PickerColumns-toolbar')}>
121
+ <Button className="PickerColumns-cancel" level="default" onClick={close}>
122
+ {__('cancel')}
123
+ </Button>
124
+ <Button className="PickerColumns-confirm" level="primary" onClick={confirm}>
125
+ {__('confirm')}
126
+ </Button>
127
+ </div>}
128
+ <div className={cx('PickerColumns-columns')} style={columnsStyle}>
129
+ {
130
+ _columns.map((column: PickerColumnItem, index: number) => renderColumnItem(column, index))
131
+ }
132
+ <div className={cx('PickerColumns-mask')} style={maskStyle}></div>
133
+ <div className={cx('PickerColumns-frame')} style={frameStyle}></div>
134
+ </div>
135
+ </div>
136
+ );
137
+ });
138
+
139
+ export default themeable(
140
+ localeable(
141
+ uncontrollable(Picker, {
142
+ value: 'onChange'
143
+ })
144
+ )
145
+ );
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @file Picker
3
- * @description 移动端选择器
3
+ * @description 移动端列滚动选择器
4
4
  */
5
5
  import React, {
6
6
  useEffect,
@@ -8,8 +8,7 @@ import React, {
8
8
  useRef,
9
9
  useImperativeHandle,
10
10
  useCallback,
11
- forwardRef,
12
- CSSProperties
11
+ forwardRef
13
12
  } from 'react';
14
13
  import isObject from 'lodash/isObject';
15
14
  import cloneDeep from 'lodash/cloneDeep';
@@ -18,37 +17,25 @@ import {uncontrollable} from 'uncontrollable';
18
17
  import {useSetState, useUpdateEffect} from '../hooks';
19
18
  import {range} from '../utils/helper';
20
19
  import {themeable, ThemeProps} from '../theme';
21
- import {localeable, LocaleProps} from '../locale';
22
20
  import useTouch from '../hooks/use-touch';
23
- import Button from './Button';
24
21
 
25
- export interface PickerColumnProps extends ThemeProps, LocaleProps {
26
- mobileClassName?: string;
27
- style?: CSSProperties;
28
- index?: number;
29
- labelField: string;
22
+ export interface PickerColumnItem {
23
+ labelField?: string;
30
24
  readonly?: boolean;
31
- value: any;
32
- swipeDuration?: number | string;
33
- visibleItemCount?: number | string;
25
+ value?: PickerOption;
26
+ swipeDuration?: number;
27
+ visibleItemCount?: number;
28
+ itemHeight?: number;
34
29
  options?: PickerOption[];
35
- children?: any;
36
30
  optionRender?: (option: string | object | PickerOption) => React.ReactNode;
37
31
  onChange?: (
38
32
  value?: PickerOption | string,
39
33
  index?: number,
40
34
  confirm?: boolean
41
35
  ) => void;
42
- onClose?: () => void;
43
- onConfirm?: () => void;
44
- }
36
+ };
45
37
 
46
- export interface Column {
47
- values?: string[];
48
- className?: string;
49
- children?: Column[];
50
- disabled?: boolean;
51
- }
38
+ export interface PickerColumnProps extends PickerColumnItem, ThemeProps {}
52
39
 
53
40
  export type PickerOption = string | number | PickerObjectOption;
54
41
 
@@ -77,23 +64,17 @@ function getElementTranslateY(element: HTMLElement | null) {
77
64
  function isOptionDisabled(option: PickerOption) {
78
65
  return isObject(option) && option.disabled;
79
66
  }
80
-
67
+
81
68
  const PickerColumn = forwardRef<{}, PickerColumnProps>((props, ref) => {
82
69
  const {
83
- onClose,
84
- onConfirm,
85
- mobileClassName,
86
70
  visibleItemCount = 5,
71
+ itemHeight = 30,
87
72
  value,
88
73
  swipeDuration = 1000,
89
- labelField = 'value',
90
- translate: __,
74
+ labelField = 'text',
91
75
  options = [],
92
76
  classnames: cx
93
77
  } = props;
94
- let itemHeight = 24;
95
-
96
- const defaultIndex = options.findIndex(item => item === value);
97
78
 
98
79
  const root = useRef(null);
99
80
  const menuItemRef = useRef(null);
@@ -105,21 +86,9 @@ const PickerColumn = forwardRef<{}, PickerColumnProps>((props, ref) => {
105
86
  const touchStartTime = useRef(0);
106
87
  const momentumOffset = useRef(0);
107
88
 
108
- if (menuItemRef.current) {
109
- //@ts-ignore
110
- itemHeight = menuItemRef.current.getBoundingClientRect().height;
111
- }
112
-
113
- const [state, updateState] = useSetState({
114
- index: defaultIndex,
115
- offset: 0,
116
- duration: 0,
117
- options: cloneDeep(options)
118
- });
119
-
120
89
  const touch = useTouch();
121
-
122
- const count = state.options.length;
90
+ const count = options.length;
91
+ const defaultIndex = options.findIndex(item => item === value);
123
92
 
124
93
  const baseOffset = useMemo(() => {
125
94
  // 默认转入第一个选项的位置
@@ -128,20 +97,27 @@ const PickerColumn = forwardRef<{}, PickerColumnProps>((props, ref) => {
128
97
 
129
98
  const adjustIndex = (index: number) => {
130
99
  index = range(index, 0, count);
131
- if (!state.options) {
100
+ if (!options) {
132
101
  return;
133
102
  }
134
103
 
135
104
  for (let i = index; i < count; i += 1) {
136
- if (!isOptionDisabled(state.options[i])) return i;
105
+ if (!isOptionDisabled(options[i])) return i;
137
106
  }
138
107
  for (let i = index - 1; i >= 0; i -= 1) {
139
- if (!isOptionDisabled(state.options[i])) return i;
108
+ if (!isOptionDisabled(options[i])) return i;
140
109
  }
141
110
 
142
111
  return null;
143
112
  };
144
113
 
114
+ const [state, updateState] = useSetState({
115
+ index: adjustIndex(defaultIndex) || 0,
116
+ offset: 0,
117
+ duration: 0,
118
+ options: cloneDeep(options)
119
+ });
120
+
145
121
  /**
146
122
  *
147
123
  * @param index 索引
@@ -156,9 +132,14 @@ const PickerColumn = forwardRef<{}, PickerColumnProps>((props, ref) => {
156
132
  updateState({index});
157
133
 
158
134
  if (emitChange && props.onChange) {
159
- setTimeout(() => {
160
- props.onChange?.(options[index], index, confirm);
161
- }, 0);
135
+ requestAnimationFrame(
136
+ () => {
137
+ props.onChange?.(options[index], index, confirm);
138
+ }
139
+ );
140
+ // setTimeout(() => {
141
+ // props.onChange?.(options[index], index, confirm);
142
+ // }, 0);
162
143
  }
163
144
  };
164
145
 
@@ -175,7 +156,8 @@ const PickerColumn = forwardRef<{}, PickerColumnProps>((props, ref) => {
175
156
  const setOptions = (options: Array<PickerOption>) => {
176
157
  if (JSON.stringify(options) !== JSON.stringify(state.options)) {
177
158
  updateState({options});
178
- setIndex(defaultIndex, true);
159
+ const index = options.findIndex(item => item === value) || 0;
160
+ setIndex(index, true, true);
179
161
  }
180
162
  };
181
163
 
@@ -189,7 +171,7 @@ const PickerColumn = forwardRef<{}, PickerColumnProps>((props, ref) => {
189
171
  };
190
172
 
191
173
  const getOptionText = (option: [] | PickerOption) => {
192
- if (isObject(option) && props.labelField in option) {
174
+ if (isObject(option) && labelField in option) {
193
175
  //@ts-ignore
194
176
  return option[labelField];
195
177
  }
@@ -298,6 +280,10 @@ const PickerColumn = forwardRef<{}, PickerColumnProps>((props, ref) => {
298
280
  };
299
281
 
300
282
  const renderOptions = () => {
283
+ const style = {
284
+ height: `${itemHeight}px`,
285
+ lineHeight: `${itemHeight}px`
286
+ };
301
287
  return state.options.map((option, index: number) => {
302
288
  const text: string | PickerOption = getOptionText(option);
303
289
  const disabled = isOptionDisabled(option);
@@ -305,6 +291,7 @@ const PickerColumn = forwardRef<{}, PickerColumnProps>((props, ref) => {
305
291
  const data = {
306
292
  role: 'button',
307
293
  key: index,
294
+ style,
308
295
  tabIndex: disabled ? -1 : 0,
309
296
  className: props.classnames(`PickerColumns-columnItem`, {
310
297
  'is-disabled': disabled,
@@ -314,7 +301,7 @@ const PickerColumn = forwardRef<{}, PickerColumnProps>((props, ref) => {
314
301
  onClickItem(index);
315
302
  }
316
303
  };
317
-
304
+
318
305
  const childData = {
319
306
  className: 'text-ellipsis',
320
307
  children: text
@@ -335,7 +322,7 @@ const PickerColumn = forwardRef<{}, PickerColumnProps>((props, ref) => {
335
322
  const setValue = (value: string) => {
336
323
  const {options} = state;
337
324
  for (let i = 0; i < options.length; i += 1) {
338
- if (getOptionText(options[i]) === value) {
325
+ if (options[i] === value) {
339
326
  return setIndex(i);
340
327
  }
341
328
  }
@@ -348,7 +335,7 @@ const PickerColumn = forwardRef<{}, PickerColumnProps>((props, ref) => {
348
335
  );
349
336
 
350
337
  useEffect(() => {
351
- setIndex(defaultIndex, true);
338
+ setIndex(defaultIndex);
352
339
  }, [defaultIndex]);
353
340
 
354
341
  useUpdateEffect(() => {
@@ -369,61 +356,37 @@ const PickerColumn = forwardRef<{}, PickerColumnProps>((props, ref) => {
369
356
  transitionDuration: `${state.duration}ms`,
370
357
  transitionProperty: state.duration ? 'all' : 'none'
371
358
  };
372
-
373
- const wrapHeight = itemHeight * +visibleItemCount;
374
- const frameStyle = {height: `${itemHeight}px`};
375
- const columnsStyle = {height: `${wrapHeight}px`};
376
- const maskStyle = {
377
- backgroundSize: `100% ${(wrapHeight - itemHeight) / 2}px`
378
- };
379
-
380
359
  return (
381
- <div
382
- className={cx(mobileClassName, 'PickerColumns', 'PickerColumns-popOver')}
383
- >
384
- <div className={cx('PickerColumns-toolbar')}>
385
- <Button level="default" onClick={onClose}>
386
- {__('cancel')}
387
- </Button>
388
- <Button level="primary" onClick={onConfirm}>
389
- {__('confirm')}
390
- </Button>
391
- </div>
392
- <div className={cx('PickerColumns-columns')} style={columnsStyle}>
393
- <div
360
+ <div
394
361
  ref={root}
395
- className={props.classnames(props.className)}
362
+ className={props.classnames('PickerColumns', props.className)}
396
363
  onTouchStart={onTouchStart}
397
364
  onTouchMove={onTouchMove}
398
365
  onTouchEnd={onTouchEnd}
399
366
  onTouchCancel={onTouchEnd}
400
- >
367
+ >
401
368
  <ul
402
- ref={wrapper}
403
- style={wrapperStyle}
404
- className={props.classnames('PickerColumns-columnWrapper')}
405
- onTransitionEnd={stopMomentum}
369
+ ref={wrapper}
370
+ style={wrapperStyle}
371
+ className={props.classnames('PickerColumns-columnWrapper')}
372
+ onTransitionEnd={stopMomentum}
406
373
  >
407
- {renderOptions()}
374
+ {renderOptions()}
408
375
  </ul>
409
- </div>
410
- <div className={cx('PickerColumns-mask')} style={maskStyle}></div>
411
- <div className={cx('PickerColumns-frame')} style={frameStyle}></div>
412
376
  </div>
413
- </div>
414
377
  );
415
378
  });
416
379
 
417
380
  PickerColumn.defaultProps = {
418
381
  options: [],
419
382
  visibleItemCount: 5,
420
- swipeDuration: 1000
383
+ swipeDuration: 1000,
384
+ itemHeight: 30
421
385
  };
422
386
 
423
387
  export default themeable(
424
- localeable(
425
- uncontrollable(PickerColumn, {
426
- value: 'onChange'
427
- })
428
- )
388
+ uncontrollable(PickerColumn, {
389
+ value: 'onChange'
390
+ })
429
391
  );
392
+