@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.cjs
CHANGED
|
@@ -73,26 +73,26 @@ const getFlavouredFeelVariableNames = (feelString, feelFlavour = 'expression', o
|
|
|
73
73
|
return [...new Set(variables)];
|
|
74
74
|
};
|
|
75
75
|
|
|
76
|
-
/**
|
|
77
|
-
* Get the variable name at the specified index in a given path expression.
|
|
78
|
-
*
|
|
79
|
-
* @param {Object} root - The root node of the path expression tree.
|
|
80
|
-
* @param {number} index - The index of the variable name to retrieve.
|
|
81
|
-
* @returns {string|null} The variable name at the specified index or null if index is out of bounds.
|
|
76
|
+
/**
|
|
77
|
+
* Get the variable name at the specified index in a given path expression.
|
|
78
|
+
*
|
|
79
|
+
* @param {Object} root - The root node of the path expression tree.
|
|
80
|
+
* @param {number} index - The index of the variable name to retrieve.
|
|
81
|
+
* @returns {string|null} The variable name at the specified index or null if index is out of bounds.
|
|
82
82
|
*/
|
|
83
83
|
const _getVariableNameAtPathIndex = (root, index) => {
|
|
84
84
|
const nodes = _linearizePathExpression(root);
|
|
85
85
|
return nodes[index].variableName || null;
|
|
86
86
|
};
|
|
87
87
|
|
|
88
|
-
/**
|
|
89
|
-
* Extracts the variables which are required of the external context for a given path expression.
|
|
90
|
-
* This is done by traversing the path expression tree and keeping track of the current depth relative to the external context.
|
|
91
|
-
*
|
|
92
|
-
* @param {Object} node - The root node of the path expression tree.
|
|
93
|
-
* @param {number} initialDepth - The depth at which the root node is located in the outer context.
|
|
94
|
-
* @param {Object} specialDepthAccessors - Definitions of special keywords which represent more complex accesses of the outer context.
|
|
95
|
-
* @returns {Set} - A set containing the extracted variable names.
|
|
88
|
+
/**
|
|
89
|
+
* Extracts the variables which are required of the external context for a given path expression.
|
|
90
|
+
* This is done by traversing the path expression tree and keeping track of the current depth relative to the external context.
|
|
91
|
+
*
|
|
92
|
+
* @param {Object} node - The root node of the path expression tree.
|
|
93
|
+
* @param {number} initialDepth - The depth at which the root node is located in the outer context.
|
|
94
|
+
* @param {Object} specialDepthAccessors - Definitions of special keywords which represent more complex accesses of the outer context.
|
|
95
|
+
* @returns {Set} - A set containing the extracted variable names.
|
|
96
96
|
*/
|
|
97
97
|
const _smartExtractVariableNames = (node, initialDepth, specialDepthAccessors) => {
|
|
98
98
|
// depth info represents the previous (initialised as null) and current depth of the current accessor in the path expression
|
|
@@ -138,11 +138,11 @@ const _smartExtractVariableNames = (node, initialDepth, specialDepthAccessors) =
|
|
|
138
138
|
return new Set(extractedVariables);
|
|
139
139
|
};
|
|
140
140
|
|
|
141
|
-
/**
|
|
142
|
-
* Deconstructs a path expression tree into an array of components.
|
|
143
|
-
*
|
|
144
|
-
* @param {Object} root - The root node of the path expression tree.
|
|
145
|
-
* @returns {Array<object>} An array of components in the path expression, in the correct order.
|
|
141
|
+
/**
|
|
142
|
+
* Deconstructs a path expression tree into an array of components.
|
|
143
|
+
*
|
|
144
|
+
* @param {Object} root - The root node of the path expression tree.
|
|
145
|
+
* @returns {Array<object>} An array of components in the path expression, in the correct order.
|
|
146
146
|
*/
|
|
147
147
|
const _linearizePathExpression = root => {
|
|
148
148
|
let node = root;
|
|
@@ -161,13 +161,13 @@ const _linearizePathExpression = root => {
|
|
|
161
161
|
return parts.reverse();
|
|
162
162
|
};
|
|
163
163
|
|
|
164
|
-
/**
|
|
165
|
-
* Builds a simplified feel structure tree from the given parse tree and feel string.
|
|
166
|
-
* The nodes follow this structure: `{ name: string, children: Array, variableName?: string }`
|
|
167
|
-
*
|
|
168
|
-
* @param {Object} parseTree - The parse tree generated by a parser.
|
|
169
|
-
* @param {string} feelString - The feel string used for parsing.
|
|
170
|
-
* @returns {Object} The simplified feel structure tree.
|
|
164
|
+
/**
|
|
165
|
+
* Builds a simplified feel structure tree from the given parse tree and feel string.
|
|
166
|
+
* The nodes follow this structure: `{ name: string, children: Array, variableName?: string }`
|
|
167
|
+
*
|
|
168
|
+
* @param {Object} parseTree - The parse tree generated by a parser.
|
|
169
|
+
* @param {string} feelString - The feel string used for parsing.
|
|
170
|
+
* @returns {Object} The simplified feel structure tree.
|
|
171
171
|
*/
|
|
172
172
|
const _buildSimpleFeelStructureTree = (parseTree, feelString) => {
|
|
173
173
|
const stack = [{
|
|
@@ -193,9 +193,9 @@ const _buildSimpleFeelStructureTree = (parseTree, feelString) => {
|
|
|
193
193
|
return _extractFilterExpressions(stack[0].children[0]);
|
|
194
194
|
};
|
|
195
195
|
|
|
196
|
-
/**
|
|
197
|
-
* Restructure the tree in such a way to bring filters (which create new contexts) to the root of the tree.
|
|
198
|
-
* This is done to simplify the extraction of variables and match the context hierarchy.
|
|
196
|
+
/**
|
|
197
|
+
* Restructure the tree in such a way to bring filters (which create new contexts) to the root of the tree.
|
|
198
|
+
* This is done to simplify the extraction of variables and match the context hierarchy.
|
|
199
199
|
*/
|
|
200
200
|
const _extractFilterExpressions = tree => {
|
|
201
201
|
const flattenedExpressionTree = {
|
|
@@ -236,25 +236,25 @@ class FeelExpressionLanguage {
|
|
|
236
236
|
this._eventBus = eventBus;
|
|
237
237
|
}
|
|
238
238
|
|
|
239
|
-
/**
|
|
240
|
-
* Determines if the given value is a FEEL expression.
|
|
241
|
-
*
|
|
242
|
-
* @param {any} value
|
|
243
|
-
* @returns {boolean}
|
|
244
|
-
*
|
|
239
|
+
/**
|
|
240
|
+
* Determines if the given value is a FEEL expression.
|
|
241
|
+
*
|
|
242
|
+
* @param {any} value
|
|
243
|
+
* @returns {boolean}
|
|
244
|
+
*
|
|
245
245
|
*/
|
|
246
246
|
isExpression(value) {
|
|
247
247
|
return minDash.isString(value) && value.startsWith('=');
|
|
248
248
|
}
|
|
249
249
|
|
|
250
|
-
/**
|
|
251
|
-
* Retrieve variable names from a given FEEL expression.
|
|
252
|
-
*
|
|
253
|
-
* @param {string} expression
|
|
254
|
-
* @param {object} [options]
|
|
255
|
-
* @param {string} [options.type]
|
|
256
|
-
*
|
|
257
|
-
* @returns {string[]}
|
|
250
|
+
/**
|
|
251
|
+
* Retrieve variable names from a given FEEL expression.
|
|
252
|
+
*
|
|
253
|
+
* @param {string} expression
|
|
254
|
+
* @param {object} [options]
|
|
255
|
+
* @param {string} [options.type]
|
|
256
|
+
*
|
|
257
|
+
* @returns {string[]}
|
|
258
258
|
*/
|
|
259
259
|
getVariableNames(expression, options = {}) {
|
|
260
260
|
const {
|
|
@@ -269,13 +269,13 @@ class FeelExpressionLanguage {
|
|
|
269
269
|
return getFlavouredFeelVariableNames(expression, type);
|
|
270
270
|
}
|
|
271
271
|
|
|
272
|
-
/**
|
|
273
|
-
* Evaluate an expression.
|
|
274
|
-
*
|
|
275
|
-
* @param {string} expression
|
|
276
|
-
* @param {import('../../types').Data} [data]
|
|
277
|
-
*
|
|
278
|
-
* @returns {any}
|
|
272
|
+
/**
|
|
273
|
+
* Evaluate an expression.
|
|
274
|
+
*
|
|
275
|
+
* @param {string} expression
|
|
276
|
+
* @param {import('../../types').Data} [data]
|
|
277
|
+
*
|
|
278
|
+
* @returns {any}
|
|
279
279
|
*/
|
|
280
280
|
evaluate(expression, data = {}) {
|
|
281
281
|
if (!expression) {
|
|
@@ -300,23 +300,23 @@ FeelExpressionLanguage.$inject = ['eventBus'];
|
|
|
300
300
|
class FeelersTemplating {
|
|
301
301
|
constructor() {}
|
|
302
302
|
|
|
303
|
-
/**
|
|
304
|
-
* Determines if the given value is a feelers template.
|
|
305
|
-
*
|
|
306
|
-
* @param {any} value
|
|
307
|
-
* @returns {boolean}
|
|
308
|
-
*
|
|
303
|
+
/**
|
|
304
|
+
* Determines if the given value is a feelers template.
|
|
305
|
+
*
|
|
306
|
+
* @param {any} value
|
|
307
|
+
* @returns {boolean}
|
|
308
|
+
*
|
|
309
309
|
*/
|
|
310
310
|
isTemplate(value) {
|
|
311
311
|
return minDash.isString(value) && (value.startsWith('=') || /{{.*?}}/.test(value));
|
|
312
312
|
}
|
|
313
313
|
|
|
314
|
-
/**
|
|
315
|
-
* Retrieve variable names from a given feelers template.
|
|
316
|
-
*
|
|
317
|
-
* @param {string} template
|
|
318
|
-
*
|
|
319
|
-
* @returns {string[]}
|
|
314
|
+
/**
|
|
315
|
+
* Retrieve variable names from a given feelers template.
|
|
316
|
+
*
|
|
317
|
+
* @param {string} template
|
|
318
|
+
*
|
|
319
|
+
* @returns {string[]}
|
|
320
320
|
*/
|
|
321
321
|
getVariableNames(template) {
|
|
322
322
|
if (!this.isTemplate(template)) {
|
|
@@ -342,17 +342,17 @@ class FeelersTemplating {
|
|
|
342
342
|
}, []);
|
|
343
343
|
}
|
|
344
344
|
|
|
345
|
-
/**
|
|
346
|
-
* Evaluate a template.
|
|
347
|
-
*
|
|
348
|
-
* @param {string} template
|
|
349
|
-
* @param {Object<string, any>} context
|
|
350
|
-
* @param {Object} options
|
|
351
|
-
* @param {boolean} [options.debug = false]
|
|
352
|
-
* @param {boolean} [options.strict = false]
|
|
353
|
-
* @param {Function} [options.buildDebugString]
|
|
354
|
-
*
|
|
355
|
-
* @returns
|
|
345
|
+
/**
|
|
346
|
+
* Evaluate a template.
|
|
347
|
+
*
|
|
348
|
+
* @param {string} template
|
|
349
|
+
* @param {Object<string, any>} context
|
|
350
|
+
* @param {Object} options
|
|
351
|
+
* @param {boolean} [options.debug = false]
|
|
352
|
+
* @param {boolean} [options.strict = false]
|
|
353
|
+
* @param {Function} [options.buildDebugString]
|
|
354
|
+
*
|
|
355
|
+
* @returns
|
|
356
356
|
*/
|
|
357
357
|
evaluate(template, context = {}, options = {}) {
|
|
358
358
|
const {
|
|
@@ -367,22 +367,22 @@ class FeelersTemplating {
|
|
|
367
367
|
});
|
|
368
368
|
}
|
|
369
369
|
|
|
370
|
-
/**
|
|
371
|
-
* @typedef {Object} ExpressionWithDepth
|
|
372
|
-
* @property {number} depth - The depth of the expression in the syntax tree.
|
|
373
|
-
* @property {string} expression - The extracted expression
|
|
370
|
+
/**
|
|
371
|
+
* @typedef {Object} ExpressionWithDepth
|
|
372
|
+
* @property {number} depth - The depth of the expression in the syntax tree.
|
|
373
|
+
* @property {string} expression - The extracted expression
|
|
374
374
|
*/
|
|
375
375
|
|
|
376
|
-
/**
|
|
377
|
-
* Extracts all feel expressions in the template along with their depth in the syntax tree.
|
|
378
|
-
* The depth is incremented for child expressions of loops to account for context drilling.
|
|
379
|
-
|
|
380
|
-
* @param {string} template - A feelers template string.
|
|
381
|
-
* @returns {Array<ExpressionWithDepth>} An array of objects, each containing the depth and the extracted expression.
|
|
382
|
-
*
|
|
383
|
-
* @example
|
|
384
|
-
* const template = "Hello {{user}}, you have:{{#loop items}}\n- {{amount}} {{name}}{{/loop}}.";
|
|
385
|
-
* const extractedExpressions = _extractExpressionsWithDepth(template);
|
|
376
|
+
/**
|
|
377
|
+
* Extracts all feel expressions in the template along with their depth in the syntax tree.
|
|
378
|
+
* The depth is incremented for child expressions of loops to account for context drilling.
|
|
379
|
+
* @name extractExpressionsWithDepth
|
|
380
|
+
* @param {string} template - A feelers template string.
|
|
381
|
+
* @returns {Array<ExpressionWithDepth>} An array of objects, each containing the depth and the extracted expression.
|
|
382
|
+
*
|
|
383
|
+
* @example
|
|
384
|
+
* const template = "Hello {{user}}, you have:{{#loop items}}\n- {{amount}} {{name}}{{/loop}}.";
|
|
385
|
+
* const extractedExpressions = _extractExpressionsWithDepth(template);
|
|
386
386
|
*/
|
|
387
387
|
_extractExpressionsWithDepth(template) {
|
|
388
388
|
// build simplified feelers syntax tree
|
|
@@ -488,10 +488,10 @@ function createInjector(bootstrapModules) {
|
|
|
488
488
|
return injector;
|
|
489
489
|
}
|
|
490
490
|
|
|
491
|
-
/**
|
|
492
|
-
* @param {string?} prefix
|
|
493
|
-
*
|
|
494
|
-
* @returns Element
|
|
491
|
+
/**
|
|
492
|
+
* @param {string?} prefix
|
|
493
|
+
*
|
|
494
|
+
* @returns Element
|
|
495
495
|
*/
|
|
496
496
|
function createFormContainer(prefix = 'fjs') {
|
|
497
497
|
const container = document.createElement('div');
|
|
@@ -622,11 +622,11 @@ const LocalExpressionContext = preact.createContext({
|
|
|
622
622
|
});
|
|
623
623
|
var LocalExpressionContext$1 = LocalExpressionContext;
|
|
624
624
|
|
|
625
|
-
/**
|
|
626
|
-
* @param {string} type
|
|
627
|
-
* @param {boolean} [strict]
|
|
628
|
-
*
|
|
629
|
-
* @returns {any}
|
|
625
|
+
/**
|
|
626
|
+
* @param {string} type
|
|
627
|
+
* @param {boolean} [strict]
|
|
628
|
+
*
|
|
629
|
+
* @returns {any}
|
|
630
630
|
*/
|
|
631
631
|
function getService(type, strict) {}
|
|
632
632
|
const FormContext = preact.createContext({
|
|
@@ -669,21 +669,21 @@ function generateIdForType(type) {
|
|
|
669
669
|
return `${type}${generateIndexForType(type)}`;
|
|
670
670
|
}
|
|
671
671
|
|
|
672
|
-
/**
|
|
673
|
-
* @template T
|
|
674
|
-
* @param {T} data
|
|
675
|
-
* @param {(this: any, key: string, value: any) => any} [replacer]
|
|
676
|
-
* @return {T}
|
|
672
|
+
/**
|
|
673
|
+
* @template T
|
|
674
|
+
* @param {T} data
|
|
675
|
+
* @param {(this: any, key: string, value: any) => any} [replacer]
|
|
676
|
+
* @return {T}
|
|
677
677
|
*/
|
|
678
678
|
function clone(data, replacer) {
|
|
679
679
|
return JSON.parse(JSON.stringify(data, replacer));
|
|
680
680
|
}
|
|
681
681
|
|
|
682
|
-
/**
|
|
683
|
-
* Transform a LocalExpressionContext object into a usable FEEL context.
|
|
684
|
-
*
|
|
685
|
-
* @param {Object} context - The LocalExpressionContext object.
|
|
686
|
-
* @returns {Object} The usable FEEL context.
|
|
682
|
+
/**
|
|
683
|
+
* Transform a LocalExpressionContext object into a usable FEEL context.
|
|
684
|
+
*
|
|
685
|
+
* @param {Object} context - The LocalExpressionContext object.
|
|
686
|
+
* @returns {Object} The usable FEEL context.
|
|
687
687
|
*/
|
|
688
688
|
|
|
689
689
|
function buildExpressionContext(context) {
|
|
@@ -715,12 +715,12 @@ function _wrapObjectKeysWithUnderscores(obj) {
|
|
|
715
715
|
return newObj;
|
|
716
716
|
}
|
|
717
717
|
|
|
718
|
-
/**
|
|
719
|
-
* Evaluate if condition is met reactively based on the conditionChecker and form data.
|
|
720
|
-
*
|
|
721
|
-
* @param {string | undefined} condition
|
|
722
|
-
*
|
|
723
|
-
* @returns {boolean} true if condition is met or no condition or condition checker exists
|
|
718
|
+
/**
|
|
719
|
+
* Evaluate if condition is met reactively based on the conditionChecker and form data.
|
|
720
|
+
*
|
|
721
|
+
* @param {string | undefined} condition
|
|
722
|
+
*
|
|
723
|
+
* @returns {boolean} true if condition is met or no condition or condition checker exists
|
|
724
724
|
*/
|
|
725
725
|
function useCondition(condition) {
|
|
726
726
|
const conditionChecker = useService('conditionChecker', false);
|
|
@@ -730,17 +730,17 @@ function useCondition(condition) {
|
|
|
730
730
|
}, [conditionChecker, condition, expressionContextInfo]);
|
|
731
731
|
}
|
|
732
732
|
|
|
733
|
-
/**
|
|
734
|
-
* Custom hook to scroll an element into view only when it is not visible within the viewport.
|
|
735
|
-
*
|
|
736
|
-
* @param {Object} targetRef - A ref pointing to the DOM element to scroll into view.
|
|
737
|
-
* @param {Array} deps - An array of dependencies that trigger the effect.
|
|
738
|
-
* @param {Array} flagRefs - An array of refs that are used as flags to control when to scroll.
|
|
739
|
-
* @param {Object} [scrollOptions={}] - Options defining the behavior of the scrolling.
|
|
740
|
-
* @param {String} [scrollOptions.align='center'] - The alignment of the element within the viewport.
|
|
741
|
-
* @param {String} [scrollOptions.behavior='auto'] - The scrolling behavior.
|
|
742
|
-
* @param {Number} [scrollOptions.offset=0] - An offset that is added to the scroll position.
|
|
743
|
-
* @param {Boolean} [scrollOptions.scrollIfVisible=false] - Whether to scroll even if the element is visible.
|
|
733
|
+
/**
|
|
734
|
+
* Custom hook to scroll an element into view only when it is not visible within the viewport.
|
|
735
|
+
*
|
|
736
|
+
* @param {Object} targetRef - A ref pointing to the DOM element to scroll into view.
|
|
737
|
+
* @param {Array} deps - An array of dependencies that trigger the effect.
|
|
738
|
+
* @param {Array} flagRefs - An array of refs that are used as flags to control when to scroll.
|
|
739
|
+
* @param {Object} [scrollOptions={}] - Options defining the behavior of the scrolling.
|
|
740
|
+
* @param {String} [scrollOptions.align='center'] - The alignment of the element within the viewport.
|
|
741
|
+
* @param {String} [scrollOptions.behavior='auto'] - The scrolling behavior.
|
|
742
|
+
* @param {Number} [scrollOptions.offset=0] - An offset that is added to the scroll position.
|
|
743
|
+
* @param {Boolean} [scrollOptions.scrollIfVisible=false] - Whether to scroll even if the element is visible.
|
|
744
744
|
*/
|
|
745
745
|
function useScrollIntoView(targetRef, deps, scrollOptions = null, flagRefs = []) {
|
|
746
746
|
hooks.useEffect(() => {
|
|
@@ -805,13 +805,13 @@ function _getTopOffset(item, scrollContainer, options) {
|
|
|
805
805
|
return 0;
|
|
806
806
|
}
|
|
807
807
|
|
|
808
|
-
/**
|
|
809
|
-
* Evaluate a string reactively based on the expressionLanguage and form data.
|
|
810
|
-
* If the string is not an expression, it is returned as is.
|
|
811
|
-
* The function is memoized to minimize re-renders.
|
|
812
|
-
*
|
|
813
|
-
* @param {string} value - The string to evaluate.
|
|
814
|
-
* @returns {any} - Evaluated value or the original value if not an expression.
|
|
808
|
+
/**
|
|
809
|
+
* Evaluate a string reactively based on the expressionLanguage and form data.
|
|
810
|
+
* If the string is not an expression, it is returned as is.
|
|
811
|
+
* The function is memoized to minimize re-renders.
|
|
812
|
+
*
|
|
813
|
+
* @param {string} value - The string to evaluate.
|
|
814
|
+
* @returns {any} - Evaluated value or the original value if not an expression.
|
|
815
815
|
*/
|
|
816
816
|
function useExpressionEvaluation(value) {
|
|
817
817
|
const expressionLanguage = useService('expressionLanguage');
|
|
@@ -824,11 +824,11 @@ function useExpressionEvaluation(value) {
|
|
|
824
824
|
}, [expressionLanguage, expressionContextInfo, value]);
|
|
825
825
|
}
|
|
826
826
|
|
|
827
|
-
/**
|
|
828
|
-
* Returns the conditionally filtered data of a form reactively.
|
|
829
|
-
* Memoised to minimize re-renders
|
|
830
|
-
*
|
|
831
|
-
* Warning: costly operation, use with care
|
|
827
|
+
/**
|
|
828
|
+
* Returns the conditionally filtered data of a form reactively.
|
|
829
|
+
* Memoised to minimize re-renders
|
|
830
|
+
*
|
|
831
|
+
* Warning: costly operation, use with care
|
|
832
832
|
*/
|
|
833
833
|
function useFilteredFormData() {
|
|
834
834
|
const {
|
|
@@ -861,16 +861,16 @@ function useKeyDownAction(targetKey, action, listenerElement = window) {
|
|
|
861
861
|
});
|
|
862
862
|
}
|
|
863
863
|
|
|
864
|
-
/**
|
|
865
|
-
* Retrieve readonly value of a form field, given it can be an
|
|
866
|
-
* expression optionally or configured globally.
|
|
867
|
-
*
|
|
868
|
-
* @typedef { import('../../types').FormProperties } FormProperties
|
|
869
|
-
*
|
|
870
|
-
* @param {any} formField
|
|
871
|
-
* @param {FormProperties} properties
|
|
872
|
-
*
|
|
873
|
-
* @returns {boolean}
|
|
864
|
+
/**
|
|
865
|
+
* Retrieve readonly value of a form field, given it can be an
|
|
866
|
+
* expression optionally or configured globally.
|
|
867
|
+
*
|
|
868
|
+
* @typedef { import('../../types').FormProperties } FormProperties
|
|
869
|
+
*
|
|
870
|
+
* @param {any} formField
|
|
871
|
+
* @param {FormProperties} properties
|
|
872
|
+
*
|
|
873
|
+
* @returns {boolean}
|
|
874
874
|
*/
|
|
875
875
|
function useReadonly(formField, properties = {}) {
|
|
876
876
|
const expressionLanguage = useService('expressionLanguage');
|
|
@@ -894,12 +894,12 @@ function usePrevious(value, defaultValue, dependencies) {
|
|
|
894
894
|
return ref.current;
|
|
895
895
|
}
|
|
896
896
|
|
|
897
|
-
/**
|
|
898
|
-
* A custom hook to manage state changes with deep comparison.
|
|
899
|
-
*
|
|
900
|
-
* @param {any} value - The current value to manage.
|
|
901
|
-
* @param {any} defaultValue - The initial default value for the state.
|
|
902
|
-
* @returns {any} - Returns the current state.
|
|
897
|
+
/**
|
|
898
|
+
* A custom hook to manage state changes with deep comparison.
|
|
899
|
+
*
|
|
900
|
+
* @param {any} value - The current value to manage.
|
|
901
|
+
* @param {any} defaultValue - The initial default value for the state.
|
|
902
|
+
* @returns {any} - Returns the current state.
|
|
903
903
|
*/
|
|
904
904
|
function useDeepCompareState(value, defaultValue) {
|
|
905
905
|
const [state, setState] = hooks.useState(defaultValue);
|
|
@@ -919,16 +919,16 @@ function compare(a, b) {
|
|
|
919
919
|
return JSON.stringify(a) === JSON.stringify(b);
|
|
920
920
|
}
|
|
921
921
|
|
|
922
|
-
/**
|
|
923
|
-
* Template a string reactively based on form data. If the string is not a template, it is returned as is.
|
|
924
|
-
* Memoised to minimize re-renders
|
|
925
|
-
*
|
|
926
|
-
* @param {string} value
|
|
927
|
-
* @param {Object} options
|
|
928
|
-
* @param {boolean} [options.debug = false]
|
|
929
|
-
* @param {boolean} [options.strict = false]
|
|
930
|
-
* @param {Function} [options.buildDebugString]
|
|
931
|
-
*
|
|
922
|
+
/**
|
|
923
|
+
* Template a string reactively based on form data. If the string is not a template, it is returned as is.
|
|
924
|
+
* Memoised to minimize re-renders
|
|
925
|
+
*
|
|
926
|
+
* @param {string} value
|
|
927
|
+
* @param {Object} options
|
|
928
|
+
* @param {boolean} [options.debug = false]
|
|
929
|
+
* @param {boolean} [options.strict = false]
|
|
930
|
+
* @param {Function} [options.buildDebugString]
|
|
931
|
+
*
|
|
932
932
|
*/
|
|
933
933
|
function useTemplateEvaluation(value, options = {}) {
|
|
934
934
|
const templating = useService('templating');
|
|
@@ -941,17 +941,17 @@ function useTemplateEvaluation(value, options = {}) {
|
|
|
941
941
|
}, [templating, value, expressionContextInfo, options]);
|
|
942
942
|
}
|
|
943
943
|
|
|
944
|
-
/**
|
|
945
|
-
* Template a string reactively based on form data. If the string is not a template, it is returned as is.
|
|
946
|
-
* If the string contains multiple lines, only the first line is returned.
|
|
947
|
-
* Memoised to minimize re-renders
|
|
948
|
-
*
|
|
949
|
-
* @param {string} value
|
|
950
|
-
* @param {Object} [options]
|
|
951
|
-
* @param {boolean} [options.debug = false]
|
|
952
|
-
* @param {boolean} [options.strict = false]
|
|
953
|
-
* @param {Function} [options.buildDebugString]
|
|
954
|
-
*
|
|
944
|
+
/**
|
|
945
|
+
* Template a string reactively based on form data. If the string is not a template, it is returned as is.
|
|
946
|
+
* If the string contains multiple lines, only the first line is returned.
|
|
947
|
+
* Memoised to minimize re-renders
|
|
948
|
+
*
|
|
949
|
+
* @param {string} value
|
|
950
|
+
* @param {Object} [options]
|
|
951
|
+
* @param {boolean} [options.debug = false]
|
|
952
|
+
* @param {boolean} [options.strict = false]
|
|
953
|
+
* @param {Function} [options.buildDebugString]
|
|
954
|
+
*
|
|
955
955
|
*/
|
|
956
956
|
function useSingleLineTemplateEvaluation(value, options = {}) {
|
|
957
957
|
const evaluatedTemplate = useTemplateEvaluation(value, options);
|
|
@@ -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 {
|
|
@@ -1817,12 +1817,12 @@ FormComponent$1.config = {
|
|
|
1817
1817
|
})
|
|
1818
1818
|
};
|
|
1819
1819
|
|
|
1820
|
-
/**
|
|
1821
|
-
* Returns date format for the provided locale.
|
|
1822
|
-
* If the locale is not provided, uses the browser's locale.
|
|
1823
|
-
*
|
|
1824
|
-
* @param {string} [locale] - The locale to get date format for.
|
|
1825
|
-
* @returns {string} The date format for the locale.
|
|
1820
|
+
/**
|
|
1821
|
+
* Returns date format for the provided locale.
|
|
1822
|
+
* If the locale is not provided, uses the browser's locale.
|
|
1823
|
+
*
|
|
1824
|
+
* @param {string} [locale] - The locale to get date format for.
|
|
1825
|
+
* @returns {string} The date format for the locale.
|
|
1826
1826
|
*/
|
|
1827
1827
|
function getLocaleDateFormat(locale = 'default') {
|
|
1828
1828
|
const parts = new Intl.DateTimeFormat(locale).formatToParts(new Date(Date.UTC(2020, 5, 5)));
|
|
@@ -1841,12 +1841,12 @@ function getLocaleDateFormat(locale = 'default') {
|
|
|
1841
1841
|
}).join('');
|
|
1842
1842
|
}
|
|
1843
1843
|
|
|
1844
|
-
/**
|
|
1845
|
-
* Returns readable date format for the provided locale.
|
|
1846
|
-
* If the locale is not provided, uses the browser's locale.
|
|
1847
|
-
*
|
|
1848
|
-
* @param {string} [locale] - The locale to get readable date format for.
|
|
1849
|
-
* @returns {string} The readable date format for the locale.
|
|
1844
|
+
/**
|
|
1845
|
+
* Returns readable date format for the provided locale.
|
|
1846
|
+
* If the locale is not provided, uses the browser's locale.
|
|
1847
|
+
*
|
|
1848
|
+
* @param {string} [locale] - The locale to get readable date format for.
|
|
1849
|
+
* @returns {string} The readable date format for the locale.
|
|
1850
1850
|
*/
|
|
1851
1851
|
function getLocaleReadableDateFormat(locale) {
|
|
1852
1852
|
let format = getLocaleDateFormat(locale).toLowerCase();
|
|
@@ -1863,12 +1863,12 @@ function getLocaleReadableDateFormat(locale) {
|
|
|
1863
1863
|
return format;
|
|
1864
1864
|
}
|
|
1865
1865
|
|
|
1866
|
-
/**
|
|
1867
|
-
* Returns flatpickr config for the provided locale.
|
|
1868
|
-
* If the locale is not provided, uses the browser's locale.
|
|
1869
|
-
*
|
|
1870
|
-
* @param {string} [locale] - The locale to get flatpickr config for.
|
|
1871
|
-
* @returns {object} The flatpickr config for the locale.
|
|
1866
|
+
/**
|
|
1867
|
+
* Returns flatpickr config for the provided locale.
|
|
1868
|
+
* If the locale is not provided, uses the browser's locale.
|
|
1869
|
+
*
|
|
1870
|
+
* @param {string} [locale] - The locale to get flatpickr config for.
|
|
1871
|
+
* @returns {object} The flatpickr config for the locale.
|
|
1872
1872
|
*/
|
|
1873
1873
|
function getLocaleDateFlatpickrConfig(locale) {
|
|
1874
1874
|
return flatpickerizeDateFormat(getLocaleDateFormat(locale));
|
|
@@ -2580,10 +2580,10 @@ Datetime.config = {
|
|
|
2580
2580
|
}
|
|
2581
2581
|
};
|
|
2582
2582
|
|
|
2583
|
-
/**
|
|
2584
|
-
* This file must not be changed or exchanged.
|
|
2585
|
-
*
|
|
2586
|
-
* @see http://bpmn.io/license for more information.
|
|
2583
|
+
/**
|
|
2584
|
+
* This file must not be changed or exchanged.
|
|
2585
|
+
*
|
|
2586
|
+
* @see http://bpmn.io/license for more information.
|
|
2587
2587
|
*/
|
|
2588
2588
|
function Logo() {
|
|
2589
2589
|
return jsxRuntime.jsxs("svg", {
|
|
@@ -2769,11 +2769,11 @@ const ATTR_WHITESPACE_PATTERN = /[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u
|
|
|
2769
2769
|
|
|
2770
2770
|
const FORM_ELEMENT = document.createElement('form');
|
|
2771
2771
|
|
|
2772
|
-
/**
|
|
2773
|
-
* Sanitize a HTML string and return the cleaned, safe version.
|
|
2774
|
-
*
|
|
2775
|
-
* @param {string} html
|
|
2776
|
-
* @return {string}
|
|
2772
|
+
/**
|
|
2773
|
+
* Sanitize a HTML string and return the cleaned, safe version.
|
|
2774
|
+
*
|
|
2775
|
+
* @param {string} html
|
|
2776
|
+
* @return {string}
|
|
2777
2777
|
*/
|
|
2778
2778
|
|
|
2779
2779
|
// see https://github.com/developit/snarkdown/issues/70
|
|
@@ -2791,41 +2791,41 @@ function sanitizeHTML(html) {
|
|
|
2791
2791
|
}
|
|
2792
2792
|
}
|
|
2793
2793
|
|
|
2794
|
-
/**
|
|
2795
|
-
* Sanitizes an image source to ensure we only allow for data URI and links
|
|
2796
|
-
* that start with http(s).
|
|
2797
|
-
*
|
|
2798
|
-
* Note: Most browsers anyway do not support script execution in <img> elements.
|
|
2799
|
-
*
|
|
2800
|
-
* @param {string} src
|
|
2801
|
-
* @returns {string}
|
|
2794
|
+
/**
|
|
2795
|
+
* Sanitizes an image source to ensure we only allow for data URI and links
|
|
2796
|
+
* that start with http(s).
|
|
2797
|
+
*
|
|
2798
|
+
* Note: Most browsers anyway do not support script execution in <img> elements.
|
|
2799
|
+
*
|
|
2800
|
+
* @param {string} src
|
|
2801
|
+
* @returns {string}
|
|
2802
2802
|
*/
|
|
2803
2803
|
function sanitizeImageSource(src) {
|
|
2804
2804
|
const valid = ALLOWED_IMAGE_SRC_PATTERN.test(src);
|
|
2805
2805
|
return valid ? src : '';
|
|
2806
2806
|
}
|
|
2807
2807
|
|
|
2808
|
-
/**
|
|
2809
|
-
* Sanitizes an iframe source to ensure we only allow for links
|
|
2810
|
-
* that start with http(s).
|
|
2811
|
-
*
|
|
2812
|
-
* @param {string} src
|
|
2813
|
-
* @returns {string}
|
|
2808
|
+
/**
|
|
2809
|
+
* Sanitizes an iframe source to ensure we only allow for links
|
|
2810
|
+
* that start with http(s).
|
|
2811
|
+
*
|
|
2812
|
+
* @param {string} src
|
|
2813
|
+
* @returns {string}
|
|
2814
2814
|
*/
|
|
2815
2815
|
function sanitizeIFrameSource(src) {
|
|
2816
2816
|
const valid = ALLOWED_IFRAME_SRC_PATTERN.test(src);
|
|
2817
2817
|
return valid ? src : '';
|
|
2818
2818
|
}
|
|
2819
2819
|
|
|
2820
|
-
/**
|
|
2821
|
-
* Recursively sanitize a HTML node, potentially
|
|
2822
|
-
* removing it, its children or attributes.
|
|
2823
|
-
*
|
|
2824
|
-
* Inspired by https://github.com/developit/snarkdown/issues/70
|
|
2825
|
-
* and https://github.com/cure53/DOMPurify. Simplified
|
|
2826
|
-
* for our use-case.
|
|
2827
|
-
*
|
|
2828
|
-
* @param {Element} node
|
|
2820
|
+
/**
|
|
2821
|
+
* Recursively sanitize a HTML node, potentially
|
|
2822
|
+
* removing it, its children or attributes.
|
|
2823
|
+
*
|
|
2824
|
+
* Inspired by https://github.com/developit/snarkdown/issues/70
|
|
2825
|
+
* and https://github.com/cure53/DOMPurify. Simplified
|
|
2826
|
+
* for our use-case.
|
|
2827
|
+
*
|
|
2828
|
+
* @param {Element} node
|
|
2829
2829
|
*/
|
|
2830
2830
|
function sanitizeNode(node) {
|
|
2831
2831
|
// allow text nodes
|
|
@@ -2869,13 +2869,13 @@ function sanitizeNode(node) {
|
|
|
2869
2869
|
}
|
|
2870
2870
|
}
|
|
2871
2871
|
|
|
2872
|
-
/**
|
|
2873
|
-
* Validates attributes for validity.
|
|
2874
|
-
*
|
|
2875
|
-
* @param {string} lcTag
|
|
2876
|
-
* @param {string} lcName
|
|
2877
|
-
* @param {string} value
|
|
2878
|
-
* @return {boolean}
|
|
2872
|
+
/**
|
|
2873
|
+
* Validates attributes for validity.
|
|
2874
|
+
*
|
|
2875
|
+
* @param {string} lcTag
|
|
2876
|
+
* @param {string} lcName
|
|
2877
|
+
* @param {string} value
|
|
2878
|
+
* @return {boolean}
|
|
2879
2879
|
*/
|
|
2880
2880
|
function isValidAttribute(lcTag, lcName, value) {
|
|
2881
2881
|
// disallow most attributes based on whitelist
|
|
@@ -2938,7 +2938,7 @@ function IFrame(props) {
|
|
|
2938
2938
|
height: height,
|
|
2939
2939
|
class: "fjs-iframe",
|
|
2940
2940
|
id: prefixId(id, formId),
|
|
2941
|
-
sandbox: ""
|
|
2941
|
+
sandbox: "allow-scripts"
|
|
2942
2942
|
}), evaluatedUrl && !safeUrl && jsxRuntime.jsx(IFramePlaceholder, {
|
|
2943
2943
|
text: "External content couldn't be loaded."
|
|
2944
2944
|
})]
|
|
@@ -4545,28 +4545,28 @@ var CaretRightIcon = SvgCaretRight;
|
|
|
4545
4545
|
|
|
4546
4546
|
const type = 'table';
|
|
4547
4547
|
|
|
4548
|
-
/**
|
|
4549
|
-
* @typedef {('asc'|'desc')} Direction
|
|
4550
|
-
*
|
|
4551
|
-
* @typedef Sorting
|
|
4552
|
-
* @property {string} key
|
|
4553
|
-
* @property {Direction} direction
|
|
4554
|
-
*
|
|
4555
|
-
* @typedef Column
|
|
4556
|
-
* @property {string} label
|
|
4557
|
-
* @property {string} key
|
|
4558
|
-
*
|
|
4559
|
-
* @typedef Props
|
|
4560
|
-
* @property {Object} field
|
|
4561
|
-
* @property {string} field.id
|
|
4562
|
-
* @property {Array<Column>} [field.columns]
|
|
4563
|
-
* @property {string} [field.columnsExpression]
|
|
4564
|
-
* @property {string} [field.label]
|
|
4565
|
-
* @property {number} [field.rowCount]
|
|
4566
|
-
* @property {string} [field.dataSource]
|
|
4567
|
-
*
|
|
4568
|
-
* @param {Props} props
|
|
4569
|
-
* @returns {import("preact").JSX.Element}
|
|
4548
|
+
/**
|
|
4549
|
+
* @typedef {('asc'|'desc')} Direction
|
|
4550
|
+
*
|
|
4551
|
+
* @typedef Sorting
|
|
4552
|
+
* @property {string} key
|
|
4553
|
+
* @property {Direction} direction
|
|
4554
|
+
*
|
|
4555
|
+
* @typedef Column
|
|
4556
|
+
* @property {string} label
|
|
4557
|
+
* @property {string} key
|
|
4558
|
+
*
|
|
4559
|
+
* @typedef Props
|
|
4560
|
+
* @property {Object} field
|
|
4561
|
+
* @property {string} field.id
|
|
4562
|
+
* @property {Array<Column>} [field.columns]
|
|
4563
|
+
* @property {string} [field.columnsExpression]
|
|
4564
|
+
* @property {string} [field.label]
|
|
4565
|
+
* @property {number} [field.rowCount]
|
|
4566
|
+
* @property {string} [field.dataSource]
|
|
4567
|
+
*
|
|
4568
|
+
* @param {Props} props
|
|
4569
|
+
* @returns {import("preact").JSX.Element}
|
|
4570
4570
|
*/
|
|
4571
4571
|
function Table(props) {
|
|
4572
4572
|
const {
|
|
@@ -4776,10 +4776,10 @@ Table.config = {
|
|
|
4776
4776
|
|
|
4777
4777
|
// helpers /////////////////////////////
|
|
4778
4778
|
|
|
4779
|
-
/**
|
|
4780
|
-
* @param {string|void} columnsExpression
|
|
4781
|
-
* @param {Column[]} fallbackColumns
|
|
4782
|
-
* @returns {Column[]}
|
|
4779
|
+
/**
|
|
4780
|
+
* @param {string|void} columnsExpression
|
|
4781
|
+
* @param {Column[]} fallbackColumns
|
|
4782
|
+
* @returns {Column[]}
|
|
4783
4783
|
*/
|
|
4784
4784
|
function useEvaluatedColumns(columnsExpression, fallbackColumns) {
|
|
4785
4785
|
/** @type {Column[]|null} */
|
|
@@ -4787,18 +4787,18 @@ function useEvaluatedColumns(columnsExpression, fallbackColumns) {
|
|
|
4787
4787
|
return Array.isArray(evaluation) && evaluation.every(isColumn) ? evaluation : fallbackColumns;
|
|
4788
4788
|
}
|
|
4789
4789
|
|
|
4790
|
-
/**
|
|
4791
|
-
* @param {any} column
|
|
4792
|
-
* @returns {column is Column}
|
|
4790
|
+
/**
|
|
4791
|
+
* @param {any} column
|
|
4792
|
+
* @returns {column is Column}
|
|
4793
4793
|
*/
|
|
4794
4794
|
function isColumn(column) {
|
|
4795
4795
|
return minDash.isObject(column) && minDash.isString(column['label']) && minDash.isString(column['key']);
|
|
4796
4796
|
}
|
|
4797
4797
|
|
|
4798
|
-
/**
|
|
4799
|
-
* @param {Array} array
|
|
4800
|
-
* @param {number} size
|
|
4801
|
-
* @returns {Array}
|
|
4798
|
+
/**
|
|
4799
|
+
* @param {Array} array
|
|
4800
|
+
* @param {number} size
|
|
4801
|
+
* @returns {Array}
|
|
4802
4802
|
*/
|
|
4803
4803
|
function chunk(array, size) {
|
|
4804
4804
|
return array.reduce((chunks, item, index) => {
|
|
@@ -4811,11 +4811,11 @@ function chunk(array, size) {
|
|
|
4811
4811
|
}, []);
|
|
4812
4812
|
}
|
|
4813
4813
|
|
|
4814
|
-
/**
|
|
4815
|
-
* @param {unknown[]} array
|
|
4816
|
-
* @param {string} key
|
|
4817
|
-
* @param {Direction} direction
|
|
4818
|
-
* @returns {unknown[]}
|
|
4814
|
+
/**
|
|
4815
|
+
* @param {unknown[]} array
|
|
4816
|
+
* @param {string} key
|
|
4817
|
+
* @param {Direction} direction
|
|
4818
|
+
* @returns {unknown[]}
|
|
4819
4819
|
*/
|
|
4820
4820
|
function sortByColumn(array, key, direction) {
|
|
4821
4821
|
return [...array].sort((a, b) => {
|
|
@@ -4829,10 +4829,10 @@ function sortByColumn(array, key, direction) {
|
|
|
4829
4829
|
});
|
|
4830
4830
|
}
|
|
4831
4831
|
|
|
4832
|
-
/**
|
|
4833
|
-
* @param {null|Sorting} sortBy
|
|
4834
|
-
* @param {string} key
|
|
4835
|
-
* @param {string} label
|
|
4832
|
+
/**
|
|
4833
|
+
* @param {null|Sorting} sortBy
|
|
4834
|
+
* @param {string} key
|
|
4835
|
+
* @param {string} label
|
|
4836
4836
|
*/
|
|
4837
4837
|
function getHeaderAriaLabel(sortBy, key, label) {
|
|
4838
4838
|
if (sortBy === null || sortBy.key !== key) {
|
|
@@ -5207,37 +5207,37 @@ class FormFields {
|
|
|
5207
5207
|
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'];
|
|
5208
5208
|
const TEMPLATE_PROPERTIES = ['alt', 'appearance.prefixAdorner', 'appearance.suffixAdorner', 'description', 'label', 'source', 'text', 'url'];
|
|
5209
5209
|
|
|
5210
|
-
/**
|
|
5211
|
-
* @typedef { import('../types').Schema } Schema
|
|
5210
|
+
/**
|
|
5211
|
+
* @typedef { import('../types').Schema } Schema
|
|
5212
5212
|
*/
|
|
5213
5213
|
|
|
5214
|
-
/**
|
|
5215
|
-
* Parse the schema for variables a form might make use of.
|
|
5216
|
-
*
|
|
5217
|
-
* @example
|
|
5218
|
-
*
|
|
5219
|
-
* // retrieve variables from schema
|
|
5220
|
-
* const variables = getSchemaVariables(schema);
|
|
5221
|
-
*
|
|
5222
|
-
* @example
|
|
5223
|
-
*
|
|
5224
|
-
* // retrieve input variables from schema
|
|
5225
|
-
* const inputVariables = getSchemaVariables(schema, { outputs: false });
|
|
5226
|
-
*
|
|
5227
|
-
* @example
|
|
5228
|
-
*
|
|
5229
|
-
* // retrieve output variables from schema
|
|
5230
|
-
* const outputVariables = getSchemaVariables(schema, { inputs: false });
|
|
5231
|
-
*
|
|
5232
|
-
* @param {Schema} schema
|
|
5233
|
-
* @param {object} [options]
|
|
5234
|
-
* @param {any} [options.expressionLanguage]
|
|
5235
|
-
* @param {any} [options.templating]
|
|
5236
|
-
* @param {any} [options.formFields]
|
|
5237
|
-
* @param {boolean} [options.inputs=true]
|
|
5238
|
-
* @param {boolean} [options.outputs=true]
|
|
5239
|
-
*
|
|
5240
|
-
* @return {string[]}
|
|
5214
|
+
/**
|
|
5215
|
+
* Parse the schema for variables a form might make use of.
|
|
5216
|
+
*
|
|
5217
|
+
* @example
|
|
5218
|
+
*
|
|
5219
|
+
* // retrieve variables from schema
|
|
5220
|
+
* const variables = getSchemaVariables(schema);
|
|
5221
|
+
*
|
|
5222
|
+
* @example
|
|
5223
|
+
*
|
|
5224
|
+
* // retrieve input variables from schema
|
|
5225
|
+
* const inputVariables = getSchemaVariables(schema, { outputs: false });
|
|
5226
|
+
*
|
|
5227
|
+
* @example
|
|
5228
|
+
*
|
|
5229
|
+
* // retrieve output variables from schema
|
|
5230
|
+
* const outputVariables = getSchemaVariables(schema, { inputs: false });
|
|
5231
|
+
*
|
|
5232
|
+
* @param {Schema} schema
|
|
5233
|
+
* @param {object} [options]
|
|
5234
|
+
* @param {any} [options.expressionLanguage]
|
|
5235
|
+
* @param {any} [options.templating]
|
|
5236
|
+
* @param {any} [options.formFields]
|
|
5237
|
+
* @param {boolean} [options.inputs=true]
|
|
5238
|
+
* @param {boolean} [options.outputs=true]
|
|
5239
|
+
*
|
|
5240
|
+
* @return {string[]}
|
|
5241
5241
|
*/
|
|
5242
5242
|
function getSchemaVariables(schema, options = {}) {
|
|
5243
5243
|
const {
|
|
@@ -5313,13 +5313,13 @@ function getSchemaVariables(schema, options = {}) {
|
|
|
5313
5313
|
return Array.from(new Set(variables));
|
|
5314
5314
|
}
|
|
5315
5315
|
|
|
5316
|
-
/**
|
|
5317
|
-
* Get the ancestry list of a form field.
|
|
5318
|
-
*
|
|
5319
|
-
* @param {string} formFieldId
|
|
5320
|
-
* @param {import('../core/FormFieldRegistry').default} formFieldRegistry
|
|
5321
|
-
*
|
|
5322
|
-
* @return {Array<string>} ancestry list
|
|
5316
|
+
/**
|
|
5317
|
+
* Get the ancestry list of a form field.
|
|
5318
|
+
*
|
|
5319
|
+
* @param {string} formFieldId
|
|
5320
|
+
* @param {import('../core/FormFieldRegistry').default} formFieldRegistry
|
|
5321
|
+
*
|
|
5322
|
+
* @return {Array<string>} ancestry list
|
|
5323
5323
|
*/
|
|
5324
5324
|
const getAncestryList = (formFieldId, formFieldRegistry) => {
|
|
5325
5325
|
const ids = [];
|
|
@@ -5331,9 +5331,9 @@ const getAncestryList = (formFieldId, formFieldRegistry) => {
|
|
|
5331
5331
|
return ids;
|
|
5332
5332
|
};
|
|
5333
5333
|
|
|
5334
|
-
/**
|
|
5335
|
-
* @typedef {object} Condition
|
|
5336
|
-
* @property {string} [hide]
|
|
5334
|
+
/**
|
|
5335
|
+
* @typedef {object} Condition
|
|
5336
|
+
* @property {string} [hide]
|
|
5337
5337
|
*/
|
|
5338
5338
|
|
|
5339
5339
|
class ConditionChecker {
|
|
@@ -5343,14 +5343,14 @@ class ConditionChecker {
|
|
|
5343
5343
|
this._eventBus = eventBus;
|
|
5344
5344
|
}
|
|
5345
5345
|
|
|
5346
|
-
/**
|
|
5347
|
-
* For given data, remove properties based on condition.
|
|
5348
|
-
*
|
|
5349
|
-
* @param {Object<string, any>} data
|
|
5350
|
-
* @param {Object<string, any>} contextData
|
|
5351
|
-
* @param {Object} [options]
|
|
5352
|
-
* @param {Function} [options.getFilterPath]
|
|
5353
|
-
* @param {boolean} [options.leafNodeDeletionOnly]
|
|
5346
|
+
/**
|
|
5347
|
+
* For given data, remove properties based on condition.
|
|
5348
|
+
*
|
|
5349
|
+
* @param {Object<string, any>} data
|
|
5350
|
+
* @param {Object<string, any>} contextData
|
|
5351
|
+
* @param {Object} [options]
|
|
5352
|
+
* @param {Function} [options.getFilterPath]
|
|
5353
|
+
* @param {boolean} [options.leafNodeDeletionOnly]
|
|
5354
5354
|
*/
|
|
5355
5355
|
applyConditions(data, contextData = {}, options = {}) {
|
|
5356
5356
|
const workingData = clone(data);
|
|
@@ -5444,13 +5444,13 @@ class ConditionChecker {
|
|
|
5444
5444
|
return workingData;
|
|
5445
5445
|
}
|
|
5446
5446
|
|
|
5447
|
-
/**
|
|
5448
|
-
* Check if given condition is met. Returns null for invalid/missing conditions.
|
|
5449
|
-
*
|
|
5450
|
-
* @param {string} condition
|
|
5451
|
-
* @param {import('../../types').Data} [data]
|
|
5452
|
-
*
|
|
5453
|
-
* @returns {boolean|null}
|
|
5447
|
+
/**
|
|
5448
|
+
* Check if given condition is met. Returns null for invalid/missing conditions.
|
|
5449
|
+
*
|
|
5450
|
+
* @param {string} condition
|
|
5451
|
+
* @param {import('../../types').Data} [data]
|
|
5452
|
+
*
|
|
5453
|
+
* @returns {boolean|null}
|
|
5454
5454
|
*/
|
|
5455
5455
|
check(condition, data = {}) {
|
|
5456
5456
|
if (!condition) {
|
|
@@ -5471,12 +5471,12 @@ class ConditionChecker {
|
|
|
5471
5471
|
}
|
|
5472
5472
|
}
|
|
5473
5473
|
|
|
5474
|
-
/**
|
|
5475
|
-
* Check if hide condition is met.
|
|
5476
|
-
*
|
|
5477
|
-
* @param {Condition} condition
|
|
5478
|
-
* @param {Object<string, any>} data
|
|
5479
|
-
* @returns {boolean}
|
|
5474
|
+
/**
|
|
5475
|
+
* Check if hide condition is met.
|
|
5476
|
+
*
|
|
5477
|
+
* @param {Condition} condition
|
|
5478
|
+
* @param {Object<string, any>} data
|
|
5479
|
+
* @returns {boolean}
|
|
5480
5480
|
*/
|
|
5481
5481
|
_checkHideCondition(condition, data) {
|
|
5482
5482
|
if (!condition.hide) {
|
|
@@ -5518,12 +5518,12 @@ class MarkdownRenderer {
|
|
|
5518
5518
|
this._converter = new showdown.Converter();
|
|
5519
5519
|
}
|
|
5520
5520
|
|
|
5521
|
-
/**
|
|
5522
|
-
* Render markdown to HTML.
|
|
5523
|
-
*
|
|
5524
|
-
* @param {string} markdown - The markdown to render
|
|
5525
|
-
*
|
|
5526
|
-
* @returns {string} HTML
|
|
5521
|
+
/**
|
|
5522
|
+
* Render markdown to HTML.
|
|
5523
|
+
*
|
|
5524
|
+
* @param {string} markdown - The markdown to render
|
|
5525
|
+
*
|
|
5526
|
+
* @returns {string} HTML
|
|
5527
5527
|
*/
|
|
5528
5528
|
render(markdown) {
|
|
5529
5529
|
return this._converter.makeHtml(markdown);
|
|
@@ -6144,11 +6144,11 @@ class RepeatRenderManager {
|
|
|
6144
6144
|
this.RepeatFooter = this.RepeatFooter.bind(this);
|
|
6145
6145
|
}
|
|
6146
6146
|
|
|
6147
|
-
/**
|
|
6148
|
-
* Checks whether a field is currently repeating its children.
|
|
6149
|
-
*
|
|
6150
|
-
* @param {string} id - The id of the field to check
|
|
6151
|
-
* @returns {boolean} - True if repeatable, false otherwise
|
|
6147
|
+
/**
|
|
6148
|
+
* Checks whether a field is currently repeating its children.
|
|
6149
|
+
*
|
|
6150
|
+
* @param {string} id - The id of the field to check
|
|
6151
|
+
* @returns {boolean} - True if repeatable, false otherwise
|
|
6152
6152
|
*/
|
|
6153
6153
|
isFieldRepeating(id) {
|
|
6154
6154
|
if (!id) {
|
|
@@ -6908,8 +6908,8 @@ Validator.$inject = ['expressionLanguage', 'conditionChecker', 'form'];
|
|
|
6908
6908
|
|
|
6909
6909
|
// helpers //////////
|
|
6910
6910
|
|
|
6911
|
-
/**
|
|
6912
|
-
* Helper function to evaluate optional FEEL validation values.
|
|
6911
|
+
/**
|
|
6912
|
+
* Helper function to evaluate optional FEEL validation values.
|
|
6913
6913
|
*/
|
|
6914
6914
|
function evaluateFEELValues(validate, expressionLanguage, conditionChecker, form) {
|
|
6915
6915
|
const evaluatedValidate = {
|
|
@@ -6943,12 +6943,12 @@ function evaluateFEELValues(validate, expressionLanguage, conditionChecker, form
|
|
|
6943
6943
|
}
|
|
6944
6944
|
|
|
6945
6945
|
class Importer {
|
|
6946
|
-
/**
|
|
6947
|
-
* @constructor
|
|
6948
|
-
* @param { import('./FormFieldRegistry').default } formFieldRegistry
|
|
6949
|
-
* @param { import('./PathRegistry').default } pathRegistry
|
|
6950
|
-
* @param { import('./FieldFactory').default } fieldFactory
|
|
6951
|
-
* @param { import('./FormLayouter').default } formLayouter
|
|
6946
|
+
/**
|
|
6947
|
+
* @constructor
|
|
6948
|
+
* @param { import('./FormFieldRegistry').default } formFieldRegistry
|
|
6949
|
+
* @param { import('./PathRegistry').default } pathRegistry
|
|
6950
|
+
* @param { import('./FieldFactory').default } fieldFactory
|
|
6951
|
+
* @param { import('./FormLayouter').default } formLayouter
|
|
6952
6952
|
*/
|
|
6953
6953
|
constructor(formFieldRegistry, pathRegistry, fieldFactory, formLayouter) {
|
|
6954
6954
|
this._formFieldRegistry = formFieldRegistry;
|
|
@@ -6957,21 +6957,21 @@ class Importer {
|
|
|
6957
6957
|
this._formLayouter = formLayouter;
|
|
6958
6958
|
}
|
|
6959
6959
|
|
|
6960
|
-
/**
|
|
6961
|
-
* Import schema creating rows, fields, attaching additional
|
|
6962
|
-
* information to each field and adding fields to the
|
|
6963
|
-
* field registry.
|
|
6964
|
-
*
|
|
6965
|
-
* Additional information attached:
|
|
6966
|
-
*
|
|
6967
|
-
* * `id` (unless present)
|
|
6968
|
-
* * `_parent`
|
|
6969
|
-
* * `_path`
|
|
6970
|
-
*
|
|
6971
|
-
* @param {any} schema
|
|
6972
|
-
*
|
|
6973
|
-
* @typedef {{ warnings: Error[], schema: any }} ImportResult
|
|
6974
|
-
* @returns {ImportResult}
|
|
6960
|
+
/**
|
|
6961
|
+
* Import schema creating rows, fields, attaching additional
|
|
6962
|
+
* information to each field and adding fields to the
|
|
6963
|
+
* field registry.
|
|
6964
|
+
*
|
|
6965
|
+
* Additional information attached:
|
|
6966
|
+
*
|
|
6967
|
+
* * `id` (unless present)
|
|
6968
|
+
* * `_parent`
|
|
6969
|
+
* * `_path`
|
|
6970
|
+
*
|
|
6971
|
+
* @param {any} schema
|
|
6972
|
+
*
|
|
6973
|
+
* @typedef {{ warnings: Error[], schema: any }} ImportResult
|
|
6974
|
+
* @returns {ImportResult}
|
|
6975
6975
|
*/
|
|
6976
6976
|
importSchema(schema) {
|
|
6977
6977
|
// TODO: Add warnings
|
|
@@ -6996,12 +6996,12 @@ class Importer {
|
|
|
6996
6996
|
this._pathRegistry.clear();
|
|
6997
6997
|
}
|
|
6998
6998
|
|
|
6999
|
-
/**
|
|
7000
|
-
* @param {{[x: string]: any}} fieldAttrs
|
|
7001
|
-
* @param {String} [parentId]
|
|
7002
|
-
* @param {number} [index]
|
|
7003
|
-
*
|
|
7004
|
-
* @return {any} field
|
|
6999
|
+
/**
|
|
7000
|
+
* @param {{[x: string]: any}} fieldAttrs
|
|
7001
|
+
* @param {String} [parentId]
|
|
7002
|
+
* @param {number} [index]
|
|
7003
|
+
*
|
|
7004
|
+
* @return {any} field
|
|
7005
7005
|
*/
|
|
7006
7006
|
importFormField(fieldAttrs, parentId, index) {
|
|
7007
7007
|
const {
|
|
@@ -7026,11 +7026,11 @@ class Importer {
|
|
|
7026
7026
|
return field;
|
|
7027
7027
|
}
|
|
7028
7028
|
|
|
7029
|
-
/**
|
|
7030
|
-
* @param {Array<any>} components
|
|
7031
|
-
* @param {string} parentId
|
|
7032
|
-
*
|
|
7033
|
-
* @return {Array<any>} imported components
|
|
7029
|
+
/**
|
|
7030
|
+
* @param {Array<any>} components
|
|
7031
|
+
* @param {string} parentId
|
|
7032
|
+
*
|
|
7033
|
+
* @return {Array<any>} imported components
|
|
7034
7034
|
*/
|
|
7035
7035
|
importFormFields(components, parentId) {
|
|
7036
7036
|
return components.map((component, index) => {
|
|
@@ -7041,11 +7041,11 @@ class Importer {
|
|
|
7041
7041
|
Importer.$inject = ['formFieldRegistry', 'pathRegistry', 'fieldFactory', 'formLayouter'];
|
|
7042
7042
|
|
|
7043
7043
|
class FieldFactory {
|
|
7044
|
-
/**
|
|
7045
|
-
* @constructor
|
|
7046
|
-
*
|
|
7047
|
-
* @param formFieldRegistry
|
|
7048
|
-
* @param formFields
|
|
7044
|
+
/**
|
|
7045
|
+
* @constructor
|
|
7046
|
+
*
|
|
7047
|
+
* @param formFieldRegistry
|
|
7048
|
+
* @param formFields
|
|
7049
7049
|
*/
|
|
7050
7050
|
constructor(formFieldRegistry, pathRegistry, formFields) {
|
|
7051
7051
|
this._formFieldRegistry = formFieldRegistry;
|
|
@@ -7155,36 +7155,36 @@ class FieldFactory {
|
|
|
7155
7155
|
}
|
|
7156
7156
|
FieldFactory.$inject = ['formFieldRegistry', 'pathRegistry', 'formFields'];
|
|
7157
7157
|
|
|
7158
|
-
/**
|
|
7159
|
-
* The PathRegistry class manages a hierarchical structure of paths associated with form fields.
|
|
7160
|
-
* It enables claiming, unclaiming, and validating paths within this structure.
|
|
7161
|
-
*
|
|
7162
|
-
* Example Tree Structure:
|
|
7163
|
-
*
|
|
7164
|
-
* [
|
|
7165
|
-
* {
|
|
7166
|
-
* segment: 'root',
|
|
7167
|
-
* claimCount: 1,
|
|
7168
|
-
* children: [
|
|
7169
|
-
* {
|
|
7170
|
-
* segment: 'child1',
|
|
7171
|
-
* claimCount: 2,
|
|
7172
|
-
* children: null // A leaf node (closed path)
|
|
7173
|
-
* },
|
|
7174
|
-
* {
|
|
7175
|
-
* segment: 'child2',
|
|
7176
|
-
* claimCount: 1,
|
|
7177
|
-
* children: [
|
|
7178
|
-
* {
|
|
7179
|
-
* segment: 'subChild1',
|
|
7180
|
-
* claimCount: 1,
|
|
7181
|
-
* children: [] // An open node (open path)
|
|
7182
|
-
* }
|
|
7183
|
-
* ]
|
|
7184
|
-
* }
|
|
7185
|
-
* ]
|
|
7186
|
-
* }
|
|
7187
|
-
* ]
|
|
7158
|
+
/**
|
|
7159
|
+
* The PathRegistry class manages a hierarchical structure of paths associated with form fields.
|
|
7160
|
+
* It enables claiming, unclaiming, and validating paths within this structure.
|
|
7161
|
+
*
|
|
7162
|
+
* Example Tree Structure:
|
|
7163
|
+
*
|
|
7164
|
+
* [
|
|
7165
|
+
* {
|
|
7166
|
+
* segment: 'root',
|
|
7167
|
+
* claimCount: 1,
|
|
7168
|
+
* children: [
|
|
7169
|
+
* {
|
|
7170
|
+
* segment: 'child1',
|
|
7171
|
+
* claimCount: 2,
|
|
7172
|
+
* children: null // A leaf node (closed path)
|
|
7173
|
+
* },
|
|
7174
|
+
* {
|
|
7175
|
+
* segment: 'child2',
|
|
7176
|
+
* claimCount: 1,
|
|
7177
|
+
* children: [
|
|
7178
|
+
* {
|
|
7179
|
+
* segment: 'subChild1',
|
|
7180
|
+
* claimCount: 1,
|
|
7181
|
+
* children: [] // An open node (open path)
|
|
7182
|
+
* }
|
|
7183
|
+
* ]
|
|
7184
|
+
* }
|
|
7185
|
+
* ]
|
|
7186
|
+
* }
|
|
7187
|
+
* ]
|
|
7188
7188
|
*/
|
|
7189
7189
|
class PathRegistry {
|
|
7190
7190
|
constructor(formFieldRegistry, formFields, injector) {
|
|
@@ -7300,16 +7300,16 @@ class PathRegistry {
|
|
|
7300
7300
|
}
|
|
7301
7301
|
}
|
|
7302
7302
|
|
|
7303
|
-
/**
|
|
7304
|
-
* Applies a function (fn) recursively on a given field and its children.
|
|
7305
|
-
*
|
|
7306
|
-
* - `field`: Starting field object.
|
|
7307
|
-
* - `fn`: Function to apply.
|
|
7308
|
-
* - `context`: Optional object for passing data between calls.
|
|
7309
|
-
*
|
|
7310
|
-
* Stops early if `fn` returns `false`. Useful for traversing the form field tree.
|
|
7311
|
-
*
|
|
7312
|
-
* @returns {boolean} Success status based on function execution.
|
|
7303
|
+
/**
|
|
7304
|
+
* Applies a function (fn) recursively on a given field and its children.
|
|
7305
|
+
*
|
|
7306
|
+
* - `field`: Starting field object.
|
|
7307
|
+
* - `fn`: Function to apply.
|
|
7308
|
+
* - `context`: Optional object for passing data between calls.
|
|
7309
|
+
*
|
|
7310
|
+
* Stops early if `fn` returns `false`. Useful for traversing the form field tree.
|
|
7311
|
+
*
|
|
7312
|
+
* @returns {boolean} Success status based on function execution.
|
|
7313
7313
|
*/
|
|
7314
7314
|
executeRecursivelyOnFields(field, fn, context = {}) {
|
|
7315
7315
|
let result = true;
|
|
@@ -7350,16 +7350,16 @@ class PathRegistry {
|
|
|
7350
7350
|
return result;
|
|
7351
7351
|
}
|
|
7352
7352
|
|
|
7353
|
-
/**
|
|
7354
|
-
* Generates an array representing the binding path to an underlying data object for a form field.
|
|
7355
|
-
*
|
|
7356
|
-
* @param {Object} field - The field object with properties: `key`, `path`, `id`, and optionally `_parent`.
|
|
7357
|
-
* @param {Object} [options={}] - Configuration options.
|
|
7358
|
-
* @param {Object} [options.replacements={}] - A map of field IDs to alternative path arrays.
|
|
7359
|
-
* @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.
|
|
7360
|
-
* @param {Object} [options.cutoffNode] - The ID of the parent field at which to stop generating the path.
|
|
7361
|
-
*
|
|
7362
|
-
* @returns {(Array<string>|undefined)} An array of strings representing the binding path, or undefined if not determinable.
|
|
7353
|
+
/**
|
|
7354
|
+
* Generates an array representing the binding path to an underlying data object for a form field.
|
|
7355
|
+
*
|
|
7356
|
+
* @param {Object} field - The field object with properties: `key`, `path`, `id`, and optionally `_parent`.
|
|
7357
|
+
* @param {Object} [options={}] - Configuration options.
|
|
7358
|
+
* @param {Object} [options.replacements={}] - A map of field IDs to alternative path arrays.
|
|
7359
|
+
* @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.
|
|
7360
|
+
* @param {Object} [options.cutoffNode] - The ID of the parent field at which to stop generating the path.
|
|
7361
|
+
*
|
|
7362
|
+
* @returns {(Array<string>|undefined)} An array of strings representing the binding path, or undefined if not determinable.
|
|
7363
7363
|
*/
|
|
7364
7364
|
getValuePath(field, options = {}) {
|
|
7365
7365
|
const {
|
|
@@ -7420,23 +7420,23 @@ const _getNextSegment = (node, segment) => {
|
|
|
7420
7420
|
};
|
|
7421
7421
|
PathRegistry.$inject = ['formFieldRegistry', 'formFields', 'injector'];
|
|
7422
7422
|
|
|
7423
|
-
/**
|
|
7424
|
-
* @typedef { { id: String, components: Array<String> } } FormRow
|
|
7425
|
-
* @typedef { { formFieldId: String, rows: Array<FormRow> } } FormRows
|
|
7423
|
+
/**
|
|
7424
|
+
* @typedef { { id: String, components: Array<String> } } FormRow
|
|
7425
|
+
* @typedef { { formFieldId: String, rows: Array<FormRow> } } FormRows
|
|
7426
7426
|
*/
|
|
7427
7427
|
|
|
7428
|
-
/**
|
|
7429
|
-
* Maintains the Form layout in a given structure, for example
|
|
7430
|
-
*
|
|
7431
|
-
* [
|
|
7432
|
-
* {
|
|
7433
|
-
* formFieldId: 'FormField_1',
|
|
7434
|
-
* rows: [
|
|
7435
|
-
* { id: 'Row_1', components: [ 'Text_1', 'Textdield_1', ... ] }
|
|
7436
|
-
* ]
|
|
7437
|
-
* }
|
|
7438
|
-
* ]
|
|
7439
|
-
*
|
|
7428
|
+
/**
|
|
7429
|
+
* Maintains the Form layout in a given structure, for example
|
|
7430
|
+
*
|
|
7431
|
+
* [
|
|
7432
|
+
* {
|
|
7433
|
+
* formFieldId: 'FormField_1',
|
|
7434
|
+
* rows: [
|
|
7435
|
+
* { id: 'Row_1', components: [ 'Text_1', 'Textdield_1', ... ] }
|
|
7436
|
+
* ]
|
|
7437
|
+
* }
|
|
7438
|
+
* ]
|
|
7439
|
+
*
|
|
7440
7440
|
*/
|
|
7441
7441
|
class FormLayouter {
|
|
7442
7442
|
constructor(eventBus) {
|
|
@@ -7446,8 +7446,8 @@ class FormLayouter {
|
|
|
7446
7446
|
this._eventBus = eventBus;
|
|
7447
7447
|
}
|
|
7448
7448
|
|
|
7449
|
-
/**
|
|
7450
|
-
* @param {FormRow} row
|
|
7449
|
+
/**
|
|
7450
|
+
* @param {FormRow} row
|
|
7451
7451
|
*/
|
|
7452
7452
|
addRow(formFieldId, row) {
|
|
7453
7453
|
let rowsPerComponent = this._rows.find(r => r.formFieldId === formFieldId);
|
|
@@ -7461,18 +7461,18 @@ class FormLayouter {
|
|
|
7461
7461
|
rowsPerComponent.rows.push(row);
|
|
7462
7462
|
}
|
|
7463
7463
|
|
|
7464
|
-
/**
|
|
7465
|
-
* @param {String} id
|
|
7466
|
-
* @returns {FormRow}
|
|
7464
|
+
/**
|
|
7465
|
+
* @param {String} id
|
|
7466
|
+
* @returns {FormRow}
|
|
7467
7467
|
*/
|
|
7468
7468
|
getRow(id) {
|
|
7469
7469
|
const rows = allRows(this._rows);
|
|
7470
7470
|
return rows.find(r => r.id === id);
|
|
7471
7471
|
}
|
|
7472
7472
|
|
|
7473
|
-
/**
|
|
7474
|
-
* @param {any} formField
|
|
7475
|
-
* @returns {FormRow}
|
|
7473
|
+
/**
|
|
7474
|
+
* @param {any} formField
|
|
7475
|
+
* @returns {FormRow}
|
|
7476
7476
|
*/
|
|
7477
7477
|
getRowForField(formField) {
|
|
7478
7478
|
return allRows(this._rows).find(r => {
|
|
@@ -7483,9 +7483,9 @@ class FormLayouter {
|
|
|
7483
7483
|
});
|
|
7484
7484
|
}
|
|
7485
7485
|
|
|
7486
|
-
/**
|
|
7487
|
-
* @param {String} formFieldId
|
|
7488
|
-
* @returns { Array<FormRow> }
|
|
7486
|
+
/**
|
|
7487
|
+
* @param {String} formFieldId
|
|
7488
|
+
* @returns { Array<FormRow> }
|
|
7489
7489
|
*/
|
|
7490
7490
|
getRows(formFieldId) {
|
|
7491
7491
|
const rowsForField = this._rows.find(r => formFieldId === r.formFieldId);
|
|
@@ -7495,15 +7495,15 @@ class FormLayouter {
|
|
|
7495
7495
|
return rowsForField.rows;
|
|
7496
7496
|
}
|
|
7497
7497
|
|
|
7498
|
-
/**
|
|
7499
|
-
* @returns {string}
|
|
7498
|
+
/**
|
|
7499
|
+
* @returns {string}
|
|
7500
7500
|
*/
|
|
7501
7501
|
nextRowId() {
|
|
7502
7502
|
return this._ids.nextPrefixed('Row_');
|
|
7503
7503
|
}
|
|
7504
7504
|
|
|
7505
|
-
/**
|
|
7506
|
-
* @param {any} formField
|
|
7505
|
+
/**
|
|
7506
|
+
* @param {any} formField
|
|
7507
7507
|
*/
|
|
7508
7508
|
calculateLayout(formField) {
|
|
7509
7509
|
const {
|
|
@@ -7557,9 +7557,9 @@ function groupByRow(components, ids) {
|
|
|
7557
7557
|
});
|
|
7558
7558
|
}
|
|
7559
7559
|
|
|
7560
|
-
/**
|
|
7561
|
-
* @param {Array<FormRows>} formRows
|
|
7562
|
-
* @returns {Array<FormRow>}
|
|
7560
|
+
/**
|
|
7561
|
+
* @param {Array<FormRows>} formRows
|
|
7562
|
+
* @returns {Array<FormRow>}
|
|
7563
7563
|
*/
|
|
7564
7564
|
function allRows(formRows) {
|
|
7565
7565
|
return minDash.flatten(formRows.map(c => c.rows));
|
|
@@ -7684,55 +7684,55 @@ var core = {
|
|
|
7684
7684
|
validator: ['type', Validator]
|
|
7685
7685
|
};
|
|
7686
7686
|
|
|
7687
|
-
/**
|
|
7688
|
-
* @typedef { import('./types').Injector } Injector
|
|
7689
|
-
* @typedef { import('./types').Data } Data
|
|
7690
|
-
* @typedef { import('./types').Errors } Errors
|
|
7691
|
-
* @typedef { import('./types').Schema } Schema
|
|
7692
|
-
* @typedef { import('./types').FormProperties } FormProperties
|
|
7693
|
-
* @typedef { import('./types').FormProperty } FormProperty
|
|
7694
|
-
* @typedef { import('./types').FormEvent } FormEvent
|
|
7695
|
-
* @typedef { import('./types').FormOptions } FormOptions
|
|
7696
|
-
*
|
|
7697
|
-
* @typedef { {
|
|
7698
|
-
* data: Data,
|
|
7699
|
-
* initialData: Data,
|
|
7700
|
-
* errors: Errors,
|
|
7701
|
-
* properties: FormProperties,
|
|
7702
|
-
* schema: Schema
|
|
7703
|
-
* } } State
|
|
7704
|
-
*
|
|
7705
|
-
* @typedef { (type:FormEvent, priority:number, handler:Function) => void } OnEventWithPriority
|
|
7706
|
-
* @typedef { (type:FormEvent, handler:Function) => void } OnEventWithOutPriority
|
|
7707
|
-
* @typedef { OnEventWithPriority & OnEventWithOutPriority } OnEventType
|
|
7687
|
+
/**
|
|
7688
|
+
* @typedef { import('./types').Injector } Injector
|
|
7689
|
+
* @typedef { import('./types').Data } Data
|
|
7690
|
+
* @typedef { import('./types').Errors } Errors
|
|
7691
|
+
* @typedef { import('./types').Schema } Schema
|
|
7692
|
+
* @typedef { import('./types').FormProperties } FormProperties
|
|
7693
|
+
* @typedef { import('./types').FormProperty } FormProperty
|
|
7694
|
+
* @typedef { import('./types').FormEvent } FormEvent
|
|
7695
|
+
* @typedef { import('./types').FormOptions } FormOptions
|
|
7696
|
+
*
|
|
7697
|
+
* @typedef { {
|
|
7698
|
+
* data: Data,
|
|
7699
|
+
* initialData: Data,
|
|
7700
|
+
* errors: Errors,
|
|
7701
|
+
* properties: FormProperties,
|
|
7702
|
+
* schema: Schema
|
|
7703
|
+
* } } State
|
|
7704
|
+
*
|
|
7705
|
+
* @typedef { (type:FormEvent, priority:number, handler:Function) => void } OnEventWithPriority
|
|
7706
|
+
* @typedef { (type:FormEvent, handler:Function) => void } OnEventWithOutPriority
|
|
7707
|
+
* @typedef { OnEventWithPriority & OnEventWithOutPriority } OnEventType
|
|
7708
7708
|
*/
|
|
7709
7709
|
|
|
7710
7710
|
const ids = new Ids([32, 36, 1]);
|
|
7711
7711
|
|
|
7712
|
-
/**
|
|
7713
|
-
* The form.
|
|
7712
|
+
/**
|
|
7713
|
+
* The form.
|
|
7714
7714
|
*/
|
|
7715
7715
|
class Form {
|
|
7716
|
-
/**
|
|
7717
|
-
* @constructor
|
|
7718
|
-
* @param {FormOptions} options
|
|
7716
|
+
/**
|
|
7717
|
+
* @constructor
|
|
7718
|
+
* @param {FormOptions} options
|
|
7719
7719
|
*/
|
|
7720
7720
|
constructor(options = {}) {
|
|
7721
|
-
/**
|
|
7722
|
-
* @public
|
|
7723
|
-
* @type {OnEventType}
|
|
7721
|
+
/**
|
|
7722
|
+
* @public
|
|
7723
|
+
* @type {OnEventType}
|
|
7724
7724
|
*/
|
|
7725
7725
|
this.on = this._onEvent;
|
|
7726
7726
|
|
|
7727
|
-
/**
|
|
7728
|
-
* @public
|
|
7729
|
-
* @type {String}
|
|
7727
|
+
/**
|
|
7728
|
+
* @public
|
|
7729
|
+
* @type {String}
|
|
7730
7730
|
*/
|
|
7731
7731
|
this._id = ids.next();
|
|
7732
7732
|
|
|
7733
|
-
/**
|
|
7734
|
-
* @private
|
|
7735
|
-
* @type {Element}
|
|
7733
|
+
/**
|
|
7734
|
+
* @private
|
|
7735
|
+
* @type {Element}
|
|
7736
7736
|
*/
|
|
7737
7737
|
this._container = createFormContainer();
|
|
7738
7738
|
const {
|
|
@@ -7741,9 +7741,9 @@ class Form {
|
|
|
7741
7741
|
properties = {}
|
|
7742
7742
|
} = options;
|
|
7743
7743
|
|
|
7744
|
-
/**
|
|
7745
|
-
* @private
|
|
7746
|
-
* @type {State}
|
|
7744
|
+
/**
|
|
7745
|
+
* @private
|
|
7746
|
+
* @type {State}
|
|
7747
7747
|
*/
|
|
7748
7748
|
this._state = {
|
|
7749
7749
|
initialData: null,
|
|
@@ -7767,9 +7767,9 @@ class Form {
|
|
|
7767
7767
|
this._emit('form.clear');
|
|
7768
7768
|
}
|
|
7769
7769
|
|
|
7770
|
-
/**
|
|
7771
|
-
* Destroy the form, removing it from DOM,
|
|
7772
|
-
* if attached.
|
|
7770
|
+
/**
|
|
7771
|
+
* Destroy the form, removing it from DOM,
|
|
7772
|
+
* if attached.
|
|
7773
7773
|
*/
|
|
7774
7774
|
destroy() {
|
|
7775
7775
|
// destroy form services
|
|
@@ -7780,13 +7780,13 @@ class Form {
|
|
|
7780
7780
|
this._detach(false);
|
|
7781
7781
|
}
|
|
7782
7782
|
|
|
7783
|
-
/**
|
|
7784
|
-
* Open a form schema with the given initial data.
|
|
7785
|
-
*
|
|
7786
|
-
* @param {Schema} schema
|
|
7787
|
-
* @param {Data} [data]
|
|
7788
|
-
*
|
|
7789
|
-
* @return Promise<{ warnings: Array<any> }>
|
|
7783
|
+
/**
|
|
7784
|
+
* Open a form schema with the given initial data.
|
|
7785
|
+
*
|
|
7786
|
+
* @param {Schema} schema
|
|
7787
|
+
* @param {Data} [data]
|
|
7788
|
+
*
|
|
7789
|
+
* @return Promise<{ warnings: Array<any> }>
|
|
7790
7790
|
*/
|
|
7791
7791
|
importSchema(schema, data = {}) {
|
|
7792
7792
|
return new Promise((resolve, reject) => {
|
|
@@ -7819,10 +7819,10 @@ class Form {
|
|
|
7819
7819
|
});
|
|
7820
7820
|
}
|
|
7821
7821
|
|
|
7822
|
-
/**
|
|
7823
|
-
* Submit the form, triggering all field validations.
|
|
7824
|
-
*
|
|
7825
|
-
* @returns { { data: Data, errors: Errors } }
|
|
7822
|
+
/**
|
|
7823
|
+
* Submit the form, triggering all field validations.
|
|
7824
|
+
*
|
|
7825
|
+
* @returns { { data: Data, errors: Errors } }
|
|
7826
7826
|
*/
|
|
7827
7827
|
submit() {
|
|
7828
7828
|
const {
|
|
@@ -7848,8 +7848,8 @@ class Form {
|
|
|
7848
7848
|
});
|
|
7849
7849
|
}
|
|
7850
7850
|
|
|
7851
|
-
/**
|
|
7852
|
-
* @returns {Errors}
|
|
7851
|
+
/**
|
|
7852
|
+
* @returns {Errors}
|
|
7853
7853
|
*/
|
|
7854
7854
|
validate() {
|
|
7855
7855
|
const formFields = this.get('formFields'),
|
|
@@ -7921,8 +7921,8 @@ class Form {
|
|
|
7921
7921
|
return filteredErrors;
|
|
7922
7922
|
}
|
|
7923
7923
|
|
|
7924
|
-
/**
|
|
7925
|
-
* @param {Element|string} parentNode
|
|
7924
|
+
/**
|
|
7925
|
+
* @param {Element|string} parentNode
|
|
7926
7926
|
*/
|
|
7927
7927
|
attachTo(parentNode) {
|
|
7928
7928
|
if (!parentNode) {
|
|
@@ -7940,10 +7940,10 @@ class Form {
|
|
|
7940
7940
|
this._detach();
|
|
7941
7941
|
}
|
|
7942
7942
|
|
|
7943
|
-
/**
|
|
7944
|
-
* @private
|
|
7945
|
-
*
|
|
7946
|
-
* @param {boolean} [emit]
|
|
7943
|
+
/**
|
|
7944
|
+
* @private
|
|
7945
|
+
*
|
|
7946
|
+
* @param {boolean} [emit]
|
|
7947
7947
|
*/
|
|
7948
7948
|
_detach(emit = true) {
|
|
7949
7949
|
const container = this._container,
|
|
@@ -7957,9 +7957,9 @@ class Form {
|
|
|
7957
7957
|
parentNode.removeChild(container);
|
|
7958
7958
|
}
|
|
7959
7959
|
|
|
7960
|
-
/**
|
|
7961
|
-
* @param {FormProperty} property
|
|
7962
|
-
* @param {any} value
|
|
7960
|
+
/**
|
|
7961
|
+
* @param {FormProperty} property
|
|
7962
|
+
* @param {any} value
|
|
7963
7963
|
*/
|
|
7964
7964
|
setProperty(property, value) {
|
|
7965
7965
|
const properties = minDash.set(this._getState().properties, [property], value);
|
|
@@ -7968,21 +7968,21 @@ class Form {
|
|
|
7968
7968
|
});
|
|
7969
7969
|
}
|
|
7970
7970
|
|
|
7971
|
-
/**
|
|
7972
|
-
* @param {FormEvent} type
|
|
7973
|
-
* @param {Function} handler
|
|
7971
|
+
/**
|
|
7972
|
+
* @param {FormEvent} type
|
|
7973
|
+
* @param {Function} handler
|
|
7974
7974
|
*/
|
|
7975
7975
|
off(type, handler) {
|
|
7976
7976
|
this.get('eventBus').off(type, handler);
|
|
7977
7977
|
}
|
|
7978
7978
|
|
|
7979
|
-
/**
|
|
7980
|
-
* @private
|
|
7981
|
-
*
|
|
7982
|
-
* @param {FormOptions} options
|
|
7983
|
-
* @param {Element} container
|
|
7984
|
-
*
|
|
7985
|
-
* @returns {Injector}
|
|
7979
|
+
/**
|
|
7980
|
+
* @private
|
|
7981
|
+
*
|
|
7982
|
+
* @param {FormOptions} options
|
|
7983
|
+
* @param {Element} container
|
|
7984
|
+
*
|
|
7985
|
+
* @returns {Injector}
|
|
7986
7986
|
*/
|
|
7987
7987
|
_createInjector(options, container) {
|
|
7988
7988
|
const {
|
|
@@ -8001,17 +8001,17 @@ class Form {
|
|
|
8001
8001
|
}, core, ...modules, ...additionalModules]);
|
|
8002
8002
|
}
|
|
8003
8003
|
|
|
8004
|
-
/**
|
|
8005
|
-
* @private
|
|
8004
|
+
/**
|
|
8005
|
+
* @private
|
|
8006
8006
|
*/
|
|
8007
8007
|
_emit(type, data) {
|
|
8008
8008
|
this.get('eventBus').fire(type, data);
|
|
8009
8009
|
}
|
|
8010
8010
|
|
|
8011
|
-
/**
|
|
8012
|
-
* @internal
|
|
8013
|
-
*
|
|
8014
|
-
* @param { { add?: boolean, field: any, indexes: object, remove?: number, value?: any } } update
|
|
8011
|
+
/**
|
|
8012
|
+
* @internal
|
|
8013
|
+
*
|
|
8014
|
+
* @param { { add?: boolean, field: any, indexes: object, remove?: number, value?: any } } update
|
|
8015
8015
|
*/
|
|
8016
8016
|
_update(update) {
|
|
8017
8017
|
const {
|
|
@@ -8037,15 +8037,15 @@ class Form {
|
|
|
8037
8037
|
});
|
|
8038
8038
|
}
|
|
8039
8039
|
|
|
8040
|
-
/**
|
|
8041
|
-
* @internal
|
|
8040
|
+
/**
|
|
8041
|
+
* @internal
|
|
8042
8042
|
*/
|
|
8043
8043
|
_getState() {
|
|
8044
8044
|
return this._state;
|
|
8045
8045
|
}
|
|
8046
8046
|
|
|
8047
|
-
/**
|
|
8048
|
-
* @internal
|
|
8047
|
+
/**
|
|
8048
|
+
* @internal
|
|
8049
8049
|
*/
|
|
8050
8050
|
_setState(state) {
|
|
8051
8051
|
this._state = {
|
|
@@ -8055,22 +8055,22 @@ class Form {
|
|
|
8055
8055
|
this._emit('changed', this._getState());
|
|
8056
8056
|
}
|
|
8057
8057
|
|
|
8058
|
-
/**
|
|
8059
|
-
* @internal
|
|
8058
|
+
/**
|
|
8059
|
+
* @internal
|
|
8060
8060
|
*/
|
|
8061
8061
|
_getModules() {
|
|
8062
8062
|
return [ExpressionLanguageModule, MarkdownModule, ViewerCommandsModule, RepeatRenderModule];
|
|
8063
8063
|
}
|
|
8064
8064
|
|
|
8065
|
-
/**
|
|
8066
|
-
* @internal
|
|
8065
|
+
/**
|
|
8066
|
+
* @internal
|
|
8067
8067
|
*/
|
|
8068
8068
|
_onEvent(type, priority, handler) {
|
|
8069
8069
|
this.get('eventBus').on(type, priority, handler);
|
|
8070
8070
|
}
|
|
8071
8071
|
|
|
8072
|
-
/**
|
|
8073
|
-
* @internal
|
|
8072
|
+
/**
|
|
8073
|
+
* @internal
|
|
8074
8074
|
*/
|
|
8075
8075
|
_getSubmitData() {
|
|
8076
8076
|
const formFieldRegistry = this.get('formFieldRegistry');
|
|
@@ -8127,16 +8127,16 @@ class Form {
|
|
|
8127
8127
|
return this._applyConditions(workingSubmitData, formData);
|
|
8128
8128
|
}
|
|
8129
8129
|
|
|
8130
|
-
/**
|
|
8131
|
-
* @internal
|
|
8130
|
+
/**
|
|
8131
|
+
* @internal
|
|
8132
8132
|
*/
|
|
8133
8133
|
_applyConditions(toFilter, data, options = {}) {
|
|
8134
8134
|
const conditionChecker = this.get('conditionChecker');
|
|
8135
8135
|
return conditionChecker.applyConditions(toFilter, data, options);
|
|
8136
8136
|
}
|
|
8137
8137
|
|
|
8138
|
-
/**
|
|
8139
|
-
* @internal
|
|
8138
|
+
/**
|
|
8139
|
+
* @internal
|
|
8140
8140
|
*/
|
|
8141
8141
|
_getInitializedFieldData(data, options = {}) {
|
|
8142
8142
|
const formFieldRegistry = this.get('formFieldRegistry');
|