@atlaskit/media-avatar-picker 24.10.2 → 24.10.5
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/CHANGELOG.md +21 -0
- package/dist/cjs/image-navigator/index.js +2 -2
- package/dist/cjs/image-placer/container.js +2 -2
- package/dist/cjs/image-placer/image.js +16 -19
- package/dist/cjs/image-placer/index.js +7 -10
- package/dist/cjs/util.js +5 -1
- package/dist/es2019/image-navigator/index.js +1 -1
- package/dist/es2019/image-placer/container.js +1 -1
- package/dist/es2019/image-placer/image.js +6 -4
- package/dist/es2019/image-placer/index.js +78 -76
- package/dist/es2019/util.js +2 -1
- package/dist/esm/image-navigator/index.js +2 -2
- package/dist/esm/image-placer/container.js +2 -2
- package/dist/esm/image-placer/image.js +16 -19
- package/dist/esm/image-placer/index.js +7 -10
- package/dist/esm/util.js +4 -1
- package/dist/types/image-navigator/index.d.ts +1 -1
- package/dist/types/image-placer/container.d.ts +1 -1
- package/dist/types/image-placer/image.d.ts +1 -1
- package/dist/types/image-placer/index.d.ts +1 -1
- package/dist/types/util.d.ts +1 -0
- package/dist/types-ts4.5/image-navigator/index.d.ts +1 -1
- package/dist/types-ts4.5/image-placer/container.d.ts +1 -1
- package/dist/types-ts4.5/image-placer/image.d.ts +1 -1
- package/dist/types-ts4.5/image-placer/index.d.ts +1 -1
- package/dist/types-ts4.5/util.d.ts +1 -0
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,26 @@
|
|
|
1
1
|
# @atlaskit/media-avatar-picker
|
|
2
2
|
|
|
3
|
+
## 24.10.5
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`8409cdfa1a7b4`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/8409cdfa1a7b4) -
|
|
8
|
+
React 18 strict mode fix
|
|
9
|
+
|
|
10
|
+
## 24.10.4
|
|
11
|
+
|
|
12
|
+
### Patch Changes
|
|
13
|
+
|
|
14
|
+
- [#160682](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/160682)
|
|
15
|
+
[`5237432b2a106`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/5237432b2a106) -
|
|
16
|
+
Fix React 18 strict mode issues
|
|
17
|
+
|
|
18
|
+
## 24.10.3
|
|
19
|
+
|
|
20
|
+
### Patch Changes
|
|
21
|
+
|
|
22
|
+
- Updated dependencies
|
|
23
|
+
|
|
3
24
|
## 24.10.2
|
|
4
25
|
|
|
5
26
|
### Patch Changes
|
|
@@ -224,8 +224,8 @@ var ImageNavigator = exports.ImageNavigator = /*#__PURE__*/function (_Component)
|
|
|
224
224
|
return _this;
|
|
225
225
|
}
|
|
226
226
|
(0, _createClass2.default)(ImageNavigator, [{
|
|
227
|
-
key: "
|
|
228
|
-
value: function
|
|
227
|
+
key: "componentDidMount",
|
|
228
|
+
value: function componentDidMount() {
|
|
229
229
|
if (!exenv.canUseDOM) {
|
|
230
230
|
return;
|
|
231
231
|
}
|
|
@@ -72,8 +72,8 @@ var ImagePlacerContainer = exports.ImagePlacerContainer = /*#__PURE__*/function
|
|
|
72
72
|
return _this;
|
|
73
73
|
}
|
|
74
74
|
(0, _createClass2.default)(ImagePlacerContainer, [{
|
|
75
|
-
key: "
|
|
76
|
-
value: function
|
|
75
|
+
key: "componentDidMount",
|
|
76
|
+
value: function componentDidMount() {
|
|
77
77
|
if (this.isTouch) {
|
|
78
78
|
document.addEventListener('touchmove', this.onTouchMove);
|
|
79
79
|
document.addEventListener('touchend', this.onMouseUp);
|
|
@@ -15,6 +15,7 @@ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/de
|
|
|
15
15
|
var _react = _interopRequireDefault(require("react"));
|
|
16
16
|
var _isImageRemote = require("../image-cropper/isImageRemote");
|
|
17
17
|
var _imageWrapper = require("./imageWrapper");
|
|
18
|
+
var _util = require("../util");
|
|
18
19
|
function _createSuper(t) { var r = _isNativeReflectConstruct(); return function () { var e, o = (0, _getPrototypeOf2.default)(t); if (r) { var s = (0, _getPrototypeOf2.default)(this).constructor; e = Reflect.construct(o, arguments, s); } else e = o.apply(this, arguments); return (0, _possibleConstructorReturn2.default)(this, e); }; }
|
|
19
20
|
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
|
20
21
|
// TODO: i18n https://product-fabric.atlassian.net/browse/MS-1261
|
|
@@ -25,13 +26,10 @@ var IMAGE_ERRORS = exports.IMAGE_ERRORS = {
|
|
|
25
26
|
var ImagePlacerImage = exports.ImagePlacerImage = /*#__PURE__*/function (_React$Component) {
|
|
26
27
|
(0, _inherits2.default)(ImagePlacerImage, _React$Component);
|
|
27
28
|
var _super = _createSuper(ImagePlacerImage);
|
|
28
|
-
function ImagePlacerImage() {
|
|
29
|
+
function ImagePlacerImage(props) {
|
|
29
30
|
var _this;
|
|
30
31
|
(0, _classCallCheck2.default)(this, ImagePlacerImage);
|
|
31
|
-
|
|
32
|
-
args[_key] = arguments[_key];
|
|
33
|
-
}
|
|
34
|
-
_this = _super.call.apply(_super, [this].concat(args));
|
|
32
|
+
_this = _super.call(this, props);
|
|
35
33
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "onLoad", function (e) {
|
|
36
34
|
var image = e.currentTarget;
|
|
37
35
|
var width = image.naturalWidth,
|
|
@@ -41,23 +39,22 @@ var ImagePlacerImage = exports.ImagePlacerImage = /*#__PURE__*/function (_React$
|
|
|
41
39
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "onError", function () {
|
|
42
40
|
_this.props.onError(IMAGE_ERRORS.LOAD_FAIL);
|
|
43
41
|
});
|
|
42
|
+
if ((0, _util.isSSR)()) {
|
|
43
|
+
return (0, _possibleConstructorReturn2.default)(_this);
|
|
44
|
+
}
|
|
45
|
+
var _this$props = _this.props,
|
|
46
|
+
src = _this$props.src,
|
|
47
|
+
onError = _this$props.onError;
|
|
48
|
+
if (src !== undefined) {
|
|
49
|
+
try {
|
|
50
|
+
(0, _isImageRemote.isImageRemote)(src);
|
|
51
|
+
} catch (e) {
|
|
52
|
+
onError(IMAGE_ERRORS.BAD_URL);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
44
55
|
return _this;
|
|
45
56
|
}
|
|
46
57
|
(0, _createClass2.default)(ImagePlacerImage, [{
|
|
47
|
-
key: "UNSAFE_componentWillMount",
|
|
48
|
-
value: function UNSAFE_componentWillMount() {
|
|
49
|
-
var _this$props = this.props,
|
|
50
|
-
src = _this$props.src,
|
|
51
|
-
onError = _this$props.onError;
|
|
52
|
-
if (src !== undefined) {
|
|
53
|
-
try {
|
|
54
|
-
(0, _isImageRemote.isImageRemote)(src);
|
|
55
|
-
} catch (e) {
|
|
56
|
-
onError(IMAGE_ERRORS.BAD_URL);
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
}, {
|
|
61
58
|
key: "render",
|
|
62
59
|
value: function render() {
|
|
63
60
|
var _this$props2 = this.props,
|
|
@@ -25,6 +25,7 @@ var _styles = require("./styles");
|
|
|
25
25
|
var _imageProcessor = require("./imageProcessor");
|
|
26
26
|
var _constraints = require("./constraints");
|
|
27
27
|
var _imagePlacerErrorWrapper = require("./imagePlacerErrorWrapper");
|
|
28
|
+
var _util = require("../util");
|
|
28
29
|
function _createSuper(t) { var r = _isNativeReflectConstruct(); return function () { var e, o = (0, _getPrototypeOf2.default)(t); if (r) { var s = (0, _getPrototypeOf2.default)(this).constructor; e = Reflect.construct(o, arguments, s); } else e = o.apply(this, arguments); return (0, _possibleConstructorReturn2.default)(this, e); }; }
|
|
29
30
|
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); } /**
|
|
30
31
|
* @jsxRuntime classic
|
|
@@ -77,13 +78,10 @@ var defaultProps = exports.defaultProps = {
|
|
|
77
78
|
var ImagePlacer = exports.ImagePlacer = /*#__PURE__*/function (_React$Component) {
|
|
78
79
|
(0, _inherits2.default)(ImagePlacer, _React$Component);
|
|
79
80
|
var _super = _createSuper(ImagePlacer);
|
|
80
|
-
function ImagePlacer() {
|
|
81
|
+
function ImagePlacer(_props) {
|
|
81
82
|
var _this;
|
|
82
83
|
(0, _classCallCheck2.default)(this, ImagePlacer);
|
|
83
|
-
|
|
84
|
-
args[_key] = arguments[_key];
|
|
85
|
-
}
|
|
86
|
-
_this = _super.call.apply(_super, [this].concat(args));
|
|
84
|
+
_this = _super.call(this, _props);
|
|
87
85
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "imageSourceRect", new _mediaUi.Rectangle(0, 0));
|
|
88
86
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "state", {
|
|
89
87
|
imageWidth: 0,
|
|
@@ -168,6 +166,10 @@ var ImagePlacer = exports.ImagePlacer = /*#__PURE__*/function (_React$Component)
|
|
|
168
166
|
_this.setZoom(clampedZoom);
|
|
169
167
|
_this.updateZoomProp(clampedZoom);
|
|
170
168
|
});
|
|
169
|
+
if ((0, _util.isSSR)()) {
|
|
170
|
+
return (0, _possibleConstructorReturn2.default)(_this);
|
|
171
|
+
}
|
|
172
|
+
_this.provideImageActions();
|
|
171
173
|
return _this;
|
|
172
174
|
}
|
|
173
175
|
(0, _createClass2.default)(ImagePlacer, [{
|
|
@@ -244,11 +246,6 @@ var ImagePlacer = exports.ImagePlacer = /*#__PURE__*/function (_React$Component)
|
|
|
244
246
|
cornerY = _this$transformVisibl2.y;
|
|
245
247
|
return new _mediaUi.Bounds(originX, originY, cornerX - originX, cornerY - originY);
|
|
246
248
|
}
|
|
247
|
-
}, {
|
|
248
|
-
key: "UNSAFE_componentWillMount",
|
|
249
|
-
value: function UNSAFE_componentWillMount() {
|
|
250
|
-
this.provideImageActions();
|
|
251
|
-
}
|
|
252
249
|
}, {
|
|
253
250
|
key: "provideImageActions",
|
|
254
251
|
value: function provideImageActions() {
|
package/dist/cjs/util.js
CHANGED
|
@@ -5,6 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.fileSizeMb = fileSizeMb;
|
|
7
7
|
exports.getCanvas = getCanvas;
|
|
8
|
+
exports.isSSR = void 0;
|
|
8
9
|
function fileSizeMb(file) {
|
|
9
10
|
return file.size / 1024 / 1024;
|
|
10
11
|
}
|
|
@@ -17,4 +18,7 @@ function getCanvas(width, height) {
|
|
|
17
18
|
canvas: canvas,
|
|
18
19
|
context: context
|
|
19
20
|
};
|
|
20
|
-
}
|
|
21
|
+
}
|
|
22
|
+
var isSSR = exports.isSSR = function isSSR() {
|
|
23
|
+
return typeof window === 'undefined' || typeof document === 'undefined';
|
|
24
|
+
};
|
|
@@ -51,7 +51,7 @@ export class ImagePlacerContainer extends React.Component {
|
|
|
51
51
|
this.props.onWheel(e.deltaY);
|
|
52
52
|
});
|
|
53
53
|
}
|
|
54
|
-
|
|
54
|
+
componentDidMount() {
|
|
55
55
|
if (this.isTouch) {
|
|
56
56
|
document.addEventListener('touchmove', this.onTouchMove);
|
|
57
57
|
document.addEventListener('touchend', this.onMouseUp);
|
|
@@ -2,14 +2,15 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import { isImageRemote } from '../image-cropper/isImageRemote';
|
|
4
4
|
import { ImageWrapper } from './imageWrapper';
|
|
5
|
+
import { isSSR } from '../util';
|
|
5
6
|
// TODO: i18n https://product-fabric.atlassian.net/browse/MS-1261
|
|
6
7
|
export const IMAGE_ERRORS = {
|
|
7
8
|
BAD_URL: 'Invalid image url',
|
|
8
9
|
LOAD_FAIL: 'Image failed to load'
|
|
9
10
|
};
|
|
10
11
|
export class ImagePlacerImage extends React.Component {
|
|
11
|
-
constructor(
|
|
12
|
-
super(
|
|
12
|
+
constructor(props) {
|
|
13
|
+
super(props);
|
|
13
14
|
_defineProperty(this, "onLoad", e => {
|
|
14
15
|
const image = e.currentTarget;
|
|
15
16
|
const {
|
|
@@ -21,8 +22,9 @@ export class ImagePlacerImage extends React.Component {
|
|
|
21
22
|
_defineProperty(this, "onError", () => {
|
|
22
23
|
this.props.onError(IMAGE_ERRORS.LOAD_FAIL);
|
|
23
24
|
});
|
|
24
|
-
|
|
25
|
-
|
|
25
|
+
if (isSSR()) {
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
26
28
|
const {
|
|
27
29
|
src,
|
|
28
30
|
onError
|
|
@@ -14,6 +14,7 @@ import { imagePlacerWrapperStyles } from './styles';
|
|
|
14
14
|
import { initialiseImagePreview, renderImageAtCurrentView } from './imageProcessor';
|
|
15
15
|
import { zoomToFit, applyConstraints, transformVisibleBoundsToImageCoords } from './constraints';
|
|
16
16
|
import { ImagePlacerErrorWrapper } from './imagePlacerErrorWrapper';
|
|
17
|
+
import { isSSR } from '../util';
|
|
17
18
|
|
|
18
19
|
/*
|
|
19
20
|
"container(Width|Height)" is the outputed size of the final image plus "margin"s.
|
|
@@ -60,8 +61,80 @@ export const defaultProps = {
|
|
|
60
61
|
backgroundColor: DEFAULT_BACKGROUND_COLOR
|
|
61
62
|
};
|
|
62
63
|
export class ImagePlacer extends React.Component {
|
|
63
|
-
|
|
64
|
-
|
|
64
|
+
/* the local rect of the container with margins */
|
|
65
|
+
get containerRectWithMargins() {
|
|
66
|
+
const {
|
|
67
|
+
containerWidth,
|
|
68
|
+
containerHeight,
|
|
69
|
+
margin
|
|
70
|
+
} = this.props;
|
|
71
|
+
return new Rectangle(containerWidth + margin * 2, containerHeight + margin * 2);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/* the local rect of the container without margins */
|
|
75
|
+
get containerRect() {
|
|
76
|
+
const {
|
|
77
|
+
containerWidth,
|
|
78
|
+
containerHeight
|
|
79
|
+
} = this.props;
|
|
80
|
+
return new Rectangle(containerWidth, containerHeight);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/* the bounds of the scaled/panned image, relative to container */
|
|
84
|
+
get imageBounds() {
|
|
85
|
+
const {
|
|
86
|
+
zoom
|
|
87
|
+
} = this.state;
|
|
88
|
+
return this.calcImageBounds(zoom);
|
|
89
|
+
}
|
|
90
|
+
calcImageBounds(zoom) {
|
|
91
|
+
const {
|
|
92
|
+
margin,
|
|
93
|
+
maxZoom
|
|
94
|
+
} = this.props;
|
|
95
|
+
const {
|
|
96
|
+
originX,
|
|
97
|
+
originY,
|
|
98
|
+
imageWidth,
|
|
99
|
+
imageHeight
|
|
100
|
+
} = this.state;
|
|
101
|
+
const x = margin + originX;
|
|
102
|
+
const y = margin + originY;
|
|
103
|
+
const maxWidthDiff = imageWidth * maxZoom - imageWidth;
|
|
104
|
+
const maxHeightDiff = imageHeight * maxZoom - imageHeight;
|
|
105
|
+
const width = imageWidth + maxWidthDiff * zoom;
|
|
106
|
+
const height = imageHeight + maxHeightDiff * zoom;
|
|
107
|
+
return new Bounds(x, y, width, height);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/* the bounds of the visible area (container - margins), relative to container */
|
|
111
|
+
get visibleBounds() {
|
|
112
|
+
const {
|
|
113
|
+
containerWidth,
|
|
114
|
+
containerHeight,
|
|
115
|
+
margin
|
|
116
|
+
} = this.props;
|
|
117
|
+
return new Bounds(margin, margin, containerWidth, containerHeight);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
/* a coordinate mapping from visibleBounds to local rect of image */
|
|
121
|
+
get sourceBounds() {
|
|
122
|
+
const {
|
|
123
|
+
containerWidth,
|
|
124
|
+
containerHeight
|
|
125
|
+
} = this.props;
|
|
126
|
+
const {
|
|
127
|
+
x: originX,
|
|
128
|
+
y: originY
|
|
129
|
+
} = this.transformVisibleBoundsToImageCoords(0, 0);
|
|
130
|
+
const {
|
|
131
|
+
x: cornerX,
|
|
132
|
+
y: cornerY
|
|
133
|
+
} = this.transformVisibleBoundsToImageCoords(containerWidth, containerHeight);
|
|
134
|
+
return new Bounds(originX, originY, cornerX - originX, cornerY - originY);
|
|
135
|
+
}
|
|
136
|
+
constructor(_props) {
|
|
137
|
+
super(_props);
|
|
65
138
|
_defineProperty(this, "imageSourceRect", new Rectangle(0, 0));
|
|
66
139
|
_defineProperty(this, "state", {
|
|
67
140
|
imageWidth: 0,
|
|
@@ -156,80 +229,9 @@ export class ImagePlacer extends React.Component {
|
|
|
156
229
|
this.setZoom(clampedZoom);
|
|
157
230
|
this.updateZoomProp(clampedZoom);
|
|
158
231
|
});
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
const {
|
|
163
|
-
containerWidth,
|
|
164
|
-
containerHeight,
|
|
165
|
-
margin
|
|
166
|
-
} = this.props;
|
|
167
|
-
return new Rectangle(containerWidth + margin * 2, containerHeight + margin * 2);
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
/* the local rect of the container without margins */
|
|
171
|
-
get containerRect() {
|
|
172
|
-
const {
|
|
173
|
-
containerWidth,
|
|
174
|
-
containerHeight
|
|
175
|
-
} = this.props;
|
|
176
|
-
return new Rectangle(containerWidth, containerHeight);
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
/* the bounds of the scaled/panned image, relative to container */
|
|
180
|
-
get imageBounds() {
|
|
181
|
-
const {
|
|
182
|
-
zoom
|
|
183
|
-
} = this.state;
|
|
184
|
-
return this.calcImageBounds(zoom);
|
|
185
|
-
}
|
|
186
|
-
calcImageBounds(zoom) {
|
|
187
|
-
const {
|
|
188
|
-
margin,
|
|
189
|
-
maxZoom
|
|
190
|
-
} = this.props;
|
|
191
|
-
const {
|
|
192
|
-
originX,
|
|
193
|
-
originY,
|
|
194
|
-
imageWidth,
|
|
195
|
-
imageHeight
|
|
196
|
-
} = this.state;
|
|
197
|
-
const x = margin + originX;
|
|
198
|
-
const y = margin + originY;
|
|
199
|
-
const maxWidthDiff = imageWidth * maxZoom - imageWidth;
|
|
200
|
-
const maxHeightDiff = imageHeight * maxZoom - imageHeight;
|
|
201
|
-
const width = imageWidth + maxWidthDiff * zoom;
|
|
202
|
-
const height = imageHeight + maxHeightDiff * zoom;
|
|
203
|
-
return new Bounds(x, y, width, height);
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
/* the bounds of the visible area (container - margins), relative to container */
|
|
207
|
-
get visibleBounds() {
|
|
208
|
-
const {
|
|
209
|
-
containerWidth,
|
|
210
|
-
containerHeight,
|
|
211
|
-
margin
|
|
212
|
-
} = this.props;
|
|
213
|
-
return new Bounds(margin, margin, containerWidth, containerHeight);
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
/* a coordinate mapping from visibleBounds to local rect of image */
|
|
217
|
-
get sourceBounds() {
|
|
218
|
-
const {
|
|
219
|
-
containerWidth,
|
|
220
|
-
containerHeight
|
|
221
|
-
} = this.props;
|
|
222
|
-
const {
|
|
223
|
-
x: originX,
|
|
224
|
-
y: originY
|
|
225
|
-
} = this.transformVisibleBoundsToImageCoords(0, 0);
|
|
226
|
-
const {
|
|
227
|
-
x: cornerX,
|
|
228
|
-
y: cornerY
|
|
229
|
-
} = this.transformVisibleBoundsToImageCoords(containerWidth, containerHeight);
|
|
230
|
-
return new Bounds(originX, originY, cornerX - originX, cornerY - originY);
|
|
231
|
-
}
|
|
232
|
-
UNSAFE_componentWillMount() {
|
|
232
|
+
if (isSSR()) {
|
|
233
|
+
return;
|
|
234
|
+
}
|
|
233
235
|
this.provideImageActions();
|
|
234
236
|
}
|
|
235
237
|
provideImageActions() {
|
package/dist/es2019/util.js
CHANGED
|
@@ -217,8 +217,8 @@ export var ImageNavigator = /*#__PURE__*/function (_Component) {
|
|
|
217
217
|
return _this;
|
|
218
218
|
}
|
|
219
219
|
_createClass(ImageNavigator, [{
|
|
220
|
-
key: "
|
|
221
|
-
value: function
|
|
220
|
+
key: "componentDidMount",
|
|
221
|
+
value: function componentDidMount() {
|
|
222
222
|
if (!exenv.canUseDOM) {
|
|
223
223
|
return;
|
|
224
224
|
}
|
|
@@ -66,8 +66,8 @@ export var ImagePlacerContainer = /*#__PURE__*/function (_React$Component) {
|
|
|
66
66
|
return _this;
|
|
67
67
|
}
|
|
68
68
|
_createClass(ImagePlacerContainer, [{
|
|
69
|
-
key: "
|
|
70
|
-
value: function
|
|
69
|
+
key: "componentDidMount",
|
|
70
|
+
value: function componentDidMount() {
|
|
71
71
|
if (this.isTouch) {
|
|
72
72
|
document.addEventListener('touchmove', this.onTouchMove);
|
|
73
73
|
document.addEventListener('touchend', this.onMouseUp);
|
|
@@ -10,6 +10,7 @@ function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.
|
|
|
10
10
|
import React from 'react';
|
|
11
11
|
import { isImageRemote } from '../image-cropper/isImageRemote';
|
|
12
12
|
import { ImageWrapper } from './imageWrapper';
|
|
13
|
+
import { isSSR } from '../util';
|
|
13
14
|
// TODO: i18n https://product-fabric.atlassian.net/browse/MS-1261
|
|
14
15
|
export var IMAGE_ERRORS = {
|
|
15
16
|
BAD_URL: 'Invalid image url',
|
|
@@ -18,13 +19,10 @@ export var IMAGE_ERRORS = {
|
|
|
18
19
|
export var ImagePlacerImage = /*#__PURE__*/function (_React$Component) {
|
|
19
20
|
_inherits(ImagePlacerImage, _React$Component);
|
|
20
21
|
var _super = _createSuper(ImagePlacerImage);
|
|
21
|
-
function ImagePlacerImage() {
|
|
22
|
+
function ImagePlacerImage(props) {
|
|
22
23
|
var _this;
|
|
23
24
|
_classCallCheck(this, ImagePlacerImage);
|
|
24
|
-
|
|
25
|
-
args[_key] = arguments[_key];
|
|
26
|
-
}
|
|
27
|
-
_this = _super.call.apply(_super, [this].concat(args));
|
|
25
|
+
_this = _super.call(this, props);
|
|
28
26
|
_defineProperty(_assertThisInitialized(_this), "onLoad", function (e) {
|
|
29
27
|
var image = e.currentTarget;
|
|
30
28
|
var width = image.naturalWidth,
|
|
@@ -34,23 +32,22 @@ export var ImagePlacerImage = /*#__PURE__*/function (_React$Component) {
|
|
|
34
32
|
_defineProperty(_assertThisInitialized(_this), "onError", function () {
|
|
35
33
|
_this.props.onError(IMAGE_ERRORS.LOAD_FAIL);
|
|
36
34
|
});
|
|
35
|
+
if (isSSR()) {
|
|
36
|
+
return _possibleConstructorReturn(_this);
|
|
37
|
+
}
|
|
38
|
+
var _this$props = _this.props,
|
|
39
|
+
src = _this$props.src,
|
|
40
|
+
onError = _this$props.onError;
|
|
41
|
+
if (src !== undefined) {
|
|
42
|
+
try {
|
|
43
|
+
isImageRemote(src);
|
|
44
|
+
} catch (e) {
|
|
45
|
+
onError(IMAGE_ERRORS.BAD_URL);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
37
48
|
return _this;
|
|
38
49
|
}
|
|
39
50
|
_createClass(ImagePlacerImage, [{
|
|
40
|
-
key: "UNSAFE_componentWillMount",
|
|
41
|
-
value: function UNSAFE_componentWillMount() {
|
|
42
|
-
var _this$props = this.props,
|
|
43
|
-
src = _this$props.src,
|
|
44
|
-
onError = _this$props.onError;
|
|
45
|
-
if (src !== undefined) {
|
|
46
|
-
try {
|
|
47
|
-
isImageRemote(src);
|
|
48
|
-
} catch (e) {
|
|
49
|
-
onError(IMAGE_ERRORS.BAD_URL);
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
}, {
|
|
54
51
|
key: "render",
|
|
55
52
|
value: function render() {
|
|
56
53
|
var _this$props2 = this.props,
|
|
@@ -25,6 +25,7 @@ import { imagePlacerWrapperStyles } from './styles';
|
|
|
25
25
|
import { initialiseImagePreview, renderImageAtCurrentView } from './imageProcessor';
|
|
26
26
|
import { zoomToFit as _zoomToFit, applyConstraints as _applyConstraints, transformVisibleBoundsToImageCoords as _transformVisibleBoundsToImageCoords } from './constraints';
|
|
27
27
|
import { ImagePlacerErrorWrapper } from './imagePlacerErrorWrapper';
|
|
28
|
+
import { isSSR } from '../util';
|
|
28
29
|
|
|
29
30
|
/*
|
|
30
31
|
"container(Width|Height)" is the outputed size of the final image plus "margin"s.
|
|
@@ -73,13 +74,10 @@ export var defaultProps = {
|
|
|
73
74
|
export var ImagePlacer = /*#__PURE__*/function (_React$Component) {
|
|
74
75
|
_inherits(ImagePlacer, _React$Component);
|
|
75
76
|
var _super = _createSuper(ImagePlacer);
|
|
76
|
-
function ImagePlacer() {
|
|
77
|
+
function ImagePlacer(_props) {
|
|
77
78
|
var _this;
|
|
78
79
|
_classCallCheck(this, ImagePlacer);
|
|
79
|
-
|
|
80
|
-
args[_key] = arguments[_key];
|
|
81
|
-
}
|
|
82
|
-
_this = _super.call.apply(_super, [this].concat(args));
|
|
80
|
+
_this = _super.call(this, _props);
|
|
83
81
|
_defineProperty(_assertThisInitialized(_this), "imageSourceRect", new Rectangle(0, 0));
|
|
84
82
|
_defineProperty(_assertThisInitialized(_this), "state", {
|
|
85
83
|
imageWidth: 0,
|
|
@@ -164,6 +162,10 @@ export var ImagePlacer = /*#__PURE__*/function (_React$Component) {
|
|
|
164
162
|
_this.setZoom(clampedZoom);
|
|
165
163
|
_this.updateZoomProp(clampedZoom);
|
|
166
164
|
});
|
|
165
|
+
if (isSSR()) {
|
|
166
|
+
return _possibleConstructorReturn(_this);
|
|
167
|
+
}
|
|
168
|
+
_this.provideImageActions();
|
|
167
169
|
return _this;
|
|
168
170
|
}
|
|
169
171
|
_createClass(ImagePlacer, [{
|
|
@@ -240,11 +242,6 @@ export var ImagePlacer = /*#__PURE__*/function (_React$Component) {
|
|
|
240
242
|
cornerY = _this$transformVisibl2.y;
|
|
241
243
|
return new Bounds(originX, originY, cornerX - originX, cornerY - originY);
|
|
242
244
|
}
|
|
243
|
-
}, {
|
|
244
|
-
key: "UNSAFE_componentWillMount",
|
|
245
|
-
value: function UNSAFE_componentWillMount() {
|
|
246
|
-
this.provideImageActions();
|
|
247
|
-
}
|
|
248
245
|
}, {
|
|
249
246
|
key: "provideImageActions",
|
|
250
247
|
value: function provideImageActions() {
|
package/dist/esm/util.js
CHANGED
|
@@ -44,7 +44,7 @@ export interface State {
|
|
|
44
44
|
export declare class ImageNavigator extends Component<Props & WrappedComponentProps, State> {
|
|
45
45
|
state: State;
|
|
46
46
|
imageElement?: HTMLImageElement;
|
|
47
|
-
|
|
47
|
+
componentDidMount(): void;
|
|
48
48
|
componentWillUnmount(): void;
|
|
49
49
|
onDragStarted: (x: number, y: number) => void;
|
|
50
50
|
onMouseMove: (e: MouseEvent) => void;
|
|
@@ -15,7 +15,7 @@ export interface ImagePlacerContainerProps {
|
|
|
15
15
|
}
|
|
16
16
|
export declare class ImagePlacerContainer extends React.Component<ImagePlacerContainerProps, {}> {
|
|
17
17
|
private dragClientStart?;
|
|
18
|
-
|
|
18
|
+
componentDidMount(): void;
|
|
19
19
|
componentWillUnmount(): void;
|
|
20
20
|
get isDragging(): boolean;
|
|
21
21
|
get isTouch(): boolean;
|
|
@@ -13,7 +13,7 @@ export declare const IMAGE_ERRORS: {
|
|
|
13
13
|
LOAD_FAIL: string;
|
|
14
14
|
};
|
|
15
15
|
export declare class ImagePlacerImage extends React.Component<ImagePlacerImageProps, {}> {
|
|
16
|
-
|
|
16
|
+
constructor(props: ImagePlacerImageProps);
|
|
17
17
|
onLoad: (e: React.SyntheticEvent<HTMLImageElement>) => void;
|
|
18
18
|
onError: () => void;
|
|
19
19
|
render(): JSX.Element | null;
|
|
@@ -84,7 +84,7 @@ export declare class ImagePlacer extends React.Component<ImagePlacerProps, Image
|
|
|
84
84
|
private calcImageBounds;
|
|
85
85
|
get visibleBounds(): Bounds;
|
|
86
86
|
get sourceBounds(): Bounds;
|
|
87
|
-
|
|
87
|
+
constructor(props: ImagePlacerProps);
|
|
88
88
|
private provideImageActions;
|
|
89
89
|
UNSAFE_componentWillReceiveProps(nextProps: ImagePlacerProps): Promise<void>;
|
|
90
90
|
preprocessFile(fileInfo: FileInfo): Promise<void>;
|
package/dist/types/util.d.ts
CHANGED
|
@@ -44,7 +44,7 @@ export interface State {
|
|
|
44
44
|
export declare class ImageNavigator extends Component<Props & WrappedComponentProps, State> {
|
|
45
45
|
state: State;
|
|
46
46
|
imageElement?: HTMLImageElement;
|
|
47
|
-
|
|
47
|
+
componentDidMount(): void;
|
|
48
48
|
componentWillUnmount(): void;
|
|
49
49
|
onDragStarted: (x: number, y: number) => void;
|
|
50
50
|
onMouseMove: (e: MouseEvent) => void;
|
|
@@ -15,7 +15,7 @@ export interface ImagePlacerContainerProps {
|
|
|
15
15
|
}
|
|
16
16
|
export declare class ImagePlacerContainer extends React.Component<ImagePlacerContainerProps, {}> {
|
|
17
17
|
private dragClientStart?;
|
|
18
|
-
|
|
18
|
+
componentDidMount(): void;
|
|
19
19
|
componentWillUnmount(): void;
|
|
20
20
|
get isDragging(): boolean;
|
|
21
21
|
get isTouch(): boolean;
|
|
@@ -13,7 +13,7 @@ export declare const IMAGE_ERRORS: {
|
|
|
13
13
|
LOAD_FAIL: string;
|
|
14
14
|
};
|
|
15
15
|
export declare class ImagePlacerImage extends React.Component<ImagePlacerImageProps, {}> {
|
|
16
|
-
|
|
16
|
+
constructor(props: ImagePlacerImageProps);
|
|
17
17
|
onLoad: (e: React.SyntheticEvent<HTMLImageElement>) => void;
|
|
18
18
|
onError: () => void;
|
|
19
19
|
render(): JSX.Element | null;
|
|
@@ -84,7 +84,7 @@ export declare class ImagePlacer extends React.Component<ImagePlacerProps, Image
|
|
|
84
84
|
private calcImageBounds;
|
|
85
85
|
get visibleBounds(): Bounds;
|
|
86
86
|
get sourceBounds(): Bounds;
|
|
87
|
-
|
|
87
|
+
constructor(props: ImagePlacerProps);
|
|
88
88
|
private provideImageActions;
|
|
89
89
|
UNSAFE_componentWillReceiveProps(nextProps: ImagePlacerProps): Promise<void>;
|
|
90
90
|
preprocessFile(fileInfo: FileInfo): Promise<void>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/media-avatar-picker",
|
|
3
|
-
"version": "24.10.
|
|
3
|
+
"version": "24.10.5",
|
|
4
4
|
"description": "A component to select, drag and resize image avatars. It also provides a default list of predefined avatars.",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -39,12 +39,12 @@
|
|
|
39
39
|
"@atlaskit/icon": "^22.24.0",
|
|
40
40
|
"@atlaskit/media-ui": "^26.0.0",
|
|
41
41
|
"@atlaskit/modal-dialog": "^12.17.0",
|
|
42
|
-
"@atlaskit/primitives": "^
|
|
42
|
+
"@atlaskit/primitives": "^13.0.0",
|
|
43
43
|
"@atlaskit/range": "^7.4.0",
|
|
44
44
|
"@atlaskit/spinner": "^16.3.0",
|
|
45
45
|
"@atlaskit/textfield": "^6.5.0",
|
|
46
46
|
"@atlaskit/theme": "^14.0.0",
|
|
47
|
-
"@atlaskit/tokens": "^2.
|
|
47
|
+
"@atlaskit/tokens": "^2.2.0",
|
|
48
48
|
"@atlaskit/visually-hidden": "^1.5.0",
|
|
49
49
|
"@babel/runtime": "^7.0.0",
|
|
50
50
|
"exenv": "^1.2.2",
|