@autobest-ui/components 3.0.0-alpha.7 → 3.0.0-alpha.8

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 (43) hide show
  1. package/esm/accordion/CollapseItem.d.ts +14 -0
  2. package/esm/accordion/CollapseItem.js +56 -0
  3. package/esm/accordion/Item.d.ts +11 -14
  4. package/esm/accordion/Item.js +11 -23
  5. package/esm/accordion/index.d.ts +9 -6
  6. package/esm/accordion/index.js +29 -13
  7. package/esm/accordion/type.d.ts +8 -0
  8. package/esm/accordion/type.js +1 -0
  9. package/esm/date-picker/calendar/Day.js +4 -3
  10. package/esm/date-picker/calendar/grid/index.css +1 -1
  11. package/esm/date-picker/calendar/grid/index.d.ts +1 -1
  12. package/esm/date-picker/calendar/grid/index.js +2 -2
  13. package/esm/date-picker/calendar/index.css +1 -1
  14. package/esm/date-picker/index.js +1 -0
  15. package/esm/date-picker/style/index.css +1 -1
  16. package/esm/lazy-image/index.d.ts +10 -30
  17. package/esm/lazy-image/index.js +30 -51
  18. package/esm/lazy-image/style/index.css +1 -1
  19. package/esm/loading-container/index.d.ts +11 -2
  20. package/esm/loading-container/index.js +22 -8
  21. package/esm/style.css +1 -1
  22. package/lib/accordion/CollapseItem.d.ts +14 -0
  23. package/lib/accordion/CollapseItem.js +64 -0
  24. package/lib/accordion/Item.d.ts +11 -14
  25. package/lib/accordion/Item.js +11 -23
  26. package/lib/accordion/index.d.ts +9 -6
  27. package/lib/accordion/index.js +28 -12
  28. package/lib/accordion/type.d.ts +8 -0
  29. package/lib/accordion/type.js +5 -0
  30. package/lib/date-picker/calendar/Day.js +4 -3
  31. package/lib/date-picker/calendar/grid/index.css +1 -1
  32. package/lib/date-picker/calendar/grid/index.d.ts +1 -1
  33. package/lib/date-picker/calendar/grid/index.js +2 -2
  34. package/lib/date-picker/calendar/index.css +1 -1
  35. package/lib/date-picker/index.js +1 -0
  36. package/lib/date-picker/style/index.css +1 -1
  37. package/lib/lazy-image/index.d.ts +10 -30
  38. package/lib/lazy-image/index.js +30 -51
  39. package/lib/lazy-image/style/index.css +1 -1
  40. package/lib/loading-container/index.d.ts +11 -2
  41. package/lib/loading-container/index.js +22 -8
  42. package/lib/style.css +1 -1
  43. package/package.json +3 -3
@@ -0,0 +1,14 @@
1
+ import React from 'react';
2
+ import { CollapseProps } from '../collapse';
3
+ import { BaseAccordionItemProps } from './type';
4
+ /**
5
+ * 父组件传进来的值,不需要用户传入
6
+ */
7
+ export interface CollapseAccordionItemProps extends BaseAccordionItemProps, Pick<CollapseProps, 'title' | 'appear' | 'visible'> {
8
+ onClick?: () => void;
9
+ }
10
+ declare class CollapseAccordionItem extends React.Component<CollapseAccordionItemProps, null> {
11
+ getTitle: () => React.ReactElement<any, string | React.JSXElementConstructor<any>>;
12
+ render(): JSX.Element;
13
+ }
14
+ export default CollapseAccordionItem;
@@ -0,0 +1,56 @@
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 from 'react';
24
+ import Collapse from '../collapse';
25
+ var CollapseAccordionItem = /** @class */function (_super) {
26
+ __extends(CollapseAccordionItem, _super);
27
+ function CollapseAccordionItem() {
28
+ var _this = _super !== null && _super.apply(this, arguments) || this;
29
+ _this.getTitle = function () {
30
+ var _a = _this.props,
31
+ title = _a.title,
32
+ onClick = _a.onClick;
33
+ if (!title) {
34
+ return null;
35
+ }
36
+ var child = React.Children.only(title);
37
+ return /*#__PURE__*/React.cloneElement(child, {
38
+ onClick: onClick
39
+ });
40
+ };
41
+ return _this;
42
+ }
43
+ CollapseAccordionItem.prototype.render = function () {
44
+ var _a = this.props,
45
+ appear = _a.appear,
46
+ children = _a.children,
47
+ visible = _a.visible;
48
+ return /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(Collapse, {
49
+ title: this.getTitle(),
50
+ visible: visible,
51
+ appear: appear
52
+ }, children));
53
+ };
54
+ return CollapseAccordionItem;
55
+ }(React.Component);
56
+ export default CollapseAccordionItem;
@@ -1,22 +1,19 @@
1
1
  import React from 'react';
2
- import { CollapseProps } from '../collapse';
3
- /**
4
- * 暴露给用户的接口,用于接收来自用户输入的参数
5
- */
6
- export interface BaseAccordionItemProps extends Pick<CollapseProps, 'title' | 'appear'> {
2
+ import { BaseAccordionItemProps } from './type';
3
+ interface AccordionItemChild {
7
4
  /**
8
- * 用于标识Item
5
+ * 是否是展开状态
9
6
  */
10
- name: React.ReactText;
7
+ visible: boolean;
8
+ /**
9
+ * 点击触发后改变Visible状态
10
+ */
11
+ onClick?: () => void;
11
12
  }
12
- /**
13
- * 父组件传进来的值,不需要用户传入
14
- */
15
- export interface AccordionItemProps extends BaseAccordionItemProps, Pick<CollapseProps, 'visible'> {
16
- onTitleClick?: () => void;
13
+ export interface AccordionItemProps extends BaseAccordionItemProps, Partial<AccordionItemChild> {
14
+ children: React.ReactElement | ((params: AccordionItemChild) => React.ReactElement);
17
15
  }
18
16
  declare class AccordionItem extends React.Component<AccordionItemProps, null> {
19
- getTitle: () => React.ReactElement<any, string | React.JSXElementConstructor<any>>;
20
- render(): JSX.Element;
17
+ render(): React.ReactElement<any, string | React.JSXElementConstructor<any>> | (((params: AccordionItemChild) => React.ReactElement<any, string | React.JSXElementConstructor<any>>) & string) | (((params: AccordionItemChild) => React.ReactElement<any, string | React.JSXElementConstructor<any>>) & number) | (((params: AccordionItemChild) => React.ReactElement<any, string | React.JSXElementConstructor<any>>) & false) | (((params: AccordionItemChild) => React.ReactElement<any, string | React.JSXElementConstructor<any>>) & true);
21
18
  }
22
19
  export default AccordionItem;
@@ -21,35 +21,23 @@ var __extends = this && this.__extends || function () {
21
21
  };
22
22
  }();
23
23
  import React from 'react';
24
- import Collapse from '../collapse';
25
24
  var AccordionItem = /** @class */function (_super) {
26
25
  __extends(AccordionItem, _super);
27
26
  function AccordionItem() {
28
- var _this = _super !== null && _super.apply(this, arguments) || this;
29
- _this.getTitle = function () {
30
- var _a = _this.props,
31
- title = _a.title,
32
- onTitleClick = _a.onTitleClick;
33
- if (!title) {
34
- return null;
35
- }
36
- var child = React.Children.only(title);
37
- return /*#__PURE__*/React.cloneElement(child, {
38
- onClick: onTitleClick
39
- });
40
- };
41
- return _this;
27
+ return _super !== null && _super.apply(this, arguments) || this;
42
28
  }
43
29
  AccordionItem.prototype.render = function () {
44
30
  var _a = this.props,
45
- appear = _a.appear,
46
- children = _a.children,
47
- visible = _a.visible;
48
- return /*#__PURE__*/React.createElement("li", null, /*#__PURE__*/React.createElement(Collapse, {
49
- title: this.getTitle(),
50
- visible: visible,
51
- appear: appear
52
- }, children));
31
+ onClick = _a.onClick,
32
+ visible = _a.visible,
33
+ children = _a.children;
34
+ if (typeof children === 'function') {
35
+ return children({
36
+ onClick: onClick,
37
+ visible: visible
38
+ });
39
+ }
40
+ return children;
53
41
  };
54
42
  return AccordionItem;
55
43
  }(React.Component);
@@ -1,5 +1,6 @@
1
1
  import React from 'react';
2
- import { BaseAccordionItemProps } from './Item';
2
+ import { CollapseAccordionItemProps } from './CollapseItem';
3
+ import { AccordionItemProps } from './Item';
3
4
  export interface AccordionProps {
4
5
  children: React.ReactElement | React.ReactElement[];
5
6
  /**
@@ -12,12 +13,13 @@ export interface AccordionProps {
12
13
  interactive?: boolean;
13
14
  /**
14
15
  * visible改变前执行的方法
16
+ * 如果返回false,则不执行这次visible变更;如果返回true,则执行这次visible变更
15
17
  */
16
- beforeVisibleChange?: (name?: React.ReactText) => boolean;
18
+ beforeVisibleChange?: (visible: boolean, name?: React.ReactText) => boolean;
17
19
  /**
18
20
  * visible改变后执行的方法
19
21
  */
20
- onVisibleChange?: (name?: React.ReactText, visible?: boolean) => void;
22
+ afterVisibleChange?: (visible: boolean, name?: React.ReactText) => void;
21
23
  /**
22
24
  * 需要一开始显示的Item name集合
23
25
  */
@@ -25,19 +27,20 @@ export interface AccordionProps {
25
27
  }
26
28
  interface AccordionState {
27
29
  visibleNames: {
28
- [propName: string]: boolean;
29
- [propName: number]: boolean;
30
+ [propName: React.ReactText]: boolean;
30
31
  };
31
32
  }
32
33
  declare class Accordion extends React.Component<AccordionProps, AccordionState> {
33
34
  readonly prefixCls = "ab-accordion";
34
- static Item: React.ComponentType<BaseAccordionItemProps>;
35
+ static CollapseItem: React.ComponentType<Omit<CollapseAccordionItemProps, "visible" | "onClick">>;
36
+ static Item: React.ComponentType<Pick<AccordionItemProps, "name" | "children">>;
35
37
  constructor(props: any);
36
38
  static defaultProps: {
37
39
  className: string;
38
40
  interactive: boolean;
39
41
  defaultVisibleNames: any[];
40
42
  };
43
+ refresh: () => void;
41
44
  /** *
42
45
  * 展开下拉链接列表
43
46
  * @param name
@@ -34,13 +34,26 @@ var __assign = this && this.__assign || function () {
34
34
  };
35
35
  import React from 'react';
36
36
  import classNames from 'classnames';
37
- import { isEmptyArray } from '@autobest-ui/utils';
37
+ import { isBlank, isEmptyArray } from '@autobest-ui/utils';
38
+ import CollapseAccordionItem from './CollapseItem';
38
39
  import AccordionItem from './Item';
39
40
  var Accordion = /** @class */function (_super) {
40
41
  __extends(Accordion, _super);
41
42
  function Accordion(props) {
42
43
  var _this = _super.call(this, props) || this;
43
44
  _this.prefixCls = 'ab-accordion';
45
+ _this.refresh = function () {
46
+ var visibleNames = {};
47
+ var defaultVisibleNames = _this.props.defaultVisibleNames;
48
+ if (!isEmptyArray(defaultVisibleNames)) {
49
+ defaultVisibleNames.forEach(function (name) {
50
+ visibleNames[name] = true;
51
+ });
52
+ }
53
+ _this.setState({
54
+ visibleNames: visibleNames
55
+ });
56
+ };
44
57
  /** *
45
58
  * 展开下拉链接列表
46
59
  * @param name
@@ -50,25 +63,25 @@ var Accordion = /** @class */function (_super) {
50
63
  var _c = _this.props,
51
64
  interactive = _c.interactive,
52
65
  beforeVisibleChange = _c.beforeVisibleChange,
53
- onVisibleChange = _c.onVisibleChange;
54
- if (beforeVisibleChange) {
55
- beforeVisibleChange(name);
56
- }
66
+ afterVisibleChange = _c.afterVisibleChange;
57
67
  var visibleNames = _this.state.visibleNames;
58
- var isCurVisible = visibleNames[name];
68
+ var nextVisible = !visibleNames[name];
69
+ if (beforeVisibleChange && !beforeVisibleChange(nextVisible, name)) {
70
+ return;
71
+ }
59
72
  if (interactive) {
60
73
  // 能同时展开多项,只对当前项做展开/闭合操作
61
74
  _this.setState({
62
- visibleNames: __assign(__assign({}, visibleNames), (_a = {}, _a[name] = !isCurVisible, _a))
75
+ visibleNames: __assign(__assign({}, visibleNames), (_a = {}, _a[name] = nextVisible, _a))
63
76
  });
64
77
  } else {
65
78
  // 每次只能展开一项
66
79
  _this.setState({
67
- visibleNames: (_b = {}, _b[name] = !isCurVisible, _b)
80
+ visibleNames: (_b = {}, _b[name] = nextVisible, _b)
68
81
  });
69
82
  }
70
- if (onVisibleChange) {
71
- onVisibleChange(name, !isCurVisible);
83
+ if (afterVisibleChange) {
84
+ afterVisibleChange(nextVisible, name);
72
85
  }
73
86
  };
74
87
  var visibleNames = {};
@@ -90,20 +103,23 @@ var Accordion = /** @class */function (_super) {
90
103
  className = _a.className,
91
104
  children = _a.children;
92
105
  var visibleNames = this.state.visibleNames;
93
- return /*#__PURE__*/React.createElement("ul", {
106
+ return /*#__PURE__*/React.createElement("div", {
94
107
  className: classNames(cls, className)
95
108
  }, React.Children.map(children, function (child) {
96
109
  var name = child.props.name;
110
+ if (isBlank(name)) {
111
+ return child;
112
+ }
97
113
  return /*#__PURE__*/React.cloneElement(child, {
98
114
  key: name,
99
- onTitleClick: function onTitleClick() {
115
+ onClick: function onClick() {
100
116
  _this.onVisibleChange(name);
101
117
  },
102
118
  visible: !!visibleNames[name]
103
119
  });
104
120
  }));
105
121
  };
106
- // 限制用户传入的参数,所以用BaseAccordionItemProps
122
+ Accordion.CollapseItem = CollapseAccordionItem;
107
123
  Accordion.Item = AccordionItem;
108
124
  Accordion.defaultProps = {
109
125
  className: '',
@@ -0,0 +1,8 @@
1
+ import React from 'react';
2
+ export interface BaseAccordionItemProps {
3
+ /**
4
+ * 用于标识Item
5
+ * 每个Item的name必须是唯一值
6
+ */
7
+ name: React.ReactText;
8
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -31,16 +31,17 @@ var DayCalendar = function DayCalendar(props) {
31
31
  isOut = false;
32
32
  }
33
33
  var disabled = isOutOfDate(date, minDate, maxDate);
34
+ var selected = compareDate(date, selectedDate) === 0;
34
35
  return {
35
36
  value: date,
36
37
  name: date.getDate(),
37
38
  disabled: disabled,
38
- selected: compareDate(date, selectedDate) === 0,
39
+ selected: selected,
39
40
  isToday: compareDate(date, today) === 0,
40
41
  onClick: disabled ? null : function () {
41
42
  return onSelect(date);
42
43
  },
43
- className: !disabled && isOut ? "".concat(cls, "-out") : null
44
+ isOut: !selected && !disabled && isOut
44
45
  };
45
46
  };
46
47
  var currentTitle = getTitle(navigatedDate);
@@ -79,7 +80,7 @@ var DayCalendar = function DayCalendar(props) {
79
80
  headList: currentHeadList,
80
81
  dateList: dayList
81
82
  };
82
- }, [today, navigatedDate, minDate, maxDate, firstDayOfWeek, selectedDate, onSelect, cls]),
83
+ }, [today, navigatedDate, minDate, maxDate, firstDayOfWeek, selectedDate, onSelect]),
83
84
  title = _a.title,
84
85
  startDate = _a.startDate,
85
86
  endDate = _a.endDate,
@@ -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}.ab-dp-cg-arrow{cursor:pointer}
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:#333;border-radius:4px}.ab-dp-cg-content>li:hover{background:#f0f0f0}.ab-dp-cg-content>li.ab-dp-cg-out{color:#666}.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{background:#0078d4;color:#fff}.ab-dp-cg-content>li.ab-dp-cg-selected:hover{background:#0078d4}.ab-dp-cg-content>li.ab-dp-cg-today{border:1px solid #0078d4}.ab-dp-cg-arrow{cursor:pointer}
@@ -1,10 +1,10 @@
1
1
  import React from 'react';
2
2
  export interface CalendarGridItemProps {
3
- className?: string;
4
3
  name: string;
5
4
  disabled: boolean;
6
5
  selected: boolean;
7
6
  isToday?: boolean;
7
+ isOut?: boolean;
8
8
  onClick: (event?: React.MouseEvent<HTMLElement, MouseEvent>) => void;
9
9
  }
10
10
  export interface CalendarGridProps {
@@ -46,10 +46,10 @@ var CalendarGrid = function CalendarGrid(_a) {
46
46
  })), /*#__PURE__*/React.createElement("ul", {
47
47
  className: "".concat(cls, "-content")
48
48
  }, list.map(function (item, index) {
49
- var _a, _b, _c;
49
+ var _a, _b, _c, _d;
50
50
  return /*#__PURE__*/React.createElement("li", {
51
51
  key: "".concat(index, " ").concat(item.name),
52
- className: classNames((_a = {}, _a["".concat(cls, "-dis")] = item.disabled, _a), (_b = {}, _b["".concat(cls, "-selected")] = item.selected, _b), (_c = {}, _c["".concat(cls, "-today")] = item.isToday, _c), item.className),
52
+ className: classNames((_a = {}, _a["".concat(cls, "-dis")] = item.disabled, _a), (_b = {}, _b["".concat(cls, "-selected")] = item.selected, _b), (_c = {}, _c["".concat(cls, "-today")] = item.isToday, _c), (_d = {}, _d["".concat(cls, "-out")] = item.isOut, _d)),
53
53
  onClick: item.onClick
54
54
  }, item.name);
55
55
  })), bottomElement);
@@ -1 +1 @@
1
- .ab-dp-cal{display:flex}.ab-dp-cal-my{padding-left:.12rem;margin-left:.12rem;border-left:1px solid #b0b0b0}.ab-dp-cal-day,.ab-dp-cal-my{width:2.1rem}.ab-dp-cal-dis{color:#c8c8c8}.ab-dp-cal-dg>ul>li{width:14.28%;height:.28rem}.ab-dp-cal-dg>ul>li.ab-dp-cal-out{color:#666}.ab-dp-cal-myg{padding-bottom:.62rem}.ab-dp-cal-myg>ul{justify-content:space-between}.ab-dp-cal-myg>ul>li{width:.4rem;height:.4rem;margin-bottom:.1rem}.ab-dp-cal-t{cursor:pointer;position:absolute;right:.08rem;bottom:.3rem}.ab-dp-cal-t.ab-dp-cal-t-dis{color:#b0b0b0;cursor:default}
1
+ .ab-dp-cal{display:flex}.ab-dp-cal-my{padding-left:.12rem;margin-left:.12rem;border-left:1px solid #b0b0b0}.ab-dp-cal-day,.ab-dp-cal-my{width:2.1rem}.ab-dp-cal-dis{color:#c8c8c8}.ab-dp-cal-dg>ul>li{width:14.28%;height:.28rem}.ab-dp-cal-myg{padding-bottom:.62rem}.ab-dp-cal-myg>ul{justify-content:space-between}.ab-dp-cal-myg>ul>li{width:.4rem;height:.4rem;margin-bottom:.1rem}.ab-dp-cal-t{cursor:pointer;position:absolute;right:.08rem;bottom:.3rem}.ab-dp-cal-t.ab-dp-cal-t-dis{color:#b0b0b0;cursor:default}
@@ -37,6 +37,7 @@ import classNames from 'classnames';
37
37
  import Popover from '../popover';
38
38
  import Calendar from './calendar';
39
39
  // TODO: 移动端
40
+ // TODO: 时区问题导致Date().getDate()获取到的日期会有±1天的时差
40
41
  var DatePicker = /** @class */function (_super) {
41
42
  __extends(DatePicker, _super);
42
43
  function DatePicker(props) {
@@ -1 +1 @@
1
- .ab-dp-cal{display:flex}.ab-dp-cal-my{padding-left:.12rem;margin-left:.12rem;border-left:1px solid #b0b0b0}.ab-dp-cal-day,.ab-dp-cal-my{width:2.1rem}.ab-dp-cal-dis{color:#c8c8c8}.ab-dp-cal-dg>ul>li{width:14.28%;height:.28rem}.ab-dp-cal-dg>ul>li.ab-dp-cal-out{color:#666}.ab-dp-cal-myg{padding-bottom:.62rem}.ab-dp-cal-myg>ul{justify-content:space-between}.ab-dp-cal-myg>ul>li{width:.4rem;height:.4rem;margin-bottom:.1rem}.ab-dp-cal-t{cursor:pointer;position:absolute;right:.08rem;bottom:.3rem}.ab-dp-cal-t.ab-dp-cal-t-dis{color:#b0b0b0;cursor:default}.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}.ab-trigger-wrap{position:absolute;top:0;left:0;z-index:101}.ab-trigger-wrap.ab-trigger-hidden{display:none}.ab-trigger-mask{position:fixed;top:0;left:0;bottom:0;right:0;z-index:101;background-color:transparent;display:none}.ab-trigger-mask.ab-trigger-mask-show{display:block}.ab-trigger-fade-appear,.ab-trigger-fade-enter,.ab-trigger-fade-hr-appear,.ab-trigger-fade-hr-enter{opacity:0}.ab-trigger-fade-appear,.ab-trigger-fade-enter{transform:scale(.7)}.ab-trigger-fade-hr-appear,.ab-trigger-fade-hr-enter{opacity:0;transform:scaleY(.7)}.ab-trigger-fade-appear-active,.ab-trigger-fade-enter-active,.ab-trigger-fade-hr-appear-active,.ab-trigger-fade-hr-enter-active{opacity:1;transition:opacity .2s,transform .2s}.ab-trigger-fade-appear-active,.ab-trigger-fade-enter-active{transform:scale(1)}.ab-trigger-fade-hr-appear-active,.ab-trigger-fade-hr-enter-active{transform:scaleY(1)}.ab-trigger-fade-exit,.ab-trigger-fade-hr-exit{opacity:1}.ab-trigger-fade-exit-active,.ab-trigger-fade-hr-exit-active{opacity:0;transition:opacity .2s,transform .2s}.ab-trigger-fade-exit-active{transform:scale(.7)}.ab-trigger-fade-hr-exit-active{transform:scaleY(.7)}.ab-trigger-fade-exit-done,.ab-trigger-fade-hr-exit-done{display:none}.ab-popover-wrap{background-clip:padding-box;min-width:210px;border-radius:4px}.ab-popover-inner{padding:.08rem .11rem .05rem;position:relative;width:100%;overflow:auto;font-size:.12rem}.ab-popover-inner-expand{padding-right:.1rem}.ab-popover-arrow{position:absolute;display:block;width:8px;height:8px;border-style:solid;box-shadow:3px 3px 7px rgba(0,0,0,.07)}.ab-popover-close{position:absolute;right:.02rem;top:.05rem;cursor:pointer;padding:0 .05rem;color:#bfbfbf;font-size:.2rem;line-height:1;z-index:2}.ab-popover-close:hover{color:#4a4a4a}.ab-popover-white{background-color:#fff;box-shadow:0 2px 8px rgba(0,0,0,.15)}.ab-popover-white .ab-popover-arrow{background-color:#fff;border-color:transparent #fff #fff transparent;border-width:4px}.ab-popover-orange{border:1px solid #906c00;box-shadow:1px 1px 5px -1px #000;background-color:#fffaec}.ab-popover-orange .ab-popover-arrow{background-color:#fffaec;border-color:transparent #906c00 #906c00 transparent;border-width:1px}@media only screen and (max-width:767px){.ab-popover-wrap{width:calc(100% - .3rem)}}.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%)}
1
+ .ab-dp-cal{display:flex}.ab-dp-cal-my{padding-left:.12rem;margin-left:.12rem;border-left:1px solid #b0b0b0}.ab-dp-cal-day,.ab-dp-cal-my{width:2.1rem}.ab-dp-cal-dis{color:#c8c8c8}.ab-dp-cal-dg>ul>li{width:14.28%;height:.28rem}.ab-dp-cal-myg{padding-bottom:.62rem}.ab-dp-cal-myg>ul{justify-content:space-between}.ab-dp-cal-myg>ul>li{width:.4rem;height:.4rem;margin-bottom:.1rem}.ab-dp-cal-t{cursor:pointer;position:absolute;right:.08rem;bottom:.3rem}.ab-dp-cal-t.ab-dp-cal-t-dis{color:#b0b0b0;cursor:default}.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:#333;border-radius:4px}.ab-dp-cg-content>li:hover{background:#f0f0f0}.ab-dp-cg-content>li.ab-dp-cg-out{color:#666}.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{background:#0078d4;color:#fff}.ab-dp-cg-content>li.ab-dp-cg-selected:hover{background:#0078d4}.ab-dp-cg-content>li.ab-dp-cg-today{border:1px solid #0078d4}.ab-dp-cg-arrow{cursor:pointer}.ab-trigger-wrap{position:absolute;top:0;left:0;z-index:101}.ab-trigger-wrap.ab-trigger-hidden{display:none}.ab-trigger-mask{position:fixed;top:0;left:0;bottom:0;right:0;z-index:101;background-color:transparent;display:none}.ab-trigger-mask.ab-trigger-mask-show{display:block}.ab-trigger-fade-appear,.ab-trigger-fade-enter,.ab-trigger-fade-hr-appear,.ab-trigger-fade-hr-enter{opacity:0}.ab-trigger-fade-appear,.ab-trigger-fade-enter{transform:scale(.7)}.ab-trigger-fade-hr-appear,.ab-trigger-fade-hr-enter{opacity:0;transform:scaleY(.7)}.ab-trigger-fade-appear-active,.ab-trigger-fade-enter-active,.ab-trigger-fade-hr-appear-active,.ab-trigger-fade-hr-enter-active{opacity:1;transition:opacity .2s,transform .2s}.ab-trigger-fade-appear-active,.ab-trigger-fade-enter-active{transform:scale(1)}.ab-trigger-fade-hr-appear-active,.ab-trigger-fade-hr-enter-active{transform:scaleY(1)}.ab-trigger-fade-exit,.ab-trigger-fade-hr-exit{opacity:1}.ab-trigger-fade-exit-active,.ab-trigger-fade-hr-exit-active{opacity:0;transition:opacity .2s,transform .2s}.ab-trigger-fade-exit-active{transform:scale(.7)}.ab-trigger-fade-hr-exit-active{transform:scaleY(.7)}.ab-trigger-fade-exit-done,.ab-trigger-fade-hr-exit-done{display:none}.ab-popover-wrap{background-clip:padding-box;min-width:210px;border-radius:4px}.ab-popover-inner{padding:.08rem .11rem .05rem;position:relative;width:100%;overflow:auto;font-size:.12rem}.ab-popover-inner-expand{padding-right:.1rem}.ab-popover-arrow{position:absolute;display:block;width:8px;height:8px;border-style:solid;box-shadow:3px 3px 7px rgba(0,0,0,.07)}.ab-popover-close{position:absolute;right:.02rem;top:.05rem;cursor:pointer;padding:0 .05rem;color:#bfbfbf;font-size:.2rem;line-height:1;z-index:2}.ab-popover-close:hover{color:#4a4a4a}.ab-popover-white{background-color:#fff;box-shadow:0 2px 8px rgba(0,0,0,.15)}.ab-popover-white .ab-popover-arrow{background-color:#fff;border-color:transparent #fff #fff transparent;border-width:4px}.ab-popover-orange{border:1px solid #906c00;box-shadow:1px 1px 5px -1px #000;background-color:#fffaec}.ab-popover-orange .ab-popover-arrow{background-color:#fffaec;border-color:transparent #906c00 #906c00 transparent;border-width:1px}@media only screen and (max-width:767px){.ab-popover-wrap{width:calc(100% - .3rem)}}.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%)}
@@ -1,5 +1,9 @@
1
- import React, { MouseEventHandler, MouseEvent } from 'react';
2
- export interface LazyImageProps extends React.ImgHTMLAttributes<HTMLImageElement> {
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 extends React.ImgHTMLAttributes<HTMLImageElement
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%}}
@@ -17,17 +17,26 @@ export interface LoadingContainerProps {
17
17
  * LoadingIcon是否需要保持在可视区域内
18
18
  */
19
19
  loadingInView?: boolean;
20
+ /**
21
+ * loadingInView为true时才生效
22
+ * LoadingIcon距离边界最近距离
23
+ */
24
+ spaceToBorder: number;
20
25
  }
21
26
  declare class LoadingContainer extends React.Component<LoadingContainerProps> {
22
27
  prefixCls: string;
23
28
  addScrollHandlerListener: AddListenerEventRemoveHandler;
29
+ addResizeHandlerListener: AddListenerEventRemoveHandler;
24
30
  wrapRef: React.RefObject<HTMLDivElement>;
25
31
  iconRef: React.RefObject<HTMLSpanElement>;
32
+ static defaultProps: {
33
+ spaceToBorder: number;
34
+ };
26
35
  componentDidMount(): void;
27
36
  componentDidUpdate(prevProps: Readonly<LoadingContainerProps>): void;
28
37
  componentWillUnmount(): void;
29
- addScrollListener: () => void;
30
- removeScrollListener: () => void;
38
+ addListener: () => void;
39
+ removeListener: () => void;
31
40
  setIconTopStyle: (top: string) => void;
32
41
  onHandlerScroll: () => void;
33
42
  render(): JSX.Element;