@douyinfe/semi-ui 2.19.2-alpha.0 → 2.20.0-beta.1
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/dist/css/semi.css +243 -968
- package/dist/css/semi.min.css +1 -1
- package/dist/umd/semi-ui.js +3449 -452
- package/dist/umd/semi-ui.js.map +1 -1
- package/dist/umd/semi-ui.min.js +1 -1
- package/dist/umd/semi-ui.min.js.map +1 -1
- package/lib/cjs/button/Button.d.ts +1 -1
- package/lib/cjs/button/index.d.ts +1 -1
- package/lib/cjs/carousel/CarouselIndicator.d.ts +1 -1
- package/lib/cjs/carousel/index.d.ts +1 -1
- package/lib/cjs/datePicker/dateInput.d.ts +1 -1
- package/lib/cjs/datePicker/datePicker.d.ts +1 -1
- package/lib/cjs/datePicker/monthsGrid.d.ts +1 -1
- package/lib/cjs/image/image.d.ts +48 -0
- package/lib/cjs/image/image.js +248 -0
- package/lib/cjs/image/index.d.ts +6 -0
- package/lib/cjs/image/index.js +29 -0
- package/lib/cjs/image/interface.d.ts +178 -0
- package/lib/cjs/image/interface.js +5 -0
- package/lib/cjs/image/preview.d.ts +81 -0
- package/lib/cjs/image/preview.js +249 -0
- package/lib/cjs/image/previewContext.d.ts +12 -0
- package/lib/cjs/image/previewContext.js +11 -0
- package/lib/cjs/image/previewFooter.d.ts +62 -0
- package/lib/cjs/image/previewFooter.js +337 -0
- package/lib/cjs/image/previewHeader.d.ts +4 -0
- package/lib/cjs/image/previewHeader.js +57 -0
- package/lib/cjs/image/previewImage.d.ts +49 -0
- package/lib/cjs/image/previewImage.js +253 -0
- package/lib/cjs/image/previewInner.d.ts +87 -0
- package/lib/cjs/image/previewInner.js +443 -0
- package/lib/cjs/index.d.ts +2 -0
- package/lib/cjs/index.js +14 -0
- package/lib/cjs/locale/interface.d.ts +13 -0
- package/lib/cjs/locale/source/ar.js +13 -0
- package/lib/cjs/locale/source/de.js +13 -0
- package/lib/cjs/locale/source/en_GB.js +13 -0
- package/lib/cjs/locale/source/en_US.js +13 -0
- package/lib/cjs/locale/source/es.js +13 -0
- package/lib/cjs/locale/source/fr.js +13 -0
- package/lib/cjs/locale/source/id_ID.js +13 -0
- package/lib/cjs/locale/source/it.js +13 -0
- package/lib/cjs/locale/source/ja_JP.js +13 -0
- package/lib/cjs/locale/source/ko_KR.js +13 -0
- package/lib/cjs/locale/source/ms_MY.js +13 -0
- package/lib/cjs/locale/source/pt_BR.js +13 -0
- package/lib/cjs/locale/source/ru_RU.js +13 -0
- package/lib/cjs/locale/source/th_TH.js +13 -0
- package/lib/cjs/locale/source/tr_TR.js +13 -0
- package/lib/cjs/locale/source/vi_VN.js +13 -0
- package/lib/cjs/locale/source/zh_CN.js +13 -0
- package/lib/cjs/locale/source/zh_TW.js +13 -0
- package/lib/cjs/progress/index.d.ts +10 -2
- package/lib/cjs/progress/index.js +37 -8
- package/lib/cjs/radio/radio.d.ts +1 -1
- package/lib/cjs/radio/radioGroup.d.ts +1 -1
- package/lib/cjs/skeleton/item.d.ts +1 -0
- package/lib/cjs/skeleton/item.js +10 -4
- package/lib/cjs/tag/index.js +5 -1
- package/lib/cjs/tag/interface.d.ts +2 -0
- package/lib/cjs/timePicker/TimePicker.d.ts +2 -2
- package/lib/cjs/timePicker/TimeShape.d.ts +1 -1
- package/lib/cjs/timePicker/index.d.ts +2 -2
- package/lib/cjs/toast/index.d.ts +9 -0
- package/lib/cjs/toast/index.js +50 -10
- package/lib/cjs/toast/toast.d.ts +1 -0
- package/lib/cjs/toast/toast.js +4 -0
- package/lib/cjs/typography/base.d.ts +1 -1
- package/lib/cjs/typography/paragraph.d.ts +1 -1
- package/lib/cjs/typography/text.d.ts +1 -1
- package/lib/cjs/typography/title.d.ts +2 -2
- package/lib/cjs/upload/index.d.ts +1 -1
- package/lib/es/button/Button.d.ts +1 -1
- package/lib/es/button/index.d.ts +1 -1
- package/lib/es/carousel/CarouselIndicator.d.ts +1 -1
- package/lib/es/carousel/index.d.ts +1 -1
- package/lib/es/datePicker/dateInput.d.ts +1 -1
- package/lib/es/datePicker/datePicker.d.ts +1 -1
- package/lib/es/datePicker/monthsGrid.d.ts +1 -1
- package/lib/es/image/image.d.ts +48 -0
- package/lib/es/image/image.js +224 -0
- package/lib/es/image/index.d.ts +6 -0
- package/lib/es/image/index.js +5 -0
- package/lib/es/image/interface.d.ts +178 -0
- package/lib/es/image/interface.js +1 -0
- package/lib/es/image/preview.d.ts +81 -0
- package/lib/es/image/preview.js +229 -0
- package/lib/es/image/previewContext.d.ts +12 -0
- package/lib/es/image/previewContext.js +2 -0
- package/lib/es/image/previewFooter.d.ts +62 -0
- package/lib/es/image/previewFooter.js +301 -0
- package/lib/es/image/previewHeader.d.ts +4 -0
- package/lib/es/image/previewHeader.js +38 -0
- package/lib/es/image/previewImage.d.ts +49 -0
- package/lib/es/image/previewImage.js +235 -0
- package/lib/es/image/previewInner.d.ts +87 -0
- package/lib/es/image/previewInner.js +419 -0
- package/lib/es/index.d.ts +2 -0
- package/lib/es/index.js +3 -1
- package/lib/es/locale/interface.d.ts +13 -0
- package/lib/es/locale/source/ar.js +13 -0
- package/lib/es/locale/source/de.js +13 -0
- package/lib/es/locale/source/en_GB.js +13 -0
- package/lib/es/locale/source/en_US.js +13 -0
- package/lib/es/locale/source/es.js +13 -0
- package/lib/es/locale/source/fr.js +13 -0
- package/lib/es/locale/source/id_ID.js +13 -0
- package/lib/es/locale/source/it.js +13 -0
- package/lib/es/locale/source/ja_JP.js +13 -0
- package/lib/es/locale/source/ko_KR.js +13 -0
- package/lib/es/locale/source/ms_MY.js +13 -0
- package/lib/es/locale/source/pt_BR.js +13 -0
- package/lib/es/locale/source/ru_RU.js +13 -0
- package/lib/es/locale/source/th_TH.js +13 -0
- package/lib/es/locale/source/tr_TR.js +13 -0
- package/lib/es/locale/source/vi_VN.js +13 -0
- package/lib/es/locale/source/zh_CN.js +13 -0
- package/lib/es/locale/source/zh_TW.js +13 -0
- package/lib/es/progress/index.d.ts +10 -2
- package/lib/es/progress/index.js +36 -8
- package/lib/es/radio/radio.d.ts +1 -1
- package/lib/es/radio/radioGroup.d.ts +1 -1
- package/lib/es/skeleton/item.d.ts +1 -0
- package/lib/es/skeleton/item.js +10 -4
- package/lib/es/tag/index.js +5 -1
- package/lib/es/tag/interface.d.ts +2 -0
- package/lib/es/timePicker/TimePicker.d.ts +2 -2
- package/lib/es/timePicker/TimeShape.d.ts +1 -1
- package/lib/es/timePicker/index.d.ts +2 -2
- package/lib/es/toast/index.d.ts +9 -0
- package/lib/es/toast/index.js +50 -10
- package/lib/es/toast/toast.d.ts +1 -0
- package/lib/es/toast/toast.js +4 -0
- package/lib/es/typography/base.d.ts +1 -1
- package/lib/es/typography/paragraph.d.ts +1 -1
- package/lib/es/typography/text.d.ts +1 -1
- package/lib/es/typography/title.d.ts +2 -2
- package/lib/es/upload/index.d.ts +1 -1
- package/package.json +8 -8
|
@@ -0,0 +1,249 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
|
|
8
|
+
var _isObject2 = _interopRequireDefault(require("lodash/isObject"));
|
|
9
|
+
|
|
10
|
+
var _react = _interopRequireDefault(require("react"));
|
|
11
|
+
|
|
12
|
+
var _previewContext = require("./previewContext");
|
|
13
|
+
|
|
14
|
+
var _baseComponent = _interopRequireDefault(require("../_base/baseComponent"));
|
|
15
|
+
|
|
16
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
17
|
+
|
|
18
|
+
var _previewInner = _interopRequireDefault(require("./previewInner"));
|
|
19
|
+
|
|
20
|
+
var _previewFoundation = _interopRequireDefault(require("@douyinfe/semi-foundation/lib/cjs/image/previewFoundation"));
|
|
21
|
+
|
|
22
|
+
var _uuid = require("@douyinfe/semi-foundation/lib/cjs/utils/uuid");
|
|
23
|
+
|
|
24
|
+
var _constants = require("@douyinfe/semi-foundation/lib/cjs/image/constants");
|
|
25
|
+
|
|
26
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
27
|
+
|
|
28
|
+
var __rest = void 0 && (void 0).__rest || function (s, e) {
|
|
29
|
+
var t = {};
|
|
30
|
+
|
|
31
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
|
|
32
|
+
|
|
33
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
34
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
|
|
35
|
+
}
|
|
36
|
+
return t;
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
const prefixCls = _constants.cssClasses.PREFIX;
|
|
40
|
+
|
|
41
|
+
class Preview extends _baseComponent.default {
|
|
42
|
+
constructor(props) {
|
|
43
|
+
super(props);
|
|
44
|
+
|
|
45
|
+
this.handleVisibleChange = newVisible => {
|
|
46
|
+
this.foundation.handleVisibleChange(newVisible);
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
this.handleCurrentIndexChange = index => {
|
|
50
|
+
this.foundation.handleCurrentIndexChange(index);
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
this.loopImageIndex = () => {
|
|
54
|
+
const {
|
|
55
|
+
children
|
|
56
|
+
} = this.props;
|
|
57
|
+
let index = 0;
|
|
58
|
+
const srcListInChildren = [];
|
|
59
|
+
const titles = [];
|
|
60
|
+
|
|
61
|
+
const loop = children => {
|
|
62
|
+
return _react.default.Children.map(children, child => {
|
|
63
|
+
var _a;
|
|
64
|
+
|
|
65
|
+
if (child && child.props && child.type) {
|
|
66
|
+
if (child.type.isSemiImage) {
|
|
67
|
+
const {
|
|
68
|
+
src,
|
|
69
|
+
preview,
|
|
70
|
+
alt
|
|
71
|
+
} = child.props;
|
|
72
|
+
|
|
73
|
+
if (preview) {
|
|
74
|
+
const previewSrc = (0, _isObject2.default)(preview) ? (_a = preview.src) !== null && _a !== void 0 ? _a : src : src;
|
|
75
|
+
srcListInChildren.push(previewSrc);
|
|
76
|
+
titles.push(preview === null || preview === void 0 ? void 0 : preview.previewTitle);
|
|
77
|
+
return /*#__PURE__*/_react.default.cloneElement(child, {
|
|
78
|
+
imageID: index++
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
return child;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
if (child && child.props && child.props.children) {
|
|
87
|
+
return /*#__PURE__*/_react.default.cloneElement(child, {
|
|
88
|
+
children: loop(child.props.children)
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
return child;
|
|
93
|
+
});
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
return {
|
|
97
|
+
srcListInChildren,
|
|
98
|
+
newChildren: loop(children),
|
|
99
|
+
titles
|
|
100
|
+
};
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
this.state = {
|
|
104
|
+
currentIndex: props.currentIndex || props.defaultCurrentIndex || 0,
|
|
105
|
+
visible: props.visible || props.currentDefaultVisible || false
|
|
106
|
+
};
|
|
107
|
+
this.foundation = new _previewFoundation.default(this.adapter);
|
|
108
|
+
this.previewGroupId = (0, _uuid.getUuidShort)({
|
|
109
|
+
prefix: "semi-image-preview-group",
|
|
110
|
+
length: 4
|
|
111
|
+
});
|
|
112
|
+
this.previewRef = /*#__PURE__*/_react.default.createRef();
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
get adapter() {
|
|
116
|
+
return Object.assign({}, super.adapter);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
componentDidMount() {
|
|
120
|
+
const {
|
|
121
|
+
lazyLoadMargin
|
|
122
|
+
} = this.props;
|
|
123
|
+
const allElement = document.querySelectorAll(".".concat(prefixCls, "-img")); // use IntersectionObserver to lazy load image
|
|
124
|
+
|
|
125
|
+
const observer = new IntersectionObserver(entries => {
|
|
126
|
+
entries.forEach(item => {
|
|
127
|
+
var _a;
|
|
128
|
+
|
|
129
|
+
const src = (_a = item.target.dataset) === null || _a === void 0 ? void 0 : _a.src;
|
|
130
|
+
|
|
131
|
+
if (item.isIntersecting && src) {
|
|
132
|
+
item.target.src = src;
|
|
133
|
+
observer.unobserve(item.target);
|
|
134
|
+
}
|
|
135
|
+
});
|
|
136
|
+
}, {
|
|
137
|
+
root: document.querySelector("#".concat(this.previewGroupId)),
|
|
138
|
+
rootMargin: lazyLoadMargin
|
|
139
|
+
});
|
|
140
|
+
allElement.forEach(item => observer.observe(item));
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
static getDerivedStateFromProps(props, state) {
|
|
144
|
+
const willUpdateStates = {};
|
|
145
|
+
|
|
146
|
+
if ("currentIndex" in props && props.currentIndex !== state.currentIndex) {
|
|
147
|
+
willUpdateStates.currentIndex = props.currentIndex;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
if ("visible" in props && props.visible !== state.visible) {
|
|
151
|
+
willUpdateStates.visible = props.visible;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
return willUpdateStates;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
render() {
|
|
158
|
+
const _a = this.props,
|
|
159
|
+
{
|
|
160
|
+
src,
|
|
161
|
+
style,
|
|
162
|
+
lazyLoad
|
|
163
|
+
} = _a,
|
|
164
|
+
restProps = __rest(_a, ["src", "style", "lazyLoad"]);
|
|
165
|
+
|
|
166
|
+
const {
|
|
167
|
+
currentIndex,
|
|
168
|
+
visible
|
|
169
|
+
} = this.state;
|
|
170
|
+
const {
|
|
171
|
+
srcListInChildren,
|
|
172
|
+
newChildren,
|
|
173
|
+
titles
|
|
174
|
+
} = this.loopImageIndex();
|
|
175
|
+
const srcArr = Array.isArray(src) ? src : typeof src === "string" ? [src] : [];
|
|
176
|
+
const finalSrcList = [...srcArr, ...srcListInChildren];
|
|
177
|
+
return /*#__PURE__*/_react.default.createElement(_previewContext.PreviewContext.Provider, {
|
|
178
|
+
value: {
|
|
179
|
+
isGroup: finalSrcList.length > 1,
|
|
180
|
+
previewSrc: finalSrcList,
|
|
181
|
+
titles: titles,
|
|
182
|
+
currentIndex,
|
|
183
|
+
visible,
|
|
184
|
+
lazyLoad,
|
|
185
|
+
setCurrentIndex: this.handleCurrentIndexChange,
|
|
186
|
+
handleVisibleChange: this.handleVisibleChange
|
|
187
|
+
}
|
|
188
|
+
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
189
|
+
id: this.previewGroupId,
|
|
190
|
+
style: style,
|
|
191
|
+
className: "".concat(prefixCls, "-preview-group")
|
|
192
|
+
}, newChildren), /*#__PURE__*/_react.default.createElement(_previewInner.default, Object.assign({}, restProps, {
|
|
193
|
+
ref: this.previewRef,
|
|
194
|
+
src: finalSrcList,
|
|
195
|
+
currentIndex: currentIndex,
|
|
196
|
+
visible: visible,
|
|
197
|
+
onVisibleChange: this.handleVisibleChange
|
|
198
|
+
})));
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
exports.default = Preview;
|
|
204
|
+
Preview.propTypes = {
|
|
205
|
+
style: _propTypes.default.object,
|
|
206
|
+
className: _propTypes.default.string,
|
|
207
|
+
visible: _propTypes.default.bool,
|
|
208
|
+
src: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.array]),
|
|
209
|
+
currentIndex: _propTypes.default.number,
|
|
210
|
+
defaultIndex: _propTypes.default.number,
|
|
211
|
+
defaultVisible: _propTypes.default.bool,
|
|
212
|
+
maskClosable: _propTypes.default.bool,
|
|
213
|
+
closable: _propTypes.default.bool,
|
|
214
|
+
zoomStep: _propTypes.default.number,
|
|
215
|
+
infinite: _propTypes.default.bool,
|
|
216
|
+
showTooltip: _propTypes.default.bool,
|
|
217
|
+
closeOnEsc: _propTypes.default.bool,
|
|
218
|
+
prevTip: _propTypes.default.string,
|
|
219
|
+
nextTip: _propTypes.default.string,
|
|
220
|
+
zoomInTip: _propTypes.default.string,
|
|
221
|
+
zoomOutTip: _propTypes.default.string,
|
|
222
|
+
downloadTip: _propTypes.default.string,
|
|
223
|
+
adaptiveTip: _propTypes.default.string,
|
|
224
|
+
originTip: _propTypes.default.string,
|
|
225
|
+
lazyLoad: _propTypes.default.bool,
|
|
226
|
+
lazyLoadMargin: _propTypes.default.string,
|
|
227
|
+
preLoad: _propTypes.default.bool,
|
|
228
|
+
preLoadGap: _propTypes.default.number,
|
|
229
|
+
disableDownload: _propTypes.default.bool,
|
|
230
|
+
zIndex: _propTypes.default.number,
|
|
231
|
+
renderHeader: _propTypes.default.func,
|
|
232
|
+
renderPreviewMenu: _propTypes.default.func,
|
|
233
|
+
getPopupContainer: _propTypes.default.func,
|
|
234
|
+
onVisibleChange: _propTypes.default.func,
|
|
235
|
+
onChange: _propTypes.default.func,
|
|
236
|
+
onClose: _propTypes.default.func,
|
|
237
|
+
onZoomIn: _propTypes.default.func,
|
|
238
|
+
onZoomOut: _propTypes.default.func,
|
|
239
|
+
onPrev: _propTypes.default.func,
|
|
240
|
+
onNext: _propTypes.default.func,
|
|
241
|
+
onDownload: _propTypes.default.func,
|
|
242
|
+
onRatioChange: _propTypes.default.func,
|
|
243
|
+
onRotateChange: _propTypes.default.func
|
|
244
|
+
};
|
|
245
|
+
Preview.defaultProps = {
|
|
246
|
+
src: [],
|
|
247
|
+
lazyLoad: true,
|
|
248
|
+
lazyLoadMargin: "0px 100px 100px 0px"
|
|
249
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { ReactNode } from "react";
|
|
2
|
+
export interface PreviewContextProps {
|
|
3
|
+
isGroup: boolean;
|
|
4
|
+
lazyLoad: boolean;
|
|
5
|
+
previewSrc: string[];
|
|
6
|
+
titles: ReactNode[];
|
|
7
|
+
currentIndex: number;
|
|
8
|
+
visible: boolean;
|
|
9
|
+
setCurrentIndex: (current: number) => void;
|
|
10
|
+
handleVisibleChange: (visible: boolean, preVisible?: boolean) => void;
|
|
11
|
+
}
|
|
12
|
+
export declare const PreviewContext: import("react").Context<PreviewContextProps>;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.PreviewContext = void 0;
|
|
7
|
+
|
|
8
|
+
var _react = require("react");
|
|
9
|
+
|
|
10
|
+
const PreviewContext = /*#__PURE__*/(0, _react.createContext)({});
|
|
11
|
+
exports.PreviewContext = PreviewContext;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/// <reference types="lodash" />
|
|
2
|
+
import React, { ReactNode } from "react";
|
|
3
|
+
import BaseComponent from "../_base/baseComponent";
|
|
4
|
+
import { FooterProps } from "./interface";
|
|
5
|
+
import PropTypes from "prop-types";
|
|
6
|
+
import PreviewFooterFoundation, { PreviewFooterAdapter } from '@douyinfe/semi-foundation/lib/cjs/image/previewFooterFoundation';
|
|
7
|
+
export default class Footer extends BaseComponent<FooterProps> {
|
|
8
|
+
static propTypes: {
|
|
9
|
+
curPage: PropTypes.Requireable<number>;
|
|
10
|
+
totalNum: PropTypes.Requireable<number>;
|
|
11
|
+
disabledPrev: PropTypes.Requireable<boolean>;
|
|
12
|
+
disabledNext: PropTypes.Requireable<boolean>;
|
|
13
|
+
disableDownload: PropTypes.Requireable<boolean>;
|
|
14
|
+
className: PropTypes.Requireable<string>;
|
|
15
|
+
zoom: PropTypes.Requireable<number>;
|
|
16
|
+
ratio: PropTypes.Requireable<string>;
|
|
17
|
+
prevTip: PropTypes.Requireable<string>;
|
|
18
|
+
nextTip: PropTypes.Requireable<string>;
|
|
19
|
+
zoomInTip: PropTypes.Requireable<string>;
|
|
20
|
+
zoomOutTip: PropTypes.Requireable<string>;
|
|
21
|
+
rotateTip: PropTypes.Requireable<string>;
|
|
22
|
+
downloadTip: PropTypes.Requireable<string>;
|
|
23
|
+
adaptiveTip: PropTypes.Requireable<string>;
|
|
24
|
+
originTip: PropTypes.Requireable<string>;
|
|
25
|
+
showTooltip: PropTypes.Requireable<boolean>;
|
|
26
|
+
onZoomIn: PropTypes.Requireable<(...args: any[]) => any>;
|
|
27
|
+
onZoomOut: PropTypes.Requireable<(...args: any[]) => any>;
|
|
28
|
+
onPrev: PropTypes.Requireable<(...args: any[]) => any>;
|
|
29
|
+
onNext: PropTypes.Requireable<(...args: any[]) => any>;
|
|
30
|
+
onAdjustRatio: PropTypes.Requireable<(...args: any[]) => any>;
|
|
31
|
+
onRotateLeft: PropTypes.Requireable<(...args: any[]) => any>;
|
|
32
|
+
onDownload: PropTypes.Requireable<(...args: any[]) => any>;
|
|
33
|
+
};
|
|
34
|
+
static defaultProps: {
|
|
35
|
+
min: number;
|
|
36
|
+
max: number;
|
|
37
|
+
step: number;
|
|
38
|
+
showTooltip: boolean;
|
|
39
|
+
disableDownload: boolean;
|
|
40
|
+
};
|
|
41
|
+
get adapter(): PreviewFooterAdapter<FooterProps>;
|
|
42
|
+
foundation: PreviewFooterFoundation;
|
|
43
|
+
constructor(props: FooterProps);
|
|
44
|
+
changeSliderValue: (type: string) => void;
|
|
45
|
+
handleMinusClick: () => void;
|
|
46
|
+
handlePlusClick: () => void;
|
|
47
|
+
handleRotateLeft: () => void;
|
|
48
|
+
handleRotateRight: () => void;
|
|
49
|
+
handleSlideChange: import("lodash").DebouncedFunc<(value: any) => void>;
|
|
50
|
+
handleRatioClick: () => void;
|
|
51
|
+
customRenderViewMenu: () => ReactNode;
|
|
52
|
+
getFinalIconElement: (element: ReactNode, content: ReactNode) => string | number | boolean | React.ReactFragment | JSX.Element;
|
|
53
|
+
getLocalTextByKey: (key: string) => JSX.Element;
|
|
54
|
+
getIconChevronLeft: () => string | number | boolean | React.ReactFragment | JSX.Element;
|
|
55
|
+
getIconChevronRight: () => string | number | boolean | React.ReactFragment | JSX.Element;
|
|
56
|
+
getIconMinus: () => string | number | boolean | React.ReactFragment | JSX.Element;
|
|
57
|
+
getIconPlus: () => string | number | boolean | React.ReactFragment | JSX.Element;
|
|
58
|
+
getIconRatio: () => string | number | boolean | React.ReactFragment | JSX.Element;
|
|
59
|
+
getIconRotate: () => string | number | boolean | React.ReactFragment | JSX.Element;
|
|
60
|
+
getIconDownload: () => string | number | boolean | React.ReactFragment | JSX.Element;
|
|
61
|
+
render(): JSX.Element;
|
|
62
|
+
}
|
|
@@ -0,0 +1,337 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
|
|
8
|
+
var _throttle2 = _interopRequireDefault(require("lodash/throttle"));
|
|
9
|
+
|
|
10
|
+
var _react = _interopRequireDefault(require("react"));
|
|
11
|
+
|
|
12
|
+
var _baseComponent = _interopRequireDefault(require("../_base/baseComponent"));
|
|
13
|
+
|
|
14
|
+
var _semiIcons = require("@douyinfe/semi-icons");
|
|
15
|
+
|
|
16
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
17
|
+
|
|
18
|
+
var _tooltip = _interopRequireDefault(require("../tooltip"));
|
|
19
|
+
|
|
20
|
+
var _divider = _interopRequireDefault(require("../divider"));
|
|
21
|
+
|
|
22
|
+
var _slider = _interopRequireDefault(require("../slider"));
|
|
23
|
+
|
|
24
|
+
var _constants = require("@douyinfe/semi-foundation/lib/cjs/image/constants");
|
|
25
|
+
|
|
26
|
+
var _classnames = _interopRequireDefault(require("classnames"));
|
|
27
|
+
|
|
28
|
+
var _previewFooterFoundation = _interopRequireDefault(require("@douyinfe/semi-foundation/lib/cjs/image/previewFooterFoundation"));
|
|
29
|
+
|
|
30
|
+
var _localeConsumer = _interopRequireDefault(require("../locale/localeConsumer"));
|
|
31
|
+
|
|
32
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
33
|
+
|
|
34
|
+
const prefixCls = _constants.cssClasses.PREFIX;
|
|
35
|
+
const footerPrefixCls = "".concat(_constants.cssClasses.PREFIX, "-preview-footer");
|
|
36
|
+
let mouseActiveTime = 0;
|
|
37
|
+
|
|
38
|
+
class Footer extends _baseComponent.default {
|
|
39
|
+
constructor(props) {
|
|
40
|
+
super(props);
|
|
41
|
+
|
|
42
|
+
this.changeSliderValue = type => {
|
|
43
|
+
this.foundation.changeSliderValue(type);
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
this.handleMinusClick = () => {
|
|
47
|
+
this.changeSliderValue("minus");
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
this.handlePlusClick = () => {
|
|
51
|
+
this.changeSliderValue("plus");
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
this.handleRotateLeft = () => {
|
|
55
|
+
this.foundation.handleRotate("left");
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
this.handleRotateRight = () => {
|
|
59
|
+
this.foundation.handleRotate("right");
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
this.handleSlideChange = (0, _throttle2.default)(value => {
|
|
63
|
+
this.foundation.handleValueChange(value);
|
|
64
|
+
}, 50);
|
|
65
|
+
|
|
66
|
+
this.handleRatioClick = () => {
|
|
67
|
+
this.foundation.handleRatioClick();
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
this.customRenderViewMenu = () => {
|
|
71
|
+
const {
|
|
72
|
+
min,
|
|
73
|
+
max,
|
|
74
|
+
step,
|
|
75
|
+
curPage,
|
|
76
|
+
totalNum,
|
|
77
|
+
ratio,
|
|
78
|
+
zoom,
|
|
79
|
+
disabledPrev,
|
|
80
|
+
disabledNext,
|
|
81
|
+
disableDownload,
|
|
82
|
+
onNext,
|
|
83
|
+
onPrev,
|
|
84
|
+
onDownload,
|
|
85
|
+
renderPreviewMenu
|
|
86
|
+
} = this.props;
|
|
87
|
+
const props = {
|
|
88
|
+
min,
|
|
89
|
+
max,
|
|
90
|
+
step,
|
|
91
|
+
curPage,
|
|
92
|
+
totalNum,
|
|
93
|
+
ratio,
|
|
94
|
+
zoom,
|
|
95
|
+
disabledPrev,
|
|
96
|
+
disabledNext,
|
|
97
|
+
disableDownload,
|
|
98
|
+
onNext,
|
|
99
|
+
onPrev,
|
|
100
|
+
onDownload,
|
|
101
|
+
onRotateLeft: this.handleRotateLeft,
|
|
102
|
+
onRotateRight: this.handleRotateRight,
|
|
103
|
+
disabledZoomIn: zoom === max,
|
|
104
|
+
disabledZoomOut: zoom === min,
|
|
105
|
+
onRatioClick: this.handleRatioClick,
|
|
106
|
+
onZoomIn: this.handlePlusClick,
|
|
107
|
+
onZoomOut: this.handleMinusClick
|
|
108
|
+
};
|
|
109
|
+
return renderPreviewMenu(props);
|
|
110
|
+
}; // According to showTooltip in props, decide whether to use Tooltip to pack a layer
|
|
111
|
+
// 根据 props 中的 showTooltip 决定是否使用 Tooltip 包一层
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
this.getFinalIconElement = (element, content) => {
|
|
115
|
+
const {
|
|
116
|
+
showTooltip
|
|
117
|
+
} = this.props;
|
|
118
|
+
return showTooltip ? /*#__PURE__*/_react.default.createElement(_tooltip.default, {
|
|
119
|
+
content: content
|
|
120
|
+
}, element) : element;
|
|
121
|
+
};
|
|
122
|
+
|
|
123
|
+
this.getLocalTextByKey = key => /*#__PURE__*/_react.default.createElement(_localeConsumer.default, {
|
|
124
|
+
componentName: "Image"
|
|
125
|
+
}, locale => locale[key]);
|
|
126
|
+
|
|
127
|
+
this.getIconChevronLeft = () => {
|
|
128
|
+
const {
|
|
129
|
+
disabledPrev,
|
|
130
|
+
onPrev,
|
|
131
|
+
prevTip
|
|
132
|
+
} = this.props;
|
|
133
|
+
|
|
134
|
+
const icon = /*#__PURE__*/_react.default.createElement(_semiIcons.IconChevronLeft, {
|
|
135
|
+
size: "large",
|
|
136
|
+
className: disabledPrev ? "".concat(footerPrefixCls, "-disabled") : "",
|
|
137
|
+
onClick: !disabledPrev ? onPrev : undefined
|
|
138
|
+
});
|
|
139
|
+
|
|
140
|
+
const content = prevTip !== null && prevTip !== void 0 ? prevTip : this.getLocalTextByKey("prevTip");
|
|
141
|
+
return this.getFinalIconElement(icon, content);
|
|
142
|
+
};
|
|
143
|
+
|
|
144
|
+
this.getIconChevronRight = () => {
|
|
145
|
+
const {
|
|
146
|
+
disabledNext,
|
|
147
|
+
onNext,
|
|
148
|
+
nextTip
|
|
149
|
+
} = this.props;
|
|
150
|
+
|
|
151
|
+
const icon = /*#__PURE__*/_react.default.createElement(_semiIcons.IconChevronRight, {
|
|
152
|
+
size: "large",
|
|
153
|
+
className: disabledNext ? "".concat(footerPrefixCls, "-disabled") : "",
|
|
154
|
+
onClick: !disabledNext ? onNext : undefined
|
|
155
|
+
});
|
|
156
|
+
|
|
157
|
+
const content = nextTip !== null && nextTip !== void 0 ? nextTip : this.getLocalTextByKey("nextTip");
|
|
158
|
+
return this.getFinalIconElement(icon, content);
|
|
159
|
+
};
|
|
160
|
+
|
|
161
|
+
this.getIconMinus = () => {
|
|
162
|
+
const {
|
|
163
|
+
zoomOutTip,
|
|
164
|
+
zoom,
|
|
165
|
+
min
|
|
166
|
+
} = this.props;
|
|
167
|
+
const disabledZoomOut = zoom === min;
|
|
168
|
+
|
|
169
|
+
const icon = /*#__PURE__*/_react.default.createElement(_semiIcons.IconMinus, {
|
|
170
|
+
size: "large",
|
|
171
|
+
onClick: !disabledZoomOut ? this.handleMinusClick : undefined,
|
|
172
|
+
className: disabledZoomOut ? "".concat(footerPrefixCls, "-disabled") : ""
|
|
173
|
+
});
|
|
174
|
+
|
|
175
|
+
const content = zoomOutTip !== null && zoomOutTip !== void 0 ? zoomOutTip : this.getLocalTextByKey("zoomOutTip");
|
|
176
|
+
return this.getFinalIconElement(icon, content);
|
|
177
|
+
};
|
|
178
|
+
|
|
179
|
+
this.getIconPlus = () => {
|
|
180
|
+
const {
|
|
181
|
+
zoomInTip,
|
|
182
|
+
zoom,
|
|
183
|
+
max
|
|
184
|
+
} = this.props;
|
|
185
|
+
const disabledZoomIn = zoom === max;
|
|
186
|
+
|
|
187
|
+
const icon = /*#__PURE__*/_react.default.createElement(_semiIcons.IconPlus, {
|
|
188
|
+
size: "large",
|
|
189
|
+
onClick: !disabledZoomIn ? this.handlePlusClick : undefined,
|
|
190
|
+
className: disabledZoomIn ? "".concat(footerPrefixCls, "-disabled") : ""
|
|
191
|
+
});
|
|
192
|
+
|
|
193
|
+
const content = zoomInTip !== null && zoomInTip !== void 0 ? zoomInTip : this.getLocalTextByKey("zoomInTip");
|
|
194
|
+
return this.getFinalIconElement(icon, content);
|
|
195
|
+
};
|
|
196
|
+
|
|
197
|
+
this.getIconRatio = () => {
|
|
198
|
+
const {
|
|
199
|
+
ratio,
|
|
200
|
+
originTip,
|
|
201
|
+
adaptiveTip
|
|
202
|
+
} = this.props;
|
|
203
|
+
const props = {
|
|
204
|
+
size: "large",
|
|
205
|
+
className: (0, _classnames.default)("".concat(footerPrefixCls, "-gap")),
|
|
206
|
+
onClick: this.handleRatioClick
|
|
207
|
+
};
|
|
208
|
+
const icon = ratio === "adaptation" ? /*#__PURE__*/_react.default.createElement(_semiIcons.IconRealSizeStroked, Object.assign({}, props)) : /*#__PURE__*/_react.default.createElement(_semiIcons.IconWindowAdaptionStroked, Object.assign({}, props));
|
|
209
|
+
let content;
|
|
210
|
+
|
|
211
|
+
if (ratio === "adaptation") {
|
|
212
|
+
content = originTip !== null && originTip !== void 0 ? originTip : this.getLocalTextByKey("originTip");
|
|
213
|
+
} else {
|
|
214
|
+
content = adaptiveTip !== null && adaptiveTip !== void 0 ? adaptiveTip : this.getLocalTextByKey("adaptiveTip");
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
return this.getFinalIconElement(icon, content);
|
|
218
|
+
};
|
|
219
|
+
|
|
220
|
+
this.getIconRotate = () => {
|
|
221
|
+
const {
|
|
222
|
+
rotateTip
|
|
223
|
+
} = this.props;
|
|
224
|
+
|
|
225
|
+
const icon = /*#__PURE__*/_react.default.createElement(_semiIcons.IconRotate, {
|
|
226
|
+
size: "large",
|
|
227
|
+
onClick: this.handleRotateLeft
|
|
228
|
+
});
|
|
229
|
+
|
|
230
|
+
const content = rotateTip !== null && rotateTip !== void 0 ? rotateTip : this.getLocalTextByKey("rotateTip");
|
|
231
|
+
return this.getFinalIconElement(icon, content);
|
|
232
|
+
};
|
|
233
|
+
|
|
234
|
+
this.getIconDownload = () => {
|
|
235
|
+
const {
|
|
236
|
+
downloadTip,
|
|
237
|
+
onDownload,
|
|
238
|
+
disableDownload
|
|
239
|
+
} = this.props;
|
|
240
|
+
|
|
241
|
+
const icon = /*#__PURE__*/_react.default.createElement(_semiIcons.IconDownload, {
|
|
242
|
+
size: "large",
|
|
243
|
+
onClick: !disableDownload ? onDownload : undefined,
|
|
244
|
+
className: (0, _classnames.default)("".concat(footerPrefixCls, "-gap"), {
|
|
245
|
+
["".concat(footerPrefixCls, "-disabled")]: disableDownload
|
|
246
|
+
})
|
|
247
|
+
});
|
|
248
|
+
|
|
249
|
+
const content = downloadTip !== null && downloadTip !== void 0 ? downloadTip : this.getLocalTextByKey("downloadTip");
|
|
250
|
+
return this.getFinalIconElement(icon, content);
|
|
251
|
+
};
|
|
252
|
+
|
|
253
|
+
this.foundation = new _previewFooterFoundation.default(this.adapter);
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
get adapter() {
|
|
257
|
+
return Object.assign(Object.assign({}, super.adapter), {
|
|
258
|
+
setStartMouseOffset: time => {
|
|
259
|
+
mouseActiveTime = time;
|
|
260
|
+
}
|
|
261
|
+
});
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
render() {
|
|
265
|
+
const {
|
|
266
|
+
min,
|
|
267
|
+
max,
|
|
268
|
+
step,
|
|
269
|
+
curPage,
|
|
270
|
+
totalNum,
|
|
271
|
+
zoom,
|
|
272
|
+
showTooltip,
|
|
273
|
+
className,
|
|
274
|
+
renderPreviewMenu
|
|
275
|
+
} = this.props;
|
|
276
|
+
|
|
277
|
+
if (renderPreviewMenu) {
|
|
278
|
+
return /*#__PURE__*/_react.default.createElement("div", {
|
|
279
|
+
className: "".concat(footerPrefixCls, "-wrapper")
|
|
280
|
+
}, this.customRenderViewMenu());
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
return /*#__PURE__*/_react.default.createElement("section", {
|
|
284
|
+
className: (0, _classnames.default)(footerPrefixCls, "".concat(footerPrefixCls, "-wrapper"), className)
|
|
285
|
+
}, this.getIconChevronLeft(), /*#__PURE__*/_react.default.createElement("div", {
|
|
286
|
+
className: "".concat(footerPrefixCls, "-page")
|
|
287
|
+
}, /*#__PURE__*/_react.default.createElement("span", null, curPage), /*#__PURE__*/_react.default.createElement("span", null, "/"), /*#__PURE__*/_react.default.createElement("span", null, totalNum)), this.getIconChevronRight(), /*#__PURE__*/_react.default.createElement(_divider.default, {
|
|
288
|
+
layout: "vertical"
|
|
289
|
+
}), this.getIconMinus(), /*#__PURE__*/_react.default.createElement(_slider.default, {
|
|
290
|
+
value: zoom,
|
|
291
|
+
min: min,
|
|
292
|
+
max: max,
|
|
293
|
+
step: step,
|
|
294
|
+
tipFormatter: v => "".concat(v, "%"),
|
|
295
|
+
tooltipVisible: showTooltip ? undefined : false,
|
|
296
|
+
onChange: this.handleSlideChange
|
|
297
|
+
}), this.getIconPlus(), this.getIconRatio(), /*#__PURE__*/_react.default.createElement(_divider.default, {
|
|
298
|
+
layout: "vertical"
|
|
299
|
+
}), this.getIconRotate(), this.getIconDownload());
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
exports.default = Footer;
|
|
305
|
+
Footer.propTypes = {
|
|
306
|
+
curPage: _propTypes.default.number,
|
|
307
|
+
totalNum: _propTypes.default.number,
|
|
308
|
+
disabledPrev: _propTypes.default.bool,
|
|
309
|
+
disabledNext: _propTypes.default.bool,
|
|
310
|
+
disableDownload: _propTypes.default.bool,
|
|
311
|
+
className: _propTypes.default.string,
|
|
312
|
+
zoom: _propTypes.default.number,
|
|
313
|
+
ratio: _propTypes.default.string,
|
|
314
|
+
prevTip: _propTypes.default.string,
|
|
315
|
+
nextTip: _propTypes.default.string,
|
|
316
|
+
zoomInTip: _propTypes.default.string,
|
|
317
|
+
zoomOutTip: _propTypes.default.string,
|
|
318
|
+
rotateTip: _propTypes.default.string,
|
|
319
|
+
downloadTip: _propTypes.default.string,
|
|
320
|
+
adaptiveTip: _propTypes.default.string,
|
|
321
|
+
originTip: _propTypes.default.string,
|
|
322
|
+
showTooltip: _propTypes.default.bool,
|
|
323
|
+
onZoomIn: _propTypes.default.func,
|
|
324
|
+
onZoomOut: _propTypes.default.func,
|
|
325
|
+
onPrev: _propTypes.default.func,
|
|
326
|
+
onNext: _propTypes.default.func,
|
|
327
|
+
onAdjustRatio: _propTypes.default.func,
|
|
328
|
+
onRotateLeft: _propTypes.default.func,
|
|
329
|
+
onDownload: _propTypes.default.func
|
|
330
|
+
};
|
|
331
|
+
Footer.defaultProps = {
|
|
332
|
+
min: 10,
|
|
333
|
+
max: 500,
|
|
334
|
+
step: 10,
|
|
335
|
+
showTooltip: false,
|
|
336
|
+
disableDownload: false
|
|
337
|
+
};
|