@autobest-ui/components 2.13.11 → 2.14.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 (91) hide show
  1. package/esm/carousel/index.d.ts +4 -0
  2. package/esm/carousel/index.js +10 -1
  3. package/esm/checkbox/Checkbox.js +3 -19
  4. package/esm/checkbox/style/index.css +1 -1
  5. package/esm/index.d.ts +6 -0
  6. package/esm/index.js +4 -1
  7. package/esm/input/Adorn.d.ts +4 -0
  8. package/esm/input/Adorn.js +7 -3
  9. package/esm/input/Input.d.ts +1 -0
  10. package/esm/input/Input.js +5 -1
  11. package/esm/input/TextArea.d.ts +1 -0
  12. package/esm/input/TextArea.js +4 -1
  13. package/esm/input-number/index.d.ts +1 -0
  14. package/esm/input-number/index.js +5 -1
  15. package/esm/input-phone/index.d.ts +1 -0
  16. package/esm/input-phone/index.js +1 -0
  17. package/esm/lazy-image/index.d.ts +10 -30
  18. package/esm/lazy-image/index.js +30 -51
  19. package/esm/lazy-image/style/index.css +1 -1
  20. package/esm/loading-container/index.d.ts +1 -19
  21. package/esm/loading-container/index.js +16 -122
  22. package/esm/loading-icon/index.d.ts +1 -1
  23. package/esm/loading-icon/index.js +3 -21
  24. package/esm/move/index.d.ts +10 -0
  25. package/esm/move/index.js +12 -7
  26. package/esm/radio/Radio.js +10 -7
  27. package/esm/radio/RadioGroup.js +3 -6
  28. package/esm/radio/style/index.css +1 -1
  29. package/esm/radio/type.d.ts +0 -2
  30. package/esm/read-more/index.d.ts +92 -0
  31. package/esm/read-more/index.js +377 -0
  32. package/esm/read-more/style/index.css +1 -0
  33. package/esm/read-more-html/index.d.ts +89 -0
  34. package/esm/read-more-html/index.js +362 -0
  35. package/esm/read-more-html/style/index.css +1 -0
  36. package/esm/select/index.d.ts +0 -3
  37. package/esm/select/index.js +4 -25
  38. package/esm/select/style/index.css +1 -1
  39. package/esm/show-more/index.d.ts +27 -12
  40. package/esm/show-more/index.js +87 -41
  41. package/esm/show-more/style/index.css +1 -1
  42. package/esm/style.css +1 -1
  43. package/esm/table/style/index.css +1 -1
  44. package/esm/trigger/index.d.ts +3 -10
  45. package/esm/trigger/index.js +19 -39
  46. package/lib/carousel/index.d.ts +4 -0
  47. package/lib/carousel/index.js +10 -1
  48. package/lib/checkbox/Checkbox.js +3 -19
  49. package/lib/checkbox/style/index.css +1 -1
  50. package/lib/index.d.ts +6 -0
  51. package/lib/index.js +20 -0
  52. package/lib/input/Adorn.d.ts +4 -0
  53. package/lib/input/Adorn.js +7 -3
  54. package/lib/input/Input.d.ts +1 -0
  55. package/lib/input/Input.js +5 -1
  56. package/lib/input/TextArea.d.ts +1 -0
  57. package/lib/input/TextArea.js +4 -1
  58. package/lib/input-number/index.d.ts +1 -0
  59. package/lib/input-number/index.js +5 -1
  60. package/lib/input-phone/index.d.ts +1 -0
  61. package/lib/input-phone/index.js +1 -0
  62. package/lib/lazy-image/index.d.ts +10 -30
  63. package/lib/lazy-image/index.js +30 -51
  64. package/lib/lazy-image/style/index.css +1 -1
  65. package/lib/loading-container/index.d.ts +1 -19
  66. package/lib/loading-container/index.js +16 -125
  67. package/lib/loading-icon/index.d.ts +1 -1
  68. package/lib/loading-icon/index.js +3 -21
  69. package/lib/move/index.d.ts +10 -0
  70. package/lib/move/index.js +12 -7
  71. package/lib/radio/Radio.js +10 -7
  72. package/lib/radio/RadioGroup.js +3 -6
  73. package/lib/radio/style/index.css +1 -1
  74. package/lib/radio/type.d.ts +0 -2
  75. package/lib/read-more/index.d.ts +92 -0
  76. package/lib/read-more/index.js +388 -0
  77. package/lib/read-more/style/index.css +1 -0
  78. package/lib/read-more-html/index.d.ts +89 -0
  79. package/lib/read-more-html/index.js +373 -0
  80. package/lib/read-more-html/style/index.css +1 -0
  81. package/lib/select/index.d.ts +0 -3
  82. package/lib/select/index.js +4 -25
  83. package/lib/select/style/index.css +1 -1
  84. package/lib/show-more/index.d.ts +27 -12
  85. package/lib/show-more/index.js +86 -40
  86. package/lib/show-more/style/index.css +1 -1
  87. package/lib/style.css +1 -1
  88. package/lib/table/style/index.css +1 -1
  89. package/lib/trigger/index.d.ts +3 -10
  90. package/lib/trigger/index.js +19 -39
  91. package/package.json +3 -3
@@ -6,6 +6,10 @@ export interface CarouselProps {
6
6
  * 一行显示的数量
7
7
  */
8
8
  slidesPerView?: number;
9
+ /**
10
+ * 初始化时显示第几个,默认是第一个
11
+ */
12
+ defaultValue?: number;
9
13
  /**
10
14
  * 监听resize
11
15
  */
@@ -40,12 +40,21 @@ var Carousel = /** @class */function (_super) {
40
40
  _this.autoplayTimer = null;
41
41
  _this.fadeEffectTimer = null;
42
42
  _this.next = function (transition) {
43
+ if (transition === void 0) {
44
+ transition = Transition.TransformEaseInOut;
45
+ }
43
46
  _this.interceptorChangePage(_this.state.currentPage + 1, transition);
44
47
  };
45
48
  _this.prev = function (transition) {
49
+ if (transition === void 0) {
50
+ transition = Transition.TransformEaseInOut;
51
+ }
46
52
  _this.interceptorChangePage(_this.state.currentPage - 1, transition);
47
53
  };
48
54
  _this.goTo = function (nextIndex, transition) {
55
+ if (transition === void 0) {
56
+ transition = Transition.TransformEaseInOut;
57
+ }
49
58
  _this.interceptorChangePage(nextIndex - 1, transition);
50
59
  };
51
60
  /**
@@ -154,7 +163,7 @@ var Carousel = /** @class */function (_super) {
154
163
  element.style.visibility = '';
155
164
  });
156
165
  } else {
157
- element.style.transition = transition || Transition.TransformEaseInOut;
166
+ element.style.transition = transition;
158
167
  }
159
168
  element.style.transform = "translateX(".concat(translateX, "px)");
160
169
  };
@@ -39,30 +39,14 @@ var Checkbox = /*#__PURE__*/forwardRef(function (_a, ref) {
39
39
  type: "checkbox",
40
40
  checked: checked,
41
41
  disabled: disabled,
42
- onChange: onCheckboxChange,
43
- style: {
44
- width: size,
45
- height: size
46
- }
42
+ onChange: onCheckboxChange
47
43
  }), /*#__PURE__*/React.createElement("span", {
48
- className: "".concat(cls, "-control"),
49
- style: {
50
- width: size,
51
- height: size,
52
- fontSize: size
53
- }
54
- }, /*#__PURE__*/React.createElement("span", {
55
- className: "".concat(cls, "-outer"),
44
+ className: "".concat(cls, "-inner"),
56
45
  style: {
57
46
  width: size,
58
47
  height: size
59
48
  }
60
- }), /*#__PURE__*/React.createElement("svg", {
61
- className: "".concat(cls, "-check"),
62
- viewBox: "0 0 18 18"
63
- }, /*#__PURE__*/React.createElement("path", {
64
- d: "M2.8284 8.4853 7.7782 13.435 15.5563 5.6569 14.1421 4.2426 7.7782 10.6066 4.2426 7.0711 2.8284 8.4853Z"
65
- }))), children);
49
+ }), children);
66
50
  });
67
51
  Checkbox.defaultProps = {
68
52
  disabled: false,
@@ -1 +1 @@
1
- .ab-checkbox{position:relative;cursor:pointer;display:inline-flex;align-items:center;user-select:none}.ab-checkbox:hover .ab-checkbox-outer{border-color:#767676}.ab-checkbox-input{cursor:pointer;position:absolute;opacity:0;margin:0;padding:0;top:50%;left:0;transform:translateY(-50%);z-index:2}.ab-checkbox-check{opacity:0;transform:scale(0);transition:.2s cubic-bezier(.71,-.46,.88,.6),opacity .1s}.ab-checkbox-control{display:inline-block;margin-right:.06rem;position:relative;flex-shrink:0}.ab-checkbox-control svg{position:absolute;left:0;top:0;width:1em;height:1em;user-select:none;flex-shrink:0;fill:currentcolor;stroke:none}.ab-checkbox-outer{position:absolute;left:0;top:0;border:1px solid #b0b0b0;border-radius:.02rem;background-color:#fff}.ab-checkbox-checked .ab-checkbox-check{opacity:1;transform:scale(1);transition:.2s cubic-bezier(.12,.4,.29,1.46) .1s}.ab-checkbox-disabled{cursor:not-allowed;color:rgba(0,0,0,.25)}.ab-checkbox-disabled .ab-checkbox-input{cursor:not-allowed}.ab-checkbox-disabled span.ab-checkbox-control .ab-checkbox-outer{border-color:#f0f0f0;background-color:#f5f5f5}.ab-checkbox-disabled svg.ab-checkbox-check{color:#cecece}.ab-checkbox-white .ab-checkbox-check{color:#e84040}.ab-checkbox-blue .ab-checkbox-check{color:#fff}.ab-checkbox-blue.ab-checkbox-checked .ab-checkbox-outer{background-color:#0075ff;border-color:#0075ff}.ab-checkbox-group{display:flex;flex-wrap:wrap}.ab-checkbox-group .ab-checkbox{margin-right:.08rem}
1
+ .ab-checkbox{cursor:pointer;display:inline-flex;align-items:center;user-select:none;position:relative}.ab-checkbox-input{cursor:pointer;position:absolute;opacity:0;margin:0;padding:0;z-index:2}.ab-checkbox-inner{display:inline-block;margin-right:.06rem;position:relative;border:1px solid #b0b0b0;border-radius:.02rem;background-color:#fff;transition:.3s;flex-shrink:0}.ab-checkbox-inner::after{box-sizing:border-box;position:absolute;top:45%;left:22%;display:table;width:37.5%;height:62.5%;border-style:solid;border-width:2px;border-top:0;border-inline-start:0;transform:rotate(45deg) scale(0) translate(-50%,-50%);opacity:0;content:"";transition:.2s cubic-bezier(.71,-.46,.88,.6),opacity .1s}.ab-checkbox-checked .ab-checkbox-inner::after{opacity:1;transform:rotate(45deg) scale(1) translate(-50%,-50%);transition:.2s cubic-bezier(.12,.4,.29,1.46) .1s}.ab-checkbox-disabled{cursor:not-allowed;color:rgba(0,0,0,.25)}.ab-checkbox-disabled .ab-checkbox-inner{border-color:#f0f0f0;background-color:#f5f5f5}.ab-checkbox-disabled .ab-checkbox-input{cursor:not-allowed}.ab-checkbox-white .ab-checkbox-inner::after{border-color:#e84040}.ab-checkbox-white.ab-checkbox-disabled .ab-checkbox-inner::after{border-color:#cecece}.ab-checkbox-blue .ab-checkbox-inner::after{border-color:#fff}.ab-checkbox-blue.ab-checkbox-checked .ab-checkbox-inner{transition:none;background-color:#0075ff;border-color:#0075ff}.ab-checkbox-blue.ab-checkbox-disabled .ab-checkbox-inner{border-color:#f0f0f0;background-color:#f5f5f5}.ab-checkbox-blue.ab-checkbox-disabled .ab-checkbox-inner::after{border-color:#cecece}.ab-checkbox-group{display:flex;flex-wrap:wrap}.ab-checkbox-group .ab-checkbox{margin-right:.08rem}
package/esm/index.d.ts CHANGED
@@ -14,6 +14,10 @@ export type { MoveProps } from './move';
14
14
  export { default as Move } from './move';
15
15
  export type { ShowMoreProps } from './show-more';
16
16
  export { default as ShowMore } from './show-more';
17
+ export type { ReadMoreProps } from './read-more';
18
+ export { default as ReadMore } from './show-more';
19
+ export type { ReadMoreHtmlProps } from './read-more-html';
20
+ export { default as ReadMoreHtml } from './read-more-html';
17
21
  export type { SelectOptionItem, SelectProps, SelectPlacement } from './select';
18
22
  export { default as Select } from './select';
19
23
  export type { ConfirmProps } from './confirm';
@@ -61,3 +65,5 @@ export { default as Trigger } from './trigger';
61
65
  export { composeRef, supportRef, fillRef } from './trigger/ref';
62
66
  export type { RadioProps, RadioGroupProps, RadioValue, RadioOptionItem } from './radio';
63
67
  export { Radio, RadioGroup } from './radio';
68
+ export type { PortalProps } from './portal';
69
+ export { default as Portal } from './portal';
package/esm/index.js CHANGED
@@ -6,6 +6,8 @@ export { default as Popover } from './popover';
6
6
  export { default as Skeleton } from './skeleton';
7
7
  export { default as Move } from './move';
8
8
  export { default as ShowMore } from './show-more';
9
+ export { default as ReadMore } from './show-more';
10
+ export { default as ReadMoreHtml } from './read-more-html';
9
11
  export { default as Select } from './select';
10
12
  export { default as Confirm } from './confirm';
11
13
  export { default as Collapse } from './collapse';
@@ -29,4 +31,5 @@ export { default as LoadingBar } from './loading-bar';
29
31
  export { default as LoadingIcon } from './loading-icon';
30
32
  export { default as Trigger } from './trigger';
31
33
  export { composeRef, supportRef, fillRef } from './trigger/ref';
32
- export { Radio, RadioGroup } from './radio';
34
+ export { Radio, RadioGroup } from './radio';
35
+ export { default as Portal } from './portal';
@@ -8,6 +8,10 @@ export interface AdornProps {
8
8
  * 样式前缀,这个需要使用者提供前缀
9
9
  */
10
10
  prefixCls: string;
11
+ /**
12
+ * 包裹input父级元素标签名
13
+ */
14
+ wrapTagName?: string;
11
15
  /**
12
16
  * 样式
13
17
  */
@@ -47,17 +47,21 @@ var Adorn = function Adorn(props) {
47
47
  onBlur(ev);
48
48
  }
49
49
  }, [onBlur, disabled]);
50
- return /*#__PURE__*/React.createElement("div", {
50
+ var WrapTagName = props.wrapTagName;
51
+ return /*#__PURE__*/React.createElement(WrapTagName, {
51
52
  className: classNames(prefixCls, className, (_a = {}, _a["".concat(prefixCls, "-enter")] = isEnter || isFocus, _a), (_b = {}, _b["".concat(prefixCls, "-focus")] = isFocus, _b), (_c = {}, _c["".concat(prefixCls, "-disabled")] = disabled, _c)),
52
53
  onMouseEnter: onMouseEnterCallback,
53
54
  onMouseLeave: onMouseLeaveCallback
54
- }, !isBlank(prefix) ? /*#__PURE__*/React.createElement("div", {
55
+ }, !isBlank(prefix) ? /*#__PURE__*/React.createElement("span", {
55
56
  className: "".concat(prefixCls, "-prefix")
56
57
  }, prefix) : null, /*#__PURE__*/React.cloneElement(children, {
57
58
  onFocus: onFocusCallback,
58
59
  onBlur: onBlurCallback
59
- }), !isBlank(suffix) ? /*#__PURE__*/React.createElement("div", {
60
+ }), !isBlank(suffix) ? /*#__PURE__*/React.createElement("span", {
60
61
  className: "".concat(prefixCls, "-suffix")
61
62
  }, suffix) : null);
62
63
  };
64
+ Adorn.defaultProps = {
65
+ wrapTagName: 'div'
66
+ };
63
67
  export default Adorn;
@@ -54,6 +54,7 @@ export declare class InputNotRef extends React.Component<InputPropsWithRef, Inpu
54
54
  inputRef: React.RefObject<HTMLInputElement>;
55
55
  static defaultProps: {
56
56
  defaultValue: string;
57
+ wrapTagName: string;
57
58
  type: string;
58
59
  checkValueOnMounted: boolean;
59
60
  };
@@ -207,10 +207,12 @@ var InputNotRef = /** @class */function (_super) {
207
207
  title = _a.title,
208
208
  onKeyUp = _a.onKeyUp,
209
209
  name = _a.name,
210
- autoComplete = _a.autoComplete;
210
+ autoComplete = _a.autoComplete,
211
+ wrapTagName = _a.wrapTagName;
211
212
  var value = this.state.value;
212
213
  var isFileUpload = this.isFileUpload();
213
214
  return /*#__PURE__*/React.createElement(Adorn, {
215
+ wrapTagName: wrapTagName,
214
216
  prefixCls: cls,
215
217
  onFocus: this.onFocus,
216
218
  onBlur: this.onBlur,
@@ -239,6 +241,8 @@ var InputNotRef = /** @class */function (_super) {
239
241
  };
240
242
  InputNotRef.defaultProps = {
241
243
  defaultValue: '',
244
+ // TODO:: 在改动最小的情况下设置默认是div, 后续升级时默认需改成label
245
+ wrapTagName: 'div',
242
246
  type: 'text',
243
247
  checkValueOnMounted: false
244
248
  };
@@ -54,6 +54,7 @@ export declare class TextAreaNotRef extends React.Component<TextAreaPropsWithRef
54
54
  textareaRef: React.RefObject<HTMLTextAreaElement>;
55
55
  static defaultProps: {
56
56
  defaultValue: string;
57
+ wrapTagName: string;
57
58
  rows: number;
58
59
  maxlength: number;
59
60
  checkValueOnMounted: boolean;
@@ -176,10 +176,12 @@ var TextAreaNotRef = /** @class */function (_super) {
176
176
  prefix = _a.prefix,
177
177
  rows = _a.rows,
178
178
  maxLength = _a.maxLength,
179
- name = _a.name;
179
+ name = _a.name,
180
+ wrapTagName = _a.wrapTagName;
180
181
  var value = this.state.value;
181
182
  return /*#__PURE__*/React.createElement(Adorn, {
182
183
  prefixCls: cls,
184
+ wrapTagName: wrapTagName,
183
185
  onFocus: this.onFocus,
184
186
  onBlur: this.onBlur,
185
187
  className: className,
@@ -202,6 +204,7 @@ var TextAreaNotRef = /** @class */function (_super) {
202
204
  };
203
205
  TextAreaNotRef.defaultProps = {
204
206
  defaultValue: '',
207
+ wrapTagName: 'div',
205
208
  rows: 5,
206
209
  maxlength: 0,
207
210
  checkValueOnMounted: false
@@ -81,6 +81,7 @@ export declare class InputNumberNotRef extends React.Component<InputNumberPropsW
81
81
  keyboardHandler: AddListenerEventRemoveHandler;
82
82
  static defaultProps: {
83
83
  defaultValue: string;
84
+ wrapTagName: string;
84
85
  controls: boolean;
85
86
  isAllowNumberWithDotAndMinus: boolean;
86
87
  isOnlyAllowNumber: boolean;
@@ -282,7 +282,8 @@ var InputNumberNotRef = /** @class */function (_super) {
282
282
  controls = _b.controls,
283
283
  isValueToString = _b.isValueToString,
284
284
  checkValueOnMounted = _b.checkValueOnMounted,
285
- maxLength = _b.maxLength;
285
+ maxLength = _b.maxLength,
286
+ wrapTagName = _b.wrapTagName;
286
287
  var originalValueStr = this.state.originalValueStr;
287
288
  var hasControls = controls && !isValueToString;
288
289
  return /*#__PURE__*/React.createElement(Input, {
@@ -290,12 +291,14 @@ var InputNumberNotRef = /** @class */function (_super) {
290
291
  className: classNames(cls, className, (_a = {}, _a["".concat(cls, "-has-controls")] = hasControls, _a)),
291
292
  placeholder: placeholder,
292
293
  disabled: disabled,
294
+ wrapTagName: wrapTagName,
293
295
  style: style,
294
296
  prefix: prefix,
295
297
  name: name,
296
298
  value: originalValueStr,
297
299
  onChange: this.onChange,
298
300
  onKeyDown: this.onKeyDown,
301
+ "aria-label": this.props['aria-label'],
299
302
  onBlur: this.onBlur,
300
303
  onFocus: this.onFocus,
301
304
  suffix: hasControls ? /*#__PURE__*/React.createElement(ControlArrow, {
@@ -309,6 +312,7 @@ var InputNumberNotRef = /** @class */function (_super) {
309
312
  };
310
313
  InputNumberNotRef.defaultProps = {
311
314
  defaultValue: '',
315
+ wrapTagName: 'div',
312
316
  controls: true,
313
317
  isAllowNumberWithDotAndMinus: false,
314
318
  isOnlyAllowNumber: false,
@@ -48,6 +48,7 @@ export declare class InputPhoneNotRef extends React.Component<InputPhonePropsWit
48
48
  onFocusTimer: ReturnType<typeof setTimeout>;
49
49
  static defaultProps: {
50
50
  defaultValue: string;
51
+ wrapTagName: string;
51
52
  format: string;
52
53
  placeholderChar: string;
53
54
  };
@@ -195,6 +195,7 @@ var InputPhoneNotRef = /** @class */function (_super) {
195
195
  };
196
196
  InputPhoneNotRef.defaultProps = {
197
197
  defaultValue: '',
198
+ wrapTagName: 'div',
198
199
  format: '(111)111-1111',
199
200
  placeholderChar: '_'
200
201
  };
@@ -1,5 +1,9 @@
1
- import React, { MouseEventHandler, MouseEvent } from 'react';
2
- export interface LazyImageProps {
1
+ import React from 'react';
2
+ export interface LazyImageProps extends React.AllHTMLAttributes<HTMLElement> {
3
+ /**
4
+ * 标签名,默认div
5
+ */
6
+ tagName?: string;
3
7
  /**
4
8
  * 需要显示的图片
5
9
  */
@@ -9,34 +13,13 @@ export interface LazyImageProps {
9
13
  */
10
14
  alt: string;
11
15
  /**
12
- * 鼠标悬浮时显示的文字
16
+ * 图片额外的属性
13
17
  */
14
- title?: string;
18
+ imgHTMLAttributes?: React.ImgHTMLAttributes<HTMLImageElement>;
15
19
  /**
16
20
  * 类名
17
21
  */
18
22
  className?: string;
19
- /**
20
- * hover 图片,图片透明度(需要注意不要少了isMobile属性)
21
- */
22
- hoverOpacity?: number;
23
- /**
24
- * 判断是否是移动端,如果是移动端,将不再执行hoverOpacity, onMouseOver, onMouseOut
25
- */
26
- isMobile?: boolean;
27
- /**
28
- * 判断是否需要动态loading效果,如果提供了defaultImage,则不再有loading
29
- */
30
- active?: boolean;
31
- onClick?: MouseEventHandler<HTMLImageElement>;
32
- /**
33
- * 鼠标放上去的回调(方便自定义样式)
34
- */
35
- onMouseOver?: MouseEventHandler<HTMLImageElement>;
36
- /**
37
- * 鼠标离开的回调(方便自定义样式)
38
- */
39
- onMouseOut?: MouseEventHandler<HTMLImageElement>;
40
23
  /**
41
24
  * 加载图片时的回调
42
25
  */
@@ -55,10 +38,9 @@ interface LazyImageStates {
55
38
  }
56
39
  declare class LazyImage extends React.Component<LazyImageProps, LazyImageStates> {
57
40
  static defaultProps: {
41
+ tagName: string;
58
42
  className: string;
59
- hoverOpacity: any;
60
- isMobile: boolean;
61
- active: boolean;
43
+ imgHTMLAttributes: {};
62
44
  };
63
45
  prefixCls: string;
64
46
  rootRef: React.RefObject<HTMLImageElement>;
@@ -71,8 +53,6 @@ declare class LazyImage extends React.Component<LazyImageProps, LazyImageStates>
71
53
  * 监听原生lazy loading, 并回调不同的事件
72
54
  */
73
55
  originalLazyLoad: () => void;
74
- onMouseOut: (ev: MouseEvent<HTMLImageElement>) => void;
75
- onMouseOver: (ev: MouseEvent<HTMLImageElement>) => void;
76
56
  render(): JSX.Element;
77
57
  }
78
58
  export default LazyImage;
@@ -32,6 +32,16 @@ var __assign = this && this.__assign || function () {
32
32
  };
33
33
  return __assign.apply(this, arguments);
34
34
  };
35
+ var __rest = this && this.__rest || function (s, e) {
36
+ var t = {};
37
+ for (var p in s) {
38
+ if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
39
+ }
40
+ if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
41
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
42
+ }
43
+ return t;
44
+ };
35
45
  import React from 'react';
36
46
  import classNames from 'classnames';
37
47
  function noop() {}
@@ -90,36 +100,6 @@ var LazyImage = /** @class */function (_super) {
90
100
  };
91
101
  }
92
102
  };
93
- _this.onMouseOut = function (ev) {
94
- if (_this.props.isMobile) {
95
- return;
96
- }
97
- var _a = _this.props,
98
- hoverOpacity = _a.hoverOpacity,
99
- onMouseOut = _a.onMouseOut;
100
- var el = ev.target;
101
- if (hoverOpacity) {
102
- el.style.opacity = '1';
103
- }
104
- if (onMouseOut) {
105
- onMouseOut(ev);
106
- }
107
- };
108
- _this.onMouseOver = function (ev) {
109
- if (_this.props.isMobile) {
110
- return;
111
- }
112
- var _a = _this.props,
113
- hoverOpacity = _a.hoverOpacity,
114
- onMouseOver = _a.onMouseOver;
115
- var el = ev.target;
116
- if (hoverOpacity) {
117
- el.style.opacity = hoverOpacity.toString();
118
- }
119
- if (onMouseOver) {
120
- onMouseOver(ev);
121
- }
122
- };
123
103
  _this.state = {
124
104
  loading: true
125
105
  };
@@ -141,34 +121,33 @@ var LazyImage = /** @class */function (_super) {
141
121
  var cls = this.prefixCls;
142
122
  var _b = this.props,
143
123
  className = _b.className,
144
- active = _b.active;
124
+ alt = _b.alt,
125
+ src = _b.src,
126
+ imgHTMLAttributes = _b.imgHTMLAttributes,
127
+ tagName = _b.tagName,
128
+ onError = _b.onError,
129
+ onLoading = _b.onLoading,
130
+ onLoaded = _b.onLoaded,
131
+ extraProps = __rest(_b, ["className", "alt", "src", "imgHTMLAttributes", "tagName", "onError", "onLoading", "onLoaded"]);
145
132
  var loading = this.state.loading;
146
- var props = __assign({}, this.props);
147
- delete props.className;
148
- delete props.onMouseOver;
149
- delete props.onMouseOut;
150
- delete props.hoverOpacity;
151
- delete props.isMobile;
152
- delete props.active;
153
- delete props.onLoading;
154
- delete props.onLoaded;
155
- return /*#__PURE__*/React.createElement("img", __assign({
156
- alt: ""
157
- }, props, {
158
- className: classNames(cls, className, (_a = {}, _a["".concat(cls, "-loading")] = loading, _a["".concat(cls, "-active")] = loading && active, _a)),
159
- onMouseOver: this.onMouseOver,
160
- onMouseOut: this.onMouseOut,
133
+ var Wrapper = tagName;
134
+ // 需要图片根据容器自适应时,需增加mask
135
+ return /*#__PURE__*/React.createElement(Wrapper, __assign({}, extraProps, {
136
+ className: classNames(cls, className, (_a = {}, _a["".concat(cls, "-loading")] = loading, _a))
137
+ }), /*#__PURE__*/React.createElement("img", __assign({
161
138
  onFocus: noop,
162
- onBlur: noop,
139
+ onBlur: noop
140
+ }, imgHTMLAttributes, {
141
+ src: src,
142
+ alt: alt,
163
143
  ref: this.rootRef,
164
144
  loading: "lazy"
165
- }));
145
+ })));
166
146
  };
167
147
  LazyImage.defaultProps = {
148
+ tagName: 'div',
168
149
  className: '',
169
- hoverOpacity: null,
170
- isMobile: false,
171
- active: true
150
+ imgHTMLAttributes: {}
172
151
  };
173
152
  return LazyImage;
174
153
  }(React.Component);
@@ -1 +1 @@
1
- .ab-lazy-image{transition:opacity .5s}.ab-lazy-image-loading{background:#f2f2f2;overflow:hidden}.ab-lazy-image-loading.ab-lazy-image-active{background:linear-gradient(90deg,#f2f2f2 25%,#e6e6e6 37%,#f2f2f2 63%);background-size:400% 100%;animation:1.4s infinite ab-skeleton-loading}@keyframes ab-skeleton-loading{0%{background-position:100% 50%}100%{background-position:0 50%}}
1
+ .ab-lazy-image{position:relative;overflow:hidden;transition:opacity .5s;display:flex;align-items:center;justify-content:center}.ab-lazy-image::after{display:none;content:"";position:absolute;left:0;top:0;width:100%;height:100%}.ab-lazy-image-loading::after{display:block;background:linear-gradient(90deg,#f2f2f2 25%,#e6e6e6 37%,#f2f2f2 63%);background-size:400% 100%;animation:1.4s infinite ab-skeleton-loading}.ab-lazy-image img{display:block;max-width:100%;max-height:100%}@keyframes ab-skeleton-loading{0%{background-position:100% 50%}100%{background-position:0 50%}}
@@ -1,5 +1,4 @@
1
1
  import React from 'react';
2
- import { AddListenerEventRemoveHandler } from '@autobest-ui/utils';
3
2
  export interface LoadingContainerProps {
4
3
  /**
5
4
  * 容器是否loading
@@ -13,23 +12,6 @@ export interface LoadingContainerProps {
13
12
  * 内容区域
14
13
  */
15
14
  children?: React.ReactElement | React.ReactElement[];
16
- /**
17
- * LoadingIcon是否需要保持在可视区域内
18
- */
19
- loadingInView?: boolean;
20
- }
21
- declare class LoadingContainer extends React.Component<LoadingContainerProps> {
22
- prefixCls: string;
23
- addScrollHandlerListener: AddListenerEventRemoveHandler;
24
- wrapRef: React.RefObject<HTMLDivElement>;
25
- iconRef: React.RefObject<HTMLSpanElement>;
26
- componentDidMount(): void;
27
- componentDidUpdate(prevProps: Readonly<LoadingContainerProps>): void;
28
- componentWillUnmount(): void;
29
- addScrollListener: () => void;
30
- removeScrollListener: () => void;
31
- setIconTopStyle: (top: string) => void;
32
- onHandlerScroll: () => void;
33
- render(): JSX.Element;
34
15
  }
16
+ declare function LoadingContainer(props: LoadingContainerProps): JSX.Element;
35
17
  export default LoadingContainer;
@@ -1,125 +1,19 @@
1
- var __extends = this && this.__extends || function () {
2
- var _extendStatics = function extendStatics(d, b) {
3
- _extendStatics = Object.setPrototypeOf || {
4
- __proto__: []
5
- } instanceof Array && function (d, b) {
6
- d.__proto__ = b;
7
- } || function (d, b) {
8
- for (var p in b) {
9
- if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p];
10
- }
11
- };
12
- return _extendStatics(d, b);
13
- };
14
- return function (d, b) {
15
- if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
16
- _extendStatics(d, b);
17
- function __() {
18
- this.constructor = d;
19
- }
20
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
21
- };
22
- }();
23
- import React, { createRef } from 'react';
1
+ import React from 'react';
24
2
  import classNames from 'classnames';
25
- import { addEventListener, getElementSize, getOffsetAndSize, isInViewArea, throttleWithRAF } from '@autobest-ui/utils';
26
3
  import LoadingIcon from '../loading-icon';
27
- var LoadingContainer = /** @class */function (_super) {
28
- __extends(LoadingContainer, _super);
29
- function LoadingContainer() {
30
- var _this = _super !== null && _super.apply(this, arguments) || this;
31
- _this.prefixCls = 'ab-loading-container';
32
- _this.wrapRef = /*#__PURE__*/createRef();
33
- _this.iconRef = /*#__PURE__*/createRef();
34
- _this.addScrollListener = function () {
35
- if (!_this.addScrollHandlerListener) {
36
- // 滚动监听
37
- _this.addScrollHandlerListener = addEventListener(window, 'scroll', throttleWithRAF(_this.onHandlerScroll));
38
- }
39
- };
40
- _this.removeScrollListener = function () {
41
- if (_this.addScrollHandlerListener) {
42
- _this.addScrollHandlerListener();
43
- _this.addScrollHandlerListener = null;
44
- }
45
- };
46
- _this.setIconTopStyle = function (top) {
47
- _this.iconRef.current.style.top = top;
48
- };
49
- _this.onHandlerScroll = function () {
50
- var wrapElement = _this.wrapRef.current;
51
- if (!_this.props.loadingInView || !_this.props.loading || !wrapElement) {
52
- return;
53
- }
54
- var iconElement = _this.iconRef.current;
55
- if (!isInViewArea(wrapElement) || !iconElement) {
56
- // 组件在可视区域外
57
- return;
58
- }
59
- var halfIconHeight = getElementSize(iconElement).height / 2;
60
- var _a = getOffsetAndSize(wrapElement, true),
61
- top = _a.top,
62
- height = _a.height;
63
- var bottom = top + height;
64
- if (top >= 0 && bottom <= window.innerHeight) {
65
- // 整个组件都在可视区域内,直接在组件内居中显示LoadingIcon
66
- _this.setIconTopStyle('50%');
67
- return;
68
- }
69
- if (top < 0 && bottom > window.innerHeight) {
70
- // 组件超出浏览器可视区域,在浏览器可视区域居中显示LoadingIcon
71
- _this.setIconTopStyle("".concat(window.innerHeight / 2 - top, "px"));
72
- return;
73
- }
74
- if (top < 0) {
75
- // 组件上半部分超出可视区域
76
- var iconTop_1 = bottom / 2 - top;
77
- _this.setIconTopStyle("".concat(iconTop_1 > height - halfIconHeight ? height - halfIconHeight : iconTop_1, "px"));
78
- return;
79
- }
80
- // 组件下半部分超出可视区域
81
- var iconTop = (window.innerHeight - top) / 2;
82
- _this.setIconTopStyle("".concat(iconTop < halfIconHeight ? halfIconHeight : iconTop, "px"));
83
- };
84
- return _this;
85
- }
86
- LoadingContainer.prototype.componentDidMount = function () {
87
- if (this.props.loadingInView && this.props.loading) {
88
- this.onHandlerScroll();
89
- this.addScrollListener();
90
- }
91
- };
92
- LoadingContainer.prototype.componentDidUpdate = function (prevProps) {
93
- if (prevProps.loading !== this.props.loading || prevProps.loadingInView !== this.props.loadingInView) {
94
- if (this.props.loadingInView && this.props.loading) {
95
- this.onHandlerScroll();
96
- this.addScrollListener();
97
- return;
98
- }
99
- this.removeScrollListener();
100
- }
101
- };
102
- LoadingContainer.prototype.componentWillUnmount = function () {
103
- this.removeScrollListener();
104
- };
105
- LoadingContainer.prototype.render = function () {
106
- var _a;
107
- var cls = this.prefixCls;
108
- var _b = this.props,
109
- _c = _b.loading,
110
- loading = _c === void 0 ? false : _c,
111
- className = _b.className,
112
- children = _b.children;
113
- return /*#__PURE__*/React.createElement("div", {
114
- className: classNames(className, cls, (_a = {}, _a["".concat(cls, "-active")] = loading, _a)),
115
- ref: this.wrapRef
116
- }, children, loading && /*#__PURE__*/React.createElement("div", {
117
- className: "".concat(cls, "-icon-box")
118
- }, /*#__PURE__*/React.createElement(LoadingIcon, {
119
- className: "".concat(cls, "-icon"),
120
- ref: this.iconRef
121
- })));
122
- };
123
- return LoadingContainer;
124
- }(React.Component);
4
+ var cls = 'ab-loading-container';
5
+ function LoadingContainer(props) {
6
+ var _a;
7
+ var _b = props.loading,
8
+ loading = _b === void 0 ? false : _b,
9
+ className = props.className,
10
+ children = props.children;
11
+ return /*#__PURE__*/React.createElement("div", {
12
+ className: classNames(className, cls, (_a = {}, _a["".concat(cls, "-active")] = loading, _a))
13
+ }, children, loading && /*#__PURE__*/React.createElement("div", {
14
+ className: "".concat(cls, "-icon-box")
15
+ }, /*#__PURE__*/React.createElement(LoadingIcon, {
16
+ className: "".concat(cls, "-icon")
17
+ })));
18
+ }
125
19
  export default LoadingContainer;
@@ -2,5 +2,5 @@ import React from 'react';
2
2
  export interface LoadingIconProps {
3
3
  className?: string;
4
4
  }
5
- declare const _default: React.MemoExoticComponent<React.ForwardRefExoticComponent<LoadingIconProps & React.RefAttributes<HTMLSpanElement>>>;
5
+ declare const _default: React.MemoExoticComponent<(props: LoadingIconProps) => JSX.Element>;
6
6
  export default _default;