@autobest-ui/components 1.2.0 → 1.4.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 (137) 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/index.d.ts +3 -4
  16. package/esm/index.js +0 -1
  17. package/esm/input-number/index.d.ts +30 -17
  18. package/esm/input-number/index.js +116 -36
  19. package/esm/style.css +9 -24
  20. package/esm/table/body/BodyRow.d.ts +9 -3
  21. package/esm/table/body/BodyRow.js +6 -2
  22. package/esm/table/body/index.d.ts +2 -2
  23. package/esm/table/body/index.js +8 -7
  24. package/esm/table/header/HeaderCell.d.ts +2 -2
  25. package/esm/table/header/HeaderCell.js +15 -7
  26. package/esm/table/header/HeaderRow.d.ts +2 -2
  27. package/esm/table/index.d.ts +4 -4
  28. package/esm/table/index.js +3 -3
  29. package/esm/table/interface.d.ts +9 -3
  30. package/esm/table/style/index.css +1 -1
  31. package/esm/table/style/index.js +0 -2
  32. package/esm/table/style/index.scss +2 -0
  33. package/lib/carousel/index.d.ts +13 -21
  34. package/lib/carousel/index.js +45 -80
  35. package/lib/carousel/style/index.css +1 -1
  36. package/lib/carousel/style/index.scss +1 -7
  37. package/lib/date-picker/calendar/grid/index.css +1 -1
  38. package/lib/date-picker/calendar/grid/index.js +17 -28
  39. package/lib/date-picker/calendar/grid/index.scss +4 -0
  40. package/lib/date-picker/calendar/index.d.ts +4 -0
  41. package/lib/date-picker/calendar/index.js +1 -1
  42. package/lib/date-picker/index.d.ts +17 -6
  43. package/lib/date-picker/index.js +61 -17
  44. package/lib/date-picker/style/index.css +1 -1
  45. package/lib/date-picker/style/index.js +0 -2
  46. package/lib/date-picker/style/index.scss +6 -1
  47. package/lib/index.d.ts +3 -4
  48. package/lib/index.js +0 -8
  49. package/lib/input-number/index.d.ts +30 -17
  50. package/lib/input-number/index.js +116 -36
  51. package/lib/style.css +9 -24
  52. package/lib/table/body/BodyRow.d.ts +9 -3
  53. package/lib/table/body/BodyRow.js +6 -2
  54. package/lib/table/body/index.d.ts +2 -2
  55. package/lib/table/body/index.js +8 -7
  56. package/lib/table/header/HeaderCell.d.ts +2 -2
  57. package/lib/table/header/HeaderCell.js +15 -8
  58. package/lib/table/header/HeaderRow.d.ts +2 -2
  59. package/lib/table/index.d.ts +4 -4
  60. package/lib/table/index.js +3 -3
  61. package/lib/table/interface.d.ts +9 -3
  62. package/lib/table/style/index.css +1 -1
  63. package/lib/table/style/index.js +0 -2
  64. package/lib/table/style/index.scss +2 -0
  65. package/package.json +2 -2
  66. package/esm/accordion/__stories__/style.css +0 -1
  67. package/esm/accordion/__stories__/style.scss +0 -59
  68. package/esm/affix/__stories__/style.css +0 -1
  69. package/esm/affix/__stories__/style.scss +0 -13
  70. package/esm/carousel/__stories__/style.css +0 -1
  71. package/esm/carousel/__stories__/style.scss +0 -41
  72. package/esm/collapse/__stories__/style.css +0 -1
  73. package/esm/collapse/__stories__/style.scss +0 -19
  74. package/esm/guide/__stories__/style.css +0 -1
  75. package/esm/guide/__stories__/style.scss +0 -14
  76. package/esm/icon/__stories__/iconNames.d.ts +0 -2
  77. package/esm/icon/__stories__/iconNames.js +0 -1
  78. package/esm/icon/__stories__/style.css +0 -1
  79. package/esm/icon/__stories__/style.scss +0 -40
  80. package/esm/icon/index.d.ts +0 -43
  81. package/esm/icon/index.js +0 -94
  82. package/esm/icon/style/index.css +0 -1
  83. package/esm/icon/style/index.d.ts +0 -1
  84. package/esm/icon/style/index.js +0 -5
  85. package/esm/icon/style/index.scss +0 -7
  86. package/esm/lazy-image/__stories__/style.css +0 -1
  87. package/esm/lazy-image/__stories__/style.scss +0 -9
  88. package/esm/loading-container/__stories__/style.css +0 -1
  89. package/esm/loading-container/__stories__/style.scss +0 -6
  90. package/esm/move/__stories__/style.css +0 -1
  91. package/esm/move/__stories__/style.scss +0 -6
  92. package/esm/popover/__stories__/style.css +0 -1
  93. package/esm/popover/__stories__/style.scss +0 -16
  94. package/esm/select/__stories__/style.css +0 -1
  95. package/esm/select/__stories__/style.scss +0 -8
  96. package/esm/skeleton/__stories__/style.css +0 -1
  97. package/esm/skeleton/__stories__/style.scss +0 -3
  98. package/esm/table/__stories__/style.css +0 -1
  99. package/esm/table/__stories__/style.scss +0 -34
  100. package/esm/tabs/__stories__/style.css +0 -1
  101. package/esm/tabs/__stories__/style.scss +0 -8
  102. package/lib/accordion/__stories__/style.css +0 -1
  103. package/lib/accordion/__stories__/style.scss +0 -59
  104. package/lib/affix/__stories__/style.css +0 -1
  105. package/lib/affix/__stories__/style.scss +0 -13
  106. package/lib/carousel/__stories__/style.css +0 -1
  107. package/lib/carousel/__stories__/style.scss +0 -41
  108. package/lib/collapse/__stories__/style.css +0 -1
  109. package/lib/collapse/__stories__/style.scss +0 -19
  110. package/lib/guide/__stories__/style.css +0 -1
  111. package/lib/guide/__stories__/style.scss +0 -14
  112. package/lib/icon/__stories__/iconNames.d.ts +0 -2
  113. package/lib/icon/__stories__/iconNames.js +0 -8
  114. package/lib/icon/__stories__/style.css +0 -1
  115. package/lib/icon/__stories__/style.scss +0 -40
  116. package/lib/icon/index.d.ts +0 -43
  117. package/lib/icon/index.js +0 -111
  118. package/lib/icon/style/index.css +0 -1
  119. package/lib/icon/style/index.d.ts +0 -1
  120. package/lib/icon/style/index.js +0 -7
  121. package/lib/icon/style/index.scss +0 -7
  122. package/lib/lazy-image/__stories__/style.css +0 -1
  123. package/lib/lazy-image/__stories__/style.scss +0 -9
  124. package/lib/loading-container/__stories__/style.css +0 -1
  125. package/lib/loading-container/__stories__/style.scss +0 -6
  126. package/lib/move/__stories__/style.css +0 -1
  127. package/lib/move/__stories__/style.scss +0 -6
  128. package/lib/popover/__stories__/style.css +0 -1
  129. package/lib/popover/__stories__/style.scss +0 -16
  130. package/lib/select/__stories__/style.css +0 -1
  131. package/lib/select/__stories__/style.scss +0 -8
  132. package/lib/skeleton/__stories__/style.css +0 -1
  133. package/lib/skeleton/__stories__/style.scss +0 -3
  134. package/lib/table/__stories__/style.css +0 -1
  135. package/lib/table/__stories__/style.scss +0 -34
  136. package/lib/tabs/__stories__/style.css +0 -1
  137. package/lib/tabs/__stories__/style.scss +0 -8
@@ -35,14 +35,14 @@ function Body(_a) {
35
35
  CheckCell: CheckCell,
36
36
  indent: 0
37
37
  }));
38
- var expandedRowKey = rowKey + " expanded";
39
- var expandedColumns = [{
40
- title: null,
41
- key: expandedRowKey,
42
- onRender: expandedRowRenderer
43
- }];
44
38
 
45
39
  if (expandable) {
40
+ var expandedRowKey = rowKey + " expanded";
41
+ var expandedColumns = [{
42
+ title: null,
43
+ key: expandedRowKey,
44
+ onRender: expandedRowRenderer
45
+ }];
46
46
  rows.push(React.createElement(BodyRow, {
47
47
  key: expandedRowKey,
48
48
  className: prefixCls + "-expand-row",
@@ -51,7 +51,8 @@ function Body(_a) {
51
51
  index: rowIndex,
52
52
  columns: expandedColumns,
53
53
  CheckCell: null,
54
- indent: CheckCell ? 1 : 0
54
+ indent: CheckCell ? 1 : 0,
55
+ isExpand: true
55
56
  }));
56
57
  }
57
58
  });
@@ -1,6 +1,6 @@
1
1
  import React from 'react';
2
- import { Column } from '../interface';
3
- export interface HeaderCellProps<T> extends Column<T> {
2
+ import { TableColumnInfo } from '../interface';
3
+ export interface HeaderCellProps<T> extends TableColumnInfo<T> {
4
4
  prefixCls: string;
5
5
  isSort: boolean;
6
6
  isSortedDescending?: boolean;
@@ -26,7 +26,6 @@ var __extends = this && this.__extends || function () {
26
26
 
27
27
  import React from 'react';
28
28
  import classNames from 'classnames';
29
- import Icon from '../../icon';
30
29
 
31
30
  var HeaderCell =
32
31
  /** @class */
@@ -61,12 +60,21 @@ function (_super) {
61
60
  return sortIcon(isSortedDescending);
62
61
  }
63
62
 
64
- return React.createElement(Icon, {
65
- className: prefixCls + "-arrow",
66
- name: "arrow",
67
- color: "#fff",
68
- transform: isSortedDescending ? 'rotate(180deg)' : null
69
- });
63
+ return React.createElement("span", {
64
+ className: prefixCls + "-arrow"
65
+ }, React.createElement("svg", {
66
+ style: isSortedDescending ? {
67
+ transform: 'rotate(180deg)'
68
+ } : null,
69
+ viewBox: "0 0 1024 1024",
70
+ version: "1.1",
71
+ width: "1em",
72
+ height: "1em",
73
+ fill: "currentColor",
74
+ xmlns: "http://www.w3.org/2000/svg"
75
+ }, React.createElement("path", {
76
+ 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"
77
+ })));
70
78
  };
71
79
 
72
80
  return _this;
@@ -1,9 +1,9 @@
1
- import { Column } from '../interface';
1
+ import { TableColumnInfo } from '../interface';
2
2
  import { HeaderCellProps } from './HeaderCell';
3
3
  import { HeaderRowSelectionInfo } from './CheckIcon';
4
4
  export interface HeaderRowProps<T> extends Pick<HeaderCellProps<T>, 'sortName' | 'isSortedDescending' | 'sortIcon'> {
5
5
  prefixCls: string;
6
- columns: Column<T>[];
6
+ columns: TableColumnInfo<T>[];
7
7
  /**
8
8
  * 点击表头触发的排序函数
9
9
  * @param isSortedDescending
@@ -1,11 +1,11 @@
1
1
  import React, { ReactText } from 'react';
2
2
  import { AddListenerEventHandler } from '@autobest-ui/utils';
3
- import { Column } from './interface';
3
+ import { TableColumnInfo } from './interface';
4
4
  import { HeaderRowProps } from './header/HeaderRow';
5
5
  import { BodyProps } from './body';
6
6
  import { HeaderRowSelectionInfo } from './header/CheckIcon';
7
7
  import { BodyRowSelectionInfo } from './body/CheckIcon';
8
- export interface RowSelectionInfo<T> extends Partial<Pick<HeaderRowSelectionInfo, 'selectAllVisible' | 'onSelectAll'>>, Partial<Pick<BodyRowSelectionInfo<T>, 'checkIcon'>> {
8
+ export interface TableRowSelectionInfo<T> extends Partial<Pick<HeaderRowSelectionInfo, 'selectAllVisible' | 'onSelectAll'>>, Partial<Pick<BodyRowSelectionInfo<T>, 'checkIcon'>> {
9
9
  defaultSelectedRowKeys?: ReactText[];
10
10
  getDisabled?: (dataRow: any, selectedRowKeys: ReactText[], selectedRows: T[]) => boolean;
11
11
  onSelect?: (checked: boolean, rowData: T, selectedRows: T[]) => void;
@@ -21,7 +21,7 @@ export interface TableProps<T> extends Pick<HeaderRowProps<T>, 'sortName' | 'sor
21
21
  * 定义每一列数据的格式
22
22
  * 具体类型见Column
23
23
  */
24
- columns: Column<T>[];
24
+ columns: TableColumnInfo<T>[];
25
25
  /**
26
26
  * 获取单条记录的唯一主键; 若是string类型,则取当前行数据中对应名称的属性值; 若是函数,则传入当前行数据,获取rowKey值;这也是勾选功能匹配时所用的key值
27
27
  */
@@ -41,7 +41,7 @@ export interface TableProps<T> extends Pick<HeaderRowProps<T>, 'sortName' | 'sor
41
41
  /**
42
42
  * 表格行是否可勾选,详见RowSelection
43
43
  */
44
- rowSelection?: RowSelectionInfo<T>;
44
+ rowSelection?: TableRowSelectionInfo<T>;
45
45
  /**
46
46
  * 默认勾选项数组, 以primaryKey取值
47
47
  */
@@ -74,9 +74,9 @@ function (_super) {
74
74
  return {
75
75
  selectedRowKeys: [],
76
76
  selectedRows: [],
77
- rowSelection: __assign(__assign({}, prevState.rowSelection), {
77
+ rowSelection: prevState.rowSelection ? __assign(__assign({}, prevState.rowSelection), {
78
78
  selectAllChecked: false
79
- })
79
+ }) : null
80
80
  };
81
81
  });
82
82
  };
@@ -243,7 +243,7 @@ function (_super) {
243
243
  };
244
244
 
245
245
  _this.getRowSelection = function () {
246
- if (!('rowSelection' in _this.props)) {
246
+ if (!('rowSelection' in _this.props) || !_this.props.rowSelection) {
247
247
  return null;
248
248
  }
249
249
 
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- export interface ColumnOnRenderReturnObjectInfo {
2
+ export interface TableColumnOnRenderReturnObjectInfo {
3
3
  children: React.ReactNode | React.ReactNode[];
4
4
  props: {
5
5
  className?: string;
@@ -7,7 +7,7 @@ export interface ColumnOnRenderReturnObjectInfo {
7
7
  colSpan?: number;
8
8
  };
9
9
  }
10
- export interface Column<T> {
10
+ export interface TableColumnInfo<T> {
11
11
  title: React.ReactNode | React.ReactNode[];
12
12
  key: string;
13
13
  dataIndex?: string;
@@ -18,5 +18,11 @@ export interface Column<T> {
18
18
  width?: string | number;
19
19
  className?: string;
20
20
  colSpan?: number;
21
- onRender?: (rowData: T, rowIndex: number, colIndex: number) => React.ReactNode | React.ReactNode[] | ColumnOnRenderReturnObjectInfo;
21
+ /**
22
+ * 渲染单元格内容的方法,不传则默认用dataIndex去取当前行对应属性值;入参分别为当前行数据,行索引, 列索引
23
+ * @param rowData
24
+ * @param rowIndex
25
+ * @param colIndex
26
+ */
27
+ onRender?: (rowData: T, rowIndex: number, colIndex: number) => React.ReactNode | React.ReactNode[] | TableColumnOnRenderReturnObjectInfo;
22
28
  }
@@ -1 +1 @@
1
- .ab-table{overflow-x:auto}.ab-table table{border-spacing:0;width:100%;table-layout:fixed}.ab-table-header{overflow:hidden}.ab-table-header table{width:calc(100% - .17rem)}.ab-table-body{overflow:auto scroll}.ab-table-checkbox{width:.32rem;text-align:center}.ab-table-title{display:flex;align-items:center;text-align:left}.ab-table-title.ab-table-point{cursor:pointer}.ab-table-arrow{padding:0 .05rem}@media only screen and (max-width:767px){.ab-table-header table{width:100%}}
1
+ .ab-table{overflow-x:auto}.ab-table table{border-spacing:0;width:100%;table-layout:fixed}.ab-table-header{overflow:hidden}.ab-table-header table{width:calc(100% - .17rem)}.ab-table-body{overflow:auto scroll}.ab-table-checkbox{width:.32rem;text-align:center}.ab-table-title{display:flex;align-items:center;text-align:left}.ab-table-title.ab-table-point{cursor:pointer}.ab-table-arrow{font-size:.16rem;color:#fff;padding:0 .05rem}@media only screen and (max-width:767px){.ab-table-header table{width:100%}}
@@ -6,6 +6,4 @@ if (canUseDOM) {
6
6
  require('../../loading-container/style/index');
7
7
 
8
8
  require('../../checkbox/style/index');
9
-
10
- require('../../icon/style/index');
11
9
  }
@@ -37,6 +37,8 @@ $namespace: ab-table;
37
37
  }
38
38
 
39
39
  &-arrow {
40
+ font-size: .16rem;
41
+ color: #fff;
40
42
  padding: 0 .05rem;
41
43
  }
42
44
  }
@@ -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
  */
@@ -5,7 +5,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
5
5
  Object.defineProperty(exports, "__esModule", {
6
6
  value: true
7
7
  });
8
- exports.default = exports.CarouselDirection = void 0;
8
+ exports.default = void 0;
9
9
 
10
10
  var _react = _interopRequireDefault(require("react"));
11
11
 
@@ -41,14 +41,6 @@ var __extends = void 0 && (void 0).__extends || function () {
41
41
  };
42
42
  }();
43
43
 
44
- var CarouselDirection;
45
- exports.CarouselDirection = CarouselDirection;
46
-
47
- (function (CarouselDirection) {
48
- CarouselDirection["vertical"] = "vertical";
49
- CarouselDirection["horizontal"] = "horizontal";
50
- })(CarouselDirection || (exports.CarouselDirection = CarouselDirection = {}));
51
-
52
44
  var Carousel =
53
45
  /** @class */
54
46
  function (_super) {
@@ -58,15 +50,14 @@ function (_super) {
58
50
  var _this = _super.call(this, props) || this;
59
51
 
60
52
  _this.prefixCls = 'ab-carousel';
61
- _this.listRef = _react.default.createRef(); // 当是horizontal时是width, 否则是height
62
-
63
- _this.sliderSize = 0;
64
- _this.contentSize = 0;
65
- _this.isDirectionLeftOrTop = true;
66
- _this.startSize = 0;
67
- _this.prevSize = 0;
68
- _this.moveSize = 0;
69
- _this.endSize = 0;
53
+ _this.listRef = _react.default.createRef();
54
+ _this.sliderWidth = 0;
55
+ _this.contentWidth = 0;
56
+ _this.isDirectionLeft = true;
57
+ _this.startX = 0;
58
+ _this.prevX = 0;
59
+ _this.moveX = 0;
60
+ _this.endX = 0;
70
61
  _this.autoplayTimer = null;
71
62
  _this.fadeEffectTimer = null;
72
63
 
@@ -81,20 +72,6 @@ function (_super) {
81
72
  _this.goTo = function (nextIndex, transition) {
82
73
  _this.interceptorChangePage(nextIndex - 1, transition);
83
74
  };
84
-
85
- _this.isHorizontalDirection = function () {
86
- return _this.props.direction === CarouselDirection.horizontal;
87
- };
88
-
89
- _this.setElementSizeByDirection = function (element, value) {
90
- var isHr = _this.isHorizontalDirection();
91
-
92
- if (isHr) {
93
- element.style.width = value;
94
- } else {
95
- element.style.height = value;
96
- }
97
- };
98
75
  /**
99
76
  * 获取滚动元素数量
100
77
  */
@@ -127,14 +104,11 @@ function (_super) {
127
104
  return;
128
105
  }
129
106
 
130
- var isHr = _this.isHorizontalDirection();
131
-
132
107
  var childCount = _this.getChildCount();
133
108
 
134
- var parentNodeOffset = (0, _utils.getElementSize)(element.parentNode);
135
- _this.contentSize = isHr ? parentNodeOffset.width : parentNodeOffset.height; // 没有子元素或者获取不到宽度
109
+ _this.contentWidth = (0, _utils.getElementSize)(element.parentNode).width; // 没有子元素或者获取不到宽度
136
110
 
137
- if (!childCount || !_this.contentSize) {
111
+ if (!childCount || !_this.contentWidth) {
138
112
  return;
139
113
  } // 执行一次,控制样式,显示slider
140
114
 
@@ -146,18 +120,23 @@ function (_super) {
146
120
  }
147
121
 
148
122
  var currentPage = _this.state.currentPage;
149
- var slidesPerView = _this.props.slidesPerView;
150
- _this.sliderSize = _this.contentSize / slidesPerView;
123
+ var _a = _this.props,
124
+ slidesPerView = _a.slidesPerView,
125
+ height = _a.height;
126
+ _this.sliderWidth = _this.contentWidth / slidesPerView;
127
+ element.style.width = _this.sliderWidth * childCount + "px";
151
128
 
152
- _this.setElementSizeByDirection(element, _this.sliderSize * childCount + "px");
129
+ if (height) {
130
+ element.style.height = height;
131
+ }
153
132
 
154
133
  var childList = Array.from(element.children);
155
134
  childList.forEach(function (child) {
156
- _this.setElementSizeByDirection(child, _this.sliderSize + "px");
135
+ child.style.width = _this.sliderWidth + "px";
157
136
  });
158
- _this.prevSize = -currentPage * _this.sliderSize;
137
+ _this.prevX = -currentPage * _this.sliderWidth;
159
138
 
160
- _this.setListStyles(element, _this.prevSize);
139
+ _this.setListStyles(element, _this.prevX);
161
140
 
162
141
  _this.onAutoplay();
163
142
  };
@@ -194,11 +173,11 @@ function (_super) {
194
173
  nextPage = 0;
195
174
  }
196
175
 
197
- _this.prevSize = -nextPage * _this.sliderSize;
176
+ _this.prevX = -nextPage * _this.sliderWidth;
198
177
 
199
178
  _this.onBeforeChange(nextPage);
200
179
 
201
- _this.setListStyles(element, _this.prevSize, transition);
180
+ _this.setListStyles(element, _this.prevX, transition);
202
181
 
203
182
  _this.setState({
204
183
  currentPage: nextPage
@@ -211,12 +190,12 @@ function (_super) {
211
190
  /**
212
191
  * 设置容器元素样式,分别是:透明度渐变与位置偏移
213
192
  * @param element
214
- * @param translateSize
193
+ * @param translateX
215
194
  * @param transition
216
195
  */
217
196
 
218
197
 
219
- _this.setListStyles = function (element, translateSize, transition) {
198
+ _this.setListStyles = function (element, translateX, transition) {
220
199
  element.style.transition = ''; // 当开启渐变时,直接执行渐变,将没有位置偏移动画
221
200
 
222
201
  if (_this.props.fadeEffect) {
@@ -232,17 +211,7 @@ function (_super) {
232
211
  element.style.transition = transition || _transition.default.TransformEaseInOut;
233
212
  }
234
213
 
235
- element.style.transform = _this.isHorizontalDirection() ? "translateX(" + translateSize + "px)" : "translateY(" + translateSize + "px)";
236
- };
237
-
238
- _this.getTouchSize = function (event) {
239
- var isHr = _this.isHorizontalDirection();
240
-
241
- if (event.touches) {
242
- return isHr ? event.touches[0].pageX : event.touches[0].pageY;
243
- }
244
-
245
- return isHr ? event.clientX : event.clientY;
214
+ element.style.transform = "translateX(" + translateX + "px)";
246
215
  };
247
216
 
248
217
  _this.onBeforeChange = function (currentPage) {
@@ -279,8 +248,8 @@ function (_super) {
279
248
 
280
249
  event.preventDefault();
281
250
  clearTimeout(_this.autoplayTimer);
282
- _this.endSize = 0;
283
- _this.startSize = _this.getTouchSize(event);
251
+ _this.endX = 0;
252
+ _this.startX = event.touches ? event.touches[0].pageX : event.clientX;
284
253
 
285
254
  var element = _this.getListDomNode();
286
255
 
@@ -302,9 +271,9 @@ function (_super) {
302
271
  }
303
272
 
304
273
  event.preventDefault();
305
- _this.endSize = _this.getTouchSize(event);
306
- _this.moveSize = _this.prevSize + _this.endSize - _this.startSize;
307
- _this.isDirectionLeftOrTop = _this.prevSize - _this.startSize <= _this.prevSize - _this.endSize;
274
+ _this.endX = event.touches ? event.touches[0].pageX : event.clientX;
275
+ _this.moveX = _this.prevX + _this.endX - _this.startX;
276
+ _this.isDirectionLeft = _this.prevX - _this.startX <= _this.prevX - _this.endX;
308
277
 
309
278
  var element = _this.getListDomNode();
310
279
 
@@ -312,7 +281,7 @@ function (_super) {
312
281
  return;
313
282
  }
314
283
 
315
- element.style.transform = _this.isHorizontalDirection() ? "translateX(" + _this.moveSize + "px)" : "translateY(" + _this.moveSize + "px)";
284
+ element.style.transform = "translateX(" + _this.moveX + "px)";
316
285
  };
317
286
  /**
318
287
  * 停止滑动,判断用户移动位置,确定用户最终滑动位置
@@ -339,9 +308,9 @@ function (_super) {
339
308
  var currentPage = _this.state.currentPage;
340
309
  var transition = _transition.default.TransformEaseOut; // 移动的偏移量
341
310
 
342
- var translateSize = Math.abs(_this.startSize - _this.endSize); // 判断用户未产生滑动,认为是点击
311
+ var translateX = Math.abs(_this.startX - _this.endX); // 判断用户未产生滑动,认为是点击
343
312
 
344
- if (_this.endSize === 0 || translateSize < sensitivity) {
313
+ if (_this.endX === 0 || translateX < sensitivity) {
345
314
  if (onClick) {
346
315
  onClick(_this.state.currentPage + 1);
347
316
  }
@@ -353,7 +322,7 @@ function (_super) {
353
322
 
354
323
  event.preventDefault(); // 移出左边临界点
355
324
 
356
- if (_this.moveSize >= 0) {
325
+ if (_this.moveX >= 0) {
357
326
  _this.interceptorChangePage(0, transition);
358
327
 
359
328
  return;
@@ -362,21 +331,21 @@ function (_super) {
362
331
  var childCount = _this.getChildCount(); // 移出右边临界点
363
332
 
364
333
 
365
- var listSize = _this.sliderSize * childCount;
366
- var moveX = Math.abs(_this.moveSize);
334
+ var listWidth = _this.sliderWidth * childCount;
335
+ var moveX = Math.abs(_this.moveX);
367
336
 
368
- if (moveX >= listSize - _this.contentSize) {
337
+ if (moveX >= listWidth - _this.contentWidth) {
369
338
  _this.interceptorChangePage(childCount - slidesPerView, transition);
370
339
 
371
340
  return;
372
341
  } // 未达到一页,判断是否超出sensitivity, 超出将加1
373
342
 
374
343
 
375
- var skipOne = translateSize % _this.sliderSize >= _this.props.sensitivity ? 1 : 0; // 滑动的完整页数
344
+ var skipOne = translateX % _this.sliderWidth >= _this.props.sensitivity ? 1 : 0; // 滑动的完整页数
376
345
 
377
- var skipCount = Math.floor(translateSize / _this.sliderSize); // 判断是否向左滑动
346
+ var skipCount = Math.floor(translateX / _this.sliderWidth); // 判断是否向左滑动
378
347
 
379
- if (_this.isDirectionLeftOrTop) {
348
+ if (_this.isDirectionLeft) {
380
349
  currentPage = currentPage + skipCount + skipOne;
381
350
  } else {
382
351
  currentPage -= skipCount + skipOne;
@@ -419,11 +388,9 @@ function (_super) {
419
388
  Carousel.prototype.componentDidUpdate = function (prevProps) {
420
389
  var _this = this;
421
390
 
422
- var _a = this.props,
423
- children = _a.children,
424
- direction = _a.direction;
391
+ var children = this.props.children;
425
392
 
426
- if (_react.default.Children.count(children) !== _react.default.Children.count(prevProps.children) || direction !== prevProps.direction) {
393
+ if (_react.default.Children.count(children) !== _react.default.Children.count(prevProps.children)) {
427
394
  this.init();
428
395
  } // 加入 resize 监听
429
396
 
@@ -474,9 +441,8 @@ function (_super) {
474
441
  className = _b.className,
475
442
  children = _b.children,
476
443
  pagination = _b.pagination;
477
- var isHr = this.isHorizontalDirection();
478
444
  return _react.default.createElement("div", {
479
- className: (0, _classnames.default)(cls, className, (_a = {}, _a[cls + "-init"] = this.state.initialized, _a[cls + "-hr"] = isHr, _a[cls + "-vt"] = !isHr, _a))
445
+ className: (0, _classnames.default)(cls, className, (_a = {}, _a[cls + "-init"] = this.state.initialized, _a))
480
446
  }, _react.default.createElement("div", {
481
447
  className: cls + "-content"
482
448
  }, _react.default.createElement("div", {
@@ -497,7 +463,6 @@ function (_super) {
497
463
 
498
464
 
499
465
  Carousel.defaultProps = {
500
- direction: CarouselDirection.horizontal,
501
466
  slidesPerView: 1,
502
467
  defaultValue: 1,
503
468
  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}
@@ -11,37 +11,24 @@ var _react = _interopRequireDefault(require("react"));
11
11
 
12
12
  var _classnames = _interopRequireDefault(require("classnames"));
13
13
 
14
- var _icon = _interopRequireDefault(require("../../../icon"));
15
-
16
- var __assign = void 0 && (void 0).__assign || function () {
17
- __assign = Object.assign || function (t) {
18
- for (var s, i = 1, n = arguments.length; i < n; i++) {
19
- s = arguments[i];
20
-
21
- for (var p in s) {
22
- if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
23
- }
24
- }
25
-
26
- return t;
27
- };
28
-
29
- return __assign.apply(this, arguments);
30
- };
31
-
32
14
  var cls = 'ab-dp-cg';
33
15
 
34
- var getArrowStyle = function getArrowStyle(direction, onClick) {
16
+ var renderArrow = function renderArrow(prefixCls, direction, onClick) {
35
17
  var enabled = !!onClick;
36
- return {
37
- name: 'arrow',
38
- width: 0.14,
39
- height: 0.28,
40
- color: enabled ? '#333' : '#808080',
41
- transform: direction,
42
- className: enabled ? cls + "-icon" : cls + "-dis-icon",
18
+ return _react.default.createElement("span", {
19
+ className: prefixCls + "-arrow",
43
20
  onClick: onClick
44
- };
21
+ }, _react.default.createElement("svg", {
22
+ style: direction,
23
+ viewBox: "0 0 1024 1024",
24
+ version: "1.1",
25
+ width: "0.14rem",
26
+ height: "0.28rem",
27
+ fill: enabled ? '#333' : '#808080',
28
+ xmlns: "http://www.w3.org/2000/svg"
29
+ }, _react.default.createElement("path", {
30
+ 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"
31
+ })));
45
32
  };
46
33
 
47
34
  var CalendarGrid = function CalendarGrid(_a) {
@@ -62,7 +49,9 @@ var CalendarGrid = function CalendarGrid(_a) {
62
49
  }, _react.default.createElement("strong", {
63
50
  className: (0, _classnames.default)((_b = {}, _b[cls + "-clickable"] = !!onClickTitle, _b)),
64
51
  onClick: onClickTitle
65
- }, title), _react.default.createElement(_icon.default, __assign({}, getArrowStyle('', onPrev))), _react.default.createElement(_icon.default, __assign({}, getArrowStyle('rotate(180deg)', onNext)))), _react.default.createElement("ul", {
52
+ }, title), renderArrow(cls, {}, onPrev), renderArrow(cls, {
53
+ transform: 'rotate(180deg)'
54
+ }, onNext)), _react.default.createElement("ul", {
66
55
  className: cls + "-head"
67
56
  }, headList.map(function (item, index) {
68
57
  return _react.default.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
  }