@abgov/jsonforms-components 2.4.5 → 2.4.6
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/index.esm.js +27 -17
- package/package.json +1 -1
package/index.esm.js
CHANGED
|
@@ -8489,7 +8489,6 @@ let _2 = t => t,
|
|
|
8489
8489
|
_t3$2,
|
|
8490
8490
|
_t4$2;
|
|
8491
8491
|
const _excluded$3 = ["data", "path", "handleChange", "uischema"];
|
|
8492
|
-
const DELAY_UPLOAD_TIMEOUT_MS = 5;
|
|
8493
8492
|
const DELAY_DELETE_TIMEOUT_MS = 5;
|
|
8494
8493
|
const FileUploaderReview = props => {
|
|
8495
8494
|
return FileUploader(Object.assign({}, props, {
|
|
@@ -8499,6 +8498,7 @@ const FileUploaderReview = props => {
|
|
|
8499
8498
|
const FileUploader = _ref => {
|
|
8500
8499
|
let {
|
|
8501
8500
|
data,
|
|
8501
|
+
path,
|
|
8502
8502
|
handleChange,
|
|
8503
8503
|
uischema
|
|
8504
8504
|
} = _ref,
|
|
@@ -8526,15 +8526,17 @@ const FileUploader = _ref => {
|
|
|
8526
8526
|
const variant = ((_d = uischema === null || uischema === void 0 ? void 0 : uischema.options) === null || _d === void 0 ? void 0 : _d.variant) || 'button';
|
|
8527
8527
|
const multiFileUploader = variant === 'dragdrop';
|
|
8528
8528
|
const [deleteHide, setDeleteHide] = useState(false);
|
|
8529
|
+
const fileListLength = fileList && ((_e = fileList[props.i18nKeyPrefix]) === null || _e === void 0 ? void 0 : _e.length) || 0;
|
|
8529
8530
|
function uploadFile(file) {
|
|
8530
8531
|
if (uploadTrigger) {
|
|
8532
|
+
if (!multiFileUploader) {
|
|
8533
|
+
const fileInList = getFile(fileListLength - 1);
|
|
8534
|
+
if (fileInList) {
|
|
8535
|
+
deleteTrigger(fileInList, propertyId);
|
|
8536
|
+
}
|
|
8537
|
+
}
|
|
8531
8538
|
uploadTrigger(file, propertyId);
|
|
8532
|
-
const handleFunction = () => {
|
|
8533
|
-
const value = ['Loading', Array.isArray(data) ? data[1] : file === null || file === void 0 ? void 0 : file.name];
|
|
8534
|
-
handleChange(propertyId, value);
|
|
8535
|
-
};
|
|
8536
8539
|
setDeleteHide(false);
|
|
8537
|
-
setTimeout(handleFunction, DELAY_UPLOAD_TIMEOUT_MS);
|
|
8538
8540
|
}
|
|
8539
8541
|
}
|
|
8540
8542
|
function downloadFile(file) {
|
|
@@ -8549,30 +8551,39 @@ const FileUploader = _ref => {
|
|
|
8549
8551
|
}
|
|
8550
8552
|
function getFileName(index) {
|
|
8551
8553
|
var _a;
|
|
8552
|
-
return
|
|
8554
|
+
return (_a = getFile(index)) === null || _a === void 0 ? void 0 : _a.filename;
|
|
8553
8555
|
}
|
|
8554
8556
|
function getFile(index) {
|
|
8555
|
-
|
|
8557
|
+
var _a;
|
|
8558
|
+
return (_a = fileList === null || fileList === void 0 ? void 0 : fileList[props.i18nKeyPrefix]) === null || _a === void 0 ? void 0 : _a[index];
|
|
8556
8559
|
}
|
|
8557
8560
|
useEffect(() => {
|
|
8558
8561
|
// UseEffect is required because not having it causes a react update error, but
|
|
8559
8562
|
// it doesn't function correctly within jsonforms unless there is a minor delay here
|
|
8560
8563
|
const delayedFunction = () => {
|
|
8561
|
-
|
|
8564
|
+
const files = [];
|
|
8565
|
+
for (let i = 0; i < fileListLength; i++) {
|
|
8566
|
+
files.push(getFile(i));
|
|
8567
|
+
}
|
|
8562
8568
|
if (fileList) {
|
|
8563
|
-
|
|
8569
|
+
const data = files.map(f => f.urn).join(';');
|
|
8570
|
+
if (data === '') {
|
|
8571
|
+
handleChange(path, undefined);
|
|
8572
|
+
} else {
|
|
8573
|
+
handleChange(path, data);
|
|
8574
|
+
}
|
|
8564
8575
|
}
|
|
8565
8576
|
};
|
|
8566
8577
|
const timeoutId = setTimeout(delayedFunction, 1);
|
|
8567
8578
|
return () => clearTimeout(timeoutId);
|
|
8568
8579
|
}, [handleChange, fileList, propertyId]);
|
|
8569
|
-
const readOnly = ((
|
|
8570
|
-
const maxFileSize = (
|
|
8571
|
-
const accept = (
|
|
8580
|
+
const readOnly = ((_g = (_f = uischema === null || uischema === void 0 ? void 0 : uischema.options) === null || _f === void 0 ? void 0 : _f.componentProps) === null || _g === void 0 ? void 0 : _g.readOnly) === true || (props === null || props === void 0 ? void 0 : props.isStepperReview) === true || user === null;
|
|
8581
|
+
const maxFileSize = (_k = (_j = (_h = uischema === null || uischema === void 0 ? void 0 : uischema.options) === null || _h === void 0 ? void 0 : _h.componentProps) === null || _j === void 0 ? void 0 : _j.maxFileSize) !== null && _k !== void 0 ? _k : '';
|
|
8582
|
+
const accept = (_o = (_m = (_l = uischema === null || uischema === void 0 ? void 0 : uischema.options) === null || _l === void 0 ? void 0 : _l.componentProps) === null || _m === void 0 ? void 0 : _m.accept) !== null && _o !== void 0 ? _o : '';
|
|
8572
8583
|
if (!enumerators) {
|
|
8573
8584
|
return jsx(Fragment, {});
|
|
8574
8585
|
}
|
|
8575
|
-
const helpText = (
|
|
8586
|
+
const helpText = (_p = uischema === null || uischema === void 0 ? void 0 : uischema.options) === null || _p === void 0 ? void 0 : _p.help;
|
|
8576
8587
|
const sentenceCaseLabel = convertToSentenceCase(label);
|
|
8577
8588
|
const DownloadFileWidget = ({
|
|
8578
8589
|
index
|
|
@@ -8580,7 +8591,7 @@ const FileUploader = _ref => {
|
|
|
8580
8591
|
var _a;
|
|
8581
8592
|
const [showFileDeleteConfirmation, setShowFileDeleteConfirmation] = useState(false);
|
|
8582
8593
|
return jsx("div", {
|
|
8583
|
-
children: readOnly
|
|
8594
|
+
children: readOnly ? jsxs(AttachmentBorderDisabled, {
|
|
8584
8595
|
children: [getFileName(index), jsx(GoAContextMenuIcon, {
|
|
8585
8596
|
testId: "download-icon",
|
|
8586
8597
|
title: "Download",
|
|
@@ -8614,7 +8625,7 @@ const FileUploader = _ref => {
|
|
|
8614
8625
|
deleteFile(getFile(index));
|
|
8615
8626
|
setDeleteHide(true);
|
|
8616
8627
|
const handleFunction = () => {
|
|
8617
|
-
handleChange(
|
|
8628
|
+
handleChange(path, undefined);
|
|
8618
8629
|
};
|
|
8619
8630
|
setTimeout(handleFunction, DELAY_DELETE_TIMEOUT_MS);
|
|
8620
8631
|
}
|
|
@@ -8622,7 +8633,6 @@ const FileUploader = _ref => {
|
|
|
8622
8633
|
})
|
|
8623
8634
|
});
|
|
8624
8635
|
};
|
|
8625
|
-
const fileListLength = fileList && ((_p = fileList[props.i18nKeyPrefix]) === null || _p === void 0 ? void 0 : _p.length) || 0;
|
|
8626
8636
|
return jsxs(FileUploaderStyle, {
|
|
8627
8637
|
className: "FileUploader",
|
|
8628
8638
|
children: [required ? jsx(GoAFormItem, {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@abgov/jsonforms-components",
|
|
3
|
-
"version": "2.4.
|
|
3
|
+
"version": "2.4.6",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"description": "Government of Alberta - React renderers for JSON Forms based on the design system.",
|
|
6
6
|
"repository": "https://github.com/GovAlta/adsp-monorepo",
|