@bpmn-io/form-js-viewer 1.19.0 → 1.21.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/README.md +31 -0
- package/dist/index.cjs +186 -51
- package/dist/index.cjs.map +1 -1
- package/dist/index.es.js +186 -52
- package/dist/index.es.js.map +1 -1
- package/dist/types/core/Validator.d.ts +1 -0
- package/dist/types/features/expressionLanguage/ConditionChecker.d.ts +12 -1
- package/dist/types/features/expressionLanguage/FeelExpressionLanguage.d.ts +9 -0
- package/dist/types/render/components/form-fields/DocumentPreview.d.ts +4 -2
- package/dist/types/render/hooks/index.d.ts +1 -0
- package/dist/types/render/hooks/useCondition.d.ts +3 -3
- package/dist/types/render/hooks/useUnaryTestEvaluation.d.ts +8 -0
- package/dist/types/types.d.ts +17 -0
- package/dist/types/util/expressions.d.ts +12 -2
- package/dist/types/util/getSchemaVariables.d.ts +8 -4
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -48,6 +48,37 @@ form.on('changed', 500, (event) => {
|
|
|
48
48
|
});
|
|
49
49
|
```
|
|
50
50
|
|
|
51
|
+
### Customize document preview requests
|
|
52
|
+
|
|
53
|
+
If you use the `documentPreview` field and need custom authentication for file downloads/previews,
|
|
54
|
+
you can provide a `documentEndpointBuilder` service via dependency injection.
|
|
55
|
+
|
|
56
|
+
```javascript
|
|
57
|
+
import { Form } from '@bpmn-io/form-js-viewer';
|
|
58
|
+
|
|
59
|
+
const DocumentPreviewRequestModule = {
|
|
60
|
+
documentEndpointBuilder: [
|
|
61
|
+
'value',
|
|
62
|
+
{
|
|
63
|
+
buildUrl: (document) => document.endpoint,
|
|
64
|
+
buildRequestInit: (document) => ({
|
|
65
|
+
headers: {
|
|
66
|
+
'x-document-id': document.documentId,
|
|
67
|
+
},
|
|
68
|
+
credentials: 'include',
|
|
69
|
+
}),
|
|
70
|
+
},
|
|
71
|
+
],
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
const form = new Form({
|
|
75
|
+
container: document.querySelector('#form'),
|
|
76
|
+
additionalModules: [DocumentPreviewRequestModule],
|
|
77
|
+
});
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
`buildRequestInit` is optional, used to [configure the fetch request](https://developer.mozilla.org/en-US/docs/Web/API/RequestInit). If omitted, document requests use the default `fetch(url)` behavior.
|
|
81
|
+
|
|
51
82
|
Check out [a full example](https://github.com/bpmn-io/form-js-examples).
|
|
52
83
|
|
|
53
84
|
## Styling
|
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
284
|
return null;
|
|
285
285
|
}
|
|
286
|
-
|
|
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
|
+
});
|
|
295
|
+
return null;
|
|
296
|
+
}
|
|
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.
|
|
314
|
+
} = feelin.unaryTest(expression.slice(1), data);
|
|
293
315
|
return result;
|
|
294
316
|
} catch (error) {
|
|
295
317
|
this._eventBus.fire('error', {
|
|
@@ -766,31 +788,53 @@ function buildExpressionContext(context) {
|
|
|
766
788
|
/**
|
|
767
789
|
* If the value is a valid expression, it is evaluated and returned. Otherwise, it is returned as-is.
|
|
768
790
|
*
|
|
769
|
-
* @param {
|
|
791
|
+
* @param {import('../types').ExpressionLanguage} expressionLanguage - The expression language to use.
|
|
770
792
|
* @param {any} value - The static value or expression to evaluate.
|
|
771
793
|
* @param {Object} expressionContextInfo - The context information to use.
|
|
772
794
|
* @returns {any} - Evaluated value or the original value if not an expression.
|
|
773
795
|
*/
|
|
774
796
|
function runExpressionEvaluation(expressionLanguage, value, expressionContextInfo) {
|
|
775
|
-
if (expressionLanguage
|
|
797
|
+
if (expressionLanguage.isExpression(value)) {
|
|
776
798
|
return expressionLanguage.evaluate(value, buildExpressionContext(expressionContextInfo));
|
|
777
799
|
}
|
|
778
800
|
return value;
|
|
779
801
|
}
|
|
780
802
|
|
|
781
803
|
/**
|
|
782
|
-
* Evaluate
|
|
804
|
+
* Evaluate a value as a unary test expression. Returns null for invalid/missing expressions or
|
|
805
|
+
* if the expression language is not available.
|
|
806
|
+
*
|
|
807
|
+
* @param {import('../types').ExpressionLanguage} expressionLanguage - The expression language to use.
|
|
808
|
+
* @param {string} value - The unary test expression to evaluate.
|
|
809
|
+
* @param {Object} expressionContextInfo - The context information to use.
|
|
810
|
+
* @returns {boolean | null} - Evaluated result, or null if expression is invalid/missing.
|
|
811
|
+
*/
|
|
812
|
+
function runUnaryTestEvaluation(expressionLanguage, value, expressionContextInfo) {
|
|
813
|
+
return expressionLanguage.evaluateUnaryTest(value, buildExpressionContext(expressionContextInfo));
|
|
814
|
+
}
|
|
815
|
+
|
|
816
|
+
/**
|
|
817
|
+
* Evaluate a unary test expression reactively. Returns null for invalid/missing expressions.
|
|
818
|
+
* The function is memoized to minimize re-renders.
|
|
819
|
+
*
|
|
820
|
+
* @param {string | undefined} value - A unary test expression to evaluate.
|
|
821
|
+
* @returns {boolean | null} - Evaluated result, or null if expression is invalid/missing.
|
|
822
|
+
*/
|
|
823
|
+
function useUnaryTestEvaluation(value) {
|
|
824
|
+
const expressionLanguage = useService('expressionLanguage');
|
|
825
|
+
const expressionContextInfo = hooks.useContext(LocalExpressionContext);
|
|
826
|
+
return hooks.useMemo(() => runUnaryTestEvaluation(expressionLanguage, value, expressionContextInfo), [expressionLanguage, expressionContextInfo, value]);
|
|
827
|
+
}
|
|
828
|
+
|
|
829
|
+
/**
|
|
830
|
+
* Evaluate if condition is met reactively based on the expression language and form data.
|
|
783
831
|
*
|
|
784
832
|
* @param {string | undefined} condition
|
|
785
833
|
*
|
|
786
|
-
* @returns {boolean} true if condition is met
|
|
834
|
+
* @returns {boolean | null} true if condition is met, false if not, null if no condition or expression language
|
|
787
835
|
*/
|
|
788
836
|
function useCondition(condition) {
|
|
789
|
-
|
|
790
|
-
const expressionContextInfo = hooks.useContext(LocalExpressionContext);
|
|
791
|
-
return hooks.useMemo(() => {
|
|
792
|
-
return conditionChecker ? conditionChecker.check(condition, buildExpressionContext(expressionContextInfo)) : null;
|
|
793
|
-
}, [conditionChecker, condition, expressionContextInfo]);
|
|
837
|
+
return useUnaryTestEvaluation(condition);
|
|
794
838
|
}
|
|
795
839
|
|
|
796
840
|
/**
|
|
@@ -1278,16 +1322,16 @@ function useKeyDownAction(targetKey, action, listenerElement = window) {
|
|
|
1278
1322
|
*/
|
|
1279
1323
|
function useReadonly(formField, properties = {}) {
|
|
1280
1324
|
const expressionLanguage = useService('expressionLanguage');
|
|
1281
|
-
const conditionChecker = useService('conditionChecker', false);
|
|
1282
|
-
const expressionContextInfo = hooks.useContext(LocalExpressionContext);
|
|
1283
1325
|
const {
|
|
1284
1326
|
readonly
|
|
1285
1327
|
} = formField;
|
|
1328
|
+
const isExpression = expressionLanguage && expressionLanguage.isExpression(readonly);
|
|
1329
|
+
const evaluatedReadonly = useUnaryTestEvaluation(isExpression ? readonly : undefined);
|
|
1286
1330
|
if (properties.readOnly) {
|
|
1287
1331
|
return true;
|
|
1288
1332
|
}
|
|
1289
|
-
if (
|
|
1290
|
-
return
|
|
1333
|
+
if (isExpression) {
|
|
1334
|
+
return evaluatedReadonly === true;
|
|
1291
1335
|
}
|
|
1292
1336
|
return readonly || false;
|
|
1293
1337
|
}
|
|
@@ -2516,6 +2560,9 @@ function Datepicker(props) {
|
|
|
2516
2560
|
// flatpicker logic that was lost when setting allowInput to true
|
|
2517
2561
|
instance.config.onOpen = [() => instance.calendarContainer.addEventListener('focusout', onCalendarFocusOut), () => instance.calendarContainer.addEventListener('mousedown', onCalendarMouseDown)];
|
|
2518
2562
|
instance.config.onClose = [() => instance.calendarContainer.removeEventListener('focusout', onCalendarFocusOut), () => instance.calendarContainer.removeEventListener('mousedown', onCalendarMouseDown)];
|
|
2563
|
+
return () => {
|
|
2564
|
+
instance.destroy();
|
|
2565
|
+
};
|
|
2519
2566
|
}, [disallowPassedDates]);
|
|
2520
2567
|
|
|
2521
2568
|
// onChange is updated dynamically, so not to re-render the flatpicker every time it changes
|
|
@@ -5949,7 +5996,8 @@ const type = 'documentPreview';
|
|
|
5949
5996
|
|
|
5950
5997
|
/**
|
|
5951
5998
|
* @typedef DocumentEndpointBuilder
|
|
5952
|
-
* @property {(document: DocumentMetadata) => string} buildUrl
|
|
5999
|
+
* @property {(document: DocumentMetadata) => string} [buildUrl]
|
|
6000
|
+
* @property {(document: DocumentMetadata) => RequestInit|undefined} [buildRequestInit]
|
|
5953
6001
|
*/
|
|
5954
6002
|
|
|
5955
6003
|
/**
|
|
@@ -6000,13 +6048,18 @@ function DocumentPreview(props) {
|
|
|
6000
6048
|
class: `fjs-${type}-document-container`,
|
|
6001
6049
|
id: domId,
|
|
6002
6050
|
children: data.map((document, index) => {
|
|
6003
|
-
const finalEndpoint = tryCatch(() => documentEndpointBuilder?.buildUrl(document)) ?? document.endpoint;
|
|
6004
|
-
|
|
6051
|
+
const finalEndpoint = tryCatch(() => documentEndpointBuilder?.buildUrl?.(document)) ?? document.endpoint;
|
|
6052
|
+
if (!isValidDocumentEndpoint(finalEndpoint)) {
|
|
6053
|
+
return null;
|
|
6054
|
+
}
|
|
6055
|
+
const requestInit = getDocumentRequestInit(documentEndpointBuilder, document);
|
|
6056
|
+
return jsxRuntime.jsx(DocumentRenderer, {
|
|
6005
6057
|
documentMetadata: document,
|
|
6006
6058
|
endpoint: finalEndpoint,
|
|
6059
|
+
requestInit: requestInit,
|
|
6007
6060
|
maxHeight: maxHeight,
|
|
6008
6061
|
domId: `${domId}-${index}`
|
|
6009
|
-
}, document.documentId)
|
|
6062
|
+
}, document.documentId);
|
|
6010
6063
|
})
|
|
6011
6064
|
}), jsxRuntime.jsx(Errors, {
|
|
6012
6065
|
id: errorMessageId,
|
|
@@ -6082,13 +6135,15 @@ function useValidDocumentData(dataSource) {
|
|
|
6082
6135
|
* @param {string} props.fileName
|
|
6083
6136
|
* @param {Function} props.onError
|
|
6084
6137
|
* @param {string} props.errorMessageId
|
|
6138
|
+
* @param {RequestInit|undefined} props.requestInit
|
|
6085
6139
|
* @returns {import("preact").JSX.Element}
|
|
6086
6140
|
*/
|
|
6087
6141
|
function PdfRenderer(props) {
|
|
6088
6142
|
const {
|
|
6089
6143
|
url,
|
|
6090
6144
|
onError,
|
|
6091
|
-
errorMessageId
|
|
6145
|
+
errorMessageId,
|
|
6146
|
+
requestInit
|
|
6092
6147
|
} = props;
|
|
6093
6148
|
/** @type {ReturnType<typeof import("preact/hooks").useState<null | string>>} */
|
|
6094
6149
|
const [pdfObjectUrl, setPdfObjectUrl] = hooks.useState(null);
|
|
@@ -6098,7 +6153,7 @@ function PdfRenderer(props) {
|
|
|
6098
6153
|
let objectUrl = null;
|
|
6099
6154
|
const fetchPdf = async () => {
|
|
6100
6155
|
try {
|
|
6101
|
-
const response = await fetch(url);
|
|
6156
|
+
const response = await fetch(url, requestInit);
|
|
6102
6157
|
if (!response.ok) {
|
|
6103
6158
|
setHasError(true);
|
|
6104
6159
|
onError();
|
|
@@ -6118,7 +6173,7 @@ function PdfRenderer(props) {
|
|
|
6118
6173
|
URL.revokeObjectURL(objectUrl);
|
|
6119
6174
|
}
|
|
6120
6175
|
};
|
|
6121
|
-
}, [url, onError]);
|
|
6176
|
+
}, [url, onError, requestInit]);
|
|
6122
6177
|
return jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
6123
6178
|
children: [pdfObjectUrl !== null ? jsxRuntime.jsx("embed", {
|
|
6124
6179
|
src: pdfObjectUrl,
|
|
@@ -6131,12 +6186,61 @@ function PdfRenderer(props) {
|
|
|
6131
6186
|
});
|
|
6132
6187
|
}
|
|
6133
6188
|
|
|
6189
|
+
/**
|
|
6190
|
+
* @param {Object} props
|
|
6191
|
+
* @param {string} props.url
|
|
6192
|
+
* @param {string} props.alt
|
|
6193
|
+
* @param {Function} props.onError
|
|
6194
|
+
* @param {RequestInit|undefined} props.requestInit
|
|
6195
|
+
* @returns {import("preact").JSX.Element}
|
|
6196
|
+
*/
|
|
6197
|
+
function ImageRenderer(props) {
|
|
6198
|
+
const {
|
|
6199
|
+
url,
|
|
6200
|
+
alt,
|
|
6201
|
+
onError,
|
|
6202
|
+
requestInit
|
|
6203
|
+
} = props;
|
|
6204
|
+
/** @type {ReturnType<typeof import("preact/hooks").useState<null | string>>} */
|
|
6205
|
+
const [imageObjectUrl, setImageObjectUrl] = hooks.useState(null);
|
|
6206
|
+
hooks.useEffect(() => {
|
|
6207
|
+
/** @type {null | string} */
|
|
6208
|
+
let objectUrl = null;
|
|
6209
|
+
const fetchImage = async () => {
|
|
6210
|
+
try {
|
|
6211
|
+
const response = await fetch(url, requestInit);
|
|
6212
|
+
if (!response.ok) {
|
|
6213
|
+
onError();
|
|
6214
|
+
return;
|
|
6215
|
+
}
|
|
6216
|
+
const blob = await response.blob();
|
|
6217
|
+
objectUrl = URL.createObjectURL(blob);
|
|
6218
|
+
setImageObjectUrl(objectUrl);
|
|
6219
|
+
} catch {
|
|
6220
|
+
onError();
|
|
6221
|
+
}
|
|
6222
|
+
};
|
|
6223
|
+
fetchImage();
|
|
6224
|
+
return () => {
|
|
6225
|
+
if (objectUrl) {
|
|
6226
|
+
URL.revokeObjectURL(objectUrl);
|
|
6227
|
+
}
|
|
6228
|
+
};
|
|
6229
|
+
}, [url, onError, requestInit]);
|
|
6230
|
+
return imageObjectUrl !== null ? jsxRuntime.jsx("img", {
|
|
6231
|
+
src: imageObjectUrl,
|
|
6232
|
+
alt: alt,
|
|
6233
|
+
class: `fjs-${type}-image`
|
|
6234
|
+
}) : null;
|
|
6235
|
+
}
|
|
6236
|
+
|
|
6134
6237
|
/**
|
|
6135
6238
|
*
|
|
6136
6239
|
* @param {Object} props
|
|
6137
6240
|
* @param {DocumentMetadata} props.documentMetadata
|
|
6138
6241
|
* @param {string} props.endpoint
|
|
6139
6242
|
* @param {string} props.domId
|
|
6243
|
+
* @param {RequestInit|undefined} props.requestInit
|
|
6140
6244
|
* @param {number|undefined} props.maxHeight
|
|
6141
6245
|
*
|
|
6142
6246
|
* @returns {import("preact").JSX.Element}
|
|
@@ -6146,7 +6250,8 @@ function DocumentRenderer(props) {
|
|
|
6146
6250
|
documentMetadata,
|
|
6147
6251
|
endpoint,
|
|
6148
6252
|
maxHeight,
|
|
6149
|
-
domId
|
|
6253
|
+
domId,
|
|
6254
|
+
requestInit
|
|
6150
6255
|
} = props;
|
|
6151
6256
|
const {
|
|
6152
6257
|
metadata
|
|
@@ -6165,13 +6270,15 @@ function DocumentRenderer(props) {
|
|
|
6165
6270
|
maxHeight
|
|
6166
6271
|
},
|
|
6167
6272
|
"aria-describedby": hasError ? errorMessageId : undefined,
|
|
6168
|
-
children: [jsxRuntime.jsx(
|
|
6169
|
-
|
|
6273
|
+
children: [jsxRuntime.jsx(ImageRenderer, {
|
|
6274
|
+
url: endpoint,
|
|
6170
6275
|
alt: metadata.fileName,
|
|
6171
|
-
|
|
6276
|
+
requestInit: requestInit,
|
|
6277
|
+
onError: () => setHasError(true)
|
|
6172
6278
|
}), jsxRuntime.jsx(DownloadButton, {
|
|
6173
6279
|
endpoint: endpoint,
|
|
6174
6280
|
fileName: metadata.fileName,
|
|
6281
|
+
requestInit: requestInit,
|
|
6175
6282
|
onDownloadError: () => {
|
|
6176
6283
|
setHasError(true);
|
|
6177
6284
|
}
|
|
@@ -6191,6 +6298,7 @@ function DocumentRenderer(props) {
|
|
|
6191
6298
|
children: jsxRuntime.jsx(PdfRenderer, {
|
|
6192
6299
|
url: endpoint,
|
|
6193
6300
|
fileName: metadata.fileName,
|
|
6301
|
+
requestInit: requestInit,
|
|
6194
6302
|
onError: () => setHasError(true),
|
|
6195
6303
|
errorMessageId: errorMessageId
|
|
6196
6304
|
})
|
|
@@ -6211,6 +6319,7 @@ function DocumentRenderer(props) {
|
|
|
6211
6319
|
}), jsxRuntime.jsx(DownloadButton, {
|
|
6212
6320
|
endpoint: endpoint,
|
|
6213
6321
|
fileName: metadata.fileName,
|
|
6322
|
+
requestInit: requestInit,
|
|
6214
6323
|
onDownloadError: () => {
|
|
6215
6324
|
setHasError(true);
|
|
6216
6325
|
}
|
|
@@ -6223,6 +6332,7 @@ function DocumentRenderer(props) {
|
|
|
6223
6332
|
* @param {string} props.endpoint
|
|
6224
6333
|
* @param {string} props.fileName
|
|
6225
6334
|
* @param {Function} props.onDownloadError
|
|
6335
|
+
* @param {RequestInit|undefined} props.requestInit
|
|
6226
6336
|
*
|
|
6227
6337
|
* @returns {import("preact").JSX.Element}
|
|
6228
6338
|
*/
|
|
@@ -6230,11 +6340,12 @@ function DownloadButton(props) {
|
|
|
6230
6340
|
const {
|
|
6231
6341
|
endpoint,
|
|
6232
6342
|
fileName,
|
|
6233
|
-
onDownloadError
|
|
6343
|
+
onDownloadError,
|
|
6344
|
+
requestInit
|
|
6234
6345
|
} = props;
|
|
6235
6346
|
const handleDownload = async () => {
|
|
6236
6347
|
try {
|
|
6237
|
-
const response = await fetch(endpoint);
|
|
6348
|
+
const response = await fetch(endpoint, requestInit);
|
|
6238
6349
|
if (!response.ok) {
|
|
6239
6350
|
onDownloadError();
|
|
6240
6351
|
return;
|
|
@@ -6288,6 +6399,16 @@ function useInViewport(ref) {
|
|
|
6288
6399
|
return isInViewport;
|
|
6289
6400
|
}
|
|
6290
6401
|
|
|
6402
|
+
/**
|
|
6403
|
+
* @param {DocumentEndpointBuilder | null} documentEndpointBuilder
|
|
6404
|
+
* @param {DocumentMetadata} document
|
|
6405
|
+
* @returns {RequestInit|undefined}
|
|
6406
|
+
*/
|
|
6407
|
+
function getDocumentRequestInit(documentEndpointBuilder, document) {
|
|
6408
|
+
const requestInit = tryCatch(() => documentEndpointBuilder?.buildRequestInit?.(document));
|
|
6409
|
+
return requestInit !== null && typeof requestInit === 'object' ? requestInit : undefined;
|
|
6410
|
+
}
|
|
6411
|
+
|
|
6291
6412
|
/**
|
|
6292
6413
|
* @template T
|
|
6293
6414
|
* @param {() => T} fn - Function to execute
|
|
@@ -6464,6 +6585,8 @@ const TEMPLATE_PROPERTIES = ['alt', 'appearance.prefixAdorner', 'appearance.suff
|
|
|
6464
6585
|
|
|
6465
6586
|
/**
|
|
6466
6587
|
* @typedef { import('../types').Schema } Schema
|
|
6588
|
+
* @typedef { import('../types').ExpressionLanguage } ExpressionLanguage
|
|
6589
|
+
* @typedef { import('../types').Templating } Templating
|
|
6467
6590
|
*/
|
|
6468
6591
|
|
|
6469
6592
|
/**
|
|
@@ -6486,8 +6609,8 @@ const TEMPLATE_PROPERTIES = ['alt', 'appearance.prefixAdorner', 'appearance.suff
|
|
|
6486
6609
|
*
|
|
6487
6610
|
* @param {Schema} schema
|
|
6488
6611
|
* @param {object} [options]
|
|
6489
|
-
* @param {
|
|
6490
|
-
* @param {
|
|
6612
|
+
* @param {ExpressionLanguage} [options.expressionLanguage]
|
|
6613
|
+
* @param {Templating} [options.templating]
|
|
6491
6614
|
* @param {any} [options.formFields]
|
|
6492
6615
|
* @param {boolean} [options.inputs=true]
|
|
6493
6616
|
* @param {boolean} [options.outputs=true]
|
|
@@ -6586,15 +6709,26 @@ const getAncestryList = (formFieldId, formFieldRegistry) => {
|
|
|
6586
6709
|
return ids;
|
|
6587
6710
|
};
|
|
6588
6711
|
|
|
6712
|
+
/**
|
|
6713
|
+
* @typedef { import('../../types').ExpressionLanguage } ExpressionLanguage
|
|
6714
|
+
*/
|
|
6715
|
+
|
|
6589
6716
|
/**
|
|
6590
6717
|
* @typedef {object} Condition
|
|
6591
6718
|
* @property {string} [hide]
|
|
6592
6719
|
*/
|
|
6593
6720
|
|
|
6594
6721
|
class ConditionChecker {
|
|
6595
|
-
|
|
6722
|
+
/**
|
|
6723
|
+
* @param {Object} formFieldRegistry
|
|
6724
|
+
* @param {Object} pathRegistry
|
|
6725
|
+
* @param {ExpressionLanguage} expressionLanguage
|
|
6726
|
+
* @param {Object} eventBus
|
|
6727
|
+
*/
|
|
6728
|
+
constructor(formFieldRegistry, pathRegistry, expressionLanguage, eventBus) {
|
|
6596
6729
|
this._formFieldRegistry = formFieldRegistry;
|
|
6597
6730
|
this._pathRegistry = pathRegistry;
|
|
6731
|
+
this._expressionLanguage = expressionLanguage;
|
|
6598
6732
|
this._eventBus = eventBus;
|
|
6599
6733
|
}
|
|
6600
6734
|
|
|
@@ -6717,24 +6851,7 @@ class ConditionChecker {
|
|
|
6717
6851
|
* @returns {boolean|null}
|
|
6718
6852
|
*/
|
|
6719
6853
|
check(condition, data = {}) {
|
|
6720
|
-
|
|
6721
|
-
return null;
|
|
6722
|
-
}
|
|
6723
|
-
if (!minDash.isString(condition) || !condition.startsWith('=')) {
|
|
6724
|
-
return null;
|
|
6725
|
-
}
|
|
6726
|
-
try {
|
|
6727
|
-
// cut off initial '='
|
|
6728
|
-
const {
|
|
6729
|
-
value: result
|
|
6730
|
-
} = feelin.unaryTest(condition.slice(1), data);
|
|
6731
|
-
return result;
|
|
6732
|
-
} catch (error) {
|
|
6733
|
-
this._eventBus.fire('error', {
|
|
6734
|
-
error
|
|
6735
|
-
});
|
|
6736
|
-
return null;
|
|
6737
|
-
}
|
|
6854
|
+
return this._expressionLanguage.evaluateUnaryTest(condition, data);
|
|
6738
6855
|
}
|
|
6739
6856
|
|
|
6740
6857
|
/**
|
|
@@ -6768,7 +6885,7 @@ class ConditionChecker {
|
|
|
6768
6885
|
return Array.isArray(parentObject) && (!parentObject.length || parentObject.every(item => item === undefined));
|
|
6769
6886
|
}
|
|
6770
6887
|
}
|
|
6771
|
-
ConditionChecker.$inject = ['formFieldRegistry', 'pathRegistry', 'eventBus'];
|
|
6888
|
+
ConditionChecker.$inject = ['formFieldRegistry', 'pathRegistry', 'expressionLanguage', 'eventBus'];
|
|
6772
6889
|
|
|
6773
6890
|
const ExpressionLanguageModule = {
|
|
6774
6891
|
__init__: ['expressionLanguage', 'templating', 'conditionChecker'],
|
|
@@ -8278,6 +8395,10 @@ function invokeFunction(fn, args) {
|
|
|
8278
8395
|
return fn.apply(null, args);
|
|
8279
8396
|
}
|
|
8280
8397
|
|
|
8398
|
+
/**
|
|
8399
|
+
* @typedef { import('../types').ExpressionLanguage } ExpressionLanguage
|
|
8400
|
+
*/
|
|
8401
|
+
|
|
8281
8402
|
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])?)*$/;
|
|
8282
8403
|
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}$/;
|
|
8283
8404
|
const VALIDATE_FEEL_PROPERTIES = ['min', 'max', 'minLength', 'maxLength'];
|
|
@@ -8406,6 +8527,12 @@ function runPresetValidation(field, validation, value) {
|
|
|
8406
8527
|
}
|
|
8407
8528
|
return errors;
|
|
8408
8529
|
}
|
|
8530
|
+
|
|
8531
|
+
/**
|
|
8532
|
+
* @param {Object} validate
|
|
8533
|
+
* @param {ExpressionLanguage} expressionLanguage
|
|
8534
|
+
* @param {Object} expressionContextInfo
|
|
8535
|
+
*/
|
|
8409
8536
|
function evaluateFEELValues(validate, expressionLanguage, expressionContextInfo) {
|
|
8410
8537
|
const evaluatedValidate = {
|
|
8411
8538
|
...validate
|
|
@@ -8418,6 +8545,13 @@ function evaluateFEELValues(validate, expressionLanguage, expressionContextInfo)
|
|
|
8418
8545
|
});
|
|
8419
8546
|
return evaluatedValidate;
|
|
8420
8547
|
}
|
|
8548
|
+
|
|
8549
|
+
/**
|
|
8550
|
+
* @param {Object} validate
|
|
8551
|
+
* @param {ExpressionLanguage} expressionLanguage
|
|
8552
|
+
* @param {Object} conditionChecker
|
|
8553
|
+
* @param {Object} form
|
|
8554
|
+
*/
|
|
8421
8555
|
function oldEvaluateFEELValues(validate, expressionLanguage, conditionChecker, form) {
|
|
8422
8556
|
const evaluatedValidate = {
|
|
8423
8557
|
...validate
|
|
@@ -9971,6 +10105,7 @@ exports.pathParse = pathParse;
|
|
|
9971
10105
|
exports.pathsEqual = pathsEqual;
|
|
9972
10106
|
exports.runExpressionEvaluation = runExpressionEvaluation;
|
|
9973
10107
|
exports.runRecursively = runRecursively;
|
|
10108
|
+
exports.runUnaryTestEvaluation = runUnaryTestEvaluation;
|
|
9974
10109
|
exports.sanitizeDateTimePickerValue = sanitizeDateTimePickerValue;
|
|
9975
10110
|
exports.sanitizeHTML = sanitizeHTML;
|
|
9976
10111
|
exports.sanitizeIFrameSource = sanitizeIFrameSource;
|