@atlaskit/media-avatar-picker 27.0.0 → 27.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +8 -0
- package/dist/cjs/image-placer/index.js +110 -20
- package/dist/es2019/image-placer/index.js +69 -0
- package/dist/esm/image-placer/index.js +110 -20
- package/dist/types/image-placer/index.d.ts +1 -0
- package/dist/types-ts4.5/image-placer/index.d.ts +1 -0
- package/package.json +8 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# @atlaskit/media-avatar-picker
|
|
2
2
|
|
|
3
|
+
## 27.0.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`e3d1ec1074c7e`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/e3d1ec1074c7e) -
|
|
8
|
+
Removing UNSAFE_componentWillReceiveProps from media-picker, media-avatar-picker and media-viewer
|
|
9
|
+
package to support React19 migration
|
|
10
|
+
|
|
3
11
|
## 27.0.0
|
|
4
12
|
|
|
5
13
|
### Major Changes
|
|
@@ -24,6 +24,7 @@ var _image = require("./image");
|
|
|
24
24
|
var _margin = require("./margin");
|
|
25
25
|
var _imageProcessor = require("./imageProcessor");
|
|
26
26
|
var _constraints = require("./constraints");
|
|
27
|
+
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
27
28
|
var _imagePlacerErrorWrapper = require("./imagePlacerErrorWrapper");
|
|
28
29
|
var _util = require("../util");
|
|
29
30
|
function _callSuper(t, o, e) { return o = (0, _getPrototypeOf2.default)(o), (0, _possibleConstructorReturn2.default)(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], (0, _getPrototypeOf2.default)(t).constructor) : o.apply(t, e)); }
|
|
@@ -266,6 +267,12 @@ var ImagePlacer = exports.ImagePlacer = /*#__PURE__*/function (_React$Component)
|
|
|
266
267
|
return _regenerator.default.wrap(function _callee$(_context) {
|
|
267
268
|
while (1) switch (_context.prev = _context.next) {
|
|
268
269
|
case 0:
|
|
270
|
+
if (!(0, _platformFeatureFlags.fg)('platform_media_package_react19_lifecycle_fix')) {
|
|
271
|
+
_context.next = 2;
|
|
272
|
+
break;
|
|
273
|
+
}
|
|
274
|
+
return _context.abrupt("return");
|
|
275
|
+
case 2:
|
|
269
276
|
imageSourceRect = this.imageSourceRect, state = this.state, props = this.props;
|
|
270
277
|
zoom = state.zoom;
|
|
271
278
|
currentUseConstraints = props.useConstraints, currentContainerWidth = props.containerWidth, currentContainerHeight = props.containerHeight, currentMargin = props.margin, currentSrc = props.src;
|
|
@@ -294,34 +301,34 @@ var ImagePlacer = exports.ImagePlacer = /*#__PURE__*/function (_React$Component)
|
|
|
294
301
|
this.updateZoomProp();
|
|
295
302
|
}
|
|
296
303
|
if (!(nextSrc instanceof File && nextSrc !== currentSrc)) {
|
|
297
|
-
_context.next =
|
|
304
|
+
_context.next = 20;
|
|
298
305
|
break;
|
|
299
306
|
}
|
|
300
|
-
_context.next =
|
|
307
|
+
_context.next = 19;
|
|
301
308
|
return (0, _mediaUi.getFileInfo)(nextSrc);
|
|
302
|
-
case
|
|
309
|
+
case 19:
|
|
303
310
|
fileInfo = _context.sent;
|
|
304
|
-
case
|
|
311
|
+
case 20:
|
|
305
312
|
if (!(typeof nextSrc === 'string' && nextSrc !== currentSrc)) {
|
|
306
|
-
_context.next =
|
|
313
|
+
_context.next = 24;
|
|
307
314
|
break;
|
|
308
315
|
}
|
|
309
|
-
_context.next =
|
|
316
|
+
_context.next = 23;
|
|
310
317
|
return (0, _mediaUi.getFileInfoFromSrc)(nextSrc);
|
|
311
|
-
case
|
|
318
|
+
case 23:
|
|
312
319
|
fileInfo = _context.sent;
|
|
313
|
-
case
|
|
320
|
+
case 24:
|
|
314
321
|
if (!fileInfo) {
|
|
315
|
-
_context.next =
|
|
322
|
+
_context.next = 27;
|
|
316
323
|
break;
|
|
317
324
|
}
|
|
318
|
-
_context.next =
|
|
325
|
+
_context.next = 27;
|
|
319
326
|
return this.preprocessFile(fileInfo);
|
|
320
|
-
case
|
|
327
|
+
case 27:
|
|
321
328
|
if (isImageAction) {
|
|
322
329
|
this.provideImageActions();
|
|
323
330
|
}
|
|
324
|
-
case
|
|
331
|
+
case 28:
|
|
325
332
|
case "end":
|
|
326
333
|
return _context.stop();
|
|
327
334
|
}
|
|
@@ -333,18 +340,101 @@ var ImagePlacer = exports.ImagePlacer = /*#__PURE__*/function (_React$Component)
|
|
|
333
340
|
return UNSAFE_componentWillReceiveProps;
|
|
334
341
|
}())
|
|
335
342
|
}, {
|
|
336
|
-
key: "
|
|
343
|
+
key: "componentDidUpdate",
|
|
337
344
|
value: function () {
|
|
338
|
-
var
|
|
339
|
-
var
|
|
345
|
+
var _componentDidUpdate = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2(prevProps) {
|
|
346
|
+
var imageSourceRect, props, nextZoom, nextUseConstraints, nextContainerWidth, nextContainerHeight, nextMargin, nextSrc, nextOnImageActions, prevZoom, prevUseConstraints, prevContainerWidth, prevContainerHeight, prevMargin, prevSrc, prevOnImageActions, isZoomChange, isUseConstraintsChange, isContainerWidthChange, isContainerHeightChange, isMarginChange, isImageActionChange, zoomReset, fileInfo;
|
|
340
347
|
return _regenerator.default.wrap(function _callee2$(_context2) {
|
|
341
348
|
while (1) switch (_context2.prev = _context2.next) {
|
|
349
|
+
case 0:
|
|
350
|
+
if ((0, _platformFeatureFlags.fg)('platform_media_package_react19_lifecycle_fix')) {
|
|
351
|
+
_context2.next = 2;
|
|
352
|
+
break;
|
|
353
|
+
}
|
|
354
|
+
return _context2.abrupt("return");
|
|
355
|
+
case 2:
|
|
356
|
+
imageSourceRect = this.imageSourceRect, props = this.props;
|
|
357
|
+
nextZoom = props.zoom, nextUseConstraints = props.useConstraints, nextContainerWidth = props.containerWidth, nextContainerHeight = props.containerHeight, nextMargin = props.margin, nextSrc = props.src, nextOnImageActions = props.onImageActions;
|
|
358
|
+
prevZoom = prevProps.zoom, prevUseConstraints = prevProps.useConstraints, prevContainerWidth = prevProps.containerWidth, prevContainerHeight = prevProps.containerHeight, prevMargin = prevProps.margin, prevSrc = prevProps.src, prevOnImageActions = prevProps.onImageActions;
|
|
359
|
+
isZoomChange = nextZoom !== prevZoom;
|
|
360
|
+
isUseConstraintsChange = nextUseConstraints !== undefined && nextUseConstraints !== prevUseConstraints;
|
|
361
|
+
isContainerWidthChange = nextContainerWidth !== undefined && nextContainerWidth !== prevContainerWidth;
|
|
362
|
+
isContainerHeightChange = nextContainerHeight !== undefined && nextContainerHeight !== prevContainerHeight;
|
|
363
|
+
isMarginChange = nextMargin !== undefined && nextMargin !== prevMargin;
|
|
364
|
+
isImageActionChange = nextOnImageActions !== prevOnImageActions;
|
|
365
|
+
zoomReset = {
|
|
366
|
+
zoom: 0
|
|
367
|
+
};
|
|
368
|
+
if (isZoomChange) {
|
|
369
|
+
this.setZoom(nextZoom);
|
|
370
|
+
}
|
|
371
|
+
if (isUseConstraintsChange) {
|
|
372
|
+
this.setState({
|
|
373
|
+
zoom: 0,
|
|
374
|
+
imageWidth: imageSourceRect.width,
|
|
375
|
+
imageHeight: imageSourceRect.height
|
|
376
|
+
}, this.update);
|
|
377
|
+
}
|
|
378
|
+
if (isContainerWidthChange || isContainerHeightChange || isMarginChange) {
|
|
379
|
+
this.setState(zoomReset, this.update);
|
|
380
|
+
this.updateZoomProp();
|
|
381
|
+
}
|
|
382
|
+
if (!(nextSrc !== prevSrc)) {
|
|
383
|
+
_context2.next = 27;
|
|
384
|
+
break;
|
|
385
|
+
}
|
|
386
|
+
if (!(nextSrc instanceof File)) {
|
|
387
|
+
_context2.next = 20;
|
|
388
|
+
break;
|
|
389
|
+
}
|
|
390
|
+
_context2.next = 19;
|
|
391
|
+
return (0, _mediaUi.getFileInfo)(nextSrc);
|
|
392
|
+
case 19:
|
|
393
|
+
fileInfo = _context2.sent;
|
|
394
|
+
case 20:
|
|
395
|
+
if (!(typeof nextSrc === 'string')) {
|
|
396
|
+
_context2.next = 24;
|
|
397
|
+
break;
|
|
398
|
+
}
|
|
399
|
+
_context2.next = 23;
|
|
400
|
+
return (0, _mediaUi.getFileInfoFromSrc)(nextSrc);
|
|
401
|
+
case 23:
|
|
402
|
+
fileInfo = _context2.sent;
|
|
403
|
+
case 24:
|
|
404
|
+
if (!fileInfo) {
|
|
405
|
+
_context2.next = 27;
|
|
406
|
+
break;
|
|
407
|
+
}
|
|
408
|
+
_context2.next = 27;
|
|
409
|
+
return this.preprocessFile(fileInfo);
|
|
410
|
+
case 27:
|
|
411
|
+
if (isImageActionChange) {
|
|
412
|
+
this.provideImageActions();
|
|
413
|
+
}
|
|
414
|
+
case 28:
|
|
415
|
+
case "end":
|
|
416
|
+
return _context2.stop();
|
|
417
|
+
}
|
|
418
|
+
}, _callee2, this);
|
|
419
|
+
}));
|
|
420
|
+
function componentDidUpdate(_x2) {
|
|
421
|
+
return _componentDidUpdate.apply(this, arguments);
|
|
422
|
+
}
|
|
423
|
+
return componentDidUpdate;
|
|
424
|
+
}()
|
|
425
|
+
}, {
|
|
426
|
+
key: "preprocessFile",
|
|
427
|
+
value: function () {
|
|
428
|
+
var _preprocessFile = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee3(fileInfo) {
|
|
429
|
+
var maxZoom, previewInfo, width, height;
|
|
430
|
+
return _regenerator.default.wrap(function _callee3$(_context3) {
|
|
431
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
342
432
|
case 0:
|
|
343
433
|
maxZoom = this.props.maxZoom;
|
|
344
|
-
|
|
434
|
+
_context3.next = 3;
|
|
345
435
|
return (0, _imageProcessor.initialiseImagePreview)(fileInfo, this.containerRect, maxZoom);
|
|
346
436
|
case 3:
|
|
347
|
-
previewInfo =
|
|
437
|
+
previewInfo = _context3.sent;
|
|
348
438
|
if (previewInfo) {
|
|
349
439
|
width = previewInfo.width, height = previewInfo.height;
|
|
350
440
|
this.imageSourceRect = new _mediaUi.Rectangle(width, height);
|
|
@@ -357,11 +447,11 @@ var ImagePlacer = exports.ImagePlacer = /*#__PURE__*/function (_React$Component)
|
|
|
357
447
|
}
|
|
358
448
|
case 5:
|
|
359
449
|
case "end":
|
|
360
|
-
return
|
|
450
|
+
return _context3.stop();
|
|
361
451
|
}
|
|
362
|
-
},
|
|
452
|
+
}, _callee3, this);
|
|
363
453
|
}));
|
|
364
|
-
function preprocessFile(
|
|
454
|
+
function preprocessFile(_x3) {
|
|
365
455
|
return _preprocessFile.apply(this, arguments);
|
|
366
456
|
}
|
|
367
457
|
return preprocessFile;
|
|
@@ -9,6 +9,7 @@ import { ImagePlacerImage } from './image';
|
|
|
9
9
|
import { Margin } from './margin';
|
|
10
10
|
import { initialiseImagePreview, renderImageAtCurrentView } from './imageProcessor';
|
|
11
11
|
import { zoomToFit, applyConstraints, transformVisibleBoundsToImageCoords } from './constraints';
|
|
12
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
12
13
|
import { ImagePlacerErrorWrapper } from './imagePlacerErrorWrapper';
|
|
13
14
|
import { isSSR } from '../util';
|
|
14
15
|
|
|
@@ -247,6 +248,9 @@ export class ImagePlacer extends React.Component {
|
|
|
247
248
|
|
|
248
249
|
/* respond to prop changes */
|
|
249
250
|
async UNSAFE_componentWillReceiveProps(nextProps) {
|
|
251
|
+
if (fg('platform_media_package_react19_lifecycle_fix')) {
|
|
252
|
+
return;
|
|
253
|
+
}
|
|
250
254
|
const {
|
|
251
255
|
imageSourceRect,
|
|
252
256
|
state,
|
|
@@ -308,6 +312,71 @@ export class ImagePlacer extends React.Component {
|
|
|
308
312
|
this.provideImageActions();
|
|
309
313
|
}
|
|
310
314
|
}
|
|
315
|
+
async componentDidUpdate(prevProps) {
|
|
316
|
+
if (!fg('platform_media_package_react19_lifecycle_fix')) {
|
|
317
|
+
return;
|
|
318
|
+
}
|
|
319
|
+
const {
|
|
320
|
+
imageSourceRect,
|
|
321
|
+
props
|
|
322
|
+
} = this;
|
|
323
|
+
const {
|
|
324
|
+
zoom: nextZoom,
|
|
325
|
+
useConstraints: nextUseConstraints,
|
|
326
|
+
containerWidth: nextContainerWidth,
|
|
327
|
+
containerHeight: nextContainerHeight,
|
|
328
|
+
margin: nextMargin,
|
|
329
|
+
src: nextSrc,
|
|
330
|
+
onImageActions: nextOnImageActions
|
|
331
|
+
} = props;
|
|
332
|
+
const {
|
|
333
|
+
zoom: prevZoom,
|
|
334
|
+
useConstraints: prevUseConstraints,
|
|
335
|
+
containerWidth: prevContainerWidth,
|
|
336
|
+
containerHeight: prevContainerHeight,
|
|
337
|
+
margin: prevMargin,
|
|
338
|
+
src: prevSrc,
|
|
339
|
+
onImageActions: prevOnImageActions
|
|
340
|
+
} = prevProps;
|
|
341
|
+
const isZoomChange = nextZoom !== prevZoom;
|
|
342
|
+
const isUseConstraintsChange = nextUseConstraints !== undefined && nextUseConstraints !== prevUseConstraints;
|
|
343
|
+
const isContainerWidthChange = nextContainerWidth !== undefined && nextContainerWidth !== prevContainerWidth;
|
|
344
|
+
const isContainerHeightChange = nextContainerHeight !== undefined && nextContainerHeight !== prevContainerHeight;
|
|
345
|
+
const isMarginChange = nextMargin !== undefined && nextMargin !== prevMargin;
|
|
346
|
+
const isImageActionChange = nextOnImageActions !== prevOnImageActions;
|
|
347
|
+
const zoomReset = {
|
|
348
|
+
zoom: 0
|
|
349
|
+
};
|
|
350
|
+
if (isZoomChange) {
|
|
351
|
+
this.setZoom(nextZoom);
|
|
352
|
+
}
|
|
353
|
+
if (isUseConstraintsChange) {
|
|
354
|
+
this.setState({
|
|
355
|
+
zoom: 0,
|
|
356
|
+
imageWidth: imageSourceRect.width,
|
|
357
|
+
imageHeight: imageSourceRect.height
|
|
358
|
+
}, this.update);
|
|
359
|
+
}
|
|
360
|
+
if (isContainerWidthChange || isContainerHeightChange || isMarginChange) {
|
|
361
|
+
this.setState(zoomReset, this.update);
|
|
362
|
+
this.updateZoomProp();
|
|
363
|
+
}
|
|
364
|
+
if (nextSrc !== prevSrc) {
|
|
365
|
+
let fileInfo;
|
|
366
|
+
if (nextSrc instanceof File) {
|
|
367
|
+
fileInfo = await getFileInfo(nextSrc);
|
|
368
|
+
}
|
|
369
|
+
if (typeof nextSrc === 'string') {
|
|
370
|
+
fileInfo = await getFileInfoFromSrc(nextSrc);
|
|
371
|
+
}
|
|
372
|
+
if (fileInfo) {
|
|
373
|
+
await this.preprocessFile(fileInfo);
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
if (isImageActionChange) {
|
|
377
|
+
this.provideImageActions();
|
|
378
|
+
}
|
|
379
|
+
}
|
|
311
380
|
async preprocessFile(fileInfo) {
|
|
312
381
|
const {
|
|
313
382
|
maxZoom
|
|
@@ -19,6 +19,7 @@ import { ImagePlacerImage } from './image';
|
|
|
19
19
|
import { Margin } from './margin';
|
|
20
20
|
import { initialiseImagePreview, renderImageAtCurrentView } from './imageProcessor';
|
|
21
21
|
import { zoomToFit as _zoomToFit, applyConstraints as _applyConstraints, transformVisibleBoundsToImageCoords as _transformVisibleBoundsToImageCoords } from './constraints';
|
|
22
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
22
23
|
import { ImagePlacerErrorWrapper } from './imagePlacerErrorWrapper';
|
|
23
24
|
import { isSSR } from '../util';
|
|
24
25
|
|
|
@@ -260,6 +261,12 @@ export var ImagePlacer = /*#__PURE__*/function (_React$Component) {
|
|
|
260
261
|
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
261
262
|
while (1) switch (_context.prev = _context.next) {
|
|
262
263
|
case 0:
|
|
264
|
+
if (!fg('platform_media_package_react19_lifecycle_fix')) {
|
|
265
|
+
_context.next = 2;
|
|
266
|
+
break;
|
|
267
|
+
}
|
|
268
|
+
return _context.abrupt("return");
|
|
269
|
+
case 2:
|
|
263
270
|
imageSourceRect = this.imageSourceRect, state = this.state, props = this.props;
|
|
264
271
|
zoom = state.zoom;
|
|
265
272
|
currentUseConstraints = props.useConstraints, currentContainerWidth = props.containerWidth, currentContainerHeight = props.containerHeight, currentMargin = props.margin, currentSrc = props.src;
|
|
@@ -288,34 +295,34 @@ export var ImagePlacer = /*#__PURE__*/function (_React$Component) {
|
|
|
288
295
|
this.updateZoomProp();
|
|
289
296
|
}
|
|
290
297
|
if (!(nextSrc instanceof File && nextSrc !== currentSrc)) {
|
|
291
|
-
_context.next =
|
|
298
|
+
_context.next = 20;
|
|
292
299
|
break;
|
|
293
300
|
}
|
|
294
|
-
_context.next =
|
|
301
|
+
_context.next = 19;
|
|
295
302
|
return getFileInfo(nextSrc);
|
|
296
|
-
case
|
|
303
|
+
case 19:
|
|
297
304
|
fileInfo = _context.sent;
|
|
298
|
-
case
|
|
305
|
+
case 20:
|
|
299
306
|
if (!(typeof nextSrc === 'string' && nextSrc !== currentSrc)) {
|
|
300
|
-
_context.next =
|
|
307
|
+
_context.next = 24;
|
|
301
308
|
break;
|
|
302
309
|
}
|
|
303
|
-
_context.next =
|
|
310
|
+
_context.next = 23;
|
|
304
311
|
return getFileInfoFromSrc(nextSrc);
|
|
305
|
-
case
|
|
312
|
+
case 23:
|
|
306
313
|
fileInfo = _context.sent;
|
|
307
|
-
case
|
|
314
|
+
case 24:
|
|
308
315
|
if (!fileInfo) {
|
|
309
|
-
_context.next =
|
|
316
|
+
_context.next = 27;
|
|
310
317
|
break;
|
|
311
318
|
}
|
|
312
|
-
_context.next =
|
|
319
|
+
_context.next = 27;
|
|
313
320
|
return this.preprocessFile(fileInfo);
|
|
314
|
-
case
|
|
321
|
+
case 27:
|
|
315
322
|
if (isImageAction) {
|
|
316
323
|
this.provideImageActions();
|
|
317
324
|
}
|
|
318
|
-
case
|
|
325
|
+
case 28:
|
|
319
326
|
case "end":
|
|
320
327
|
return _context.stop();
|
|
321
328
|
}
|
|
@@ -327,18 +334,101 @@ export var ImagePlacer = /*#__PURE__*/function (_React$Component) {
|
|
|
327
334
|
return UNSAFE_componentWillReceiveProps;
|
|
328
335
|
}())
|
|
329
336
|
}, {
|
|
330
|
-
key: "
|
|
337
|
+
key: "componentDidUpdate",
|
|
331
338
|
value: function () {
|
|
332
|
-
var
|
|
333
|
-
var
|
|
339
|
+
var _componentDidUpdate = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(prevProps) {
|
|
340
|
+
var imageSourceRect, props, nextZoom, nextUseConstraints, nextContainerWidth, nextContainerHeight, nextMargin, nextSrc, nextOnImageActions, prevZoom, prevUseConstraints, prevContainerWidth, prevContainerHeight, prevMargin, prevSrc, prevOnImageActions, isZoomChange, isUseConstraintsChange, isContainerWidthChange, isContainerHeightChange, isMarginChange, isImageActionChange, zoomReset, fileInfo;
|
|
334
341
|
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
335
342
|
while (1) switch (_context2.prev = _context2.next) {
|
|
343
|
+
case 0:
|
|
344
|
+
if (fg('platform_media_package_react19_lifecycle_fix')) {
|
|
345
|
+
_context2.next = 2;
|
|
346
|
+
break;
|
|
347
|
+
}
|
|
348
|
+
return _context2.abrupt("return");
|
|
349
|
+
case 2:
|
|
350
|
+
imageSourceRect = this.imageSourceRect, props = this.props;
|
|
351
|
+
nextZoom = props.zoom, nextUseConstraints = props.useConstraints, nextContainerWidth = props.containerWidth, nextContainerHeight = props.containerHeight, nextMargin = props.margin, nextSrc = props.src, nextOnImageActions = props.onImageActions;
|
|
352
|
+
prevZoom = prevProps.zoom, prevUseConstraints = prevProps.useConstraints, prevContainerWidth = prevProps.containerWidth, prevContainerHeight = prevProps.containerHeight, prevMargin = prevProps.margin, prevSrc = prevProps.src, prevOnImageActions = prevProps.onImageActions;
|
|
353
|
+
isZoomChange = nextZoom !== prevZoom;
|
|
354
|
+
isUseConstraintsChange = nextUseConstraints !== undefined && nextUseConstraints !== prevUseConstraints;
|
|
355
|
+
isContainerWidthChange = nextContainerWidth !== undefined && nextContainerWidth !== prevContainerWidth;
|
|
356
|
+
isContainerHeightChange = nextContainerHeight !== undefined && nextContainerHeight !== prevContainerHeight;
|
|
357
|
+
isMarginChange = nextMargin !== undefined && nextMargin !== prevMargin;
|
|
358
|
+
isImageActionChange = nextOnImageActions !== prevOnImageActions;
|
|
359
|
+
zoomReset = {
|
|
360
|
+
zoom: 0
|
|
361
|
+
};
|
|
362
|
+
if (isZoomChange) {
|
|
363
|
+
this.setZoom(nextZoom);
|
|
364
|
+
}
|
|
365
|
+
if (isUseConstraintsChange) {
|
|
366
|
+
this.setState({
|
|
367
|
+
zoom: 0,
|
|
368
|
+
imageWidth: imageSourceRect.width,
|
|
369
|
+
imageHeight: imageSourceRect.height
|
|
370
|
+
}, this.update);
|
|
371
|
+
}
|
|
372
|
+
if (isContainerWidthChange || isContainerHeightChange || isMarginChange) {
|
|
373
|
+
this.setState(zoomReset, this.update);
|
|
374
|
+
this.updateZoomProp();
|
|
375
|
+
}
|
|
376
|
+
if (!(nextSrc !== prevSrc)) {
|
|
377
|
+
_context2.next = 27;
|
|
378
|
+
break;
|
|
379
|
+
}
|
|
380
|
+
if (!(nextSrc instanceof File)) {
|
|
381
|
+
_context2.next = 20;
|
|
382
|
+
break;
|
|
383
|
+
}
|
|
384
|
+
_context2.next = 19;
|
|
385
|
+
return getFileInfo(nextSrc);
|
|
386
|
+
case 19:
|
|
387
|
+
fileInfo = _context2.sent;
|
|
388
|
+
case 20:
|
|
389
|
+
if (!(typeof nextSrc === 'string')) {
|
|
390
|
+
_context2.next = 24;
|
|
391
|
+
break;
|
|
392
|
+
}
|
|
393
|
+
_context2.next = 23;
|
|
394
|
+
return getFileInfoFromSrc(nextSrc);
|
|
395
|
+
case 23:
|
|
396
|
+
fileInfo = _context2.sent;
|
|
397
|
+
case 24:
|
|
398
|
+
if (!fileInfo) {
|
|
399
|
+
_context2.next = 27;
|
|
400
|
+
break;
|
|
401
|
+
}
|
|
402
|
+
_context2.next = 27;
|
|
403
|
+
return this.preprocessFile(fileInfo);
|
|
404
|
+
case 27:
|
|
405
|
+
if (isImageActionChange) {
|
|
406
|
+
this.provideImageActions();
|
|
407
|
+
}
|
|
408
|
+
case 28:
|
|
409
|
+
case "end":
|
|
410
|
+
return _context2.stop();
|
|
411
|
+
}
|
|
412
|
+
}, _callee2, this);
|
|
413
|
+
}));
|
|
414
|
+
function componentDidUpdate(_x2) {
|
|
415
|
+
return _componentDidUpdate.apply(this, arguments);
|
|
416
|
+
}
|
|
417
|
+
return componentDidUpdate;
|
|
418
|
+
}()
|
|
419
|
+
}, {
|
|
420
|
+
key: "preprocessFile",
|
|
421
|
+
value: function () {
|
|
422
|
+
var _preprocessFile = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(fileInfo) {
|
|
423
|
+
var maxZoom, previewInfo, width, height;
|
|
424
|
+
return _regeneratorRuntime.wrap(function _callee3$(_context3) {
|
|
425
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
336
426
|
case 0:
|
|
337
427
|
maxZoom = this.props.maxZoom;
|
|
338
|
-
|
|
428
|
+
_context3.next = 3;
|
|
339
429
|
return initialiseImagePreview(fileInfo, this.containerRect, maxZoom);
|
|
340
430
|
case 3:
|
|
341
|
-
previewInfo =
|
|
431
|
+
previewInfo = _context3.sent;
|
|
342
432
|
if (previewInfo) {
|
|
343
433
|
width = previewInfo.width, height = previewInfo.height;
|
|
344
434
|
this.imageSourceRect = new Rectangle(width, height);
|
|
@@ -351,11 +441,11 @@ export var ImagePlacer = /*#__PURE__*/function (_React$Component) {
|
|
|
351
441
|
}
|
|
352
442
|
case 5:
|
|
353
443
|
case "end":
|
|
354
|
-
return
|
|
444
|
+
return _context3.stop();
|
|
355
445
|
}
|
|
356
|
-
},
|
|
446
|
+
}, _callee3, this);
|
|
357
447
|
}));
|
|
358
|
-
function preprocessFile(
|
|
448
|
+
function preprocessFile(_x3) {
|
|
359
449
|
return _preprocessFile.apply(this, arguments);
|
|
360
450
|
}
|
|
361
451
|
return preprocessFile;
|
|
@@ -82,6 +82,7 @@ export declare class ImagePlacer extends React.Component<ImagePlacerProps, Image
|
|
|
82
82
|
constructor(props: ImagePlacerProps);
|
|
83
83
|
private provideImageActions;
|
|
84
84
|
UNSAFE_componentWillReceiveProps(nextProps: ImagePlacerProps): Promise<void>;
|
|
85
|
+
componentDidUpdate(prevProps: ImagePlacerProps): Promise<void>;
|
|
85
86
|
preprocessFile(fileInfo: FileInfo): Promise<void>;
|
|
86
87
|
setSrc(fileInfo: FileInfo): void;
|
|
87
88
|
private updateZoomProp;
|
|
@@ -82,6 +82,7 @@ export declare class ImagePlacer extends React.Component<ImagePlacerProps, Image
|
|
|
82
82
|
constructor(props: ImagePlacerProps);
|
|
83
83
|
private provideImageActions;
|
|
84
84
|
UNSAFE_componentWillReceiveProps(nextProps: ImagePlacerProps): Promise<void>;
|
|
85
|
+
componentDidUpdate(prevProps: ImagePlacerProps): Promise<void>;
|
|
85
86
|
preprocessFile(fileInfo: FileInfo): Promise<void>;
|
|
86
87
|
setSrc(fileInfo: FileInfo): void;
|
|
87
88
|
private updateZoomProp;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/media-avatar-picker",
|
|
3
|
-
"version": "27.0.
|
|
3
|
+
"version": "27.0.1",
|
|
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/"
|
|
@@ -37,7 +37,8 @@
|
|
|
37
37
|
"@atlaskit/form": "^15.5.0",
|
|
38
38
|
"@atlaskit/icon": "^34.2.0",
|
|
39
39
|
"@atlaskit/media-ui": "^29.0.0",
|
|
40
|
-
"@atlaskit/modal-dialog": "^14.
|
|
40
|
+
"@atlaskit/modal-dialog": "^14.16.0",
|
|
41
|
+
"@atlaskit/platform-feature-flags": "^1.1.0",
|
|
41
42
|
"@atlaskit/primitives": "^19.0.0",
|
|
42
43
|
"@atlaskit/range": "^10.0.0",
|
|
43
44
|
"@atlaskit/spinner": "^19.1.0",
|
|
@@ -67,6 +68,11 @@
|
|
|
67
68
|
"react-dom": "^18.2.0",
|
|
68
69
|
"react-intl": "^6.6.2"
|
|
69
70
|
},
|
|
71
|
+
"platform-feature-flags": {
|
|
72
|
+
"platform_media_package_react19_lifecycle_fix": {
|
|
73
|
+
"type": "boolean"
|
|
74
|
+
}
|
|
75
|
+
},
|
|
70
76
|
"techstack": {
|
|
71
77
|
"@repo/internal": {
|
|
72
78
|
"design-tokens": [
|