ui-kit-ck-consultant 0.5.216 → 0.5.217
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +67 -16
- package/dist/index.js.map +1 -1
- package/dist/index.modern.js +67 -16
- package/dist/index.modern.js.map +1 -1
- package/package.json +1 -1
package/dist/index.modern.js
CHANGED
@@ -3025,6 +3025,56 @@ var DropzoneMultiple = /*#__PURE__*/function (_React$Component) {
|
|
3025
3025
|
|
3026
3026
|
_this = _React$Component.call(this, props) || this;
|
3027
3027
|
|
3028
|
+
_this.resizeImage = function (base64, mime, callback) {
|
3029
|
+
if (callback === void 0) {
|
3030
|
+
callback = function callback() {};
|
3031
|
+
}
|
3032
|
+
|
3033
|
+
if (_this.props.maxImageSize && ['image/png', 'image/jpeg', 'image/jpg'].includes(mime)) {
|
3034
|
+
var image = new Image();
|
3035
|
+
image.src = base64;
|
3036
|
+
|
3037
|
+
image.onload = function () {
|
3038
|
+
var initialWidth = image.width;
|
3039
|
+
var initialHeight = image.height;
|
3040
|
+
var finalWidth = 0;
|
3041
|
+
var finalHeight = 0;
|
3042
|
+
|
3043
|
+
if (initialWidth > initialHeight) {
|
3044
|
+
if (initialWidth > _this.props.maxImageSize) {
|
3045
|
+
finalWidth = _this.props.maxImageSize;
|
3046
|
+
finalHeight = finalWidth * initialHeight / initialWidth;
|
3047
|
+
} else {
|
3048
|
+
finalWidth = initialWidth;
|
3049
|
+
finalHeight = initialHeight;
|
3050
|
+
}
|
3051
|
+
} else {
|
3052
|
+
if (initialHeight > _this.props.maxImageSize) {
|
3053
|
+
finalHeight = _this.props.maxImageSize;
|
3054
|
+
finalWidth = finalHeight * initialWidth / initialHeight;
|
3055
|
+
} else {
|
3056
|
+
finalWidth = initialWidth;
|
3057
|
+
finalHeight = initialHeight;
|
3058
|
+
}
|
3059
|
+
}
|
3060
|
+
|
3061
|
+
var canvas = document.createElement('canvas');
|
3062
|
+
var ctx = canvas.getContext('2d');
|
3063
|
+
canvas.width = finalWidth;
|
3064
|
+
canvas.height = finalHeight;
|
3065
|
+
ctx.drawImage(image, 0, 0, finalWidth, finalHeight);
|
3066
|
+
base64 = canvas.toDataURL(mime, 0.9);
|
3067
|
+
callback(base64);
|
3068
|
+
};
|
3069
|
+
|
3070
|
+
image.onerror = function () {
|
3071
|
+
callback(base64);
|
3072
|
+
};
|
3073
|
+
} else {
|
3074
|
+
callback(base64);
|
3075
|
+
}
|
3076
|
+
};
|
3077
|
+
|
3028
3078
|
_this.handleDeleteFile = function (idx) {
|
3029
3079
|
var files = _this.state.files;
|
3030
3080
|
files.splice(idx, 1);
|
@@ -3070,22 +3120,23 @@ var DropzoneMultiple = /*#__PURE__*/function (_React$Component) {
|
|
3070
3120
|
var reader = new window.FileReader();
|
3071
3121
|
|
3072
3122
|
reader.onload = function () {
|
3073
|
-
|
3074
|
-
|
3075
|
-
|
3076
|
-
|
3077
|
-
|
3078
|
-
|
3079
|
-
|
3080
|
-
|
3081
|
-
|
3082
|
-
|
3083
|
-
|
3084
|
-
|
3085
|
-
|
3086
|
-
|
3087
|
-
|
3088
|
-
|
3123
|
+
_this.resizeImage(reader.result, file.type, function (base64) {
|
3124
|
+
var tmpFiles = _this.state.files;
|
3125
|
+
tmpFiles.push({
|
3126
|
+
base64: base64,
|
3127
|
+
mime: file.type,
|
3128
|
+
name: file.name,
|
3129
|
+
extension: name[name.length - 1],
|
3130
|
+
size: file.size
|
3131
|
+
});
|
3132
|
+
|
3133
|
+
_this.setState({
|
3134
|
+
files: tmpFiles
|
3135
|
+
}, function () {
|
3136
|
+
_this.currentFile += 1;
|
3137
|
+
|
3138
|
+
_this.nextFile(files);
|
3139
|
+
});
|
3089
3140
|
});
|
3090
3141
|
};
|
3091
3142
|
|