@autobest-ui/components 2.13.11 → 3.0.0-alpha.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/affix/index.d.ts +10 -0
- package/esm/affix/index.js +50 -9
- package/esm/affix/observe.d.ts +8 -0
- package/esm/affix/observe.js +6 -0
- package/esm/confirm/style/index.css +1 -1
- package/esm/lazy-image/index.d.ts +1 -1
- package/esm/modal/index.d.ts +19 -5
- package/esm/modal/index.js +18 -17
- package/esm/modal/style/index.css +1 -1
- package/esm/move/index.d.ts +10 -0
- package/esm/move/index.js +12 -7
- package/esm/show-more/index.d.ts +15 -3
- package/esm/show-more/index.js +35 -5
- package/esm/show-more/style/index.css +1 -1
- package/esm/style.css +1 -1
- package/lib/affix/index.d.ts +10 -0
- package/lib/affix/index.js +49 -8
- package/lib/affix/observe.d.ts +8 -0
- package/lib/affix/observe.js +12 -0
- package/lib/confirm/style/index.css +1 -1
- package/lib/lazy-image/index.d.ts +1 -1
- package/lib/modal/index.d.ts +19 -5
- package/lib/modal/index.js +18 -17
- package/lib/modal/style/index.css +1 -1
- package/lib/move/index.d.ts +10 -0
- package/lib/move/index.js +12 -7
- package/lib/show-more/index.d.ts +15 -3
- package/lib/show-more/index.js +35 -5
- package/lib/show-more/style/index.css +1 -1
- package/lib/style.css +1 -1
- package/package.json +3 -3
- package/esm/modal/Affix.d.ts +0 -4
- package/esm/modal/Affix.js +0 -7
- package/lib/modal/Affix.d.ts +0 -4
- package/lib/modal/Affix.js +0 -14
package/esm/affix/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { AddListenerEventRemoveHandler, getOffsetAndSize } from '@autobest-ui/utils';
|
|
3
|
+
import { CurrentResizeObserver } from './observe';
|
|
3
4
|
export interface GetFixedStateParams {
|
|
4
5
|
positionInfo: OffsetInfo;
|
|
5
6
|
scrollTop: number;
|
|
@@ -49,6 +50,10 @@ export interface AffixProps {
|
|
|
49
50
|
* 是否忽略水平方向固定定位, true将跟着鼠标左右移动
|
|
50
51
|
*/
|
|
51
52
|
ignoreHorizontalFixed?: boolean;
|
|
53
|
+
/**
|
|
54
|
+
* 是否监听children的大小变化(仅用于非自定义renderAffix的情况)
|
|
55
|
+
*/
|
|
56
|
+
observeSize?: boolean;
|
|
52
57
|
}
|
|
53
58
|
interface AffixStates {
|
|
54
59
|
visible: boolean;
|
|
@@ -64,6 +69,7 @@ declare class Affix extends React.Component<AffixProps, AffixStates> {
|
|
|
64
69
|
isFixed: boolean;
|
|
65
70
|
wrapRef: React.RefObject<HTMLDivElement>;
|
|
66
71
|
customRef: React.RefObject<HTMLDivElement>;
|
|
72
|
+
resizeObserver: CurrentResizeObserver;
|
|
67
73
|
static defaultProps: {
|
|
68
74
|
offsetTop: number;
|
|
69
75
|
allWidth: boolean;
|
|
@@ -74,6 +80,10 @@ declare class Affix extends React.Component<AffixProps, AffixStates> {
|
|
|
74
80
|
constructor(props: AffixProps);
|
|
75
81
|
componentDidMount(): void;
|
|
76
82
|
componentWillUnmount(): void;
|
|
83
|
+
onVisibleChange: (visible: any) => void;
|
|
84
|
+
addElementObserve: () => void;
|
|
85
|
+
removeElementObserve: () => void;
|
|
86
|
+
refreshWrap: () => void;
|
|
77
87
|
onHandlerScroll: (isResize?: boolean) => void;
|
|
78
88
|
renderContent(): JSX.Element;
|
|
79
89
|
render(): JSX.Element;
|
package/esm/affix/index.js
CHANGED
|
@@ -34,8 +34,9 @@ var __assign = this && this.__assign || function () {
|
|
|
34
34
|
};
|
|
35
35
|
import React from 'react';
|
|
36
36
|
import classNames from 'classnames';
|
|
37
|
-
import { throttleWithRAF, addEventListener, getOffsetAndSize, getScrollOffset, getOffset } from '@autobest-ui/utils';
|
|
37
|
+
import { throttleWithRAF, addEventListener, getOffsetAndSize, getScrollOffset, getOffset, getElementSize } from '@autobest-ui/utils';
|
|
38
38
|
import PortalAffix from './PortalAffix';
|
|
39
|
+
import getResizeObserver from './observe';
|
|
39
40
|
var Affix = /** @class */function (_super) {
|
|
40
41
|
__extends(Affix, _super);
|
|
41
42
|
function Affix(props) {
|
|
@@ -44,16 +45,46 @@ var Affix = /** @class */function (_super) {
|
|
|
44
45
|
_this.resizeHandler = null;
|
|
45
46
|
_this.wrapRef = /*#__PURE__*/React.createRef();
|
|
46
47
|
_this.customRef = /*#__PURE__*/React.createRef();
|
|
48
|
+
_this.onVisibleChange = function (visible) {
|
|
49
|
+
var _a = _this.props,
|
|
50
|
+
onChange = _a.onChange,
|
|
51
|
+
observeSize = _a.observeSize,
|
|
52
|
+
renderAffix = _a.renderAffix;
|
|
53
|
+
onChange(visible);
|
|
54
|
+
if (visible && observeSize && !renderAffix) {
|
|
55
|
+
_this.addElementObserve();
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
_this.removeElementObserve();
|
|
59
|
+
};
|
|
60
|
+
_this.addElementObserve = function () {
|
|
61
|
+
var element = _this.wrapRef.current;
|
|
62
|
+
var CurrentResizeObserve = getResizeObserver();
|
|
63
|
+
if (_this.resizeObserver || !element || !CurrentResizeObserve) {
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
_this.resizeObserver = new CurrentResizeObserve(_this.refreshWrap);
|
|
67
|
+
_this.resizeObserver.observe(element);
|
|
68
|
+
};
|
|
69
|
+
_this.removeElementObserve = function () {
|
|
70
|
+
if (_this.resizeObserver) {
|
|
71
|
+
_this.resizeObserver.disconnect();
|
|
72
|
+
_this.resizeObserver = null;
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
_this.refreshWrap = function () {
|
|
76
|
+
_this.onHandlerScroll();
|
|
77
|
+
};
|
|
47
78
|
_this.onHandlerScroll = function (isResize) {
|
|
48
79
|
var _a = _this.props,
|
|
49
80
|
offsetTop = _a.offsetTop,
|
|
50
|
-
onChange = _a.onChange,
|
|
51
81
|
onScroll = _a.onScroll,
|
|
52
82
|
renderAffix = _a.renderAffix,
|
|
53
83
|
allWidth = _a.allWidth,
|
|
54
84
|
fadeEffect = _a.fadeEffect,
|
|
55
85
|
getFixedStatus = _a.getFixedStatus,
|
|
56
|
-
ignoreHorizontalFixed = _a.ignoreHorizontalFixed
|
|
86
|
+
ignoreHorizontalFixed = _a.ignoreHorizontalFixed,
|
|
87
|
+
observeSize = _a.observeSize;
|
|
57
88
|
var element = _this.wrapRef.current;
|
|
58
89
|
if (!element) {
|
|
59
90
|
return;
|
|
@@ -63,12 +94,22 @@ var Affix = /** @class */function (_super) {
|
|
|
63
94
|
scrollLeft = _b.left;
|
|
64
95
|
var parentElement = element.parentNode;
|
|
65
96
|
// 元素信息
|
|
66
|
-
var
|
|
67
|
-
var positionInfo = getOffsetAndSize(
|
|
97
|
+
var isOriginalFixed = _this.isFixed && !renderAffix;
|
|
98
|
+
var positionInfo = isOriginalFixed ? getOffsetAndSize(parentElement) : getOffsetAndSize(element);
|
|
68
99
|
if (ignoreHorizontalFixed) {
|
|
69
|
-
var ignoreScrollLeft = getOffset(
|
|
100
|
+
var ignoreScrollLeft = getOffset(isOriginalFixed ? parentElement : element, true).left;
|
|
70
101
|
positionInfo.left = ignoreScrollLeft;
|
|
71
102
|
}
|
|
103
|
+
var sizeChanged = false;
|
|
104
|
+
if (observeSize && isOriginalFixed) {
|
|
105
|
+
// 如果监听元素size变化,需要获取原元素的width和height信息
|
|
106
|
+
var _c = getElementSize(element),
|
|
107
|
+
elementWidth = _c.width,
|
|
108
|
+
elementHeight = _c.height;
|
|
109
|
+
sizeChanged = elementWidth !== positionInfo.width || elementHeight !== positionInfo.height;
|
|
110
|
+
positionInfo.width = elementWidth;
|
|
111
|
+
positionInfo.height = elementHeight;
|
|
112
|
+
}
|
|
72
113
|
var currentFixed = getFixedStatus({
|
|
73
114
|
positionInfo: positionInfo,
|
|
74
115
|
scrollTop: scrollTop,
|
|
@@ -88,8 +129,8 @@ var Affix = /** @class */function (_super) {
|
|
|
88
129
|
parentElement.style.width = '';
|
|
89
130
|
parentElement.style.height = '';
|
|
90
131
|
}
|
|
91
|
-
|
|
92
|
-
} else if ((!_this.isFixed || isResize) && currentFixed) {
|
|
132
|
+
_this.onVisibleChange(false);
|
|
133
|
+
} else if ((!_this.isFixed || isResize || sizeChanged) && currentFixed) {
|
|
93
134
|
_this.isFixed = true;
|
|
94
135
|
var documentWidth = document.body.offsetWidth;
|
|
95
136
|
var allWidthLeft = ignoreHorizontalFixed ? "-".concat(scrollLeft, "px") : '0px';
|
|
@@ -108,7 +149,7 @@ var Affix = /** @class */function (_super) {
|
|
|
108
149
|
parentElement.style.width = "".concat(positionInfo.width, "px");
|
|
109
150
|
parentElement.style.height = "".concat(positionInfo.height, "px");
|
|
110
151
|
}
|
|
111
|
-
|
|
152
|
+
_this.onVisibleChange(true);
|
|
112
153
|
} else if (_this.isFixed && currentFixed && ignoreHorizontalFixed) {
|
|
113
154
|
var allWidthLeft = "-".concat(scrollLeft, "px");
|
|
114
155
|
if (renderAffix || fadeEffect) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
.ab-mask{position:fixed;top:0;left:0;z-index:101;width:100%;height:100%;background-color:rgba(0,0,0,.45);transition:opacity .4s cubic-bezier(.7,.3,.1,1)}.ab-mask-fade-appear,.ab-mask-fade-enter{opacity:0}.ab-mask-fade-appear-active,.ab-mask-fade-enter-active,.ab-mask-fade-enter-done,.ab-mask-fade-exit{opacity:1}.ab-mask-fade-exit-active{opacity:0}.ab-mask-fade-exit-done{display:none}.ab-modal{position:fixed;top:0;right:0;bottom:0;left:0;
|
|
1
|
+
.ab-mask{position:fixed;top:0;left:0;z-index:101;width:100%;height:100%;background-color:rgba(0,0,0,.45);transition:opacity .4s cubic-bezier(.7,.3,.1,1)}.ab-mask-fade-appear,.ab-mask-fade-enter{opacity:0}.ab-mask-fade-appear-active,.ab-mask-fade-enter-active,.ab-mask-fade-enter-done,.ab-mask-fade-exit{opacity:1}.ab-mask-fade-exit-active{opacity:0}.ab-mask-fade-exit-done{display:none}.ab-modal{position:fixed;top:0;right:0;bottom:0;left:0;overflow:auto;outline:0}.ab-modal.ab-modal-center{text-align:center}.ab-modal.ab-modal-center::before{display:inline-block;width:0;height:100%;vertical-align:middle;content:""}.ab-modal.ab-modal-center .ab-modal-content{top:0;text-align:left;display:inline-block;vertical-align:middle}.ab-modal-content{position:relative;background-color:#fff;max-width:calc(100vw - .3rem);margin-left:auto;margin-right:auto;overflow:auto;-webkit-overflow-scrolling:touch;transition:transform .3s,opacity .3s cubic-bezier(.7,.3,.1,1);z-index:101}.ab-modal-title{position:relative;width:100%}.ab-modal-title .ab-modal-times{top:50%;transform:translateY(-50%)}.ab-modal-times{position:absolute;top:.12rem;right:.12rem;font-size:.15rem;color:#b0b0b0;cursor:pointer}.ab-modal-times svg{display:block}.ab-modal-times:hover{color:#333}.ab-modal-hidden{display:none}@media only screen and (max-width:767px){.ab-modal-content{width:calc(100vw - .3rem)}}.ab-modal-fade-appear,.ab-modal-fade-enter{transform:translate3d(0,-30px,0);opacity:0}.ab-modal-fade-appear-active,.ab-modal-fade-enter-active,.ab-modal-fade-enter-done,.ab-modal-fade-exit{transform:translateZ(0);opacity:1}.ab-modal-fade-exit-active{transform:translate3d(0,-30px,0);opacity:0}.ab-modal-fade-exit-done{display:none}.ab-confirm-btns{display:flex;justify-content:flex-end;padding-top:.42rem}.ab-confirm-cancel,.ab-confirm-ok{overflow:hidden;position:relative;font-size:.12rem;border-width:1px;border-style:solid;outline:0;cursor:pointer;font-weight:700;padding:.05rem .3rem;display:inline-block;color:#fff;margin-left:.3rem}.ab-confirm-ok{border-color:#bc0000;background:linear-gradient(180deg,#c00000 0,#c00000 0,#a00000 100%,#a00000 100%)}.ab-confirm-ok:hover{border-color:#bc0000;background:#bc0000}.ab-confirm-cancel{border-color:grey;background:linear-gradient(180deg,#909090 0,#909090 0,#707070 100%,#707070 100%)}.ab-confirm-cancel:hover{border-color:grey;background:grey}
|
package/esm/modal/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React from 'react';
|
|
1
|
+
import React, { CSSProperties } from 'react';
|
|
2
2
|
import { AddListenerEventRemoveHandler } from '@autobest-ui/utils';
|
|
3
3
|
declare type PrevPopupSize = {
|
|
4
4
|
width: number;
|
|
@@ -35,9 +35,22 @@ export interface ModalProps {
|
|
|
35
35
|
popupLimitSpacing?: number;
|
|
36
36
|
/**
|
|
37
37
|
* 当写成`auto`时, 宽度是全屏
|
|
38
|
+
* 默认值为6.5rem
|
|
38
39
|
*/
|
|
39
|
-
width?:
|
|
40
|
-
|
|
40
|
+
width?: CSSProperties['width'];
|
|
41
|
+
/**
|
|
42
|
+
* 固定弹出框高度
|
|
43
|
+
* 默认值为auto
|
|
44
|
+
*/
|
|
45
|
+
height?: CSSProperties['height'];
|
|
46
|
+
/**
|
|
47
|
+
* 弹出框最小高度
|
|
48
|
+
*/
|
|
49
|
+
minHeight?: CSSProperties['minHeight'];
|
|
50
|
+
/**
|
|
51
|
+
* 弹出框z-index层级
|
|
52
|
+
*/
|
|
53
|
+
zIndex?: CSSProperties['zIndex'];
|
|
41
54
|
/**
|
|
42
55
|
* 弹框到顶部距离(只有在placement="top"时,有作用)
|
|
43
56
|
*/
|
|
@@ -77,7 +90,6 @@ interface ModalStates {
|
|
|
77
90
|
cacheVisible: boolean;
|
|
78
91
|
}
|
|
79
92
|
declare class Modal extends React.Component<ModalProps, ModalStates> {
|
|
80
|
-
static Affix: React.ComponentType<Required<Omit<import("../portal").PortalProps, "didUpdate">>>;
|
|
81
93
|
static cacheOpenedIds: number[];
|
|
82
94
|
openId: number;
|
|
83
95
|
prefixCls: string;
|
|
@@ -86,7 +98,9 @@ declare class Modal extends React.Component<ModalProps, ModalStates> {
|
|
|
86
98
|
placement: string;
|
|
87
99
|
width: string;
|
|
88
100
|
height: string;
|
|
101
|
+
minHeight: string;
|
|
89
102
|
top: string;
|
|
103
|
+
zIndex: number;
|
|
90
104
|
popupLimitSpacing: number;
|
|
91
105
|
closable: boolean;
|
|
92
106
|
maskClosable: boolean;
|
|
@@ -113,7 +127,7 @@ declare class Modal extends React.Component<ModalProps, ModalStates> {
|
|
|
113
127
|
*/
|
|
114
128
|
onDocumentClick: (event: any) => void;
|
|
115
129
|
clearOutsideHandler(): void;
|
|
116
|
-
clearPopupTimer: (
|
|
130
|
+
clearPopupTimer: () => void;
|
|
117
131
|
getPopupDomNode(): HTMLDivElement;
|
|
118
132
|
getMaskDomNode(): HTMLDivElement;
|
|
119
133
|
onClose: (event: any, isOutsideClick?: boolean) => void;
|
package/esm/modal/index.js
CHANGED
|
@@ -27,7 +27,6 @@ import { addEventListener, hasVerticalScrollbar, isTouchScreen, getElementSize,
|
|
|
27
27
|
import Portal from '../portal';
|
|
28
28
|
import Mask from '../mask';
|
|
29
29
|
import Title from './Title';
|
|
30
|
-
import Affix from './Affix';
|
|
31
30
|
import getPopupLocation from './getPopupLocation';
|
|
32
31
|
function getId() {
|
|
33
32
|
try {
|
|
@@ -68,12 +67,8 @@ var Modal = /** @class */function (_super) {
|
|
|
68
67
|
_this.onClose(target, true);
|
|
69
68
|
}
|
|
70
69
|
};
|
|
71
|
-
_this.clearPopupTimer = function (
|
|
70
|
+
_this.clearPopupTimer = function () {
|
|
72
71
|
clearTimeout(_this.popupTimer);
|
|
73
|
-
var element = popupEl || _this.getPopupDomNode();
|
|
74
|
-
if (element) {
|
|
75
|
-
element.style.visibility = '';
|
|
76
|
-
}
|
|
77
72
|
};
|
|
78
73
|
_this.onClose = function (event, isOutsideClick) {
|
|
79
74
|
if (isOutsideClick === void 0) {
|
|
@@ -93,11 +88,11 @@ var Modal = /** @class */function (_super) {
|
|
|
93
88
|
if (!element) {
|
|
94
89
|
return;
|
|
95
90
|
}
|
|
96
|
-
if (element
|
|
91
|
+
if (element.parentNode) {
|
|
97
92
|
var parentNode = element.parentNode;
|
|
98
93
|
parentNode.style.display = 'block';
|
|
99
94
|
}
|
|
100
|
-
_this.clearPopupTimer(
|
|
95
|
+
_this.clearPopupTimer();
|
|
101
96
|
var _a = _this.props,
|
|
102
97
|
placement = _a.placement,
|
|
103
98
|
hiddenScroll = _a.hiddenScroll,
|
|
@@ -141,7 +136,7 @@ var Modal = /** @class */function (_super) {
|
|
|
141
136
|
lastChild.style.overflow = 'auto';
|
|
142
137
|
var popupHeight = height || _this.props.height;
|
|
143
138
|
if (!popupHeight || popupHeight === 'auto') {
|
|
144
|
-
lastChild.style.maxHeight = "calc(100vh - .
|
|
139
|
+
lastChild.style.maxHeight = "calc(100vh - ".concat(popupLimitSpacing * 2, "px - ").concat(placement === 'top' && top ? top : '0px', " - ").concat(firstChildHeight, "px)");
|
|
145
140
|
} else {
|
|
146
141
|
lastChild.style.maxHeight = "calc(100% - ".concat(firstChildHeight, "px)");
|
|
147
142
|
}
|
|
@@ -240,11 +235,9 @@ var Modal = /** @class */function (_super) {
|
|
|
240
235
|
width = _a.width,
|
|
241
236
|
height = _a.height;
|
|
242
237
|
if (prevPopupSize.width !== width || prevPopupSize.height !== height) {
|
|
243
|
-
this.clearPopupTimer(
|
|
244
|
-
popupEl.style.visibility = 'hidden';
|
|
238
|
+
this.clearPopupTimer();
|
|
245
239
|
this.popupTimer = setTimeout(function () {
|
|
246
240
|
_this.onEnter(popupEl);
|
|
247
|
-
popupEl.style.visibility = '';
|
|
248
241
|
});
|
|
249
242
|
}
|
|
250
243
|
}
|
|
@@ -287,14 +280,20 @@ var Modal = /** @class */function (_super) {
|
|
|
287
280
|
children = _b.children,
|
|
288
281
|
width = _b.width,
|
|
289
282
|
height = _b.height,
|
|
283
|
+
minHeight = _b.minHeight,
|
|
284
|
+
zIndex = _b.zIndex,
|
|
290
285
|
className = _b.className,
|
|
291
286
|
closable = _b.closable,
|
|
292
287
|
title = _b.title,
|
|
293
288
|
placement = _b.placement,
|
|
294
|
-
top = _b.top
|
|
295
|
-
|
|
289
|
+
top = _b.top,
|
|
290
|
+
popupLimitSpacing = _b.popupLimitSpacing;
|
|
291
|
+
var maxHeight = "calc(100vh - ".concat(popupLimitSpacing * 2, "px - ").concat(placement === 'top' && top ? top : '0px', ")");
|
|
296
292
|
return /*#__PURE__*/React.createElement("div", {
|
|
297
|
-
className: classNames(cls, className, (_a = {}, _a["".concat(cls, "-center")] = placement === 'center', _a["".concat(this.prefixCls, "-hidden")] = !visible && !this.state.isUserOperated, _a))
|
|
293
|
+
className: classNames(cls, className, (_a = {}, _a["".concat(cls, "-center")] = placement === 'center', _a["".concat(this.prefixCls, "-hidden")] = !visible && !this.state.isUserOperated, _a)),
|
|
294
|
+
style: {
|
|
295
|
+
zIndex: zIndex
|
|
296
|
+
}
|
|
298
297
|
}, /*#__PURE__*/React.createElement(CSSTransition, {
|
|
299
298
|
"in": visible,
|
|
300
299
|
timeout: 300,
|
|
@@ -309,7 +308,8 @@ var Modal = /** @class */function (_super) {
|
|
|
309
308
|
style: state !== 'exited' ? {
|
|
310
309
|
width: width,
|
|
311
310
|
height: height,
|
|
312
|
-
maxHeight: maxHeight
|
|
311
|
+
maxHeight: maxHeight,
|
|
312
|
+
minHeight: minHeight
|
|
313
313
|
} : undefined,
|
|
314
314
|
ref: _this.popupRef
|
|
315
315
|
}, /*#__PURE__*/React.createElement(Title, {
|
|
@@ -341,14 +341,15 @@ var Modal = /** @class */function (_super) {
|
|
|
341
341
|
}
|
|
342
342
|
return null;
|
|
343
343
|
};
|
|
344
|
-
Modal.Affix = Affix;
|
|
345
344
|
Modal.cacheOpenedIds = [];
|
|
346
345
|
// 默认值
|
|
347
346
|
Modal.defaultProps = {
|
|
348
347
|
placement: 'center',
|
|
349
348
|
width: '6.5rem',
|
|
350
349
|
height: 'auto',
|
|
350
|
+
minHeight: '',
|
|
351
351
|
top: '10%',
|
|
352
|
+
zIndex: 101,
|
|
352
353
|
popupLimitSpacing: 14,
|
|
353
354
|
closable: true,
|
|
354
355
|
maskClosable: true,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
.ab-mask{position:fixed;top:0;left:0;z-index:101;width:100%;height:100%;background-color:rgba(0,0,0,.45);transition:opacity .4s cubic-bezier(.7,.3,.1,1)}.ab-mask-fade-appear,.ab-mask-fade-enter{opacity:0}.ab-mask-fade-appear-active,.ab-mask-fade-enter-active,.ab-mask-fade-enter-done,.ab-mask-fade-exit{opacity:1}.ab-mask-fade-exit-active{opacity:0}.ab-mask-fade-exit-done{display:none}.ab-modal{position:fixed;top:0;right:0;bottom:0;left:0;
|
|
1
|
+
.ab-mask{position:fixed;top:0;left:0;z-index:101;width:100%;height:100%;background-color:rgba(0,0,0,.45);transition:opacity .4s cubic-bezier(.7,.3,.1,1)}.ab-mask-fade-appear,.ab-mask-fade-enter{opacity:0}.ab-mask-fade-appear-active,.ab-mask-fade-enter-active,.ab-mask-fade-enter-done,.ab-mask-fade-exit{opacity:1}.ab-mask-fade-exit-active{opacity:0}.ab-mask-fade-exit-done{display:none}.ab-modal{position:fixed;top:0;right:0;bottom:0;left:0;overflow:auto;outline:0}.ab-modal.ab-modal-center{text-align:center}.ab-modal.ab-modal-center::before{display:inline-block;width:0;height:100%;vertical-align:middle;content:""}.ab-modal.ab-modal-center .ab-modal-content{top:0;text-align:left;display:inline-block;vertical-align:middle}.ab-modal-content{position:relative;background-color:#fff;max-width:calc(100vw - .3rem);margin-left:auto;margin-right:auto;overflow:auto;-webkit-overflow-scrolling:touch;transition:transform .3s,opacity .3s cubic-bezier(.7,.3,.1,1);z-index:101}.ab-modal-title{position:relative;width:100%}.ab-modal-title .ab-modal-times{top:50%;transform:translateY(-50%)}.ab-modal-times{position:absolute;top:.12rem;right:.12rem;font-size:.15rem;color:#b0b0b0;cursor:pointer}.ab-modal-times svg{display:block}.ab-modal-times:hover{color:#333}.ab-modal-hidden{display:none}@media only screen and (max-width:767px){.ab-modal-content{width:calc(100vw - .3rem)}}.ab-modal-fade-appear,.ab-modal-fade-enter{transform:translate3d(0,-30px,0);opacity:0}.ab-modal-fade-appear-active,.ab-modal-fade-enter-active,.ab-modal-fade-enter-done,.ab-modal-fade-exit{transform:translateZ(0);opacity:1}.ab-modal-fade-exit-active{transform:translate3d(0,-30px,0);opacity:0}.ab-modal-fade-exit-done{display:none}
|
package/esm/move/index.d.ts
CHANGED
|
@@ -36,6 +36,14 @@ export interface MoveProps {
|
|
|
36
36
|
* 点击的回调函数, 如果移动,则不是click
|
|
37
37
|
*/
|
|
38
38
|
onClick?: (event: any) => void;
|
|
39
|
+
/**
|
|
40
|
+
* 禁止水平方向的移动
|
|
41
|
+
*/
|
|
42
|
+
horizontalMoveDisabled?: boolean;
|
|
43
|
+
/**
|
|
44
|
+
* 禁止垂直方向的移动
|
|
45
|
+
*/
|
|
46
|
+
verticalMoveDisabled?: boolean;
|
|
39
47
|
}
|
|
40
48
|
declare class Move extends React.Component<MoveProps> {
|
|
41
49
|
readonly prefixCls = "ab-move";
|
|
@@ -46,6 +54,8 @@ declare class Move extends React.Component<MoveProps> {
|
|
|
46
54
|
maxScalable: number;
|
|
47
55
|
horizontalPlacement: string;
|
|
48
56
|
verticalPlacement: string;
|
|
57
|
+
horizontalMoveDisabled: boolean;
|
|
58
|
+
verticalMoveDisabled: boolean;
|
|
49
59
|
};
|
|
50
60
|
prevElementSize: {
|
|
51
61
|
width: number;
|
package/esm/move/index.js
CHANGED
|
@@ -205,13 +205,16 @@ var Move = /** @class */function (_super) {
|
|
|
205
205
|
if (_this.isTouchScale && event.touches.length <= 1) {
|
|
206
206
|
return;
|
|
207
207
|
}
|
|
208
|
+
var _a = _this.props,
|
|
209
|
+
horizontalMoveDisabled = _a.horizontalMoveDisabled,
|
|
210
|
+
verticalMoveDisabled = _a.verticalMoveDisabled;
|
|
208
211
|
_this.moveObj = {
|
|
209
212
|
left: event.touches ? event.touches[0].pageX : event.clientX,
|
|
210
213
|
top: event.touches ? event.touches[0].pageY : event.clientY
|
|
211
214
|
};
|
|
212
215
|
_this.currentObj = {
|
|
213
|
-
left: _this.prevObj.left + _this.moveObj.left - _this.startObj.left,
|
|
214
|
-
top: _this.prevObj.top + _this.moveObj.top - _this.startObj.top
|
|
216
|
+
left: horizontalMoveDisabled ? _this.prevObj.left : _this.prevObj.left + _this.moveObj.left - _this.startObj.left,
|
|
217
|
+
top: verticalMoveDisabled ? _this.prevObj.top : _this.prevObj.top + _this.moveObj.top - _this.startObj.top
|
|
215
218
|
};
|
|
216
219
|
_this.setElementInfo(element);
|
|
217
220
|
};
|
|
@@ -223,6 +226,10 @@ var Move = /** @class */function (_super) {
|
|
|
223
226
|
if (event.stopPropagation) {
|
|
224
227
|
event.stopPropagation();
|
|
225
228
|
}
|
|
229
|
+
var onClick = _this.props.onClick;
|
|
230
|
+
if (onClick && _this.currentObj.left === _this.prevObj.left && _this.currentObj.top === _this.prevObj.top && _this.prevScaleSize === _this.currentScaleSize) {
|
|
231
|
+
onClick(event);
|
|
232
|
+
}
|
|
226
233
|
var _a = _this.checkRange(),
|
|
227
234
|
nextX = _a.nextX,
|
|
228
235
|
nextY = _a.nextY,
|
|
@@ -237,10 +244,6 @@ var Move = /** @class */function (_super) {
|
|
|
237
244
|
_this.currentScaleSize = nextScaleSize;
|
|
238
245
|
_this.setElementInfo(element);
|
|
239
246
|
}
|
|
240
|
-
var onClick = _this.props.onClick;
|
|
241
|
-
if (onClick && _this.currentObj.left === _this.prevObj.left && _this.currentObj.top === _this.prevObj.top && _this.prevScaleSize === _this.currentScaleSize) {
|
|
242
|
-
onClick(event);
|
|
243
|
-
}
|
|
244
247
|
};
|
|
245
248
|
_this.onTransitionEnd = function () {
|
|
246
249
|
var element = _this.getDomNode();
|
|
@@ -375,7 +378,9 @@ var Move = /** @class */function (_super) {
|
|
|
375
378
|
minScalable: 1,
|
|
376
379
|
maxScalable: 1,
|
|
377
380
|
horizontalPlacement: 'left',
|
|
378
|
-
verticalPlacement: 'top'
|
|
381
|
+
verticalPlacement: 'top',
|
|
382
|
+
horizontalMoveDisabled: false,
|
|
383
|
+
verticalMoveDisabled: false
|
|
379
384
|
};
|
|
380
385
|
return Move;
|
|
381
386
|
}(React.Component);
|
package/esm/show-more/index.d.ts
CHANGED
|
@@ -33,9 +33,17 @@ export interface ShowMoreProps {
|
|
|
33
33
|
*/
|
|
34
34
|
expandable?: boolean;
|
|
35
35
|
/**
|
|
36
|
-
*
|
|
36
|
+
* 展开后点击收起的文字,若为空则代表没有点击收起的功能
|
|
37
37
|
*/
|
|
38
|
-
|
|
38
|
+
collapseText?: string;
|
|
39
|
+
/**
|
|
40
|
+
* 收起按钮样式, 注意不能加padding样式, 可以通过空格来解决左右间距问题
|
|
41
|
+
*/
|
|
42
|
+
collapseClassName?: string;
|
|
43
|
+
/**
|
|
44
|
+
* 点击展开/收起后的回调函数
|
|
45
|
+
*/
|
|
46
|
+
onAfterChange?: (isExpand: boolean) => void;
|
|
39
47
|
/**
|
|
40
48
|
* 渲染后的回调函数
|
|
41
49
|
*/
|
|
@@ -51,9 +59,11 @@ declare class ShowMore extends Component<ShowMoreProps, ShowMoreStates> {
|
|
|
51
59
|
static defaultProps: {
|
|
52
60
|
children: string;
|
|
53
61
|
ellipsisText: string;
|
|
62
|
+
collapseText: any;
|
|
54
63
|
lines: number;
|
|
55
64
|
width: number;
|
|
56
65
|
expandable: boolean;
|
|
66
|
+
onAfterChange: () => any;
|
|
57
67
|
};
|
|
58
68
|
prefixCls: string;
|
|
59
69
|
targetElement: HTMLSpanElement | null;
|
|
@@ -63,13 +73,15 @@ declare class ShowMore extends Component<ShowMoreProps, ShowMoreStates> {
|
|
|
63
73
|
canvasContext: CanvasRenderingContext2D;
|
|
64
74
|
timer: any;
|
|
65
75
|
targetWidth: number;
|
|
76
|
+
prevPreviewText: string;
|
|
66
77
|
constructor(props: ShowMoreProps);
|
|
67
78
|
componentDidMount(): void;
|
|
68
79
|
componentDidUpdate(prevProps: ShowMoreProps): void;
|
|
69
80
|
componentWillUnmount(): void;
|
|
70
81
|
setHiddenTextStatus: () => void;
|
|
71
82
|
delayCalculate(): void;
|
|
72
|
-
|
|
83
|
+
onExpand: () => void;
|
|
84
|
+
onCollapse: () => void;
|
|
73
85
|
innerText: (node: HTMLSpanElement) => string;
|
|
74
86
|
calcTargetWidth: (callback?: () => void) => void;
|
|
75
87
|
measureWidth: (text: string) => number;
|
package/esm/show-more/index.js
CHANGED
|
@@ -46,6 +46,7 @@ var ShowMore = /** @class */function (_super) {
|
|
|
46
46
|
_this.setChildrenElement = function (el) {
|
|
47
47
|
return _this.textElement = el;
|
|
48
48
|
};
|
|
49
|
+
_this.prevPreviewText = '';
|
|
49
50
|
_this.setHiddenTextStatus = function () {
|
|
50
51
|
_this.calcTargetWidth(function () {
|
|
51
52
|
if (_this.textElement) {
|
|
@@ -55,11 +56,24 @@ var ShowMore = /** @class */function (_super) {
|
|
|
55
56
|
}
|
|
56
57
|
});
|
|
57
58
|
};
|
|
58
|
-
_this.
|
|
59
|
+
_this.onExpand = function () {
|
|
59
60
|
if (!_this.props.expandable) {
|
|
60
61
|
return;
|
|
61
62
|
}
|
|
62
|
-
_this.setRenderText(
|
|
63
|
+
_this.setRenderText(function () {
|
|
64
|
+
_this.props.onAfterChange(true);
|
|
65
|
+
}, false);
|
|
66
|
+
};
|
|
67
|
+
_this.onCollapse = function () {
|
|
68
|
+
if (isBlank(_this.props.collapseText)) {
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
_this.setState({
|
|
72
|
+
previewText: _this.prevPreviewText
|
|
73
|
+
}, function () {
|
|
74
|
+
_this.props.onAfterChange(false);
|
|
75
|
+
});
|
|
76
|
+
_this.prevPreviewText = '';
|
|
63
77
|
};
|
|
64
78
|
_this.innerText = function (node) {
|
|
65
79
|
var div = document.createElement('div');
|
|
@@ -159,7 +173,7 @@ var ShowMore = /** @class */function (_super) {
|
|
|
159
173
|
hiddenLineStr = hiddenLineStr.replace(lastLineText, '');
|
|
160
174
|
resultLine = /*#__PURE__*/React.createElement(React.Fragment, null, "".concat(lastLineText, "... "), /*#__PURE__*/React.createElement("span", {
|
|
161
175
|
className: classNames(ellipsisClassName, "".concat(cls, "-ellipsis"), (_a = {}, _a["".concat(cls, "-btn")] = expandable, _a)),
|
|
162
|
-
onClick: _this.
|
|
176
|
+
onClick: _this.onExpand
|
|
163
177
|
}, ellipsisText));
|
|
164
178
|
} else {
|
|
165
179
|
var lower = 0;
|
|
@@ -209,7 +223,9 @@ var ShowMore = /** @class */function (_super) {
|
|
|
209
223
|
var targetWidth = _this.targetWidth;
|
|
210
224
|
var _a = _this.props,
|
|
211
225
|
children = _a.children,
|
|
212
|
-
numLines = _a.lines
|
|
226
|
+
numLines = _a.lines,
|
|
227
|
+
collapseText = _a.collapseText,
|
|
228
|
+
collapseClassName = _a.collapseClassName;
|
|
213
229
|
var previewText;
|
|
214
230
|
var hiddenText;
|
|
215
231
|
var isTruncated = isBlank(isHidden) ? _this.state.isTruncated : isHidden;
|
|
@@ -222,6 +238,16 @@ var ShowMore = /** @class */function (_super) {
|
|
|
222
238
|
} else {
|
|
223
239
|
previewText = children;
|
|
224
240
|
hiddenText = '';
|
|
241
|
+
if (!isTruncated && !isBlank(collapseText)) {
|
|
242
|
+
var cls = _this.prefixCls;
|
|
243
|
+
// 记录未展开前的内容
|
|
244
|
+
_this.prevPreviewText = _this.state.previewText;
|
|
245
|
+
// 结尾加上收起按钮
|
|
246
|
+
previewText = /*#__PURE__*/React.createElement(React.Fragment, null, children, ' ', /*#__PURE__*/React.createElement("span", {
|
|
247
|
+
className: classNames(collapseClassName, "".concat(cls, "-collapse ").concat(cls, "-btn")),
|
|
248
|
+
onClick: _this.onCollapse
|
|
249
|
+
}, collapseText));
|
|
250
|
+
}
|
|
225
251
|
}
|
|
226
252
|
_this.setState({
|
|
227
253
|
previewText: previewText,
|
|
@@ -297,9 +323,13 @@ var ShowMore = /** @class */function (_super) {
|
|
|
297
323
|
ShowMore.defaultProps = {
|
|
298
324
|
children: '',
|
|
299
325
|
ellipsisText: 'Show More',
|
|
326
|
+
collapseText: null,
|
|
300
327
|
lines: 2,
|
|
301
328
|
width: 0,
|
|
302
|
-
expandable: true
|
|
329
|
+
expandable: true,
|
|
330
|
+
onAfterChange: function onAfterChange() {
|
|
331
|
+
return null;
|
|
332
|
+
}
|
|
303
333
|
};
|
|
304
334
|
return ShowMore;
|
|
305
335
|
}(Component);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
.ab-show-more-ellipsis{white-space:nowrap}.ab-show-more-btn{color:#4068b0;cursor:pointer}.ab-show-more-hidden,.ab-show-more-text{visibility:hidden;height:0;display:block;overflow:hidden}.ab-show-more-hidden{width:0}
|
|
1
|
+
.ab-show-more-collapse,.ab-show-more-ellipsis{white-space:nowrap}.ab-show-more-btn{color:#4068b0;cursor:pointer}.ab-show-more-hidden,.ab-show-more-text{visibility:hidden;height:0;display:block;overflow:hidden}.ab-show-more-hidden{width:0}
|