@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.
Files changed (161) hide show
  1. package/esm/carousel/index.d.ts +13 -21
  2. package/esm/carousel/index.js +44 -77
  3. package/esm/carousel/style/index.css +1 -1
  4. package/esm/carousel/style/index.scss +1 -7
  5. package/esm/date-picker/calendar/grid/index.css +1 -1
  6. package/esm/date-picker/calendar/grid/index.js +17 -27
  7. package/esm/date-picker/calendar/grid/index.scss +4 -0
  8. package/esm/date-picker/calendar/index.d.ts +4 -0
  9. package/esm/date-picker/calendar/index.js +1 -1
  10. package/esm/date-picker/index.d.ts +17 -6
  11. package/esm/date-picker/index.js +62 -17
  12. package/esm/date-picker/style/index.css +1 -1
  13. package/esm/date-picker/style/index.js +0 -2
  14. package/esm/date-picker/style/index.scss +6 -1
  15. package/esm/guide/index.d.ts +4 -5
  16. package/esm/guide/index.js +4 -6
  17. package/esm/index.d.ts +3 -5
  18. package/esm/index.js +1 -3
  19. package/esm/input-number/index.d.ts +30 -17
  20. package/esm/input-number/index.js +116 -36
  21. package/esm/loading/index.d.ts +7 -2
  22. package/esm/loading/index.js +18 -24
  23. package/esm/loading/style/index.css +1 -1
  24. package/esm/loading/style/index.scss +0 -10
  25. package/esm/style.css +7 -23
  26. package/esm/table/body/BodyRow.d.ts +9 -3
  27. package/esm/table/body/BodyRow.js +6 -2
  28. package/esm/table/body/index.d.ts +2 -2
  29. package/esm/table/body/index.js +8 -7
  30. package/esm/table/header/HeaderCell.d.ts +2 -2
  31. package/esm/table/header/HeaderCell.js +15 -7
  32. package/esm/table/header/HeaderRow.d.ts +2 -2
  33. package/esm/table/index.d.ts +4 -4
  34. package/esm/table/index.js +3 -3
  35. package/esm/table/interface.d.ts +9 -3
  36. package/esm/table/style/index.css +1 -1
  37. package/esm/table/style/index.js +0 -2
  38. package/esm/table/style/index.scss +2 -0
  39. package/lib/carousel/index.d.ts +13 -21
  40. package/lib/carousel/index.js +45 -80
  41. package/lib/carousel/style/index.css +1 -1
  42. package/lib/carousel/style/index.scss +1 -7
  43. package/lib/date-picker/calendar/grid/index.css +1 -1
  44. package/lib/date-picker/calendar/grid/index.js +17 -28
  45. package/lib/date-picker/calendar/grid/index.scss +4 -0
  46. package/lib/date-picker/calendar/index.d.ts +4 -0
  47. package/lib/date-picker/calendar/index.js +1 -1
  48. package/lib/date-picker/index.d.ts +17 -6
  49. package/lib/date-picker/index.js +61 -17
  50. package/lib/date-picker/style/index.css +1 -1
  51. package/lib/date-picker/style/index.js +0 -2
  52. package/lib/date-picker/style/index.scss +6 -1
  53. package/lib/guide/index.d.ts +4 -5
  54. package/lib/guide/index.js +4 -7
  55. package/lib/index.d.ts +3 -5
  56. package/lib/index.js +2 -30
  57. package/lib/input-number/index.d.ts +30 -17
  58. package/lib/input-number/index.js +116 -36
  59. package/lib/loading/index.d.ts +7 -2
  60. package/lib/loading/index.js +18 -25
  61. package/lib/loading/style/index.css +1 -1
  62. package/lib/loading/style/index.scss +0 -10
  63. package/lib/style.css +7 -23
  64. package/lib/table/body/BodyRow.d.ts +9 -3
  65. package/lib/table/body/BodyRow.js +6 -2
  66. package/lib/table/body/index.d.ts +2 -2
  67. package/lib/table/body/index.js +8 -7
  68. package/lib/table/header/HeaderCell.d.ts +2 -2
  69. package/lib/table/header/HeaderCell.js +15 -8
  70. package/lib/table/header/HeaderRow.d.ts +2 -2
  71. package/lib/table/index.d.ts +4 -4
  72. package/lib/table/index.js +3 -3
  73. package/lib/table/interface.d.ts +9 -3
  74. package/lib/table/style/index.css +1 -1
  75. package/lib/table/style/index.js +0 -2
  76. package/lib/table/style/index.scss +2 -0
  77. package/package.json +2 -2
  78. package/esm/accordion/__stories__/style.css +0 -1
  79. package/esm/accordion/__stories__/style.scss +0 -59
  80. package/esm/affix/__stories__/style.css +0 -1
  81. package/esm/affix/__stories__/style.scss +0 -13
  82. package/esm/carousel/__stories__/style.css +0 -1
  83. package/esm/carousel/__stories__/style.scss +0 -41
  84. package/esm/collapse/__stories__/style.css +0 -1
  85. package/esm/collapse/__stories__/style.scss +0 -19
  86. package/esm/guide/__stories__/style.css +0 -1
  87. package/esm/guide/__stories__/style.scss +0 -14
  88. package/esm/icon/__stories__/iconNames.d.ts +0 -2
  89. package/esm/icon/__stories__/iconNames.js +0 -1
  90. package/esm/icon/__stories__/style.css +0 -1
  91. package/esm/icon/__stories__/style.scss +0 -40
  92. package/esm/icon/index.d.ts +0 -43
  93. package/esm/icon/index.js +0 -94
  94. package/esm/icon/style/index.css +0 -1
  95. package/esm/icon/style/index.d.ts +0 -1
  96. package/esm/icon/style/index.js +0 -5
  97. package/esm/icon/style/index.scss +0 -7
  98. package/esm/lazy-image/__stories__/style.css +0 -1
  99. package/esm/lazy-image/__stories__/style.scss +0 -9
  100. package/esm/loading-container/__stories__/style.css +0 -1
  101. package/esm/loading-container/__stories__/style.scss +0 -6
  102. package/esm/move/__stories__/style.css +0 -1
  103. package/esm/move/__stories__/style.scss +0 -6
  104. package/esm/popover/__stories__/style.css +0 -1
  105. package/esm/popover/__stories__/style.scss +0 -16
  106. package/esm/select/__stories__/style.css +0 -1
  107. package/esm/select/__stories__/style.scss +0 -8
  108. package/esm/skeleton/__stories__/style.css +0 -1
  109. package/esm/skeleton/__stories__/style.scss +0 -3
  110. package/esm/table/__stories__/style.css +0 -1
  111. package/esm/table/__stories__/style.scss +0 -34
  112. package/esm/tabs/__stories__/style.css +0 -1
  113. package/esm/tabs/__stories__/style.scss +0 -8
  114. package/esm/use-config/index.d.ts +0 -5
  115. package/esm/use-config/index.js +0 -13
  116. package/esm/use-config/style/index.css +0 -0
  117. package/esm/use-config/style/index.d.ts +0 -1
  118. package/esm/use-config/style/index.js +0 -1
  119. package/esm/use-config/style/index.scss +0 -0
  120. package/lib/accordion/__stories__/style.css +0 -1
  121. package/lib/accordion/__stories__/style.scss +0 -59
  122. package/lib/affix/__stories__/style.css +0 -1
  123. package/lib/affix/__stories__/style.scss +0 -13
  124. package/lib/carousel/__stories__/style.css +0 -1
  125. package/lib/carousel/__stories__/style.scss +0 -41
  126. package/lib/collapse/__stories__/style.css +0 -1
  127. package/lib/collapse/__stories__/style.scss +0 -19
  128. package/lib/guide/__stories__/style.css +0 -1
  129. package/lib/guide/__stories__/style.scss +0 -14
  130. package/lib/icon/__stories__/iconNames.d.ts +0 -2
  131. package/lib/icon/__stories__/iconNames.js +0 -8
  132. package/lib/icon/__stories__/style.css +0 -1
  133. package/lib/icon/__stories__/style.scss +0 -40
  134. package/lib/icon/index.d.ts +0 -43
  135. package/lib/icon/index.js +0 -111
  136. package/lib/icon/style/index.css +0 -1
  137. package/lib/icon/style/index.d.ts +0 -1
  138. package/lib/icon/style/index.js +0 -7
  139. package/lib/icon/style/index.scss +0 -7
  140. package/lib/lazy-image/__stories__/style.css +0 -1
  141. package/lib/lazy-image/__stories__/style.scss +0 -9
  142. package/lib/loading-container/__stories__/style.css +0 -1
  143. package/lib/loading-container/__stories__/style.scss +0 -6
  144. package/lib/move/__stories__/style.css +0 -1
  145. package/lib/move/__stories__/style.scss +0 -6
  146. package/lib/popover/__stories__/style.css +0 -1
  147. package/lib/popover/__stories__/style.scss +0 -16
  148. package/lib/select/__stories__/style.css +0 -1
  149. package/lib/select/__stories__/style.scss +0 -8
  150. package/lib/skeleton/__stories__/style.css +0 -1
  151. package/lib/skeleton/__stories__/style.scss +0 -3
  152. package/lib/table/__stories__/style.css +0 -1
  153. package/lib/table/__stories__/style.scss +0 -34
  154. package/lib/tabs/__stories__/style.css +0 -1
  155. package/lib/tabs/__stories__/style.scss +0 -8
  156. package/lib/use-config/index.d.ts +0 -5
  157. package/lib/use-config/index.js +0 -21
  158. package/lib/use-config/style/index.css +0 -0
  159. package/lib/use-config/style/index.d.ts +0 -1
  160. package/lib/use-config/style/index.js +0 -1
  161. package/lib/use-config/style/index.scss +0 -0
@@ -7,7 +7,5 @@ if (canUseDOM) {
7
7
 
8
8
  require('../calendar/grid/index.scss');
9
9
 
10
- require('../../icon/style/index');
11
-
12
10
  require('../../popover/style/index');
13
11
  }
@@ -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
+ }
@@ -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;
@@ -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
- img = _a.img,
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 = img;
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
- img = _a.img;
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: img,
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, CarouselDirection } from './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, CarouselDirection } from './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 OnchangeHandler {
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: OnchangeHandler;
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
- isPositive?: boolean;
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?: OnchangeHandler;
64
+ onChangePackMultipleBefore?: OnChangeHandler;
60
65
  /**
61
66
  * packMultiple 有值时,判断后的回调函数
62
67
  */
63
- onChangePackMultipleAfter?: OnchangeHandler;
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
- isPositive: boolean;
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
- debounce: DebounceRef;
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
- getDebounce: () => DebounceRef;
125
- callback: (value: string) => void;
126
- onValueChange: (ev: ChangeEvent) => void;
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.getDebounce = function () {
323
- if (_this.debounce) {
324
- return _this.debounce;
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
- _this.debounce = debounce(_this.onChangePackMultipleValue, _this.props.delay);
328
- return _this.debounce;
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
- var packMultiple = _this.props.packMultiple || 1;
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
- var valueNumber = parseFloat(value);
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
- _this.getDebounce()(value);
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.debounce) {
355
- _this.debounce.cancel();
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
- isPositive = _a.isPositive,
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 (isPositive && currentValue.indexOf('.') > -1) {
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: (parseFloat(value.toString()) || 0) + step
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: (parseFloat(value.toString()) || 0) - step
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.debounce) {
490
- this.debounce.cancel();
491
- this.debounce = null;
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.isPositive;
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
- isPositive: true,
621
+ digital: 0,
622
+ padDigital: false,
543
623
  delay: 1000,
544
624
  visibleButton: false
545
625
  };
@@ -1,8 +1,13 @@
1
+ import React from 'react';
1
2
  export interface LoadingProps {
2
3
  /**
3
- * loading 样式的另一种
4
+ * loading 样式
4
5
  */
5
- isRectLoading?: boolean;
6
+ className?: string;
7
+ /**
8
+ * 自定义loading, 需要补全自定义元素样式
9
+ */
10
+ customIcon?: React.ReactElement;
6
11
  /**
7
12
  * loading开始后自动隐藏的时间,单位:毫秒
8
13
  */
@@ -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(isRectLoading) {
30
- var _a;
31
-
29
+ function getLoadingContainer(customIcon, className) {
32
30
  return React.createElement("div", {
33
- className: classNames(cls + "-wrap", (_a = {}, _a[cls + "-rect-loading"] = isRectLoading, _a))
34
- }, isRectLoading ? React.createElement("img", {
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(isRectLoading) {
42
+ function createLoading(customIcon, className) {
50
43
  loadingElement = document.createElement('div');
51
44
  document.body.appendChild(loadingElement);
52
- ReactDOM.render(getLoadingContainer(isRectLoading), loadingElement);
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.isRectLoading);
72
- } else if (prevIsRectLoading !== config.isRectLoading) {
73
- // loading 类型不同时,重新创建
74
- try {
75
- document.body.removeChild(loadingElement);
76
- } catch (e) {}
77
-
78
- createLoading(config.isRectLoading);
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
- prevIsRectLoading = config.isRectLoading; // 如果配置中有expire且大于0
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)}.ab-loading-wrap.ab-loading-rect-loading{background-color:rgba(0,0,0,.7)}.ab-loading-wrap.ab-loading-rect-loading .ab-loading-content{top:10%;width:1.6rem;height:.24rem}
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
  }