@bpmn-io/form-js-viewer 1.14.0 → 1.14.1-alpha.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/dist/index.cjs +65 -12
- package/dist/index.cjs.map +1 -1
- package/dist/index.es.js +65 -12
- package/dist/index.es.js.map +1 -1
- package/package.json +5 -5
package/dist/index.es.js
CHANGED
|
@@ -907,7 +907,6 @@ function useDeepCompareMemoize(value) {
|
|
|
907
907
|
* @enum { String }
|
|
908
908
|
*/
|
|
909
909
|
const LOAD_STATES = {
|
|
910
|
-
LOADING: 'loading',
|
|
911
910
|
LOADED: 'loaded',
|
|
912
911
|
ERROR: 'error'
|
|
913
912
|
};
|
|
@@ -1118,6 +1117,9 @@ function _isElementScrollable(el) {
|
|
|
1118
1117
|
return (overflowY === 'auto' || overflowY === 'scroll') && el.scrollHeight > el.clientHeight;
|
|
1119
1118
|
}
|
|
1120
1119
|
|
|
1120
|
+
const EMPTY_OBJECT = {};
|
|
1121
|
+
const EMPTY_ARRAY$2 = [];
|
|
1122
|
+
|
|
1121
1123
|
/**
|
|
1122
1124
|
* Custom hook to scroll an element within a scrollable container.
|
|
1123
1125
|
*
|
|
@@ -1131,8 +1133,8 @@ function _isElementScrollable(el) {
|
|
|
1131
1133
|
* @param {Array} [flagRefs] - An array of refs that are used as flags to control when to scroll.
|
|
1132
1134
|
*/
|
|
1133
1135
|
function useScrollIntoView(scrolledElementRef, deps, scrollOptions, flagRefs) {
|
|
1134
|
-
const _scrollOptions = scrollOptions;
|
|
1135
|
-
const _flagRefs = flagRefs;
|
|
1136
|
+
const _scrollOptions = scrollOptions || EMPTY_OBJECT;
|
|
1137
|
+
const _flagRefs = flagRefs || EMPTY_ARRAY$2;
|
|
1136
1138
|
useEffect(() => {
|
|
1137
1139
|
// return early if flags are not raised, or component is not mounted
|
|
1138
1140
|
if (some(_flagRefs, ref => !ref.current) || !scrolledElementRef.current) {
|
|
@@ -6041,6 +6043,59 @@ function useValidDocumentData(dataSource) {
|
|
|
6041
6043
|
return data.filter(isValidDocument);
|
|
6042
6044
|
}
|
|
6043
6045
|
|
|
6046
|
+
/**
|
|
6047
|
+
* @param {Object} props
|
|
6048
|
+
* @param {string} props.url
|
|
6049
|
+
* @param {string} props.fileName
|
|
6050
|
+
* @param {Function} props.onError
|
|
6051
|
+
* @param {string} props.errorMessageId
|
|
6052
|
+
* @returns {import("preact").JSX.Element}
|
|
6053
|
+
*/
|
|
6054
|
+
function PdfRenderer(props) {
|
|
6055
|
+
const {
|
|
6056
|
+
url,
|
|
6057
|
+
onError,
|
|
6058
|
+
errorMessageId
|
|
6059
|
+
} = props;
|
|
6060
|
+
const [pdfObjectUrl, setPdfObjectUrl] = useState(null);
|
|
6061
|
+
const [hasError, setHasError] = useState(false);
|
|
6062
|
+
useEffect(() => {
|
|
6063
|
+
let objectUrl = null;
|
|
6064
|
+
const fetchPdf = async () => {
|
|
6065
|
+
try {
|
|
6066
|
+
const response = await fetch(url);
|
|
6067
|
+
if (!response.ok) {
|
|
6068
|
+
setHasError(true);
|
|
6069
|
+
onError();
|
|
6070
|
+
return;
|
|
6071
|
+
}
|
|
6072
|
+
const blob = await response.blob();
|
|
6073
|
+
objectUrl = URL.createObjectURL(blob);
|
|
6074
|
+
setPdfObjectUrl(objectUrl);
|
|
6075
|
+
} catch {
|
|
6076
|
+
setHasError(true);
|
|
6077
|
+
onError();
|
|
6078
|
+
}
|
|
6079
|
+
};
|
|
6080
|
+
fetchPdf();
|
|
6081
|
+
return () => {
|
|
6082
|
+
if (objectUrl) {
|
|
6083
|
+
URL.revokeObjectURL(objectUrl);
|
|
6084
|
+
}
|
|
6085
|
+
};
|
|
6086
|
+
}, [url, onError]);
|
|
6087
|
+
return jsxs(Fragment, {
|
|
6088
|
+
children: [pdfObjectUrl ? jsx("embed", {
|
|
6089
|
+
src: pdfObjectUrl,
|
|
6090
|
+
type: "application/pdf",
|
|
6091
|
+
class: `fjs-${type}-pdf-viewer`
|
|
6092
|
+
}) : null, hasError ? jsx(Errors, {
|
|
6093
|
+
id: errorMessageId,
|
|
6094
|
+
errors: ['Unable to download document']
|
|
6095
|
+
}) : null]
|
|
6096
|
+
});
|
|
6097
|
+
}
|
|
6098
|
+
|
|
6044
6099
|
/**
|
|
6045
6100
|
*
|
|
6046
6101
|
* @param {Object} props
|
|
@@ -6097,20 +6152,18 @@ function DocumentRenderer(props) {
|
|
|
6097
6152
|
});
|
|
6098
6153
|
}
|
|
6099
6154
|
if (isContentTypePresent && metadata.contentType.toLowerCase() === 'application/pdf' && isInViewport) {
|
|
6100
|
-
return
|
|
6155
|
+
return jsx("div", {
|
|
6101
6156
|
class: singleDocumentContainerClassName,
|
|
6102
6157
|
style: {
|
|
6103
6158
|
maxHeight
|
|
6104
6159
|
},
|
|
6105
6160
|
"aria-describedby": hasError ? errorMessageId : undefined,
|
|
6106
|
-
children:
|
|
6107
|
-
|
|
6108
|
-
|
|
6109
|
-
|
|
6110
|
-
|
|
6111
|
-
|
|
6112
|
-
errors: [errorMessage]
|
|
6113
|
-
}) : null]
|
|
6161
|
+
children: jsx(PdfRenderer, {
|
|
6162
|
+
url: fullUrl,
|
|
6163
|
+
fileName: metadata.fileName,
|
|
6164
|
+
onError: () => setHasError(true),
|
|
6165
|
+
errorMessageId: errorMessageId
|
|
6166
|
+
})
|
|
6114
6167
|
});
|
|
6115
6168
|
}
|
|
6116
6169
|
return jsxs("div", {
|