@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.
- package/esm/carousel/index.d.ts +13 -21
- package/esm/carousel/index.js +44 -77
- package/esm/carousel/style/index.css +1 -1
- package/esm/carousel/style/index.scss +1 -7
- package/esm/date-picker/calendar/grid/index.css +1 -1
- package/esm/date-picker/calendar/grid/index.js +17 -27
- package/esm/date-picker/calendar/grid/index.scss +4 -0
- package/esm/date-picker/calendar/index.d.ts +4 -0
- package/esm/date-picker/calendar/index.js +1 -1
- package/esm/date-picker/index.d.ts +17 -6
- package/esm/date-picker/index.js +62 -17
- package/esm/date-picker/style/index.css +1 -1
- package/esm/date-picker/style/index.js +0 -2
- package/esm/date-picker/style/index.scss +6 -1
- package/esm/index.d.ts +3 -4
- package/esm/index.js +0 -1
- package/esm/input-number/index.d.ts +30 -17
- package/esm/input-number/index.js +116 -36
- package/esm/style.css +9 -24
- package/esm/table/body/BodyRow.d.ts +9 -3
- package/esm/table/body/BodyRow.js +6 -2
- package/esm/table/body/index.d.ts +2 -2
- package/esm/table/body/index.js +8 -7
- package/esm/table/header/HeaderCell.d.ts +2 -2
- package/esm/table/header/HeaderCell.js +15 -7
- package/esm/table/header/HeaderRow.d.ts +2 -2
- package/esm/table/index.d.ts +4 -4
- package/esm/table/index.js +3 -3
- package/esm/table/interface.d.ts +9 -3
- package/esm/table/style/index.css +1 -1
- package/esm/table/style/index.js +0 -2
- package/esm/table/style/index.scss +2 -0
- package/lib/carousel/index.d.ts +13 -21
- package/lib/carousel/index.js +45 -80
- package/lib/carousel/style/index.css +1 -1
- package/lib/carousel/style/index.scss +1 -7
- package/lib/date-picker/calendar/grid/index.css +1 -1
- package/lib/date-picker/calendar/grid/index.js +17 -28
- package/lib/date-picker/calendar/grid/index.scss +4 -0
- package/lib/date-picker/calendar/index.d.ts +4 -0
- package/lib/date-picker/calendar/index.js +1 -1
- package/lib/date-picker/index.d.ts +17 -6
- package/lib/date-picker/index.js +61 -17
- package/lib/date-picker/style/index.css +1 -1
- package/lib/date-picker/style/index.js +0 -2
- package/lib/date-picker/style/index.scss +6 -1
- package/lib/index.d.ts +3 -4
- package/lib/index.js +0 -8
- package/lib/input-number/index.d.ts +30 -17
- package/lib/input-number/index.js +116 -36
- package/lib/style.css +9 -24
- package/lib/table/body/BodyRow.d.ts +9 -3
- package/lib/table/body/BodyRow.js +6 -2
- package/lib/table/body/index.d.ts +2 -2
- package/lib/table/body/index.js +8 -7
- package/lib/table/header/HeaderCell.d.ts +2 -2
- package/lib/table/header/HeaderCell.js +15 -8
- package/lib/table/header/HeaderRow.d.ts +2 -2
- package/lib/table/index.d.ts +4 -4
- package/lib/table/index.js +3 -3
- package/lib/table/interface.d.ts +9 -3
- package/lib/table/style/index.css +1 -1
- package/lib/table/style/index.js +0 -2
- package/lib/table/style/index.scss +2 -0
- package/package.json +2 -2
- package/esm/accordion/__stories__/style.css +0 -1
- package/esm/accordion/__stories__/style.scss +0 -59
- package/esm/affix/__stories__/style.css +0 -1
- package/esm/affix/__stories__/style.scss +0 -13
- package/esm/carousel/__stories__/style.css +0 -1
- package/esm/carousel/__stories__/style.scss +0 -41
- package/esm/collapse/__stories__/style.css +0 -1
- package/esm/collapse/__stories__/style.scss +0 -19
- package/esm/guide/__stories__/style.css +0 -1
- package/esm/guide/__stories__/style.scss +0 -14
- package/esm/icon/__stories__/iconNames.d.ts +0 -2
- package/esm/icon/__stories__/iconNames.js +0 -1
- package/esm/icon/__stories__/style.css +0 -1
- package/esm/icon/__stories__/style.scss +0 -40
- package/esm/icon/index.d.ts +0 -43
- package/esm/icon/index.js +0 -94
- package/esm/icon/style/index.css +0 -1
- package/esm/icon/style/index.d.ts +0 -1
- package/esm/icon/style/index.js +0 -5
- package/esm/icon/style/index.scss +0 -7
- package/esm/lazy-image/__stories__/style.css +0 -1
- package/esm/lazy-image/__stories__/style.scss +0 -9
- package/esm/loading-container/__stories__/style.css +0 -1
- package/esm/loading-container/__stories__/style.scss +0 -6
- package/esm/move/__stories__/style.css +0 -1
- package/esm/move/__stories__/style.scss +0 -6
- package/esm/popover/__stories__/style.css +0 -1
- package/esm/popover/__stories__/style.scss +0 -16
- package/esm/select/__stories__/style.css +0 -1
- package/esm/select/__stories__/style.scss +0 -8
- package/esm/skeleton/__stories__/style.css +0 -1
- package/esm/skeleton/__stories__/style.scss +0 -3
- package/esm/table/__stories__/style.css +0 -1
- package/esm/table/__stories__/style.scss +0 -34
- package/esm/tabs/__stories__/style.css +0 -1
- package/esm/tabs/__stories__/style.scss +0 -8
- package/lib/accordion/__stories__/style.css +0 -1
- package/lib/accordion/__stories__/style.scss +0 -59
- package/lib/affix/__stories__/style.css +0 -1
- package/lib/affix/__stories__/style.scss +0 -13
- package/lib/carousel/__stories__/style.css +0 -1
- package/lib/carousel/__stories__/style.scss +0 -41
- package/lib/collapse/__stories__/style.css +0 -1
- package/lib/collapse/__stories__/style.scss +0 -19
- package/lib/guide/__stories__/style.css +0 -1
- package/lib/guide/__stories__/style.scss +0 -14
- package/lib/icon/__stories__/iconNames.d.ts +0 -2
- package/lib/icon/__stories__/iconNames.js +0 -8
- package/lib/icon/__stories__/style.css +0 -1
- package/lib/icon/__stories__/style.scss +0 -40
- package/lib/icon/index.d.ts +0 -43
- package/lib/icon/index.js +0 -111
- package/lib/icon/style/index.css +0 -1
- package/lib/icon/style/index.d.ts +0 -1
- package/lib/icon/style/index.js +0 -7
- package/lib/icon/style/index.scss +0 -7
- package/lib/lazy-image/__stories__/style.css +0 -1
- package/lib/lazy-image/__stories__/style.scss +0 -9
- package/lib/loading-container/__stories__/style.css +0 -1
- package/lib/loading-container/__stories__/style.scss +0 -6
- package/lib/move/__stories__/style.css +0 -1
- package/lib/move/__stories__/style.scss +0 -6
- package/lib/popover/__stories__/style.css +0 -1
- package/lib/popover/__stories__/style.scss +0 -16
- package/lib/select/__stories__/style.css +0 -1
- package/lib/select/__stories__/style.scss +0 -8
- package/lib/skeleton/__stories__/style.css +0 -1
- package/lib/skeleton/__stories__/style.scss +0 -3
- package/lib/table/__stories__/style.css +0 -1
- package/lib/table/__stories__/style.scss +0 -34
- package/lib/tabs/__stories__/style.css +0 -1
- package/lib/tabs/__stories__/style.scss +0 -8
package/esm/table/body/index.js
CHANGED
|
@@ -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 {
|
|
3
|
-
export interface HeaderCellProps<T> extends
|
|
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(
|
|
65
|
-
className: prefixCls + "-arrow"
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
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 {
|
|
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:
|
|
6
|
+
columns: TableColumnInfo<T>[];
|
|
7
7
|
/**
|
|
8
8
|
* 点击表头触发的排序函数
|
|
9
9
|
* @param isSortedDescending
|
package/esm/table/index.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import React, { ReactText } from 'react';
|
|
2
2
|
import { AddListenerEventHandler } from '@autobest-ui/utils';
|
|
3
|
-
import {
|
|
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
|
|
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:
|
|
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?:
|
|
44
|
+
rowSelection?: TableRowSelectionInfo<T>;
|
|
45
45
|
/**
|
|
46
46
|
* 默认勾选项数组, 以primaryKey取值
|
|
47
47
|
*/
|
package/esm/table/index.js
CHANGED
|
@@ -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
|
|
package/esm/table/interface.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
export interface
|
|
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
|
|
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
|
-
|
|
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%}}
|
package/esm/table/style/index.js
CHANGED
package/lib/carousel/index.d.ts
CHANGED
|
@@ -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
|
-
|
|
61
|
-
|
|
62
|
-
|
|
56
|
+
sliderWidth: number;
|
|
57
|
+
contentWidth: number;
|
|
58
|
+
isDirectionLeft: boolean;
|
|
63
59
|
intersectionObserver: IntersectionObserver;
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
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
|
|
106
|
+
* @param translateX
|
|
114
107
|
* @param transition
|
|
115
108
|
*/
|
|
116
|
-
setListStyles: (element: HTMLElement,
|
|
117
|
-
getTouchSize: (event: any) => any;
|
|
109
|
+
setListStyles: (element: HTMLElement, translateX: number, transition?: string) => void;
|
|
118
110
|
/**
|
|
119
111
|
* 开启自动偏移或者渐变,当元素少于2时,将不会开启
|
|
120
112
|
*/
|
package/lib/carousel/index.js
CHANGED
|
@@ -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 =
|
|
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();
|
|
62
|
-
|
|
63
|
-
_this.
|
|
64
|
-
_this.
|
|
65
|
-
_this.
|
|
66
|
-
_this.
|
|
67
|
-
_this.
|
|
68
|
-
_this.
|
|
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
|
-
|
|
135
|
-
_this.contentSize = isHr ? parentNodeOffset.width : parentNodeOffset.height; // 没有子元素或者获取不到宽度
|
|
109
|
+
_this.contentWidth = (0, _utils.getElementSize)(element.parentNode).width; // 没有子元素或者获取不到宽度
|
|
136
110
|
|
|
137
|
-
if (!childCount || !_this.
|
|
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
|
|
150
|
-
|
|
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
|
-
|
|
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
|
-
|
|
135
|
+
child.style.width = _this.sliderWidth + "px";
|
|
157
136
|
});
|
|
158
|
-
_this.
|
|
137
|
+
_this.prevX = -currentPage * _this.sliderWidth;
|
|
159
138
|
|
|
160
|
-
_this.setListStyles(element, _this.
|
|
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.
|
|
176
|
+
_this.prevX = -nextPage * _this.sliderWidth;
|
|
198
177
|
|
|
199
178
|
_this.onBeforeChange(nextPage);
|
|
200
179
|
|
|
201
|
-
_this.setListStyles(element, _this.
|
|
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
|
|
193
|
+
* @param translateX
|
|
215
194
|
* @param transition
|
|
216
195
|
*/
|
|
217
196
|
|
|
218
197
|
|
|
219
|
-
_this.setListStyles = function (element,
|
|
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 =
|
|
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.
|
|
283
|
-
_this.
|
|
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.
|
|
306
|
-
_this.
|
|
307
|
-
_this.
|
|
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 =
|
|
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
|
|
311
|
+
var translateX = Math.abs(_this.startX - _this.endX); // 判断用户未产生滑动,认为是点击
|
|
343
312
|
|
|
344
|
-
if (_this.
|
|
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.
|
|
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
|
|
366
|
-
var moveX = Math.abs(_this.
|
|
334
|
+
var listWidth = _this.sliderWidth * childCount;
|
|
335
|
+
var moveX = Math.abs(_this.moveX);
|
|
367
336
|
|
|
368
|
-
if (moveX >=
|
|
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 =
|
|
344
|
+
var skipOne = translateX % _this.sliderWidth >= _this.props.sensitivity ? 1 : 0; // 滑动的完整页数
|
|
376
345
|
|
|
377
|
-
var skipCount = Math.floor(
|
|
346
|
+
var skipCount = Math.floor(translateX / _this.sliderWidth); // 判断是否向左滑动
|
|
378
347
|
|
|
379
|
-
if (_this.
|
|
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
|
|
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)
|
|
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
|
|
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
|
|
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
|
|
16
|
+
var renderArrow = function renderArrow(prefixCls, direction, onClick) {
|
|
35
17
|
var enabled = !!onClick;
|
|
36
|
-
return {
|
|
37
|
-
|
|
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),
|
|
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", {
|