@bpmn-io/form-js-viewer 1.13.1 → 1.13.2

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 CHANGED
@@ -5454,7 +5454,7 @@ function Table(props) {
5454
5454
  key
5455
5455
  }) => key);
5456
5456
  const evaluatedDataSource = useExpressionEvaluation(dataSource);
5457
- const data = Array.isArray(evaluatedDataSource) ? evaluatedDataSource.filter(i => i !== undefined) : [];
5457
+ const data = Array.isArray(evaluatedDataSource) ? evaluatedDataSource.filter(entry => !minDash.isNil(entry) || typeof entry !== 'object') : [];
5458
5458
  const sortedData = sortBy === null ? data : sortByColumn(data, sortBy.key, sortBy.direction);
5459
5459
 
5460
5460
  /** @type {unknown[][]} */
@@ -5464,12 +5464,6 @@ function Table(props) {
5464
5464
  hooks.useEffect(() => {
5465
5465
  setCurrentPage(0);
5466
5466
  }, [rowCount, sortBy]);
5467
- const serializeCellData = cellData => {
5468
- if (cellData !== null && typeof cellData === 'object') {
5469
- return JSON.stringify(cellData);
5470
- }
5471
- return cellData;
5472
- };
5473
5467
 
5474
5468
  /** @param {string} key */
5475
5469
  function toggleSortBy(key) {
@@ -5740,6 +5734,17 @@ function getHeaderAriaLabel(sortBy, key, label) {
5740
5734
  return `Click to sort by ${label} ascending`;
5741
5735
  }
5742
5736
 
5737
+ /**
5738
+ * @param {unknown} cellData
5739
+ * @returns string
5740
+ */
5741
+ function serializeCellData(cellData) {
5742
+ if (cellData !== null && typeof cellData === 'object') {
5743
+ return JSON.stringify(cellData);
5744
+ }
5745
+ return `${cellData || ''}`;
5746
+ }
5747
+
5743
5748
  const FILE_PICKER_FILE_KEY_PREFIX = 'files::';
5744
5749
 
5745
5750
  const type$1 = 'filepicker';
@@ -5920,6 +5925,7 @@ const type = 'documentPreview';
5920
5925
  /**
5921
5926
  * @typedef DocumentMetadata
5922
5927
  * @property {string} documentId
5928
+ * @property {string} contentHash
5923
5929
  * @property {Object} metadata
5924
5930
  * @property {string|undefined} [metadata.contentType]
5925
5931
  * @property {string} metadata.fileName
@@ -6079,7 +6085,11 @@ function DocumentRenderer(props) {
6079
6085
  const [hasError, setHasError] = hooks.useState(false);
6080
6086
  const ref = hooks.useRef(null);
6081
6087
  const isInViewport = useInViewport(ref);
6082
- const fullUrl = endpoint.replace(DOCUMENT_ID_PLACEHOLDER, documentMetadata.documentId);
6088
+ const fullUrl = buildUrl({
6089
+ baseUrl: endpoint,
6090
+ documentId: documentMetadata.documentId,
6091
+ contentHash: documentMetadata.contentHash
6092
+ });
6083
6093
  const singleDocumentContainerClassName = `fjs-${type}-single-document-container`;
6084
6094
  const errorMessageId = `${domId}-error-message`;
6085
6095
  const errorMessage = 'Unable to download document';
@@ -6189,12 +6199,16 @@ function DownloadButton(props) {
6189
6199
 
6190
6200
  /**
6191
6201
  *
6192
- * @param {import("preact").RefObject<HTMLElement>} ref
6202
+ * @param {import("preact").RefObject<HTMLElement|null>} ref
6193
6203
  * @returns boolean
6194
6204
  */
6195
6205
  function useInViewport(ref) {
6196
6206
  const [isInViewport, setIsInViewport] = hooks.useState(false);
6197
6207
  hooks.useEffect(() => {
6208
+ const container = ref.current;
6209
+ if (!container) {
6210
+ return;
6211
+ }
6198
6212
  const observer = new IntersectionObserver(([entry]) => {
6199
6213
  if (entry.isIntersecting) {
6200
6214
  setIsInViewport(true);
@@ -6202,18 +6216,39 @@ function useInViewport(ref) {
6202
6216
  }, {
6203
6217
  threshold: 0
6204
6218
  });
6205
- if (ref.current) {
6206
- observer.observe(ref.current);
6207
- }
6219
+ observer.observe(container);
6208
6220
  return () => {
6209
- if (ref.current) {
6210
- observer.unobserve(ref.current);
6221
+ if (container) {
6222
+ observer.unobserve(container);
6211
6223
  }
6212
6224
  };
6213
6225
  }, [ref]);
6214
6226
  return isInViewport;
6215
6227
  }
6216
6228
 
6229
+ /**
6230
+ * This solution should be a temporary fix, we should try to remove it via: https://github.com/bpmn-io/form-js/issues/1341
6231
+ *
6232
+ * @param {Object} options
6233
+ * @param {string} options.baseUrl
6234
+ * @param {string} options.documentId
6235
+ * @param {string} [options.contentHash]
6236
+ *
6237
+ * @returns {string}
6238
+ */
6239
+ function buildUrl(options) {
6240
+ const {
6241
+ baseUrl,
6242
+ documentId,
6243
+ contentHash
6244
+ } = options;
6245
+ const finalUrl = new URL(baseUrl.replace(DOCUMENT_ID_PLACEHOLDER, documentId));
6246
+ if (contentHash !== undefined) {
6247
+ finalUrl.searchParams.set('contentHash', contentHash);
6248
+ }
6249
+ return decodeURI(finalUrl.toString());
6250
+ }
6251
+
6217
6252
  /**
6218
6253
  * This file must not be changed or exchanged.
6219
6254
  *