@bpmn-io/form-js-viewer 1.6.3 → 1.6.4
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 +580 -580
- package/dist/index.cjs.map +1 -1
- package/dist/index.es.js +580 -580
- package/dist/index.es.js.map +1 -1
- package/dist/types/types.d.ts +35 -35
- package/package.json +3 -3
package/dist/index.es.js
CHANGED
|
@@ -54,26 +54,26 @@ const getFlavouredFeelVariableNames = (feelString, feelFlavour = 'expression', o
|
|
|
54
54
|
return [...new Set(variables)];
|
|
55
55
|
};
|
|
56
56
|
|
|
57
|
-
/**
|
|
58
|
-
* Get the variable name at the specified index in a given path expression.
|
|
59
|
-
*
|
|
60
|
-
* @param {Object} root - The root node of the path expression tree.
|
|
61
|
-
* @param {number} index - The index of the variable name to retrieve.
|
|
62
|
-
* @returns {string|null} The variable name at the specified index or null if index is out of bounds.
|
|
57
|
+
/**
|
|
58
|
+
* Get the variable name at the specified index in a given path expression.
|
|
59
|
+
*
|
|
60
|
+
* @param {Object} root - The root node of the path expression tree.
|
|
61
|
+
* @param {number} index - The index of the variable name to retrieve.
|
|
62
|
+
* @returns {string|null} The variable name at the specified index or null if index is out of bounds.
|
|
63
63
|
*/
|
|
64
64
|
const _getVariableNameAtPathIndex = (root, index) => {
|
|
65
65
|
const nodes = _linearizePathExpression(root);
|
|
66
66
|
return nodes[index].variableName || null;
|
|
67
67
|
};
|
|
68
68
|
|
|
69
|
-
/**
|
|
70
|
-
* Extracts the variables which are required of the external context for a given path expression.
|
|
71
|
-
* This is done by traversing the path expression tree and keeping track of the current depth relative to the external context.
|
|
72
|
-
*
|
|
73
|
-
* @param {Object} node - The root node of the path expression tree.
|
|
74
|
-
* @param {number} initialDepth - The depth at which the root node is located in the outer context.
|
|
75
|
-
* @param {Object} specialDepthAccessors - Definitions of special keywords which represent more complex accesses of the outer context.
|
|
76
|
-
* @returns {Set} - A set containing the extracted variable names.
|
|
69
|
+
/**
|
|
70
|
+
* Extracts the variables which are required of the external context for a given path expression.
|
|
71
|
+
* This is done by traversing the path expression tree and keeping track of the current depth relative to the external context.
|
|
72
|
+
*
|
|
73
|
+
* @param {Object} node - The root node of the path expression tree.
|
|
74
|
+
* @param {number} initialDepth - The depth at which the root node is located in the outer context.
|
|
75
|
+
* @param {Object} specialDepthAccessors - Definitions of special keywords which represent more complex accesses of the outer context.
|
|
76
|
+
* @returns {Set} - A set containing the extracted variable names.
|
|
77
77
|
*/
|
|
78
78
|
const _smartExtractVariableNames = (node, initialDepth, specialDepthAccessors) => {
|
|
79
79
|
// depth info represents the previous (initialised as null) and current depth of the current accessor in the path expression
|
|
@@ -119,11 +119,11 @@ const _smartExtractVariableNames = (node, initialDepth, specialDepthAccessors) =
|
|
|
119
119
|
return new Set(extractedVariables);
|
|
120
120
|
};
|
|
121
121
|
|
|
122
|
-
/**
|
|
123
|
-
* Deconstructs a path expression tree into an array of components.
|
|
124
|
-
*
|
|
125
|
-
* @param {Object} root - The root node of the path expression tree.
|
|
126
|
-
* @returns {Array<object>} An array of components in the path expression, in the correct order.
|
|
122
|
+
/**
|
|
123
|
+
* Deconstructs a path expression tree into an array of components.
|
|
124
|
+
*
|
|
125
|
+
* @param {Object} root - The root node of the path expression tree.
|
|
126
|
+
* @returns {Array<object>} An array of components in the path expression, in the correct order.
|
|
127
127
|
*/
|
|
128
128
|
const _linearizePathExpression = root => {
|
|
129
129
|
let node = root;
|
|
@@ -142,13 +142,13 @@ const _linearizePathExpression = root => {
|
|
|
142
142
|
return parts.reverse();
|
|
143
143
|
};
|
|
144
144
|
|
|
145
|
-
/**
|
|
146
|
-
* Builds a simplified feel structure tree from the given parse tree and feel string.
|
|
147
|
-
* The nodes follow this structure: `{ name: string, children: Array, variableName?: string }`
|
|
148
|
-
*
|
|
149
|
-
* @param {Object} parseTree - The parse tree generated by a parser.
|
|
150
|
-
* @param {string} feelString - The feel string used for parsing.
|
|
151
|
-
* @returns {Object} The simplified feel structure tree.
|
|
145
|
+
/**
|
|
146
|
+
* Builds a simplified feel structure tree from the given parse tree and feel string.
|
|
147
|
+
* The nodes follow this structure: `{ name: string, children: Array, variableName?: string }`
|
|
148
|
+
*
|
|
149
|
+
* @param {Object} parseTree - The parse tree generated by a parser.
|
|
150
|
+
* @param {string} feelString - The feel string used for parsing.
|
|
151
|
+
* @returns {Object} The simplified feel structure tree.
|
|
152
152
|
*/
|
|
153
153
|
const _buildSimpleFeelStructureTree = (parseTree, feelString) => {
|
|
154
154
|
const stack = [{
|
|
@@ -174,9 +174,9 @@ const _buildSimpleFeelStructureTree = (parseTree, feelString) => {
|
|
|
174
174
|
return _extractFilterExpressions(stack[0].children[0]);
|
|
175
175
|
};
|
|
176
176
|
|
|
177
|
-
/**
|
|
178
|
-
* Restructure the tree in such a way to bring filters (which create new contexts) to the root of the tree.
|
|
179
|
-
* This is done to simplify the extraction of variables and match the context hierarchy.
|
|
177
|
+
/**
|
|
178
|
+
* Restructure the tree in such a way to bring filters (which create new contexts) to the root of the tree.
|
|
179
|
+
* This is done to simplify the extraction of variables and match the context hierarchy.
|
|
180
180
|
*/
|
|
181
181
|
const _extractFilterExpressions = tree => {
|
|
182
182
|
const flattenedExpressionTree = {
|
|
@@ -217,25 +217,25 @@ class FeelExpressionLanguage {
|
|
|
217
217
|
this._eventBus = eventBus;
|
|
218
218
|
}
|
|
219
219
|
|
|
220
|
-
/**
|
|
221
|
-
* Determines if the given value is a FEEL expression.
|
|
222
|
-
*
|
|
223
|
-
* @param {any} value
|
|
224
|
-
* @returns {boolean}
|
|
225
|
-
*
|
|
220
|
+
/**
|
|
221
|
+
* Determines if the given value is a FEEL expression.
|
|
222
|
+
*
|
|
223
|
+
* @param {any} value
|
|
224
|
+
* @returns {boolean}
|
|
225
|
+
*
|
|
226
226
|
*/
|
|
227
227
|
isExpression(value) {
|
|
228
228
|
return isString(value) && value.startsWith('=');
|
|
229
229
|
}
|
|
230
230
|
|
|
231
|
-
/**
|
|
232
|
-
* Retrieve variable names from a given FEEL expression.
|
|
233
|
-
*
|
|
234
|
-
* @param {string} expression
|
|
235
|
-
* @param {object} [options]
|
|
236
|
-
* @param {string} [options.type]
|
|
237
|
-
*
|
|
238
|
-
* @returns {string[]}
|
|
231
|
+
/**
|
|
232
|
+
* Retrieve variable names from a given FEEL expression.
|
|
233
|
+
*
|
|
234
|
+
* @param {string} expression
|
|
235
|
+
* @param {object} [options]
|
|
236
|
+
* @param {string} [options.type]
|
|
237
|
+
*
|
|
238
|
+
* @returns {string[]}
|
|
239
239
|
*/
|
|
240
240
|
getVariableNames(expression, options = {}) {
|
|
241
241
|
const {
|
|
@@ -250,13 +250,13 @@ class FeelExpressionLanguage {
|
|
|
250
250
|
return getFlavouredFeelVariableNames(expression, type);
|
|
251
251
|
}
|
|
252
252
|
|
|
253
|
-
/**
|
|
254
|
-
* Evaluate an expression.
|
|
255
|
-
*
|
|
256
|
-
* @param {string} expression
|
|
257
|
-
* @param {import('../../types').Data} [data]
|
|
258
|
-
*
|
|
259
|
-
* @returns {any}
|
|
253
|
+
/**
|
|
254
|
+
* Evaluate an expression.
|
|
255
|
+
*
|
|
256
|
+
* @param {string} expression
|
|
257
|
+
* @param {import('../../types').Data} [data]
|
|
258
|
+
*
|
|
259
|
+
* @returns {any}
|
|
260
260
|
*/
|
|
261
261
|
evaluate(expression, data = {}) {
|
|
262
262
|
if (!expression) {
|
|
@@ -281,23 +281,23 @@ FeelExpressionLanguage.$inject = ['eventBus'];
|
|
|
281
281
|
class FeelersTemplating {
|
|
282
282
|
constructor() {}
|
|
283
283
|
|
|
284
|
-
/**
|
|
285
|
-
* Determines if the given value is a feelers template.
|
|
286
|
-
*
|
|
287
|
-
* @param {any} value
|
|
288
|
-
* @returns {boolean}
|
|
289
|
-
*
|
|
284
|
+
/**
|
|
285
|
+
* Determines if the given value is a feelers template.
|
|
286
|
+
*
|
|
287
|
+
* @param {any} value
|
|
288
|
+
* @returns {boolean}
|
|
289
|
+
*
|
|
290
290
|
*/
|
|
291
291
|
isTemplate(value) {
|
|
292
292
|
return isString(value) && (value.startsWith('=') || /{{.*?}}/.test(value));
|
|
293
293
|
}
|
|
294
294
|
|
|
295
|
-
/**
|
|
296
|
-
* Retrieve variable names from a given feelers template.
|
|
297
|
-
*
|
|
298
|
-
* @param {string} template
|
|
299
|
-
*
|
|
300
|
-
* @returns {string[]}
|
|
295
|
+
/**
|
|
296
|
+
* Retrieve variable names from a given feelers template.
|
|
297
|
+
*
|
|
298
|
+
* @param {string} template
|
|
299
|
+
*
|
|
300
|
+
* @returns {string[]}
|
|
301
301
|
*/
|
|
302
302
|
getVariableNames(template) {
|
|
303
303
|
if (!this.isTemplate(template)) {
|
|
@@ -323,17 +323,17 @@ class FeelersTemplating {
|
|
|
323
323
|
}, []);
|
|
324
324
|
}
|
|
325
325
|
|
|
326
|
-
/**
|
|
327
|
-
* Evaluate a template.
|
|
328
|
-
*
|
|
329
|
-
* @param {string} template
|
|
330
|
-
* @param {Object<string, any>} context
|
|
331
|
-
* @param {Object} options
|
|
332
|
-
* @param {boolean} [options.debug = false]
|
|
333
|
-
* @param {boolean} [options.strict = false]
|
|
334
|
-
* @param {Function} [options.buildDebugString]
|
|
335
|
-
*
|
|
336
|
-
* @returns
|
|
326
|
+
/**
|
|
327
|
+
* Evaluate a template.
|
|
328
|
+
*
|
|
329
|
+
* @param {string} template
|
|
330
|
+
* @param {Object<string, any>} context
|
|
331
|
+
* @param {Object} options
|
|
332
|
+
* @param {boolean} [options.debug = false]
|
|
333
|
+
* @param {boolean} [options.strict = false]
|
|
334
|
+
* @param {Function} [options.buildDebugString]
|
|
335
|
+
*
|
|
336
|
+
* @returns
|
|
337
337
|
*/
|
|
338
338
|
evaluate(template, context = {}, options = {}) {
|
|
339
339
|
const {
|
|
@@ -348,22 +348,22 @@ class FeelersTemplating {
|
|
|
348
348
|
});
|
|
349
349
|
}
|
|
350
350
|
|
|
351
|
-
/**
|
|
352
|
-
* @typedef {Object} ExpressionWithDepth
|
|
353
|
-
* @property {number} depth - The depth of the expression in the syntax tree.
|
|
354
|
-
* @property {string} expression - The extracted expression
|
|
351
|
+
/**
|
|
352
|
+
* @typedef {Object} ExpressionWithDepth
|
|
353
|
+
* @property {number} depth - The depth of the expression in the syntax tree.
|
|
354
|
+
* @property {string} expression - The extracted expression
|
|
355
355
|
*/
|
|
356
356
|
|
|
357
|
-
/**
|
|
358
|
-
* Extracts all feel expressions in the template along with their depth in the syntax tree.
|
|
359
|
-
* The depth is incremented for child expressions of loops to account for context drilling.
|
|
360
|
-
|
|
361
|
-
* @param {string} template - A feelers template string.
|
|
362
|
-
* @returns {Array<ExpressionWithDepth>} An array of objects, each containing the depth and the extracted expression.
|
|
363
|
-
*
|
|
364
|
-
* @example
|
|
365
|
-
* const template = "Hello {{user}}, you have:{{#loop items}}\n- {{amount}} {{name}}{{/loop}}.";
|
|
366
|
-
* const extractedExpressions = _extractExpressionsWithDepth(template);
|
|
357
|
+
/**
|
|
358
|
+
* Extracts all feel expressions in the template along with their depth in the syntax tree.
|
|
359
|
+
* The depth is incremented for child expressions of loops to account for context drilling.
|
|
360
|
+
* @name extractExpressionsWithDepth
|
|
361
|
+
* @param {string} template - A feelers template string.
|
|
362
|
+
* @returns {Array<ExpressionWithDepth>} An array of objects, each containing the depth and the extracted expression.
|
|
363
|
+
*
|
|
364
|
+
* @example
|
|
365
|
+
* const template = "Hello {{user}}, you have:{{#loop items}}\n- {{amount}} {{name}}{{/loop}}.";
|
|
366
|
+
* const extractedExpressions = _extractExpressionsWithDepth(template);
|
|
367
367
|
*/
|
|
368
368
|
_extractExpressionsWithDepth(template) {
|
|
369
369
|
// build simplified feelers syntax tree
|
|
@@ -469,10 +469,10 @@ function createInjector(bootstrapModules) {
|
|
|
469
469
|
return injector;
|
|
470
470
|
}
|
|
471
471
|
|
|
472
|
-
/**
|
|
473
|
-
* @param {string?} prefix
|
|
474
|
-
*
|
|
475
|
-
* @returns Element
|
|
472
|
+
/**
|
|
473
|
+
* @param {string?} prefix
|
|
474
|
+
*
|
|
475
|
+
* @returns Element
|
|
476
476
|
*/
|
|
477
477
|
function createFormContainer(prefix = 'fjs') {
|
|
478
478
|
const container = document.createElement('div');
|
|
@@ -603,11 +603,11 @@ const LocalExpressionContext = createContext({
|
|
|
603
603
|
});
|
|
604
604
|
var LocalExpressionContext$1 = LocalExpressionContext;
|
|
605
605
|
|
|
606
|
-
/**
|
|
607
|
-
* @param {string} type
|
|
608
|
-
* @param {boolean} [strict]
|
|
609
|
-
*
|
|
610
|
-
* @returns {any}
|
|
606
|
+
/**
|
|
607
|
+
* @param {string} type
|
|
608
|
+
* @param {boolean} [strict]
|
|
609
|
+
*
|
|
610
|
+
* @returns {any}
|
|
611
611
|
*/
|
|
612
612
|
function getService(type, strict) {}
|
|
613
613
|
const FormContext = createContext({
|
|
@@ -650,21 +650,21 @@ function generateIdForType(type) {
|
|
|
650
650
|
return `${type}${generateIndexForType(type)}`;
|
|
651
651
|
}
|
|
652
652
|
|
|
653
|
-
/**
|
|
654
|
-
* @template T
|
|
655
|
-
* @param {T} data
|
|
656
|
-
* @param {(this: any, key: string, value: any) => any} [replacer]
|
|
657
|
-
* @return {T}
|
|
653
|
+
/**
|
|
654
|
+
* @template T
|
|
655
|
+
* @param {T} data
|
|
656
|
+
* @param {(this: any, key: string, value: any) => any} [replacer]
|
|
657
|
+
* @return {T}
|
|
658
658
|
*/
|
|
659
659
|
function clone(data, replacer) {
|
|
660
660
|
return JSON.parse(JSON.stringify(data, replacer));
|
|
661
661
|
}
|
|
662
662
|
|
|
663
|
-
/**
|
|
664
|
-
* Transform a LocalExpressionContext object into a usable FEEL context.
|
|
665
|
-
*
|
|
666
|
-
* @param {Object} context - The LocalExpressionContext object.
|
|
667
|
-
* @returns {Object} The usable FEEL context.
|
|
663
|
+
/**
|
|
664
|
+
* Transform a LocalExpressionContext object into a usable FEEL context.
|
|
665
|
+
*
|
|
666
|
+
* @param {Object} context - The LocalExpressionContext object.
|
|
667
|
+
* @returns {Object} The usable FEEL context.
|
|
668
668
|
*/
|
|
669
669
|
|
|
670
670
|
function buildExpressionContext(context) {
|
|
@@ -696,12 +696,12 @@ function _wrapObjectKeysWithUnderscores(obj) {
|
|
|
696
696
|
return newObj;
|
|
697
697
|
}
|
|
698
698
|
|
|
699
|
-
/**
|
|
700
|
-
* Evaluate if condition is met reactively based on the conditionChecker and form data.
|
|
701
|
-
*
|
|
702
|
-
* @param {string | undefined} condition
|
|
703
|
-
*
|
|
704
|
-
* @returns {boolean} true if condition is met or no condition or condition checker exists
|
|
699
|
+
/**
|
|
700
|
+
* Evaluate if condition is met reactively based on the conditionChecker and form data.
|
|
701
|
+
*
|
|
702
|
+
* @param {string | undefined} condition
|
|
703
|
+
*
|
|
704
|
+
* @returns {boolean} true if condition is met or no condition or condition checker exists
|
|
705
705
|
*/
|
|
706
706
|
function useCondition(condition) {
|
|
707
707
|
const conditionChecker = useService('conditionChecker', false);
|
|
@@ -711,17 +711,17 @@ function useCondition(condition) {
|
|
|
711
711
|
}, [conditionChecker, condition, expressionContextInfo]);
|
|
712
712
|
}
|
|
713
713
|
|
|
714
|
-
/**
|
|
715
|
-
* Custom hook to scroll an element into view only when it is not visible within the viewport.
|
|
716
|
-
*
|
|
717
|
-
* @param {Object} targetRef - A ref pointing to the DOM element to scroll into view.
|
|
718
|
-
* @param {Array} deps - An array of dependencies that trigger the effect.
|
|
719
|
-
* @param {Array} flagRefs - An array of refs that are used as flags to control when to scroll.
|
|
720
|
-
* @param {Object} [scrollOptions={}] - Options defining the behavior of the scrolling.
|
|
721
|
-
* @param {String} [scrollOptions.align='center'] - The alignment of the element within the viewport.
|
|
722
|
-
* @param {String} [scrollOptions.behavior='auto'] - The scrolling behavior.
|
|
723
|
-
* @param {Number} [scrollOptions.offset=0] - An offset that is added to the scroll position.
|
|
724
|
-
* @param {Boolean} [scrollOptions.scrollIfVisible=false] - Whether to scroll even if the element is visible.
|
|
714
|
+
/**
|
|
715
|
+
* Custom hook to scroll an element into view only when it is not visible within the viewport.
|
|
716
|
+
*
|
|
717
|
+
* @param {Object} targetRef - A ref pointing to the DOM element to scroll into view.
|
|
718
|
+
* @param {Array} deps - An array of dependencies that trigger the effect.
|
|
719
|
+
* @param {Array} flagRefs - An array of refs that are used as flags to control when to scroll.
|
|
720
|
+
* @param {Object} [scrollOptions={}] - Options defining the behavior of the scrolling.
|
|
721
|
+
* @param {String} [scrollOptions.align='center'] - The alignment of the element within the viewport.
|
|
722
|
+
* @param {String} [scrollOptions.behavior='auto'] - The scrolling behavior.
|
|
723
|
+
* @param {Number} [scrollOptions.offset=0] - An offset that is added to the scroll position.
|
|
724
|
+
* @param {Boolean} [scrollOptions.scrollIfVisible=false] - Whether to scroll even if the element is visible.
|
|
725
725
|
*/
|
|
726
726
|
function useScrollIntoView(targetRef, deps, scrollOptions = null, flagRefs = []) {
|
|
727
727
|
useEffect(() => {
|
|
@@ -786,13 +786,13 @@ function _getTopOffset(item, scrollContainer, options) {
|
|
|
786
786
|
return 0;
|
|
787
787
|
}
|
|
788
788
|
|
|
789
|
-
/**
|
|
790
|
-
* Evaluate a string reactively based on the expressionLanguage and form data.
|
|
791
|
-
* If the string is not an expression, it is returned as is.
|
|
792
|
-
* The function is memoized to minimize re-renders.
|
|
793
|
-
*
|
|
794
|
-
* @param {string} value - The string to evaluate.
|
|
795
|
-
* @returns {any} - Evaluated value or the original value if not an expression.
|
|
789
|
+
/**
|
|
790
|
+
* Evaluate a string reactively based on the expressionLanguage and form data.
|
|
791
|
+
* If the string is not an expression, it is returned as is.
|
|
792
|
+
* The function is memoized to minimize re-renders.
|
|
793
|
+
*
|
|
794
|
+
* @param {string} value - The string to evaluate.
|
|
795
|
+
* @returns {any} - Evaluated value or the original value if not an expression.
|
|
796
796
|
*/
|
|
797
797
|
function useExpressionEvaluation(value) {
|
|
798
798
|
const expressionLanguage = useService('expressionLanguage');
|
|
@@ -805,11 +805,11 @@ function useExpressionEvaluation(value) {
|
|
|
805
805
|
}, [expressionLanguage, expressionContextInfo, value]);
|
|
806
806
|
}
|
|
807
807
|
|
|
808
|
-
/**
|
|
809
|
-
* Returns the conditionally filtered data of a form reactively.
|
|
810
|
-
* Memoised to minimize re-renders
|
|
811
|
-
*
|
|
812
|
-
* Warning: costly operation, use with care
|
|
808
|
+
/**
|
|
809
|
+
* Returns the conditionally filtered data of a form reactively.
|
|
810
|
+
* Memoised to minimize re-renders
|
|
811
|
+
*
|
|
812
|
+
* Warning: costly operation, use with care
|
|
813
813
|
*/
|
|
814
814
|
function useFilteredFormData() {
|
|
815
815
|
const {
|
|
@@ -842,16 +842,16 @@ function useKeyDownAction(targetKey, action, listenerElement = window) {
|
|
|
842
842
|
});
|
|
843
843
|
}
|
|
844
844
|
|
|
845
|
-
/**
|
|
846
|
-
* Retrieve readonly value of a form field, given it can be an
|
|
847
|
-
* expression optionally or configured globally.
|
|
848
|
-
*
|
|
849
|
-
* @typedef { import('../../types').FormProperties } FormProperties
|
|
850
|
-
*
|
|
851
|
-
* @param {any} formField
|
|
852
|
-
* @param {FormProperties} properties
|
|
853
|
-
*
|
|
854
|
-
* @returns {boolean}
|
|
845
|
+
/**
|
|
846
|
+
* Retrieve readonly value of a form field, given it can be an
|
|
847
|
+
* expression optionally or configured globally.
|
|
848
|
+
*
|
|
849
|
+
* @typedef { import('../../types').FormProperties } FormProperties
|
|
850
|
+
*
|
|
851
|
+
* @param {any} formField
|
|
852
|
+
* @param {FormProperties} properties
|
|
853
|
+
*
|
|
854
|
+
* @returns {boolean}
|
|
855
855
|
*/
|
|
856
856
|
function useReadonly(formField, properties = {}) {
|
|
857
857
|
const expressionLanguage = useService('expressionLanguage');
|
|
@@ -875,12 +875,12 @@ function usePrevious(value, defaultValue, dependencies) {
|
|
|
875
875
|
return ref.current;
|
|
876
876
|
}
|
|
877
877
|
|
|
878
|
-
/**
|
|
879
|
-
* A custom hook to manage state changes with deep comparison.
|
|
880
|
-
*
|
|
881
|
-
* @param {any} value - The current value to manage.
|
|
882
|
-
* @param {any} defaultValue - The initial default value for the state.
|
|
883
|
-
* @returns {any} - Returns the current state.
|
|
878
|
+
/**
|
|
879
|
+
* A custom hook to manage state changes with deep comparison.
|
|
880
|
+
*
|
|
881
|
+
* @param {any} value - The current value to manage.
|
|
882
|
+
* @param {any} defaultValue - The initial default value for the state.
|
|
883
|
+
* @returns {any} - Returns the current state.
|
|
884
884
|
*/
|
|
885
885
|
function useDeepCompareState(value, defaultValue) {
|
|
886
886
|
const [state, setState] = useState(defaultValue);
|
|
@@ -900,16 +900,16 @@ function compare(a, b) {
|
|
|
900
900
|
return JSON.stringify(a) === JSON.stringify(b);
|
|
901
901
|
}
|
|
902
902
|
|
|
903
|
-
/**
|
|
904
|
-
* Template a string reactively based on form data. If the string is not a template, it is returned as is.
|
|
905
|
-
* Memoised to minimize re-renders
|
|
906
|
-
*
|
|
907
|
-
* @param {string} value
|
|
908
|
-
* @param {Object} options
|
|
909
|
-
* @param {boolean} [options.debug = false]
|
|
910
|
-
* @param {boolean} [options.strict = false]
|
|
911
|
-
* @param {Function} [options.buildDebugString]
|
|
912
|
-
*
|
|
903
|
+
/**
|
|
904
|
+
* Template a string reactively based on form data. If the string is not a template, it is returned as is.
|
|
905
|
+
* Memoised to minimize re-renders
|
|
906
|
+
*
|
|
907
|
+
* @param {string} value
|
|
908
|
+
* @param {Object} options
|
|
909
|
+
* @param {boolean} [options.debug = false]
|
|
910
|
+
* @param {boolean} [options.strict = false]
|
|
911
|
+
* @param {Function} [options.buildDebugString]
|
|
912
|
+
*
|
|
913
913
|
*/
|
|
914
914
|
function useTemplateEvaluation(value, options = {}) {
|
|
915
915
|
const templating = useService('templating');
|
|
@@ -922,17 +922,17 @@ function useTemplateEvaluation(value, options = {}) {
|
|
|
922
922
|
}, [templating, value, expressionContextInfo, options]);
|
|
923
923
|
}
|
|
924
924
|
|
|
925
|
-
/**
|
|
926
|
-
* Template a string reactively based on form data. If the string is not a template, it is returned as is.
|
|
927
|
-
* If the string contains multiple lines, only the first line is returned.
|
|
928
|
-
* Memoised to minimize re-renders
|
|
929
|
-
*
|
|
930
|
-
* @param {string} value
|
|
931
|
-
* @param {Object} [options]
|
|
932
|
-
* @param {boolean} [options.debug = false]
|
|
933
|
-
* @param {boolean} [options.strict = false]
|
|
934
|
-
* @param {Function} [options.buildDebugString]
|
|
935
|
-
*
|
|
925
|
+
/**
|
|
926
|
+
* Template a string reactively based on form data. If the string is not a template, it is returned as is.
|
|
927
|
+
* If the string contains multiple lines, only the first line is returned.
|
|
928
|
+
* Memoised to minimize re-renders
|
|
929
|
+
*
|
|
930
|
+
* @param {string} value
|
|
931
|
+
* @param {Object} [options]
|
|
932
|
+
* @param {boolean} [options.debug = false]
|
|
933
|
+
* @param {boolean} [options.strict = false]
|
|
934
|
+
* @param {Function} [options.buildDebugString]
|
|
935
|
+
*
|
|
936
936
|
*/
|
|
937
937
|
function useSingleLineTemplateEvaluation(value, options = {}) {
|
|
938
938
|
const evaluatedTemplate = useTemplateEvaluation(value, options);
|
|
@@ -1088,15 +1088,15 @@ function normalizeOptionsData(optionsData) {
|
|
|
1088
1088
|
return optionsData.filter(_isAllowedValue).map(_normalizeOption).filter(o => !isNil(o));
|
|
1089
1089
|
}
|
|
1090
1090
|
|
|
1091
|
-
/**
|
|
1092
|
-
* Converts the provided option to a normalized format.
|
|
1093
|
-
* If the option is not valid, null is returned.
|
|
1094
|
-
*
|
|
1095
|
-
* @param {object} option
|
|
1096
|
-
* @param {string} option.label
|
|
1097
|
-
* @param {*} option.value
|
|
1098
|
-
*
|
|
1099
|
-
* @returns
|
|
1091
|
+
/**
|
|
1092
|
+
* Converts the provided option to a normalized format.
|
|
1093
|
+
* If the option is not valid, null is returned.
|
|
1094
|
+
*
|
|
1095
|
+
* @param {object} option
|
|
1096
|
+
* @param {string} option.label
|
|
1097
|
+
* @param {*} option.value
|
|
1098
|
+
*
|
|
1099
|
+
* @returns
|
|
1100
1100
|
*/
|
|
1101
1101
|
function _normalizeOption(option) {
|
|
1102
1102
|
// (1) simple primitive case, use it as both label and value
|
|
@@ -1154,8 +1154,8 @@ function createEmptyOptions(options = {}) {
|
|
|
1154
1154
|
};
|
|
1155
1155
|
}
|
|
1156
1156
|
|
|
1157
|
-
/**
|
|
1158
|
-
* @enum { String }
|
|
1157
|
+
/**
|
|
1158
|
+
* @enum { String }
|
|
1159
1159
|
*/
|
|
1160
1160
|
const LOAD_STATES = {
|
|
1161
1161
|
LOADING: 'loading',
|
|
@@ -1163,17 +1163,17 @@ const LOAD_STATES = {
|
|
|
1163
1163
|
ERROR: 'error'
|
|
1164
1164
|
};
|
|
1165
1165
|
|
|
1166
|
-
/**
|
|
1167
|
-
* @typedef {Object} OptionsGetter
|
|
1168
|
-
* @property {Object[]} options - The options data
|
|
1169
|
-
* @property {(LOAD_STATES)} loadState - The options data's loading state, to use for conditional rendering
|
|
1166
|
+
/**
|
|
1167
|
+
* @typedef {Object} OptionsGetter
|
|
1168
|
+
* @property {Object[]} options - The options data
|
|
1169
|
+
* @property {(LOAD_STATES)} loadState - The options data's loading state, to use for conditional rendering
|
|
1170
1170
|
*/
|
|
1171
1171
|
|
|
1172
|
-
/**
|
|
1173
|
-
* A hook to load options for single and multiselect components.
|
|
1174
|
-
*
|
|
1175
|
-
* @param {Object} field - The form field to handle options for
|
|
1176
|
-
* @return {OptionsGetter} optionsGetter - A options getter object providing loading state and options
|
|
1172
|
+
/**
|
|
1173
|
+
* A hook to load options for single and multiselect components.
|
|
1174
|
+
*
|
|
1175
|
+
* @param {Object} field - The form field to handle options for
|
|
1176
|
+
* @return {OptionsGetter} optionsGetter - A options getter object providing loading state and options
|
|
1177
1177
|
*/
|
|
1178
1178
|
function useOptionsAsync (field) {
|
|
1179
1179
|
const {
|
|
@@ -1820,12 +1820,12 @@ FormComponent$1.config = {
|
|
|
1820
1820
|
})
|
|
1821
1821
|
};
|
|
1822
1822
|
|
|
1823
|
-
/**
|
|
1824
|
-
* Returns date format for the provided locale.
|
|
1825
|
-
* If the locale is not provided, uses the browser's locale.
|
|
1826
|
-
*
|
|
1827
|
-
* @param {string} [locale] - The locale to get date format for.
|
|
1828
|
-
* @returns {string} The date format for the locale.
|
|
1823
|
+
/**
|
|
1824
|
+
* Returns date format for the provided locale.
|
|
1825
|
+
* If the locale is not provided, uses the browser's locale.
|
|
1826
|
+
*
|
|
1827
|
+
* @param {string} [locale] - The locale to get date format for.
|
|
1828
|
+
* @returns {string} The date format for the locale.
|
|
1829
1829
|
*/
|
|
1830
1830
|
function getLocaleDateFormat(locale = 'default') {
|
|
1831
1831
|
const parts = new Intl.DateTimeFormat(locale).formatToParts(new Date(Date.UTC(2020, 5, 5)));
|
|
@@ -1844,12 +1844,12 @@ function getLocaleDateFormat(locale = 'default') {
|
|
|
1844
1844
|
}).join('');
|
|
1845
1845
|
}
|
|
1846
1846
|
|
|
1847
|
-
/**
|
|
1848
|
-
* Returns readable date format for the provided locale.
|
|
1849
|
-
* If the locale is not provided, uses the browser's locale.
|
|
1850
|
-
*
|
|
1851
|
-
* @param {string} [locale] - The locale to get readable date format for.
|
|
1852
|
-
* @returns {string} The readable date format for the locale.
|
|
1847
|
+
/**
|
|
1848
|
+
* Returns readable date format for the provided locale.
|
|
1849
|
+
* If the locale is not provided, uses the browser's locale.
|
|
1850
|
+
*
|
|
1851
|
+
* @param {string} [locale] - The locale to get readable date format for.
|
|
1852
|
+
* @returns {string} The readable date format for the locale.
|
|
1853
1853
|
*/
|
|
1854
1854
|
function getLocaleReadableDateFormat(locale) {
|
|
1855
1855
|
let format = getLocaleDateFormat(locale).toLowerCase();
|
|
@@ -1866,12 +1866,12 @@ function getLocaleReadableDateFormat(locale) {
|
|
|
1866
1866
|
return format;
|
|
1867
1867
|
}
|
|
1868
1868
|
|
|
1869
|
-
/**
|
|
1870
|
-
* Returns flatpickr config for the provided locale.
|
|
1871
|
-
* If the locale is not provided, uses the browser's locale.
|
|
1872
|
-
*
|
|
1873
|
-
* @param {string} [locale] - The locale to get flatpickr config for.
|
|
1874
|
-
* @returns {object} The flatpickr config for the locale.
|
|
1869
|
+
/**
|
|
1870
|
+
* Returns flatpickr config for the provided locale.
|
|
1871
|
+
* If the locale is not provided, uses the browser's locale.
|
|
1872
|
+
*
|
|
1873
|
+
* @param {string} [locale] - The locale to get flatpickr config for.
|
|
1874
|
+
* @returns {object} The flatpickr config for the locale.
|
|
1875
1875
|
*/
|
|
1876
1876
|
function getLocaleDateFlatpickrConfig(locale) {
|
|
1877
1877
|
return flatpickerizeDateFormat(getLocaleDateFormat(locale));
|
|
@@ -2583,10 +2583,10 @@ Datetime.config = {
|
|
|
2583
2583
|
}
|
|
2584
2584
|
};
|
|
2585
2585
|
|
|
2586
|
-
/**
|
|
2587
|
-
* This file must not be changed or exchanged.
|
|
2588
|
-
*
|
|
2589
|
-
* @see http://bpmn.io/license for more information.
|
|
2586
|
+
/**
|
|
2587
|
+
* This file must not be changed or exchanged.
|
|
2588
|
+
*
|
|
2589
|
+
* @see http://bpmn.io/license for more information.
|
|
2590
2590
|
*/
|
|
2591
2591
|
function Logo() {
|
|
2592
2592
|
return jsxs("svg", {
|
|
@@ -2772,11 +2772,11 @@ const ATTR_WHITESPACE_PATTERN = /[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u
|
|
|
2772
2772
|
|
|
2773
2773
|
const FORM_ELEMENT = document.createElement('form');
|
|
2774
2774
|
|
|
2775
|
-
/**
|
|
2776
|
-
* Sanitize a HTML string and return the cleaned, safe version.
|
|
2777
|
-
*
|
|
2778
|
-
* @param {string} html
|
|
2779
|
-
* @return {string}
|
|
2775
|
+
/**
|
|
2776
|
+
* Sanitize a HTML string and return the cleaned, safe version.
|
|
2777
|
+
*
|
|
2778
|
+
* @param {string} html
|
|
2779
|
+
* @return {string}
|
|
2780
2780
|
*/
|
|
2781
2781
|
|
|
2782
2782
|
// see https://github.com/developit/snarkdown/issues/70
|
|
@@ -2794,41 +2794,41 @@ function sanitizeHTML(html) {
|
|
|
2794
2794
|
}
|
|
2795
2795
|
}
|
|
2796
2796
|
|
|
2797
|
-
/**
|
|
2798
|
-
* Sanitizes an image source to ensure we only allow for data URI and links
|
|
2799
|
-
* that start with http(s).
|
|
2800
|
-
*
|
|
2801
|
-
* Note: Most browsers anyway do not support script execution in <img> elements.
|
|
2802
|
-
*
|
|
2803
|
-
* @param {string} src
|
|
2804
|
-
* @returns {string}
|
|
2797
|
+
/**
|
|
2798
|
+
* Sanitizes an image source to ensure we only allow for data URI and links
|
|
2799
|
+
* that start with http(s).
|
|
2800
|
+
*
|
|
2801
|
+
* Note: Most browsers anyway do not support script execution in <img> elements.
|
|
2802
|
+
*
|
|
2803
|
+
* @param {string} src
|
|
2804
|
+
* @returns {string}
|
|
2805
2805
|
*/
|
|
2806
2806
|
function sanitizeImageSource(src) {
|
|
2807
2807
|
const valid = ALLOWED_IMAGE_SRC_PATTERN.test(src);
|
|
2808
2808
|
return valid ? src : '';
|
|
2809
2809
|
}
|
|
2810
2810
|
|
|
2811
|
-
/**
|
|
2812
|
-
* Sanitizes an iframe source to ensure we only allow for links
|
|
2813
|
-
* that start with http(s).
|
|
2814
|
-
*
|
|
2815
|
-
* @param {string} src
|
|
2816
|
-
* @returns {string}
|
|
2811
|
+
/**
|
|
2812
|
+
* Sanitizes an iframe source to ensure we only allow for links
|
|
2813
|
+
* that start with http(s).
|
|
2814
|
+
*
|
|
2815
|
+
* @param {string} src
|
|
2816
|
+
* @returns {string}
|
|
2817
2817
|
*/
|
|
2818
2818
|
function sanitizeIFrameSource(src) {
|
|
2819
2819
|
const valid = ALLOWED_IFRAME_SRC_PATTERN.test(src);
|
|
2820
2820
|
return valid ? src : '';
|
|
2821
2821
|
}
|
|
2822
2822
|
|
|
2823
|
-
/**
|
|
2824
|
-
* Recursively sanitize a HTML node, potentially
|
|
2825
|
-
* removing it, its children or attributes.
|
|
2826
|
-
*
|
|
2827
|
-
* Inspired by https://github.com/developit/snarkdown/issues/70
|
|
2828
|
-
* and https://github.com/cure53/DOMPurify. Simplified
|
|
2829
|
-
* for our use-case.
|
|
2830
|
-
*
|
|
2831
|
-
* @param {Element} node
|
|
2823
|
+
/**
|
|
2824
|
+
* Recursively sanitize a HTML node, potentially
|
|
2825
|
+
* removing it, its children or attributes.
|
|
2826
|
+
*
|
|
2827
|
+
* Inspired by https://github.com/developit/snarkdown/issues/70
|
|
2828
|
+
* and https://github.com/cure53/DOMPurify. Simplified
|
|
2829
|
+
* for our use-case.
|
|
2830
|
+
*
|
|
2831
|
+
* @param {Element} node
|
|
2832
2832
|
*/
|
|
2833
2833
|
function sanitizeNode(node) {
|
|
2834
2834
|
// allow text nodes
|
|
@@ -2872,13 +2872,13 @@ function sanitizeNode(node) {
|
|
|
2872
2872
|
}
|
|
2873
2873
|
}
|
|
2874
2874
|
|
|
2875
|
-
/**
|
|
2876
|
-
* Validates attributes for validity.
|
|
2877
|
-
*
|
|
2878
|
-
* @param {string} lcTag
|
|
2879
|
-
* @param {string} lcName
|
|
2880
|
-
* @param {string} value
|
|
2881
|
-
* @return {boolean}
|
|
2875
|
+
/**
|
|
2876
|
+
* Validates attributes for validity.
|
|
2877
|
+
*
|
|
2878
|
+
* @param {string} lcTag
|
|
2879
|
+
* @param {string} lcName
|
|
2880
|
+
* @param {string} value
|
|
2881
|
+
* @return {boolean}
|
|
2882
2882
|
*/
|
|
2883
2883
|
function isValidAttribute(lcTag, lcName, value) {
|
|
2884
2884
|
// disallow most attributes based on whitelist
|
|
@@ -3493,9 +3493,9 @@ Radio.config = {
|
|
|
3493
3493
|
create: createEmptyOptions
|
|
3494
3494
|
};
|
|
3495
3495
|
|
|
3496
|
-
/**
|
|
3497
|
-
* This hook allows us to retrieve the label from a value in linear time by caching it in a map
|
|
3498
|
-
* @param {Array} options
|
|
3496
|
+
/**
|
|
3497
|
+
* This hook allows us to retrieve the label from a value in linear time by caching it in a map
|
|
3498
|
+
* @param {Array} options
|
|
3499
3499
|
*/
|
|
3500
3500
|
function useGetLabelCorrelation(options) {
|
|
3501
3501
|
// This allows us to retrieve the label from a value in linear time
|
|
@@ -4607,28 +4607,28 @@ var CaretRightIcon = SvgCaretRight;
|
|
|
4607
4607
|
|
|
4608
4608
|
const type = 'table';
|
|
4609
4609
|
|
|
4610
|
-
/**
|
|
4611
|
-
* @typedef {('asc'|'desc')} Direction
|
|
4612
|
-
*
|
|
4613
|
-
* @typedef Sorting
|
|
4614
|
-
* @property {string} key
|
|
4615
|
-
* @property {Direction} direction
|
|
4616
|
-
*
|
|
4617
|
-
* @typedef Column
|
|
4618
|
-
* @property {string} label
|
|
4619
|
-
* @property {string} key
|
|
4620
|
-
*
|
|
4621
|
-
* @typedef Props
|
|
4622
|
-
* @property {Object} field
|
|
4623
|
-
* @property {string} field.id
|
|
4624
|
-
* @property {Array<Column>} [field.columns]
|
|
4625
|
-
* @property {string} [field.columnsExpression]
|
|
4626
|
-
* @property {string} [field.label]
|
|
4627
|
-
* @property {number} [field.rowCount]
|
|
4628
|
-
* @property {string} [field.dataSource]
|
|
4629
|
-
*
|
|
4630
|
-
* @param {Props} props
|
|
4631
|
-
* @returns {import("preact").JSX.Element}
|
|
4610
|
+
/**
|
|
4611
|
+
* @typedef {('asc'|'desc')} Direction
|
|
4612
|
+
*
|
|
4613
|
+
* @typedef Sorting
|
|
4614
|
+
* @property {string} key
|
|
4615
|
+
* @property {Direction} direction
|
|
4616
|
+
*
|
|
4617
|
+
* @typedef Column
|
|
4618
|
+
* @property {string} label
|
|
4619
|
+
* @property {string} key
|
|
4620
|
+
*
|
|
4621
|
+
* @typedef Props
|
|
4622
|
+
* @property {Object} field
|
|
4623
|
+
* @property {string} field.id
|
|
4624
|
+
* @property {Array<Column>} [field.columns]
|
|
4625
|
+
* @property {string} [field.columnsExpression]
|
|
4626
|
+
* @property {string} [field.label]
|
|
4627
|
+
* @property {number} [field.rowCount]
|
|
4628
|
+
* @property {string} [field.dataSource]
|
|
4629
|
+
*
|
|
4630
|
+
* @param {Props} props
|
|
4631
|
+
* @returns {import("preact").JSX.Element}
|
|
4632
4632
|
*/
|
|
4633
4633
|
function Table(props) {
|
|
4634
4634
|
const {
|
|
@@ -4838,10 +4838,10 @@ Table.config = {
|
|
|
4838
4838
|
|
|
4839
4839
|
// helpers /////////////////////////////
|
|
4840
4840
|
|
|
4841
|
-
/**
|
|
4842
|
-
* @param {string|void} columnsExpression
|
|
4843
|
-
* @param {Column[]} fallbackColumns
|
|
4844
|
-
* @returns {Column[]}
|
|
4841
|
+
/**
|
|
4842
|
+
* @param {string|void} columnsExpression
|
|
4843
|
+
* @param {Column[]} fallbackColumns
|
|
4844
|
+
* @returns {Column[]}
|
|
4845
4845
|
*/
|
|
4846
4846
|
function useEvaluatedColumns(columnsExpression, fallbackColumns) {
|
|
4847
4847
|
/** @type {Column[]|null} */
|
|
@@ -4849,18 +4849,18 @@ function useEvaluatedColumns(columnsExpression, fallbackColumns) {
|
|
|
4849
4849
|
return Array.isArray(evaluation) && evaluation.every(isColumn) ? evaluation : fallbackColumns;
|
|
4850
4850
|
}
|
|
4851
4851
|
|
|
4852
|
-
/**
|
|
4853
|
-
* @param {any} column
|
|
4854
|
-
* @returns {column is Column}
|
|
4852
|
+
/**
|
|
4853
|
+
* @param {any} column
|
|
4854
|
+
* @returns {column is Column}
|
|
4855
4855
|
*/
|
|
4856
4856
|
function isColumn(column) {
|
|
4857
4857
|
return isObject(column) && isString(column['label']) && isString(column['key']);
|
|
4858
4858
|
}
|
|
4859
4859
|
|
|
4860
|
-
/**
|
|
4861
|
-
* @param {Array} array
|
|
4862
|
-
* @param {number} size
|
|
4863
|
-
* @returns {Array}
|
|
4860
|
+
/**
|
|
4861
|
+
* @param {Array} array
|
|
4862
|
+
* @param {number} size
|
|
4863
|
+
* @returns {Array}
|
|
4864
4864
|
*/
|
|
4865
4865
|
function chunk(array, size) {
|
|
4866
4866
|
return array.reduce((chunks, item, index) => {
|
|
@@ -4873,11 +4873,11 @@ function chunk(array, size) {
|
|
|
4873
4873
|
}, []);
|
|
4874
4874
|
}
|
|
4875
4875
|
|
|
4876
|
-
/**
|
|
4877
|
-
* @param {unknown[]} array
|
|
4878
|
-
* @param {string} key
|
|
4879
|
-
* @param {Direction} direction
|
|
4880
|
-
* @returns {unknown[]}
|
|
4876
|
+
/**
|
|
4877
|
+
* @param {unknown[]} array
|
|
4878
|
+
* @param {string} key
|
|
4879
|
+
* @param {Direction} direction
|
|
4880
|
+
* @returns {unknown[]}
|
|
4881
4881
|
*/
|
|
4882
4882
|
function sortByColumn(array, key, direction) {
|
|
4883
4883
|
return [...array].sort((a, b) => {
|
|
@@ -4891,10 +4891,10 @@ function sortByColumn(array, key, direction) {
|
|
|
4891
4891
|
});
|
|
4892
4892
|
}
|
|
4893
4893
|
|
|
4894
|
-
/**
|
|
4895
|
-
* @param {null|Sorting} sortBy
|
|
4896
|
-
* @param {string} key
|
|
4897
|
-
* @param {string} label
|
|
4894
|
+
/**
|
|
4895
|
+
* @param {null|Sorting} sortBy
|
|
4896
|
+
* @param {string} key
|
|
4897
|
+
* @param {string} label
|
|
4898
4898
|
*/
|
|
4899
4899
|
function getHeaderAriaLabel(sortBy, key, label) {
|
|
4900
4900
|
if (sortBy === null || sortBy.key !== key) {
|
|
@@ -5269,37 +5269,37 @@ class FormFields {
|
|
|
5269
5269
|
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'];
|
|
5270
5270
|
const TEMPLATE_PROPERTIES = ['alt', 'appearance.prefixAdorner', 'appearance.suffixAdorner', 'description', 'label', 'source', 'text', 'url'];
|
|
5271
5271
|
|
|
5272
|
-
/**
|
|
5273
|
-
* @typedef { import('../types').Schema } Schema
|
|
5272
|
+
/**
|
|
5273
|
+
* @typedef { import('../types').Schema } Schema
|
|
5274
5274
|
*/
|
|
5275
5275
|
|
|
5276
|
-
/**
|
|
5277
|
-
* Parse the schema for variables a form might make use of.
|
|
5278
|
-
*
|
|
5279
|
-
* @example
|
|
5280
|
-
*
|
|
5281
|
-
* // retrieve variables from schema
|
|
5282
|
-
* const variables = getSchemaVariables(schema);
|
|
5283
|
-
*
|
|
5284
|
-
* @example
|
|
5285
|
-
*
|
|
5286
|
-
* // retrieve input variables from schema
|
|
5287
|
-
* const inputVariables = getSchemaVariables(schema, { outputs: false });
|
|
5288
|
-
*
|
|
5289
|
-
* @example
|
|
5290
|
-
*
|
|
5291
|
-
* // retrieve output variables from schema
|
|
5292
|
-
* const outputVariables = getSchemaVariables(schema, { inputs: false });
|
|
5293
|
-
*
|
|
5294
|
-
* @param {Schema} schema
|
|
5295
|
-
* @param {object} [options]
|
|
5296
|
-
* @param {any} [options.expressionLanguage]
|
|
5297
|
-
* @param {any} [options.templating]
|
|
5298
|
-
* @param {any} [options.formFields]
|
|
5299
|
-
* @param {boolean} [options.inputs=true]
|
|
5300
|
-
* @param {boolean} [options.outputs=true]
|
|
5301
|
-
*
|
|
5302
|
-
* @return {string[]}
|
|
5276
|
+
/**
|
|
5277
|
+
* Parse the schema for variables a form might make use of.
|
|
5278
|
+
*
|
|
5279
|
+
* @example
|
|
5280
|
+
*
|
|
5281
|
+
* // retrieve variables from schema
|
|
5282
|
+
* const variables = getSchemaVariables(schema);
|
|
5283
|
+
*
|
|
5284
|
+
* @example
|
|
5285
|
+
*
|
|
5286
|
+
* // retrieve input variables from schema
|
|
5287
|
+
* const inputVariables = getSchemaVariables(schema, { outputs: false });
|
|
5288
|
+
*
|
|
5289
|
+
* @example
|
|
5290
|
+
*
|
|
5291
|
+
* // retrieve output variables from schema
|
|
5292
|
+
* const outputVariables = getSchemaVariables(schema, { inputs: false });
|
|
5293
|
+
*
|
|
5294
|
+
* @param {Schema} schema
|
|
5295
|
+
* @param {object} [options]
|
|
5296
|
+
* @param {any} [options.expressionLanguage]
|
|
5297
|
+
* @param {any} [options.templating]
|
|
5298
|
+
* @param {any} [options.formFields]
|
|
5299
|
+
* @param {boolean} [options.inputs=true]
|
|
5300
|
+
* @param {boolean} [options.outputs=true]
|
|
5301
|
+
*
|
|
5302
|
+
* @return {string[]}
|
|
5303
5303
|
*/
|
|
5304
5304
|
function getSchemaVariables(schema, options = {}) {
|
|
5305
5305
|
const {
|
|
@@ -5375,13 +5375,13 @@ function getSchemaVariables(schema, options = {}) {
|
|
|
5375
5375
|
return Array.from(new Set(variables));
|
|
5376
5376
|
}
|
|
5377
5377
|
|
|
5378
|
-
/**
|
|
5379
|
-
* Get the ancestry list of a form field.
|
|
5380
|
-
*
|
|
5381
|
-
* @param {string} formFieldId
|
|
5382
|
-
* @param {import('../core/FormFieldRegistry').default} formFieldRegistry
|
|
5383
|
-
*
|
|
5384
|
-
* @return {Array<string>} ancestry list
|
|
5378
|
+
/**
|
|
5379
|
+
* Get the ancestry list of a form field.
|
|
5380
|
+
*
|
|
5381
|
+
* @param {string} formFieldId
|
|
5382
|
+
* @param {import('../core/FormFieldRegistry').default} formFieldRegistry
|
|
5383
|
+
*
|
|
5384
|
+
* @return {Array<string>} ancestry list
|
|
5385
5385
|
*/
|
|
5386
5386
|
const getAncestryList = (formFieldId, formFieldRegistry) => {
|
|
5387
5387
|
const ids = [];
|
|
@@ -5393,9 +5393,9 @@ const getAncestryList = (formFieldId, formFieldRegistry) => {
|
|
|
5393
5393
|
return ids;
|
|
5394
5394
|
};
|
|
5395
5395
|
|
|
5396
|
-
/**
|
|
5397
|
-
* @typedef {object} Condition
|
|
5398
|
-
* @property {string} [hide]
|
|
5396
|
+
/**
|
|
5397
|
+
* @typedef {object} Condition
|
|
5398
|
+
* @property {string} [hide]
|
|
5399
5399
|
*/
|
|
5400
5400
|
|
|
5401
5401
|
class ConditionChecker {
|
|
@@ -5405,14 +5405,14 @@ class ConditionChecker {
|
|
|
5405
5405
|
this._eventBus = eventBus;
|
|
5406
5406
|
}
|
|
5407
5407
|
|
|
5408
|
-
/**
|
|
5409
|
-
* For given data, remove properties based on condition.
|
|
5410
|
-
*
|
|
5411
|
-
* @param {Object<string, any>} data
|
|
5412
|
-
* @param {Object<string, any>} contextData
|
|
5413
|
-
* @param {Object} [options]
|
|
5414
|
-
* @param {Function} [options.getFilterPath]
|
|
5415
|
-
* @param {boolean} [options.leafNodeDeletionOnly]
|
|
5408
|
+
/**
|
|
5409
|
+
* For given data, remove properties based on condition.
|
|
5410
|
+
*
|
|
5411
|
+
* @param {Object<string, any>} data
|
|
5412
|
+
* @param {Object<string, any>} contextData
|
|
5413
|
+
* @param {Object} [options]
|
|
5414
|
+
* @param {Function} [options.getFilterPath]
|
|
5415
|
+
* @param {boolean} [options.leafNodeDeletionOnly]
|
|
5416
5416
|
*/
|
|
5417
5417
|
applyConditions(data, contextData = {}, options = {}) {
|
|
5418
5418
|
const workingData = clone(data);
|
|
@@ -5506,13 +5506,13 @@ class ConditionChecker {
|
|
|
5506
5506
|
return workingData;
|
|
5507
5507
|
}
|
|
5508
5508
|
|
|
5509
|
-
/**
|
|
5510
|
-
* Check if given condition is met. Returns null for invalid/missing conditions.
|
|
5511
|
-
*
|
|
5512
|
-
* @param {string} condition
|
|
5513
|
-
* @param {import('../../types').Data} [data]
|
|
5514
|
-
*
|
|
5515
|
-
* @returns {boolean|null}
|
|
5509
|
+
/**
|
|
5510
|
+
* Check if given condition is met. Returns null for invalid/missing conditions.
|
|
5511
|
+
*
|
|
5512
|
+
* @param {string} condition
|
|
5513
|
+
* @param {import('../../types').Data} [data]
|
|
5514
|
+
*
|
|
5515
|
+
* @returns {boolean|null}
|
|
5516
5516
|
*/
|
|
5517
5517
|
check(condition, data = {}) {
|
|
5518
5518
|
if (!condition) {
|
|
@@ -5533,12 +5533,12 @@ class ConditionChecker {
|
|
|
5533
5533
|
}
|
|
5534
5534
|
}
|
|
5535
5535
|
|
|
5536
|
-
/**
|
|
5537
|
-
* Check if hide condition is met.
|
|
5538
|
-
*
|
|
5539
|
-
* @param {Condition} condition
|
|
5540
|
-
* @param {Object<string, any>} data
|
|
5541
|
-
* @returns {boolean}
|
|
5536
|
+
/**
|
|
5537
|
+
* Check if hide condition is met.
|
|
5538
|
+
*
|
|
5539
|
+
* @param {Condition} condition
|
|
5540
|
+
* @param {Object<string, any>} data
|
|
5541
|
+
* @returns {boolean}
|
|
5542
5542
|
*/
|
|
5543
5543
|
_checkHideCondition(condition, data) {
|
|
5544
5544
|
if (!condition.hide) {
|
|
@@ -5580,12 +5580,12 @@ class MarkdownRenderer {
|
|
|
5580
5580
|
this._converter = new showdown.Converter();
|
|
5581
5581
|
}
|
|
5582
5582
|
|
|
5583
|
-
/**
|
|
5584
|
-
* Render markdown to HTML.
|
|
5585
|
-
*
|
|
5586
|
-
* @param {string} markdown - The markdown to render
|
|
5587
|
-
*
|
|
5588
|
-
* @returns {string} HTML
|
|
5583
|
+
/**
|
|
5584
|
+
* Render markdown to HTML.
|
|
5585
|
+
*
|
|
5586
|
+
* @param {string} markdown - The markdown to render
|
|
5587
|
+
*
|
|
5588
|
+
* @returns {string} HTML
|
|
5589
5589
|
*/
|
|
5590
5590
|
render(markdown) {
|
|
5591
5591
|
return this._converter.makeHtml(markdown);
|
|
@@ -6206,11 +6206,11 @@ class RepeatRenderManager {
|
|
|
6206
6206
|
this.RepeatFooter = this.RepeatFooter.bind(this);
|
|
6207
6207
|
}
|
|
6208
6208
|
|
|
6209
|
-
/**
|
|
6210
|
-
* Checks whether a field is currently repeating its children.
|
|
6211
|
-
*
|
|
6212
|
-
* @param {string} id - The id of the field to check
|
|
6213
|
-
* @returns {boolean} - True if repeatable, false otherwise
|
|
6209
|
+
/**
|
|
6210
|
+
* Checks whether a field is currently repeating its children.
|
|
6211
|
+
*
|
|
6212
|
+
* @param {string} id - The id of the field to check
|
|
6213
|
+
* @returns {boolean} - True if repeatable, false otherwise
|
|
6214
6214
|
*/
|
|
6215
6215
|
isFieldRepeating(id) {
|
|
6216
6216
|
if (!id) {
|
|
@@ -6970,8 +6970,8 @@ Validator.$inject = ['expressionLanguage', 'conditionChecker', 'form'];
|
|
|
6970
6970
|
|
|
6971
6971
|
// helpers //////////
|
|
6972
6972
|
|
|
6973
|
-
/**
|
|
6974
|
-
* Helper function to evaluate optional FEEL validation values.
|
|
6973
|
+
/**
|
|
6974
|
+
* Helper function to evaluate optional FEEL validation values.
|
|
6975
6975
|
*/
|
|
6976
6976
|
function evaluateFEELValues(validate, expressionLanguage, conditionChecker, form) {
|
|
6977
6977
|
const evaluatedValidate = {
|
|
@@ -7005,12 +7005,12 @@ function evaluateFEELValues(validate, expressionLanguage, conditionChecker, form
|
|
|
7005
7005
|
}
|
|
7006
7006
|
|
|
7007
7007
|
class Importer {
|
|
7008
|
-
/**
|
|
7009
|
-
* @constructor
|
|
7010
|
-
* @param { import('./FormFieldRegistry').default } formFieldRegistry
|
|
7011
|
-
* @param { import('./PathRegistry').default } pathRegistry
|
|
7012
|
-
* @param { import('./FieldFactory').default } fieldFactory
|
|
7013
|
-
* @param { import('./FormLayouter').default } formLayouter
|
|
7008
|
+
/**
|
|
7009
|
+
* @constructor
|
|
7010
|
+
* @param { import('./FormFieldRegistry').default } formFieldRegistry
|
|
7011
|
+
* @param { import('./PathRegistry').default } pathRegistry
|
|
7012
|
+
* @param { import('./FieldFactory').default } fieldFactory
|
|
7013
|
+
* @param { import('./FormLayouter').default } formLayouter
|
|
7014
7014
|
*/
|
|
7015
7015
|
constructor(formFieldRegistry, pathRegistry, fieldFactory, formLayouter) {
|
|
7016
7016
|
this._formFieldRegistry = formFieldRegistry;
|
|
@@ -7019,21 +7019,21 @@ class Importer {
|
|
|
7019
7019
|
this._formLayouter = formLayouter;
|
|
7020
7020
|
}
|
|
7021
7021
|
|
|
7022
|
-
/**
|
|
7023
|
-
* Import schema creating rows, fields, attaching additional
|
|
7024
|
-
* information to each field and adding fields to the
|
|
7025
|
-
* field registry.
|
|
7026
|
-
*
|
|
7027
|
-
* Additional information attached:
|
|
7028
|
-
*
|
|
7029
|
-
* * `id` (unless present)
|
|
7030
|
-
* * `_parent`
|
|
7031
|
-
* * `_path`
|
|
7032
|
-
*
|
|
7033
|
-
* @param {any} schema
|
|
7034
|
-
*
|
|
7035
|
-
* @typedef {{ warnings: Error[], schema: any }} ImportResult
|
|
7036
|
-
* @returns {ImportResult}
|
|
7022
|
+
/**
|
|
7023
|
+
* Import schema creating rows, fields, attaching additional
|
|
7024
|
+
* information to each field and adding fields to the
|
|
7025
|
+
* field registry.
|
|
7026
|
+
*
|
|
7027
|
+
* Additional information attached:
|
|
7028
|
+
*
|
|
7029
|
+
* * `id` (unless present)
|
|
7030
|
+
* * `_parent`
|
|
7031
|
+
* * `_path`
|
|
7032
|
+
*
|
|
7033
|
+
* @param {any} schema
|
|
7034
|
+
*
|
|
7035
|
+
* @typedef {{ warnings: Error[], schema: any }} ImportResult
|
|
7036
|
+
* @returns {ImportResult}
|
|
7037
7037
|
*/
|
|
7038
7038
|
importSchema(schema) {
|
|
7039
7039
|
// TODO: Add warnings
|
|
@@ -7058,12 +7058,12 @@ class Importer {
|
|
|
7058
7058
|
this._pathRegistry.clear();
|
|
7059
7059
|
}
|
|
7060
7060
|
|
|
7061
|
-
/**
|
|
7062
|
-
* @param {{[x: string]: any}} fieldAttrs
|
|
7063
|
-
* @param {String} [parentId]
|
|
7064
|
-
* @param {number} [index]
|
|
7065
|
-
*
|
|
7066
|
-
* @return {any} field
|
|
7061
|
+
/**
|
|
7062
|
+
* @param {{[x: string]: any}} fieldAttrs
|
|
7063
|
+
* @param {String} [parentId]
|
|
7064
|
+
* @param {number} [index]
|
|
7065
|
+
*
|
|
7066
|
+
* @return {any} field
|
|
7067
7067
|
*/
|
|
7068
7068
|
importFormField(fieldAttrs, parentId, index) {
|
|
7069
7069
|
const {
|
|
@@ -7088,11 +7088,11 @@ class Importer {
|
|
|
7088
7088
|
return field;
|
|
7089
7089
|
}
|
|
7090
7090
|
|
|
7091
|
-
/**
|
|
7092
|
-
* @param {Array<any>} components
|
|
7093
|
-
* @param {string} parentId
|
|
7094
|
-
*
|
|
7095
|
-
* @return {Array<any>} imported components
|
|
7091
|
+
/**
|
|
7092
|
+
* @param {Array<any>} components
|
|
7093
|
+
* @param {string} parentId
|
|
7094
|
+
*
|
|
7095
|
+
* @return {Array<any>} imported components
|
|
7096
7096
|
*/
|
|
7097
7097
|
importFormFields(components, parentId) {
|
|
7098
7098
|
return components.map((component, index) => {
|
|
@@ -7103,11 +7103,11 @@ class Importer {
|
|
|
7103
7103
|
Importer.$inject = ['formFieldRegistry', 'pathRegistry', 'fieldFactory', 'formLayouter'];
|
|
7104
7104
|
|
|
7105
7105
|
class FieldFactory {
|
|
7106
|
-
/**
|
|
7107
|
-
* @constructor
|
|
7108
|
-
*
|
|
7109
|
-
* @param formFieldRegistry
|
|
7110
|
-
* @param formFields
|
|
7106
|
+
/**
|
|
7107
|
+
* @constructor
|
|
7108
|
+
*
|
|
7109
|
+
* @param formFieldRegistry
|
|
7110
|
+
* @param formFields
|
|
7111
7111
|
*/
|
|
7112
7112
|
constructor(formFieldRegistry, pathRegistry, formFields) {
|
|
7113
7113
|
this._formFieldRegistry = formFieldRegistry;
|
|
@@ -7217,36 +7217,36 @@ class FieldFactory {
|
|
|
7217
7217
|
}
|
|
7218
7218
|
FieldFactory.$inject = ['formFieldRegistry', 'pathRegistry', 'formFields'];
|
|
7219
7219
|
|
|
7220
|
-
/**
|
|
7221
|
-
* The PathRegistry class manages a hierarchical structure of paths associated with form fields.
|
|
7222
|
-
* It enables claiming, unclaiming, and validating paths within this structure.
|
|
7223
|
-
*
|
|
7224
|
-
* Example Tree Structure:
|
|
7225
|
-
*
|
|
7226
|
-
* [
|
|
7227
|
-
* {
|
|
7228
|
-
* segment: 'root',
|
|
7229
|
-
* claimCount: 1,
|
|
7230
|
-
* children: [
|
|
7231
|
-
* {
|
|
7232
|
-
* segment: 'child1',
|
|
7233
|
-
* claimCount: 2,
|
|
7234
|
-
* children: null // A leaf node (closed path)
|
|
7235
|
-
* },
|
|
7236
|
-
* {
|
|
7237
|
-
* segment: 'child2',
|
|
7238
|
-
* claimCount: 1,
|
|
7239
|
-
* children: [
|
|
7240
|
-
* {
|
|
7241
|
-
* segment: 'subChild1',
|
|
7242
|
-
* claimCount: 1,
|
|
7243
|
-
* children: [] // An open node (open path)
|
|
7244
|
-
* }
|
|
7245
|
-
* ]
|
|
7246
|
-
* }
|
|
7247
|
-
* ]
|
|
7248
|
-
* }
|
|
7249
|
-
* ]
|
|
7220
|
+
/**
|
|
7221
|
+
* The PathRegistry class manages a hierarchical structure of paths associated with form fields.
|
|
7222
|
+
* It enables claiming, unclaiming, and validating paths within this structure.
|
|
7223
|
+
*
|
|
7224
|
+
* Example Tree Structure:
|
|
7225
|
+
*
|
|
7226
|
+
* [
|
|
7227
|
+
* {
|
|
7228
|
+
* segment: 'root',
|
|
7229
|
+
* claimCount: 1,
|
|
7230
|
+
* children: [
|
|
7231
|
+
* {
|
|
7232
|
+
* segment: 'child1',
|
|
7233
|
+
* claimCount: 2,
|
|
7234
|
+
* children: null // A leaf node (closed path)
|
|
7235
|
+
* },
|
|
7236
|
+
* {
|
|
7237
|
+
* segment: 'child2',
|
|
7238
|
+
* claimCount: 1,
|
|
7239
|
+
* children: [
|
|
7240
|
+
* {
|
|
7241
|
+
* segment: 'subChild1',
|
|
7242
|
+
* claimCount: 1,
|
|
7243
|
+
* children: [] // An open node (open path)
|
|
7244
|
+
* }
|
|
7245
|
+
* ]
|
|
7246
|
+
* }
|
|
7247
|
+
* ]
|
|
7248
|
+
* }
|
|
7249
|
+
* ]
|
|
7250
7250
|
*/
|
|
7251
7251
|
class PathRegistry {
|
|
7252
7252
|
constructor(formFieldRegistry, formFields, injector) {
|
|
@@ -7362,16 +7362,16 @@ class PathRegistry {
|
|
|
7362
7362
|
}
|
|
7363
7363
|
}
|
|
7364
7364
|
|
|
7365
|
-
/**
|
|
7366
|
-
* Applies a function (fn) recursively on a given field and its children.
|
|
7367
|
-
*
|
|
7368
|
-
* - `field`: Starting field object.
|
|
7369
|
-
* - `fn`: Function to apply.
|
|
7370
|
-
* - `context`: Optional object for passing data between calls.
|
|
7371
|
-
*
|
|
7372
|
-
* Stops early if `fn` returns `false`. Useful for traversing the form field tree.
|
|
7373
|
-
*
|
|
7374
|
-
* @returns {boolean} Success status based on function execution.
|
|
7365
|
+
/**
|
|
7366
|
+
* Applies a function (fn) recursively on a given field and its children.
|
|
7367
|
+
*
|
|
7368
|
+
* - `field`: Starting field object.
|
|
7369
|
+
* - `fn`: Function to apply.
|
|
7370
|
+
* - `context`: Optional object for passing data between calls.
|
|
7371
|
+
*
|
|
7372
|
+
* Stops early if `fn` returns `false`. Useful for traversing the form field tree.
|
|
7373
|
+
*
|
|
7374
|
+
* @returns {boolean} Success status based on function execution.
|
|
7375
7375
|
*/
|
|
7376
7376
|
executeRecursivelyOnFields(field, fn, context = {}) {
|
|
7377
7377
|
let result = true;
|
|
@@ -7412,16 +7412,16 @@ class PathRegistry {
|
|
|
7412
7412
|
return result;
|
|
7413
7413
|
}
|
|
7414
7414
|
|
|
7415
|
-
/**
|
|
7416
|
-
* Generates an array representing the binding path to an underlying data object for a form field.
|
|
7417
|
-
*
|
|
7418
|
-
* @param {Object} field - The field object with properties: `key`, `path`, `id`, and optionally `_parent`.
|
|
7419
|
-
* @param {Object} [options={}] - Configuration options.
|
|
7420
|
-
* @param {Object} [options.replacements={}] - A map of field IDs to alternative path arrays.
|
|
7421
|
-
* @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.
|
|
7422
|
-
* @param {Object} [options.cutoffNode] - The ID of the parent field at which to stop generating the path.
|
|
7423
|
-
*
|
|
7424
|
-
* @returns {(Array<string>|undefined)} An array of strings representing the binding path, or undefined if not determinable.
|
|
7415
|
+
/**
|
|
7416
|
+
* Generates an array representing the binding path to an underlying data object for a form field.
|
|
7417
|
+
*
|
|
7418
|
+
* @param {Object} field - The field object with properties: `key`, `path`, `id`, and optionally `_parent`.
|
|
7419
|
+
* @param {Object} [options={}] - Configuration options.
|
|
7420
|
+
* @param {Object} [options.replacements={}] - A map of field IDs to alternative path arrays.
|
|
7421
|
+
* @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.
|
|
7422
|
+
* @param {Object} [options.cutoffNode] - The ID of the parent field at which to stop generating the path.
|
|
7423
|
+
*
|
|
7424
|
+
* @returns {(Array<string>|undefined)} An array of strings representing the binding path, or undefined if not determinable.
|
|
7425
7425
|
*/
|
|
7426
7426
|
getValuePath(field, options = {}) {
|
|
7427
7427
|
const {
|
|
@@ -7482,23 +7482,23 @@ const _getNextSegment = (node, segment) => {
|
|
|
7482
7482
|
};
|
|
7483
7483
|
PathRegistry.$inject = ['formFieldRegistry', 'formFields', 'injector'];
|
|
7484
7484
|
|
|
7485
|
-
/**
|
|
7486
|
-
* @typedef { { id: String, components: Array<String> } } FormRow
|
|
7487
|
-
* @typedef { { formFieldId: String, rows: Array<FormRow> } } FormRows
|
|
7485
|
+
/**
|
|
7486
|
+
* @typedef { { id: String, components: Array<String> } } FormRow
|
|
7487
|
+
* @typedef { { formFieldId: String, rows: Array<FormRow> } } FormRows
|
|
7488
7488
|
*/
|
|
7489
7489
|
|
|
7490
|
-
/**
|
|
7491
|
-
* Maintains the Form layout in a given structure, for example
|
|
7492
|
-
*
|
|
7493
|
-
* [
|
|
7494
|
-
* {
|
|
7495
|
-
* formFieldId: 'FormField_1',
|
|
7496
|
-
* rows: [
|
|
7497
|
-
* { id: 'Row_1', components: [ 'Text_1', 'Textdield_1', ... ] }
|
|
7498
|
-
* ]
|
|
7499
|
-
* }
|
|
7500
|
-
* ]
|
|
7501
|
-
*
|
|
7490
|
+
/**
|
|
7491
|
+
* Maintains the Form layout in a given structure, for example
|
|
7492
|
+
*
|
|
7493
|
+
* [
|
|
7494
|
+
* {
|
|
7495
|
+
* formFieldId: 'FormField_1',
|
|
7496
|
+
* rows: [
|
|
7497
|
+
* { id: 'Row_1', components: [ 'Text_1', 'Textdield_1', ... ] }
|
|
7498
|
+
* ]
|
|
7499
|
+
* }
|
|
7500
|
+
* ]
|
|
7501
|
+
*
|
|
7502
7502
|
*/
|
|
7503
7503
|
class FormLayouter {
|
|
7504
7504
|
constructor(eventBus) {
|
|
@@ -7508,8 +7508,8 @@ class FormLayouter {
|
|
|
7508
7508
|
this._eventBus = eventBus;
|
|
7509
7509
|
}
|
|
7510
7510
|
|
|
7511
|
-
/**
|
|
7512
|
-
* @param {FormRow} row
|
|
7511
|
+
/**
|
|
7512
|
+
* @param {FormRow} row
|
|
7513
7513
|
*/
|
|
7514
7514
|
addRow(formFieldId, row) {
|
|
7515
7515
|
let rowsPerComponent = this._rows.find(r => r.formFieldId === formFieldId);
|
|
@@ -7523,18 +7523,18 @@ class FormLayouter {
|
|
|
7523
7523
|
rowsPerComponent.rows.push(row);
|
|
7524
7524
|
}
|
|
7525
7525
|
|
|
7526
|
-
/**
|
|
7527
|
-
* @param {String} id
|
|
7528
|
-
* @returns {FormRow}
|
|
7526
|
+
/**
|
|
7527
|
+
* @param {String} id
|
|
7528
|
+
* @returns {FormRow}
|
|
7529
7529
|
*/
|
|
7530
7530
|
getRow(id) {
|
|
7531
7531
|
const rows = allRows(this._rows);
|
|
7532
7532
|
return rows.find(r => r.id === id);
|
|
7533
7533
|
}
|
|
7534
7534
|
|
|
7535
|
-
/**
|
|
7536
|
-
* @param {any} formField
|
|
7537
|
-
* @returns {FormRow}
|
|
7535
|
+
/**
|
|
7536
|
+
* @param {any} formField
|
|
7537
|
+
* @returns {FormRow}
|
|
7538
7538
|
*/
|
|
7539
7539
|
getRowForField(formField) {
|
|
7540
7540
|
return allRows(this._rows).find(r => {
|
|
@@ -7545,9 +7545,9 @@ class FormLayouter {
|
|
|
7545
7545
|
});
|
|
7546
7546
|
}
|
|
7547
7547
|
|
|
7548
|
-
/**
|
|
7549
|
-
* @param {String} formFieldId
|
|
7550
|
-
* @returns { Array<FormRow> }
|
|
7548
|
+
/**
|
|
7549
|
+
* @param {String} formFieldId
|
|
7550
|
+
* @returns { Array<FormRow> }
|
|
7551
7551
|
*/
|
|
7552
7552
|
getRows(formFieldId) {
|
|
7553
7553
|
const rowsForField = this._rows.find(r => formFieldId === r.formFieldId);
|
|
@@ -7557,15 +7557,15 @@ class FormLayouter {
|
|
|
7557
7557
|
return rowsForField.rows;
|
|
7558
7558
|
}
|
|
7559
7559
|
|
|
7560
|
-
/**
|
|
7561
|
-
* @returns {string}
|
|
7560
|
+
/**
|
|
7561
|
+
* @returns {string}
|
|
7562
7562
|
*/
|
|
7563
7563
|
nextRowId() {
|
|
7564
7564
|
return this._ids.nextPrefixed('Row_');
|
|
7565
7565
|
}
|
|
7566
7566
|
|
|
7567
|
-
/**
|
|
7568
|
-
* @param {any} formField
|
|
7567
|
+
/**
|
|
7568
|
+
* @param {any} formField
|
|
7569
7569
|
*/
|
|
7570
7570
|
calculateLayout(formField) {
|
|
7571
7571
|
const {
|
|
@@ -7619,9 +7619,9 @@ function groupByRow(components, ids) {
|
|
|
7619
7619
|
});
|
|
7620
7620
|
}
|
|
7621
7621
|
|
|
7622
|
-
/**
|
|
7623
|
-
* @param {Array<FormRows>} formRows
|
|
7624
|
-
* @returns {Array<FormRow>}
|
|
7622
|
+
/**
|
|
7623
|
+
* @param {Array<FormRows>} formRows
|
|
7624
|
+
* @returns {Array<FormRow>}
|
|
7625
7625
|
*/
|
|
7626
7626
|
function allRows(formRows) {
|
|
7627
7627
|
return flatten(formRows.map(c => c.rows));
|
|
@@ -7746,55 +7746,55 @@ var core = {
|
|
|
7746
7746
|
validator: ['type', Validator]
|
|
7747
7747
|
};
|
|
7748
7748
|
|
|
7749
|
-
/**
|
|
7750
|
-
* @typedef { import('./types').Injector } Injector
|
|
7751
|
-
* @typedef { import('./types').Data } Data
|
|
7752
|
-
* @typedef { import('./types').Errors } Errors
|
|
7753
|
-
* @typedef { import('./types').Schema } Schema
|
|
7754
|
-
* @typedef { import('./types').FormProperties } FormProperties
|
|
7755
|
-
* @typedef { import('./types').FormProperty } FormProperty
|
|
7756
|
-
* @typedef { import('./types').FormEvent } FormEvent
|
|
7757
|
-
* @typedef { import('./types').FormOptions } FormOptions
|
|
7758
|
-
*
|
|
7759
|
-
* @typedef { {
|
|
7760
|
-
* data: Data,
|
|
7761
|
-
* initialData: Data,
|
|
7762
|
-
* errors: Errors,
|
|
7763
|
-
* properties: FormProperties,
|
|
7764
|
-
* schema: Schema
|
|
7765
|
-
* } } State
|
|
7766
|
-
*
|
|
7767
|
-
* @typedef { (type:FormEvent, priority:number, handler:Function) => void } OnEventWithPriority
|
|
7768
|
-
* @typedef { (type:FormEvent, handler:Function) => void } OnEventWithOutPriority
|
|
7769
|
-
* @typedef { OnEventWithPriority & OnEventWithOutPriority } OnEventType
|
|
7749
|
+
/**
|
|
7750
|
+
* @typedef { import('./types').Injector } Injector
|
|
7751
|
+
* @typedef { import('./types').Data } Data
|
|
7752
|
+
* @typedef { import('./types').Errors } Errors
|
|
7753
|
+
* @typedef { import('./types').Schema } Schema
|
|
7754
|
+
* @typedef { import('./types').FormProperties } FormProperties
|
|
7755
|
+
* @typedef { import('./types').FormProperty } FormProperty
|
|
7756
|
+
* @typedef { import('./types').FormEvent } FormEvent
|
|
7757
|
+
* @typedef { import('./types').FormOptions } FormOptions
|
|
7758
|
+
*
|
|
7759
|
+
* @typedef { {
|
|
7760
|
+
* data: Data,
|
|
7761
|
+
* initialData: Data,
|
|
7762
|
+
* errors: Errors,
|
|
7763
|
+
* properties: FormProperties,
|
|
7764
|
+
* schema: Schema
|
|
7765
|
+
* } } State
|
|
7766
|
+
*
|
|
7767
|
+
* @typedef { (type:FormEvent, priority:number, handler:Function) => void } OnEventWithPriority
|
|
7768
|
+
* @typedef { (type:FormEvent, handler:Function) => void } OnEventWithOutPriority
|
|
7769
|
+
* @typedef { OnEventWithPriority & OnEventWithOutPriority } OnEventType
|
|
7770
7770
|
*/
|
|
7771
7771
|
|
|
7772
7772
|
const ids = new Ids([32, 36, 1]);
|
|
7773
7773
|
|
|
7774
|
-
/**
|
|
7775
|
-
* The form.
|
|
7774
|
+
/**
|
|
7775
|
+
* The form.
|
|
7776
7776
|
*/
|
|
7777
7777
|
class Form {
|
|
7778
|
-
/**
|
|
7779
|
-
* @constructor
|
|
7780
|
-
* @param {FormOptions} options
|
|
7778
|
+
/**
|
|
7779
|
+
* @constructor
|
|
7780
|
+
* @param {FormOptions} options
|
|
7781
7781
|
*/
|
|
7782
7782
|
constructor(options = {}) {
|
|
7783
|
-
/**
|
|
7784
|
-
* @public
|
|
7785
|
-
* @type {OnEventType}
|
|
7783
|
+
/**
|
|
7784
|
+
* @public
|
|
7785
|
+
* @type {OnEventType}
|
|
7786
7786
|
*/
|
|
7787
7787
|
this.on = this._onEvent;
|
|
7788
7788
|
|
|
7789
|
-
/**
|
|
7790
|
-
* @public
|
|
7791
|
-
* @type {String}
|
|
7789
|
+
/**
|
|
7790
|
+
* @public
|
|
7791
|
+
* @type {String}
|
|
7792
7792
|
*/
|
|
7793
7793
|
this._id = ids.next();
|
|
7794
7794
|
|
|
7795
|
-
/**
|
|
7796
|
-
* @private
|
|
7797
|
-
* @type {Element}
|
|
7795
|
+
/**
|
|
7796
|
+
* @private
|
|
7797
|
+
* @type {Element}
|
|
7798
7798
|
*/
|
|
7799
7799
|
this._container = createFormContainer();
|
|
7800
7800
|
const {
|
|
@@ -7803,9 +7803,9 @@ class Form {
|
|
|
7803
7803
|
properties = {}
|
|
7804
7804
|
} = options;
|
|
7805
7805
|
|
|
7806
|
-
/**
|
|
7807
|
-
* @private
|
|
7808
|
-
* @type {State}
|
|
7806
|
+
/**
|
|
7807
|
+
* @private
|
|
7808
|
+
* @type {State}
|
|
7809
7809
|
*/
|
|
7810
7810
|
this._state = {
|
|
7811
7811
|
initialData: null,
|
|
@@ -7829,9 +7829,9 @@ class Form {
|
|
|
7829
7829
|
this._emit('form.clear');
|
|
7830
7830
|
}
|
|
7831
7831
|
|
|
7832
|
-
/**
|
|
7833
|
-
* Destroy the form, removing it from DOM,
|
|
7834
|
-
* if attached.
|
|
7832
|
+
/**
|
|
7833
|
+
* Destroy the form, removing it from DOM,
|
|
7834
|
+
* if attached.
|
|
7835
7835
|
*/
|
|
7836
7836
|
destroy() {
|
|
7837
7837
|
// destroy form services
|
|
@@ -7842,13 +7842,13 @@ class Form {
|
|
|
7842
7842
|
this._detach(false);
|
|
7843
7843
|
}
|
|
7844
7844
|
|
|
7845
|
-
/**
|
|
7846
|
-
* Open a form schema with the given initial data.
|
|
7847
|
-
*
|
|
7848
|
-
* @param {Schema} schema
|
|
7849
|
-
* @param {Data} [data]
|
|
7850
|
-
*
|
|
7851
|
-
* @return Promise<{ warnings: Array<any> }>
|
|
7845
|
+
/**
|
|
7846
|
+
* Open a form schema with the given initial data.
|
|
7847
|
+
*
|
|
7848
|
+
* @param {Schema} schema
|
|
7849
|
+
* @param {Data} [data]
|
|
7850
|
+
*
|
|
7851
|
+
* @return Promise<{ warnings: Array<any> }>
|
|
7852
7852
|
*/
|
|
7853
7853
|
importSchema(schema, data = {}) {
|
|
7854
7854
|
return new Promise((resolve, reject) => {
|
|
@@ -7881,10 +7881,10 @@ class Form {
|
|
|
7881
7881
|
});
|
|
7882
7882
|
}
|
|
7883
7883
|
|
|
7884
|
-
/**
|
|
7885
|
-
* Submit the form, triggering all field validations.
|
|
7886
|
-
*
|
|
7887
|
-
* @returns { { data: Data, errors: Errors } }
|
|
7884
|
+
/**
|
|
7885
|
+
* Submit the form, triggering all field validations.
|
|
7886
|
+
*
|
|
7887
|
+
* @returns { { data: Data, errors: Errors } }
|
|
7888
7888
|
*/
|
|
7889
7889
|
submit() {
|
|
7890
7890
|
const {
|
|
@@ -7910,8 +7910,8 @@ class Form {
|
|
|
7910
7910
|
});
|
|
7911
7911
|
}
|
|
7912
7912
|
|
|
7913
|
-
/**
|
|
7914
|
-
* @returns {Errors}
|
|
7913
|
+
/**
|
|
7914
|
+
* @returns {Errors}
|
|
7915
7915
|
*/
|
|
7916
7916
|
validate() {
|
|
7917
7917
|
const formFields = this.get('formFields'),
|
|
@@ -7983,8 +7983,8 @@ class Form {
|
|
|
7983
7983
|
return filteredErrors;
|
|
7984
7984
|
}
|
|
7985
7985
|
|
|
7986
|
-
/**
|
|
7987
|
-
* @param {Element|string} parentNode
|
|
7986
|
+
/**
|
|
7987
|
+
* @param {Element|string} parentNode
|
|
7988
7988
|
*/
|
|
7989
7989
|
attachTo(parentNode) {
|
|
7990
7990
|
if (!parentNode) {
|
|
@@ -8002,10 +8002,10 @@ class Form {
|
|
|
8002
8002
|
this._detach();
|
|
8003
8003
|
}
|
|
8004
8004
|
|
|
8005
|
-
/**
|
|
8006
|
-
* @private
|
|
8007
|
-
*
|
|
8008
|
-
* @param {boolean} [emit]
|
|
8005
|
+
/**
|
|
8006
|
+
* @private
|
|
8007
|
+
*
|
|
8008
|
+
* @param {boolean} [emit]
|
|
8009
8009
|
*/
|
|
8010
8010
|
_detach(emit = true) {
|
|
8011
8011
|
const container = this._container,
|
|
@@ -8019,9 +8019,9 @@ class Form {
|
|
|
8019
8019
|
parentNode.removeChild(container);
|
|
8020
8020
|
}
|
|
8021
8021
|
|
|
8022
|
-
/**
|
|
8023
|
-
* @param {FormProperty} property
|
|
8024
|
-
* @param {any} value
|
|
8022
|
+
/**
|
|
8023
|
+
* @param {FormProperty} property
|
|
8024
|
+
* @param {any} value
|
|
8025
8025
|
*/
|
|
8026
8026
|
setProperty(property, value) {
|
|
8027
8027
|
const properties = set(this._getState().properties, [property], value);
|
|
@@ -8030,21 +8030,21 @@ class Form {
|
|
|
8030
8030
|
});
|
|
8031
8031
|
}
|
|
8032
8032
|
|
|
8033
|
-
/**
|
|
8034
|
-
* @param {FormEvent} type
|
|
8035
|
-
* @param {Function} handler
|
|
8033
|
+
/**
|
|
8034
|
+
* @param {FormEvent} type
|
|
8035
|
+
* @param {Function} handler
|
|
8036
8036
|
*/
|
|
8037
8037
|
off(type, handler) {
|
|
8038
8038
|
this.get('eventBus').off(type, handler);
|
|
8039
8039
|
}
|
|
8040
8040
|
|
|
8041
|
-
/**
|
|
8042
|
-
* @private
|
|
8043
|
-
*
|
|
8044
|
-
* @param {FormOptions} options
|
|
8045
|
-
* @param {Element} container
|
|
8046
|
-
*
|
|
8047
|
-
* @returns {Injector}
|
|
8041
|
+
/**
|
|
8042
|
+
* @private
|
|
8043
|
+
*
|
|
8044
|
+
* @param {FormOptions} options
|
|
8045
|
+
* @param {Element} container
|
|
8046
|
+
*
|
|
8047
|
+
* @returns {Injector}
|
|
8048
8048
|
*/
|
|
8049
8049
|
_createInjector(options, container) {
|
|
8050
8050
|
const {
|
|
@@ -8065,17 +8065,17 @@ class Form {
|
|
|
8065
8065
|
}, core, ...modules, ...additionalModules]);
|
|
8066
8066
|
}
|
|
8067
8067
|
|
|
8068
|
-
/**
|
|
8069
|
-
* @private
|
|
8068
|
+
/**
|
|
8069
|
+
* @private
|
|
8070
8070
|
*/
|
|
8071
8071
|
_emit(type, data) {
|
|
8072
8072
|
this.get('eventBus').fire(type, data);
|
|
8073
8073
|
}
|
|
8074
8074
|
|
|
8075
|
-
/**
|
|
8076
|
-
* @internal
|
|
8077
|
-
*
|
|
8078
|
-
* @param { { add?: boolean, field: any, indexes: object, remove?: number, value?: any } } update
|
|
8075
|
+
/**
|
|
8076
|
+
* @internal
|
|
8077
|
+
*
|
|
8078
|
+
* @param { { add?: boolean, field: any, indexes: object, remove?: number, value?: any } } update
|
|
8079
8079
|
*/
|
|
8080
8080
|
_update(update) {
|
|
8081
8081
|
const {
|
|
@@ -8101,15 +8101,15 @@ class Form {
|
|
|
8101
8101
|
});
|
|
8102
8102
|
}
|
|
8103
8103
|
|
|
8104
|
-
/**
|
|
8105
|
-
* @internal
|
|
8104
|
+
/**
|
|
8105
|
+
* @internal
|
|
8106
8106
|
*/
|
|
8107
8107
|
_getState() {
|
|
8108
8108
|
return this._state;
|
|
8109
8109
|
}
|
|
8110
8110
|
|
|
8111
|
-
/**
|
|
8112
|
-
* @internal
|
|
8111
|
+
/**
|
|
8112
|
+
* @internal
|
|
8113
8113
|
*/
|
|
8114
8114
|
_setState(state) {
|
|
8115
8115
|
this._state = {
|
|
@@ -8119,22 +8119,22 @@ class Form {
|
|
|
8119
8119
|
this._emit('changed', this._getState());
|
|
8120
8120
|
}
|
|
8121
8121
|
|
|
8122
|
-
/**
|
|
8123
|
-
* @internal
|
|
8122
|
+
/**
|
|
8123
|
+
* @internal
|
|
8124
8124
|
*/
|
|
8125
8125
|
_getModules() {
|
|
8126
8126
|
return [ExpressionLanguageModule, MarkdownModule, ViewerCommandsModule, RepeatRenderModule];
|
|
8127
8127
|
}
|
|
8128
8128
|
|
|
8129
|
-
/**
|
|
8130
|
-
* @internal
|
|
8129
|
+
/**
|
|
8130
|
+
* @internal
|
|
8131
8131
|
*/
|
|
8132
8132
|
_onEvent(type, priority, handler) {
|
|
8133
8133
|
this.get('eventBus').on(type, priority, handler);
|
|
8134
8134
|
}
|
|
8135
8135
|
|
|
8136
|
-
/**
|
|
8137
|
-
* @internal
|
|
8136
|
+
/**
|
|
8137
|
+
* @internal
|
|
8138
8138
|
*/
|
|
8139
8139
|
_getSubmitData() {
|
|
8140
8140
|
const formFieldRegistry = this.get('formFieldRegistry');
|
|
@@ -8191,16 +8191,16 @@ class Form {
|
|
|
8191
8191
|
return this._applyConditions(workingSubmitData, formData);
|
|
8192
8192
|
}
|
|
8193
8193
|
|
|
8194
|
-
/**
|
|
8195
|
-
* @internal
|
|
8194
|
+
/**
|
|
8195
|
+
* @internal
|
|
8196
8196
|
*/
|
|
8197
8197
|
_applyConditions(toFilter, data, options = {}) {
|
|
8198
8198
|
const conditionChecker = this.get('conditionChecker');
|
|
8199
8199
|
return conditionChecker.applyConditions(toFilter, data, options);
|
|
8200
8200
|
}
|
|
8201
8201
|
|
|
8202
|
-
/**
|
|
8203
|
-
* @internal
|
|
8202
|
+
/**
|
|
8203
|
+
* @internal
|
|
8204
8204
|
*/
|
|
8205
8205
|
_getInitializedFieldData(data, options = {}) {
|
|
8206
8206
|
const formFieldRegistry = this.get('formFieldRegistry');
|