@douyinfe/semi-foundation 2.20.0-beta.0 → 2.20.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (57) hide show
  1. package/calendar/foundation.ts +1 -2
  2. package/datePicker/foundation.ts +6 -5
  3. package/datePicker/monthsGridFoundation.ts +6 -6
  4. package/datePicker/yearAndMonthFoundation.ts +2 -2
  5. package/form/form.scss +14 -0
  6. package/image/image.scss +3 -0
  7. package/image/{imageFoundation.tsx → imageFoundation.ts} +0 -0
  8. package/image/{previewFooterFoundation.tsx → previewFooterFoundation.ts} +0 -0
  9. package/image/{previewFoundation.tsx → previewFoundation.ts} +0 -0
  10. package/image/{previewImageFoundation.tsx → previewImageFoundation.ts} +5 -5
  11. package/image/{previewInnerFoundation.tsx → previewInnerFoundation.ts} +5 -1
  12. package/image/utils.ts +5 -3
  13. package/lib/cjs/calendar/foundation.d.ts +2 -1
  14. package/lib/cjs/datePicker/foundation.d.ts +4 -4
  15. package/lib/cjs/datePicker/monthsGridFoundation.d.ts +2 -3
  16. package/lib/cjs/datePicker/yearAndMonthFoundation.d.ts +2 -3
  17. package/lib/cjs/form/form.css +8 -0
  18. package/lib/cjs/form/form.scss +14 -0
  19. package/lib/cjs/image/image.css +3 -0
  20. package/lib/cjs/image/image.scss +3 -0
  21. package/lib/cjs/image/imageFoundation.d.ts +11 -0
  22. package/lib/cjs/image/imageFoundation.js +89 -0
  23. package/lib/cjs/image/previewFooterFoundation.d.ts +10 -0
  24. package/lib/cjs/image/previewFooterFoundation.js +69 -0
  25. package/lib/cjs/image/previewFoundation.d.ts +5 -0
  26. package/lib/cjs/image/previewFoundation.js +49 -0
  27. package/lib/cjs/image/previewImageFoundation.d.ts +58 -0
  28. package/lib/cjs/image/previewImageFoundation.js +367 -0
  29. package/lib/cjs/image/previewInnerFoundation.d.ts +44 -0
  30. package/lib/cjs/image/previewInnerFoundation.js +341 -0
  31. package/lib/cjs/image/utils.js +5 -5
  32. package/lib/cjs/navigation/foundation.d.ts +0 -1
  33. package/lib/cjs/navigation/foundation.js +1 -11
  34. package/lib/es/calendar/foundation.d.ts +2 -1
  35. package/lib/es/datePicker/foundation.d.ts +4 -4
  36. package/lib/es/datePicker/monthsGridFoundation.d.ts +2 -3
  37. package/lib/es/datePicker/yearAndMonthFoundation.d.ts +2 -3
  38. package/lib/es/form/form.css +8 -0
  39. package/lib/es/form/form.scss +14 -0
  40. package/lib/es/image/image.css +3 -0
  41. package/lib/es/image/image.scss +3 -0
  42. package/lib/es/image/imageFoundation.d.ts +11 -0
  43. package/lib/es/image/imageFoundation.js +76 -0
  44. package/lib/es/image/previewFooterFoundation.d.ts +10 -0
  45. package/lib/es/image/previewFooterFoundation.js +57 -0
  46. package/lib/es/image/previewFoundation.d.ts +5 -0
  47. package/lib/es/image/previewFoundation.js +37 -0
  48. package/lib/es/image/previewImageFoundation.d.ts +58 -0
  49. package/lib/es/image/previewImageFoundation.js +352 -0
  50. package/lib/es/image/previewInnerFoundation.d.ts +44 -0
  51. package/lib/es/image/previewInnerFoundation.js +326 -0
  52. package/lib/es/image/utils.js +5 -5
  53. package/lib/es/navigation/foundation.d.ts +0 -1
  54. package/lib/es/navigation/foundation.js +1 -11
  55. package/navigation/foundation.ts +2 -9
  56. package/package.json +2 -2
  57. package/tree/treeUtil.ts +1 -1
@@ -0,0 +1,341 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+
8
+ var _foundation = _interopRequireDefault(require("../base/foundation"));
9
+
10
+ var _keyCode = _interopRequireDefault(require("../utils/keyCode"));
11
+
12
+ var _utils = require("./utils");
13
+
14
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
15
+
16
+ const NOT_CLOSE_TARGETS = ["icon", "footer"];
17
+ const STOP_CLOSE_TARGET = ["icon", "footer", "header"];
18
+
19
+ class PreviewInnerFoundation extends _foundation.default {
20
+ constructor(adapter) {
21
+ super(Object.assign({}, adapter));
22
+
23
+ this.handleViewVisibleChange = () => {
24
+ const nowTime = new Date().getTime();
25
+
26
+ const mouseActiveTime = this._adapter.getMouseActiveTime();
27
+
28
+ const stopTiming = this._adapter.getStopTiming();
29
+
30
+ const {
31
+ viewerVisibleDelay
32
+ } = this.getProps();
33
+ const {
34
+ viewerVisible
35
+ } = this.getStates();
36
+
37
+ if (nowTime - mouseActiveTime > viewerVisibleDelay && !stopTiming) {
38
+ viewerVisible && this.setState({
39
+ viewerVisible: false
40
+ });
41
+ }
42
+ };
43
+
44
+ this.handleMouseMoveEvent = (e, event) => {
45
+ const isTarget = (0, _utils.isTargetEmit)(e.nativeEvent, STOP_CLOSE_TARGET);
46
+
47
+ if (isTarget && event === "over") {
48
+ this._adapter.setStopTiming(true);
49
+ } else if (isTarget && event === "out") {
50
+ this._adapter.setStopTiming(false);
51
+ }
52
+ };
53
+
54
+ this.handleMouseMove = e => {
55
+ this._adapter.setMouseActiveTime(new Date().getTime());
56
+
57
+ this.setState({
58
+ viewerVisible: true
59
+ });
60
+ };
61
+
62
+ this.handleMouseUp = e => {
63
+ const {
64
+ maskClosable
65
+ } = this.getProps();
66
+ let couldClose = !(0, _utils.isTargetEmit)(e.nativeEvent, NOT_CLOSE_TARGETS);
67
+ const {
68
+ clientX,
69
+ clientY
70
+ } = e;
71
+
72
+ const {
73
+ x,
74
+ y
75
+ } = this._adapter.getStartMouseDown(); // 对鼠标移动做容错处理,当 x 和 y 方向在 mouseUp 的时候移动距离都小于等于 5px 时候就可以关闭预览
76
+ // Error-tolerant processing of mouse movement, when the movement distance in the x and y directions is less than or equal to 5px in mouseUp, the preview can be closed
77
+ // 不做容错处理的话,直接用 clientX !== x || y !== clientY 做判断,鼠标在用户点击时候无意识的轻微移动无法关闭预览,不符合用户预期
78
+ // If you do not do fault-tolerant processing, but directly use clientX !== x || y !== clientY to make judgments, the slight movement of the mouse when the user clicks will not be able to close the preview, which does not meet the user's expectations.
79
+
80
+
81
+ if (Math.abs(clientX - x) > 5 || Math.abs(y - clientY) > 5) {
82
+ couldClose = false;
83
+ }
84
+
85
+ if (couldClose && maskClosable) {
86
+ this.handlePreviewClose();
87
+ }
88
+ };
89
+
90
+ this.handleMouseDown = e => {
91
+ const {
92
+ clientX,
93
+ clientY
94
+ } = e;
95
+
96
+ this._adapter.setStartMouseDown(clientX, clientY);
97
+ };
98
+
99
+ this.handleKeyDown = e => {
100
+ const {
101
+ closeOnEsc
102
+ } = this.getProps();
103
+
104
+ if (closeOnEsc && e.keyCode === _keyCode.default.ESC) {
105
+ e.stopPropagation();
106
+
107
+ this._adapter.notifyVisibleChange(false);
108
+
109
+ this._adapter.notifyClose();
110
+
111
+ return;
112
+ }
113
+ };
114
+
115
+ this.handleSwitchImage = direction => {
116
+ const step = direction === "prev" ? -1 : 1;
117
+ const {
118
+ imgSrc,
119
+ currentIndex: currentIndexInState
120
+ } = this.getStates();
121
+ const srcLength = imgSrc.length;
122
+ const newIndex = (currentIndexInState + step + srcLength) % srcLength;
123
+
124
+ if ("currentIndex" in this.getProps()) {
125
+ if (this._adapter.getIsInGroup()) {
126
+ const setCurrentIndex = this._adapter.getContext("setCurrentIndex");
127
+
128
+ setCurrentIndex(newIndex);
129
+ }
130
+ } else {
131
+ this.setState({
132
+ currentIndex: newIndex
133
+ });
134
+ }
135
+
136
+ this._adapter.notifyChange(newIndex);
137
+
138
+ this.setState({
139
+ direction,
140
+ rotation: 0
141
+ });
142
+
143
+ this._adapter.notifyRotateChange(0);
144
+ };
145
+
146
+ this.handleDownload = () => {
147
+ const {
148
+ currentIndex,
149
+ imgSrc
150
+ } = this.getStates();
151
+ const downloadSrc = imgSrc[currentIndex];
152
+ const downloadName = downloadSrc.slice(downloadSrc.lastIndexOf("/") + 1);
153
+ (0, _utils.downloadImage)(downloadSrc, downloadName);
154
+
155
+ this._adapter.notifyDownload(downloadSrc, currentIndex);
156
+ };
157
+
158
+ this.handlePreviewClose = () => {
159
+ this._adapter.notifyVisibleChange(false);
160
+
161
+ this._adapter.notifyClose();
162
+ };
163
+
164
+ this.handleAdjustRatio = type => {
165
+ this.setState({
166
+ ratio: type
167
+ });
168
+
169
+ this._adapter.notifyRatioChange(type);
170
+ };
171
+
172
+ this.handleRotateImage = direction => {
173
+ const {
174
+ rotation
175
+ } = this.getStates();
176
+ const newRotation = rotation + (direction === "left" ? 90 : -90);
177
+ this.setState({
178
+ rotation: newRotation
179
+ });
180
+
181
+ this._adapter.notifyRotateChange(newRotation);
182
+ };
183
+
184
+ this.handleZoomImage = newZoom => {
185
+ const {
186
+ zoom
187
+ } = this.getStates();
188
+
189
+ this._adapter.notifyZoom(newZoom, newZoom > zoom);
190
+
191
+ this.setState({
192
+ zoom: newZoom
193
+ });
194
+ }; // 当 visible 改变之后,预览组件完成首张图片加载后,启动预加载
195
+ // 如: 1,2,3,4,5,6,7,8张图片, 点击第 4 张图片,preLoadGap 为 2
196
+ // 当 visible 从 false 变为 true ,首先加载第 4 张图片,当第 4 张图片加载完成后,
197
+ // 再按照 5,3,6,2的顺序预先加载这几张图片
198
+ // When visible changes, the preview component finishes loading the first image and starts preloading
199
+ // Such as: 1, 2, 3, 4, 5, 6, 7, 8 pictures, click the 4th picture, preLoadGap is 2
200
+ // When visible changes from false to true , load the 4th image first, when the 4th image is loaded,
201
+ // Preload these pictures in the order of 5, 3, 6, 2
202
+
203
+
204
+ this.preloadGapImage = () => {
205
+ const {
206
+ preLoad,
207
+ preLoadGap,
208
+ infinite,
209
+ currentIndex
210
+ } = this.getProps();
211
+ const {
212
+ imgSrc
213
+ } = this.getStates();
214
+
215
+ if (!preLoad || typeof preLoadGap !== "number" || preLoadGap < 1) {
216
+ return;
217
+ }
218
+
219
+ const preloadImages = (0, _utils.getPreloadImagArr)(imgSrc, currentIndex, preLoadGap, infinite);
220
+ const Img = new Image();
221
+ let index = 0;
222
+
223
+ function callback(e) {
224
+ index++;
225
+
226
+ if (index < preloadImages.length) {
227
+ Img.src = preloadImages[index];
228
+ }
229
+ }
230
+
231
+ Img.onload = e => {
232
+ this.setLoadSuccessStatus(Img.src);
233
+ callback(e);
234
+ };
235
+
236
+ Img.onerror = callback;
237
+ Img.src = preloadImages[0];
238
+ }; // 在切换左右图片时,当被切换图片完成加载后,根据方向决定下一个预加载的图片
239
+ // 如: 1,2,3,4,5,6,7,8张图片
240
+ // 当 preLoadGap 为 2, 从第 5 张图片进行切换
241
+ // - 如果向 右 切换到第 6 张,则第 6 张图片加载动作结束后(无论加载成功 or 失败),会预先加载第 8 张;
242
+ // - 如果向 左 切换到第 4 张,则第 4 张图片加载动作结束后(无论加载成功 or 失败),会预先加载第 2 张;
243
+ // When switching the left and right pictures, when the switched picture is loaded, the next preloaded picture is determined according to the direction
244
+ // Such as: 1, 2, 3, 4, 5, 6, 7, 8 pictures
245
+ // When preLoadGap is 2, switch from the 5th picture
246
+ // - If you switch to the 6th image(direction is next), the 8th image will be preloaded after the 6th image is loaded (whether it succeeds or fails to load);
247
+ // - If you switch to the 4th image(direction is prev), the second image will be preloaded after the 4th image is loaded (whether it succeeds or fails to load);
248
+
249
+
250
+ this.preloadSingleImage = () => {
251
+ const {
252
+ preLoad,
253
+ preLoadGap,
254
+ infinite
255
+ } = this.getProps();
256
+ const {
257
+ imgSrc,
258
+ currentIndex,
259
+ direction,
260
+ imgLoadStatus
261
+ } = this.getStates();
262
+
263
+ if (!preLoad || typeof preLoadGap !== "number" || preLoadGap < 1) {
264
+ return;
265
+ } // 根据方向决定preload那个index
266
+ // Determine the index of preload according to the direction
267
+
268
+
269
+ let preloadIndex = currentIndex + (direction === "prev" ? -1 : 1) * preLoadGap;
270
+
271
+ if (preloadIndex < 0 || preloadIndex >= imgSrc.length) {
272
+ if (infinite) {
273
+ preloadIndex = (preloadIndex + imgSrc.length) % imgSrc.length;
274
+ } else {
275
+ return;
276
+ }
277
+ } // 如果图片没有加载成功过,则进行预加载
278
+ // If the image has not been loaded successfully, preload it
279
+
280
+
281
+ if (!imgLoadStatus[preloadIndex]) {
282
+ const Img = new Image();
283
+
284
+ Img.onload = e => {
285
+ this.setLoadSuccessStatus(imgSrc[preloadIndex]);
286
+ };
287
+
288
+ Img.src = imgSrc[preloadIndex];
289
+ }
290
+ };
291
+
292
+ this.setLoadSuccessStatus = src => {
293
+ const {
294
+ imgLoadStatus
295
+ } = this.getStates();
296
+ const status = Object.assign({}, imgLoadStatus);
297
+ status[src] = true;
298
+ this.setState({
299
+ imgLoadStatus: status
300
+ });
301
+ };
302
+
303
+ this.onImageLoad = src => {
304
+ const {
305
+ preloadAfterVisibleChange
306
+ } = this.getStates();
307
+ this.setLoadSuccessStatus(src); // 当 preview 中当前加载的图片加载完成后,
308
+ // 如果是在visible change之后的第一次加载,则启动加载该currentIndex左右preloadGap范围的图片
309
+ // 如果是非第一次加载,是在左右切换图片,则根据方向预先加载单张图片
310
+ // When the currently loaded image in Preview is loaded,
311
+ // - It is the first load after visible change, start loading the images in the preloadGap range around the currentIndex
312
+ // - It is not the first load, the image is switched left and right, and a single image is preloaded according to the direction
313
+
314
+ if (preloadAfterVisibleChange) {
315
+ this.preloadGapImage();
316
+ this.setState({
317
+ preloadAfterVisibleChange: false
318
+ });
319
+ } else {
320
+ this.preloadSingleImage();
321
+ }
322
+ };
323
+ }
324
+
325
+ beforeShow() {
326
+ this._adapter.registerKeyDownListener();
327
+ }
328
+
329
+ afterHide() {
330
+ this._adapter.unregisterKeyDownListener();
331
+ }
332
+
333
+ handleRatio(type) {
334
+ this.setState({
335
+ ratio: type
336
+ });
337
+ }
338
+
339
+ }
340
+
341
+ exports.default = PreviewInnerFoundation;
@@ -6,11 +6,11 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.isTargetEmit = exports.getPreloadImagArr = exports.downloadImage = exports.crossMerge = void 0;
7
7
 
8
8
  const isTargetEmit = (event, targetClasses) => {
9
- var _a; // e.path is the event-triggered bubbling path, which stores each node through which bubbling passes.
10
- // e.path.length-4 is to remove elements above the root node, such as body, html, document, window
11
-
12
-
13
- const isTarget = (_a = event === null || event === void 0 ? void 0 : event.path) === null || _a === void 0 ? void 0 : _a.slice(0, event.path.length - 4).some(node => {
9
+ // event.path usage is discouraged, use event.composedPath() as it's standard and is more future-proof
10
+ // path is the event-triggered bubbling path, which stores each node through which bubbling passes.
11
+ // path.length-4 is to remove elements above the root node, such as body, html, document, window
12
+ const path = event === null || event === void 0 ? void 0 : event.composedPath();
13
+ const isTarget = path === null || path === void 0 ? void 0 : path.slice(0, path.length - 4).some(node => {
14
14
  if (node.className && typeof node.className === "string") {
15
15
  return targetClasses.some(c => node.className.includes(c));
16
16
  }
@@ -74,7 +74,6 @@ export default class NavigationFoundation<P = Record<string, any>, S = Record<st
74
74
  * @param {*} itemKeysMap
75
75
  */
76
76
  getWillOpenKeys(itemKeysMap: ItemKey2ParentKeysMap): any[];
77
- getItemKey(item: string | number, keyPropName?: string): string | number;
78
77
  getShouldOpenKeys(itemKeysMap?: ItemKey2ParentKeysMap, selectedKeys?: string | number[]): unknown[];
79
78
  destroy(): void;
80
79
  selectLevelZeroParentKeys(itemKeysMap: ItemKey2ParentKeysMap, ...itemKeys: (string | number)[]): any[];
@@ -186,16 +186,6 @@ class NavigationFoundation extends _foundation.default {
186
186
  return [...willOpenKeys];
187
187
  }
188
188
 
189
- getItemKey(item) {
190
- let keyPropName = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'itemKey';
191
-
192
- if (item && typeof item === 'object') {
193
- return item[keyPropName];
194
- }
195
-
196
- return item;
197
- }
198
-
199
189
  getShouldOpenKeys() {
200
190
  let itemKeysMap = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
201
191
  let selectedKeys = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
@@ -204,7 +194,7 @@ class NavigationFoundation extends _foundation.default {
204
194
  if (Array.isArray(selectedKeys) && selectedKeys.length) {
205
195
  selectedKeys.forEach(item => {
206
196
  if (item) {
207
- const parentKeys = (0, _get2.default)(itemKeysMap, this.getItemKey(item));
197
+ const parentKeys = (0, _get2.default)(itemKeysMap, item);
208
198
 
209
199
  if (Array.isArray(parentKeys)) {
210
200
  parentKeys.forEach(k => willOpenKeySet.add(k));
@@ -1,6 +1,7 @@
1
1
  import BaseFoundation, { DefaultAdapter } from '../base/foundation';
2
2
  import { Locale } from 'date-fns';
3
- import { DateObj, weeekStartsOnEnum } from './eventUtil';
3
+ import { DateObj } from './eventUtil';
4
+ import type { weeekStartsOnEnum } from './eventUtil';
4
5
  export { weeekStartsOnEnum };
5
6
  export interface EventObject {
6
7
  [x: string]: any;
@@ -1,9 +1,9 @@
1
1
  import BaseFoundation, { DefaultAdapter } from '../base/foundation';
2
2
  import { strings } from './constants';
3
- import { Type, DateInputFoundationProps, InsetInputValue } from './inputFoundation';
4
- import { MonthsGridFoundationProps } from './monthsGridFoundation';
5
- import { WeekStartNumber } from './_utils/getMonthTable';
6
- import { ArrayElement, Motion } from '../utils/type';
3
+ import type { ArrayElement, Motion } from '../utils/type';
4
+ import type { Type, DateInputFoundationProps, InsetInputValue } from './inputFoundation';
5
+ import type { MonthsGridFoundationProps } from './monthsGridFoundation';
6
+ import type { WeekStartNumber } from './_utils/getMonthTable';
7
7
  export declare type ValidateStatus = ArrayElement<typeof strings.STATUS>;
8
8
  export declare type InputSize = ArrayElement<typeof strings.SIZE_SET>;
9
9
  export declare type Position = ArrayElement<typeof strings.POSITION_SET>;
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import BaseFoundation, { DefaultAdapter } from '../base/foundation';
3
2
  import { strings } from './constants';
4
3
  import { WeekStartNumber } from './_utils/getMonthTable';
@@ -56,8 +55,8 @@ export interface MonthsGridFoundationProps extends MonthsGridElementProps {
56
55
  triggerRender?: (props: Record<string, any>) => any;
57
56
  insetInput: boolean;
58
57
  presetPosition?: PresetPosition;
59
- renderQuickControls?: React.ReactNode;
60
- renderDateInput?: React.ReactNode;
58
+ renderQuickControls?: any;
59
+ renderDateInput?: any;
61
60
  }
62
61
  export interface MonthInfo {
63
62
  pickerDate: Date;
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import BaseFoundation, { DefaultAdapter } from '../base/foundation';
3
2
  import { PresetPosition } from './foundation';
4
3
  export interface YearAndMonthFoundationProps {
@@ -17,8 +16,8 @@ export interface YearAndMonthFoundationProps {
17
16
  disabledDate?: (date: Date) => boolean;
18
17
  density?: string;
19
18
  presetPosition?: PresetPosition;
20
- renderQuickControls?: React.ReactNode;
21
- renderDateInput?: React.ReactNode;
19
+ renderQuickControls?: any;
20
+ renderDateInput?: any;
22
21
  }
23
22
  export interface YearAndMonthFoundationState {
24
23
  years: Array<{
@@ -35,6 +35,14 @@
35
35
  display: flex;
36
36
  justify-content: flex-start;
37
37
  }
38
+ .semi-form-vertical .semi-form-field-group .semi-form-col-right {
39
+ display: flex;
40
+ justify-content: flex-end;
41
+ }
42
+ .semi-form-vertical .semi-form-field-group .semi-form-col-left {
43
+ display: flex;
44
+ justify-content: flex-start;
45
+ }
38
46
  .semi-form-field-label {
39
47
  box-sizing: border-box;
40
48
  padding-right: 16px;
@@ -66,6 +66,20 @@ $rating: #{$prefix}-rating;
66
66
  }
67
67
  }
68
68
  }
69
+
70
+ .#{$field}-group {
71
+ .#{$col} {
72
+ &-right {
73
+ display: flex;
74
+ justify-content: flex-end;
75
+ }
76
+ &-left {
77
+ display: flex;
78
+ justify-content: flex-start;
79
+ }
80
+ }
81
+ }
82
+
69
83
  .#{$field}-pure {
70
84
  // padding-top: 0;
71
85
  // padding-bottom: 0;
@@ -10,6 +10,7 @@
10
10
  .semi-image-img {
11
11
  vertical-align: middle;
12
12
  border-radius: inherit;
13
+ user-select: none;
13
14
  }
14
15
  .semi-image-img-preview {
15
16
  cursor: zoom-in;
@@ -120,6 +121,7 @@
120
121
  transform: translateX(-50%);
121
122
  }
122
123
  .semi-image-preview-footer-page {
124
+ user-select: none;
123
125
  color: var(--semi-color-white);
124
126
  font-size: 16px;
125
127
  line-height: 22px;
@@ -168,6 +170,7 @@
168
170
  transform: scale3d(1, 1, 1) var(--semi-transform-rotate-none);
169
171
  transition: transform 0.3s 0s;
170
172
  z-index: 0;
173
+ user-select: none;
171
174
  }
172
175
  .semi-image-preview-image-spin {
173
176
  position: absolute;
@@ -13,6 +13,7 @@ $module: #{$prefix}-image;
13
13
  &-img {
14
14
  vertical-align: middle;
15
15
  border-radius: inherit;
16
+ user-select: none;
16
17
 
17
18
  &-preview {
18
19
  cursor: zoom-in;
@@ -135,6 +136,7 @@ $module: #{$prefix}-image;
135
136
  }
136
137
 
137
138
  &-page {
139
+ user-select: none;
138
140
  color: $color-image_preview_footer_icon;
139
141
  @include font-size-header-6;
140
142
  margin: $spacing-image_preview_footer_page-marginY $spacing-image_preview_footer_page-marginX;
@@ -192,6 +194,7 @@ $module: #{$prefix}-image;
192
194
  transform: scale3d($transform_scale3d-image_preview_image_img) $transform_rotate-image_preview_image_img;
193
195
  transition: transform $transition_duration-image_preview_image_img $transition_delay-image_preview_image_img;
194
196
  z-index: 0;
197
+ user-select: none;
195
198
  }
196
199
 
197
200
  &-spin {
@@ -0,0 +1,11 @@
1
+ import BaseFoundation, { DefaultAdapter } from "../base/foundation";
2
+ export interface ImageAdapter<P = Record<string, any>, S = Record<string, any>> extends DefaultAdapter<P, S> {
3
+ getIsInGroup: () => boolean;
4
+ }
5
+ export default class ImageFoundation<P = Record<string, any>, S = Record<string, any>> extends BaseFoundation<ImageAdapter<P, S>, P, S> {
6
+ constructor(adapter: ImageAdapter<P, S>);
7
+ handleClick: (e: any) => void;
8
+ handleLoaded: (e: any) => void;
9
+ handleError: (e: any) => void;
10
+ handlePreviewVisibleChange: (newVisible: boolean) => void;
11
+ }
@@ -0,0 +1,76 @@
1
+ import _isObject from "lodash/isObject";
2
+ import BaseFoundation from "../base/foundation";
3
+ export default class ImageFoundation extends BaseFoundation {
4
+ constructor(adapter) {
5
+ super(Object.assign({}, adapter));
6
+
7
+ this.handleClick = e => {
8
+ const {
9
+ imageID,
10
+ preview
11
+ } = this.getProps(); // if preview = false, then it cannot preview
12
+
13
+ if (!preview) {
14
+ return;
15
+ } // if image in group, then use group's Preview components
16
+
17
+
18
+ if (this._adapter.getIsInGroup()) {
19
+ const {
20
+ setCurrentIndex,
21
+ handleVisibleChange
22
+ } = this._adapter.getContexts();
23
+
24
+ setCurrentIndex(imageID);
25
+ handleVisibleChange(true);
26
+ } else {
27
+ // image isn't in group, then use it's own Preview components
28
+ this.handlePreviewVisibleChange(true);
29
+ }
30
+ };
31
+
32
+ this.handleLoaded = e => {
33
+ const {
34
+ onLoad
35
+ } = this.getProps();
36
+ onLoad && onLoad(e);
37
+ this.setState({
38
+ loadStatus: "success"
39
+ });
40
+ };
41
+
42
+ this.handleError = e => {
43
+ const {
44
+ onError
45
+ } = this.getProps();
46
+ onError && onError(e);
47
+ this.setState({
48
+ loadStatus: "error"
49
+ });
50
+ };
51
+
52
+ this.handlePreviewVisibleChange = newVisible => {
53
+ const {
54
+ preview
55
+ } = this.getProps();
56
+
57
+ if (_isObject(preview)) {
58
+ const {
59
+ onVisibleChange
60
+ } = preview;
61
+ onVisibleChange && onVisibleChange(newVisible);
62
+
63
+ if (!("visible" in this.getProps())) {
64
+ this.setState({
65
+ previewVisible: newVisible
66
+ });
67
+ }
68
+ } else {
69
+ this.setState({
70
+ previewVisible: newVisible
71
+ });
72
+ }
73
+ };
74
+ }
75
+
76
+ }
@@ -0,0 +1,10 @@
1
+ import BaseFoundation, { DefaultAdapter } from "../base/foundation";
2
+ export interface PreviewFooterAdapter<P = Record<string, any>, S = Record<string, any>> extends DefaultAdapter<P, S> {
3
+ setStartMouseOffset: (time: number) => void;
4
+ }
5
+ export default class PreviewFooterFoundation<P = Record<string, any>, S = Record<string, any>> extends BaseFoundation<PreviewFooterAdapter<P, S>, P, S> {
6
+ changeSliderValue: (type: string) => void;
7
+ handleValueChange: (value: number) => void;
8
+ handleRatioClick: () => void;
9
+ handleRotate: (direction: string) => void;
10
+ }