@autobest-ui/components 1.2.1 → 1.5.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/esm/carousel/index.d.ts +13 -21
- package/esm/carousel/index.js +44 -77
- package/esm/carousel/style/index.css +1 -1
- package/esm/carousel/style/index.scss +1 -7
- package/esm/date-picker/calendar/grid/index.css +1 -1
- package/esm/date-picker/calendar/grid/index.js +17 -27
- package/esm/date-picker/calendar/grid/index.scss +4 -0
- package/esm/date-picker/calendar/index.d.ts +4 -0
- package/esm/date-picker/calendar/index.js +1 -1
- package/esm/date-picker/index.d.ts +17 -6
- package/esm/date-picker/index.js +62 -17
- package/esm/date-picker/style/index.css +1 -1
- package/esm/date-picker/style/index.js +0 -2
- package/esm/date-picker/style/index.scss +6 -1
- package/esm/guide/index.d.ts +4 -5
- package/esm/guide/index.js +4 -6
- package/esm/index.d.ts +3 -5
- package/esm/index.js +1 -3
- package/esm/input-number/index.d.ts +30 -17
- package/esm/input-number/index.js +116 -36
- package/esm/loading/index.d.ts +7 -2
- package/esm/loading/index.js +18 -24
- package/esm/loading/style/index.css +1 -1
- package/esm/loading/style/index.scss +0 -10
- package/esm/style.css +7 -23
- package/esm/table/body/BodyRow.d.ts +9 -3
- package/esm/table/body/BodyRow.js +6 -2
- package/esm/table/body/index.d.ts +2 -2
- package/esm/table/body/index.js +8 -7
- package/esm/table/header/HeaderCell.d.ts +2 -2
- package/esm/table/header/HeaderCell.js +15 -7
- package/esm/table/header/HeaderRow.d.ts +2 -2
- package/esm/table/index.d.ts +4 -4
- package/esm/table/index.js +3 -3
- package/esm/table/interface.d.ts +9 -3
- package/esm/table/style/index.css +1 -1
- package/esm/table/style/index.js +0 -2
- package/esm/table/style/index.scss +2 -0
- package/lib/carousel/index.d.ts +13 -21
- package/lib/carousel/index.js +45 -80
- package/lib/carousel/style/index.css +1 -1
- package/lib/carousel/style/index.scss +1 -7
- package/lib/date-picker/calendar/grid/index.css +1 -1
- package/lib/date-picker/calendar/grid/index.js +17 -28
- package/lib/date-picker/calendar/grid/index.scss +4 -0
- package/lib/date-picker/calendar/index.d.ts +4 -0
- package/lib/date-picker/calendar/index.js +1 -1
- package/lib/date-picker/index.d.ts +17 -6
- package/lib/date-picker/index.js +61 -17
- package/lib/date-picker/style/index.css +1 -1
- package/lib/date-picker/style/index.js +0 -2
- package/lib/date-picker/style/index.scss +6 -1
- package/lib/guide/index.d.ts +4 -5
- package/lib/guide/index.js +4 -7
- package/lib/index.d.ts +3 -5
- package/lib/index.js +2 -30
- package/lib/input-number/index.d.ts +30 -17
- package/lib/input-number/index.js +116 -36
- package/lib/loading/index.d.ts +7 -2
- package/lib/loading/index.js +18 -25
- package/lib/loading/style/index.css +1 -1
- package/lib/loading/style/index.scss +0 -10
- package/lib/style.css +7 -23
- package/lib/table/body/BodyRow.d.ts +9 -3
- package/lib/table/body/BodyRow.js +6 -2
- package/lib/table/body/index.d.ts +2 -2
- package/lib/table/body/index.js +8 -7
- package/lib/table/header/HeaderCell.d.ts +2 -2
- package/lib/table/header/HeaderCell.js +15 -8
- package/lib/table/header/HeaderRow.d.ts +2 -2
- package/lib/table/index.d.ts +4 -4
- package/lib/table/index.js +3 -3
- package/lib/table/interface.d.ts +9 -3
- package/lib/table/style/index.css +1 -1
- package/lib/table/style/index.js +0 -2
- package/lib/table/style/index.scss +2 -0
- package/package.json +2 -2
- package/esm/accordion/__stories__/style.css +0 -1
- package/esm/accordion/__stories__/style.scss +0 -59
- package/esm/affix/__stories__/style.css +0 -1
- package/esm/affix/__stories__/style.scss +0 -13
- package/esm/carousel/__stories__/style.css +0 -1
- package/esm/carousel/__stories__/style.scss +0 -41
- package/esm/collapse/__stories__/style.css +0 -1
- package/esm/collapse/__stories__/style.scss +0 -19
- package/esm/guide/__stories__/style.css +0 -1
- package/esm/guide/__stories__/style.scss +0 -14
- package/esm/icon/__stories__/iconNames.d.ts +0 -2
- package/esm/icon/__stories__/iconNames.js +0 -1
- package/esm/icon/__stories__/style.css +0 -1
- package/esm/icon/__stories__/style.scss +0 -40
- package/esm/icon/index.d.ts +0 -43
- package/esm/icon/index.js +0 -94
- package/esm/icon/style/index.css +0 -1
- package/esm/icon/style/index.d.ts +0 -1
- package/esm/icon/style/index.js +0 -5
- package/esm/icon/style/index.scss +0 -7
- package/esm/lazy-image/__stories__/style.css +0 -1
- package/esm/lazy-image/__stories__/style.scss +0 -9
- package/esm/loading-container/__stories__/style.css +0 -1
- package/esm/loading-container/__stories__/style.scss +0 -6
- package/esm/move/__stories__/style.css +0 -1
- package/esm/move/__stories__/style.scss +0 -6
- package/esm/popover/__stories__/style.css +0 -1
- package/esm/popover/__stories__/style.scss +0 -16
- package/esm/select/__stories__/style.css +0 -1
- package/esm/select/__stories__/style.scss +0 -8
- package/esm/skeleton/__stories__/style.css +0 -1
- package/esm/skeleton/__stories__/style.scss +0 -3
- package/esm/table/__stories__/style.css +0 -1
- package/esm/table/__stories__/style.scss +0 -34
- package/esm/tabs/__stories__/style.css +0 -1
- package/esm/tabs/__stories__/style.scss +0 -8
- package/esm/use-config/index.d.ts +0 -5
- package/esm/use-config/index.js +0 -13
- package/esm/use-config/style/index.css +0 -0
- package/esm/use-config/style/index.d.ts +0 -1
- package/esm/use-config/style/index.js +0 -1
- package/esm/use-config/style/index.scss +0 -0
- package/lib/accordion/__stories__/style.css +0 -1
- package/lib/accordion/__stories__/style.scss +0 -59
- package/lib/affix/__stories__/style.css +0 -1
- package/lib/affix/__stories__/style.scss +0 -13
- package/lib/carousel/__stories__/style.css +0 -1
- package/lib/carousel/__stories__/style.scss +0 -41
- package/lib/collapse/__stories__/style.css +0 -1
- package/lib/collapse/__stories__/style.scss +0 -19
- package/lib/guide/__stories__/style.css +0 -1
- package/lib/guide/__stories__/style.scss +0 -14
- package/lib/icon/__stories__/iconNames.d.ts +0 -2
- package/lib/icon/__stories__/iconNames.js +0 -8
- package/lib/icon/__stories__/style.css +0 -1
- package/lib/icon/__stories__/style.scss +0 -40
- package/lib/icon/index.d.ts +0 -43
- package/lib/icon/index.js +0 -111
- package/lib/icon/style/index.css +0 -1
- package/lib/icon/style/index.d.ts +0 -1
- package/lib/icon/style/index.js +0 -7
- package/lib/icon/style/index.scss +0 -7
- package/lib/lazy-image/__stories__/style.css +0 -1
- package/lib/lazy-image/__stories__/style.scss +0 -9
- package/lib/loading-container/__stories__/style.css +0 -1
- package/lib/loading-container/__stories__/style.scss +0 -6
- package/lib/move/__stories__/style.css +0 -1
- package/lib/move/__stories__/style.scss +0 -6
- package/lib/popover/__stories__/style.css +0 -1
- package/lib/popover/__stories__/style.scss +0 -16
- package/lib/select/__stories__/style.css +0 -1
- package/lib/select/__stories__/style.scss +0 -8
- package/lib/skeleton/__stories__/style.css +0 -1
- package/lib/skeleton/__stories__/style.scss +0 -3
- package/lib/table/__stories__/style.css +0 -1
- package/lib/table/__stories__/style.scss +0 -34
- package/lib/tabs/__stories__/style.css +0 -1
- package/lib/tabs/__stories__/style.scss +0 -8
- package/lib/use-config/index.d.ts +0 -5
- package/lib/use-config/index.js +0 -21
- package/lib/use-config/style/index.css +0 -0
- package/lib/use-config/style/index.d.ts +0 -1
- package/lib/use-config/style/index.js +0 -1
- package/lib/use-config/style/index.scss +0 -0
|
@@ -8,12 +8,17 @@ $namespace: ab-date-picker;
|
|
|
8
8
|
font-size: .14rem;
|
|
9
9
|
padding: .04rem;
|
|
10
10
|
width: 1.44rem;
|
|
11
|
+
|
|
12
|
+
&.#{$namespace}-error {
|
|
13
|
+
background: #fffacd;
|
|
14
|
+
}
|
|
11
15
|
}
|
|
12
16
|
|
|
13
17
|
&-icon {
|
|
18
|
+
color: #606060;
|
|
14
19
|
position: absolute;
|
|
15
20
|
right: 0.05rem;
|
|
16
21
|
top: 50%;
|
|
17
22
|
transform: translateY(-50%);
|
|
18
23
|
}
|
|
19
|
-
}
|
|
24
|
+
}
|
package/esm/guide/index.d.ts
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
export interface GuideProps {
|
|
3
|
+
/**
|
|
4
|
+
* 图片路径
|
|
5
|
+
*/
|
|
6
|
+
imgSrc: string;
|
|
3
7
|
/**
|
|
4
8
|
* 是否显示遮罩层
|
|
5
9
|
*/
|
|
@@ -12,10 +16,6 @@ export interface GuideProps {
|
|
|
12
16
|
* 是否显示带箭头的图片,图片默认显示在子元素上方,水平居中
|
|
13
17
|
*/
|
|
14
18
|
loadablePointer?: boolean;
|
|
15
|
-
/**
|
|
16
|
-
* 图片路径
|
|
17
|
-
*/
|
|
18
|
-
img?: string;
|
|
19
19
|
/**
|
|
20
20
|
* 图片默认显示在子元素上方,水平居中
|
|
21
21
|
*/
|
|
@@ -43,7 +43,6 @@ declare class Guide extends React.Component<GuideProps, GuideStates> {
|
|
|
43
43
|
imgRef: React.RefObject<HTMLImageElement>;
|
|
44
44
|
static defaultProps: {
|
|
45
45
|
loadablePointer: boolean;
|
|
46
|
-
img: string;
|
|
47
46
|
position: string;
|
|
48
47
|
translateX: number;
|
|
49
48
|
translateY: number;
|
package/esm/guide/index.js
CHANGED
|
@@ -29,7 +29,6 @@ import classNames from 'classnames';
|
|
|
29
29
|
import { findDOMNode } from 'react-dom';
|
|
30
30
|
import { getOffsetAndSize } from '@autobest-ui/utils';
|
|
31
31
|
import Portal from '../portal';
|
|
32
|
-
import UseConfig from '../use-config';
|
|
33
32
|
import Mask from '../mask';
|
|
34
33
|
|
|
35
34
|
var Guide =
|
|
@@ -101,7 +100,7 @@ function (_super) {
|
|
|
101
100
|
|
|
102
101
|
var _a = this.props,
|
|
103
102
|
loadablePointer = _a.loadablePointer,
|
|
104
|
-
|
|
103
|
+
imgSrc = _a.imgSrc,
|
|
105
104
|
position = _a.position,
|
|
106
105
|
visible = _a.visible,
|
|
107
106
|
translateX = _a.translateX,
|
|
@@ -109,7 +108,7 @@ function (_super) {
|
|
|
109
108
|
|
|
110
109
|
if (loadablePointer && visible) {
|
|
111
110
|
var image_1 = new Image();
|
|
112
|
-
image_1.src =
|
|
111
|
+
image_1.src = imgSrc;
|
|
113
112
|
|
|
114
113
|
image_1.onload = function () {
|
|
115
114
|
var element = _this.getElement();
|
|
@@ -156,7 +155,7 @@ function (_super) {
|
|
|
156
155
|
var _a = this.props,
|
|
157
156
|
visible = _a.visible,
|
|
158
157
|
loadablePointer = _a.loadablePointer,
|
|
159
|
-
|
|
158
|
+
imgSrc = _a.imgSrc;
|
|
160
159
|
var _b = this.state,
|
|
161
160
|
top = _b.top,
|
|
162
161
|
left = _b.left;
|
|
@@ -176,7 +175,7 @@ function (_super) {
|
|
|
176
175
|
}), loadablePointer ? React.createElement("img", {
|
|
177
176
|
style: style,
|
|
178
177
|
className: cls + "-icon",
|
|
179
|
-
src:
|
|
178
|
+
src: imgSrc,
|
|
180
179
|
alt: "selection pointer",
|
|
181
180
|
ref: this.imgRef
|
|
182
181
|
}) : null));
|
|
@@ -207,7 +206,6 @@ function (_super) {
|
|
|
207
206
|
|
|
208
207
|
Guide.defaultProps = {
|
|
209
208
|
loadablePointer: false,
|
|
210
|
-
img: UseConfig.assetCommonUiUrl + "/images/vehicle_pointer.png",
|
|
211
209
|
position: 'center',
|
|
212
210
|
translateX: 0,
|
|
213
211
|
translateY: 0,
|
package/esm/index.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
export { default as UseConfig } from './use-config';
|
|
2
1
|
export type { AccordionProps } from './accordion';
|
|
3
2
|
export { default as Accordion } from './accordion';
|
|
4
3
|
export type { EllipsisProps, EllipsisLinesType } from './ellipsis';
|
|
@@ -11,8 +10,6 @@ export type { PopoverPlacement, PopoverTriggerType, PopoverProps } from './popov
|
|
|
11
10
|
export { default as Popover } from './popover';
|
|
12
11
|
export type { TooltipProps, TooltipPlacement, TooltipTriggerType } from './tooltip';
|
|
13
12
|
export { default as Tooltip } from './tooltip';
|
|
14
|
-
export type { IconProps } from './icon';
|
|
15
|
-
export { default as Icon } from './icon';
|
|
16
13
|
export type { SkeletonProps } from './skeleton';
|
|
17
14
|
export { default as Skeleton } from './skeleton';
|
|
18
15
|
export type { MoveProps } from './move';
|
|
@@ -26,7 +23,7 @@ export { default as Confirm } from './confirm';
|
|
|
26
23
|
export type { CollapseProps } from './collapse';
|
|
27
24
|
export { default as Collapse } from './collapse';
|
|
28
25
|
export type { CarouselProps } from './carousel';
|
|
29
|
-
export { default as Carousel
|
|
26
|
+
export { default as Carousel } from './carousel';
|
|
30
27
|
export type { GuideProps } from './guide';
|
|
31
28
|
export { default as Guide } from './guide';
|
|
32
29
|
export type { DrawerProps } from './drawer';
|
|
@@ -43,7 +40,8 @@ export type { ScriptAttributes, ScriptProps } from './script';
|
|
|
43
40
|
export { default as Script } from './script';
|
|
44
41
|
export type { MessageProps } from './message';
|
|
45
42
|
export { default as Message } from './message';
|
|
46
|
-
export type { TableProps } from './table';
|
|
43
|
+
export type { TableProps, TableRowSelectionInfo } from './table';
|
|
44
|
+
export type { TableColumnInfo, TableColumnOnRenderReturnObjectInfo } from './table/interface';
|
|
47
45
|
export { default as Table } from './table';
|
|
48
46
|
export type { DatePickerProps } from './date-picker';
|
|
49
47
|
export { default as DatePicker } from './date-picker';
|
package/esm/index.js
CHANGED
|
@@ -1,18 +1,16 @@
|
|
|
1
|
-
export { default as UseConfig } from './use-config';
|
|
2
1
|
export { default as Accordion } from './accordion';
|
|
3
2
|
export { default as Ellipsis } from './ellipsis';
|
|
4
3
|
export { default as Affix } from './affix';
|
|
5
4
|
export { default as Modal } from './modal';
|
|
6
5
|
export { default as Popover } from './popover';
|
|
7
6
|
export { default as Tooltip } from './tooltip';
|
|
8
|
-
export { default as Icon } from './icon';
|
|
9
7
|
export { default as Skeleton } from './skeleton';
|
|
10
8
|
export { default as Move } from './move';
|
|
11
9
|
export { default as ShowMore } from './show-more';
|
|
12
10
|
export { default as Select } from './select';
|
|
13
11
|
export { default as Confirm } from './confirm';
|
|
14
12
|
export { default as Collapse } from './collapse';
|
|
15
|
-
export { default as Carousel
|
|
13
|
+
export { default as Carousel } from './carousel';
|
|
16
14
|
export { default as Guide } from './guide';
|
|
17
15
|
export { default as Drawer } from './drawer';
|
|
18
16
|
export { default as InputNumber } from './input-number';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { AddListenerEventHandler } from '@autobest-ui/utils';
|
|
3
|
-
interface
|
|
2
|
+
import { debounce, AddListenerEventHandler } from '@autobest-ui/utils';
|
|
3
|
+
interface OnChangeHandler {
|
|
4
4
|
(value: string, name?: string): void;
|
|
5
5
|
}
|
|
6
6
|
interface ChangeEvent {
|
|
@@ -12,7 +12,7 @@ export interface InputNumberProps extends Omit<React.InputHTMLAttributes<any>, '
|
|
|
12
12
|
/**
|
|
13
13
|
* 值修改后的回调函数,用于修改value属性
|
|
14
14
|
*/
|
|
15
|
-
onChange:
|
|
15
|
+
onChange: OnChangeHandler;
|
|
16
16
|
/**
|
|
17
17
|
* input样式
|
|
18
18
|
*/
|
|
@@ -30,7 +30,8 @@ export interface InputNumberProps extends Omit<React.InputHTMLAttributes<any>, '
|
|
|
30
30
|
*/
|
|
31
31
|
max?: number;
|
|
32
32
|
/**
|
|
33
|
-
*
|
|
33
|
+
* 打包值,向上取整,不赋值或者赋值为0表示不做取整操作
|
|
34
|
+
* 注:packMultiple不允许传小数
|
|
34
35
|
*/
|
|
35
36
|
packMultiple?: number;
|
|
36
37
|
/**
|
|
@@ -38,9 +39,13 @@ export interface InputNumberProps extends Omit<React.InputHTMLAttributes<any>, '
|
|
|
38
39
|
*/
|
|
39
40
|
disabled?: boolean;
|
|
40
41
|
/**
|
|
41
|
-
*
|
|
42
|
+
* 可输入的小数位数,0或没有值表示只能输入整数
|
|
42
43
|
*/
|
|
43
|
-
|
|
44
|
+
digital?: number;
|
|
45
|
+
/**
|
|
46
|
+
* 为true则自动补全小数位数
|
|
47
|
+
*/
|
|
48
|
+
padDigital?: boolean;
|
|
44
49
|
/**
|
|
45
50
|
* 输入框默认字符大小
|
|
46
51
|
*/
|
|
@@ -56,11 +61,11 @@ export interface InputNumberProps extends Omit<React.InputHTMLAttributes<any>, '
|
|
|
56
61
|
/**
|
|
57
62
|
* packMultiple 有值时,判断前的回调函数
|
|
58
63
|
*/
|
|
59
|
-
onChangePackMultipleBefore?:
|
|
64
|
+
onChangePackMultipleBefore?: OnChangeHandler;
|
|
60
65
|
/**
|
|
61
66
|
* packMultiple 有值时,判断后的回调函数
|
|
62
67
|
*/
|
|
63
|
-
onChangePackMultipleAfter?:
|
|
68
|
+
onChangePackMultipleAfter?: OnChangeHandler;
|
|
64
69
|
/**
|
|
65
70
|
* 是否需要显示增加按钮
|
|
66
71
|
*/
|
|
@@ -70,10 +75,6 @@ interface InputNumberStates {
|
|
|
70
75
|
enter: boolean;
|
|
71
76
|
focus: boolean;
|
|
72
77
|
}
|
|
73
|
-
interface DebounceRef {
|
|
74
|
-
(value: string): void;
|
|
75
|
-
cancel: () => void;
|
|
76
|
-
}
|
|
77
78
|
interface LocationInfo {
|
|
78
79
|
left: number;
|
|
79
80
|
top: number;
|
|
@@ -86,13 +87,15 @@ declare class InputNumber extends React.Component<InputNumberProps, InputNumberS
|
|
|
86
87
|
name: string;
|
|
87
88
|
size: number;
|
|
88
89
|
disabled: boolean;
|
|
89
|
-
|
|
90
|
+
digital: number;
|
|
91
|
+
padDigital: boolean;
|
|
90
92
|
delay: number;
|
|
91
93
|
visibleButton: boolean;
|
|
92
94
|
};
|
|
93
95
|
constructor(props: InputNumberProps);
|
|
94
96
|
currentRef: React.RefObject<HTMLLabelElement>;
|
|
95
|
-
|
|
97
|
+
changePackMultipleValueDebounce: ReturnType<typeof debounce>;
|
|
98
|
+
padDigitalDebounce: ReturnType<typeof debounce>;
|
|
96
99
|
addLocationInfo: LocationInfo;
|
|
97
100
|
subLocationInfo: LocationInfo;
|
|
98
101
|
mouseUpHandler: AddListenerEventHandler;
|
|
@@ -120,10 +123,20 @@ declare class InputNumber extends React.Component<InputNumberProps, InputNumberS
|
|
|
120
123
|
isInside: (ev: React.MouseEvent<Element, MouseEvent>, locationInfo: LocationInfo) => boolean;
|
|
121
124
|
getLocationInfo: () => void;
|
|
122
125
|
getCurrentValue: (value: string) => number;
|
|
126
|
+
getPadDigitalValue: (value: string) => string;
|
|
123
127
|
onChangePackMultipleValue: (value: string) => void;
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
128
|
+
onPadDigital: (value: any) => void;
|
|
129
|
+
getPadDigitalDebounce: () => {
|
|
130
|
+
(...arg: any[]): void;
|
|
131
|
+
cancel(): void;
|
|
132
|
+
};
|
|
133
|
+
getChangePackMultipleValueDebounce: () => {
|
|
134
|
+
(...arg: any[]): void;
|
|
135
|
+
cancel(): void;
|
|
136
|
+
};
|
|
137
|
+
callback: (value: string, ignoreDelay?: any) => void;
|
|
138
|
+
onValueChange: (ev: ChangeEvent, ignoreDelay?: any) => void;
|
|
139
|
+
getValueCalculate: (value: number, offset: number) => number;
|
|
127
140
|
onAdd: () => void;
|
|
128
141
|
onSub: () => void;
|
|
129
142
|
renderButton: () => JSX.Element;
|
|
@@ -43,7 +43,7 @@ var __assign = this && this.__assign || function () {
|
|
|
43
43
|
import React from 'react';
|
|
44
44
|
import classNames from 'classnames';
|
|
45
45
|
import { isBlank, debounce, getOffsetAndSize, addEventListener } from '@autobest-ui/utils';
|
|
46
|
-
var cls = 'ab-input-number';
|
|
46
|
+
var cls = 'ab-input-number'; // TODO: 重构组件
|
|
47
47
|
|
|
48
48
|
var InputNumber =
|
|
49
49
|
/** @class */
|
|
@@ -305,6 +305,19 @@ function (_super) {
|
|
|
305
305
|
return ceilNumber;
|
|
306
306
|
};
|
|
307
307
|
|
|
308
|
+
_this.getPadDigitalValue = function (value) {
|
|
309
|
+
var _a = _this.props,
|
|
310
|
+
digital = _a.digital,
|
|
311
|
+
padDigital = _a.padDigital;
|
|
312
|
+
|
|
313
|
+
if (!padDigital || isBlank(value) || !digital) {
|
|
314
|
+
return value;
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
var resultArr = value.split('.');
|
|
318
|
+
return resultArr[0] + "." + (resultArr[1] || '').padEnd(digital, '0');
|
|
319
|
+
};
|
|
320
|
+
|
|
308
321
|
_this.onChangePackMultipleValue = function (value) {
|
|
309
322
|
var currentValue = _this.getCurrentValue(value).toString();
|
|
310
323
|
|
|
@@ -319,60 +332,97 @@ function (_super) {
|
|
|
319
332
|
}
|
|
320
333
|
};
|
|
321
334
|
|
|
322
|
-
_this.
|
|
323
|
-
|
|
324
|
-
|
|
335
|
+
_this.onPadDigital = function (value) {
|
|
336
|
+
var currentValue = _this.getPadDigitalValue(value);
|
|
337
|
+
|
|
338
|
+
var _a = _this.props,
|
|
339
|
+
onChange = _a.onChange,
|
|
340
|
+
name = _a.name;
|
|
341
|
+
|
|
342
|
+
if (value !== currentValue) {
|
|
343
|
+
onChange(currentValue, name);
|
|
325
344
|
}
|
|
345
|
+
};
|
|
346
|
+
|
|
347
|
+
_this.getPadDigitalDebounce = function () {
|
|
348
|
+
if (_this.padDigitalDebounce) {
|
|
349
|
+
return _this.padDigitalDebounce;
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
_this.padDigitalDebounce = debounce(_this.onPadDigital, _this.props.delay);
|
|
353
|
+
return _this.padDigitalDebounce;
|
|
354
|
+
};
|
|
326
355
|
|
|
327
|
-
|
|
328
|
-
|
|
356
|
+
_this.getChangePackMultipleValueDebounce = function () {
|
|
357
|
+
if (_this.changePackMultipleValueDebounce) {
|
|
358
|
+
return _this.changePackMultipleValueDebounce;
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
_this.changePackMultipleValueDebounce = debounce(_this.onChangePackMultipleValue, _this.props.delay);
|
|
362
|
+
return _this.changePackMultipleValueDebounce;
|
|
329
363
|
};
|
|
330
364
|
|
|
331
|
-
_this.callback = function (value) {
|
|
365
|
+
_this.callback = function (value, ignoreDelay) {
|
|
332
366
|
var _a = _this.props,
|
|
333
367
|
name = _a.name,
|
|
334
368
|
onChange = _a.onChange,
|
|
335
|
-
onChangePackMultipleBefore = _a.onChangePackMultipleBefore
|
|
336
|
-
|
|
369
|
+
onChangePackMultipleBefore = _a.onChangePackMultipleBefore,
|
|
370
|
+
packMultiple = _a.packMultiple,
|
|
371
|
+
padDigital = _a.padDigital;
|
|
337
372
|
|
|
338
|
-
if (onChange) {
|
|
373
|
+
if (onChange && value !== _this.props.value) {
|
|
339
374
|
onChange(value, name);
|
|
340
375
|
}
|
|
341
376
|
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
if (!isBlank(packMultiple) && !isBlank(value) && valueNumber % packMultiple !== 0) {
|
|
377
|
+
if (packMultiple && !isBlank(value) && parseFloat(value) % packMultiple !== 0) {
|
|
345
378
|
if (onChangePackMultipleBefore) {
|
|
346
379
|
onChangePackMultipleBefore(value, name);
|
|
347
380
|
}
|
|
348
381
|
|
|
349
|
-
|
|
382
|
+
if (ignoreDelay) {
|
|
383
|
+
_this.onChangePackMultipleValue(value);
|
|
384
|
+
} else {
|
|
385
|
+
_this.getChangePackMultipleValueDebounce()(value);
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
return;
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
if (padDigital) {
|
|
392
|
+
if (ignoreDelay) {
|
|
393
|
+
_this.onPadDigital(value);
|
|
394
|
+
|
|
395
|
+
return;
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
_this.getPadDigitalDebounce()(value);
|
|
350
399
|
}
|
|
351
400
|
};
|
|
352
401
|
|
|
353
|
-
_this.onValueChange = function (ev) {
|
|
354
|
-
if (_this.
|
|
355
|
-
_this.
|
|
402
|
+
_this.onValueChange = function (ev, ignoreDelay) {
|
|
403
|
+
if (_this.changePackMultipleValueDebounce) {
|
|
404
|
+
_this.changePackMultipleValueDebounce.cancel();
|
|
356
405
|
}
|
|
357
406
|
|
|
358
407
|
var _a = _this.props,
|
|
359
408
|
min = _a.min,
|
|
360
409
|
max = _a.max,
|
|
361
|
-
|
|
410
|
+
digital = _a.digital,
|
|
362
411
|
value = _a.value;
|
|
363
|
-
var currentValue = ev.target.value.toString();
|
|
412
|
+
var currentValue = ev.target.value.toString(); // 输入为空
|
|
364
413
|
|
|
365
414
|
if (isBlank(currentValue)) {
|
|
366
|
-
_this.callback('');
|
|
415
|
+
_this.callback('', ignoreDelay);
|
|
367
416
|
|
|
368
417
|
return;
|
|
369
418
|
}
|
|
370
419
|
|
|
371
|
-
var preValue = value.toString();
|
|
420
|
+
var preValue = value.toString(); // 输入的不是数字格式
|
|
421
|
+
|
|
372
422
|
var reg = /^-$|(^(-?\d+)(\.\d*)?)$/;
|
|
373
423
|
|
|
374
424
|
if (!reg.test(currentValue)) {
|
|
375
|
-
_this.callback(preValue);
|
|
425
|
+
_this.callback(preValue, ignoreDelay);
|
|
376
426
|
|
|
377
427
|
return;
|
|
378
428
|
} // 0开头后面直接是数字,没有点如:011, 这是不合法的
|
|
@@ -381,41 +431,59 @@ function (_super) {
|
|
|
381
431
|
var zeroReg = /^0\d+$/;
|
|
382
432
|
|
|
383
433
|
if (zeroReg.test(currentValue)) {
|
|
384
|
-
_this.callback(preValue);
|
|
434
|
+
_this.callback(preValue, ignoreDelay);
|
|
385
435
|
|
|
386
436
|
return;
|
|
437
|
+
} // 小数位数限制
|
|
438
|
+
|
|
439
|
+
|
|
440
|
+
if (digital) {
|
|
441
|
+
currentValue = new RegExp("[^.]+([.](\\d{0," + digital + "}))?").exec(currentValue)[0].toString();
|
|
387
442
|
}
|
|
388
443
|
|
|
389
444
|
var valueNumber = parseFloat(currentValue);
|
|
390
445
|
|
|
391
446
|
if (!isBlank(min)) {
|
|
392
447
|
if (min > valueNumber) {
|
|
393
|
-
_this.callback(preValue);
|
|
448
|
+
_this.callback(preValue, ignoreDelay);
|
|
394
449
|
|
|
395
450
|
return;
|
|
396
451
|
} // 如果min>= 0, 将阻止输入-
|
|
397
452
|
|
|
398
453
|
|
|
399
454
|
if (min >= 0 && currentValue.indexOf('-') > -1) {
|
|
400
|
-
_this.callback('');
|
|
455
|
+
_this.callback('', ignoreDelay);
|
|
401
456
|
|
|
402
457
|
return;
|
|
403
458
|
}
|
|
404
459
|
}
|
|
405
460
|
|
|
406
461
|
if (!isBlank(max) && max < valueNumber) {
|
|
407
|
-
_this.callback(preValue);
|
|
462
|
+
_this.callback(preValue, ignoreDelay);
|
|
408
463
|
|
|
409
464
|
return;
|
|
410
465
|
}
|
|
411
466
|
|
|
412
|
-
if (
|
|
413
|
-
_this.callback(preValue);
|
|
467
|
+
if (!digital && currentValue.indexOf('.') > -1) {
|
|
468
|
+
_this.callback(preValue, ignoreDelay);
|
|
414
469
|
|
|
415
470
|
return;
|
|
416
471
|
}
|
|
417
472
|
|
|
418
|
-
_this.callback(currentValue);
|
|
473
|
+
_this.callback(currentValue, ignoreDelay);
|
|
474
|
+
};
|
|
475
|
+
|
|
476
|
+
_this.getValueCalculate = function (value, offset) {
|
|
477
|
+
var valueStr = value.toString();
|
|
478
|
+
var offsetStr = offset.toString();
|
|
479
|
+
|
|
480
|
+
if (valueStr.indexOf('.') < 0 && offsetStr.indexOf('.') < 0) {
|
|
481
|
+
return value + offset;
|
|
482
|
+
}
|
|
483
|
+
|
|
484
|
+
var digital = _this.props.digital;
|
|
485
|
+
var powValue = Math.pow(10, digital);
|
|
486
|
+
return Math.round((value + offset) * powValue) / powValue;
|
|
419
487
|
};
|
|
420
488
|
|
|
421
489
|
_this.onAdd = function () {
|
|
@@ -426,7 +494,7 @@ function (_super) {
|
|
|
426
494
|
|
|
427
495
|
var ev = {
|
|
428
496
|
target: {
|
|
429
|
-
value: (
|
|
497
|
+
value: _this.getPadDigitalValue(_this.getValueCalculate(Number(value), step).toString())
|
|
430
498
|
}
|
|
431
499
|
};
|
|
432
500
|
|
|
@@ -440,7 +508,7 @@ function (_super) {
|
|
|
440
508
|
var step = packMultiple || 1;
|
|
441
509
|
var ev = {
|
|
442
510
|
target: {
|
|
443
|
-
value: (
|
|
511
|
+
value: _this.getPadDigitalValue(_this.getValueCalculate(Number(value), step * -1).toString())
|
|
444
512
|
}
|
|
445
513
|
};
|
|
446
514
|
|
|
@@ -473,6 +541,11 @@ function (_super) {
|
|
|
473
541
|
|
|
474
542
|
InputNumber.prototype.componentDidMount = function () {
|
|
475
543
|
this.addMouseMoveListener();
|
|
544
|
+
this.onValueChange({
|
|
545
|
+
target: {
|
|
546
|
+
value: this.props.value
|
|
547
|
+
}
|
|
548
|
+
}, true);
|
|
476
549
|
};
|
|
477
550
|
|
|
478
551
|
InputNumber.prototype.componentWillUnmount = function () {
|
|
@@ -486,9 +559,14 @@ function (_super) {
|
|
|
486
559
|
this.mouseMoveHandler = null;
|
|
487
560
|
}
|
|
488
561
|
|
|
489
|
-
if (this.
|
|
490
|
-
this.
|
|
491
|
-
this.
|
|
562
|
+
if (this.padDigitalDebounce) {
|
|
563
|
+
this.padDigitalDebounce.cancel();
|
|
564
|
+
this.padDigitalDebounce = null;
|
|
565
|
+
}
|
|
566
|
+
|
|
567
|
+
if (this.changePackMultipleValueDebounce) {
|
|
568
|
+
this.changePackMultipleValueDebounce.cancel();
|
|
569
|
+
this.changePackMultipleValueDebounce = null;
|
|
492
570
|
}
|
|
493
571
|
};
|
|
494
572
|
|
|
@@ -497,7 +575,8 @@ function (_super) {
|
|
|
497
575
|
|
|
498
576
|
delete copyProps.onChangePackMultipleBefore;
|
|
499
577
|
delete copyProps.onChangePackMultipleAfter;
|
|
500
|
-
delete copyProps.
|
|
578
|
+
delete copyProps.digital;
|
|
579
|
+
delete copyProps.padDigital;
|
|
501
580
|
delete copyProps.packMultiple;
|
|
502
581
|
delete copyProps.visibleButton;
|
|
503
582
|
delete copyProps.onChange;
|
|
@@ -539,7 +618,8 @@ function (_super) {
|
|
|
539
618
|
name: '',
|
|
540
619
|
size: 3,
|
|
541
620
|
disabled: false,
|
|
542
|
-
|
|
621
|
+
digital: 0,
|
|
622
|
+
padDigital: false,
|
|
543
623
|
delay: 1000,
|
|
544
624
|
visibleButton: false
|
|
545
625
|
};
|
package/esm/loading/index.d.ts
CHANGED
|
@@ -1,8 +1,13 @@
|
|
|
1
|
+
import React from 'react';
|
|
1
2
|
export interface LoadingProps {
|
|
2
3
|
/**
|
|
3
|
-
* loading
|
|
4
|
+
* loading 样式
|
|
4
5
|
*/
|
|
5
|
-
|
|
6
|
+
className?: string;
|
|
7
|
+
/**
|
|
8
|
+
* 自定义loading, 需要补全自定义元素样式
|
|
9
|
+
*/
|
|
10
|
+
customIcon?: React.ReactElement;
|
|
6
11
|
/**
|
|
7
12
|
* loading开始后自动隐藏的时间,单位:毫秒
|
|
8
13
|
*/
|
package/esm/loading/index.js
CHANGED
|
@@ -18,24 +18,18 @@ import React from 'react';
|
|
|
18
18
|
import classNames from 'classnames';
|
|
19
19
|
import ReactDOM from 'react-dom';
|
|
20
20
|
import { canUseDOM } from '@autobest-ui/utils';
|
|
21
|
-
import UseConfig from '../use-config';
|
|
22
21
|
import LoadingIcon from '../loading-icon'; // 缓存创建的loading元素
|
|
23
22
|
|
|
24
23
|
var loadingElement = null;
|
|
25
24
|
var loadingTimer = null;
|
|
26
25
|
var closeTimer = null;
|
|
26
|
+
var prevCustomIcon = null;
|
|
27
27
|
var cls = 'ab-loading';
|
|
28
28
|
|
|
29
|
-
function getLoadingContainer(
|
|
30
|
-
var _a;
|
|
31
|
-
|
|
29
|
+
function getLoadingContainer(customIcon, className) {
|
|
32
30
|
return React.createElement("div", {
|
|
33
|
-
className: classNames(cls + "-wrap",
|
|
34
|
-
},
|
|
35
|
-
className: cls + "-content",
|
|
36
|
-
src: UseConfig.assetCommonUiUrl + "/images/p_loading_rect.gif",
|
|
37
|
-
alt: "loading..."
|
|
38
|
-
}) : React.createElement(LoadingIcon, {
|
|
31
|
+
className: classNames(cls + "-wrap", className)
|
|
32
|
+
}, customIcon || React.createElement(LoadingIcon, {
|
|
39
33
|
className: cls + "-content"
|
|
40
34
|
}));
|
|
41
35
|
} // openIds 容器
|
|
@@ -44,12 +38,11 @@ function getLoadingContainer(isRectLoading) {
|
|
|
44
38
|
var openIds = []; // closeIds 容器
|
|
45
39
|
|
|
46
40
|
var closeIds = [];
|
|
47
|
-
var prevIsRectLoading = false;
|
|
48
41
|
|
|
49
|
-
function createLoading(
|
|
42
|
+
function createLoading(customIcon, className) {
|
|
50
43
|
loadingElement = document.createElement('div');
|
|
51
44
|
document.body.appendChild(loadingElement);
|
|
52
|
-
ReactDOM.render(getLoadingContainer(
|
|
45
|
+
ReactDOM.render(getLoadingContainer(customIcon, className), loadingElement);
|
|
53
46
|
}
|
|
54
47
|
|
|
55
48
|
var Loading =
|
|
@@ -63,24 +56,25 @@ function () {
|
|
|
63
56
|
}
|
|
64
57
|
|
|
65
58
|
config = __assign({
|
|
66
|
-
isRectLoading: false,
|
|
67
59
|
expire: 0
|
|
68
|
-
}, config); //
|
|
60
|
+
}, config); // 防止重复创建或自定义loading icon,重新创建
|
|
69
61
|
|
|
70
62
|
if (!loadingElement) {
|
|
71
|
-
createLoading(config.
|
|
72
|
-
} else if (
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
63
|
+
createLoading(config.customIcon, config.className);
|
|
64
|
+
} else if (config.customIcon || config.customIcon !== prevCustomIcon) {
|
|
65
|
+
if (loadingElement) {
|
|
66
|
+
try {
|
|
67
|
+
document.body.removeChild(loadingElement);
|
|
68
|
+
loadingElement = null;
|
|
69
|
+
} catch (e) {}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
createLoading(config.customIcon, config.className);
|
|
79
73
|
} else {
|
|
80
74
|
loadingElement.style.display = 'block';
|
|
81
75
|
}
|
|
82
76
|
|
|
83
|
-
|
|
77
|
+
prevCustomIcon = config.customIcon; // 如果配置中有expire且大于0
|
|
84
78
|
// 将会在到达时间后自动关闭,不用手动再关闭(不需要再close())
|
|
85
79
|
|
|
86
80
|
if (config.expire > 0) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
.ab-loading-wrap{position:fixed;top:0;left:0;z-index:9999;background-color:rgba(255,255,255,.7);height:100%;width:100%}.ab-loading-wrap .ab-loading-content{position:absolute;left:50%;top:50%;display:block;width:.31rem;height:.31rem;transform:translate3d(-50%,-50%,0)}
|
|
1
|
+
.ab-loading-wrap{position:fixed;top:0;left:0;z-index:9999;background-color:rgba(255,255,255,.7);height:100%;width:100%}.ab-loading-wrap .ab-loading-content{position:absolute;left:50%;top:50%;display:block;width:.31rem;height:.31rem;transform:translate3d(-50%,-50%,0)}
|
|
@@ -18,14 +18,4 @@ $namespace: ab-loading;
|
|
|
18
18
|
height: .31rem;
|
|
19
19
|
transform: translate3d(-50%, -50%, 0);
|
|
20
20
|
}
|
|
21
|
-
|
|
22
|
-
&.#{$namespace}-rect-loading {
|
|
23
|
-
background-color: rgba(#000, .7);
|
|
24
|
-
|
|
25
|
-
.#{$namespace}-content {
|
|
26
|
-
top: 10%;
|
|
27
|
-
width: 1.6rem;
|
|
28
|
-
height: .24rem;
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
21
|
}
|