@atlaskit/media-avatar-picker 24.6.15 → 24.7.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/CHANGELOG.md +20 -0
- package/dist/cjs/avatar-picker-dialog/avatar-picker-dialog-error-boundary.js +22 -0
- package/dist/cjs/avatar-picker-dialog/avatar-picker-dialog-loader.js +18 -91
- package/dist/cjs/avatar-picker-dialog/custom-spinner.js +15 -0
- package/dist/cjs/avatar-picker-dialog/index.js +5 -3
- package/dist/cjs/image-navigator/exportCroppedImage.js +16 -0
- package/dist/cjs/image-navigator/index.js +4 -9
- package/dist/es2019/avatar-picker-dialog/avatar-picker-dialog-error-boundary.js +10 -0
- package/dist/es2019/avatar-picker-dialog/avatar-picker-dialog-loader.js +9 -42
- package/dist/es2019/avatar-picker-dialog/custom-spinner.js +8 -0
- package/dist/es2019/avatar-picker-dialog/index.js +5 -3
- package/dist/es2019/image-navigator/exportCroppedImage.js +10 -0
- package/dist/es2019/image-navigator/index.js +5 -11
- package/dist/esm/avatar-picker-dialog/avatar-picker-dialog-error-boundary.js +12 -0
- package/dist/esm/avatar-picker-dialog/avatar-picker-dialog-loader.js +13 -87
- package/dist/esm/avatar-picker-dialog/custom-spinner.js +8 -0
- package/dist/esm/avatar-picker-dialog/index.js +5 -3
- package/dist/esm/image-navigator/exportCroppedImage.js +10 -0
- package/dist/esm/image-navigator/index.js +5 -10
- package/dist/types/avatar-picker-dialog/avatar-picker-dialog-error-boundary.d.ts +6 -0
- package/dist/types/avatar-picker-dialog/avatar-picker-dialog-loader.d.ts +4 -19
- package/dist/types/avatar-picker-dialog/custom-spinner.d.ts +2 -0
- package/dist/types/image-navigator/exportCroppedImage.d.ts +2 -0
- package/dist/types-ts4.5/avatar-picker-dialog/avatar-picker-dialog-error-boundary.d.ts +6 -0
- package/dist/types-ts4.5/avatar-picker-dialog/avatar-picker-dialog-loader.d.ts +4 -19
- package/dist/types-ts4.5/avatar-picker-dialog/custom-spinner.d.ts +2 -0
- package/dist/types-ts4.5/image-navigator/exportCroppedImage.d.ts +2 -0
- package/example-helpers/index.ts +6 -5
- package/example-helpers/samples/avatar-1.svg +32 -0
- package/example-helpers/samples/avatar-10.svg +29 -0
- package/example-helpers/samples/avatar-11.svg +37 -0
- package/example-helpers/samples/avatar-12.svg +38 -0
- package/example-helpers/samples/avatar-13.svg +32 -0
- package/example-helpers/samples/avatar-14.svg +28 -0
- package/example-helpers/samples/avatar-15.svg +27 -0
- package/example-helpers/samples/avatar-16.svg +25 -0
- package/example-helpers/samples/avatar-17.svg +47 -0
- package/example-helpers/samples/avatar-18.svg +30 -0
- package/example-helpers/samples/avatar-19.svg +35 -0
- package/example-helpers/samples/avatar-2.svg +31 -0
- package/example-helpers/samples/avatar-20.svg +25 -0
- package/example-helpers/samples/avatar-21.svg +27 -0
- package/example-helpers/samples/avatar-22.svg +36 -0
- package/example-helpers/samples/avatar-23.svg +25 -0
- package/example-helpers/samples/avatar-24.svg +22 -0
- package/example-helpers/samples/avatar-25.svg +23 -0
- package/example-helpers/samples/avatar-26.svg +26 -0
- package/example-helpers/samples/avatar-3.svg +30 -0
- package/example-helpers/samples/avatar-4.svg +33 -0
- package/example-helpers/samples/avatar-5.svg +34 -0
- package/example-helpers/samples/avatar-6.svg +35 -0
- package/example-helpers/samples/avatar-7.svg +32 -0
- package/example-helpers/samples/avatar-8.svg +35 -0
- package/example-helpers/samples/avatar-9.svg +27 -0
- package/example-helpers/samples/index.ts +55 -0
- package/package.json +13 -12
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,25 @@
|
|
|
1
1
|
# @atlaskit/media-avatar-picker
|
|
2
2
|
|
|
3
|
+
## 24.7.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#136440](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/136440)
|
|
8
|
+
[`57f424ae5180e`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/57f424ae5180e) -
|
|
9
|
+
Added compatibility with React 18
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- Updated dependencies
|
|
14
|
+
|
|
15
|
+
## 24.6.16
|
|
16
|
+
|
|
17
|
+
### Patch Changes
|
|
18
|
+
|
|
19
|
+
- [#136850](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/136850)
|
|
20
|
+
[`ab4eafe4e3806`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/ab4eafe4e3806) -
|
|
21
|
+
Added test id to internal DOM elements
|
|
22
|
+
|
|
3
23
|
## 24.6.15
|
|
4
24
|
|
|
5
25
|
### Patch Changes
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.default = AvatarPickerDialogErrorBoundary;
|
|
9
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
10
|
+
var _reactErrorBoundary = require("react-error-boundary");
|
|
11
|
+
var _ = _interopRequireDefault(require("./"));
|
|
12
|
+
var _customSpinner = require("./custom-spinner");
|
|
13
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
|
14
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
15
|
+
function AvatarPickerDialogErrorBoundary(props) {
|
|
16
|
+
var ErrorBoundaryFallback = (0, _react.useCallback)(function () {
|
|
17
|
+
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, props.placeholder || /*#__PURE__*/_react.default.createElement(_customSpinner.CustomSpinner, null));
|
|
18
|
+
}, [props.placeholder]);
|
|
19
|
+
return /*#__PURE__*/_react.default.createElement(_reactErrorBoundary.ErrorBoundary, {
|
|
20
|
+
FallbackComponent: ErrorBoundaryFallback
|
|
21
|
+
}, /*#__PURE__*/_react.default.createElement(_.default, props));
|
|
22
|
+
}
|
|
@@ -1,98 +1,25 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
|
-
exports.default =
|
|
9
|
-
var
|
|
10
|
-
var
|
|
11
|
-
var
|
|
12
|
-
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
13
|
-
var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
|
|
14
|
-
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
|
15
|
-
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
|
|
16
|
-
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
|
|
17
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
18
|
-
var _react = _interopRequireDefault(require("react"));
|
|
19
|
-
var _mediaUi = require("@atlaskit/media-ui");
|
|
7
|
+
exports.default = AsyncAvatarPickerDialog;
|
|
8
|
+
var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
|
|
9
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
10
|
+
var _customSpinner = require("./custom-spinner");
|
|
20
11
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
|
21
|
-
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" !=
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
(
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
// Set state value to equal to current static value of this class.
|
|
36
|
-
AvatarPickerDialog: AsyncAvatarPickerDialog.AvatarPickerDialog
|
|
37
|
-
});
|
|
38
|
-
return _this;
|
|
39
|
-
}
|
|
40
|
-
(0, _createClass2.default)(AsyncAvatarPickerDialog, [{
|
|
41
|
-
key: "UNSAFE_componentWillMount",
|
|
42
|
-
value: function () {
|
|
43
|
-
var _UNSAFE_componentWillMount = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee() {
|
|
44
|
-
var module;
|
|
45
|
-
return _regenerator.default.wrap(function _callee$(_context) {
|
|
46
|
-
while (1) switch (_context.prev = _context.next) {
|
|
47
|
-
case 0:
|
|
48
|
-
if (this.state.AvatarPickerDialog) {
|
|
49
|
-
_context.next = 11;
|
|
50
|
-
break;
|
|
51
|
-
}
|
|
52
|
-
_context.prev = 1;
|
|
53
|
-
_context.next = 4;
|
|
54
|
-
return Promise.resolve().then(function () {
|
|
55
|
-
return _interopRequireWildcard(require( /* webpackChunkName: "@atlaskit-internal_media-avatar-picker" */
|
|
56
|
-
'.'));
|
|
57
|
-
});
|
|
58
|
-
case 4:
|
|
59
|
-
module = _context.sent;
|
|
60
|
-
AsyncAvatarPickerDialog.AvatarPickerDialog = module.default;
|
|
61
|
-
this.setState({
|
|
62
|
-
AvatarPickerDialog: module.default
|
|
63
|
-
});
|
|
64
|
-
_context.next = 11;
|
|
65
|
-
break;
|
|
66
|
-
case 9:
|
|
67
|
-
_context.prev = 9;
|
|
68
|
-
_context.t0 = _context["catch"](1);
|
|
69
|
-
case 11:
|
|
70
|
-
case "end":
|
|
71
|
-
return _context.stop();
|
|
72
|
-
}
|
|
73
|
-
}, _callee, this, [[1, 9]]);
|
|
74
|
-
}));
|
|
75
|
-
function UNSAFE_componentWillMount() {
|
|
76
|
-
return _UNSAFE_componentWillMount.apply(this, arguments);
|
|
77
|
-
}
|
|
78
|
-
return UNSAFE_componentWillMount;
|
|
79
|
-
}()
|
|
80
|
-
}, {
|
|
81
|
-
key: "render",
|
|
82
|
-
value: function render() {
|
|
83
|
-
if (!this.state.AvatarPickerDialog) {
|
|
84
|
-
var placeholder = this.props.placeholder;
|
|
85
|
-
if (placeholder) {
|
|
86
|
-
return placeholder;
|
|
87
|
-
}
|
|
88
|
-
return /*#__PURE__*/_react.default.createElement(_mediaUi.ModalSpinner, {
|
|
89
|
-
blankedColor: "var(--ds-blanket, rgba(255, 255, 255, 0.53))",
|
|
90
|
-
invertSpinnerColor: false
|
|
91
|
-
});
|
|
92
|
-
}
|
|
93
|
-
return /*#__PURE__*/_react.default.createElement(this.state.AvatarPickerDialog, this.props);
|
|
94
|
-
}
|
|
95
|
-
}]);
|
|
96
|
-
return AsyncAvatarPickerDialog;
|
|
97
|
-
}(_react.default.PureComponent);
|
|
98
|
-
(0, _defineProperty2.default)(AsyncAvatarPickerDialog, "displayName", 'AsyncAvatarPickerDialog');
|
|
12
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != (0, _typeof2.default)(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
13
|
+
var AvatarPickerDialogErrorBoundary = /*#__PURE__*/(0, _react.lazy)(function () {
|
|
14
|
+
return Promise.resolve().then(function () {
|
|
15
|
+
return _interopRequireWildcard(require( /* webpackChunkName: "@atlaskit-internal_media-avatar-picker" */'./avatar-picker-dialog-error-boundary'));
|
|
16
|
+
});
|
|
17
|
+
});
|
|
18
|
+
function AsyncAvatarPickerDialog(props) {
|
|
19
|
+
var SuspenseFallback = (0, _react.useCallback)(function () {
|
|
20
|
+
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, props.placeholder || /*#__PURE__*/_react.default.createElement(_customSpinner.CustomSpinner, null));
|
|
21
|
+
}, [props.placeholder]);
|
|
22
|
+
return /*#__PURE__*/_react.default.createElement(_react.Suspense, {
|
|
23
|
+
fallback: /*#__PURE__*/_react.default.createElement(SuspenseFallback, null)
|
|
24
|
+
}, /*#__PURE__*/_react.default.createElement(AvatarPickerDialogErrorBoundary, props));
|
|
25
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.CustomSpinner = void 0;
|
|
8
|
+
var _react = _interopRequireDefault(require("react"));
|
|
9
|
+
var _mediaUi = require("@atlaskit/media-ui");
|
|
10
|
+
var CustomSpinner = exports.CustomSpinner = function CustomSpinner() {
|
|
11
|
+
return /*#__PURE__*/_react.default.createElement(_mediaUi.ModalSpinner, {
|
|
12
|
+
blankedColor: "var(--ds-blanket, rgba(255, 255, 255, 0.53))",
|
|
13
|
+
invertSpinnerColor: false
|
|
14
|
+
});
|
|
15
|
+
};
|
|
@@ -60,8 +60,8 @@ var HeaderContent = function HeaderContent(_ref) {
|
|
|
60
60
|
return (
|
|
61
61
|
// eslint-disable-next-line @atlaskit/design-system/consistent-css-prop-usage, @atlaskit/ui-styling-standard/no-imported-style-values -- Ignored via go/DSP-18766
|
|
62
62
|
(0, _react2.jsx)("h1", {
|
|
63
|
+
"data-testid": "modal-header",
|
|
63
64
|
css: _styles.modalHeaderStyles,
|
|
64
|
-
"data-test-id": "modal-header",
|
|
65
65
|
id: modal.titleId
|
|
66
66
|
}, title || (0, _react2.jsx)(_reactIntlNext.FormattedMessage, _mediaUi.messages.upload_an_avatar))
|
|
67
67
|
);
|
|
@@ -242,7 +242,9 @@ var AvatarPickerDialog = exports.AvatarPickerDialog = /*#__PURE__*/function (_Pu
|
|
|
242
242
|
primaryButtonText = _this$props2.primaryButtonText,
|
|
243
243
|
onCancel = _this$props2.onCancel,
|
|
244
244
|
isLoading = _this$props2.isLoading;
|
|
245
|
-
return (0, _react2.jsx)(_modalDialog.ModalFooter,
|
|
245
|
+
return (0, _react2.jsx)(_modalDialog.ModalFooter, {
|
|
246
|
+
testId: "avatar-picker-dialog-footer"
|
|
247
|
+
}, (0, _react2.jsx)(_buttonGroup.default, null, (0, _react2.jsx)(_standardButton.default, {
|
|
246
248
|
appearance: "default",
|
|
247
249
|
onClick: onCancel
|
|
248
250
|
}, (0, _react2.jsx)(_reactIntlNext.FormattedMessage, _mediaUi.messages.cancel)), (0, _react2.jsx)(_loadingButton.default, {
|
|
@@ -266,6 +268,7 @@ var AvatarPickerDialog = exports.AvatarPickerDialog = /*#__PURE__*/function (_Pu
|
|
|
266
268
|
}), (0, _react2.jsx)(HeaderContent, {
|
|
267
269
|
title: this.props.title
|
|
268
270
|
}), this.state.isSubmitted && (0, _react2.jsx)(_SubmitErrorDialog.SubmitErrorDialog, null), (0, _react2.jsx)("form", {
|
|
271
|
+
"aria-label": "form",
|
|
269
272
|
onSubmit: this.onSave,
|
|
270
273
|
css: _styles.formStyles
|
|
271
274
|
}, (0, _react2.jsx)(_modalDialog.ModalBody, null, (0, _react2.jsx)("div", {
|
|
@@ -371,7 +374,6 @@ var AvatarPickerDialog = exports.AvatarPickerDialog = /*#__PURE__*/function (_Pu
|
|
|
371
374
|
}, function (_ref3) {
|
|
372
375
|
var fieldProps = _ref3.fieldProps;
|
|
373
376
|
return (0, _react2.jsx)(_react.Fragment, null, (0, _react2.jsx)(_textfield.default, (0, _extends2.default)({}, fieldProps, {
|
|
374
|
-
id: "altText",
|
|
375
377
|
onChange: function onChange(event) {
|
|
376
378
|
return _this2.updateAltText(event.currentTarget.value);
|
|
377
379
|
},
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.exportCroppedImage = void 0;
|
|
7
|
+
var _viewport = require("../viewport");
|
|
8
|
+
var exportCroppedImage = exports.exportCroppedImage = function exportCroppedImage(viewport, imageElement, outputSize) {
|
|
9
|
+
if (imageElement) {
|
|
10
|
+
var canvas = (0, _viewport.renderViewport)(viewport, imageElement, document.createElement('canvas'), outputSize);
|
|
11
|
+
if (canvas) {
|
|
12
|
+
return canvas.toDataURL();
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
return '';
|
|
16
|
+
};
|
|
@@ -32,6 +32,7 @@ var _viewport2 = require("../viewport");
|
|
|
32
32
|
var _slider = require("./slider");
|
|
33
33
|
var _layoutConst = require("../avatar-picker-dialog/layout-const");
|
|
34
34
|
var _dragZone = require("./dragZone");
|
|
35
|
+
var _exportCroppedImage = require("./exportCroppedImage");
|
|
35
36
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
|
36
37
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
37
38
|
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2.default)(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2.default)(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2.default)(this, result); }; }
|
|
@@ -136,15 +137,7 @@ var ImageNavigator = exports.ImageNavigator = /*#__PURE__*/function (_Component)
|
|
|
136
137
|
_this.exportCrop();
|
|
137
138
|
});
|
|
138
139
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "exportCroppedImage", function (outputSize) {
|
|
139
|
-
|
|
140
|
-
imageElement = _assertThisInitialize.imageElement;
|
|
141
|
-
if (imageElement) {
|
|
142
|
-
var canvas = (0, _viewport2.renderViewport)(_this.state.viewport, imageElement, document.createElement('canvas'), outputSize);
|
|
143
|
-
if (canvas) {
|
|
144
|
-
return canvas.toDataURL();
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
return '';
|
|
140
|
+
return (0, _exportCroppedImage.exportCroppedImage)(_this.state.viewport, _this.imageElement, outputSize);
|
|
148
141
|
});
|
|
149
142
|
// Trick to have a nice <input /> appearance
|
|
150
143
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "onUploadButtonClick", function (e) {
|
|
@@ -336,7 +329,9 @@ var ImageNavigator = exports.ImageNavigator = /*#__PURE__*/function (_Component)
|
|
|
336
329
|
isDisabled: isLoading,
|
|
337
330
|
testId: "upload-button"
|
|
338
331
|
}, (0, _react2.jsx)(_reactIntlNext.FormattedMessage, _mediaUi.messages.upload_photo), (0, _react2.jsx)("input", {
|
|
332
|
+
"data-testid": "image-navigator-input-file"
|
|
339
333
|
// eslint-disable-next-line @atlaskit/design-system/consistent-css-prop-usage, @atlaskit/ui-styling-standard/no-imported-style-values -- Ignored via go/DSP-18766
|
|
334
|
+
,
|
|
340
335
|
css: _styles.fileInputStyles,
|
|
341
336
|
type: "file",
|
|
342
337
|
id: "image-input",
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import React, { useCallback } from 'react';
|
|
2
|
+
import { ErrorBoundary } from 'react-error-boundary';
|
|
3
|
+
import AvatarPickerDialog from './';
|
|
4
|
+
import { CustomSpinner } from './custom-spinner';
|
|
5
|
+
export default function AvatarPickerDialogErrorBoundary(props) {
|
|
6
|
+
const ErrorBoundaryFallback = useCallback(() => /*#__PURE__*/React.createElement(React.Fragment, null, props.placeholder || /*#__PURE__*/React.createElement(CustomSpinner, null)), [props.placeholder]);
|
|
7
|
+
return /*#__PURE__*/React.createElement(ErrorBoundary, {
|
|
8
|
+
FallbackComponent: ErrorBoundaryFallback
|
|
9
|
+
}, /*#__PURE__*/React.createElement(AvatarPickerDialog, props));
|
|
10
|
+
}
|
|
@@ -1,42 +1,9 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
export default
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
});
|
|
11
|
-
}
|
|
12
|
-
async UNSAFE_componentWillMount() {
|
|
13
|
-
if (!this.state.AvatarPickerDialog) {
|
|
14
|
-
try {
|
|
15
|
-
const module = await import( /* webpackChunkName: "@atlaskit-internal_media-avatar-picker" */
|
|
16
|
-
'.');
|
|
17
|
-
AsyncAvatarPickerDialog.AvatarPickerDialog = module.default;
|
|
18
|
-
this.setState({
|
|
19
|
-
AvatarPickerDialog: module.default
|
|
20
|
-
});
|
|
21
|
-
} catch (error) {
|
|
22
|
-
// TODO [MS-2272]: Add operational error to catch async import error
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
render() {
|
|
27
|
-
if (!this.state.AvatarPickerDialog) {
|
|
28
|
-
const {
|
|
29
|
-
placeholder
|
|
30
|
-
} = this.props;
|
|
31
|
-
if (placeholder) {
|
|
32
|
-
return placeholder;
|
|
33
|
-
}
|
|
34
|
-
return /*#__PURE__*/React.createElement(ModalSpinner, {
|
|
35
|
-
blankedColor: `${"var(--ds-blanket, rgba(255, 255, 255, 0.53))"}`,
|
|
36
|
-
invertSpinnerColor: false
|
|
37
|
-
});
|
|
38
|
-
}
|
|
39
|
-
return /*#__PURE__*/React.createElement(this.state.AvatarPickerDialog, this.props);
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
_defineProperty(AsyncAvatarPickerDialog, "displayName", 'AsyncAvatarPickerDialog');
|
|
1
|
+
import React, { lazy, Suspense, useCallback } from 'react';
|
|
2
|
+
import { CustomSpinner } from './custom-spinner';
|
|
3
|
+
const AvatarPickerDialogErrorBoundary = /*#__PURE__*/lazy(() => import( /* webpackChunkName: "@atlaskit-internal_media-avatar-picker" */'./avatar-picker-dialog-error-boundary'));
|
|
4
|
+
export default function AsyncAvatarPickerDialog(props) {
|
|
5
|
+
const SuspenseFallback = useCallback(() => /*#__PURE__*/React.createElement(React.Fragment, null, props.placeholder || /*#__PURE__*/React.createElement(CustomSpinner, null)), [props.placeholder]);
|
|
6
|
+
return /*#__PURE__*/React.createElement(Suspense, {
|
|
7
|
+
fallback: /*#__PURE__*/React.createElement(SuspenseFallback, null)
|
|
8
|
+
}, /*#__PURE__*/React.createElement(AvatarPickerDialogErrorBoundary, props));
|
|
9
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { ModalSpinner } from '@atlaskit/media-ui';
|
|
3
|
+
export const CustomSpinner = () => {
|
|
4
|
+
return /*#__PURE__*/React.createElement(ModalSpinner, {
|
|
5
|
+
blankedColor: `${"var(--ds-blanket, rgba(255, 255, 255, 0.53))"}`,
|
|
6
|
+
invertSpinnerColor: false
|
|
7
|
+
});
|
|
8
|
+
};
|
|
@@ -45,8 +45,8 @@ const HeaderContent = ({
|
|
|
45
45
|
return (
|
|
46
46
|
// eslint-disable-next-line @atlaskit/design-system/consistent-css-prop-usage, @atlaskit/ui-styling-standard/no-imported-style-values -- Ignored via go/DSP-18766
|
|
47
47
|
jsx("h1", {
|
|
48
|
+
"data-testid": "modal-header",
|
|
48
49
|
css: modalHeaderStyles,
|
|
49
|
-
"data-test-id": "modal-header",
|
|
50
50
|
id: modal.titleId
|
|
51
51
|
}, title || jsx(FormattedMessage, messages.upload_an_avatar))
|
|
52
52
|
);
|
|
@@ -212,7 +212,9 @@ export class AvatarPickerDialog extends PureComponent {
|
|
|
212
212
|
onCancel,
|
|
213
213
|
isLoading
|
|
214
214
|
} = this.props;
|
|
215
|
-
return jsx(ModalFooter,
|
|
215
|
+
return jsx(ModalFooter, {
|
|
216
|
+
testId: "avatar-picker-dialog-footer"
|
|
217
|
+
}, jsx(ButtonGroup, null, jsx(Button, {
|
|
216
218
|
appearance: "default",
|
|
217
219
|
onClick: onCancel
|
|
218
220
|
}, jsx(FormattedMessage, messages.cancel)), jsx(LoadingButton, {
|
|
@@ -233,6 +235,7 @@ export class AvatarPickerDialog extends PureComponent {
|
|
|
233
235
|
}), jsx(HeaderContent, {
|
|
234
236
|
title: this.props.title
|
|
235
237
|
}), this.state.isSubmitted && jsx(SubmitErrorDialog, null), jsx("form", {
|
|
238
|
+
"aria-label": "form",
|
|
236
239
|
onSubmit: this.onSave,
|
|
237
240
|
css: formStyles
|
|
238
241
|
}, jsx(ModalBody, null, jsx("div", {
|
|
@@ -330,7 +333,6 @@ export class AvatarPickerDialog extends PureComponent {
|
|
|
330
333
|
}, ({
|
|
331
334
|
fieldProps
|
|
332
335
|
}) => jsx(Fragment, null, jsx(Textfield, _extends({}, fieldProps, {
|
|
333
|
-
id: "altText",
|
|
334
336
|
onChange: event => this.updateAltText(event.currentTarget.value),
|
|
335
337
|
value: altText || ''
|
|
336
338
|
})), jsx(HelperMessage, null, jsx(FormattedMessage, messages.alt_text_description)))));
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { renderViewport } from '../viewport';
|
|
2
|
+
export const exportCroppedImage = (viewport, imageElement, outputSize) => {
|
|
3
|
+
if (imageElement) {
|
|
4
|
+
const canvas = renderViewport(viewport, imageElement, document.createElement('canvas'), outputSize);
|
|
5
|
+
if (canvas) {
|
|
6
|
+
return canvas.toDataURL();
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
return '';
|
|
10
|
+
};
|
|
@@ -17,10 +17,11 @@ import { containerStyles, sliderContainerStyles, fileInputStyles, imageUploaderS
|
|
|
17
17
|
import { uploadPlaceholder, errorIcon } from './images';
|
|
18
18
|
import { fileSizeMb } from '../util';
|
|
19
19
|
import { ERROR, MAX_SIZE_MB, ACCEPT } from '../avatar-picker-dialog';
|
|
20
|
-
import { Viewport
|
|
20
|
+
import { Viewport } from '../viewport';
|
|
21
21
|
import { Slider } from './slider';
|
|
22
22
|
import { CONTAINER_SIZE, CONTAINER_PADDING } from '../avatar-picker-dialog/layout-const';
|
|
23
23
|
import { DragZone } from './dragZone';
|
|
24
|
+
import { exportCroppedImage } from './exportCroppedImage';
|
|
24
25
|
export const viewport = new Viewport(CONTAINER_SIZE, CONTAINER_SIZE, CONTAINER_PADDING);
|
|
25
26
|
const defaultState = {
|
|
26
27
|
imagePos: new Vector2(CONTAINER_PADDING, CONTAINER_PADDING),
|
|
@@ -117,16 +118,7 @@ export class ImageNavigator extends Component {
|
|
|
117
118
|
this.exportCrop();
|
|
118
119
|
});
|
|
119
120
|
_defineProperty(this, "exportCroppedImage", outputSize => {
|
|
120
|
-
|
|
121
|
-
imageElement
|
|
122
|
-
} = this;
|
|
123
|
-
if (imageElement) {
|
|
124
|
-
const canvas = renderViewport(this.state.viewport, imageElement, document.createElement('canvas'), outputSize);
|
|
125
|
-
if (canvas) {
|
|
126
|
-
return canvas.toDataURL();
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
return '';
|
|
121
|
+
return exportCroppedImage(this.state.viewport, this.imageElement, outputSize);
|
|
130
122
|
});
|
|
131
123
|
// Trick to have a nice <input /> appearance
|
|
132
124
|
_defineProperty(this, "onUploadButtonClick", e => {
|
|
@@ -298,7 +290,9 @@ export class ImageNavigator extends Component {
|
|
|
298
290
|
isDisabled: isLoading,
|
|
299
291
|
testId: "upload-button"
|
|
300
292
|
}, jsx(FormattedMessage, messages.upload_photo), jsx("input", {
|
|
293
|
+
"data-testid": "image-navigator-input-file"
|
|
301
294
|
// eslint-disable-next-line @atlaskit/design-system/consistent-css-prop-usage, @atlaskit/ui-styling-standard/no-imported-style-values -- Ignored via go/DSP-18766
|
|
295
|
+
,
|
|
302
296
|
css: fileInputStyles,
|
|
303
297
|
type: "file",
|
|
304
298
|
id: "image-input",
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import React, { useCallback } from 'react';
|
|
2
|
+
import { ErrorBoundary } from 'react-error-boundary';
|
|
3
|
+
import AvatarPickerDialog from './';
|
|
4
|
+
import { CustomSpinner } from './custom-spinner';
|
|
5
|
+
export default function AvatarPickerDialogErrorBoundary(props) {
|
|
6
|
+
var ErrorBoundaryFallback = useCallback(function () {
|
|
7
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, props.placeholder || /*#__PURE__*/React.createElement(CustomSpinner, null));
|
|
8
|
+
}, [props.placeholder]);
|
|
9
|
+
return /*#__PURE__*/React.createElement(ErrorBoundary, {
|
|
10
|
+
FallbackComponent: ErrorBoundaryFallback
|
|
11
|
+
}, /*#__PURE__*/React.createElement(AvatarPickerDialog, props));
|
|
12
|
+
}
|
|
@@ -1,87 +1,13 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
import
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
var AsyncAvatarPickerDialog = /*#__PURE__*/function (_React$PureComponent) {
|
|
15
|
-
_inherits(AsyncAvatarPickerDialog, _React$PureComponent);
|
|
16
|
-
var _super = _createSuper(AsyncAvatarPickerDialog);
|
|
17
|
-
function AsyncAvatarPickerDialog() {
|
|
18
|
-
var _this;
|
|
19
|
-
_classCallCheck(this, AsyncAvatarPickerDialog);
|
|
20
|
-
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
21
|
-
args[_key] = arguments[_key];
|
|
22
|
-
}
|
|
23
|
-
_this = _super.call.apply(_super, [this].concat(args));
|
|
24
|
-
_defineProperty(_assertThisInitialized(_this), "state", {
|
|
25
|
-
// Set state value to equal to current static value of this class.
|
|
26
|
-
AvatarPickerDialog: AsyncAvatarPickerDialog.AvatarPickerDialog
|
|
27
|
-
});
|
|
28
|
-
return _this;
|
|
29
|
-
}
|
|
30
|
-
_createClass(AsyncAvatarPickerDialog, [{
|
|
31
|
-
key: "UNSAFE_componentWillMount",
|
|
32
|
-
value: function () {
|
|
33
|
-
var _UNSAFE_componentWillMount = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
|
34
|
-
var module;
|
|
35
|
-
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
36
|
-
while (1) switch (_context.prev = _context.next) {
|
|
37
|
-
case 0:
|
|
38
|
-
if (this.state.AvatarPickerDialog) {
|
|
39
|
-
_context.next = 11;
|
|
40
|
-
break;
|
|
41
|
-
}
|
|
42
|
-
_context.prev = 1;
|
|
43
|
-
_context.next = 4;
|
|
44
|
-
return import( /* webpackChunkName: "@atlaskit-internal_media-avatar-picker" */
|
|
45
|
-
'.');
|
|
46
|
-
case 4:
|
|
47
|
-
module = _context.sent;
|
|
48
|
-
AsyncAvatarPickerDialog.AvatarPickerDialog = module.default;
|
|
49
|
-
this.setState({
|
|
50
|
-
AvatarPickerDialog: module.default
|
|
51
|
-
});
|
|
52
|
-
_context.next = 11;
|
|
53
|
-
break;
|
|
54
|
-
case 9:
|
|
55
|
-
_context.prev = 9;
|
|
56
|
-
_context.t0 = _context["catch"](1);
|
|
57
|
-
case 11:
|
|
58
|
-
case "end":
|
|
59
|
-
return _context.stop();
|
|
60
|
-
}
|
|
61
|
-
}, _callee, this, [[1, 9]]);
|
|
62
|
-
}));
|
|
63
|
-
function UNSAFE_componentWillMount() {
|
|
64
|
-
return _UNSAFE_componentWillMount.apply(this, arguments);
|
|
65
|
-
}
|
|
66
|
-
return UNSAFE_componentWillMount;
|
|
67
|
-
}()
|
|
68
|
-
}, {
|
|
69
|
-
key: "render",
|
|
70
|
-
value: function render() {
|
|
71
|
-
if (!this.state.AvatarPickerDialog) {
|
|
72
|
-
var placeholder = this.props.placeholder;
|
|
73
|
-
if (placeholder) {
|
|
74
|
-
return placeholder;
|
|
75
|
-
}
|
|
76
|
-
return /*#__PURE__*/React.createElement(ModalSpinner, {
|
|
77
|
-
blankedColor: "var(--ds-blanket, rgba(255, 255, 255, 0.53))",
|
|
78
|
-
invertSpinnerColor: false
|
|
79
|
-
});
|
|
80
|
-
}
|
|
81
|
-
return /*#__PURE__*/React.createElement(this.state.AvatarPickerDialog, this.props);
|
|
82
|
-
}
|
|
83
|
-
}]);
|
|
84
|
-
return AsyncAvatarPickerDialog;
|
|
85
|
-
}(React.PureComponent);
|
|
86
|
-
_defineProperty(AsyncAvatarPickerDialog, "displayName", 'AsyncAvatarPickerDialog');
|
|
87
|
-
export { AsyncAvatarPickerDialog as default };
|
|
1
|
+
import React, { lazy, Suspense, useCallback } from 'react';
|
|
2
|
+
import { CustomSpinner } from './custom-spinner';
|
|
3
|
+
var AvatarPickerDialogErrorBoundary = /*#__PURE__*/lazy(function () {
|
|
4
|
+
return import( /* webpackChunkName: "@atlaskit-internal_media-avatar-picker" */'./avatar-picker-dialog-error-boundary');
|
|
5
|
+
});
|
|
6
|
+
export default function AsyncAvatarPickerDialog(props) {
|
|
7
|
+
var SuspenseFallback = useCallback(function () {
|
|
8
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, props.placeholder || /*#__PURE__*/React.createElement(CustomSpinner, null));
|
|
9
|
+
}, [props.placeholder]);
|
|
10
|
+
return /*#__PURE__*/React.createElement(Suspense, {
|
|
11
|
+
fallback: /*#__PURE__*/React.createElement(SuspenseFallback, null)
|
|
12
|
+
}, /*#__PURE__*/React.createElement(AvatarPickerDialogErrorBoundary, props));
|
|
13
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { ModalSpinner } from '@atlaskit/media-ui';
|
|
3
|
+
export var CustomSpinner = function CustomSpinner() {
|
|
4
|
+
return /*#__PURE__*/React.createElement(ModalSpinner, {
|
|
5
|
+
blankedColor: "var(--ds-blanket, rgba(255, 255, 255, 0.53))",
|
|
6
|
+
invertSpinnerColor: false
|
|
7
|
+
});
|
|
8
|
+
};
|
|
@@ -54,8 +54,8 @@ var HeaderContent = function HeaderContent(_ref) {
|
|
|
54
54
|
return (
|
|
55
55
|
// eslint-disable-next-line @atlaskit/design-system/consistent-css-prop-usage, @atlaskit/ui-styling-standard/no-imported-style-values -- Ignored via go/DSP-18766
|
|
56
56
|
jsx("h1", {
|
|
57
|
+
"data-testid": "modal-header",
|
|
57
58
|
css: modalHeaderStyles,
|
|
58
|
-
"data-test-id": "modal-header",
|
|
59
59
|
id: modal.titleId
|
|
60
60
|
}, title || jsx(FormattedMessage, messages.upload_an_avatar))
|
|
61
61
|
);
|
|
@@ -236,7 +236,9 @@ export var AvatarPickerDialog = /*#__PURE__*/function (_PureComponent) {
|
|
|
236
236
|
primaryButtonText = _this$props2.primaryButtonText,
|
|
237
237
|
onCancel = _this$props2.onCancel,
|
|
238
238
|
isLoading = _this$props2.isLoading;
|
|
239
|
-
return jsx(ModalFooter,
|
|
239
|
+
return jsx(ModalFooter, {
|
|
240
|
+
testId: "avatar-picker-dialog-footer"
|
|
241
|
+
}, jsx(ButtonGroup, null, jsx(Button, {
|
|
240
242
|
appearance: "default",
|
|
241
243
|
onClick: onCancel
|
|
242
244
|
}, jsx(FormattedMessage, messages.cancel)), jsx(LoadingButton, {
|
|
@@ -260,6 +262,7 @@ export var AvatarPickerDialog = /*#__PURE__*/function (_PureComponent) {
|
|
|
260
262
|
}), jsx(HeaderContent, {
|
|
261
263
|
title: this.props.title
|
|
262
264
|
}), this.state.isSubmitted && jsx(SubmitErrorDialog, null), jsx("form", {
|
|
265
|
+
"aria-label": "form",
|
|
263
266
|
onSubmit: this.onSave,
|
|
264
267
|
css: formStyles
|
|
265
268
|
}, jsx(ModalBody, null, jsx("div", {
|
|
@@ -365,7 +368,6 @@ export var AvatarPickerDialog = /*#__PURE__*/function (_PureComponent) {
|
|
|
365
368
|
}, function (_ref3) {
|
|
366
369
|
var fieldProps = _ref3.fieldProps;
|
|
367
370
|
return jsx(Fragment, null, jsx(Textfield, _extends({}, fieldProps, {
|
|
368
|
-
id: "altText",
|
|
369
371
|
onChange: function onChange(event) {
|
|
370
372
|
return _this2.updateAltText(event.currentTarget.value);
|
|
371
373
|
},
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { renderViewport } from '../viewport';
|
|
2
|
+
export var exportCroppedImage = function exportCroppedImage(viewport, imageElement, outputSize) {
|
|
3
|
+
if (imageElement) {
|
|
4
|
+
var canvas = renderViewport(viewport, imageElement, document.createElement('canvas'), outputSize);
|
|
5
|
+
if (canvas) {
|
|
6
|
+
return canvas.toDataURL();
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
return '';
|
|
10
|
+
};
|