@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
@@ -32,9 +32,8 @@ import {
32
32
  parseRangeAllDayEvent,
33
33
  DateObj,
34
34
  checkWeekend,
35
- weeekStartsOnEnum
36
35
  } from './eventUtil';
37
-
36
+ import type { weeekStartsOnEnum } from './eventUtil';
38
37
 
39
38
  export { weeekStartsOnEnum };
40
39
  export interface EventObject {
@@ -12,13 +12,14 @@ import { getDefaultFormatTokenByType } from './_utils/getDefaultFormatToken';
12
12
  import { strings } from './constants';
13
13
  import { strings as inputStrings } from '../input/constants';
14
14
 
15
- import { Type, DateInputFoundationProps, InsetInputValue } from './inputFoundation';
16
- import { MonthsGridFoundationProps } from './monthsGridFoundation';
17
- import { WeekStartNumber } from './_utils/getMonthTable';
18
- import { ArrayElement, Motion } from '../utils/type';
19
15
  import getInsetInputFormatToken from './_utils/getInsetInputFormatToken';
20
16
  import getInsetInputValueFromInsetInputStr from './_utils/getInsetInputValueFromInsetInputStr';
21
17
 
18
+ import type { ArrayElement, Motion } from '../utils/type';
19
+ import type { Type, DateInputFoundationProps, InsetInputValue } from './inputFoundation';
20
+ import type { MonthsGridFoundationProps } from './monthsGridFoundation';
21
+ import type { WeekStartNumber } from './_utils/getMonthTable';
22
+
22
23
  export type ValidateStatus = ArrayElement<typeof strings.STATUS>;
23
24
  export type InputSize = ArrayElement<typeof strings.SIZE_SET>;
24
25
  export type Position = ArrayElement<typeof strings.POSITION_SET>;
@@ -956,7 +957,7 @@ export default class DatePickerFoundation extends BaseFoundation<DatePickerAdapt
956
957
  if (insetInput) {
957
958
  const insetInputFormatToken = getInsetInputFormatToken({ format, type });
958
959
  const insetInputStr = this._isMultiple() ? this.formatMultipleDates(dates, undefined, insetInputFormatToken) : this.formatDates(dates, insetInputFormatToken);
959
- insetInputValue = getInsetInputValueFromInsetInputStr({ inputValue: insetInputStr, type, rangeSeparator });
960
+ insetInputValue = getInsetInputValueFromInsetInputStr({ inputValue: insetInputStr, type, rangeSeparator });
960
961
  }
961
962
  const isRangeTypeAndInputIncomplete = this._isRangeType() && !this._isRangeValueComplete(dates);
962
963
  /**
@@ -92,8 +92,8 @@ export interface MonthsGridFoundationProps extends MonthsGridElementProps {
92
92
  triggerRender?: (props: Record<string, any>) => any;
93
93
  insetInput: boolean;
94
94
  presetPosition?: PresetPosition;
95
- renderQuickControls?: React.ReactNode;
96
- renderDateInput?: React.ReactNode;
95
+ renderQuickControls?: any;
96
+ renderDateInput?: any;
97
97
  }
98
98
 
99
99
  export interface MonthInfo {
@@ -284,7 +284,7 @@ export default class MonthsGridFoundation extends BaseFoundation<MonthsGridAdapt
284
284
  * sync change another panel month when change months from the else yam panel
285
285
  * call it when
286
286
  * - current change panel targe date month is same with another panel date
287
- *
287
+ *
288
288
  * @example
289
289
  * - panelType=right, target=new Date('2022-09-01') and left panel is in '2022-09' => call it, left panel minus one month to '2022-08'
290
290
  * - panelType=left, target=new Date('2021-12-01') and right panel is in '2021-12' => call it, right panel add one month to '2021-01'
@@ -310,7 +310,7 @@ export default class MonthsGridFoundation extends BaseFoundation<MonthsGridAdapt
310
310
  const { monthRight, monthLeft } = this._adapter.getStates();
311
311
  const currentDate = panelType === 'left' ? monthLeft.pickerDate : monthRight.pickerDate;
312
312
  let target: Date;
313
-
313
+
314
314
  switch (switchType) {
315
315
  case 'prevMonth':
316
316
  target = addMonths(currentDate, -1);
@@ -335,7 +335,7 @@ export default class MonthsGridFoundation extends BaseFoundation<MonthsGridAdapt
335
335
  const { type } = this._adapter.getProps();
336
336
  const diff = this._getDiff('month', target, panelType);
337
337
  this.handleYearOrMonthChange(diff < 0 ? 'prevMonth' : 'nextMonth', panelType, Math.abs(diff), false);
338
-
338
+
339
339
  if (this.isRangeType(type)) {
340
340
  this.handleSyncChangeMonths({ panelType, target });
341
341
  }
@@ -936,7 +936,7 @@ export default class MonthsGridFoundation extends BaseFoundation<MonthsGridAdapt
936
936
 
937
937
  /**
938
938
  * Get year and month panel open type
939
- *
939
+ *
940
940
  * It is useful info to set minHeight of weeks.
941
941
  * - When yam open type is 'left' or 'right', weeks minHeight should be set
942
942
  * If the minHeight is not set, the change of the number of weeks will cause the scrollList to be unstable
@@ -14,8 +14,8 @@ export interface YearAndMonthFoundationProps {
14
14
  disabledDate?: (date: Date) => boolean;
15
15
  density?: string;
16
16
  presetPosition?: PresetPosition;
17
- renderQuickControls?: React.ReactNode;
18
- renderDateInput?: React.ReactNode;
17
+ renderQuickControls?: any;
18
+ renderDateInput?: any;
19
19
  }
20
20
 
21
21
  export interface YearAndMonthFoundationState {
package/form/form.scss CHANGED
@@ -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;
package/image/image.scss CHANGED
@@ -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 {
@@ -220,16 +220,16 @@ export default class PreviewImageFoundation<P = Record<string, any>, S = Record<
220
220
  };
221
221
 
222
222
  handleMoveImage = (e: any): void => {
223
- const { offset, width, height, left, top } = this.getStates();
224
- const { rotation } = this.getProps();
223
+ const { offset, width, height } = this.getStates();
225
224
  const startMouseMove = this._adapter.getMouseMove();
226
225
  const startMouseOffset = this._adapter.getMouseOffset();
227
226
  const { canDragVertical, canDragHorizontal } = this.calcCanDragDirection();
228
227
  if (startMouseMove && (canDragVertical || canDragHorizontal)) {
229
- const { pageX, pageY } = e;
228
+ const { clientX, clientY } = e;
229
+ const { left: containerLeft, top: containerTop } = this._getContainerBounds();
230
230
  const { left: extremeLeft, top: extremeTop } = this.calcExtremeBounds();
231
- let newX = canDragHorizontal ? pageX - startMouseOffset.x : offset.x;
232
- let newY = canDragVertical ? pageY - startMouseOffset.y : offset.y;
231
+ let newX = canDragHorizontal ? clientX - containerLeft - startMouseOffset.x : offset.x;
232
+ let newY = canDragVertical ? clientY - containerTop - startMouseOffset.y : offset.y;
233
233
  if (canDragHorizontal) {
234
234
  newX = newX > 0 ? 0 : newX < extremeLeft ? extremeLeft : newX;
235
235
  }
@@ -77,7 +77,11 @@ export default class PreviewInnerFoundation<P = Record<string, any>, S = Record<
77
77
  let couldClose = !isTargetEmit(e.nativeEvent, NOT_CLOSE_TARGETS);
78
78
  const { clientX, clientY } = e;
79
79
  const { x, y } = this._adapter.getStartMouseDown();
80
- if (clientX !== x || y !== clientY) {
80
+ // 对鼠标移动做容错处理,当 x y 方向在 mouseUp 的时候移动距离都小于等于 5px 时候就可以关闭预览
81
+ // 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
82
+ // 不做容错处理的话,直接用 clientX !== x || y !== clientY 做判断,鼠标在用户点击时候无意识的轻微移动无法关闭预览,不符合用户预期
83
+ // 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.
84
+ if (Math.abs(clientX - x) > 5 || Math.abs(y - clientY) > 5) {
81
85
  couldClose = false;
82
86
  }
83
87
  if (couldClose && maskClosable) {
package/image/utils.ts CHANGED
@@ -1,7 +1,9 @@
1
1
  export const isTargetEmit = (event, targetClasses): boolean => {
2
- // e.path is the event-triggered bubbling path, which stores each node through which bubbling passes.
3
- // e.path.length-4 is to remove elements above the root node, such as body, html, document, window
4
- const isTarget = event?.path?.slice(0, event.path.length - 4).some((node): boolean => {
2
+ // event.path usage is discouraged, use event.composedPath() as it's standard and is more future-proof
3
+ // path is the event-triggered bubbling path, which stores each node through which bubbling passes.
4
+ // path.length-4 is to remove elements above the root node, such as body, html, document, window
5
+ const path = event?.composedPath();
6
+ const isTarget = path?.slice(0, path.length - 4).some((node): boolean => {
5
7
  if (node.className && typeof node.className === "string") {
6
8
  return targetClasses.some(c => node.className.includes(c));
7
9
  }
@@ -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,89 @@
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 _foundation = _interopRequireDefault(require("../base/foundation"));
11
+
12
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13
+
14
+ class ImageFoundation extends _foundation.default {
15
+ constructor(adapter) {
16
+ super(Object.assign({}, adapter));
17
+
18
+ this.handleClick = e => {
19
+ const {
20
+ imageID,
21
+ preview
22
+ } = this.getProps(); // if preview = false, then it cannot preview
23
+
24
+ if (!preview) {
25
+ return;
26
+ } // if image in group, then use group's Preview components
27
+
28
+
29
+ if (this._adapter.getIsInGroup()) {
30
+ const {
31
+ setCurrentIndex,
32
+ handleVisibleChange
33
+ } = this._adapter.getContexts();
34
+
35
+ setCurrentIndex(imageID);
36
+ handleVisibleChange(true);
37
+ } else {
38
+ // image isn't in group, then use it's own Preview components
39
+ this.handlePreviewVisibleChange(true);
40
+ }
41
+ };
42
+
43
+ this.handleLoaded = e => {
44
+ const {
45
+ onLoad
46
+ } = this.getProps();
47
+ onLoad && onLoad(e);
48
+ this.setState({
49
+ loadStatus: "success"
50
+ });
51
+ };
52
+
53
+ this.handleError = e => {
54
+ const {
55
+ onError
56
+ } = this.getProps();
57
+ onError && onError(e);
58
+ this.setState({
59
+ loadStatus: "error"
60
+ });
61
+ };
62
+
63
+ this.handlePreviewVisibleChange = newVisible => {
64
+ const {
65
+ preview
66
+ } = this.getProps();
67
+
68
+ if ((0, _isObject2.default)(preview)) {
69
+ const {
70
+ onVisibleChange
71
+ } = preview;
72
+ onVisibleChange && onVisibleChange(newVisible);
73
+
74
+ if (!("visible" in this.getProps())) {
75
+ this.setState({
76
+ previewVisible: newVisible
77
+ });
78
+ }
79
+ } else {
80
+ this.setState({
81
+ previewVisible: newVisible
82
+ });
83
+ }
84
+ };
85
+ }
86
+
87
+ }
88
+
89
+ exports.default = ImageFoundation;
@@ -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
+ }
@@ -0,0 +1,69 @@
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
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
11
+
12
+ class PreviewFooterFoundation extends _foundation.default {
13
+ constructor() {
14
+ super(...arguments);
15
+
16
+ this.changeSliderValue = type => {
17
+ const {
18
+ zoom,
19
+ step,
20
+ min,
21
+ max
22
+ } = this.getProps();
23
+ let newValue = type === "plus" ? zoom + step : zoom - step;
24
+
25
+ if (newValue > max) {
26
+ newValue = max;
27
+ } else if (newValue < min) {
28
+ newValue = min;
29
+ }
30
+
31
+ this.handleValueChange(newValue);
32
+ };
33
+
34
+ this.handleValueChange = value => {
35
+ const {
36
+ onZoomIn,
37
+ onZoomOut,
38
+ zoom
39
+ } = this.getProps();
40
+
41
+ if (value > zoom) {
42
+ onZoomIn(value / 100);
43
+ } else {
44
+ onZoomOut(value / 100);
45
+ }
46
+
47
+ this._adapter.setStartMouseOffset(value);
48
+ };
49
+
50
+ this.handleRatioClick = () => {
51
+ const {
52
+ ratio,
53
+ onAdjustRatio
54
+ } = this.getProps();
55
+ const type = ratio === "adaptation" ? "realSize" : "adaptation";
56
+ onAdjustRatio(type);
57
+ };
58
+
59
+ this.handleRotate = direction => {
60
+ const {
61
+ onRotate
62
+ } = this.getProps();
63
+ onRotate && onRotate(direction);
64
+ };
65
+ }
66
+
67
+ }
68
+
69
+ exports.default = PreviewFooterFoundation;
@@ -0,0 +1,5 @@
1
+ import BaseFoundation, { DefaultAdapter } from "../base/foundation";
2
+ export default class PreviewFoundation<P = Record<string, any>, S = Record<string, any>> extends BaseFoundation<Partial<DefaultAdapter>> {
3
+ handleVisibleChange: (newVisible: boolean) => void;
4
+ handleCurrentIndexChange: (index: number) => void;
5
+ }
@@ -0,0 +1,49 @@
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
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
11
+
12
+ class PreviewFoundation extends _foundation.default {
13
+ constructor() {
14
+ super(...arguments);
15
+
16
+ this.handleVisibleChange = newVisible => {
17
+ const {
18
+ visible,
19
+ onVisibleChange
20
+ } = this.getProps();
21
+
22
+ if (!(visible in this.getProps())) {
23
+ this.setState({
24
+ visible: newVisible
25
+ });
26
+ }
27
+
28
+ onVisibleChange && onVisibleChange(newVisible);
29
+ };
30
+
31
+ this.handleCurrentIndexChange = index => {
32
+ const {
33
+ currentIndex,
34
+ onChange
35
+ } = this.getProps();
36
+
37
+ if (!(currentIndex in this.getProps())) {
38
+ this.setState({
39
+ currentIndex: index
40
+ });
41
+ }
42
+
43
+ onChange && onChange(index);
44
+ };
45
+ }
46
+
47
+ }
48
+
49
+ exports.default = PreviewFoundation;
@@ -0,0 +1,58 @@
1
+ /// <reference types="lodash" />
2
+ import BaseFoundation, { DefaultAdapter } from "../base/foundation";
3
+ export interface PreviewImageAdapter<P = Record<string, any>, S = Record<string, any>> extends DefaultAdapter<P, S> {
4
+ getOriginImageSize: () => {
5
+ originImageWidth: number;
6
+ originImageHeight: number;
7
+ };
8
+ setOriginImageSize: (size: {
9
+ originImageWidth: number;
10
+ originImageHeight: number;
11
+ }) => void;
12
+ getContainerRef: () => any;
13
+ getImageRef: () => any;
14
+ getMouseMove: () => boolean;
15
+ setStartMouseMove: (move: boolean) => void;
16
+ getMouseOffset: () => {
17
+ x: number;
18
+ y: number;
19
+ };
20
+ setStartMouseOffset: (offset: {
21
+ x: number;
22
+ y: number;
23
+ }) => void;
24
+ setLoading: (loading: boolean) => void;
25
+ }
26
+ export interface DragDirection {
27
+ canDragVertical: boolean;
28
+ canDragHorizontal: boolean;
29
+ }
30
+ export interface ExtremeBounds {
31
+ left: number;
32
+ top: number;
33
+ }
34
+ export interface ImageOffset {
35
+ x: number;
36
+ y: number;
37
+ }
38
+ export default class PreviewImageFoundation<P = Record<string, any>, S = Record<string, any>> extends BaseFoundation<PreviewImageAdapter<P, S>, P, S> {
39
+ constructor(adapter: PreviewImageAdapter<P, S>);
40
+ _isImageVertical: () => boolean;
41
+ _getImageBounds: () => DOMRect;
42
+ _getContainerBounds: () => DOMRect;
43
+ _getOffset: (e: any) => ImageOffset;
44
+ setLoading: (loading: boolean) => void;
45
+ handleWindowResize: () => void;
46
+ handleLoad: (e: any) => void;
47
+ handleError: (e: any) => void;
48
+ handleResizeImage: () => void;
49
+ handleRightClickImage: (e: any) => boolean;
50
+ handleWheel: (e: React.WheelEvent<HTMLImageElement>) => void;
51
+ onWheel: import("lodash").DebouncedFunc<(e: React.WheelEvent<HTMLImageElement>) => void>;
52
+ calcCanDragDirection: () => DragDirection;
53
+ handleZoomChange: (newZoom: number, e: any) => void;
54
+ calcExtremeBounds: () => ExtremeBounds;
55
+ handleMoveImage: (e: any) => void;
56
+ handleImageMouseDown: (e: any) => void;
57
+ handleImageMouseUp: () => void;
58
+ }