@s-ui/react-molecule-photo-uploader
Advanced tools
Comparing version 2.11.0 to 2.12.0
# CHANGELOG | ||
# 2.12.0 (2022-04-13) | ||
### Bug Fixes | ||
* **components/molecule/photoUploader:** JSX Content ([d6bb641](https://github.com/SUI-Components/sui-components/commit/d6bb64116012e206ef41d0a3d9ee2872813ba9e0)) | ||
* **components/molecule/photoUploader:** maintain the status managing ([bf3b250](https://github.com/SUI-Components/sui-components/commit/bf3b250b435e0d7bfadb24866ae1582543da9980)) | ||
### Features | ||
* **components/molecule/photoUploader:** add content feature on molecule photoUploader component ([29421e9](https://github.com/SUI-Components/sui-components/commit/29421e92b84ac9bd248a46e49680a3ec533baa12)) | ||
* **components/molecule/photoUploader:** apply feedback ([a066e0f](https://github.com/SUI-Components/sui-components/commit/a066e0fd6d760d4df802e38a7feb56bc8029e66b)) | ||
* **components/molecule/photoUploader:** apply feedback ([433f9e4](https://github.com/SUI-Components/sui-components/commit/433f9e464fac3650d76eb9acad008548652e3392)) | ||
* **components/molecule/photoUploader:** update component ([afae83e](https://github.com/SUI-Components/sui-components/commit/afae83e8e7bef4bd731bb78d4de6b3d66c418eef)) | ||
# 2.11.0 (2022-04-05) | ||
@@ -4,0 +22,0 @@ |
@@ -0,2 +1,5 @@ | ||
import _extends from "@babel/runtime/helpers/esm/extends"; | ||
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose"; | ||
import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator"; | ||
var _excluded = ["blob", "croppedBase64", "url", "hasErrors", "id"]; | ||
import _regeneratorRuntime from "@babel/runtime/regenerator"; | ||
@@ -91,31 +94,31 @@ import { formatToBase64 } from './photoTools.js'; | ||
function _callbackUploadPhotoHandler() { | ||
_callbackUploadPhotoHandler = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(blob, callbackUploadPhoto, oldUrl) { | ||
_callbackUploadPhotoHandler = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(blob, callbackUploadPhoto, oldUrl) { | ||
var response; | ||
return _regeneratorRuntime.wrap(function _callee2$(_context2) { | ||
return _regeneratorRuntime.wrap(function _callee3$(_context3) { | ||
while (1) { | ||
switch (_context2.prev = _context2.next) { | ||
switch (_context3.prev = _context3.next) { | ||
case 0: | ||
if (!callbackUploadPhoto) { | ||
_context2.next = 10; | ||
_context3.next = 10; | ||
break; | ||
} | ||
_context2.prev = 1; | ||
_context2.next = 4; | ||
_context3.prev = 1; | ||
_context3.next = 4; | ||
return callbackUploadPhoto(blob, oldUrl); | ||
case 4: | ||
response = _context2.sent; | ||
return _context2.abrupt("return", response.url); | ||
response = _context3.sent; | ||
return _context3.abrupt("return", response.url); | ||
case 8: | ||
_context2.prev = 8; | ||
_context2.t0 = _context2["catch"](1); | ||
_context3.prev = 8; | ||
_context3.t0 = _context3["catch"](1); | ||
case 10: | ||
case "end": | ||
return _context2.stop(); | ||
return _context3.stop(); | ||
} | ||
} | ||
}, _callee2, null, [[1, 8]]); | ||
}, _callee3, null, [[1, 8]]); | ||
})); | ||
@@ -222,50 +225,69 @@ return _callbackUploadPhotoHandler.apply(this, arguments); | ||
}; | ||
export var loadInitialPhotos = function loadInitialPhotos(_ref5) { | ||
var initialPhotos = _ref5.initialPhotos, | ||
defaultFormatToBase64Options = _ref5.defaultFormatToBase64Options, | ||
setInitialDownloadError = _ref5.setInitialDownloadError, | ||
setFiles = _ref5.setFiles, | ||
_callbackPhotosUploaded = _ref5._callbackPhotosUploaded, | ||
setIsLoading = _ref5.setIsLoading; | ||
var filesWithBase64 = initialPhotos.map(function (item) { | ||
return formatToBase64({ | ||
item: item, | ||
options: defaultFormatToBase64Options | ||
}); | ||
}); | ||
Promise.all(filesWithBase64).then(function (newFiles) { | ||
var readyPhotos = newFiles.map(function (_ref6) { | ||
var blob = _ref6.blob, | ||
croppedBase64 = _ref6.croppedBase64, | ||
url = _ref6.url, | ||
_ref6$hasErrors = _ref6.hasErrors, | ||
hasErrors = _ref6$hasErrors === void 0 ? DEFAULT_HAS_ERRORS_STATUS : _ref6$hasErrors, | ||
id = _ref6.id; | ||
return { | ||
blob: blob, | ||
url: url, | ||
hasErrors: hasErrors, | ||
originalBase64: croppedBase64, | ||
preview: croppedBase64, | ||
rotation: DEFAULT_IMAGE_ROTATION_DEGREES, | ||
isNew: false, | ||
isModified: false, | ||
id: id | ||
}; | ||
}); | ||
export var loadInitialPhotos = /*#__PURE__*/function () { | ||
var _ref6 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(_ref5) { | ||
var initialPhotos, defaultFormatToBase64Options, setInitialDownloadError, setFiles, _callbackPhotosUploaded, setIsLoading, filesWithBase64, newFiles, readyPhotos; | ||
if (readyPhotos.some(function (photos) { | ||
return photos.hasErrors; | ||
})) { | ||
setInitialDownloadError(); | ||
} | ||
return _regeneratorRuntime.wrap(function _callee2$(_context2) { | ||
while (1) { | ||
switch (_context2.prev = _context2.next) { | ||
case 0: | ||
initialPhotos = _ref5.initialPhotos, defaultFormatToBase64Options = _ref5.defaultFormatToBase64Options, setInitialDownloadError = _ref5.setInitialDownloadError, setFiles = _ref5.setFiles, _callbackPhotosUploaded = _ref5._callbackPhotosUploaded, setIsLoading = _ref5.setIsLoading; | ||
filesWithBase64 = initialPhotos.map(function (item) { | ||
return formatToBase64({ | ||
item: item, | ||
options: defaultFormatToBase64Options | ||
}); | ||
}); | ||
_context2.next = 4; | ||
return Promise.all(filesWithBase64); | ||
setFiles([].concat(readyPhotos)); | ||
case 4: | ||
newFiles = _context2.sent; | ||
readyPhotos = newFiles.map(function (_ref7) { | ||
var blob = _ref7.blob, | ||
croppedBase64 = _ref7.croppedBase64, | ||
url = _ref7.url, | ||
_ref7$hasErrors = _ref7.hasErrors, | ||
hasErrors = _ref7$hasErrors === void 0 ? DEFAULT_HAS_ERRORS_STATUS : _ref7$hasErrors, | ||
id = _ref7.id, | ||
rest = _objectWithoutPropertiesLoose(_ref7, _excluded); | ||
_callbackPhotosUploaded(readyPhotos, { | ||
action: ACTIONS.INITIAL_LOAD | ||
}); | ||
return _extends({ | ||
blob: blob, | ||
url: url, | ||
hasErrors: hasErrors, | ||
originalBase64: croppedBase64, | ||
preview: croppedBase64, | ||
rotation: DEFAULT_IMAGE_ROTATION_DEGREES, | ||
isNew: false, | ||
isModified: false, | ||
id: id | ||
}, rest); | ||
}); | ||
setIsLoading(false); | ||
}); | ||
}; | ||
if (readyPhotos.some(function (photos) { | ||
return photos.hasErrors; | ||
})) { | ||
setInitialDownloadError(); | ||
} | ||
setFiles([].concat(readyPhotos)); | ||
_callbackPhotosUploaded(readyPhotos, { | ||
action: ACTIONS.INITIAL_LOAD | ||
}); | ||
setIsLoading(false); | ||
case 10: | ||
case "end": | ||
return _context2.stop(); | ||
} | ||
} | ||
}, _callee2); | ||
})); | ||
return function loadInitialPhotos(_x5) { | ||
return _ref6.apply(this, arguments); | ||
}; | ||
}(); |
@@ -43,2 +43,3 @@ import _extends from "@babel/runtime/helpers/esm/extends"; | ||
callbackUploadPhoto = _ref.callbackUploadPhoto, | ||
content = _ref.content, | ||
deleteIcon = _ref.deleteIcon, | ||
@@ -297,2 +298,3 @@ _ref$disableScrollToB = _ref.disableScrollToBottom, | ||
callbackUploadPhoto: callbackUploadPhoto, | ||
content: content, | ||
defaultFormatToBase64Options: DEFAULT_FORMAT_TO_BASE_64_OPTIONS, | ||
@@ -299,0 +301,0 @@ deleteIcon: deleteIcon, |
@@ -25,2 +25,3 @@ import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator"; | ||
callbackUploadPhoto = _ref.callbackUploadPhoto, | ||
content = _ref.content, | ||
defaultFormatToBase64Options = _ref.defaultFormatToBase64Options, | ||
@@ -184,3 +185,3 @@ deleteIcon = _ref.deleteIcon, | ||
}, | ||
children: /*#__PURE__*/_jsx(ThumbCard, { | ||
children: file && /*#__PURE__*/_jsx(ThumbCard, { | ||
iconSize: thumbIconSize, | ||
@@ -193,2 +194,3 @@ image: file, | ||
callbackRotateItem: _rotateItem, | ||
content: content, | ||
rotateIcon: rotateIcon(), | ||
@@ -200,3 +202,3 @@ deleteIcon: deleteIcon(), | ||
}) | ||
}, "" + file.preview + index); | ||
}, "" + (file == null ? void 0 : file.preview) + index); | ||
}); | ||
@@ -203,0 +205,0 @@ }; |
import _extends from "@babel/runtime/helpers/esm/extends"; | ||
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose"; | ||
var _excluded = ["file", "item", "options"], | ||
_excluded2 = ["url", "id"]; | ||
import { FORM_IMAGE_UPLOADER_DEFAULT_FORMAT_TO_BASE_64_OPTIONS, DEFAULT_FILE_TYPE_EXPORTED, DEFAULT_IMAGE_QUALITY_EXPORTED, DEFAULT_IMAGE_ROTATION_DEGREES } from './config.js'; | ||
@@ -7,3 +10,4 @@ export function formatToBase64(_ref) { | ||
_ref$options = _ref.options, | ||
options = _ref$options === void 0 ? FORM_IMAGE_UPLOADER_DEFAULT_FORMAT_TO_BASE_64_OPTIONS : _ref$options; | ||
options = _ref$options === void 0 ? FORM_IMAGE_UPLOADER_DEFAULT_FORMAT_TO_BASE_64_OPTIONS : _ref$options, | ||
rest = _objectWithoutPropertiesLoose(_ref, _excluded); | ||
@@ -54,3 +58,3 @@ if (file) { | ||
base64 = _ref2.base64; | ||
resolve({ | ||
resolve(_extends({ | ||
file: file, | ||
@@ -61,7 +65,7 @@ blob: blob, | ||
rotation: options.rotation | ||
}); | ||
}, rest)); | ||
})["catch"](function (e) { | ||
resolve({ | ||
resolve(_extends({ | ||
hasErrors: true | ||
}); | ||
}, rest)); | ||
}); | ||
@@ -72,3 +76,5 @@ }; | ||
var url = item.url, | ||
id = item.id; | ||
id = item.id, | ||
_rest = _objectWithoutPropertiesLoose(item, _excluded2); | ||
return new Promise(function (resolve, reject) { | ||
@@ -82,3 +88,3 @@ cropAndRotateImage(_extends({ | ||
base64 = _ref3.base64; | ||
resolve({ | ||
resolve(_extends({ | ||
url: url, | ||
@@ -88,9 +94,9 @@ blob: blob, | ||
id: id | ||
}); | ||
}, _rest)); | ||
})["catch"](function (e) { | ||
resolve({ | ||
resolve(_extends({ | ||
url: url, | ||
id: id, | ||
hasErrors: true | ||
}); | ||
}, _rest)); | ||
}); | ||
@@ -97,0 +103,0 @@ }); |
@@ -16,2 +16,6 @@ import PropTypes from 'prop-types'; | ||
callbackRotateItem = _ref.callbackRotateItem, | ||
_ref$content = _ref.content, | ||
Content = _ref$content === void 0 ? function () { | ||
return null; | ||
} : _ref$content, | ||
deleteIcon = _ref.deleteIcon, | ||
@@ -45,2 +49,5 @@ index = _ref.index, | ||
}) | ||
}), /*#__PURE__*/_jsx(Content, { | ||
file: image, | ||
index: index | ||
}), /*#__PURE__*/_jsxs("div", { | ||
@@ -47,0 +54,0 @@ className: ACTION_THUMB_CARD_CLASS_NAME, |
{ | ||
"name": "@s-ui/react-molecule-photo-uploader", | ||
"version": "2.11.0", | ||
"version": "2.12.0", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
Sorry, the diff of this file is not supported yet
90767
1327