@carbonorm/carbonreact 2.0.2 → 2.0.3
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/hoc/updateRestfulObjectArrays.d.ts +1 -1
- package/dist/hoc/uploadImage.d.ts +1 -1
- package/dist/index.cjs.js +56 -20
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +57 -21
- package/dist/index.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/hoc/updateRestfulObjectArrays.tsx +1 -1
package/dist/index.esm.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { useState, useEffect } from 'react';
|
|
1
|
+
import React, { lazy, useState, useEffect } from 'react';
|
|
2
2
|
import { toastOptions, clearCache, isTest, isVerbose } from '@carbonorm/carbonnode';
|
|
3
3
|
import { useNavigate, BrowserRouter } from 'react-router-dom';
|
|
4
4
|
import { toast, ToastContainer } from 'react-toastify';
|
|
@@ -3436,7 +3436,7 @@ var eUpdateInsertMethod;
|
|
|
3436
3436
|
* @param callback - if you want to do something with the updated state, you can pass a callback here. Run as the second
|
|
3437
3437
|
* parameter of setState.
|
|
3438
3438
|
*/
|
|
3439
|
-
function
|
|
3439
|
+
function updateRestfulObjectArrays(dataOrCallback, stateKey, uniqueObjectId, insertUpdateOrder, callback) {
|
|
3440
3440
|
if (insertUpdateOrder === void 0) { insertUpdateOrder = eUpdateInsertMethod.LAST; }
|
|
3441
3441
|
var bootstrap = CarbonReact.instance;
|
|
3442
3442
|
return bootstrap.setState(function (previousBootstrapState) {
|
|
@@ -3499,25 +3499,61 @@ function toDataURL(src, fileType, callback) {
|
|
|
3499
3499
|
});
|
|
3500
3500
|
}
|
|
3501
3501
|
function uploadImageChange(event, uploadCallback) {
|
|
3502
|
-
|
|
3503
|
-
|
|
3504
|
-
|
|
3505
|
-
|
|
3506
|
-
|
|
3507
|
-
|
|
3508
|
-
|
|
3509
|
-
var fileExtension = file.name.split('.').pop();
|
|
3510
|
-
// check file extension is valid data uri
|
|
3511
|
-
if (fileExtension !== 'jpg' && fileExtension !== 'jpeg' && fileExtension !== 'png' && fileExtension !== 'gif') {
|
|
3512
|
-
toast.error('Please upload a valid image file type (jpg, jpeg, png, gif).');
|
|
3513
|
-
return;
|
|
3514
|
-
}
|
|
3515
|
-
// @link https://github.com/palantir/tslint/issues/4653
|
|
3516
|
-
// @link https://github.com/Microsoft/TypeScript/issues/13376#issuecomment-273289748
|
|
3517
|
-
void toDataURL(URL.createObjectURL(file), file.type, uploadCallback);
|
|
3502
|
+
var _a, _b;
|
|
3503
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
3504
|
+
var _this = this;
|
|
3505
|
+
return __generator(this, function (_c) {
|
|
3506
|
+
if (event.target.files === null || undefined === ((_b = (_a = event.target) === null || _a === void 0 ? void 0 : _a.files) === null || _b === void 0 ? void 0 : _b[0])) {
|
|
3507
|
+
toast.error('Please upload a valid image file type (jpg, jpeg, png, gif, heic).');
|
|
3508
|
+
return [2 /*return*/];
|
|
3518
3509
|
}
|
|
3510
|
+
Object.keys(event.target.files).forEach(function (index) {
|
|
3511
|
+
(function () { return __awaiter(_this, void 0, void 0, function () {
|
|
3512
|
+
var file, fileExtension, isHeic;
|
|
3513
|
+
var _a;
|
|
3514
|
+
return __generator(this, function (_b) {
|
|
3515
|
+
switch (_b.label) {
|
|
3516
|
+
case 0:
|
|
3517
|
+
file = (_a = event.target.files) === null || _a === void 0 ? void 0 : _a[index];
|
|
3518
|
+
// loop through all files and create data url then post to postPost
|
|
3519
|
+
if (false === file.type.match('image.*')) {
|
|
3520
|
+
toast.error('Please upload a valid image file type (jpg, jpeg, png, gif, heic). (E_IMAGE_*<>' + file.type + ')');
|
|
3521
|
+
return [2 /*return*/];
|
|
3522
|
+
}
|
|
3523
|
+
fileExtension = file.name.split('.').pop();
|
|
3524
|
+
// check file extension is valid data uri
|
|
3525
|
+
if (fileExtension !== 'jpg'
|
|
3526
|
+
&& fileExtension !== 'jpeg'
|
|
3527
|
+
&& fileExtension !== 'heic'
|
|
3528
|
+
&& fileExtension !== 'png'
|
|
3529
|
+
&& fileExtension !== 'gif') {
|
|
3530
|
+
toast.error('Please upload a valid image file type (jpg, jpeg, png, gif, heic). (E_IMAGE_EXT)');
|
|
3531
|
+
return [2 /*return*/];
|
|
3532
|
+
}
|
|
3533
|
+
isHeic = fileExtension === 'heic';
|
|
3534
|
+
if (!isHeic) return [3 /*break*/, 2];
|
|
3535
|
+
return [4 /*yield*/, lazy(function () { return require("heic2any"); })];
|
|
3536
|
+
case 1:
|
|
3537
|
+
// todo - this should be code split and lazy loaded, but doesn't work
|
|
3538
|
+
// look up code splitting, it could be an issue with rewired
|
|
3539
|
+
file = (_b.sent())({
|
|
3540
|
+
blob: file,
|
|
3541
|
+
toType: "image/webp",
|
|
3542
|
+
quality: 1.0, // 0.5 cuts the quality and size by half
|
|
3543
|
+
});
|
|
3544
|
+
_b.label = 2;
|
|
3545
|
+
case 2:
|
|
3546
|
+
// @link https://github.com/palantir/tslint/issues/4653
|
|
3547
|
+
// @link https://github.com/Microsoft/TypeScript/issues/13376#issuecomment-273289748
|
|
3548
|
+
void toDataURL(URL.createObjectURL(file), 'image/webp', uploadCallback);
|
|
3549
|
+
return [2 /*return*/];
|
|
3550
|
+
}
|
|
3551
|
+
});
|
|
3552
|
+
}); })();
|
|
3553
|
+
});
|
|
3554
|
+
return [2 /*return*/];
|
|
3519
3555
|
});
|
|
3520
|
-
}
|
|
3556
|
+
});
|
|
3521
3557
|
}
|
|
3522
3558
|
// dataUriEncoded is the base64 encoded string which is posted in column post_content
|
|
3523
3559
|
function uploadImage(uploadCallback) {
|
|
@@ -3532,7 +3568,7 @@ function uploadImage(uploadCallback) {
|
|
|
3532
3568
|
// safari also requires addEventListener rather than .onChange
|
|
3533
3569
|
input.addEventListener('change', function (e) {
|
|
3534
3570
|
console.log('upload image event', e);
|
|
3535
|
-
uploadImageChange(e, uploadCallback);
|
|
3571
|
+
void uploadImageChange(e, uploadCallback);
|
|
3536
3572
|
});
|
|
3537
3573
|
input.click();
|
|
3538
3574
|
};
|
|
@@ -3557,5 +3593,5 @@ function useWindowDimensions() {
|
|
|
3557
3593
|
return windowDimensions;
|
|
3558
3594
|
}
|
|
3559
3595
|
|
|
3560
|
-
export { AccessDenied, Alert, BackendThrowable, C6, COLUMNS, CarbonReact, ErrorHttpCode, GlobalHistory, HandleResponseCodes, Loading, Nest, PageNotFound, Popup, TABLES, addAlert, addValidSQL$1 as addValidSQL, axiosInstance, carbons, changed, comments, deleteRestfulObjectArrays, documentation, eUpdateInsertMethod, feature_group_references, features, getRootStyleValue, getStyles, globalNavigate, group_references, groups, hexToRgb, history_logs, initialCarbonReactState, initialRequiredCarbonORMState, initialRestfulObjectsState, isEdgeBrowser, isProduction, location_references, locations, parseMultipleJson, photos, range, reports, ScrollIntoViewDirective as scrollIntoView, setCookies, setUrl, toDataURL,
|
|
3596
|
+
export { AccessDenied, Alert, BackendThrowable, C6, COLUMNS, CarbonReact, ErrorHttpCode, GlobalHistory, HandleResponseCodes, Loading, Nest, PageNotFound, Popup, TABLES, addAlert, addValidSQL$1 as addValidSQL, axiosInstance, carbons, changed, comments, deleteRestfulObjectArrays, documentation, eUpdateInsertMethod, feature_group_references, features, getRootStyleValue, getStyles, globalNavigate, group_references, groups, hexToRgb, history_logs, initialCarbonReactState, initialRequiredCarbonORMState, initialRestfulObjectsState, isEdgeBrowser, isProduction, location_references, locations, parseMultipleJson, photos, range, reports, ScrollIntoViewDirective as scrollIntoView, setCookies, setUrl, toDataURL, updateRestfulObjectArrays, uploadImage, uploadImageChange, user_followers, user_groups, user_messages, user_sessions, user_tasks, users, useWindowDimensions as windowDimensions };
|
|
3561
3597
|
//# sourceMappingURL=index.esm.js.map
|