@douyinfe/semi-ui 2.50.0-alpha.0 → 2.50.0-beta.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/dist/css/semi.css +76 -160
- package/dist/css/semi.min.css +1 -1
- package/dist/umd/semi-ui.js +582 -418
- 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/anchor/index.d.ts +1 -1
- package/lib/cjs/autoComplete/index.d.ts +1 -1
- package/lib/cjs/button/Button.d.ts +1 -1
- package/lib/cjs/button/index.d.ts +1 -1
- package/lib/cjs/carousel/index.d.ts +1 -1
- package/lib/cjs/datePicker/datePicker.d.ts +1 -1
- package/lib/cjs/datePicker/yearAndMonth.js +1 -5
- package/lib/cjs/dropdown/index.d.ts +1 -1
- package/lib/cjs/form/baseForm.d.ts +2 -2
- package/lib/cjs/form/field.d.ts +2 -2
- package/lib/cjs/image/interface.d.ts +3 -3
- package/lib/cjs/image/previewFooter.js +5 -8
- package/lib/cjs/image/previewHeader.d.ts +2 -2
- package/lib/cjs/image/previewHeader.js +9 -8
- package/lib/cjs/image/previewImage.d.ts +1 -12
- package/lib/cjs/image/previewImage.js +23 -83
- package/lib/cjs/image/previewInner.d.ts +11 -2
- package/lib/cjs/image/previewInner.js +60 -42
- package/lib/cjs/index.d.ts +2 -0
- package/lib/cjs/index.js +14 -0
- package/lib/cjs/modal/confirm.d.ts +17 -17
- package/lib/cjs/notification/index.d.ts +8 -8
- package/lib/cjs/notification/index.js +6 -5
- package/lib/cjs/notification/notice.d.ts +1 -1
- package/lib/cjs/notification/notice.js +1 -1
- package/lib/cjs/popover/index.d.ts +1 -1
- package/lib/cjs/select/index.d.ts +2 -2
- package/lib/cjs/table/Table.d.ts +1 -1
- package/lib/cjs/timePicker/TimePicker.d.ts +3 -3
- package/lib/cjs/timePicker/TimeShape.d.ts +1 -1
- package/lib/cjs/timePicker/index.d.ts +2 -2
- package/lib/cjs/tooltip/index.d.ts +1 -1
- package/lib/cjs/tree/indent.d.ts +9 -0
- package/lib/cjs/tree/indent.js +37 -0
- package/lib/cjs/tree/index.d.ts +2 -0
- package/lib/cjs/tree/index.js +8 -3
- package/lib/cjs/tree/interface.d.ts +2 -0
- package/lib/cjs/tree/treeNode.d.ts +3 -0
- package/lib/cjs/tree/treeNode.js +34 -6
- package/lib/cjs/treeSelect/index.d.ts +4 -3
- package/lib/cjs/treeSelect/index.js +124 -31
- package/lib/cjs/typography/base.d.ts +1 -1
- package/lib/cjs/typography/numeral.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 +1 -1
- package/lib/es/anchor/index.d.ts +1 -1
- package/lib/es/autoComplete/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/index.d.ts +1 -1
- package/lib/es/datePicker/datePicker.d.ts +1 -1
- package/lib/es/datePicker/yearAndMonth.js +1 -5
- package/lib/es/dropdown/index.d.ts +1 -1
- package/lib/es/form/baseForm.d.ts +2 -2
- package/lib/es/form/field.d.ts +2 -2
- package/lib/es/image/interface.d.ts +3 -3
- package/lib/es/image/previewFooter.js +5 -8
- package/lib/es/image/previewHeader.d.ts +2 -2
- package/lib/es/image/previewHeader.js +4 -3
- package/lib/es/image/previewImage.d.ts +1 -12
- package/lib/es/image/previewImage.js +23 -83
- package/lib/es/image/previewInner.d.ts +11 -2
- package/lib/es/image/previewInner.js +60 -42
- package/lib/es/index.d.ts +2 -0
- package/lib/es/index.js +2 -0
- package/lib/es/modal/confirm.d.ts +17 -17
- package/lib/es/notification/index.d.ts +8 -8
- package/lib/es/notification/index.js +6 -5
- package/lib/es/notification/notice.d.ts +1 -1
- package/lib/es/notification/notice.js +1 -1
- package/lib/es/popover/index.d.ts +1 -1
- package/lib/es/select/index.d.ts +2 -2
- package/lib/es/table/Table.d.ts +1 -1
- package/lib/es/timePicker/TimePicker.d.ts +3 -3
- package/lib/es/timePicker/TimeShape.d.ts +1 -1
- package/lib/es/timePicker/index.d.ts +2 -2
- package/lib/es/tooltip/index.d.ts +1 -1
- package/lib/es/tree/indent.d.ts +9 -0
- package/lib/es/tree/indent.js +27 -0
- package/lib/es/tree/index.d.ts +2 -0
- package/lib/es/tree/index.js +8 -3
- package/lib/es/tree/interface.d.ts +2 -0
- package/lib/es/tree/treeNode.d.ts +3 -0
- package/lib/es/tree/treeNode.js +34 -6
- package/lib/es/treeSelect/index.d.ts +4 -3
- package/lib/es/treeSelect/index.js +125 -32
- package/lib/es/typography/base.d.ts +1 -1
- package/lib/es/typography/numeral.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 +1 -1
- package/package.json +8 -8
|
@@ -49,7 +49,7 @@ declare class Anchor extends BaseComponent<AnchorProps, AnchorState> {
|
|
|
49
49
|
offsetTop: PropTypes.Requireable<number>;
|
|
50
50
|
targetOffset: PropTypes.Requireable<number>;
|
|
51
51
|
showTooltip: PropTypes.Requireable<boolean>;
|
|
52
|
-
position: PropTypes.Requireable<"left" | "right" | "top" | "topLeft" | "topRight" | "leftTop" | "leftBottom" | "rightTop" | "rightBottom" | "
|
|
52
|
+
position: PropTypes.Requireable<"left" | "right" | "top" | "bottom" | "topLeft" | "topRight" | "leftTop" | "leftBottom" | "rightTop" | "rightBottom" | "bottomLeft" | "bottomRight" | "leftTopOver" | "rightTopOver">;
|
|
53
53
|
maxWidth: PropTypes.Requireable<NonNullable<string | number>>;
|
|
54
54
|
maxHeight: PropTypes.Requireable<NonNullable<string | number>>;
|
|
55
55
|
getContainer: PropTypes.Requireable<(...args: any[]) => any>;
|
|
@@ -116,7 +116,7 @@ declare class AutoComplete<T extends AutoCompleteItems> extends BaseComponent<Au
|
|
|
116
116
|
onFocus: PropTypes.Requireable<(...args: any[]) => any>;
|
|
117
117
|
onChange: PropTypes.Requireable<(...args: any[]) => any>;
|
|
118
118
|
onKeyDown: PropTypes.Requireable<(...args: any[]) => any>;
|
|
119
|
-
position: PropTypes.Requireable<"left" | "right" | "top" | "topLeft" | "topRight" | "leftTop" | "leftBottom" | "rightTop" | "rightBottom" | "
|
|
119
|
+
position: PropTypes.Requireable<"left" | "right" | "top" | "bottom" | "topLeft" | "topRight" | "leftTop" | "leftBottom" | "rightTop" | "rightBottom" | "bottomLeft" | "bottomRight" | "leftTopOver" | "rightTopOver" | "leftBottomOver" | "rightBottomOver">;
|
|
120
120
|
placeholder: PropTypes.Requireable<string>;
|
|
121
121
|
prefix: PropTypes.Requireable<PropTypes.ReactNodeLike>;
|
|
122
122
|
onChangeWithObject: PropTypes.Requireable<boolean>;
|
|
@@ -48,7 +48,7 @@ export default class Button extends PureComponent<ButtonProps> {
|
|
|
48
48
|
prefixCls: PropTypes.Requireable<string>;
|
|
49
49
|
style: PropTypes.Requireable<object>;
|
|
50
50
|
size: PropTypes.Requireable<"default" | "small" | "large">;
|
|
51
|
-
type: PropTypes.Requireable<"warning" | "primary" | "
|
|
51
|
+
type: PropTypes.Requireable<"warning" | "primary" | "tertiary" | "secondary" | "danger">;
|
|
52
52
|
block: PropTypes.Requireable<boolean>;
|
|
53
53
|
onClick: PropTypes.Requireable<(...args: any[]) => any>;
|
|
54
54
|
onMouseDown: PropTypes.Requireable<(...args: any[]) => any>;
|
|
@@ -23,7 +23,7 @@ declare class Button extends React.PureComponent<ButtonProps> {
|
|
|
23
23
|
onMouseLeave: import("prop-types").Requireable<(...args: any[]) => any>;
|
|
24
24
|
disabled: import("prop-types").Requireable<boolean>;
|
|
25
25
|
size: import("prop-types").Requireable<"default" | "small" | "large">;
|
|
26
|
-
type: import("prop-types").Requireable<"warning" | "primary" | "
|
|
26
|
+
type: import("prop-types").Requireable<"warning" | "primary" | "tertiary" | "secondary" | "danger">;
|
|
27
27
|
block: import("prop-types").Requireable<boolean>;
|
|
28
28
|
onClick: import("prop-types").Requireable<(...args: any[]) => any>;
|
|
29
29
|
onMouseDown: import("prop-types").Requireable<(...args: any[]) => any>;
|
|
@@ -24,7 +24,7 @@ declare class Carousel extends BaseComponent<CarouselProps, CarouselState> {
|
|
|
24
24
|
indicatorType: PropTypes.Requireable<"line" | "dot" | "columnar">;
|
|
25
25
|
theme: PropTypes.Requireable<"dark" | "light" | "primary">;
|
|
26
26
|
onChange: PropTypes.Requireable<(...args: any[]) => any>;
|
|
27
|
-
arrowType: PropTypes.Requireable<"
|
|
27
|
+
arrowType: PropTypes.Requireable<"always" | "hover">;
|
|
28
28
|
showArrow: PropTypes.Requireable<boolean>;
|
|
29
29
|
showIndicator: PropTypes.Requireable<boolean>;
|
|
30
30
|
slideDirection: PropTypes.Requireable<"left" | "right">;
|
|
@@ -91,7 +91,7 @@ export default class DatePicker extends BaseComponent<DatePickerProps, DatePicke
|
|
|
91
91
|
insetLabel: PropTypes.Requireable<PropTypes.ReactNodeLike>;
|
|
92
92
|
insetLabelId: PropTypes.Requireable<string>;
|
|
93
93
|
zIndex: PropTypes.Requireable<number>;
|
|
94
|
-
position: PropTypes.Requireable<"left" | "right" | "top" | "topLeft" | "topRight" | "leftTop" | "leftBottom" | "rightTop" | "rightBottom" | "
|
|
94
|
+
position: PropTypes.Requireable<"left" | "right" | "top" | "bottom" | "topLeft" | "topRight" | "leftTop" | "leftBottom" | "rightTop" | "rightBottom" | "bottomLeft" | "bottomRight" | "leftTopOver" | "rightTopOver">;
|
|
95
95
|
getPopupContainer: PropTypes.Requireable<(...args: any[]) => any>;
|
|
96
96
|
onCancel: PropTypes.Requireable<(...args: any[]) => any>;
|
|
97
97
|
onConfirm: PropTypes.Requireable<(...args: any[]) => any>;
|
|
@@ -131,11 +131,7 @@ class YearAndMonth extends _baseComponent.default {
|
|
|
131
131
|
const right = _constants2.strings.PANEL_TYPE_RIGHT;
|
|
132
132
|
const needDisabled = year => {
|
|
133
133
|
if (panelType === right && currentYear[left]) {
|
|
134
|
-
|
|
135
|
-
return currentYear[left] > year;
|
|
136
|
-
} else {
|
|
137
|
-
return currentYear[left] >= year;
|
|
138
|
-
}
|
|
134
|
+
return currentYear[left] > year;
|
|
139
135
|
}
|
|
140
136
|
return false;
|
|
141
137
|
};
|
|
@@ -66,7 +66,7 @@ declare class Dropdown extends BaseComponent<DropdownProps, DropdownState> {
|
|
|
66
66
|
motion: PropTypes.Requireable<NonNullable<boolean | object>>;
|
|
67
67
|
onVisibleChange: PropTypes.Requireable<(...args: any[]) => any>;
|
|
68
68
|
prefixCls: PropTypes.Requireable<string>;
|
|
69
|
-
position: PropTypes.Requireable<"left" | "right" | "top" | "topLeft" | "topRight" | "leftTop" | "leftBottom" | "rightTop" | "rightBottom" | "
|
|
69
|
+
position: PropTypes.Requireable<"left" | "right" | "top" | "bottom" | "topLeft" | "topRight" | "leftTop" | "leftBottom" | "rightTop" | "rightBottom" | "bottomLeft" | "bottomRight" | "leftTopOver" | "rightTopOver" | "leftBottomOver" | "rightBottomOver">;
|
|
70
70
|
rePosKey: PropTypes.Requireable<NonNullable<string | number>>;
|
|
71
71
|
render: PropTypes.Requireable<PropTypes.ReactNodeLike>;
|
|
72
72
|
spacing: PropTypes.Requireable<NonNullable<number | object>>;
|
|
@@ -85,7 +85,7 @@ declare class Form<Values extends Record<string, any> = any> extends BaseCompone
|
|
|
85
85
|
expandRestTagsOnClick?: boolean;
|
|
86
86
|
onDropdownVisibleChange?: (visible: boolean) => void;
|
|
87
87
|
zIndex?: number;
|
|
88
|
-
position?: "left" | "right" | "top" | "topLeft" | "topRight" | "leftTop" | "leftBottom" | "rightTop" | "rightBottom" | "
|
|
88
|
+
position?: "left" | "right" | "top" | "bottom" | "topLeft" | "topRight" | "leftTop" | "leftBottom" | "rightTop" | "rightBottom" | "bottomLeft" | "bottomRight" | "leftTopOver" | "rightTopOver" | "leftBottomOver" | "rightBottomOver";
|
|
89
89
|
onSearch?: (value: string, event: React.KeyboardEvent<Element> | React.MouseEvent<Element, MouseEvent>) => void;
|
|
90
90
|
dropdownClassName?: string;
|
|
91
91
|
dropdownStyle?: React.CSSProperties;
|
|
@@ -130,7 +130,7 @@ declare class Form<Values extends Record<string, any> = any> extends BaseCompone
|
|
|
130
130
|
onDeselect?: (value: string | number | any[] | Record<string, any>, option: Record<string, any>) => void;
|
|
131
131
|
onSelect?: (value: string | number | any[] | Record<string, any>, option: Record<string, any>) => void;
|
|
132
132
|
allowCreate?: boolean;
|
|
133
|
-
triggerRender?: (props
|
|
133
|
+
triggerRender?: (props: import("../select").TriggerRenderProps) => React.ReactNode;
|
|
134
134
|
onClear?: () => void;
|
|
135
135
|
virtualize?: import("../select").virtualListProps;
|
|
136
136
|
onFocus?: (e: React.FocusEvent<Element, Element>) => void;
|
package/lib/cjs/form/field.d.ts
CHANGED
|
@@ -31,7 +31,7 @@ declare const FormSelect: import("react").ComponentType<import("utility-types").
|
|
|
31
31
|
expandRestTagsOnClick?: boolean;
|
|
32
32
|
onDropdownVisibleChange?: (visible: boolean) => void;
|
|
33
33
|
zIndex?: number;
|
|
34
|
-
position?: "left" | "right" | "top" | "topLeft" | "topRight" | "leftTop" | "leftBottom" | "rightTop" | "rightBottom" | "
|
|
34
|
+
position?: "left" | "right" | "top" | "bottom" | "topLeft" | "topRight" | "leftTop" | "leftBottom" | "rightTop" | "rightBottom" | "bottomLeft" | "bottomRight" | "leftTopOver" | "rightTopOver" | "leftBottomOver" | "rightBottomOver";
|
|
35
35
|
onSearch?: (value: string, event: import("react").KeyboardEvent<Element> | import("react").MouseEvent<Element, MouseEvent>) => void;
|
|
36
36
|
dropdownClassName?: string;
|
|
37
37
|
dropdownStyle?: import("react").CSSProperties;
|
|
@@ -76,7 +76,7 @@ declare const FormSelect: import("react").ComponentType<import("utility-types").
|
|
|
76
76
|
onDeselect?: (value: string | number | any[] | Record<string, any>, option: Record<string, any>) => void;
|
|
77
77
|
onSelect?: (value: string | number | any[] | Record<string, any>, option: Record<string, any>) => void;
|
|
78
78
|
allowCreate?: boolean;
|
|
79
|
-
triggerRender?: (props
|
|
79
|
+
triggerRender?: (props: import("../select/index").TriggerRenderProps) => import("react").ReactNode;
|
|
80
80
|
onClear?: () => void;
|
|
81
81
|
virtualize?: import("../select/index").virtualListProps;
|
|
82
82
|
onFocus?: (e: import("react").FocusEvent<Element, Element>) => void;
|
|
@@ -53,6 +53,8 @@ export interface PreviewProps extends BaseProps {
|
|
|
53
53
|
zIndex?: number;
|
|
54
54
|
children?: ReactNode;
|
|
55
55
|
crossOrigin?: "anonymous" | "use-credentials";
|
|
56
|
+
maxZoom?: number;
|
|
57
|
+
minZoom?: number;
|
|
56
58
|
renderHeader?: (info: any) => ReactNode;
|
|
57
59
|
renderPreviewMenu?: (props: MenuProps) => ReactNode;
|
|
58
60
|
getPopupContainer?: () => HTMLElement;
|
|
@@ -138,14 +140,12 @@ export interface FooterProps extends SliderProps {
|
|
|
138
140
|
onRotate?: (direction: string) => void;
|
|
139
141
|
onDownload?: () => void;
|
|
140
142
|
renderPreviewMenu?: (props: MenuProps) => ReactNode;
|
|
143
|
+
forwardRef?: React.RefObject<HTMLElement>;
|
|
141
144
|
}
|
|
142
145
|
export interface PreviewImageProps {
|
|
143
146
|
src?: string;
|
|
144
147
|
rotation?: number;
|
|
145
148
|
style?: React.CSSProperties;
|
|
146
|
-
maxZoom?: number;
|
|
147
|
-
minZoom?: number;
|
|
148
|
-
zoomStep?: number;
|
|
149
149
|
zoom?: number;
|
|
150
150
|
ratio?: RatioType;
|
|
151
151
|
disableDownload?: boolean;
|
|
@@ -19,14 +19,9 @@ var _localeConsumer = _interopRequireDefault(require("../locale/localeConsumer")
|
|
|
19
19
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
20
20
|
const prefixCls = _constants.cssClasses.PREFIX;
|
|
21
21
|
const footerPrefixCls = `${_constants.cssClasses.PREFIX}-preview-footer`;
|
|
22
|
-
let mouseActiveTime = 0;
|
|
23
22
|
class Footer extends _baseComponent.default {
|
|
24
23
|
get adapter() {
|
|
25
|
-
return Object.assign(
|
|
26
|
-
setStartMouseOffset: time => {
|
|
27
|
-
mouseActiveTime = time;
|
|
28
|
-
}
|
|
29
|
-
});
|
|
24
|
+
return Object.assign({}, super.adapter);
|
|
30
25
|
}
|
|
31
26
|
constructor(props) {
|
|
32
27
|
super(props);
|
|
@@ -266,13 +261,15 @@ class Footer extends _baseComponent.default {
|
|
|
266
261
|
render() {
|
|
267
262
|
const {
|
|
268
263
|
className,
|
|
269
|
-
renderPreviewMenu
|
|
264
|
+
renderPreviewMenu,
|
|
265
|
+
forwardRef
|
|
270
266
|
} = this.props;
|
|
271
267
|
const menuCls = (0, _classnames.default)(footerPrefixCls, `${footerPrefixCls}-wrapper`, className, {
|
|
272
268
|
[`${footerPrefixCls}-content`]: !Boolean(renderPreviewMenu)
|
|
273
269
|
});
|
|
274
270
|
return /*#__PURE__*/_react.default.createElement("section", {
|
|
275
|
-
className: menuCls
|
|
271
|
+
className: menuCls,
|
|
272
|
+
ref: forwardRef
|
|
276
273
|
}, renderPreviewMenu ? this.customRenderViewMenu() : this.getFooterMenu());
|
|
277
274
|
}
|
|
278
275
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import React from "react";
|
|
2
2
|
import { HeaderProps } from "./interface";
|
|
3
|
-
declare const Header: React.
|
|
3
|
+
declare const Header: React.ForwardRefExoticComponent<HeaderProps & React.RefAttributes<HTMLElement>>;
|
|
4
4
|
export default Header;
|
|
@@ -4,7 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
var
|
|
7
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
8
8
|
var _semiIcons = require("@douyinfe/semi-icons");
|
|
9
9
|
var _constants = require("@douyinfe/semi-foundation/lib/cjs/image/constants");
|
|
10
10
|
var _classnames = _interopRequireDefault(require("classnames"));
|
|
@@ -13,14 +13,14 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
13
13
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
14
14
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
15
15
|
const prefixCls = `${_constants.cssClasses.PREFIX}-preview-header`;
|
|
16
|
-
const Header = _ref => {
|
|
16
|
+
const Header = /*#__PURE__*/(0, _react.forwardRef)((_ref, ref) => {
|
|
17
17
|
let {
|
|
18
18
|
onClose,
|
|
19
19
|
titleStyle,
|
|
20
20
|
className,
|
|
21
21
|
renderHeader
|
|
22
22
|
} = _ref;
|
|
23
|
-
return /*#__PURE__*/
|
|
23
|
+
return /*#__PURE__*/_react.default.createElement(_previewContext.PreviewContext.Consumer, null, _ref2 => {
|
|
24
24
|
let {
|
|
25
25
|
currentIndex,
|
|
26
26
|
titles
|
|
@@ -29,16 +29,17 @@ const Header = _ref => {
|
|
|
29
29
|
if (titles && typeof currentIndex === "number") {
|
|
30
30
|
title = titles[currentIndex];
|
|
31
31
|
}
|
|
32
|
-
return /*#__PURE__*/
|
|
32
|
+
return /*#__PURE__*/_react.default.createElement("section", {
|
|
33
|
+
ref: ref,
|
|
33
34
|
className: (0, _classnames.default)(prefixCls, className)
|
|
34
|
-
}, /*#__PURE__*/
|
|
35
|
+
}, /*#__PURE__*/_react.default.createElement("section", {
|
|
35
36
|
className: `${prefixCls}-title`,
|
|
36
37
|
style: titleStyle
|
|
37
|
-
}, renderHeader ? renderHeader(title) : title), /*#__PURE__*/
|
|
38
|
+
}, renderHeader ? renderHeader(title) : title), /*#__PURE__*/_react.default.createElement("section", {
|
|
38
39
|
className: `${prefixCls}-close`,
|
|
39
40
|
onMouseUp: onClose
|
|
40
|
-
}, /*#__PURE__*/
|
|
41
|
+
}, /*#__PURE__*/_react.default.createElement(_semiIcons.IconClose, null)));
|
|
41
42
|
});
|
|
42
|
-
};
|
|
43
|
+
});
|
|
43
44
|
var _default = Header;
|
|
44
45
|
exports.default = _default;
|
|
@@ -8,9 +8,6 @@ export default class PreviewImage extends BaseComponent<PreviewImageProps, Previ
|
|
|
8
8
|
src: PropTypes.Requireable<string>;
|
|
9
9
|
rotation: PropTypes.Requireable<number>;
|
|
10
10
|
style: PropTypes.Requireable<object>;
|
|
11
|
-
maxZoom: PropTypes.Requireable<number>;
|
|
12
|
-
minZoom: PropTypes.Requireable<number>;
|
|
13
|
-
zoomStep: PropTypes.Requireable<number>;
|
|
14
11
|
zoom: PropTypes.Requireable<number>;
|
|
15
12
|
ratio: PropTypes.Requireable<string>;
|
|
16
13
|
disableDownload: PropTypes.Requireable<boolean>;
|
|
@@ -21,29 +18,21 @@ export default class PreviewImage extends BaseComponent<PreviewImageProps, Previ
|
|
|
21
18
|
onError: PropTypes.Requireable<(...args: any[]) => any>;
|
|
22
19
|
};
|
|
23
20
|
static defaultProps: {
|
|
24
|
-
maxZoom: number;
|
|
25
|
-
minZoom: number;
|
|
26
|
-
zoomStep: number;
|
|
27
21
|
zoom: any;
|
|
28
22
|
};
|
|
29
23
|
get adapter(): PreviewImageAdapter<PreviewImageProps, PreviewImageStates>;
|
|
30
24
|
containerRef: React.RefObject<HTMLDivElement>;
|
|
31
|
-
imageRef: HTMLImageElement
|
|
25
|
+
imageRef: React.RefObject<HTMLImageElement>;
|
|
32
26
|
foundation: PreviewImageFoundation;
|
|
33
27
|
constructor(props: any);
|
|
34
28
|
componentDidMount(): void;
|
|
35
29
|
componentWillUnmount(): void;
|
|
36
30
|
componentDidUpdate(prevProps: PreviewImageProps, prevStates: PreviewImageStates): void;
|
|
37
31
|
onWindowResize: () => void;
|
|
38
|
-
handleZoomChange: (newZoom: any, e: any) => void;
|
|
39
32
|
handleRightClickImage: (e: any) => void;
|
|
40
|
-
handleWheel: (e: any) => void;
|
|
41
33
|
handleLoad: (e: any) => void;
|
|
42
34
|
handleError: (e: any) => void;
|
|
43
|
-
resizeImage: () => void;
|
|
44
35
|
handleMoveImage: (e: any) => void;
|
|
45
|
-
registryImageRef: (ref: any) => void;
|
|
46
36
|
onImageMouseDown: (e: React.MouseEvent<HTMLImageElement>) => void;
|
|
47
|
-
onImageMouseUp: () => void;
|
|
48
37
|
render(): JSX.Element;
|
|
49
38
|
}
|
|
@@ -13,38 +13,14 @@ var _previewImageFoundation = _interopRequireDefault(require("@douyinfe/semi-fou
|
|
|
13
13
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
14
14
|
const prefixCls = _constants.cssClasses.PREFIX;
|
|
15
15
|
const preViewImgPrefixCls = `${prefixCls}-preview-image`;
|
|
16
|
-
let originImageWidth = null;
|
|
17
|
-
let originImageHeight = null;
|
|
18
|
-
let startMouseMove = false;
|
|
19
|
-
// startMouseOffset:The offset of the mouse relative to the left and top of the picture
|
|
20
|
-
let startMouseOffset = {
|
|
21
|
-
x: 0,
|
|
22
|
-
y: 0
|
|
23
|
-
};
|
|
24
16
|
class PreviewImage extends _baseComponent.default {
|
|
25
17
|
get adapter() {
|
|
26
18
|
return Object.assign(Object.assign({}, super.adapter), {
|
|
27
|
-
getOriginImageSize: () => ({
|
|
28
|
-
originImageWidth,
|
|
29
|
-
originImageHeight
|
|
30
|
-
}),
|
|
31
|
-
setOriginImageSize: size => {
|
|
32
|
-
originImageWidth = size.originImageWidth;
|
|
33
|
-
originImageHeight = size.originImageHeight;
|
|
34
|
-
},
|
|
35
19
|
getContainer: () => {
|
|
36
20
|
return this.containerRef.current;
|
|
37
21
|
},
|
|
38
22
|
getImage: () => {
|
|
39
|
-
return this.imageRef;
|
|
40
|
-
},
|
|
41
|
-
getMouseMove: () => startMouseMove,
|
|
42
|
-
setStartMouseMove: move => {
|
|
43
|
-
startMouseMove = move;
|
|
44
|
-
},
|
|
45
|
-
getMouseOffset: () => startMouseOffset,
|
|
46
|
-
setStartMouseOffset: offset => {
|
|
47
|
-
startMouseOffset = offset;
|
|
23
|
+
return this.imageRef.current;
|
|
48
24
|
},
|
|
49
25
|
setLoading: loading => {
|
|
50
26
|
this.setState({
|
|
@@ -52,7 +28,7 @@ class PreviewImage extends _baseComponent.default {
|
|
|
52
28
|
});
|
|
53
29
|
},
|
|
54
30
|
setImageCursor: canDrag => {
|
|
55
|
-
this.imageRef.style.cursor = canDrag ? "grab" : "default";
|
|
31
|
+
this.imageRef.current.style.cursor = canDrag ? "grab" : "default";
|
|
56
32
|
}
|
|
57
33
|
});
|
|
58
34
|
}
|
|
@@ -61,52 +37,22 @@ class PreviewImage extends _baseComponent.default {
|
|
|
61
37
|
this.onWindowResize = () => {
|
|
62
38
|
this.foundation.handleWindowResize();
|
|
63
39
|
};
|
|
64
|
-
this.handleZoomChange = (newZoom, e) => {
|
|
65
|
-
this.foundation.handleZoomChange(newZoom, e);
|
|
66
|
-
};
|
|
67
40
|
// Determine the response method of right click according to the disableDownload parameter in props
|
|
68
41
|
this.handleRightClickImage = e => {
|
|
69
42
|
this.foundation.handleRightClickImage(e);
|
|
70
43
|
};
|
|
71
|
-
this.handleWheel = e => {
|
|
72
|
-
this.foundation.handleWheel(e);
|
|
73
|
-
};
|
|
74
44
|
this.handleLoad = e => {
|
|
75
45
|
this.foundation.handleLoad(e);
|
|
76
46
|
};
|
|
77
47
|
this.handleError = e => {
|
|
78
48
|
this.foundation.handleError(e);
|
|
79
49
|
};
|
|
80
|
-
this.resizeImage = () => {
|
|
81
|
-
this.foundation.handleResizeImage();
|
|
82
|
-
};
|
|
83
50
|
this.handleMoveImage = e => {
|
|
84
51
|
this.foundation.handleMoveImage(e);
|
|
85
52
|
};
|
|
86
|
-
// 为什么通过ref注册wheel而不是使用onWheel事件?
|
|
87
|
-
// 因为对于wheel事件,浏览器将 addEventListener 的 passive 默认值更改为 true。如此,事件监听器便不能取消事件,也不会在用户滚动页面时阻止页面呈现。
|
|
88
|
-
// 这里我们需要保持页面不动,仅放大图片,因此此处需要将 passive 更改设置为 false。
|
|
89
|
-
// Why register wheel via ref instead of using onWheel event?
|
|
90
|
-
// Because for wheel events, the browser changes the passive default of addEventListener to true. This way, the event listener cannot cancel the event, nor prevent the page from rendering when the user scrolls.
|
|
91
|
-
// Here we need to keep the page still and only zoom in on the image, so here we need to set the passive change to false.
|
|
92
|
-
// https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/addEventListener#improving_scrolling_performance_with_passive_listeners。
|
|
93
|
-
this.registryImageRef = ref => {
|
|
94
|
-
if (this.imageRef) {
|
|
95
|
-
this.imageRef.removeEventListener("wheel", this.handleWheel);
|
|
96
|
-
}
|
|
97
|
-
if (ref) {
|
|
98
|
-
ref.addEventListener("wheel", this.handleWheel, {
|
|
99
|
-
passive: false
|
|
100
|
-
});
|
|
101
|
-
}
|
|
102
|
-
this.imageRef = ref;
|
|
103
|
-
};
|
|
104
53
|
this.onImageMouseDown = e => {
|
|
105
54
|
this.foundation.handleImageMouseDown(e);
|
|
106
55
|
};
|
|
107
|
-
this.onImageMouseUp = () => {
|
|
108
|
-
this.foundation.handleImageMouseUp();
|
|
109
|
-
};
|
|
110
56
|
this.state = {
|
|
111
57
|
width: 0,
|
|
112
58
|
height: 0,
|
|
@@ -120,7 +66,7 @@ class PreviewImage extends _baseComponent.default {
|
|
|
120
66
|
left: 0
|
|
121
67
|
};
|
|
122
68
|
this.containerRef = /*#__PURE__*/_react.default.createRef();
|
|
123
|
-
this.imageRef =
|
|
69
|
+
this.imageRef = /*#__PURE__*/_react.default.createRef();
|
|
124
70
|
this.foundation = new _previewImageFoundation.default(this.adapter);
|
|
125
71
|
}
|
|
126
72
|
componentDidMount() {
|
|
@@ -131,27 +77,22 @@ class PreviewImage extends _baseComponent.default {
|
|
|
131
77
|
}
|
|
132
78
|
componentDidUpdate(prevProps, prevStates) {
|
|
133
79
|
// If src changes, start a new loading
|
|
134
|
-
|
|
80
|
+
const zoomChange = "zoom" in this.props && this.props.zoom !== this.state.currZoom;
|
|
81
|
+
const srcChange = this.props.src && this.props.src !== prevProps.src;
|
|
82
|
+
if (srcChange) {
|
|
135
83
|
this.foundation.setLoading(true);
|
|
136
84
|
}
|
|
137
85
|
// If the incoming zoom changes, other content changes are determined based on the new zoom value
|
|
138
|
-
if (
|
|
139
|
-
this.
|
|
86
|
+
if (zoomChange) {
|
|
87
|
+
this.foundation.calculatePreviewImage(this.props.zoom, null);
|
|
140
88
|
}
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
} else {
|
|
148
|
-
this.props.onZoom(1);
|
|
149
|
-
}
|
|
89
|
+
if (!zoomChange && !srcChange && prevProps) {
|
|
90
|
+
if ("ratio" in this.props && this.props.ratio !== prevProps.ratio) {
|
|
91
|
+
this.foundation.handleRatioChange();
|
|
92
|
+
}
|
|
93
|
+
if ("rotation" in this.props && this.props.rotation !== prevProps.rotation) {
|
|
94
|
+
this.onWindowResize();
|
|
150
95
|
}
|
|
151
|
-
}
|
|
152
|
-
// When the incoming rotation angle of the image changes, it needs to be resized to make the image fit on the page
|
|
153
|
-
if ("rotation" in this.props && this.props.rotation !== prevProps.rotation) {
|
|
154
|
-
this.onWindowResize();
|
|
155
96
|
}
|
|
156
97
|
}
|
|
157
98
|
render() {
|
|
@@ -173,21 +114,20 @@ class PreviewImage extends _baseComponent.default {
|
|
|
173
114
|
transform: `rotate(${-rotation}deg)`,
|
|
174
115
|
top,
|
|
175
116
|
left,
|
|
176
|
-
width
|
|
177
|
-
height
|
|
117
|
+
width,
|
|
118
|
+
height
|
|
178
119
|
};
|
|
179
120
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
180
121
|
className: `${preViewImgPrefixCls}`,
|
|
181
122
|
ref: this.containerRef
|
|
182
123
|
}, /*#__PURE__*/_react.default.createElement("img", {
|
|
183
|
-
ref: this.
|
|
124
|
+
ref: this.imageRef,
|
|
184
125
|
src: src,
|
|
185
126
|
alt: "previewImag",
|
|
186
127
|
className: `${preViewImgPrefixCls}-img`,
|
|
187
128
|
key: src,
|
|
188
129
|
onMouseMove: this.handleMoveImage,
|
|
189
130
|
onMouseDown: this.onImageMouseDown,
|
|
190
|
-
onMouseUp: this.onImageMouseUp,
|
|
191
131
|
onContextMenu: this.handleRightClickImage,
|
|
192
132
|
onDragStart: e => e.preventDefault(),
|
|
193
133
|
onLoad: this.handleLoad,
|
|
@@ -205,9 +145,9 @@ PreviewImage.propTypes = {
|
|
|
205
145
|
src: _propTypes.default.string,
|
|
206
146
|
rotation: _propTypes.default.number,
|
|
207
147
|
style: _propTypes.default.object,
|
|
208
|
-
maxZoom:
|
|
209
|
-
minZoom:
|
|
210
|
-
zoomStep:
|
|
148
|
+
// maxZoom: PropTypes.number,
|
|
149
|
+
// minZoom: PropTypes.number,
|
|
150
|
+
// zoomStep: PropTypes.number,
|
|
211
151
|
zoom: _propTypes.default.number,
|
|
212
152
|
ratio: _propTypes.default.string,
|
|
213
153
|
disableDownload: _propTypes.default.bool,
|
|
@@ -218,8 +158,8 @@ PreviewImage.propTypes = {
|
|
|
218
158
|
onError: _propTypes.default.func
|
|
219
159
|
};
|
|
220
160
|
PreviewImage.defaultProps = {
|
|
221
|
-
maxZoom: 5,
|
|
222
|
-
minZoom: 0.1,
|
|
223
|
-
zoomStep: 0.1,
|
|
161
|
+
// maxZoom: 5,
|
|
162
|
+
// minZoom: 0.1,
|
|
163
|
+
// zoomStep: 0.1,
|
|
224
164
|
zoom: undefined
|
|
225
165
|
};
|
|
@@ -33,6 +33,8 @@ export default class PreviewInner extends BaseComponent<PreviewInnerProps, Previ
|
|
|
33
33
|
disableDownload: PropTypes.Requireable<boolean>;
|
|
34
34
|
viewerVisibleDelay: PropTypes.Requireable<number>;
|
|
35
35
|
zIndex: PropTypes.Requireable<number>;
|
|
36
|
+
maxZoom: PropTypes.Requireable<number>;
|
|
37
|
+
minZoom: PropTypes.Requireable<number>;
|
|
36
38
|
renderHeader: PropTypes.Requireable<(...args: any[]) => any>;
|
|
37
39
|
renderPreviewMenu: PropTypes.Requireable<(...args: any[]) => any>;
|
|
38
40
|
getPopupContainer: PropTypes.Requireable<(...args: any[]) => any>;
|
|
@@ -58,14 +60,20 @@ export default class PreviewInner extends BaseComponent<PreviewInnerProps, Previ
|
|
|
58
60
|
zIndex: number;
|
|
59
61
|
maskClosable: boolean;
|
|
60
62
|
viewerVisibleDelay: number;
|
|
63
|
+
maxZoom: number;
|
|
64
|
+
minZoom: number;
|
|
61
65
|
};
|
|
62
66
|
private bodyOverflow;
|
|
63
67
|
private scrollBarWidth;
|
|
64
68
|
private originBodyWidth;
|
|
65
69
|
get adapter(): PreviewInnerAdapter<PreviewInnerProps, PreviewInnerStates>;
|
|
66
|
-
timer: any;
|
|
67
70
|
context: PreviewContextProps;
|
|
68
71
|
foundation: PreviewInnerFoundation;
|
|
72
|
+
imageWrapRef: React.RefObject<HTMLDivElement>;
|
|
73
|
+
headerRef: React.RefObject<HTMLElement>;
|
|
74
|
+
footerRef: React.RefObject<HTMLElement>;
|
|
75
|
+
leftIconRef: React.RefObject<HTMLDivElement>;
|
|
76
|
+
rightIconRef: React.RefObject<HTMLDivElement>;
|
|
69
77
|
constructor(props: PreviewInnerProps);
|
|
70
78
|
static getDerivedStateFromProps(props: PreviewInnerProps, state: PreviewInnerStates): Partial<PreviewInnerStates>;
|
|
71
79
|
componentDidMount(): void;
|
|
@@ -81,10 +89,11 @@ export default class PreviewInner extends BaseComponent<PreviewInnerProps, Previ
|
|
|
81
89
|
handleZoomImage: (newZoom: number) => void;
|
|
82
90
|
handleMouseUp: (e: any) => void;
|
|
83
91
|
handleMouseMove: (e: any) => void;
|
|
84
|
-
handleMouseEvent: (e: any, event: string) => void;
|
|
85
92
|
handleKeyDown: (e: KeyboardEvent) => void;
|
|
86
93
|
onImageError: () => void;
|
|
87
94
|
onImageLoad: (src: any) => void;
|
|
88
95
|
handleMouseDown: (e: any) => void;
|
|
96
|
+
handleWheel: (e: any) => void;
|
|
97
|
+
registryImageWrapRef: (ref: any) => void;
|
|
89
98
|
render(): JSX.Element;
|
|
90
99
|
}
|