@bpmn-io/form-js-viewer 1.6.0 → 1.6.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/LICENSE +22 -22
- package/README.md +189 -189
- package/dist/assets/form-js-base.css +1244 -1244
- package/dist/index.cjs +569 -569
- package/dist/index.cjs.map +1 -1
- package/dist/index.es.js +569 -569
- package/dist/index.es.js.map +1 -1
- package/dist/types/types.d.ts +35 -35
- package/package.json +2 -2
package/dist/index.es.js
CHANGED
|
@@ -53,26 +53,26 @@ const getFlavouredFeelVariableNames = (feelString, feelFlavour = 'expression', o
|
|
|
53
53
|
return [...new Set(variables)];
|
|
54
54
|
};
|
|
55
55
|
|
|
56
|
-
/**
|
|
57
|
-
* Get the variable name at the specified index in a given path expression.
|
|
58
|
-
*
|
|
59
|
-
* @param {Object} root - The root node of the path expression tree.
|
|
60
|
-
* @param {number} index - The index of the variable name to retrieve.
|
|
61
|
-
* @returns {string|null} The variable name at the specified index or null if index is out of bounds.
|
|
56
|
+
/**
|
|
57
|
+
* Get the variable name at the specified index in a given path expression.
|
|
58
|
+
*
|
|
59
|
+
* @param {Object} root - The root node of the path expression tree.
|
|
60
|
+
* @param {number} index - The index of the variable name to retrieve.
|
|
61
|
+
* @returns {string|null} The variable name at the specified index or null if index is out of bounds.
|
|
62
62
|
*/
|
|
63
63
|
const _getVariableNameAtPathIndex = (root, index) => {
|
|
64
64
|
const nodes = _linearizePathExpression(root);
|
|
65
65
|
return nodes[index].variableName || null;
|
|
66
66
|
};
|
|
67
67
|
|
|
68
|
-
/**
|
|
69
|
-
* Extracts the variables which are required of the external context for a given path expression.
|
|
70
|
-
* This is done by traversing the path expression tree and keeping track of the current depth relative to the external context.
|
|
71
|
-
*
|
|
72
|
-
* @param {Object} node - The root node of the path expression tree.
|
|
73
|
-
* @param {number} initialDepth - The depth at which the root node is located in the outer context.
|
|
74
|
-
* @param {Object} specialDepthAccessors - Definitions of special keywords which represent more complex accesses of the outer context.
|
|
75
|
-
* @returns {Set} - A set containing the extracted variable names.
|
|
68
|
+
/**
|
|
69
|
+
* Extracts the variables which are required of the external context for a given path expression.
|
|
70
|
+
* This is done by traversing the path expression tree and keeping track of the current depth relative to the external context.
|
|
71
|
+
*
|
|
72
|
+
* @param {Object} node - The root node of the path expression tree.
|
|
73
|
+
* @param {number} initialDepth - The depth at which the root node is located in the outer context.
|
|
74
|
+
* @param {Object} specialDepthAccessors - Definitions of special keywords which represent more complex accesses of the outer context.
|
|
75
|
+
* @returns {Set} - A set containing the extracted variable names.
|
|
76
76
|
*/
|
|
77
77
|
const _smartExtractVariableNames = (node, initialDepth, specialDepthAccessors) => {
|
|
78
78
|
// depth info represents the previous (initialised as null) and current depth of the current accessor in the path expression
|
|
@@ -118,11 +118,11 @@ const _smartExtractVariableNames = (node, initialDepth, specialDepthAccessors) =
|
|
|
118
118
|
return new Set(extractedVariables);
|
|
119
119
|
};
|
|
120
120
|
|
|
121
|
-
/**
|
|
122
|
-
* Deconstructs a path expression tree into an array of components.
|
|
123
|
-
*
|
|
124
|
-
* @param {Object} root - The root node of the path expression tree.
|
|
125
|
-
* @returns {Array<object>} An array of components in the path expression, in the correct order.
|
|
121
|
+
/**
|
|
122
|
+
* Deconstructs a path expression tree into an array of components.
|
|
123
|
+
*
|
|
124
|
+
* @param {Object} root - The root node of the path expression tree.
|
|
125
|
+
* @returns {Array<object>} An array of components in the path expression, in the correct order.
|
|
126
126
|
*/
|
|
127
127
|
const _linearizePathExpression = root => {
|
|
128
128
|
let node = root;
|
|
@@ -141,13 +141,13 @@ const _linearizePathExpression = root => {
|
|
|
141
141
|
return parts.reverse();
|
|
142
142
|
};
|
|
143
143
|
|
|
144
|
-
/**
|
|
145
|
-
* Builds a simplified feel structure tree from the given parse tree and feel string.
|
|
146
|
-
* The nodes follow this structure: `{ name: string, children: Array, variableName?: string }`
|
|
147
|
-
*
|
|
148
|
-
* @param {Object} parseTree - The parse tree generated by a parser.
|
|
149
|
-
* @param {string} feelString - The feel string used for parsing.
|
|
150
|
-
* @returns {Object} The simplified feel structure tree.
|
|
144
|
+
/**
|
|
145
|
+
* Builds a simplified feel structure tree from the given parse tree and feel string.
|
|
146
|
+
* The nodes follow this structure: `{ name: string, children: Array, variableName?: string }`
|
|
147
|
+
*
|
|
148
|
+
* @param {Object} parseTree - The parse tree generated by a parser.
|
|
149
|
+
* @param {string} feelString - The feel string used for parsing.
|
|
150
|
+
* @returns {Object} The simplified feel structure tree.
|
|
151
151
|
*/
|
|
152
152
|
const _buildSimpleFeelStructureTree = (parseTree, feelString) => {
|
|
153
153
|
const stack = [{
|
|
@@ -173,9 +173,9 @@ const _buildSimpleFeelStructureTree = (parseTree, feelString) => {
|
|
|
173
173
|
return _extractFilterExpressions(stack[0].children[0]);
|
|
174
174
|
};
|
|
175
175
|
|
|
176
|
-
/**
|
|
177
|
-
* Restructure the tree in such a way to bring filters (which create new contexts) to the root of the tree.
|
|
178
|
-
* This is done to simplify the extraction of variables and match the context hierarchy.
|
|
176
|
+
/**
|
|
177
|
+
* Restructure the tree in such a way to bring filters (which create new contexts) to the root of the tree.
|
|
178
|
+
* This is done to simplify the extraction of variables and match the context hierarchy.
|
|
179
179
|
*/
|
|
180
180
|
const _extractFilterExpressions = tree => {
|
|
181
181
|
const flattenedExpressionTree = {
|
|
@@ -216,25 +216,25 @@ class FeelExpressionLanguage {
|
|
|
216
216
|
this._eventBus = eventBus;
|
|
217
217
|
}
|
|
218
218
|
|
|
219
|
-
/**
|
|
220
|
-
* Determines if the given value is a FEEL expression.
|
|
221
|
-
*
|
|
222
|
-
* @param {any} value
|
|
223
|
-
* @returns {boolean}
|
|
224
|
-
*
|
|
219
|
+
/**
|
|
220
|
+
* Determines if the given value is a FEEL expression.
|
|
221
|
+
*
|
|
222
|
+
* @param {any} value
|
|
223
|
+
* @returns {boolean}
|
|
224
|
+
*
|
|
225
225
|
*/
|
|
226
226
|
isExpression(value) {
|
|
227
227
|
return isString(value) && value.startsWith('=');
|
|
228
228
|
}
|
|
229
229
|
|
|
230
|
-
/**
|
|
231
|
-
* Retrieve variable names from a given FEEL expression.
|
|
232
|
-
*
|
|
233
|
-
* @param {string} expression
|
|
234
|
-
* @param {object} [options]
|
|
235
|
-
* @param {string} [options.type]
|
|
236
|
-
*
|
|
237
|
-
* @returns {string[]}
|
|
230
|
+
/**
|
|
231
|
+
* Retrieve variable names from a given FEEL expression.
|
|
232
|
+
*
|
|
233
|
+
* @param {string} expression
|
|
234
|
+
* @param {object} [options]
|
|
235
|
+
* @param {string} [options.type]
|
|
236
|
+
*
|
|
237
|
+
* @returns {string[]}
|
|
238
238
|
*/
|
|
239
239
|
getVariableNames(expression, options = {}) {
|
|
240
240
|
const {
|
|
@@ -249,13 +249,13 @@ class FeelExpressionLanguage {
|
|
|
249
249
|
return getFlavouredFeelVariableNames(expression, type);
|
|
250
250
|
}
|
|
251
251
|
|
|
252
|
-
/**
|
|
253
|
-
* Evaluate an expression.
|
|
254
|
-
*
|
|
255
|
-
* @param {string} expression
|
|
256
|
-
* @param {import('../../types').Data} [data]
|
|
257
|
-
*
|
|
258
|
-
* @returns {any}
|
|
252
|
+
/**
|
|
253
|
+
* Evaluate an expression.
|
|
254
|
+
*
|
|
255
|
+
* @param {string} expression
|
|
256
|
+
* @param {import('../../types').Data} [data]
|
|
257
|
+
*
|
|
258
|
+
* @returns {any}
|
|
259
259
|
*/
|
|
260
260
|
evaluate(expression, data = {}) {
|
|
261
261
|
if (!expression) {
|
|
@@ -280,23 +280,23 @@ FeelExpressionLanguage.$inject = ['eventBus'];
|
|
|
280
280
|
class FeelersTemplating {
|
|
281
281
|
constructor() {}
|
|
282
282
|
|
|
283
|
-
/**
|
|
284
|
-
* Determines if the given value is a feelers template.
|
|
285
|
-
*
|
|
286
|
-
* @param {any} value
|
|
287
|
-
* @returns {boolean}
|
|
288
|
-
*
|
|
283
|
+
/**
|
|
284
|
+
* Determines if the given value is a feelers template.
|
|
285
|
+
*
|
|
286
|
+
* @param {any} value
|
|
287
|
+
* @returns {boolean}
|
|
288
|
+
*
|
|
289
289
|
*/
|
|
290
290
|
isTemplate(value) {
|
|
291
291
|
return isString(value) && (value.startsWith('=') || /{{.*?}}/.test(value));
|
|
292
292
|
}
|
|
293
293
|
|
|
294
|
-
/**
|
|
295
|
-
* Retrieve variable names from a given feelers template.
|
|
296
|
-
*
|
|
297
|
-
* @param {string} template
|
|
298
|
-
*
|
|
299
|
-
* @returns {string[]}
|
|
294
|
+
/**
|
|
295
|
+
* Retrieve variable names from a given feelers template.
|
|
296
|
+
*
|
|
297
|
+
* @param {string} template
|
|
298
|
+
*
|
|
299
|
+
* @returns {string[]}
|
|
300
300
|
*/
|
|
301
301
|
getVariableNames(template) {
|
|
302
302
|
if (!this.isTemplate(template)) {
|
|
@@ -322,17 +322,17 @@ class FeelersTemplating {
|
|
|
322
322
|
}, []);
|
|
323
323
|
}
|
|
324
324
|
|
|
325
|
-
/**
|
|
326
|
-
* Evaluate a template.
|
|
327
|
-
*
|
|
328
|
-
* @param {string} template
|
|
329
|
-
* @param {Object<string, any>} context
|
|
330
|
-
* @param {Object} options
|
|
331
|
-
* @param {boolean} [options.debug = false]
|
|
332
|
-
* @param {boolean} [options.strict = false]
|
|
333
|
-
* @param {Function} [options.buildDebugString]
|
|
334
|
-
*
|
|
335
|
-
* @returns
|
|
325
|
+
/**
|
|
326
|
+
* Evaluate a template.
|
|
327
|
+
*
|
|
328
|
+
* @param {string} template
|
|
329
|
+
* @param {Object<string, any>} context
|
|
330
|
+
* @param {Object} options
|
|
331
|
+
* @param {boolean} [options.debug = false]
|
|
332
|
+
* @param {boolean} [options.strict = false]
|
|
333
|
+
* @param {Function} [options.buildDebugString]
|
|
334
|
+
*
|
|
335
|
+
* @returns
|
|
336
336
|
*/
|
|
337
337
|
evaluate(template, context = {}, options = {}) {
|
|
338
338
|
const {
|
|
@@ -347,22 +347,22 @@ class FeelersTemplating {
|
|
|
347
347
|
});
|
|
348
348
|
}
|
|
349
349
|
|
|
350
|
-
/**
|
|
351
|
-
* @typedef {Object} ExpressionWithDepth
|
|
352
|
-
* @property {number} depth - The depth of the expression in the syntax tree.
|
|
353
|
-
* @property {string} expression - The extracted expression
|
|
350
|
+
/**
|
|
351
|
+
* @typedef {Object} ExpressionWithDepth
|
|
352
|
+
* @property {number} depth - The depth of the expression in the syntax tree.
|
|
353
|
+
* @property {string} expression - The extracted expression
|
|
354
354
|
*/
|
|
355
355
|
|
|
356
|
-
/**
|
|
357
|
-
* Extracts all feel expressions in the template along with their depth in the syntax tree.
|
|
358
|
-
* The depth is incremented for child expressions of loops to account for context drilling.
|
|
359
|
-
|
|
360
|
-
* @param {string} template - A feelers template string.
|
|
361
|
-
* @returns {Array<ExpressionWithDepth>} An array of objects, each containing the depth and the extracted expression.
|
|
362
|
-
*
|
|
363
|
-
* @example
|
|
364
|
-
* const template = "Hello {{user}}, you have:{{#loop items}}\n- {{amount}} {{name}}{{/loop}}.";
|
|
365
|
-
* const extractedExpressions = _extractExpressionsWithDepth(template);
|
|
356
|
+
/**
|
|
357
|
+
* Extracts all feel expressions in the template along with their depth in the syntax tree.
|
|
358
|
+
* The depth is incremented for child expressions of loops to account for context drilling.
|
|
359
|
+
* @name extractExpressionsWithDepth
|
|
360
|
+
* @param {string} template - A feelers template string.
|
|
361
|
+
* @returns {Array<ExpressionWithDepth>} An array of objects, each containing the depth and the extracted expression.
|
|
362
|
+
*
|
|
363
|
+
* @example
|
|
364
|
+
* const template = "Hello {{user}}, you have:{{#loop items}}\n- {{amount}} {{name}}{{/loop}}.";
|
|
365
|
+
* const extractedExpressions = _extractExpressionsWithDepth(template);
|
|
366
366
|
*/
|
|
367
367
|
_extractExpressionsWithDepth(template) {
|
|
368
368
|
// build simplified feelers syntax tree
|
|
@@ -468,10 +468,10 @@ function createInjector(bootstrapModules) {
|
|
|
468
468
|
return injector;
|
|
469
469
|
}
|
|
470
470
|
|
|
471
|
-
/**
|
|
472
|
-
* @param {string?} prefix
|
|
473
|
-
*
|
|
474
|
-
* @returns Element
|
|
471
|
+
/**
|
|
472
|
+
* @param {string?} prefix
|
|
473
|
+
*
|
|
474
|
+
* @returns Element
|
|
475
475
|
*/
|
|
476
476
|
function createFormContainer(prefix = 'fjs') {
|
|
477
477
|
const container = document.createElement('div');
|
|
@@ -602,11 +602,11 @@ const LocalExpressionContext = createContext({
|
|
|
602
602
|
});
|
|
603
603
|
var LocalExpressionContext$1 = LocalExpressionContext;
|
|
604
604
|
|
|
605
|
-
/**
|
|
606
|
-
* @param {string} type
|
|
607
|
-
* @param {boolean} [strict]
|
|
608
|
-
*
|
|
609
|
-
* @returns {any}
|
|
605
|
+
/**
|
|
606
|
+
* @param {string} type
|
|
607
|
+
* @param {boolean} [strict]
|
|
608
|
+
*
|
|
609
|
+
* @returns {any}
|
|
610
610
|
*/
|
|
611
611
|
function getService(type, strict) {}
|
|
612
612
|
const FormContext = createContext({
|
|
@@ -649,21 +649,21 @@ function generateIdForType(type) {
|
|
|
649
649
|
return `${type}${generateIndexForType(type)}`;
|
|
650
650
|
}
|
|
651
651
|
|
|
652
|
-
/**
|
|
653
|
-
* @template T
|
|
654
|
-
* @param {T} data
|
|
655
|
-
* @param {(this: any, key: string, value: any) => any} [replacer]
|
|
656
|
-
* @return {T}
|
|
652
|
+
/**
|
|
653
|
+
* @template T
|
|
654
|
+
* @param {T} data
|
|
655
|
+
* @param {(this: any, key: string, value: any) => any} [replacer]
|
|
656
|
+
* @return {T}
|
|
657
657
|
*/
|
|
658
658
|
function clone(data, replacer) {
|
|
659
659
|
return JSON.parse(JSON.stringify(data, replacer));
|
|
660
660
|
}
|
|
661
661
|
|
|
662
|
-
/**
|
|
663
|
-
* Transform a LocalExpressionContext object into a usable FEEL context.
|
|
664
|
-
*
|
|
665
|
-
* @param {Object} context - The LocalExpressionContext object.
|
|
666
|
-
* @returns {Object} The usable FEEL context.
|
|
662
|
+
/**
|
|
663
|
+
* Transform a LocalExpressionContext object into a usable FEEL context.
|
|
664
|
+
*
|
|
665
|
+
* @param {Object} context - The LocalExpressionContext object.
|
|
666
|
+
* @returns {Object} The usable FEEL context.
|
|
667
667
|
*/
|
|
668
668
|
|
|
669
669
|
function buildExpressionContext(context) {
|
|
@@ -695,12 +695,12 @@ function _wrapObjectKeysWithUnderscores(obj) {
|
|
|
695
695
|
return newObj;
|
|
696
696
|
}
|
|
697
697
|
|
|
698
|
-
/**
|
|
699
|
-
* Evaluate if condition is met reactively based on the conditionChecker and form data.
|
|
700
|
-
*
|
|
701
|
-
* @param {string | undefined} condition
|
|
702
|
-
*
|
|
703
|
-
* @returns {boolean} true if condition is met or no condition or condition checker exists
|
|
698
|
+
/**
|
|
699
|
+
* Evaluate if condition is met reactively based on the conditionChecker and form data.
|
|
700
|
+
*
|
|
701
|
+
* @param {string | undefined} condition
|
|
702
|
+
*
|
|
703
|
+
* @returns {boolean} true if condition is met or no condition or condition checker exists
|
|
704
704
|
*/
|
|
705
705
|
function useCondition(condition) {
|
|
706
706
|
const conditionChecker = useService('conditionChecker', false);
|
|
@@ -710,17 +710,17 @@ function useCondition(condition) {
|
|
|
710
710
|
}, [conditionChecker, condition, expressionContextInfo]);
|
|
711
711
|
}
|
|
712
712
|
|
|
713
|
-
/**
|
|
714
|
-
* Custom hook to scroll an element into view only when it is not visible within the viewport.
|
|
715
|
-
*
|
|
716
|
-
* @param {Object} targetRef - A ref pointing to the DOM element to scroll into view.
|
|
717
|
-
* @param {Array} deps - An array of dependencies that trigger the effect.
|
|
718
|
-
* @param {Array} flagRefs - An array of refs that are used as flags to control when to scroll.
|
|
719
|
-
* @param {Object} [scrollOptions={}] - Options defining the behavior of the scrolling.
|
|
720
|
-
* @param {String} [scrollOptions.align='center'] - The alignment of the element within the viewport.
|
|
721
|
-
* @param {String} [scrollOptions.behavior='auto'] - The scrolling behavior.
|
|
722
|
-
* @param {Number} [scrollOptions.offset=0] - An offset that is added to the scroll position.
|
|
723
|
-
* @param {Boolean} [scrollOptions.scrollIfVisible=false] - Whether to scroll even if the element is visible.
|
|
713
|
+
/**
|
|
714
|
+
* Custom hook to scroll an element into view only when it is not visible within the viewport.
|
|
715
|
+
*
|
|
716
|
+
* @param {Object} targetRef - A ref pointing to the DOM element to scroll into view.
|
|
717
|
+
* @param {Array} deps - An array of dependencies that trigger the effect.
|
|
718
|
+
* @param {Array} flagRefs - An array of refs that are used as flags to control when to scroll.
|
|
719
|
+
* @param {Object} [scrollOptions={}] - Options defining the behavior of the scrolling.
|
|
720
|
+
* @param {String} [scrollOptions.align='center'] - The alignment of the element within the viewport.
|
|
721
|
+
* @param {String} [scrollOptions.behavior='auto'] - The scrolling behavior.
|
|
722
|
+
* @param {Number} [scrollOptions.offset=0] - An offset that is added to the scroll position.
|
|
723
|
+
* @param {Boolean} [scrollOptions.scrollIfVisible=false] - Whether to scroll even if the element is visible.
|
|
724
724
|
*/
|
|
725
725
|
function useScrollIntoView(targetRef, deps, scrollOptions = null, flagRefs = []) {
|
|
726
726
|
useEffect(() => {
|
|
@@ -785,13 +785,13 @@ function _getTopOffset(item, scrollContainer, options) {
|
|
|
785
785
|
return 0;
|
|
786
786
|
}
|
|
787
787
|
|
|
788
|
-
/**
|
|
789
|
-
* Evaluate a string reactively based on the expressionLanguage and form data.
|
|
790
|
-
* If the string is not an expression, it is returned as is.
|
|
791
|
-
* The function is memoized to minimize re-renders.
|
|
792
|
-
*
|
|
793
|
-
* @param {string} value - The string to evaluate.
|
|
794
|
-
* @returns {any} - Evaluated value or the original value if not an expression.
|
|
788
|
+
/**
|
|
789
|
+
* Evaluate a string reactively based on the expressionLanguage and form data.
|
|
790
|
+
* If the string is not an expression, it is returned as is.
|
|
791
|
+
* The function is memoized to minimize re-renders.
|
|
792
|
+
*
|
|
793
|
+
* @param {string} value - The string to evaluate.
|
|
794
|
+
* @returns {any} - Evaluated value or the original value if not an expression.
|
|
795
795
|
*/
|
|
796
796
|
function useExpressionEvaluation(value) {
|
|
797
797
|
const expressionLanguage = useService('expressionLanguage');
|
|
@@ -804,11 +804,11 @@ function useExpressionEvaluation(value) {
|
|
|
804
804
|
}, [expressionLanguage, expressionContextInfo, value]);
|
|
805
805
|
}
|
|
806
806
|
|
|
807
|
-
/**
|
|
808
|
-
* Returns the conditionally filtered data of a form reactively.
|
|
809
|
-
* Memoised to minimize re-renders
|
|
810
|
-
*
|
|
811
|
-
* Warning: costly operation, use with care
|
|
807
|
+
/**
|
|
808
|
+
* Returns the conditionally filtered data of a form reactively.
|
|
809
|
+
* Memoised to minimize re-renders
|
|
810
|
+
*
|
|
811
|
+
* Warning: costly operation, use with care
|
|
812
812
|
*/
|
|
813
813
|
function useFilteredFormData() {
|
|
814
814
|
const {
|
|
@@ -841,16 +841,16 @@ function useKeyDownAction(targetKey, action, listenerElement = window) {
|
|
|
841
841
|
});
|
|
842
842
|
}
|
|
843
843
|
|
|
844
|
-
/**
|
|
845
|
-
* Retrieve readonly value of a form field, given it can be an
|
|
846
|
-
* expression optionally or configured globally.
|
|
847
|
-
*
|
|
848
|
-
* @typedef { import('../../types').FormProperties } FormProperties
|
|
849
|
-
*
|
|
850
|
-
* @param {any} formField
|
|
851
|
-
* @param {FormProperties} properties
|
|
852
|
-
*
|
|
853
|
-
* @returns {boolean}
|
|
844
|
+
/**
|
|
845
|
+
* Retrieve readonly value of a form field, given it can be an
|
|
846
|
+
* expression optionally or configured globally.
|
|
847
|
+
*
|
|
848
|
+
* @typedef { import('../../types').FormProperties } FormProperties
|
|
849
|
+
*
|
|
850
|
+
* @param {any} formField
|
|
851
|
+
* @param {FormProperties} properties
|
|
852
|
+
*
|
|
853
|
+
* @returns {boolean}
|
|
854
854
|
*/
|
|
855
855
|
function useReadonly(formField, properties = {}) {
|
|
856
856
|
const expressionLanguage = useService('expressionLanguage');
|
|
@@ -874,12 +874,12 @@ function usePrevious(value, defaultValue, dependencies) {
|
|
|
874
874
|
return ref.current;
|
|
875
875
|
}
|
|
876
876
|
|
|
877
|
-
/**
|
|
878
|
-
* A custom hook to manage state changes with deep comparison.
|
|
879
|
-
*
|
|
880
|
-
* @param {any} value - The current value to manage.
|
|
881
|
-
* @param {any} defaultValue - The initial default value for the state.
|
|
882
|
-
* @returns {any} - Returns the current state.
|
|
877
|
+
/**
|
|
878
|
+
* A custom hook to manage state changes with deep comparison.
|
|
879
|
+
*
|
|
880
|
+
* @param {any} value - The current value to manage.
|
|
881
|
+
* @param {any} defaultValue - The initial default value for the state.
|
|
882
|
+
* @returns {any} - Returns the current state.
|
|
883
883
|
*/
|
|
884
884
|
function useDeepCompareState(value, defaultValue) {
|
|
885
885
|
const [state, setState] = useState(defaultValue);
|
|
@@ -899,16 +899,16 @@ function compare(a, b) {
|
|
|
899
899
|
return JSON.stringify(a) === JSON.stringify(b);
|
|
900
900
|
}
|
|
901
901
|
|
|
902
|
-
/**
|
|
903
|
-
* Template a string reactively based on form data. If the string is not a template, it is returned as is.
|
|
904
|
-
* Memoised to minimize re-renders
|
|
905
|
-
*
|
|
906
|
-
* @param {string} value
|
|
907
|
-
* @param {Object} options
|
|
908
|
-
* @param {boolean} [options.debug = false]
|
|
909
|
-
* @param {boolean} [options.strict = false]
|
|
910
|
-
* @param {Function} [options.buildDebugString]
|
|
911
|
-
*
|
|
902
|
+
/**
|
|
903
|
+
* Template a string reactively based on form data. If the string is not a template, it is returned as is.
|
|
904
|
+
* Memoised to minimize re-renders
|
|
905
|
+
*
|
|
906
|
+
* @param {string} value
|
|
907
|
+
* @param {Object} options
|
|
908
|
+
* @param {boolean} [options.debug = false]
|
|
909
|
+
* @param {boolean} [options.strict = false]
|
|
910
|
+
* @param {Function} [options.buildDebugString]
|
|
911
|
+
*
|
|
912
912
|
*/
|
|
913
913
|
function useTemplateEvaluation(value, options = {}) {
|
|
914
914
|
const templating = useService('templating');
|
|
@@ -921,17 +921,17 @@ function useTemplateEvaluation(value, options = {}) {
|
|
|
921
921
|
}, [templating, value, expressionContextInfo, options]);
|
|
922
922
|
}
|
|
923
923
|
|
|
924
|
-
/**
|
|
925
|
-
* Template a string reactively based on form data. If the string is not a template, it is returned as is.
|
|
926
|
-
* If the string contains multiple lines, only the first line is returned.
|
|
927
|
-
* Memoised to minimize re-renders
|
|
928
|
-
*
|
|
929
|
-
* @param {string} value
|
|
930
|
-
* @param {Object} [options]
|
|
931
|
-
* @param {boolean} [options.debug = false]
|
|
932
|
-
* @param {boolean} [options.strict = false]
|
|
933
|
-
* @param {Function} [options.buildDebugString]
|
|
934
|
-
*
|
|
924
|
+
/**
|
|
925
|
+
* Template a string reactively based on form data. If the string is not a template, it is returned as is.
|
|
926
|
+
* If the string contains multiple lines, only the first line is returned.
|
|
927
|
+
* Memoised to minimize re-renders
|
|
928
|
+
*
|
|
929
|
+
* @param {string} value
|
|
930
|
+
* @param {Object} [options]
|
|
931
|
+
* @param {boolean} [options.debug = false]
|
|
932
|
+
* @param {boolean} [options.strict = false]
|
|
933
|
+
* @param {Function} [options.buildDebugString]
|
|
934
|
+
*
|
|
935
935
|
*/
|
|
936
936
|
function useSingleLineTemplateEvaluation(value, options = {}) {
|
|
937
937
|
const evaluatedTemplate = useTemplateEvaluation(value, options);
|
|
@@ -1134,8 +1134,8 @@ function createEmptyOptions(options = {}) {
|
|
|
1134
1134
|
};
|
|
1135
1135
|
}
|
|
1136
1136
|
|
|
1137
|
-
/**
|
|
1138
|
-
* @enum { String }
|
|
1137
|
+
/**
|
|
1138
|
+
* @enum { String }
|
|
1139
1139
|
*/
|
|
1140
1140
|
const LOAD_STATES = {
|
|
1141
1141
|
LOADING: 'loading',
|
|
@@ -1143,17 +1143,17 @@ const LOAD_STATES = {
|
|
|
1143
1143
|
ERROR: 'error'
|
|
1144
1144
|
};
|
|
1145
1145
|
|
|
1146
|
-
/**
|
|
1147
|
-
* @typedef {Object} OptionsGetter
|
|
1148
|
-
* @property {Object[]} options - The options data
|
|
1149
|
-
* @property {(LOAD_STATES)} loadState - The options data's loading state, to use for conditional rendering
|
|
1146
|
+
/**
|
|
1147
|
+
* @typedef {Object} OptionsGetter
|
|
1148
|
+
* @property {Object[]} options - The options data
|
|
1149
|
+
* @property {(LOAD_STATES)} loadState - The options data's loading state, to use for conditional rendering
|
|
1150
1150
|
*/
|
|
1151
1151
|
|
|
1152
|
-
/**
|
|
1153
|
-
* A hook to load options for single and multiselect components.
|
|
1154
|
-
*
|
|
1155
|
-
* @param {Object} field - The form field to handle options for
|
|
1156
|
-
* @return {OptionsGetter} optionsGetter - A options getter object providing loading state and options
|
|
1152
|
+
/**
|
|
1153
|
+
* A hook to load options for single and multiselect components.
|
|
1154
|
+
*
|
|
1155
|
+
* @param {Object} field - The form field to handle options for
|
|
1156
|
+
* @return {OptionsGetter} optionsGetter - A options getter object providing loading state and options
|
|
1157
1157
|
*/
|
|
1158
1158
|
function useOptionsAsync (field) {
|
|
1159
1159
|
const {
|
|
@@ -1797,12 +1797,12 @@ FormComponent$1.config = {
|
|
|
1797
1797
|
})
|
|
1798
1798
|
};
|
|
1799
1799
|
|
|
1800
|
-
/**
|
|
1801
|
-
* Returns date format for the provided locale.
|
|
1802
|
-
* If the locale is not provided, uses the browser's locale.
|
|
1803
|
-
*
|
|
1804
|
-
* @param {string} [locale] - The locale to get date format for.
|
|
1805
|
-
* @returns {string} The date format for the locale.
|
|
1800
|
+
/**
|
|
1801
|
+
* Returns date format for the provided locale.
|
|
1802
|
+
* If the locale is not provided, uses the browser's locale.
|
|
1803
|
+
*
|
|
1804
|
+
* @param {string} [locale] - The locale to get date format for.
|
|
1805
|
+
* @returns {string} The date format for the locale.
|
|
1806
1806
|
*/
|
|
1807
1807
|
function getLocaleDateFormat(locale = 'default') {
|
|
1808
1808
|
const parts = new Intl.DateTimeFormat(locale).formatToParts(new Date(Date.UTC(2020, 5, 5)));
|
|
@@ -1821,12 +1821,12 @@ function getLocaleDateFormat(locale = 'default') {
|
|
|
1821
1821
|
}).join('');
|
|
1822
1822
|
}
|
|
1823
1823
|
|
|
1824
|
-
/**
|
|
1825
|
-
* Returns readable date format for the provided locale.
|
|
1826
|
-
* If the locale is not provided, uses the browser's locale.
|
|
1827
|
-
*
|
|
1828
|
-
* @param {string} [locale] - The locale to get readable date format for.
|
|
1829
|
-
* @returns {string} The readable date format for the locale.
|
|
1824
|
+
/**
|
|
1825
|
+
* Returns readable date format for the provided locale.
|
|
1826
|
+
* If the locale is not provided, uses the browser's locale.
|
|
1827
|
+
*
|
|
1828
|
+
* @param {string} [locale] - The locale to get readable date format for.
|
|
1829
|
+
* @returns {string} The readable date format for the locale.
|
|
1830
1830
|
*/
|
|
1831
1831
|
function getLocaleReadableDateFormat(locale) {
|
|
1832
1832
|
let format = getLocaleDateFormat(locale).toLowerCase();
|
|
@@ -1843,12 +1843,12 @@ function getLocaleReadableDateFormat(locale) {
|
|
|
1843
1843
|
return format;
|
|
1844
1844
|
}
|
|
1845
1845
|
|
|
1846
|
-
/**
|
|
1847
|
-
* Returns flatpickr config for the provided locale.
|
|
1848
|
-
* If the locale is not provided, uses the browser's locale.
|
|
1849
|
-
*
|
|
1850
|
-
* @param {string} [locale] - The locale to get flatpickr config for.
|
|
1851
|
-
* @returns {object} The flatpickr config for the locale.
|
|
1846
|
+
/**
|
|
1847
|
+
* Returns flatpickr config for the provided locale.
|
|
1848
|
+
* If the locale is not provided, uses the browser's locale.
|
|
1849
|
+
*
|
|
1850
|
+
* @param {string} [locale] - The locale to get flatpickr config for.
|
|
1851
|
+
* @returns {object} The flatpickr config for the locale.
|
|
1852
1852
|
*/
|
|
1853
1853
|
function getLocaleDateFlatpickrConfig(locale) {
|
|
1854
1854
|
return flatpickerizeDateFormat(getLocaleDateFormat(locale));
|
|
@@ -2560,10 +2560,10 @@ Datetime.config = {
|
|
|
2560
2560
|
}
|
|
2561
2561
|
};
|
|
2562
2562
|
|
|
2563
|
-
/**
|
|
2564
|
-
* This file must not be changed or exchanged.
|
|
2565
|
-
*
|
|
2566
|
-
* @see http://bpmn.io/license for more information.
|
|
2563
|
+
/**
|
|
2564
|
+
* This file must not be changed or exchanged.
|
|
2565
|
+
*
|
|
2566
|
+
* @see http://bpmn.io/license for more information.
|
|
2567
2567
|
*/
|
|
2568
2568
|
function Logo() {
|
|
2569
2569
|
return jsxs("svg", {
|
|
@@ -2749,11 +2749,11 @@ const ATTR_WHITESPACE_PATTERN = /[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u
|
|
|
2749
2749
|
|
|
2750
2750
|
const FORM_ELEMENT = document.createElement('form');
|
|
2751
2751
|
|
|
2752
|
-
/**
|
|
2753
|
-
* Sanitize a HTML string and return the cleaned, safe version.
|
|
2754
|
-
*
|
|
2755
|
-
* @param {string} html
|
|
2756
|
-
* @return {string}
|
|
2752
|
+
/**
|
|
2753
|
+
* Sanitize a HTML string and return the cleaned, safe version.
|
|
2754
|
+
*
|
|
2755
|
+
* @param {string} html
|
|
2756
|
+
* @return {string}
|
|
2757
2757
|
*/
|
|
2758
2758
|
|
|
2759
2759
|
// see https://github.com/developit/snarkdown/issues/70
|
|
@@ -2771,41 +2771,41 @@ function sanitizeHTML(html) {
|
|
|
2771
2771
|
}
|
|
2772
2772
|
}
|
|
2773
2773
|
|
|
2774
|
-
/**
|
|
2775
|
-
* Sanitizes an image source to ensure we only allow for data URI and links
|
|
2776
|
-
* that start with http(s).
|
|
2777
|
-
*
|
|
2778
|
-
* Note: Most browsers anyway do not support script execution in <img> elements.
|
|
2779
|
-
*
|
|
2780
|
-
* @param {string} src
|
|
2781
|
-
* @returns {string}
|
|
2774
|
+
/**
|
|
2775
|
+
* Sanitizes an image source to ensure we only allow for data URI and links
|
|
2776
|
+
* that start with http(s).
|
|
2777
|
+
*
|
|
2778
|
+
* Note: Most browsers anyway do not support script execution in <img> elements.
|
|
2779
|
+
*
|
|
2780
|
+
* @param {string} src
|
|
2781
|
+
* @returns {string}
|
|
2782
2782
|
*/
|
|
2783
2783
|
function sanitizeImageSource(src) {
|
|
2784
2784
|
const valid = ALLOWED_IMAGE_SRC_PATTERN.test(src);
|
|
2785
2785
|
return valid ? src : '';
|
|
2786
2786
|
}
|
|
2787
2787
|
|
|
2788
|
-
/**
|
|
2789
|
-
* Sanitizes an iframe source to ensure we only allow for links
|
|
2790
|
-
* that start with http(s).
|
|
2791
|
-
*
|
|
2792
|
-
* @param {string} src
|
|
2793
|
-
* @returns {string}
|
|
2788
|
+
/**
|
|
2789
|
+
* Sanitizes an iframe source to ensure we only allow for links
|
|
2790
|
+
* that start with http(s).
|
|
2791
|
+
*
|
|
2792
|
+
* @param {string} src
|
|
2793
|
+
* @returns {string}
|
|
2794
2794
|
*/
|
|
2795
2795
|
function sanitizeIFrameSource(src) {
|
|
2796
2796
|
const valid = ALLOWED_IFRAME_SRC_PATTERN.test(src);
|
|
2797
2797
|
return valid ? src : '';
|
|
2798
2798
|
}
|
|
2799
2799
|
|
|
2800
|
-
/**
|
|
2801
|
-
* Recursively sanitize a HTML node, potentially
|
|
2802
|
-
* removing it, its children or attributes.
|
|
2803
|
-
*
|
|
2804
|
-
* Inspired by https://github.com/developit/snarkdown/issues/70
|
|
2805
|
-
* and https://github.com/cure53/DOMPurify. Simplified
|
|
2806
|
-
* for our use-case.
|
|
2807
|
-
*
|
|
2808
|
-
* @param {Element} node
|
|
2800
|
+
/**
|
|
2801
|
+
* Recursively sanitize a HTML node, potentially
|
|
2802
|
+
* removing it, its children or attributes.
|
|
2803
|
+
*
|
|
2804
|
+
* Inspired by https://github.com/developit/snarkdown/issues/70
|
|
2805
|
+
* and https://github.com/cure53/DOMPurify. Simplified
|
|
2806
|
+
* for our use-case.
|
|
2807
|
+
*
|
|
2808
|
+
* @param {Element} node
|
|
2809
2809
|
*/
|
|
2810
2810
|
function sanitizeNode(node) {
|
|
2811
2811
|
// allow text nodes
|
|
@@ -2849,13 +2849,13 @@ function sanitizeNode(node) {
|
|
|
2849
2849
|
}
|
|
2850
2850
|
}
|
|
2851
2851
|
|
|
2852
|
-
/**
|
|
2853
|
-
* Validates attributes for validity.
|
|
2854
|
-
*
|
|
2855
|
-
* @param {string} lcTag
|
|
2856
|
-
* @param {string} lcName
|
|
2857
|
-
* @param {string} value
|
|
2858
|
-
* @return {boolean}
|
|
2852
|
+
/**
|
|
2853
|
+
* Validates attributes for validity.
|
|
2854
|
+
*
|
|
2855
|
+
* @param {string} lcTag
|
|
2856
|
+
* @param {string} lcName
|
|
2857
|
+
* @param {string} value
|
|
2858
|
+
* @return {boolean}
|
|
2859
2859
|
*/
|
|
2860
2860
|
function isValidAttribute(lcTag, lcName, value) {
|
|
2861
2861
|
// disallow most attributes based on whitelist
|
|
@@ -2918,7 +2918,7 @@ function IFrame(props) {
|
|
|
2918
2918
|
height: height,
|
|
2919
2919
|
class: "fjs-iframe",
|
|
2920
2920
|
id: prefixId(id, formId),
|
|
2921
|
-
sandbox: ""
|
|
2921
|
+
sandbox: "allow-scripts"
|
|
2922
2922
|
}), evaluatedUrl && !safeUrl && jsx(IFramePlaceholder, {
|
|
2923
2923
|
text: "External content couldn't be loaded."
|
|
2924
2924
|
})]
|
|
@@ -4525,28 +4525,28 @@ var CaretRightIcon = SvgCaretRight;
|
|
|
4525
4525
|
|
|
4526
4526
|
const type = 'table';
|
|
4527
4527
|
|
|
4528
|
-
/**
|
|
4529
|
-
* @typedef {('asc'|'desc')} Direction
|
|
4530
|
-
*
|
|
4531
|
-
* @typedef Sorting
|
|
4532
|
-
* @property {string} key
|
|
4533
|
-
* @property {Direction} direction
|
|
4534
|
-
*
|
|
4535
|
-
* @typedef Column
|
|
4536
|
-
* @property {string} label
|
|
4537
|
-
* @property {string} key
|
|
4538
|
-
*
|
|
4539
|
-
* @typedef Props
|
|
4540
|
-
* @property {Object} field
|
|
4541
|
-
* @property {string} field.id
|
|
4542
|
-
* @property {Array<Column>} [field.columns]
|
|
4543
|
-
* @property {string} [field.columnsExpression]
|
|
4544
|
-
* @property {string} [field.label]
|
|
4545
|
-
* @property {number} [field.rowCount]
|
|
4546
|
-
* @property {string} [field.dataSource]
|
|
4547
|
-
*
|
|
4548
|
-
* @param {Props} props
|
|
4549
|
-
* @returns {import("preact").JSX.Element}
|
|
4528
|
+
/**
|
|
4529
|
+
* @typedef {('asc'|'desc')} Direction
|
|
4530
|
+
*
|
|
4531
|
+
* @typedef Sorting
|
|
4532
|
+
* @property {string} key
|
|
4533
|
+
* @property {Direction} direction
|
|
4534
|
+
*
|
|
4535
|
+
* @typedef Column
|
|
4536
|
+
* @property {string} label
|
|
4537
|
+
* @property {string} key
|
|
4538
|
+
*
|
|
4539
|
+
* @typedef Props
|
|
4540
|
+
* @property {Object} field
|
|
4541
|
+
* @property {string} field.id
|
|
4542
|
+
* @property {Array<Column>} [field.columns]
|
|
4543
|
+
* @property {string} [field.columnsExpression]
|
|
4544
|
+
* @property {string} [field.label]
|
|
4545
|
+
* @property {number} [field.rowCount]
|
|
4546
|
+
* @property {string} [field.dataSource]
|
|
4547
|
+
*
|
|
4548
|
+
* @param {Props} props
|
|
4549
|
+
* @returns {import("preact").JSX.Element}
|
|
4550
4550
|
*/
|
|
4551
4551
|
function Table(props) {
|
|
4552
4552
|
const {
|
|
@@ -4756,10 +4756,10 @@ Table.config = {
|
|
|
4756
4756
|
|
|
4757
4757
|
// helpers /////////////////////////////
|
|
4758
4758
|
|
|
4759
|
-
/**
|
|
4760
|
-
* @param {string|void} columnsExpression
|
|
4761
|
-
* @param {Column[]} fallbackColumns
|
|
4762
|
-
* @returns {Column[]}
|
|
4759
|
+
/**
|
|
4760
|
+
* @param {string|void} columnsExpression
|
|
4761
|
+
* @param {Column[]} fallbackColumns
|
|
4762
|
+
* @returns {Column[]}
|
|
4763
4763
|
*/
|
|
4764
4764
|
function useEvaluatedColumns(columnsExpression, fallbackColumns) {
|
|
4765
4765
|
/** @type {Column[]|null} */
|
|
@@ -4767,18 +4767,18 @@ function useEvaluatedColumns(columnsExpression, fallbackColumns) {
|
|
|
4767
4767
|
return Array.isArray(evaluation) && evaluation.every(isColumn) ? evaluation : fallbackColumns;
|
|
4768
4768
|
}
|
|
4769
4769
|
|
|
4770
|
-
/**
|
|
4771
|
-
* @param {any} column
|
|
4772
|
-
* @returns {column is Column}
|
|
4770
|
+
/**
|
|
4771
|
+
* @param {any} column
|
|
4772
|
+
* @returns {column is Column}
|
|
4773
4773
|
*/
|
|
4774
4774
|
function isColumn(column) {
|
|
4775
4775
|
return isObject(column) && isString(column['label']) && isString(column['key']);
|
|
4776
4776
|
}
|
|
4777
4777
|
|
|
4778
|
-
/**
|
|
4779
|
-
* @param {Array} array
|
|
4780
|
-
* @param {number} size
|
|
4781
|
-
* @returns {Array}
|
|
4778
|
+
/**
|
|
4779
|
+
* @param {Array} array
|
|
4780
|
+
* @param {number} size
|
|
4781
|
+
* @returns {Array}
|
|
4782
4782
|
*/
|
|
4783
4783
|
function chunk(array, size) {
|
|
4784
4784
|
return array.reduce((chunks, item, index) => {
|
|
@@ -4791,11 +4791,11 @@ function chunk(array, size) {
|
|
|
4791
4791
|
}, []);
|
|
4792
4792
|
}
|
|
4793
4793
|
|
|
4794
|
-
/**
|
|
4795
|
-
* @param {unknown[]} array
|
|
4796
|
-
* @param {string} key
|
|
4797
|
-
* @param {Direction} direction
|
|
4798
|
-
* @returns {unknown[]}
|
|
4794
|
+
/**
|
|
4795
|
+
* @param {unknown[]} array
|
|
4796
|
+
* @param {string} key
|
|
4797
|
+
* @param {Direction} direction
|
|
4798
|
+
* @returns {unknown[]}
|
|
4799
4799
|
*/
|
|
4800
4800
|
function sortByColumn(array, key, direction) {
|
|
4801
4801
|
return [...array].sort((a, b) => {
|
|
@@ -4809,10 +4809,10 @@ function sortByColumn(array, key, direction) {
|
|
|
4809
4809
|
});
|
|
4810
4810
|
}
|
|
4811
4811
|
|
|
4812
|
-
/**
|
|
4813
|
-
* @param {null|Sorting} sortBy
|
|
4814
|
-
* @param {string} key
|
|
4815
|
-
* @param {string} label
|
|
4812
|
+
/**
|
|
4813
|
+
* @param {null|Sorting} sortBy
|
|
4814
|
+
* @param {string} key
|
|
4815
|
+
* @param {string} label
|
|
4816
4816
|
*/
|
|
4817
4817
|
function getHeaderAriaLabel(sortBy, key, label) {
|
|
4818
4818
|
if (sortBy === null || sortBy.key !== key) {
|
|
@@ -5187,37 +5187,37 @@ class FormFields {
|
|
|
5187
5187
|
const EXPRESSION_PROPERTIES = ['alt', 'appearance.prefixAdorner', 'appearance.suffixAdorner', 'conditional.hide', 'description', 'label', 'source', 'readonly', 'text', 'validate.min', 'validate.max', 'validate.minLength', 'validate.maxLength', 'valuesExpression', 'url', 'dataSource', 'columnsExpression'];
|
|
5188
5188
|
const TEMPLATE_PROPERTIES = ['alt', 'appearance.prefixAdorner', 'appearance.suffixAdorner', 'description', 'label', 'source', 'text', 'url'];
|
|
5189
5189
|
|
|
5190
|
-
/**
|
|
5191
|
-
* @typedef { import('../types').Schema } Schema
|
|
5190
|
+
/**
|
|
5191
|
+
* @typedef { import('../types').Schema } Schema
|
|
5192
5192
|
*/
|
|
5193
5193
|
|
|
5194
|
-
/**
|
|
5195
|
-
* Parse the schema for variables a form might make use of.
|
|
5196
|
-
*
|
|
5197
|
-
* @example
|
|
5198
|
-
*
|
|
5199
|
-
* // retrieve variables from schema
|
|
5200
|
-
* const variables = getSchemaVariables(schema);
|
|
5201
|
-
*
|
|
5202
|
-
* @example
|
|
5203
|
-
*
|
|
5204
|
-
* // retrieve input variables from schema
|
|
5205
|
-
* const inputVariables = getSchemaVariables(schema, { outputs: false });
|
|
5206
|
-
*
|
|
5207
|
-
* @example
|
|
5208
|
-
*
|
|
5209
|
-
* // retrieve output variables from schema
|
|
5210
|
-
* const outputVariables = getSchemaVariables(schema, { inputs: false });
|
|
5211
|
-
*
|
|
5212
|
-
* @param {Schema} schema
|
|
5213
|
-
* @param {object} [options]
|
|
5214
|
-
* @param {any} [options.expressionLanguage]
|
|
5215
|
-
* @param {any} [options.templating]
|
|
5216
|
-
* @param {any} [options.formFields]
|
|
5217
|
-
* @param {boolean} [options.inputs=true]
|
|
5218
|
-
* @param {boolean} [options.outputs=true]
|
|
5219
|
-
*
|
|
5220
|
-
* @return {string[]}
|
|
5194
|
+
/**
|
|
5195
|
+
* Parse the schema for variables a form might make use of.
|
|
5196
|
+
*
|
|
5197
|
+
* @example
|
|
5198
|
+
*
|
|
5199
|
+
* // retrieve variables from schema
|
|
5200
|
+
* const variables = getSchemaVariables(schema);
|
|
5201
|
+
*
|
|
5202
|
+
* @example
|
|
5203
|
+
*
|
|
5204
|
+
* // retrieve input variables from schema
|
|
5205
|
+
* const inputVariables = getSchemaVariables(schema, { outputs: false });
|
|
5206
|
+
*
|
|
5207
|
+
* @example
|
|
5208
|
+
*
|
|
5209
|
+
* // retrieve output variables from schema
|
|
5210
|
+
* const outputVariables = getSchemaVariables(schema, { inputs: false });
|
|
5211
|
+
*
|
|
5212
|
+
* @param {Schema} schema
|
|
5213
|
+
* @param {object} [options]
|
|
5214
|
+
* @param {any} [options.expressionLanguage]
|
|
5215
|
+
* @param {any} [options.templating]
|
|
5216
|
+
* @param {any} [options.formFields]
|
|
5217
|
+
* @param {boolean} [options.inputs=true]
|
|
5218
|
+
* @param {boolean} [options.outputs=true]
|
|
5219
|
+
*
|
|
5220
|
+
* @return {string[]}
|
|
5221
5221
|
*/
|
|
5222
5222
|
function getSchemaVariables(schema, options = {}) {
|
|
5223
5223
|
const {
|
|
@@ -5293,13 +5293,13 @@ function getSchemaVariables(schema, options = {}) {
|
|
|
5293
5293
|
return Array.from(new Set(variables));
|
|
5294
5294
|
}
|
|
5295
5295
|
|
|
5296
|
-
/**
|
|
5297
|
-
* Get the ancestry list of a form field.
|
|
5298
|
-
*
|
|
5299
|
-
* @param {string} formFieldId
|
|
5300
|
-
* @param {import('../core/FormFieldRegistry').default} formFieldRegistry
|
|
5301
|
-
*
|
|
5302
|
-
* @return {Array<string>} ancestry list
|
|
5296
|
+
/**
|
|
5297
|
+
* Get the ancestry list of a form field.
|
|
5298
|
+
*
|
|
5299
|
+
* @param {string} formFieldId
|
|
5300
|
+
* @param {import('../core/FormFieldRegistry').default} formFieldRegistry
|
|
5301
|
+
*
|
|
5302
|
+
* @return {Array<string>} ancestry list
|
|
5303
5303
|
*/
|
|
5304
5304
|
const getAncestryList = (formFieldId, formFieldRegistry) => {
|
|
5305
5305
|
const ids = [];
|
|
@@ -5311,9 +5311,9 @@ const getAncestryList = (formFieldId, formFieldRegistry) => {
|
|
|
5311
5311
|
return ids;
|
|
5312
5312
|
};
|
|
5313
5313
|
|
|
5314
|
-
/**
|
|
5315
|
-
* @typedef {object} Condition
|
|
5316
|
-
* @property {string} [hide]
|
|
5314
|
+
/**
|
|
5315
|
+
* @typedef {object} Condition
|
|
5316
|
+
* @property {string} [hide]
|
|
5317
5317
|
*/
|
|
5318
5318
|
|
|
5319
5319
|
class ConditionChecker {
|
|
@@ -5323,14 +5323,14 @@ class ConditionChecker {
|
|
|
5323
5323
|
this._eventBus = eventBus;
|
|
5324
5324
|
}
|
|
5325
5325
|
|
|
5326
|
-
/**
|
|
5327
|
-
* For given data, remove properties based on condition.
|
|
5328
|
-
*
|
|
5329
|
-
* @param {Object<string, any>} data
|
|
5330
|
-
* @param {Object<string, any>} contextData
|
|
5331
|
-
* @param {Object} [options]
|
|
5332
|
-
* @param {Function} [options.getFilterPath]
|
|
5333
|
-
* @param {boolean} [options.leafNodeDeletionOnly]
|
|
5326
|
+
/**
|
|
5327
|
+
* For given data, remove properties based on condition.
|
|
5328
|
+
*
|
|
5329
|
+
* @param {Object<string, any>} data
|
|
5330
|
+
* @param {Object<string, any>} contextData
|
|
5331
|
+
* @param {Object} [options]
|
|
5332
|
+
* @param {Function} [options.getFilterPath]
|
|
5333
|
+
* @param {boolean} [options.leafNodeDeletionOnly]
|
|
5334
5334
|
*/
|
|
5335
5335
|
applyConditions(data, contextData = {}, options = {}) {
|
|
5336
5336
|
const workingData = clone(data);
|
|
@@ -5424,13 +5424,13 @@ class ConditionChecker {
|
|
|
5424
5424
|
return workingData;
|
|
5425
5425
|
}
|
|
5426
5426
|
|
|
5427
|
-
/**
|
|
5428
|
-
* Check if given condition is met. Returns null for invalid/missing conditions.
|
|
5429
|
-
*
|
|
5430
|
-
* @param {string} condition
|
|
5431
|
-
* @param {import('../../types').Data} [data]
|
|
5432
|
-
*
|
|
5433
|
-
* @returns {boolean|null}
|
|
5427
|
+
/**
|
|
5428
|
+
* Check if given condition is met. Returns null for invalid/missing conditions.
|
|
5429
|
+
*
|
|
5430
|
+
* @param {string} condition
|
|
5431
|
+
* @param {import('../../types').Data} [data]
|
|
5432
|
+
*
|
|
5433
|
+
* @returns {boolean|null}
|
|
5434
5434
|
*/
|
|
5435
5435
|
check(condition, data = {}) {
|
|
5436
5436
|
if (!condition) {
|
|
@@ -5451,12 +5451,12 @@ class ConditionChecker {
|
|
|
5451
5451
|
}
|
|
5452
5452
|
}
|
|
5453
5453
|
|
|
5454
|
-
/**
|
|
5455
|
-
* Check if hide condition is met.
|
|
5456
|
-
*
|
|
5457
|
-
* @param {Condition} condition
|
|
5458
|
-
* @param {Object<string, any>} data
|
|
5459
|
-
* @returns {boolean}
|
|
5454
|
+
/**
|
|
5455
|
+
* Check if hide condition is met.
|
|
5456
|
+
*
|
|
5457
|
+
* @param {Condition} condition
|
|
5458
|
+
* @param {Object<string, any>} data
|
|
5459
|
+
* @returns {boolean}
|
|
5460
5460
|
*/
|
|
5461
5461
|
_checkHideCondition(condition, data) {
|
|
5462
5462
|
if (!condition.hide) {
|
|
@@ -5498,12 +5498,12 @@ class MarkdownRenderer {
|
|
|
5498
5498
|
this._converter = new showdown.Converter();
|
|
5499
5499
|
}
|
|
5500
5500
|
|
|
5501
|
-
/**
|
|
5502
|
-
* Render markdown to HTML.
|
|
5503
|
-
*
|
|
5504
|
-
* @param {string} markdown - The markdown to render
|
|
5505
|
-
*
|
|
5506
|
-
* @returns {string} HTML
|
|
5501
|
+
/**
|
|
5502
|
+
* Render markdown to HTML.
|
|
5503
|
+
*
|
|
5504
|
+
* @param {string} markdown - The markdown to render
|
|
5505
|
+
*
|
|
5506
|
+
* @returns {string} HTML
|
|
5507
5507
|
*/
|
|
5508
5508
|
render(markdown) {
|
|
5509
5509
|
return this._converter.makeHtml(markdown);
|
|
@@ -6124,11 +6124,11 @@ class RepeatRenderManager {
|
|
|
6124
6124
|
this.RepeatFooter = this.RepeatFooter.bind(this);
|
|
6125
6125
|
}
|
|
6126
6126
|
|
|
6127
|
-
/**
|
|
6128
|
-
* Checks whether a field is currently repeating its children.
|
|
6129
|
-
*
|
|
6130
|
-
* @param {string} id - The id of the field to check
|
|
6131
|
-
* @returns {boolean} - True if repeatable, false otherwise
|
|
6127
|
+
/**
|
|
6128
|
+
* Checks whether a field is currently repeating its children.
|
|
6129
|
+
*
|
|
6130
|
+
* @param {string} id - The id of the field to check
|
|
6131
|
+
* @returns {boolean} - True if repeatable, false otherwise
|
|
6132
6132
|
*/
|
|
6133
6133
|
isFieldRepeating(id) {
|
|
6134
6134
|
if (!id) {
|
|
@@ -6888,8 +6888,8 @@ Validator.$inject = ['expressionLanguage', 'conditionChecker', 'form'];
|
|
|
6888
6888
|
|
|
6889
6889
|
// helpers //////////
|
|
6890
6890
|
|
|
6891
|
-
/**
|
|
6892
|
-
* Helper function to evaluate optional FEEL validation values.
|
|
6891
|
+
/**
|
|
6892
|
+
* Helper function to evaluate optional FEEL validation values.
|
|
6893
6893
|
*/
|
|
6894
6894
|
function evaluateFEELValues(validate, expressionLanguage, conditionChecker, form) {
|
|
6895
6895
|
const evaluatedValidate = {
|
|
@@ -6923,12 +6923,12 @@ function evaluateFEELValues(validate, expressionLanguage, conditionChecker, form
|
|
|
6923
6923
|
}
|
|
6924
6924
|
|
|
6925
6925
|
class Importer {
|
|
6926
|
-
/**
|
|
6927
|
-
* @constructor
|
|
6928
|
-
* @param { import('./FormFieldRegistry').default } formFieldRegistry
|
|
6929
|
-
* @param { import('./PathRegistry').default } pathRegistry
|
|
6930
|
-
* @param { import('./FieldFactory').default } fieldFactory
|
|
6931
|
-
* @param { import('./FormLayouter').default } formLayouter
|
|
6926
|
+
/**
|
|
6927
|
+
* @constructor
|
|
6928
|
+
* @param { import('./FormFieldRegistry').default } formFieldRegistry
|
|
6929
|
+
* @param { import('./PathRegistry').default } pathRegistry
|
|
6930
|
+
* @param { import('./FieldFactory').default } fieldFactory
|
|
6931
|
+
* @param { import('./FormLayouter').default } formLayouter
|
|
6932
6932
|
*/
|
|
6933
6933
|
constructor(formFieldRegistry, pathRegistry, fieldFactory, formLayouter) {
|
|
6934
6934
|
this._formFieldRegistry = formFieldRegistry;
|
|
@@ -6937,21 +6937,21 @@ class Importer {
|
|
|
6937
6937
|
this._formLayouter = formLayouter;
|
|
6938
6938
|
}
|
|
6939
6939
|
|
|
6940
|
-
/**
|
|
6941
|
-
* Import schema creating rows, fields, attaching additional
|
|
6942
|
-
* information to each field and adding fields to the
|
|
6943
|
-
* field registry.
|
|
6944
|
-
*
|
|
6945
|
-
* Additional information attached:
|
|
6946
|
-
*
|
|
6947
|
-
* * `id` (unless present)
|
|
6948
|
-
* * `_parent`
|
|
6949
|
-
* * `_path`
|
|
6950
|
-
*
|
|
6951
|
-
* @param {any} schema
|
|
6952
|
-
*
|
|
6953
|
-
* @typedef {{ warnings: Error[], schema: any }} ImportResult
|
|
6954
|
-
* @returns {ImportResult}
|
|
6940
|
+
/**
|
|
6941
|
+
* Import schema creating rows, fields, attaching additional
|
|
6942
|
+
* information to each field and adding fields to the
|
|
6943
|
+
* field registry.
|
|
6944
|
+
*
|
|
6945
|
+
* Additional information attached:
|
|
6946
|
+
*
|
|
6947
|
+
* * `id` (unless present)
|
|
6948
|
+
* * `_parent`
|
|
6949
|
+
* * `_path`
|
|
6950
|
+
*
|
|
6951
|
+
* @param {any} schema
|
|
6952
|
+
*
|
|
6953
|
+
* @typedef {{ warnings: Error[], schema: any }} ImportResult
|
|
6954
|
+
* @returns {ImportResult}
|
|
6955
6955
|
*/
|
|
6956
6956
|
importSchema(schema) {
|
|
6957
6957
|
// TODO: Add warnings
|
|
@@ -6976,12 +6976,12 @@ class Importer {
|
|
|
6976
6976
|
this._pathRegistry.clear();
|
|
6977
6977
|
}
|
|
6978
6978
|
|
|
6979
|
-
/**
|
|
6980
|
-
* @param {{[x: string]: any}} fieldAttrs
|
|
6981
|
-
* @param {String} [parentId]
|
|
6982
|
-
* @param {number} [index]
|
|
6983
|
-
*
|
|
6984
|
-
* @return {any} field
|
|
6979
|
+
/**
|
|
6980
|
+
* @param {{[x: string]: any}} fieldAttrs
|
|
6981
|
+
* @param {String} [parentId]
|
|
6982
|
+
* @param {number} [index]
|
|
6983
|
+
*
|
|
6984
|
+
* @return {any} field
|
|
6985
6985
|
*/
|
|
6986
6986
|
importFormField(fieldAttrs, parentId, index) {
|
|
6987
6987
|
const {
|
|
@@ -7006,11 +7006,11 @@ class Importer {
|
|
|
7006
7006
|
return field;
|
|
7007
7007
|
}
|
|
7008
7008
|
|
|
7009
|
-
/**
|
|
7010
|
-
* @param {Array<any>} components
|
|
7011
|
-
* @param {string} parentId
|
|
7012
|
-
*
|
|
7013
|
-
* @return {Array<any>} imported components
|
|
7009
|
+
/**
|
|
7010
|
+
* @param {Array<any>} components
|
|
7011
|
+
* @param {string} parentId
|
|
7012
|
+
*
|
|
7013
|
+
* @return {Array<any>} imported components
|
|
7014
7014
|
*/
|
|
7015
7015
|
importFormFields(components, parentId) {
|
|
7016
7016
|
return components.map((component, index) => {
|
|
@@ -7021,11 +7021,11 @@ class Importer {
|
|
|
7021
7021
|
Importer.$inject = ['formFieldRegistry', 'pathRegistry', 'fieldFactory', 'formLayouter'];
|
|
7022
7022
|
|
|
7023
7023
|
class FieldFactory {
|
|
7024
|
-
/**
|
|
7025
|
-
* @constructor
|
|
7026
|
-
*
|
|
7027
|
-
* @param formFieldRegistry
|
|
7028
|
-
* @param formFields
|
|
7024
|
+
/**
|
|
7025
|
+
* @constructor
|
|
7026
|
+
*
|
|
7027
|
+
* @param formFieldRegistry
|
|
7028
|
+
* @param formFields
|
|
7029
7029
|
*/
|
|
7030
7030
|
constructor(formFieldRegistry, pathRegistry, formFields) {
|
|
7031
7031
|
this._formFieldRegistry = formFieldRegistry;
|
|
@@ -7135,36 +7135,36 @@ class FieldFactory {
|
|
|
7135
7135
|
}
|
|
7136
7136
|
FieldFactory.$inject = ['formFieldRegistry', 'pathRegistry', 'formFields'];
|
|
7137
7137
|
|
|
7138
|
-
/**
|
|
7139
|
-
* The PathRegistry class manages a hierarchical structure of paths associated with form fields.
|
|
7140
|
-
* It enables claiming, unclaiming, and validating paths within this structure.
|
|
7141
|
-
*
|
|
7142
|
-
* Example Tree Structure:
|
|
7143
|
-
*
|
|
7144
|
-
* [
|
|
7145
|
-
* {
|
|
7146
|
-
* segment: 'root',
|
|
7147
|
-
* claimCount: 1,
|
|
7148
|
-
* children: [
|
|
7149
|
-
* {
|
|
7150
|
-
* segment: 'child1',
|
|
7151
|
-
* claimCount: 2,
|
|
7152
|
-
* children: null // A leaf node (closed path)
|
|
7153
|
-
* },
|
|
7154
|
-
* {
|
|
7155
|
-
* segment: 'child2',
|
|
7156
|
-
* claimCount: 1,
|
|
7157
|
-
* children: [
|
|
7158
|
-
* {
|
|
7159
|
-
* segment: 'subChild1',
|
|
7160
|
-
* claimCount: 1,
|
|
7161
|
-
* children: [] // An open node (open path)
|
|
7162
|
-
* }
|
|
7163
|
-
* ]
|
|
7164
|
-
* }
|
|
7165
|
-
* ]
|
|
7166
|
-
* }
|
|
7167
|
-
* ]
|
|
7138
|
+
/**
|
|
7139
|
+
* The PathRegistry class manages a hierarchical structure of paths associated with form fields.
|
|
7140
|
+
* It enables claiming, unclaiming, and validating paths within this structure.
|
|
7141
|
+
*
|
|
7142
|
+
* Example Tree Structure:
|
|
7143
|
+
*
|
|
7144
|
+
* [
|
|
7145
|
+
* {
|
|
7146
|
+
* segment: 'root',
|
|
7147
|
+
* claimCount: 1,
|
|
7148
|
+
* children: [
|
|
7149
|
+
* {
|
|
7150
|
+
* segment: 'child1',
|
|
7151
|
+
* claimCount: 2,
|
|
7152
|
+
* children: null // A leaf node (closed path)
|
|
7153
|
+
* },
|
|
7154
|
+
* {
|
|
7155
|
+
* segment: 'child2',
|
|
7156
|
+
* claimCount: 1,
|
|
7157
|
+
* children: [
|
|
7158
|
+
* {
|
|
7159
|
+
* segment: 'subChild1',
|
|
7160
|
+
* claimCount: 1,
|
|
7161
|
+
* children: [] // An open node (open path)
|
|
7162
|
+
* }
|
|
7163
|
+
* ]
|
|
7164
|
+
* }
|
|
7165
|
+
* ]
|
|
7166
|
+
* }
|
|
7167
|
+
* ]
|
|
7168
7168
|
*/
|
|
7169
7169
|
class PathRegistry {
|
|
7170
7170
|
constructor(formFieldRegistry, formFields, injector) {
|
|
@@ -7280,16 +7280,16 @@ class PathRegistry {
|
|
|
7280
7280
|
}
|
|
7281
7281
|
}
|
|
7282
7282
|
|
|
7283
|
-
/**
|
|
7284
|
-
* Applies a function (fn) recursively on a given field and its children.
|
|
7285
|
-
*
|
|
7286
|
-
* - `field`: Starting field object.
|
|
7287
|
-
* - `fn`: Function to apply.
|
|
7288
|
-
* - `context`: Optional object for passing data between calls.
|
|
7289
|
-
*
|
|
7290
|
-
* Stops early if `fn` returns `false`. Useful for traversing the form field tree.
|
|
7291
|
-
*
|
|
7292
|
-
* @returns {boolean} Success status based on function execution.
|
|
7283
|
+
/**
|
|
7284
|
+
* Applies a function (fn) recursively on a given field and its children.
|
|
7285
|
+
*
|
|
7286
|
+
* - `field`: Starting field object.
|
|
7287
|
+
* - `fn`: Function to apply.
|
|
7288
|
+
* - `context`: Optional object for passing data between calls.
|
|
7289
|
+
*
|
|
7290
|
+
* Stops early if `fn` returns `false`. Useful for traversing the form field tree.
|
|
7291
|
+
*
|
|
7292
|
+
* @returns {boolean} Success status based on function execution.
|
|
7293
7293
|
*/
|
|
7294
7294
|
executeRecursivelyOnFields(field, fn, context = {}) {
|
|
7295
7295
|
let result = true;
|
|
@@ -7330,16 +7330,16 @@ class PathRegistry {
|
|
|
7330
7330
|
return result;
|
|
7331
7331
|
}
|
|
7332
7332
|
|
|
7333
|
-
/**
|
|
7334
|
-
* Generates an array representing the binding path to an underlying data object for a form field.
|
|
7335
|
-
*
|
|
7336
|
-
* @param {Object} field - The field object with properties: `key`, `path`, `id`, and optionally `_parent`.
|
|
7337
|
-
* @param {Object} [options={}] - Configuration options.
|
|
7338
|
-
* @param {Object} [options.replacements={}] - A map of field IDs to alternative path arrays.
|
|
7339
|
-
* @param {Object} [options.indexes=null] - A map of parent IDs to the index of the field within said parent, leave null to get an unindexed path.
|
|
7340
|
-
* @param {Object} [options.cutoffNode] - The ID of the parent field at which to stop generating the path.
|
|
7341
|
-
*
|
|
7342
|
-
* @returns {(Array<string>|undefined)} An array of strings representing the binding path, or undefined if not determinable.
|
|
7333
|
+
/**
|
|
7334
|
+
* Generates an array representing the binding path to an underlying data object for a form field.
|
|
7335
|
+
*
|
|
7336
|
+
* @param {Object} field - The field object with properties: `key`, `path`, `id`, and optionally `_parent`.
|
|
7337
|
+
* @param {Object} [options={}] - Configuration options.
|
|
7338
|
+
* @param {Object} [options.replacements={}] - A map of field IDs to alternative path arrays.
|
|
7339
|
+
* @param {Object} [options.indexes=null] - A map of parent IDs to the index of the field within said parent, leave null to get an unindexed path.
|
|
7340
|
+
* @param {Object} [options.cutoffNode] - The ID of the parent field at which to stop generating the path.
|
|
7341
|
+
*
|
|
7342
|
+
* @returns {(Array<string>|undefined)} An array of strings representing the binding path, or undefined if not determinable.
|
|
7343
7343
|
*/
|
|
7344
7344
|
getValuePath(field, options = {}) {
|
|
7345
7345
|
const {
|
|
@@ -7400,23 +7400,23 @@ const _getNextSegment = (node, segment) => {
|
|
|
7400
7400
|
};
|
|
7401
7401
|
PathRegistry.$inject = ['formFieldRegistry', 'formFields', 'injector'];
|
|
7402
7402
|
|
|
7403
|
-
/**
|
|
7404
|
-
* @typedef { { id: String, components: Array<String> } } FormRow
|
|
7405
|
-
* @typedef { { formFieldId: String, rows: Array<FormRow> } } FormRows
|
|
7403
|
+
/**
|
|
7404
|
+
* @typedef { { id: String, components: Array<String> } } FormRow
|
|
7405
|
+
* @typedef { { formFieldId: String, rows: Array<FormRow> } } FormRows
|
|
7406
7406
|
*/
|
|
7407
7407
|
|
|
7408
|
-
/**
|
|
7409
|
-
* Maintains the Form layout in a given structure, for example
|
|
7410
|
-
*
|
|
7411
|
-
* [
|
|
7412
|
-
* {
|
|
7413
|
-
* formFieldId: 'FormField_1',
|
|
7414
|
-
* rows: [
|
|
7415
|
-
* { id: 'Row_1', components: [ 'Text_1', 'Textdield_1', ... ] }
|
|
7416
|
-
* ]
|
|
7417
|
-
* }
|
|
7418
|
-
* ]
|
|
7419
|
-
*
|
|
7408
|
+
/**
|
|
7409
|
+
* Maintains the Form layout in a given structure, for example
|
|
7410
|
+
*
|
|
7411
|
+
* [
|
|
7412
|
+
* {
|
|
7413
|
+
* formFieldId: 'FormField_1',
|
|
7414
|
+
* rows: [
|
|
7415
|
+
* { id: 'Row_1', components: [ 'Text_1', 'Textdield_1', ... ] }
|
|
7416
|
+
* ]
|
|
7417
|
+
* }
|
|
7418
|
+
* ]
|
|
7419
|
+
*
|
|
7420
7420
|
*/
|
|
7421
7421
|
class FormLayouter {
|
|
7422
7422
|
constructor(eventBus) {
|
|
@@ -7426,8 +7426,8 @@ class FormLayouter {
|
|
|
7426
7426
|
this._eventBus = eventBus;
|
|
7427
7427
|
}
|
|
7428
7428
|
|
|
7429
|
-
/**
|
|
7430
|
-
* @param {FormRow} row
|
|
7429
|
+
/**
|
|
7430
|
+
* @param {FormRow} row
|
|
7431
7431
|
*/
|
|
7432
7432
|
addRow(formFieldId, row) {
|
|
7433
7433
|
let rowsPerComponent = this._rows.find(r => r.formFieldId === formFieldId);
|
|
@@ -7441,18 +7441,18 @@ class FormLayouter {
|
|
|
7441
7441
|
rowsPerComponent.rows.push(row);
|
|
7442
7442
|
}
|
|
7443
7443
|
|
|
7444
|
-
/**
|
|
7445
|
-
* @param {String} id
|
|
7446
|
-
* @returns {FormRow}
|
|
7444
|
+
/**
|
|
7445
|
+
* @param {String} id
|
|
7446
|
+
* @returns {FormRow}
|
|
7447
7447
|
*/
|
|
7448
7448
|
getRow(id) {
|
|
7449
7449
|
const rows = allRows(this._rows);
|
|
7450
7450
|
return rows.find(r => r.id === id);
|
|
7451
7451
|
}
|
|
7452
7452
|
|
|
7453
|
-
/**
|
|
7454
|
-
* @param {any} formField
|
|
7455
|
-
* @returns {FormRow}
|
|
7453
|
+
/**
|
|
7454
|
+
* @param {any} formField
|
|
7455
|
+
* @returns {FormRow}
|
|
7456
7456
|
*/
|
|
7457
7457
|
getRowForField(formField) {
|
|
7458
7458
|
return allRows(this._rows).find(r => {
|
|
@@ -7463,9 +7463,9 @@ class FormLayouter {
|
|
|
7463
7463
|
});
|
|
7464
7464
|
}
|
|
7465
7465
|
|
|
7466
|
-
/**
|
|
7467
|
-
* @param {String} formFieldId
|
|
7468
|
-
* @returns { Array<FormRow> }
|
|
7466
|
+
/**
|
|
7467
|
+
* @param {String} formFieldId
|
|
7468
|
+
* @returns { Array<FormRow> }
|
|
7469
7469
|
*/
|
|
7470
7470
|
getRows(formFieldId) {
|
|
7471
7471
|
const rowsForField = this._rows.find(r => formFieldId === r.formFieldId);
|
|
@@ -7475,15 +7475,15 @@ class FormLayouter {
|
|
|
7475
7475
|
return rowsForField.rows;
|
|
7476
7476
|
}
|
|
7477
7477
|
|
|
7478
|
-
/**
|
|
7479
|
-
* @returns {string}
|
|
7478
|
+
/**
|
|
7479
|
+
* @returns {string}
|
|
7480
7480
|
*/
|
|
7481
7481
|
nextRowId() {
|
|
7482
7482
|
return this._ids.nextPrefixed('Row_');
|
|
7483
7483
|
}
|
|
7484
7484
|
|
|
7485
|
-
/**
|
|
7486
|
-
* @param {any} formField
|
|
7485
|
+
/**
|
|
7486
|
+
* @param {any} formField
|
|
7487
7487
|
*/
|
|
7488
7488
|
calculateLayout(formField) {
|
|
7489
7489
|
const {
|
|
@@ -7537,9 +7537,9 @@ function groupByRow(components, ids) {
|
|
|
7537
7537
|
});
|
|
7538
7538
|
}
|
|
7539
7539
|
|
|
7540
|
-
/**
|
|
7541
|
-
* @param {Array<FormRows>} formRows
|
|
7542
|
-
* @returns {Array<FormRow>}
|
|
7540
|
+
/**
|
|
7541
|
+
* @param {Array<FormRows>} formRows
|
|
7542
|
+
* @returns {Array<FormRow>}
|
|
7543
7543
|
*/
|
|
7544
7544
|
function allRows(formRows) {
|
|
7545
7545
|
return flatten(formRows.map(c => c.rows));
|
|
@@ -7664,55 +7664,55 @@ var core = {
|
|
|
7664
7664
|
validator: ['type', Validator]
|
|
7665
7665
|
};
|
|
7666
7666
|
|
|
7667
|
-
/**
|
|
7668
|
-
* @typedef { import('./types').Injector } Injector
|
|
7669
|
-
* @typedef { import('./types').Data } Data
|
|
7670
|
-
* @typedef { import('./types').Errors } Errors
|
|
7671
|
-
* @typedef { import('./types').Schema } Schema
|
|
7672
|
-
* @typedef { import('./types').FormProperties } FormProperties
|
|
7673
|
-
* @typedef { import('./types').FormProperty } FormProperty
|
|
7674
|
-
* @typedef { import('./types').FormEvent } FormEvent
|
|
7675
|
-
* @typedef { import('./types').FormOptions } FormOptions
|
|
7676
|
-
*
|
|
7677
|
-
* @typedef { {
|
|
7678
|
-
* data: Data,
|
|
7679
|
-
* initialData: Data,
|
|
7680
|
-
* errors: Errors,
|
|
7681
|
-
* properties: FormProperties,
|
|
7682
|
-
* schema: Schema
|
|
7683
|
-
* } } State
|
|
7684
|
-
*
|
|
7685
|
-
* @typedef { (type:FormEvent, priority:number, handler:Function) => void } OnEventWithPriority
|
|
7686
|
-
* @typedef { (type:FormEvent, handler:Function) => void } OnEventWithOutPriority
|
|
7687
|
-
* @typedef { OnEventWithPriority & OnEventWithOutPriority } OnEventType
|
|
7667
|
+
/**
|
|
7668
|
+
* @typedef { import('./types').Injector } Injector
|
|
7669
|
+
* @typedef { import('./types').Data } Data
|
|
7670
|
+
* @typedef { import('./types').Errors } Errors
|
|
7671
|
+
* @typedef { import('./types').Schema } Schema
|
|
7672
|
+
* @typedef { import('./types').FormProperties } FormProperties
|
|
7673
|
+
* @typedef { import('./types').FormProperty } FormProperty
|
|
7674
|
+
* @typedef { import('./types').FormEvent } FormEvent
|
|
7675
|
+
* @typedef { import('./types').FormOptions } FormOptions
|
|
7676
|
+
*
|
|
7677
|
+
* @typedef { {
|
|
7678
|
+
* data: Data,
|
|
7679
|
+
* initialData: Data,
|
|
7680
|
+
* errors: Errors,
|
|
7681
|
+
* properties: FormProperties,
|
|
7682
|
+
* schema: Schema
|
|
7683
|
+
* } } State
|
|
7684
|
+
*
|
|
7685
|
+
* @typedef { (type:FormEvent, priority:number, handler:Function) => void } OnEventWithPriority
|
|
7686
|
+
* @typedef { (type:FormEvent, handler:Function) => void } OnEventWithOutPriority
|
|
7687
|
+
* @typedef { OnEventWithPriority & OnEventWithOutPriority } OnEventType
|
|
7688
7688
|
*/
|
|
7689
7689
|
|
|
7690
7690
|
const ids = new Ids([32, 36, 1]);
|
|
7691
7691
|
|
|
7692
|
-
/**
|
|
7693
|
-
* The form.
|
|
7692
|
+
/**
|
|
7693
|
+
* The form.
|
|
7694
7694
|
*/
|
|
7695
7695
|
class Form {
|
|
7696
|
-
/**
|
|
7697
|
-
* @constructor
|
|
7698
|
-
* @param {FormOptions} options
|
|
7696
|
+
/**
|
|
7697
|
+
* @constructor
|
|
7698
|
+
* @param {FormOptions} options
|
|
7699
7699
|
*/
|
|
7700
7700
|
constructor(options = {}) {
|
|
7701
|
-
/**
|
|
7702
|
-
* @public
|
|
7703
|
-
* @type {OnEventType}
|
|
7701
|
+
/**
|
|
7702
|
+
* @public
|
|
7703
|
+
* @type {OnEventType}
|
|
7704
7704
|
*/
|
|
7705
7705
|
this.on = this._onEvent;
|
|
7706
7706
|
|
|
7707
|
-
/**
|
|
7708
|
-
* @public
|
|
7709
|
-
* @type {String}
|
|
7707
|
+
/**
|
|
7708
|
+
* @public
|
|
7709
|
+
* @type {String}
|
|
7710
7710
|
*/
|
|
7711
7711
|
this._id = ids.next();
|
|
7712
7712
|
|
|
7713
|
-
/**
|
|
7714
|
-
* @private
|
|
7715
|
-
* @type {Element}
|
|
7713
|
+
/**
|
|
7714
|
+
* @private
|
|
7715
|
+
* @type {Element}
|
|
7716
7716
|
*/
|
|
7717
7717
|
this._container = createFormContainer();
|
|
7718
7718
|
const {
|
|
@@ -7721,9 +7721,9 @@ class Form {
|
|
|
7721
7721
|
properties = {}
|
|
7722
7722
|
} = options;
|
|
7723
7723
|
|
|
7724
|
-
/**
|
|
7725
|
-
* @private
|
|
7726
|
-
* @type {State}
|
|
7724
|
+
/**
|
|
7725
|
+
* @private
|
|
7726
|
+
* @type {State}
|
|
7727
7727
|
*/
|
|
7728
7728
|
this._state = {
|
|
7729
7729
|
initialData: null,
|
|
@@ -7747,9 +7747,9 @@ class Form {
|
|
|
7747
7747
|
this._emit('form.clear');
|
|
7748
7748
|
}
|
|
7749
7749
|
|
|
7750
|
-
/**
|
|
7751
|
-
* Destroy the form, removing it from DOM,
|
|
7752
|
-
* if attached.
|
|
7750
|
+
/**
|
|
7751
|
+
* Destroy the form, removing it from DOM,
|
|
7752
|
+
* if attached.
|
|
7753
7753
|
*/
|
|
7754
7754
|
destroy() {
|
|
7755
7755
|
// destroy form services
|
|
@@ -7760,13 +7760,13 @@ class Form {
|
|
|
7760
7760
|
this._detach(false);
|
|
7761
7761
|
}
|
|
7762
7762
|
|
|
7763
|
-
/**
|
|
7764
|
-
* Open a form schema with the given initial data.
|
|
7765
|
-
*
|
|
7766
|
-
* @param {Schema} schema
|
|
7767
|
-
* @param {Data} [data]
|
|
7768
|
-
*
|
|
7769
|
-
* @return Promise<{ warnings: Array<any> }>
|
|
7763
|
+
/**
|
|
7764
|
+
* Open a form schema with the given initial data.
|
|
7765
|
+
*
|
|
7766
|
+
* @param {Schema} schema
|
|
7767
|
+
* @param {Data} [data]
|
|
7768
|
+
*
|
|
7769
|
+
* @return Promise<{ warnings: Array<any> }>
|
|
7770
7770
|
*/
|
|
7771
7771
|
importSchema(schema, data = {}) {
|
|
7772
7772
|
return new Promise((resolve, reject) => {
|
|
@@ -7799,10 +7799,10 @@ class Form {
|
|
|
7799
7799
|
});
|
|
7800
7800
|
}
|
|
7801
7801
|
|
|
7802
|
-
/**
|
|
7803
|
-
* Submit the form, triggering all field validations.
|
|
7804
|
-
*
|
|
7805
|
-
* @returns { { data: Data, errors: Errors } }
|
|
7802
|
+
/**
|
|
7803
|
+
* Submit the form, triggering all field validations.
|
|
7804
|
+
*
|
|
7805
|
+
* @returns { { data: Data, errors: Errors } }
|
|
7806
7806
|
*/
|
|
7807
7807
|
submit() {
|
|
7808
7808
|
const {
|
|
@@ -7828,8 +7828,8 @@ class Form {
|
|
|
7828
7828
|
});
|
|
7829
7829
|
}
|
|
7830
7830
|
|
|
7831
|
-
/**
|
|
7832
|
-
* @returns {Errors}
|
|
7831
|
+
/**
|
|
7832
|
+
* @returns {Errors}
|
|
7833
7833
|
*/
|
|
7834
7834
|
validate() {
|
|
7835
7835
|
const formFields = this.get('formFields'),
|
|
@@ -7901,8 +7901,8 @@ class Form {
|
|
|
7901
7901
|
return filteredErrors;
|
|
7902
7902
|
}
|
|
7903
7903
|
|
|
7904
|
-
/**
|
|
7905
|
-
* @param {Element|string} parentNode
|
|
7904
|
+
/**
|
|
7905
|
+
* @param {Element|string} parentNode
|
|
7906
7906
|
*/
|
|
7907
7907
|
attachTo(parentNode) {
|
|
7908
7908
|
if (!parentNode) {
|
|
@@ -7920,10 +7920,10 @@ class Form {
|
|
|
7920
7920
|
this._detach();
|
|
7921
7921
|
}
|
|
7922
7922
|
|
|
7923
|
-
/**
|
|
7924
|
-
* @private
|
|
7925
|
-
*
|
|
7926
|
-
* @param {boolean} [emit]
|
|
7923
|
+
/**
|
|
7924
|
+
* @private
|
|
7925
|
+
*
|
|
7926
|
+
* @param {boolean} [emit]
|
|
7927
7927
|
*/
|
|
7928
7928
|
_detach(emit = true) {
|
|
7929
7929
|
const container = this._container,
|
|
@@ -7937,9 +7937,9 @@ class Form {
|
|
|
7937
7937
|
parentNode.removeChild(container);
|
|
7938
7938
|
}
|
|
7939
7939
|
|
|
7940
|
-
/**
|
|
7941
|
-
* @param {FormProperty} property
|
|
7942
|
-
* @param {any} value
|
|
7940
|
+
/**
|
|
7941
|
+
* @param {FormProperty} property
|
|
7942
|
+
* @param {any} value
|
|
7943
7943
|
*/
|
|
7944
7944
|
setProperty(property, value) {
|
|
7945
7945
|
const properties = set(this._getState().properties, [property], value);
|
|
@@ -7948,21 +7948,21 @@ class Form {
|
|
|
7948
7948
|
});
|
|
7949
7949
|
}
|
|
7950
7950
|
|
|
7951
|
-
/**
|
|
7952
|
-
* @param {FormEvent} type
|
|
7953
|
-
* @param {Function} handler
|
|
7951
|
+
/**
|
|
7952
|
+
* @param {FormEvent} type
|
|
7953
|
+
* @param {Function} handler
|
|
7954
7954
|
*/
|
|
7955
7955
|
off(type, handler) {
|
|
7956
7956
|
this.get('eventBus').off(type, handler);
|
|
7957
7957
|
}
|
|
7958
7958
|
|
|
7959
|
-
/**
|
|
7960
|
-
* @private
|
|
7961
|
-
*
|
|
7962
|
-
* @param {FormOptions} options
|
|
7963
|
-
* @param {Element} container
|
|
7964
|
-
*
|
|
7965
|
-
* @returns {Injector}
|
|
7959
|
+
/**
|
|
7960
|
+
* @private
|
|
7961
|
+
*
|
|
7962
|
+
* @param {FormOptions} options
|
|
7963
|
+
* @param {Element} container
|
|
7964
|
+
*
|
|
7965
|
+
* @returns {Injector}
|
|
7966
7966
|
*/
|
|
7967
7967
|
_createInjector(options, container) {
|
|
7968
7968
|
const {
|
|
@@ -7981,17 +7981,17 @@ class Form {
|
|
|
7981
7981
|
}, core, ...modules, ...additionalModules]);
|
|
7982
7982
|
}
|
|
7983
7983
|
|
|
7984
|
-
/**
|
|
7985
|
-
* @private
|
|
7984
|
+
/**
|
|
7985
|
+
* @private
|
|
7986
7986
|
*/
|
|
7987
7987
|
_emit(type, data) {
|
|
7988
7988
|
this.get('eventBus').fire(type, data);
|
|
7989
7989
|
}
|
|
7990
7990
|
|
|
7991
|
-
/**
|
|
7992
|
-
* @internal
|
|
7993
|
-
*
|
|
7994
|
-
* @param { { add?: boolean, field: any, indexes: object, remove?: number, value?: any } } update
|
|
7991
|
+
/**
|
|
7992
|
+
* @internal
|
|
7993
|
+
*
|
|
7994
|
+
* @param { { add?: boolean, field: any, indexes: object, remove?: number, value?: any } } update
|
|
7995
7995
|
*/
|
|
7996
7996
|
_update(update) {
|
|
7997
7997
|
const {
|
|
@@ -8017,15 +8017,15 @@ class Form {
|
|
|
8017
8017
|
});
|
|
8018
8018
|
}
|
|
8019
8019
|
|
|
8020
|
-
/**
|
|
8021
|
-
* @internal
|
|
8020
|
+
/**
|
|
8021
|
+
* @internal
|
|
8022
8022
|
*/
|
|
8023
8023
|
_getState() {
|
|
8024
8024
|
return this._state;
|
|
8025
8025
|
}
|
|
8026
8026
|
|
|
8027
|
-
/**
|
|
8028
|
-
* @internal
|
|
8027
|
+
/**
|
|
8028
|
+
* @internal
|
|
8029
8029
|
*/
|
|
8030
8030
|
_setState(state) {
|
|
8031
8031
|
this._state = {
|
|
@@ -8035,22 +8035,22 @@ class Form {
|
|
|
8035
8035
|
this._emit('changed', this._getState());
|
|
8036
8036
|
}
|
|
8037
8037
|
|
|
8038
|
-
/**
|
|
8039
|
-
* @internal
|
|
8038
|
+
/**
|
|
8039
|
+
* @internal
|
|
8040
8040
|
*/
|
|
8041
8041
|
_getModules() {
|
|
8042
8042
|
return [ExpressionLanguageModule, MarkdownModule, ViewerCommandsModule, RepeatRenderModule];
|
|
8043
8043
|
}
|
|
8044
8044
|
|
|
8045
|
-
/**
|
|
8046
|
-
* @internal
|
|
8045
|
+
/**
|
|
8046
|
+
* @internal
|
|
8047
8047
|
*/
|
|
8048
8048
|
_onEvent(type, priority, handler) {
|
|
8049
8049
|
this.get('eventBus').on(type, priority, handler);
|
|
8050
8050
|
}
|
|
8051
8051
|
|
|
8052
|
-
/**
|
|
8053
|
-
* @internal
|
|
8052
|
+
/**
|
|
8053
|
+
* @internal
|
|
8054
8054
|
*/
|
|
8055
8055
|
_getSubmitData() {
|
|
8056
8056
|
const formFieldRegistry = this.get('formFieldRegistry');
|
|
@@ -8107,16 +8107,16 @@ class Form {
|
|
|
8107
8107
|
return this._applyConditions(workingSubmitData, formData);
|
|
8108
8108
|
}
|
|
8109
8109
|
|
|
8110
|
-
/**
|
|
8111
|
-
* @internal
|
|
8110
|
+
/**
|
|
8111
|
+
* @internal
|
|
8112
8112
|
*/
|
|
8113
8113
|
_applyConditions(toFilter, data, options = {}) {
|
|
8114
8114
|
const conditionChecker = this.get('conditionChecker');
|
|
8115
8115
|
return conditionChecker.applyConditions(toFilter, data, options);
|
|
8116
8116
|
}
|
|
8117
8117
|
|
|
8118
|
-
/**
|
|
8119
|
-
* @internal
|
|
8118
|
+
/**
|
|
8119
|
+
* @internal
|
|
8120
8120
|
*/
|
|
8121
8121
|
_getInitializedFieldData(data, options = {}) {
|
|
8122
8122
|
const formFieldRegistry = this.get('formFieldRegistry');
|