@bpmn-io/form-js-viewer 1.13.0 → 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.es.js CHANGED
@@ -5434,7 +5434,7 @@ function Table(props) {
5434
5434
  key
5435
5435
  }) => key);
5436
5436
  const evaluatedDataSource = useExpressionEvaluation(dataSource);
5437
- const data = Array.isArray(evaluatedDataSource) ? evaluatedDataSource.filter(i => i !== undefined) : [];
5437
+ const data = Array.isArray(evaluatedDataSource) ? evaluatedDataSource.filter(entry => !isNil(entry) || typeof entry !== 'object') : [];
5438
5438
  const sortedData = sortBy === null ? data : sortByColumn(data, sortBy.key, sortBy.direction);
5439
5439
 
5440
5440
  /** @type {unknown[][]} */
@@ -5444,12 +5444,6 @@ function Table(props) {
5444
5444
  useEffect(() => {
5445
5445
  setCurrentPage(0);
5446
5446
  }, [rowCount, sortBy]);
5447
- const serializeCellData = cellData => {
5448
- if (cellData !== null && typeof cellData === 'object') {
5449
- return JSON.stringify(cellData);
5450
- }
5451
- return cellData;
5452
- };
5453
5447
 
5454
5448
  /** @param {string} key */
5455
5449
  function toggleSortBy(key) {
@@ -5720,6 +5714,17 @@ function getHeaderAriaLabel(sortBy, key, label) {
5720
5714
  return `Click to sort by ${label} ascending`;
5721
5715
  }
5722
5716
 
5717
+ /**
5718
+ * @param {unknown} cellData
5719
+ * @returns string
5720
+ */
5721
+ function serializeCellData(cellData) {
5722
+ if (cellData !== null && typeof cellData === 'object') {
5723
+ return JSON.stringify(cellData);
5724
+ }
5725
+ return `${cellData || ''}`;
5726
+ }
5727
+
5723
5728
  const FILE_PICKER_FILE_KEY_PREFIX = 'files::';
5724
5729
 
5725
5730
  const type$1 = 'filepicker';
@@ -5900,6 +5905,7 @@ const type = 'documentPreview';
5900
5905
  /**
5901
5906
  * @typedef DocumentMetadata
5902
5907
  * @property {string} documentId
5908
+ * @property {string} contentHash
5903
5909
  * @property {Object} metadata
5904
5910
  * @property {string|undefined} [metadata.contentType]
5905
5911
  * @property {string} metadata.fileName
@@ -6059,7 +6065,11 @@ function DocumentRenderer(props) {
6059
6065
  const [hasError, setHasError] = useState(false);
6060
6066
  const ref = useRef(null);
6061
6067
  const isInViewport = useInViewport(ref);
6062
- const fullUrl = endpoint.replace(DOCUMENT_ID_PLACEHOLDER, documentMetadata.documentId);
6068
+ const fullUrl = buildUrl({
6069
+ baseUrl: endpoint,
6070
+ documentId: documentMetadata.documentId,
6071
+ contentHash: documentMetadata.contentHash
6072
+ });
6063
6073
  const singleDocumentContainerClassName = `fjs-${type}-single-document-container`;
6064
6074
  const errorMessageId = `${domId}-error-message`;
6065
6075
  const errorMessage = 'Unable to download document';
@@ -6169,12 +6179,16 @@ function DownloadButton(props) {
6169
6179
 
6170
6180
  /**
6171
6181
  *
6172
- * @param {import("preact").RefObject<HTMLElement>} ref
6182
+ * @param {import("preact").RefObject<HTMLElement|null>} ref
6173
6183
  * @returns boolean
6174
6184
  */
6175
6185
  function useInViewport(ref) {
6176
6186
  const [isInViewport, setIsInViewport] = useState(false);
6177
6187
  useEffect(() => {
6188
+ const container = ref.current;
6189
+ if (!container) {
6190
+ return;
6191
+ }
6178
6192
  const observer = new IntersectionObserver(([entry]) => {
6179
6193
  if (entry.isIntersecting) {
6180
6194
  setIsInViewport(true);
@@ -6182,18 +6196,39 @@ function useInViewport(ref) {
6182
6196
  }, {
6183
6197
  threshold: 0
6184
6198
  });
6185
- if (ref.current) {
6186
- observer.observe(ref.current);
6187
- }
6199
+ observer.observe(container);
6188
6200
  return () => {
6189
- if (ref.current) {
6190
- observer.unobserve(ref.current);
6201
+ if (container) {
6202
+ observer.unobserve(container);
6191
6203
  }
6192
6204
  };
6193
6205
  }, [ref]);
6194
6206
  return isInViewport;
6195
6207
  }
6196
6208
 
6209
+ /**
6210
+ * This solution should be a temporary fix, we should try to remove it via: https://github.com/bpmn-io/form-js/issues/1341
6211
+ *
6212
+ * @param {Object} options
6213
+ * @param {string} options.baseUrl
6214
+ * @param {string} options.documentId
6215
+ * @param {string} [options.contentHash]
6216
+ *
6217
+ * @returns {string}
6218
+ */
6219
+ function buildUrl(options) {
6220
+ const {
6221
+ baseUrl,
6222
+ documentId,
6223
+ contentHash
6224
+ } = options;
6225
+ const finalUrl = new URL(baseUrl.replace(DOCUMENT_ID_PLACEHOLDER, documentId));
6226
+ if (contentHash !== undefined) {
6227
+ finalUrl.searchParams.set('contentHash', contentHash);
6228
+ }
6229
+ return decodeURI(finalUrl.toString());
6230
+ }
6231
+
6197
6232
  /**
6198
6233
  * This file must not be changed or exchanged.
6199
6234
  *
@@ -6332,7 +6367,7 @@ function FormComponent(props) {
6332
6367
  const formFields = [/* Input */
6333
6368
  Textfield, Textarea, Numberfield, Datetime, ExpressionField, FilePicker, /* Selection */
6334
6369
  Checkbox, Checklist, Radio, Select, Taglist, /* Presentation */
6335
- Text, Image, Table, Html, Spacer, Separator, DocumentPreview, /* Containers */
6370
+ Text, Image, Table, Html, DocumentPreview, Spacer, Separator, /* Containers */
6336
6371
  Group, DynamicList, IFrame, /* Other */
6337
6372
  Button, Default];
6338
6373