@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
@@ -1,19 +1,11 @@
1
1
  import React from 'react';
2
2
  import { AddListenerEventHandler } from '@autobest-ui/utils';
3
- export declare enum CarouselDirection {
4
- vertical = "vertical",
5
- horizontal = "horizontal"
6
- }
7
3
  export interface CarouselProps {
8
4
  children: React.ReactElement[] | React.ReactElement;
9
5
  /**
10
6
  * 一行显示的数量
11
7
  */
12
8
  slidesPerView?: number;
13
- /**
14
- * 滚动方向
15
- */
16
- direction?: CarouselDirection;
17
9
  /**
18
10
  * 监听resize
19
11
  */
@@ -22,6 +14,10 @@ export interface CarouselProps {
22
14
  * 是否可以手动控制 只支持移动端
23
15
  */
24
16
  controllable?: boolean;
17
+ /**
18
+ * 组件高度,可以不写,不写情况下,自动获取高度
19
+ */
20
+ height?: string;
25
21
  /**
26
22
  * 敏感值,设置多少后可以进行切换, 只有在 controllable = true时生效
27
23
  */
@@ -57,18 +53,17 @@ interface CarouselStates {
57
53
  declare class Carousel extends React.Component<CarouselProps, CarouselStates> {
58
54
  readonly prefixCls = "ab-carousel";
59
55
  listRef: React.RefObject<HTMLDivElement>;
60
- sliderSize: number;
61
- contentSize: number;
62
- isDirectionLeftOrTop: boolean;
56
+ sliderWidth: number;
57
+ contentWidth: number;
58
+ isDirectionLeft: boolean;
63
59
  intersectionObserver: IntersectionObserver;
64
- startSize: number;
65
- prevSize: number;
66
- moveSize: number;
67
- endSize: number;
60
+ startX: number;
61
+ prevX: number;
62
+ moveX: number;
63
+ endX: number;
68
64
  autoplayTimer: any;
69
65
  fadeEffectTimer: any;
70
66
  static defaultProps: {
71
- direction: CarouselDirection;
72
67
  slidesPerView: number;
73
68
  defaultValue: number;
74
69
  className: string;
@@ -87,8 +82,6 @@ declare class Carousel extends React.Component<CarouselProps, CarouselStates> {
87
82
  next: (transition?: string) => void;
88
83
  prev: (transition?: string) => void;
89
84
  goTo: (nextIndex: number, transition?: string) => void;
90
- isHorizontalDirection: () => boolean;
91
- setElementSizeByDirection: (element: HTMLElement, value: string) => void;
92
85
  /**
93
86
  * 获取滚动元素数量
94
87
  */
@@ -110,11 +103,10 @@ declare class Carousel extends React.Component<CarouselProps, CarouselStates> {
110
103
  /**
111
104
  * 设置容器元素样式,分别是:透明度渐变与位置偏移
112
105
  * @param element
113
- * @param translateSize
106
+ * @param translateX
114
107
  * @param transition
115
108
  */
116
- setListStyles: (element: HTMLElement, translateSize: number, transition?: string) => void;
117
- getTouchSize: (event: any) => any;
109
+ setListStyles: (element: HTMLElement, translateX: number, transition?: string) => void;
118
110
  /**
119
111
  * 开启自动偏移或者渐变,当元素少于2时,将不会开启
120
112
  */
@@ -28,12 +28,6 @@ import React from 'react';
28
28
  import classNames from 'classnames';
29
29
  import { isTouchScreen, addEventListener, throttleWithRAF, getElementSize } from '@autobest-ui/utils';
30
30
  import Transition from './transition';
31
- export var CarouselDirection;
32
-
33
- (function (CarouselDirection) {
34
- CarouselDirection["vertical"] = "vertical";
35
- CarouselDirection["horizontal"] = "horizontal";
36
- })(CarouselDirection || (CarouselDirection = {}));
37
31
 
38
32
  var Carousel =
39
33
  /** @class */
@@ -44,15 +38,14 @@ function (_super) {
44
38
  var _this = _super.call(this, props) || this;
45
39
 
46
40
  _this.prefixCls = 'ab-carousel';
47
- _this.listRef = React.createRef(); // 当是horizontal时是width, 否则是height
48
-
49
- _this.sliderSize = 0;
50
- _this.contentSize = 0;
51
- _this.isDirectionLeftOrTop = true;
52
- _this.startSize = 0;
53
- _this.prevSize = 0;
54
- _this.moveSize = 0;
55
- _this.endSize = 0;
41
+ _this.listRef = React.createRef();
42
+ _this.sliderWidth = 0;
43
+ _this.contentWidth = 0;
44
+ _this.isDirectionLeft = true;
45
+ _this.startX = 0;
46
+ _this.prevX = 0;
47
+ _this.moveX = 0;
48
+ _this.endX = 0;
56
49
  _this.autoplayTimer = null;
57
50
  _this.fadeEffectTimer = null;
58
51
 
@@ -67,20 +60,6 @@ function (_super) {
67
60
  _this.goTo = function (nextIndex, transition) {
68
61
  _this.interceptorChangePage(nextIndex - 1, transition);
69
62
  };
70
-
71
- _this.isHorizontalDirection = function () {
72
- return _this.props.direction === CarouselDirection.horizontal;
73
- };
74
-
75
- _this.setElementSizeByDirection = function (element, value) {
76
- var isHr = _this.isHorizontalDirection();
77
-
78
- if (isHr) {
79
- element.style.width = value;
80
- } else {
81
- element.style.height = value;
82
- }
83
- };
84
63
  /**
85
64
  * 获取滚动元素数量
86
65
  */
@@ -113,14 +92,11 @@ function (_super) {
113
92
  return;
114
93
  }
115
94
 
116
- var isHr = _this.isHorizontalDirection();
117
-
118
95
  var childCount = _this.getChildCount();
119
96
 
120
- var parentNodeOffset = getElementSize(element.parentNode);
121
- _this.contentSize = isHr ? parentNodeOffset.width : parentNodeOffset.height; // 没有子元素或者获取不到宽度
97
+ _this.contentWidth = getElementSize(element.parentNode).width; // 没有子元素或者获取不到宽度
122
98
 
123
- if (!childCount || !_this.contentSize) {
99
+ if (!childCount || !_this.contentWidth) {
124
100
  return;
125
101
  } // 执行一次,控制样式,显示slider
126
102
 
@@ -132,18 +108,23 @@ function (_super) {
132
108
  }
133
109
 
134
110
  var currentPage = _this.state.currentPage;
135
- var slidesPerView = _this.props.slidesPerView;
136
- _this.sliderSize = _this.contentSize / slidesPerView;
111
+ var _a = _this.props,
112
+ slidesPerView = _a.slidesPerView,
113
+ height = _a.height;
114
+ _this.sliderWidth = _this.contentWidth / slidesPerView;
115
+ element.style.width = _this.sliderWidth * childCount + "px";
137
116
 
138
- _this.setElementSizeByDirection(element, _this.sliderSize * childCount + "px");
117
+ if (height) {
118
+ element.style.height = height;
119
+ }
139
120
 
140
121
  var childList = Array.from(element.children);
141
122
  childList.forEach(function (child) {
142
- _this.setElementSizeByDirection(child, _this.sliderSize + "px");
123
+ child.style.width = _this.sliderWidth + "px";
143
124
  });
144
- _this.prevSize = -currentPage * _this.sliderSize;
125
+ _this.prevX = -currentPage * _this.sliderWidth;
145
126
 
146
- _this.setListStyles(element, _this.prevSize);
127
+ _this.setListStyles(element, _this.prevX);
147
128
 
148
129
  _this.onAutoplay();
149
130
  };
@@ -180,11 +161,11 @@ function (_super) {
180
161
  nextPage = 0;
181
162
  }
182
163
 
183
- _this.prevSize = -nextPage * _this.sliderSize;
164
+ _this.prevX = -nextPage * _this.sliderWidth;
184
165
 
185
166
  _this.onBeforeChange(nextPage);
186
167
 
187
- _this.setListStyles(element, _this.prevSize, transition);
168
+ _this.setListStyles(element, _this.prevX, transition);
188
169
 
189
170
  _this.setState({
190
171
  currentPage: nextPage
@@ -197,12 +178,12 @@ function (_super) {
197
178
  /**
198
179
  * 设置容器元素样式,分别是:透明度渐变与位置偏移
199
180
  * @param element
200
- * @param translateSize
181
+ * @param translateX
201
182
  * @param transition
202
183
  */
203
184
 
204
185
 
205
- _this.setListStyles = function (element, translateSize, transition) {
186
+ _this.setListStyles = function (element, translateX, transition) {
206
187
  element.style.transition = ''; // 当开启渐变时,直接执行渐变,将没有位置偏移动画
207
188
 
208
189
  if (_this.props.fadeEffect) {
@@ -218,17 +199,7 @@ function (_super) {
218
199
  element.style.transition = transition || Transition.TransformEaseInOut;
219
200
  }
220
201
 
221
- element.style.transform = _this.isHorizontalDirection() ? "translateX(" + translateSize + "px)" : "translateY(" + translateSize + "px)";
222
- };
223
-
224
- _this.getTouchSize = function (event) {
225
- var isHr = _this.isHorizontalDirection();
226
-
227
- if (event.touches) {
228
- return isHr ? event.touches[0].pageX : event.touches[0].pageY;
229
- }
230
-
231
- return isHr ? event.clientX : event.clientY;
202
+ element.style.transform = "translateX(" + translateX + "px)";
232
203
  };
233
204
 
234
205
  _this.onBeforeChange = function (currentPage) {
@@ -265,8 +236,8 @@ function (_super) {
265
236
 
266
237
  event.preventDefault();
267
238
  clearTimeout(_this.autoplayTimer);
268
- _this.endSize = 0;
269
- _this.startSize = _this.getTouchSize(event);
239
+ _this.endX = 0;
240
+ _this.startX = event.touches ? event.touches[0].pageX : event.clientX;
270
241
 
271
242
  var element = _this.getListDomNode();
272
243
 
@@ -288,9 +259,9 @@ function (_super) {
288
259
  }
289
260
 
290
261
  event.preventDefault();
291
- _this.endSize = _this.getTouchSize(event);
292
- _this.moveSize = _this.prevSize + _this.endSize - _this.startSize;
293
- _this.isDirectionLeftOrTop = _this.prevSize - _this.startSize <= _this.prevSize - _this.endSize;
262
+ _this.endX = event.touches ? event.touches[0].pageX : event.clientX;
263
+ _this.moveX = _this.prevX + _this.endX - _this.startX;
264
+ _this.isDirectionLeft = _this.prevX - _this.startX <= _this.prevX - _this.endX;
294
265
 
295
266
  var element = _this.getListDomNode();
296
267
 
@@ -298,7 +269,7 @@ function (_super) {
298
269
  return;
299
270
  }
300
271
 
301
- element.style.transform = _this.isHorizontalDirection() ? "translateX(" + _this.moveSize + "px)" : "translateY(" + _this.moveSize + "px)";
272
+ element.style.transform = "translateX(" + _this.moveX + "px)";
302
273
  };
303
274
  /**
304
275
  * 停止滑动,判断用户移动位置,确定用户最终滑动位置
@@ -325,9 +296,9 @@ function (_super) {
325
296
  var currentPage = _this.state.currentPage;
326
297
  var transition = Transition.TransformEaseOut; // 移动的偏移量
327
298
 
328
- var translateSize = Math.abs(_this.startSize - _this.endSize); // 判断用户未产生滑动,认为是点击
299
+ var translateX = Math.abs(_this.startX - _this.endX); // 判断用户未产生滑动,认为是点击
329
300
 
330
- if (_this.endSize === 0 || translateSize < sensitivity) {
301
+ if (_this.endX === 0 || translateX < sensitivity) {
331
302
  if (onClick) {
332
303
  onClick(_this.state.currentPage + 1);
333
304
  }
@@ -339,7 +310,7 @@ function (_super) {
339
310
 
340
311
  event.preventDefault(); // 移出左边临界点
341
312
 
342
- if (_this.moveSize >= 0) {
313
+ if (_this.moveX >= 0) {
343
314
  _this.interceptorChangePage(0, transition);
344
315
 
345
316
  return;
@@ -348,21 +319,21 @@ function (_super) {
348
319
  var childCount = _this.getChildCount(); // 移出右边临界点
349
320
 
350
321
 
351
- var listSize = _this.sliderSize * childCount;
352
- var moveX = Math.abs(_this.moveSize);
322
+ var listWidth = _this.sliderWidth * childCount;
323
+ var moveX = Math.abs(_this.moveX);
353
324
 
354
- if (moveX >= listSize - _this.contentSize) {
325
+ if (moveX >= listWidth - _this.contentWidth) {
355
326
  _this.interceptorChangePage(childCount - slidesPerView, transition);
356
327
 
357
328
  return;
358
329
  } // 未达到一页,判断是否超出sensitivity, 超出将加1
359
330
 
360
331
 
361
- var skipOne = translateSize % _this.sliderSize >= _this.props.sensitivity ? 1 : 0; // 滑动的完整页数
332
+ var skipOne = translateX % _this.sliderWidth >= _this.props.sensitivity ? 1 : 0; // 滑动的完整页数
362
333
 
363
- var skipCount = Math.floor(translateSize / _this.sliderSize); // 判断是否向左滑动
334
+ var skipCount = Math.floor(translateX / _this.sliderWidth); // 判断是否向左滑动
364
335
 
365
- if (_this.isDirectionLeftOrTop) {
336
+ if (_this.isDirectionLeft) {
366
337
  currentPage = currentPage + skipCount + skipOne;
367
338
  } else {
368
339
  currentPage -= skipCount + skipOne;
@@ -405,11 +376,9 @@ function (_super) {
405
376
  Carousel.prototype.componentDidUpdate = function (prevProps) {
406
377
  var _this = this;
407
378
 
408
- var _a = this.props,
409
- children = _a.children,
410
- direction = _a.direction;
379
+ var children = this.props.children;
411
380
 
412
- if (React.Children.count(children) !== React.Children.count(prevProps.children) || direction !== prevProps.direction) {
381
+ if (React.Children.count(children) !== React.Children.count(prevProps.children)) {
413
382
  this.init();
414
383
  } // 加入 resize 监听
415
384
 
@@ -460,9 +429,8 @@ function (_super) {
460
429
  className = _b.className,
461
430
  children = _b.children,
462
431
  pagination = _b.pagination;
463
- var isHr = this.isHorizontalDirection();
464
432
  return React.createElement("div", {
465
- className: classNames(cls, className, (_a = {}, _a[cls + "-init"] = this.state.initialized, _a[cls + "-hr"] = isHr, _a[cls + "-vt"] = !isHr, _a))
433
+ className: classNames(cls, className, (_a = {}, _a[cls + "-init"] = this.state.initialized, _a))
466
434
  }, React.createElement("div", {
467
435
  className: cls + "-content"
468
436
  }, React.createElement("div", {
@@ -483,7 +451,6 @@ function (_super) {
483
451
 
484
452
 
485
453
  Carousel.defaultProps = {
486
- direction: CarouselDirection.horizontal,
487
454
  slidesPerView: 1,
488
455
  defaultValue: 1,
489
456
  className: '',
@@ -1 +1 @@
1
- .ab-carousel{position:relative;height:100%}.ab-carousel-content{position:relative;display:block;height:100%;width:100%;margin:0;padding:0;overflow:hidden}.ab-carousel-list{user-select:none;position:relative;top:0;left:0;display:block;overflow:hidden}.ab-carousel-slider{outline:0;overflow:hidden;display:none}.ab-carousel.ab-carousel-init .ab-carousel-slider{display:block}.ab-carousel.ab-carousel-hr .ab-carousel-slider{float:left}
1
+ .ab-carousel{position:relative}.ab-carousel-content{position:relative;display:block;height:100%;width:100%;margin:0;padding:0;overflow:hidden}.ab-carousel-list{user-select:none;position:relative;top:0;left:0;display:block;overflow:hidden}.ab-carousel-slider{outline:0;overflow:hidden;float:left;display:none}.ab-carousel.ab-carousel-init .ab-carousel-slider{display:block}
@@ -2,7 +2,6 @@ $namespace: ab-carousel;
2
2
 
3
3
  .#{$namespace} {
4
4
  position: relative;
5
- height: 100%;
6
5
 
7
6
  &-content {
8
7
  position: relative;
@@ -26,6 +25,7 @@ $namespace: ab-carousel;
26
25
  &-slider {
27
26
  outline: none;
28
27
  overflow: hidden;
28
+ float: left;
29
29
  display: none;
30
30
  }
31
31
 
@@ -34,10 +34,4 @@ $namespace: ab-carousel;
34
34
  display: block;
35
35
  }
36
36
  }
37
-
38
- &.#{$namespace}-hr {
39
- .#{$namespace}-slider {
40
- float: left;
41
- }
42
- }
43
37
  }
@@ -1 +1 @@
1
- .ab-dp-cg-content,.ab-dp-cg-head,.ab-dp-cg-title{display:flex;align-items:center}.ab-dp-cg-title{user-select:none;font-size:.14rem;padding-bottom:.08rem}.ab-dp-cg-title>strong{flex:1 1;margin-left:.1rem;cursor:default;color:#4a4a4a}.ab-dp-cg-title>strong.ab-dp-cg-clickable{cursor:pointer}.ab-dp-cg-title>strong.ab-dp-cg-clickable:hover{color:#000}.ab-dp-cg-dis-icon,.ab-dp-cg-icon{align-self:flex-end;margin-left:.08rem}.ab-dp-cg-icon{cursor:pointer}.ab-dp-cg-head{padding-bottom:.05rem}.ab-dp-cg-head>li{display:flex;align-items:center;justify-content:center;cursor:default}.ab-dp-cg-content{flex-wrap:wrap}.ab-dp-cg-content>li{cursor:pointer;display:flex;align-items:center;justify-content:center;color:#000}.ab-dp-cg-content>li:hover{background:#f0f0f0}.ab-dp-cg-content>li.ab-dp-cg-dis{cursor:not-allowed;color:#b0b0b0}.ab-dp-cg-content>li.ab-dp-cg-dis:hover{background:0 0}.ab-dp-cg-content>li.ab-dp-cg-selected,.ab-dp-cg-content>li:active{background:#c7e0f4;border:3px solid #c7e0f4;border-radius:2px;color:#000}.ab-dp-cg-content>li.ab-dp-cg-today{background:#0078d4;color:#fff}
1
+ .ab-dp-cg-content,.ab-dp-cg-head,.ab-dp-cg-title{display:flex;align-items:center}.ab-dp-cg-title{user-select:none;font-size:.14rem;padding-bottom:.08rem}.ab-dp-cg-title>strong{flex:1 1;margin-left:.1rem;cursor:default;color:#4a4a4a}.ab-dp-cg-title>strong.ab-dp-cg-clickable{cursor:pointer}.ab-dp-cg-title>strong.ab-dp-cg-clickable:hover{color:#000}.ab-dp-cg-dis-icon,.ab-dp-cg-icon{align-self:flex-end;margin-left:.08rem}.ab-dp-cg-icon{cursor:pointer}.ab-dp-cg-head{padding-bottom:.05rem}.ab-dp-cg-head>li{display:flex;align-items:center;justify-content:center;cursor:default}.ab-dp-cg-content{flex-wrap:wrap}.ab-dp-cg-content>li{cursor:pointer;display:flex;align-items:center;justify-content:center;color:#000}.ab-dp-cg-content>li:hover{background:#f0f0f0}.ab-dp-cg-content>li.ab-dp-cg-dis{cursor:not-allowed;color:#b0b0b0}.ab-dp-cg-content>li.ab-dp-cg-dis:hover{background:0 0}.ab-dp-cg-content>li.ab-dp-cg-selected,.ab-dp-cg-content>li:active{background:#c7e0f4;border:3px solid #c7e0f4;border-radius:2px;color:#000}.ab-dp-cg-content>li.ab-dp-cg-today{background:#0078d4;color:#fff}.ab-dp-cg-arrow{cursor:pointer}
@@ -1,35 +1,23 @@
1
- var __assign = this && this.__assign || function () {
2
- __assign = Object.assign || function (t) {
3
- for (var s, i = 1, n = arguments.length; i < n; i++) {
4
- s = arguments[i];
5
-
6
- for (var p in s) {
7
- if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
8
- }
9
- }
10
-
11
- return t;
12
- };
13
-
14
- return __assign.apply(this, arguments);
15
- };
16
-
17
1
  import React from 'react';
18
2
  import classNames from 'classnames';
19
- import Icon from '../../../icon';
20
3
  var cls = 'ab-dp-cg';
21
4
 
22
- var getArrowStyle = function getArrowStyle(direction, onClick) {
5
+ var renderArrow = function renderArrow(prefixCls, direction, onClick) {
23
6
  var enabled = !!onClick;
24
- return {
25
- name: 'arrow',
26
- width: 0.14,
27
- height: 0.28,
28
- color: enabled ? '#333' : '#808080',
29
- transform: direction,
30
- className: enabled ? cls + "-icon" : cls + "-dis-icon",
7
+ return React.createElement("span", {
8
+ className: prefixCls + "-arrow",
31
9
  onClick: onClick
32
- };
10
+ }, React.createElement("svg", {
11
+ style: direction,
12
+ viewBox: "0 0 1024 1024",
13
+ version: "1.1",
14
+ width: "0.14rem",
15
+ height: "0.28rem",
16
+ fill: enabled ? '#333' : '#808080',
17
+ xmlns: "http://www.w3.org/2000/svg"
18
+ }, React.createElement("path", {
19
+ d: "M525.339326 186.172452L801.789086 462.622212c12.496698 12.496698 32.758136 12.496698 45.254834 0 12.497405-12.497405 12.496698-32.758136 0-45.254834l-331.014362-331.014362c-12.496698-12.496698-32.757429-12.497405-45.254834 0l-341.795619 339.143969c-12.496698 12.496698-12.496698 32.758136 0 45.254834 12.496698 12.496698 32.758136 12.496698 45.254834 0l287.10586-284.454209L461.372325 925.726242c0 17.673427 14.32669 32.000117 32.000118 32.000117 17.67272-0.000707 31.99941-14.327398 32.000117-32.000117l-0.032527-739.553083z"
20
+ })));
33
21
  };
34
22
 
35
23
  var CalendarGrid = function CalendarGrid(_a) {
@@ -50,7 +38,9 @@ var CalendarGrid = function CalendarGrid(_a) {
50
38
  }, React.createElement("strong", {
51
39
  className: classNames((_b = {}, _b[cls + "-clickable"] = !!onClickTitle, _b)),
52
40
  onClick: onClickTitle
53
- }, title), React.createElement(Icon, __assign({}, getArrowStyle('', onPrev))), React.createElement(Icon, __assign({}, getArrowStyle('rotate(180deg)', onNext)))), React.createElement("ul", {
41
+ }, title), renderArrow(cls, {}, onPrev), renderArrow(cls, {
42
+ transform: 'rotate(180deg)'
43
+ }, onNext)), React.createElement("ul", {
54
44
  className: cls + "-head"
55
45
  }, headList.map(function (item, index) {
56
46
  return React.createElement("li", {
@@ -83,4 +83,8 @@ $namespace: ab-dp-cg;
83
83
  }
84
84
  }
85
85
  }
86
+
87
+ &-arrow {
88
+ cursor: pointer;
89
+ }
86
90
  }
@@ -12,6 +12,10 @@ export interface CalendarProps extends Omit<DayCalendarProps, omitType>, Omit<Mo
12
12
  * 选择日期的回调函数
13
13
  */
14
14
  onSelect: (date?: Date, name?: ReactText) => void;
15
+ /**
16
+ * 默认日期
17
+ */
18
+ defaultDate?: Date;
15
19
  }
16
20
  interface CalendarState {
17
21
  selectedDate: Date;
@@ -74,7 +74,7 @@ function (_super) {
74
74
  });
75
75
  };
76
76
 
77
- var nowDate = props.defaultValue || props.today || new Date();
77
+ var nowDate = props.defaultDate || props.today || new Date();
78
78
  _this.state = {
79
79
  selectedDate: nowDate,
80
80
  navigatedDate: getMonthStart(nowDate.getFullYear(), nowDate.getMonth())
@@ -1,6 +1,6 @@
1
1
  import React, { ReactText } from 'react';
2
2
  import Calendar, { CalendarProps } from './calendar';
3
- export interface DatePickerProps extends Partial<CalendarProps> {
3
+ export interface DatePickerProps extends Partial<Omit<CalendarProps, 'defaultDate'>> {
4
4
  /**
5
5
  * 组件整体样式
6
6
  */
@@ -13,6 +13,14 @@ export interface DatePickerProps extends Partial<CalendarProps> {
13
13
  * 需要显示在input框中的日期格式
14
14
  */
15
15
  onFormatDate?: (v: Date, name?: ReactText) => string;
16
+ /**
17
+ * 默认选中的值,用于初始化展示
18
+ */
19
+ defaultValue?: Date;
20
+ /**
21
+ * 外部控制value
22
+ */
23
+ value?: Date;
16
24
  /**
17
25
  * 是否显示input框中的日历图标
18
26
  */
@@ -29,10 +37,6 @@ export interface DatePickerProps extends Partial<CalendarProps> {
29
37
  * 是否禁用
30
38
  */
31
39
  disabled?: boolean;
32
- /**
33
- * 默认选中的值,用于初始化展示
34
- */
35
- defaultValue?: Date;
36
40
  /**
37
41
  * 与onFormatDate正相反,将input框中的字符串转为Date,当onFormatDate有值时,该属性``也需要有值
38
42
  */
@@ -45,7 +49,9 @@ interface DatePickerState {
45
49
  declare class DatePicker extends React.Component<DatePickerProps, DatePickerState> {
46
50
  prefixCls: string;
47
51
  calendarRef: React.RefObject<Calendar>;
48
- constructor(props: any);
52
+ defaultDate?: Date;
53
+ popoverTriggered: boolean;
54
+ constructor(props: DatePickerProps);
49
55
  static defaultProps: {
50
56
  onFormatDate: (date: any) => any;
51
57
  iconVisible: boolean;
@@ -53,7 +59,12 @@ declare class DatePicker extends React.Component<DatePickerProps, DatePickerStat
53
59
  disabled: boolean;
54
60
  parseDateFromString: (value: any) => Date;
55
61
  };
62
+ static getDerivedStateFromProps(nextProps: DatePickerProps, prevState: DatePickerState): {
63
+ inputValue: string;
64
+ calendarVisible: boolean;
65
+ };
56
66
  onCalendarSelect: (date: Date) => void;
67
+ updateDate: () => void;
57
68
  onInputFocus: () => void;
58
69
  onInputChange: (ev: any) => void;
59
70
  onChangeDate: () => void;
@@ -43,8 +43,7 @@ var __assign = this && this.__assign || function () {
43
43
  import React, { createRef } from 'react';
44
44
  import classNames from 'classnames';
45
45
  import Calendar from './calendar';
46
- import Popover from '../popover';
47
- import Icon from '../icon'; // TODO: 移动端
46
+ import Popover from '../popover'; // TODO: 移动端
48
47
 
49
48
  var DatePicker =
50
49
  /** @class */
@@ -56,6 +55,7 @@ function (_super) {
56
55
 
57
56
  _this.prefixCls = 'ab-date-picker';
58
57
  _this.calendarRef = createRef();
58
+ _this.popoverTriggered = false;
59
59
 
60
60
  _this.onCalendarSelect = function (date) {
61
61
  _this.setState({
@@ -68,14 +68,35 @@ function (_super) {
68
68
  }
69
69
  };
70
70
 
71
- _this.onInputFocus = function () {
72
- if (_this.calendarRef.current && _this.state.inputValue) {
73
- _this.calendarRef.current.updateDate(_this.props.parseDateFromString(_this.state.inputValue, _this.props.name));
71
+ _this.updateDate = function () {
72
+ if (!_this.calendarRef.current || !_this.state.inputValue) {
73
+ return;
74
+ }
75
+
76
+ var date = _this.props.parseDateFromString(_this.state.inputValue, _this.props.name);
77
+
78
+ if (isNaN(date.getTime())) {
79
+ return;
74
80
  }
75
81
 
82
+ _this.calendarRef.current.updateDate(date);
83
+ };
84
+
85
+ _this.onInputFocus = function () {
86
+ _this.updateDate();
87
+
76
88
  _this.setState({
77
89
  calendarVisible: true
78
90
  });
91
+
92
+ if (!_this.popoverTriggered) {
93
+ // 标记触发过popover visible
94
+ _this.popoverTriggered = true;
95
+
96
+ if ('value' in _this.props && _this.props.value) {
97
+ _this.defaultDate = _this.props.value;
98
+ }
99
+ }
79
100
  };
80
101
 
81
102
  _this.onInputChange = function (ev) {
@@ -89,13 +110,11 @@ function (_super) {
89
110
  };
90
111
 
91
112
  _this.onChangeDate = function () {
92
- if (!_this.props.allowTextInput || !_this.calendarRef.current || !_this.state.inputValue) {
113
+ if (!_this.props.allowTextInput) {
93
114
  return;
94
115
  }
95
116
 
96
- var date = _this.props.parseDateFromString(_this.state.inputValue, _this.props.name);
97
-
98
- _this.calendarRef.current.updateDate(date);
117
+ _this.updateDate();
99
118
  };
100
119
 
101
120
  _this.onPopoverVisibleChange = function (visible) {
@@ -123,12 +142,14 @@ function (_super) {
123
142
  return React.createElement(Calendar, __assign({}, copyProps, {
124
143
  ref: _this.calendarRef,
125
144
  onSelect: _this.onCalendarSelect,
126
- className: copyProps.calendarClassName
145
+ className: copyProps.calendarClassName,
146
+ defaultDate: _this.defaultDate
127
147
  }));
128
148
  };
129
149
 
130
150
  var defaultValue = props.defaultValue,
131
151
  onFormatDate = props.onFormatDate;
152
+ _this.defaultDate = defaultValue;
132
153
  _this.state = {
133
154
  calendarVisible: false,
134
155
  inputValue: defaultValue ? onFormatDate(defaultValue) : ''
@@ -136,6 +157,25 @@ function (_super) {
136
157
  return _this;
137
158
  }
138
159
 
160
+ DatePicker.getDerivedStateFromProps = function (nextProps, prevState) {
161
+ if ('value' in nextProps) {
162
+ var onFormatDate = nextProps.onFormatDate,
163
+ value = nextProps.value;
164
+ var currentValue = value ? onFormatDate(value) : '';
165
+
166
+ if (prevState.inputValue === currentValue) {
167
+ return null;
168
+ }
169
+
170
+ return {
171
+ inputValue: currentValue,
172
+ calendarVisible: false
173
+ };
174
+ }
175
+
176
+ return null;
177
+ };
178
+
139
179
  DatePicker.prototype.render = function () {
140
180
  var cls = this.prefixCls;
141
181
  var _a = this.props,
@@ -162,13 +202,18 @@ function (_super) {
162
202
  value: inputValue,
163
203
  onFocus: this.onInputFocus,
164
204
  onChange: this.onInputChange
165
- }), iconVisible && React.createElement(Icon, {
166
- className: cls + "-icon",
167
- name: "calendar",
168
- color: "#606060",
169
- width: 0.16,
170
- height: 0.18
171
- })));
205
+ }), iconVisible && React.createElement("span", {
206
+ className: cls + "-icon"
207
+ }, React.createElement("svg", {
208
+ viewBox: "0 0 1024 1024",
209
+ version: "1.1",
210
+ width: "0.16rem",
211
+ height: "0.18rem",
212
+ fill: "currentColor",
213
+ xmlns: "http://www.w3.org/2000/svg"
214
+ }, React.createElement("path", {
215
+ d: "M928 128H832V64h-64v64H256V64H192v64H96l-32 32v768l32 32h832l32-32v-768l-32-32zM896 896H128V320h768v576z m0-640H128V192h768v64zM256 512H192v64h64V512z m-64 128h64v64H192v-64z m64 128H192v64h64v-64z m128-256h64v64H384V512z m64 128H384v64h64v-64z m-64 128h64v64H384v-64z m64-384H384v64h64V384z m128 128h64v64H576V512z m64 128H576v64h64v-64z m-64 128h64v64H576v-64z m64-384H576v64h64V384z m128 128h64v64h-64V512z m64 128h-64v64h64v-64z m-64-256h64v64h-64V384z"
216
+ })))));
172
217
  };
173
218
 
174
219
  DatePicker.defaultProps = {
@@ -1 +1 @@
1
- .ab-date-picker{position:relative}.ab-date-picker-input{outline:0;font-size:.14rem;padding:.04rem;width:1.44rem}.ab-date-picker-icon{position:absolute;right:.05rem;top:50%;transform:translateY(-50%)}
1
+ .ab-date-picker{position:relative}.ab-date-picker-input{outline:0;font-size:.14rem;padding:.04rem;width:1.44rem}.ab-date-picker-input.ab-date-picker-error{background:#fffacd}.ab-date-picker-icon{color:#606060;position:absolute;right:.05rem;top:50%;transform:translateY(-50%)}