@bpmn-io/form-js-viewer 1.20.0 → 1.21.1

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
@@ -280,16 +280,38 @@ class FeelExpressionLanguage {
280
280
  * @returns {any}
281
281
  */
282
282
  evaluate(expression, data = {}) {
283
- if (!expression) {
283
+ if (!this.isExpression(expression)) {
284
+ return null;
285
+ }
286
+ try {
287
+ const {
288
+ value: result
289
+ } = feelin.evaluate(expression.slice(1), data);
290
+ return result;
291
+ } catch (error) {
292
+ this._eventBus.fire('error', {
293
+ error
294
+ });
284
295
  return null;
285
296
  }
286
- if (!minDash.isString(expression) || !expression.startsWith('=')) {
297
+ }
298
+
299
+ /**
300
+ * Evaluate a unary test expression. Returns null for invalid/missing expressions.
301
+ *
302
+ * @param {string} expression
303
+ * @param {import('../../types').Data} [data]
304
+ *
305
+ * @returns {boolean|null}
306
+ */
307
+ evaluateUnaryTest(expression, data = {}) {
308
+ if (!this.isExpression(expression)) {
287
309
  return null;
288
310
  }
289
311
  try {
290
312
  const {
291
313
  value: result
292
- } = feelin.evaluate(expression.slice(1), data);
314
+ } = feelin.unaryTest(expression.slice(1), data);
293
315
  return result;
294
316
  } catch (error) {
295
317
  this._eventBus.fire('error', {
@@ -618,6 +640,110 @@ function prefixId(id, formId, indexes) {
618
640
  return result;
619
641
  }
620
642
 
643
+ /**
644
+ * Returns the options data for the provided if they can be simply determined, ignoring expression defined options.
645
+ *
646
+ * @param {object} formField
647
+ * @param {object} formData
648
+ */
649
+ function getSimpleOptionsData(formField, formData) {
650
+ const {
651
+ valuesExpression: optionsExpression,
652
+ valuesKey: optionsKey,
653
+ values: staticOptions
654
+ } = formField;
655
+ if (optionsExpression) {
656
+ return null;
657
+ }
658
+ return optionsKey ? minDash.get(formData, [optionsKey]) : staticOptions;
659
+ }
660
+
661
+ /**
662
+ * Normalizes the provided options data to a format that can be used by the select components.
663
+ * If the options data is not valid, it is filtered out.
664
+ *
665
+ * @param {any[]} optionsData
666
+ *
667
+ * @returns {object[]}
668
+ */
669
+ function normalizeOptionsData(optionsData) {
670
+ return optionsData.filter(_isAllowedValue).map(_normalizeOption).filter(o => !minDash.isNil(o));
671
+ }
672
+
673
+ /**
674
+ * Creates an options object with default values if no options are provided.
675
+ *
676
+ * @param {object} options
677
+ *
678
+ * @returns {object}
679
+ */
680
+ function createEmptyOptions(options = {}) {
681
+ const defaults = {};
682
+
683
+ // provide default options if valuesKey and valuesExpression are not set
684
+ if (!options.valuesKey && !options.valuesExpression) {
685
+ defaults.values = [{
686
+ label: 'Value',
687
+ value: 'value'
688
+ }];
689
+ }
690
+ return {
691
+ ...defaults,
692
+ ...options
693
+ };
694
+ }
695
+
696
+ /**
697
+ * Converts the provided option to a normalized format.
698
+ * If the option is not valid, null is returned.
699
+ *
700
+ * @param {object} option
701
+ * @param {string} option.label
702
+ * @param {*} option.value
703
+ *
704
+ * @returns
705
+ */
706
+ function _normalizeOption(option) {
707
+ // (1) simple primitive case, use it as both label and value
708
+ if (_isAllowedPrimitive(option)) {
709
+ return {
710
+ value: option,
711
+ label: `${option}`
712
+ };
713
+ }
714
+ if (minDash.isObject(option)) {
715
+ const isValidLabel = _isValidLabel(option.label);
716
+
717
+ // (2) no label provided, but value is a simple primitive, use it as label and value
718
+ if (!isValidLabel && _isAllowedPrimitive(option.value)) {
719
+ return {
720
+ value: option.value,
721
+ label: `${option.value}`
722
+ };
723
+ }
724
+
725
+ // (3) both label and value are provided, use them as is
726
+ if (isValidLabel && _isAllowedValue(option.value)) {
727
+ return option;
728
+ }
729
+ }
730
+ return null;
731
+ }
732
+ function _isAllowedPrimitive(value) {
733
+ const isAllowedPrimitiveType = ['number', 'string', 'boolean'].includes(typeof value);
734
+ const isValid = value || value === 0 || value === false;
735
+ return isAllowedPrimitiveType && isValid;
736
+ }
737
+ function _isValidLabel(label) {
738
+ return label && minDash.isString(label);
739
+ }
740
+ function _isAllowedValue(value) {
741
+ if (minDash.isObject(value)) {
742
+ return Object.keys(value).length > 0;
743
+ }
744
+ return _isAllowedPrimitive(value);
745
+ }
746
+
621
747
  const FormRenderContext = preact.createContext({
622
748
  Empty: props => {
623
749
  return null;
@@ -658,7 +784,8 @@ const FormRenderContext = preact.createContext({
658
784
  },
659
785
  hoverInfo: {
660
786
  cleanup: () => {}
661
- }
787
+ },
788
+ applyVisibilityConditions: true
662
789
  });
663
790
 
664
791
  const LocalExpressionContext = preact.createContext({
@@ -766,135 +893,29 @@ function buildExpressionContext(context) {
766
893
  /**
767
894
  * If the value is a valid expression, it is evaluated and returned. Otherwise, it is returned as-is.
768
895
  *
769
- * @param {any} expressionLanguage - The expression language to use.
896
+ * @param {import('../types').ExpressionLanguage} expressionLanguage - The expression language to use.
770
897
  * @param {any} value - The static value or expression to evaluate.
771
898
  * @param {Object} expressionContextInfo - The context information to use.
772
899
  * @returns {any} - Evaluated value or the original value if not an expression.
773
900
  */
774
901
  function runExpressionEvaluation(expressionLanguage, value, expressionContextInfo) {
775
- if (expressionLanguage && expressionLanguage.isExpression(value)) {
902
+ if (expressionLanguage.isExpression(value)) {
776
903
  return expressionLanguage.evaluate(value, buildExpressionContext(expressionContextInfo));
777
904
  }
778
905
  return value;
779
906
  }
780
907
 
781
908
  /**
782
- * Evaluate if condition is met reactively based on the conditionChecker and form data.
783
- *
784
- * @param {string | undefined} condition
785
- *
786
- * @returns {boolean} true if condition is met or no condition or condition checker exists
787
- */
788
- function useCondition(condition) {
789
- const conditionChecker = useService('conditionChecker', false);
790
- const expressionContextInfo = hooks.useContext(LocalExpressionContext);
791
- return hooks.useMemo(() => {
792
- return conditionChecker ? conditionChecker.check(condition, buildExpressionContext(expressionContextInfo)) : null;
793
- }, [conditionChecker, condition, expressionContextInfo]);
794
- }
795
-
796
- /**
797
- * Returns the options data for the provided if they can be simply determined, ignoring expression defined options.
798
- *
799
- * @param {object} formField
800
- * @param {object} formData
801
- */
802
- function getSimpleOptionsData(formField, formData) {
803
- const {
804
- valuesExpression: optionsExpression,
805
- valuesKey: optionsKey,
806
- values: staticOptions
807
- } = formField;
808
- if (optionsExpression) {
809
- return null;
810
- }
811
- return optionsKey ? minDash.get(formData, [optionsKey]) : staticOptions;
812
- }
813
-
814
- /**
815
- * Normalizes the provided options data to a format that can be used by the select components.
816
- * If the options data is not valid, it is filtered out.
817
- *
818
- * @param {any[]} optionsData
819
- *
820
- * @returns {object[]}
821
- */
822
- function normalizeOptionsData(optionsData) {
823
- return optionsData.filter(_isAllowedValue).map(_normalizeOption).filter(o => !minDash.isNil(o));
824
- }
825
-
826
- /**
827
- * Creates an options object with default values if no options are provided.
828
- *
829
- * @param {object} options
830
- *
831
- * @returns {object}
832
- */
833
- function createEmptyOptions(options = {}) {
834
- const defaults = {};
835
-
836
- // provide default options if valuesKey and valuesExpression are not set
837
- if (!options.valuesKey && !options.valuesExpression) {
838
- defaults.values = [{
839
- label: 'Value',
840
- value: 'value'
841
- }];
842
- }
843
- return {
844
- ...defaults,
845
- ...options
846
- };
847
- }
848
-
849
- /**
850
- * Converts the provided option to a normalized format.
851
- * If the option is not valid, null is returned.
852
- *
853
- * @param {object} option
854
- * @param {string} option.label
855
- * @param {*} option.value
909
+ * Evaluate a value as a unary test expression. Returns null for invalid/missing expressions or
910
+ * if the expression language is not available.
856
911
  *
857
- * @returns
912
+ * @param {import('../types').ExpressionLanguage} expressionLanguage - The expression language to use.
913
+ * @param {string} value - The unary test expression to evaluate.
914
+ * @param {Object} expressionContextInfo - The context information to use.
915
+ * @returns {boolean | null} - Evaluated result, or null if expression is invalid/missing.
858
916
  */
859
- function _normalizeOption(option) {
860
- // (1) simple primitive case, use it as both label and value
861
- if (_isAllowedPrimitive(option)) {
862
- return {
863
- value: option,
864
- label: `${option}`
865
- };
866
- }
867
- if (minDash.isObject(option)) {
868
- const isValidLabel = _isValidLabel(option.label);
869
-
870
- // (2) no label provided, but value is a simple primitive, use it as label and value
871
- if (!isValidLabel && _isAllowedPrimitive(option.value)) {
872
- return {
873
- value: option.value,
874
- label: `${option.value}`
875
- };
876
- }
877
-
878
- // (3) both label and value are provided, use them as is
879
- if (isValidLabel && _isAllowedValue(option.value)) {
880
- return option;
881
- }
882
- }
883
- return null;
884
- }
885
- function _isAllowedPrimitive(value) {
886
- const isAllowedPrimitiveType = ['number', 'string', 'boolean'].includes(typeof value);
887
- const isValid = value || value === 0 || value === false;
888
- return isAllowedPrimitiveType && isValid;
889
- }
890
- function _isValidLabel(label) {
891
- return label && minDash.isString(label);
892
- }
893
- function _isAllowedValue(value) {
894
- if (minDash.isObject(value)) {
895
- return Object.keys(value).length > 0;
896
- }
897
- return _isAllowedPrimitive(value);
917
+ function runUnaryTestEvaluation(expressionLanguage, value, expressionContextInfo) {
918
+ return expressionLanguage.evaluateUnaryTest(value, buildExpressionContext(expressionContextInfo));
898
919
  }
899
920
 
900
921
  /**
@@ -1228,6 +1249,19 @@ function useBooleanExpressionEvaluation(value) {
1228
1249
  }, [expressionLanguage, expressionContextInfo, value]);
1229
1250
  }
1230
1251
 
1252
+ /**
1253
+ * Evaluate a unary test expression reactively. Returns null for invalid/missing expressions.
1254
+ * The function is memoized to minimize re-renders.
1255
+ *
1256
+ * @param {string | undefined} value - A unary test expression to evaluate.
1257
+ * @returns {boolean | null} - Evaluated result, or null if expression is invalid/missing.
1258
+ */
1259
+ function useUnaryTestEvaluation(value) {
1260
+ const expressionLanguage = useService('expressionLanguage');
1261
+ const expressionContextInfo = hooks.useContext(LocalExpressionContext);
1262
+ return hooks.useMemo(() => runUnaryTestEvaluation(expressionLanguage, value, expressionContextInfo), [expressionLanguage, expressionContextInfo, value]);
1263
+ }
1264
+
1231
1265
  /**
1232
1266
  * Returns the conditionally filtered data of a form reactively.
1233
1267
  * Memoised to minimize re-renders
@@ -1278,16 +1312,16 @@ function useKeyDownAction(targetKey, action, listenerElement = window) {
1278
1312
  */
1279
1313
  function useReadonly(formField, properties = {}) {
1280
1314
  const expressionLanguage = useService('expressionLanguage');
1281
- const conditionChecker = useService('conditionChecker', false);
1282
- const expressionContextInfo = hooks.useContext(LocalExpressionContext);
1283
1315
  const {
1284
1316
  readonly
1285
1317
  } = formField;
1318
+ const isExpression = expressionLanguage && expressionLanguage.isExpression(readonly);
1319
+ const evaluatedReadonly = useUnaryTestEvaluation(isExpression ? readonly : undefined);
1286
1320
  if (properties.readOnly) {
1287
1321
  return true;
1288
1322
  }
1289
- if (expressionLanguage && expressionLanguage.isExpression(readonly)) {
1290
- return conditionChecker ? conditionChecker.check(readonly, buildExpressionContext(expressionContextInfo)) : false;
1323
+ if (isExpression) {
1324
+ return evaluatedReadonly === true;
1291
1325
  }
1292
1326
  return readonly || false;
1293
1327
  }
@@ -2039,7 +2073,8 @@ function FormField(props) {
2039
2073
  const {
2040
2074
  Element,
2041
2075
  Hidden,
2042
- Column
2076
+ Column,
2077
+ applyVisibilityConditions
2043
2078
  } = hooks.useContext(FormRenderContext);
2044
2079
  const {
2045
2080
  formId
@@ -2063,7 +2098,8 @@ function FormField(props) {
2063
2098
 
2064
2099
  // add precedence: global readonly > form field disabled
2065
2100
  const disabled = !properties.readOnly && (properties.disabled || field.disabled || false);
2066
- const hidden = useCondition(field.conditional && field.conditional.hide || null);
2101
+ const conditionResult = useUnaryTestEvaluation(field.conditional && field.conditional.hide || null);
2102
+ const hidden = applyVisibilityConditions ? conditionResult : null;
2067
2103
  const instanceId = hooks.useMemo(() => {
2068
2104
  if (!formFieldInstanceRegistry) {
2069
2105
  return null;
@@ -5952,7 +5988,8 @@ const type = 'documentPreview';
5952
5988
 
5953
5989
  /**
5954
5990
  * @typedef DocumentEndpointBuilder
5955
- * @property {(document: DocumentMetadata) => string} buildUrl
5991
+ * @property {(document: DocumentMetadata) => string} [buildUrl]
5992
+ * @property {(document: DocumentMetadata) => RequestInit|undefined} [buildRequestInit]
5956
5993
  */
5957
5994
 
5958
5995
  /**
@@ -6003,13 +6040,18 @@ function DocumentPreview(props) {
6003
6040
  class: `fjs-${type}-document-container`,
6004
6041
  id: domId,
6005
6042
  children: data.map((document, index) => {
6006
- const finalEndpoint = tryCatch(() => documentEndpointBuilder?.buildUrl(document)) ?? document.endpoint;
6007
- return isValidDocumentEndpoint(finalEndpoint) ? jsxRuntime.jsx(DocumentRenderer, {
6043
+ const finalEndpoint = tryCatch(() => documentEndpointBuilder?.buildUrl?.(document)) ?? document.endpoint;
6044
+ if (!isValidDocumentEndpoint(finalEndpoint)) {
6045
+ return null;
6046
+ }
6047
+ const requestInit = getDocumentRequestInit(documentEndpointBuilder, document);
6048
+ return jsxRuntime.jsx(DocumentRenderer, {
6008
6049
  documentMetadata: document,
6009
6050
  endpoint: finalEndpoint,
6051
+ requestInit: requestInit,
6010
6052
  maxHeight: maxHeight,
6011
6053
  domId: `${domId}-${index}`
6012
- }, document.documentId) : null;
6054
+ }, document.documentId);
6013
6055
  })
6014
6056
  }), jsxRuntime.jsx(Errors, {
6015
6057
  id: errorMessageId,
@@ -6085,13 +6127,15 @@ function useValidDocumentData(dataSource) {
6085
6127
  * @param {string} props.fileName
6086
6128
  * @param {Function} props.onError
6087
6129
  * @param {string} props.errorMessageId
6130
+ * @param {RequestInit|undefined} props.requestInit
6088
6131
  * @returns {import("preact").JSX.Element}
6089
6132
  */
6090
6133
  function PdfRenderer(props) {
6091
6134
  const {
6092
6135
  url,
6093
6136
  onError,
6094
- errorMessageId
6137
+ errorMessageId,
6138
+ requestInit
6095
6139
  } = props;
6096
6140
  /** @type {ReturnType<typeof import("preact/hooks").useState<null | string>>} */
6097
6141
  const [pdfObjectUrl, setPdfObjectUrl] = hooks.useState(null);
@@ -6101,7 +6145,7 @@ function PdfRenderer(props) {
6101
6145
  let objectUrl = null;
6102
6146
  const fetchPdf = async () => {
6103
6147
  try {
6104
- const response = await fetch(url);
6148
+ const response = await fetch(url, requestInit);
6105
6149
  if (!response.ok) {
6106
6150
  setHasError(true);
6107
6151
  onError();
@@ -6121,7 +6165,7 @@ function PdfRenderer(props) {
6121
6165
  URL.revokeObjectURL(objectUrl);
6122
6166
  }
6123
6167
  };
6124
- }, [url, onError]);
6168
+ }, [url, onError, requestInit]);
6125
6169
  return jsxRuntime.jsxs(jsxRuntime.Fragment, {
6126
6170
  children: [pdfObjectUrl !== null ? jsxRuntime.jsx("embed", {
6127
6171
  src: pdfObjectUrl,
@@ -6134,12 +6178,61 @@ function PdfRenderer(props) {
6134
6178
  });
6135
6179
  }
6136
6180
 
6181
+ /**
6182
+ * @param {Object} props
6183
+ * @param {string} props.url
6184
+ * @param {string} props.alt
6185
+ * @param {Function} props.onError
6186
+ * @param {RequestInit|undefined} props.requestInit
6187
+ * @returns {import("preact").JSX.Element}
6188
+ */
6189
+ function ImageRenderer(props) {
6190
+ const {
6191
+ url,
6192
+ alt,
6193
+ onError,
6194
+ requestInit
6195
+ } = props;
6196
+ /** @type {ReturnType<typeof import("preact/hooks").useState<null | string>>} */
6197
+ const [imageObjectUrl, setImageObjectUrl] = hooks.useState(null);
6198
+ hooks.useEffect(() => {
6199
+ /** @type {null | string} */
6200
+ let objectUrl = null;
6201
+ const fetchImage = async () => {
6202
+ try {
6203
+ const response = await fetch(url, requestInit);
6204
+ if (!response.ok) {
6205
+ onError();
6206
+ return;
6207
+ }
6208
+ const blob = await response.blob();
6209
+ objectUrl = URL.createObjectURL(blob);
6210
+ setImageObjectUrl(objectUrl);
6211
+ } catch {
6212
+ onError();
6213
+ }
6214
+ };
6215
+ fetchImage();
6216
+ return () => {
6217
+ if (objectUrl) {
6218
+ URL.revokeObjectURL(objectUrl);
6219
+ }
6220
+ };
6221
+ }, [url, onError, requestInit]);
6222
+ return imageObjectUrl !== null ? jsxRuntime.jsx("img", {
6223
+ src: imageObjectUrl,
6224
+ alt: alt,
6225
+ class: `fjs-${type}-image`
6226
+ }) : null;
6227
+ }
6228
+
6137
6229
  /**
6138
6230
  *
6139
6231
  * @param {Object} props
6140
6232
  * @param {DocumentMetadata} props.documentMetadata
6141
6233
  * @param {string} props.endpoint
6142
6234
  * @param {string} props.domId
6235
+ * @param {RequestInit|undefined} props.requestInit
6143
6236
  * @param {number|undefined} props.maxHeight
6144
6237
  *
6145
6238
  * @returns {import("preact").JSX.Element}
@@ -6149,7 +6242,8 @@ function DocumentRenderer(props) {
6149
6242
  documentMetadata,
6150
6243
  endpoint,
6151
6244
  maxHeight,
6152
- domId
6245
+ domId,
6246
+ requestInit
6153
6247
  } = props;
6154
6248
  const {
6155
6249
  metadata
@@ -6168,13 +6262,15 @@ function DocumentRenderer(props) {
6168
6262
  maxHeight
6169
6263
  },
6170
6264
  "aria-describedby": hasError ? errorMessageId : undefined,
6171
- children: [jsxRuntime.jsx("img", {
6172
- src: endpoint,
6265
+ children: [jsxRuntime.jsx(ImageRenderer, {
6266
+ url: endpoint,
6173
6267
  alt: metadata.fileName,
6174
- class: `fjs-${type}-image`
6268
+ requestInit: requestInit,
6269
+ onError: () => setHasError(true)
6175
6270
  }), jsxRuntime.jsx(DownloadButton, {
6176
6271
  endpoint: endpoint,
6177
6272
  fileName: metadata.fileName,
6273
+ requestInit: requestInit,
6178
6274
  onDownloadError: () => {
6179
6275
  setHasError(true);
6180
6276
  }
@@ -6194,6 +6290,7 @@ function DocumentRenderer(props) {
6194
6290
  children: jsxRuntime.jsx(PdfRenderer, {
6195
6291
  url: endpoint,
6196
6292
  fileName: metadata.fileName,
6293
+ requestInit: requestInit,
6197
6294
  onError: () => setHasError(true),
6198
6295
  errorMessageId: errorMessageId
6199
6296
  })
@@ -6214,6 +6311,7 @@ function DocumentRenderer(props) {
6214
6311
  }), jsxRuntime.jsx(DownloadButton, {
6215
6312
  endpoint: endpoint,
6216
6313
  fileName: metadata.fileName,
6314
+ requestInit: requestInit,
6217
6315
  onDownloadError: () => {
6218
6316
  setHasError(true);
6219
6317
  }
@@ -6226,6 +6324,7 @@ function DocumentRenderer(props) {
6226
6324
  * @param {string} props.endpoint
6227
6325
  * @param {string} props.fileName
6228
6326
  * @param {Function} props.onDownloadError
6327
+ * @param {RequestInit|undefined} props.requestInit
6229
6328
  *
6230
6329
  * @returns {import("preact").JSX.Element}
6231
6330
  */
@@ -6233,11 +6332,12 @@ function DownloadButton(props) {
6233
6332
  const {
6234
6333
  endpoint,
6235
6334
  fileName,
6236
- onDownloadError
6335
+ onDownloadError,
6336
+ requestInit
6237
6337
  } = props;
6238
6338
  const handleDownload = async () => {
6239
6339
  try {
6240
- const response = await fetch(endpoint);
6340
+ const response = await fetch(endpoint, requestInit);
6241
6341
  if (!response.ok) {
6242
6342
  onDownloadError();
6243
6343
  return;
@@ -6291,6 +6391,16 @@ function useInViewport(ref) {
6291
6391
  return isInViewport;
6292
6392
  }
6293
6393
 
6394
+ /**
6395
+ * @param {DocumentEndpointBuilder | null} documentEndpointBuilder
6396
+ * @param {DocumentMetadata} document
6397
+ * @returns {RequestInit|undefined}
6398
+ */
6399
+ function getDocumentRequestInit(documentEndpointBuilder, document) {
6400
+ const requestInit = tryCatch(() => documentEndpointBuilder?.buildRequestInit?.(document));
6401
+ return requestInit !== null && typeof requestInit === 'object' ? requestInit : undefined;
6402
+ }
6403
+
6294
6404
  /**
6295
6405
  * @template T
6296
6406
  * @param {() => T} fn - Function to execute
@@ -6467,6 +6577,8 @@ const TEMPLATE_PROPERTIES = ['alt', 'appearance.prefixAdorner', 'appearance.suff
6467
6577
 
6468
6578
  /**
6469
6579
  * @typedef { import('../types').Schema } Schema
6580
+ * @typedef { import('../types').ExpressionLanguage } ExpressionLanguage
6581
+ * @typedef { import('../types').Templating } Templating
6470
6582
  */
6471
6583
 
6472
6584
  /**
@@ -6489,8 +6601,8 @@ const TEMPLATE_PROPERTIES = ['alt', 'appearance.prefixAdorner', 'appearance.suff
6489
6601
  *
6490
6602
  * @param {Schema} schema
6491
6603
  * @param {object} [options]
6492
- * @param {any} [options.expressionLanguage]
6493
- * @param {any} [options.templating]
6604
+ * @param {ExpressionLanguage} [options.expressionLanguage]
6605
+ * @param {Templating} [options.templating]
6494
6606
  * @param {any} [options.formFields]
6495
6607
  * @param {boolean} [options.inputs=true]
6496
6608
  * @param {boolean} [options.outputs=true]
@@ -6589,15 +6701,26 @@ const getAncestryList = (formFieldId, formFieldRegistry) => {
6589
6701
  return ids;
6590
6702
  };
6591
6703
 
6704
+ /**
6705
+ * @typedef { import('../../types').ExpressionLanguage } ExpressionLanguage
6706
+ */
6707
+
6592
6708
  /**
6593
6709
  * @typedef {object} Condition
6594
6710
  * @property {string} [hide]
6595
6711
  */
6596
6712
 
6597
6713
  class ConditionChecker {
6598
- constructor(formFieldRegistry, pathRegistry, eventBus) {
6714
+ /**
6715
+ * @param {Object} formFieldRegistry
6716
+ * @param {Object} pathRegistry
6717
+ * @param {ExpressionLanguage} expressionLanguage
6718
+ * @param {Object} eventBus
6719
+ */
6720
+ constructor(formFieldRegistry, pathRegistry, expressionLanguage, eventBus) {
6599
6721
  this._formFieldRegistry = formFieldRegistry;
6600
6722
  this._pathRegistry = pathRegistry;
6723
+ this._expressionLanguage = expressionLanguage;
6601
6724
  this._eventBus = eventBus;
6602
6725
  }
6603
6726
 
@@ -6720,24 +6843,7 @@ class ConditionChecker {
6720
6843
  * @returns {boolean|null}
6721
6844
  */
6722
6845
  check(condition, data = {}) {
6723
- if (!condition) {
6724
- return null;
6725
- }
6726
- if (!minDash.isString(condition) || !condition.startsWith('=')) {
6727
- return null;
6728
- }
6729
- try {
6730
- // cut off initial '='
6731
- const {
6732
- value: result
6733
- } = feelin.unaryTest(condition.slice(1), data);
6734
- return result;
6735
- } catch (error) {
6736
- this._eventBus.fire('error', {
6737
- error
6738
- });
6739
- return null;
6740
- }
6846
+ return this._expressionLanguage.evaluateUnaryTest(condition, data);
6741
6847
  }
6742
6848
 
6743
6849
  /**
@@ -6771,7 +6877,7 @@ class ConditionChecker {
6771
6877
  return Array.isArray(parentObject) && (!parentObject.length || parentObject.every(item => item === undefined));
6772
6878
  }
6773
6879
  }
6774
- ConditionChecker.$inject = ['formFieldRegistry', 'pathRegistry', 'eventBus'];
6880
+ ConditionChecker.$inject = ['formFieldRegistry', 'pathRegistry', 'expressionLanguage', 'eventBus'];
6775
6881
 
6776
6882
  const ExpressionLanguageModule = {
6777
6883
  __init__: ['expressionLanguage', 'templating', 'conditionChecker'],
@@ -8281,6 +8387,10 @@ function invokeFunction(fn, args) {
8281
8387
  return fn.apply(null, args);
8282
8388
  }
8283
8389
 
8390
+ /**
8391
+ * @typedef { import('../types').ExpressionLanguage } ExpressionLanguage
8392
+ */
8393
+
8284
8394
  const EMAIL_PATTERN = /^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/;
8285
8395
  const PHONE_PATTERN = /(\+|00)(297|93|244|1264|358|355|376|971|54|374|1684|1268|61|43|994|257|32|229|226|880|359|973|1242|387|590|375|501|1441|591|55|1246|673|975|267|236|1|61|41|56|86|225|237|243|242|682|57|269|238|506|53|5999|61|1345|357|420|49|253|1767|45|1809|1829|1849|213|593|20|291|212|34|372|251|358|679|500|33|298|691|241|44|995|44|233|350|224|590|220|245|240|30|1473|299|502|594|1671|592|852|504|385|509|36|62|44|91|246|353|98|964|354|972|39|1876|44|962|81|76|77|254|996|855|686|1869|82|383|965|856|961|231|218|1758|423|94|266|370|352|371|853|590|212|377|373|261|960|52|692|389|223|356|95|382|976|1670|258|222|1664|596|230|265|60|262|264|687|227|672|234|505|683|31|47|977|674|64|968|92|507|64|51|63|680|675|48|1787|1939|850|351|595|970|689|974|262|40|7|250|966|249|221|65|500|4779|677|232|503|378|252|508|381|211|239|597|421|386|46|268|1721|248|963|1649|235|228|66|992|690|993|670|676|1868|216|90|688|886|255|256|380|598|1|998|3906698|379|1784|58|1284|1340|84|678|681|685|967|27|260|263)(9[976]\d|8[987530]\d|6[987]\d|5[90]\d|42\d|3[875]\d|2[98654321]\d|9[8543210]|8[6421]|6[6543210]|5[87654321]|4[987654310]|3[9643210]|2[70]|7|1)\d{4,20}$/;
8286
8396
  const VALIDATE_FEEL_PROPERTIES = ['min', 'max', 'minLength', 'maxLength'];
@@ -8409,6 +8519,12 @@ function runPresetValidation(field, validation, value) {
8409
8519
  }
8410
8520
  return errors;
8411
8521
  }
8522
+
8523
+ /**
8524
+ * @param {Object} validate
8525
+ * @param {ExpressionLanguage} expressionLanguage
8526
+ * @param {Object} expressionContextInfo
8527
+ */
8412
8528
  function evaluateFEELValues(validate, expressionLanguage, expressionContextInfo) {
8413
8529
  const evaluatedValidate = {
8414
8530
  ...validate
@@ -8421,6 +8537,13 @@ function evaluateFEELValues(validate, expressionLanguage, expressionContextInfo)
8421
8537
  });
8422
8538
  return evaluatedValidate;
8423
8539
  }
8540
+
8541
+ /**
8542
+ * @param {Object} validate
8543
+ * @param {ExpressionLanguage} expressionLanguage
8544
+ * @param {Object} conditionChecker
8545
+ * @param {Object} form
8546
+ */
8424
8547
  function oldEvaluateFEELValues(validate, expressionLanguage, conditionChecker, form) {
8425
8548
  const evaluatedValidate = {
8426
8549
  ...validate
@@ -9974,6 +10097,7 @@ exports.pathParse = pathParse;
9974
10097
  exports.pathsEqual = pathsEqual;
9975
10098
  exports.runExpressionEvaluation = runExpressionEvaluation;
9976
10099
  exports.runRecursively = runRecursively;
10100
+ exports.runUnaryTestEvaluation = runUnaryTestEvaluation;
9977
10101
  exports.sanitizeDateTimePickerValue = sanitizeDateTimePickerValue;
9978
10102
  exports.sanitizeHTML = sanitizeHTML;
9979
10103
  exports.sanitizeIFrameSource = sanitizeIFrameSource;