@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.cjs
CHANGED
|
@@ -74,26 +74,26 @@ const getFlavouredFeelVariableNames = (feelString, feelFlavour = 'expression', o
|
|
|
74
74
|
return [...new Set(variables)];
|
|
75
75
|
};
|
|
76
76
|
|
|
77
|
-
/**
|
|
78
|
-
* Get the variable name at the specified index in a given path expression.
|
|
79
|
-
*
|
|
80
|
-
* @param {Object} root - The root node of the path expression tree.
|
|
81
|
-
* @param {number} index - The index of the variable name to retrieve.
|
|
82
|
-
* @returns {string|null} The variable name at the specified index or null if index is out of bounds.
|
|
77
|
+
/**
|
|
78
|
+
* Get the variable name at the specified index in a given path expression.
|
|
79
|
+
*
|
|
80
|
+
* @param {Object} root - The root node of the path expression tree.
|
|
81
|
+
* @param {number} index - The index of the variable name to retrieve.
|
|
82
|
+
* @returns {string|null} The variable name at the specified index or null if index is out of bounds.
|
|
83
83
|
*/
|
|
84
84
|
const _getVariableNameAtPathIndex = (root, index) => {
|
|
85
85
|
const nodes = _linearizePathExpression(root);
|
|
86
86
|
return nodes[index].variableName || null;
|
|
87
87
|
};
|
|
88
88
|
|
|
89
|
-
/**
|
|
90
|
-
* Extracts the variables which are required of the external context for a given path expression.
|
|
91
|
-
* This is done by traversing the path expression tree and keeping track of the current depth relative to the external context.
|
|
92
|
-
*
|
|
93
|
-
* @param {Object} node - The root node of the path expression tree.
|
|
94
|
-
* @param {number} initialDepth - The depth at which the root node is located in the outer context.
|
|
95
|
-
* @param {Object} specialDepthAccessors - Definitions of special keywords which represent more complex accesses of the outer context.
|
|
96
|
-
* @returns {Set} - A set containing the extracted variable names.
|
|
89
|
+
/**
|
|
90
|
+
* Extracts the variables which are required of the external context for a given path expression.
|
|
91
|
+
* This is done by traversing the path expression tree and keeping track of the current depth relative to the external context.
|
|
92
|
+
*
|
|
93
|
+
* @param {Object} node - The root node of the path expression tree.
|
|
94
|
+
* @param {number} initialDepth - The depth at which the root node is located in the outer context.
|
|
95
|
+
* @param {Object} specialDepthAccessors - Definitions of special keywords which represent more complex accesses of the outer context.
|
|
96
|
+
* @returns {Set} - A set containing the extracted variable names.
|
|
97
97
|
*/
|
|
98
98
|
const _smartExtractVariableNames = (node, initialDepth, specialDepthAccessors) => {
|
|
99
99
|
// depth info represents the previous (initialised as null) and current depth of the current accessor in the path expression
|
|
@@ -139,11 +139,11 @@ const _smartExtractVariableNames = (node, initialDepth, specialDepthAccessors) =
|
|
|
139
139
|
return new Set(extractedVariables);
|
|
140
140
|
};
|
|
141
141
|
|
|
142
|
-
/**
|
|
143
|
-
* Deconstructs a path expression tree into an array of components.
|
|
144
|
-
*
|
|
145
|
-
* @param {Object} root - The root node of the path expression tree.
|
|
146
|
-
* @returns {Array<object>} An array of components in the path expression, in the correct order.
|
|
142
|
+
/**
|
|
143
|
+
* Deconstructs a path expression tree into an array of components.
|
|
144
|
+
*
|
|
145
|
+
* @param {Object} root - The root node of the path expression tree.
|
|
146
|
+
* @returns {Array<object>} An array of components in the path expression, in the correct order.
|
|
147
147
|
*/
|
|
148
148
|
const _linearizePathExpression = root => {
|
|
149
149
|
let node = root;
|
|
@@ -162,13 +162,13 @@ const _linearizePathExpression = root => {
|
|
|
162
162
|
return parts.reverse();
|
|
163
163
|
};
|
|
164
164
|
|
|
165
|
-
/**
|
|
166
|
-
* Builds a simplified feel structure tree from the given parse tree and feel string.
|
|
167
|
-
* The nodes follow this structure: `{ name: string, children: Array, variableName?: string }`
|
|
168
|
-
*
|
|
169
|
-
* @param {Object} parseTree - The parse tree generated by a parser.
|
|
170
|
-
* @param {string} feelString - The feel string used for parsing.
|
|
171
|
-
* @returns {Object} The simplified feel structure tree.
|
|
165
|
+
/**
|
|
166
|
+
* Builds a simplified feel structure tree from the given parse tree and feel string.
|
|
167
|
+
* The nodes follow this structure: `{ name: string, children: Array, variableName?: string }`
|
|
168
|
+
*
|
|
169
|
+
* @param {Object} parseTree - The parse tree generated by a parser.
|
|
170
|
+
* @param {string} feelString - The feel string used for parsing.
|
|
171
|
+
* @returns {Object} The simplified feel structure tree.
|
|
172
172
|
*/
|
|
173
173
|
const _buildSimpleFeelStructureTree = (parseTree, feelString) => {
|
|
174
174
|
const stack = [{
|
|
@@ -194,9 +194,9 @@ const _buildSimpleFeelStructureTree = (parseTree, feelString) => {
|
|
|
194
194
|
return _extractFilterExpressions(stack[0].children[0]);
|
|
195
195
|
};
|
|
196
196
|
|
|
197
|
-
/**
|
|
198
|
-
* Restructure the tree in such a way to bring filters (which create new contexts) to the root of the tree.
|
|
199
|
-
* This is done to simplify the extraction of variables and match the context hierarchy.
|
|
197
|
+
/**
|
|
198
|
+
* Restructure the tree in such a way to bring filters (which create new contexts) to the root of the tree.
|
|
199
|
+
* This is done to simplify the extraction of variables and match the context hierarchy.
|
|
200
200
|
*/
|
|
201
201
|
const _extractFilterExpressions = tree => {
|
|
202
202
|
const flattenedExpressionTree = {
|
|
@@ -237,25 +237,25 @@ class FeelExpressionLanguage {
|
|
|
237
237
|
this._eventBus = eventBus;
|
|
238
238
|
}
|
|
239
239
|
|
|
240
|
-
/**
|
|
241
|
-
* Determines if the given value is a FEEL expression.
|
|
242
|
-
*
|
|
243
|
-
* @param {any} value
|
|
244
|
-
* @returns {boolean}
|
|
245
|
-
*
|
|
240
|
+
/**
|
|
241
|
+
* Determines if the given value is a FEEL expression.
|
|
242
|
+
*
|
|
243
|
+
* @param {any} value
|
|
244
|
+
* @returns {boolean}
|
|
245
|
+
*
|
|
246
246
|
*/
|
|
247
247
|
isExpression(value) {
|
|
248
248
|
return minDash.isString(value) && value.startsWith('=');
|
|
249
249
|
}
|
|
250
250
|
|
|
251
|
-
/**
|
|
252
|
-
* Retrieve variable names from a given FEEL expression.
|
|
253
|
-
*
|
|
254
|
-
* @param {string} expression
|
|
255
|
-
* @param {object} [options]
|
|
256
|
-
* @param {string} [options.type]
|
|
257
|
-
*
|
|
258
|
-
* @returns {string[]}
|
|
251
|
+
/**
|
|
252
|
+
* Retrieve variable names from a given FEEL expression.
|
|
253
|
+
*
|
|
254
|
+
* @param {string} expression
|
|
255
|
+
* @param {object} [options]
|
|
256
|
+
* @param {string} [options.type]
|
|
257
|
+
*
|
|
258
|
+
* @returns {string[]}
|
|
259
259
|
*/
|
|
260
260
|
getVariableNames(expression, options = {}) {
|
|
261
261
|
const {
|
|
@@ -270,13 +270,13 @@ class FeelExpressionLanguage {
|
|
|
270
270
|
return getFlavouredFeelVariableNames(expression, type);
|
|
271
271
|
}
|
|
272
272
|
|
|
273
|
-
/**
|
|
274
|
-
* Evaluate an expression.
|
|
275
|
-
*
|
|
276
|
-
* @param {string} expression
|
|
277
|
-
* @param {import('../../types').Data} [data]
|
|
278
|
-
*
|
|
279
|
-
* @returns {any}
|
|
273
|
+
/**
|
|
274
|
+
* Evaluate an expression.
|
|
275
|
+
*
|
|
276
|
+
* @param {string} expression
|
|
277
|
+
* @param {import('../../types').Data} [data]
|
|
278
|
+
*
|
|
279
|
+
* @returns {any}
|
|
280
280
|
*/
|
|
281
281
|
evaluate(expression, data = {}) {
|
|
282
282
|
if (!expression) {
|
|
@@ -301,23 +301,23 @@ FeelExpressionLanguage.$inject = ['eventBus'];
|
|
|
301
301
|
class FeelersTemplating {
|
|
302
302
|
constructor() {}
|
|
303
303
|
|
|
304
|
-
/**
|
|
305
|
-
* Determines if the given value is a feelers template.
|
|
306
|
-
*
|
|
307
|
-
* @param {any} value
|
|
308
|
-
* @returns {boolean}
|
|
309
|
-
*
|
|
304
|
+
/**
|
|
305
|
+
* Determines if the given value is a feelers template.
|
|
306
|
+
*
|
|
307
|
+
* @param {any} value
|
|
308
|
+
* @returns {boolean}
|
|
309
|
+
*
|
|
310
310
|
*/
|
|
311
311
|
isTemplate(value) {
|
|
312
312
|
return minDash.isString(value) && (value.startsWith('=') || /{{.*?}}/.test(value));
|
|
313
313
|
}
|
|
314
314
|
|
|
315
|
-
/**
|
|
316
|
-
* Retrieve variable names from a given feelers template.
|
|
317
|
-
*
|
|
318
|
-
* @param {string} template
|
|
319
|
-
*
|
|
320
|
-
* @returns {string[]}
|
|
315
|
+
/**
|
|
316
|
+
* Retrieve variable names from a given feelers template.
|
|
317
|
+
*
|
|
318
|
+
* @param {string} template
|
|
319
|
+
*
|
|
320
|
+
* @returns {string[]}
|
|
321
321
|
*/
|
|
322
322
|
getVariableNames(template) {
|
|
323
323
|
if (!this.isTemplate(template)) {
|
|
@@ -343,17 +343,17 @@ class FeelersTemplating {
|
|
|
343
343
|
}, []);
|
|
344
344
|
}
|
|
345
345
|
|
|
346
|
-
/**
|
|
347
|
-
* Evaluate a template.
|
|
348
|
-
*
|
|
349
|
-
* @param {string} template
|
|
350
|
-
* @param {Object<string, any>} context
|
|
351
|
-
* @param {Object} options
|
|
352
|
-
* @param {boolean} [options.debug = false]
|
|
353
|
-
* @param {boolean} [options.strict = false]
|
|
354
|
-
* @param {Function} [options.buildDebugString]
|
|
355
|
-
*
|
|
356
|
-
* @returns
|
|
346
|
+
/**
|
|
347
|
+
* Evaluate a template.
|
|
348
|
+
*
|
|
349
|
+
* @param {string} template
|
|
350
|
+
* @param {Object<string, any>} context
|
|
351
|
+
* @param {Object} options
|
|
352
|
+
* @param {boolean} [options.debug = false]
|
|
353
|
+
* @param {boolean} [options.strict = false]
|
|
354
|
+
* @param {Function} [options.buildDebugString]
|
|
355
|
+
*
|
|
356
|
+
* @returns
|
|
357
357
|
*/
|
|
358
358
|
evaluate(template, context = {}, options = {}) {
|
|
359
359
|
const {
|
|
@@ -368,22 +368,22 @@ class FeelersTemplating {
|
|
|
368
368
|
});
|
|
369
369
|
}
|
|
370
370
|
|
|
371
|
-
/**
|
|
372
|
-
* @typedef {Object} ExpressionWithDepth
|
|
373
|
-
* @property {number} depth - The depth of the expression in the syntax tree.
|
|
374
|
-
* @property {string} expression - The extracted expression
|
|
371
|
+
/**
|
|
372
|
+
* @typedef {Object} ExpressionWithDepth
|
|
373
|
+
* @property {number} depth - The depth of the expression in the syntax tree.
|
|
374
|
+
* @property {string} expression - The extracted expression
|
|
375
375
|
*/
|
|
376
376
|
|
|
377
|
-
/**
|
|
378
|
-
* Extracts all feel expressions in the template along with their depth in the syntax tree.
|
|
379
|
-
* The depth is incremented for child expressions of loops to account for context drilling.
|
|
380
|
-
|
|
381
|
-
* @param {string} template - A feelers template string.
|
|
382
|
-
* @returns {Array<ExpressionWithDepth>} An array of objects, each containing the depth and the extracted expression.
|
|
383
|
-
*
|
|
384
|
-
* @example
|
|
385
|
-
* const template = "Hello {{user}}, you have:{{#loop items}}\n- {{amount}} {{name}}{{/loop}}.";
|
|
386
|
-
* const extractedExpressions = _extractExpressionsWithDepth(template);
|
|
377
|
+
/**
|
|
378
|
+
* Extracts all feel expressions in the template along with their depth in the syntax tree.
|
|
379
|
+
* The depth is incremented for child expressions of loops to account for context drilling.
|
|
380
|
+
* @name extractExpressionsWithDepth
|
|
381
|
+
* @param {string} template - A feelers template string.
|
|
382
|
+
* @returns {Array<ExpressionWithDepth>} An array of objects, each containing the depth and the extracted expression.
|
|
383
|
+
*
|
|
384
|
+
* @example
|
|
385
|
+
* const template = "Hello {{user}}, you have:{{#loop items}}\n- {{amount}} {{name}}{{/loop}}.";
|
|
386
|
+
* const extractedExpressions = _extractExpressionsWithDepth(template);
|
|
387
387
|
*/
|
|
388
388
|
_extractExpressionsWithDepth(template) {
|
|
389
389
|
// build simplified feelers syntax tree
|
|
@@ -489,10 +489,10 @@ function createInjector(bootstrapModules) {
|
|
|
489
489
|
return injector;
|
|
490
490
|
}
|
|
491
491
|
|
|
492
|
-
/**
|
|
493
|
-
* @param {string?} prefix
|
|
494
|
-
*
|
|
495
|
-
* @returns Element
|
|
492
|
+
/**
|
|
493
|
+
* @param {string?} prefix
|
|
494
|
+
*
|
|
495
|
+
* @returns Element
|
|
496
496
|
*/
|
|
497
497
|
function createFormContainer(prefix = 'fjs') {
|
|
498
498
|
const container = document.createElement('div');
|
|
@@ -623,11 +623,11 @@ const LocalExpressionContext = preact.createContext({
|
|
|
623
623
|
});
|
|
624
624
|
var LocalExpressionContext$1 = LocalExpressionContext;
|
|
625
625
|
|
|
626
|
-
/**
|
|
627
|
-
* @param {string} type
|
|
628
|
-
* @param {boolean} [strict]
|
|
629
|
-
*
|
|
630
|
-
* @returns {any}
|
|
626
|
+
/**
|
|
627
|
+
* @param {string} type
|
|
628
|
+
* @param {boolean} [strict]
|
|
629
|
+
*
|
|
630
|
+
* @returns {any}
|
|
631
631
|
*/
|
|
632
632
|
function getService(type, strict) {}
|
|
633
633
|
const FormContext = preact.createContext({
|
|
@@ -670,21 +670,21 @@ function generateIdForType(type) {
|
|
|
670
670
|
return `${type}${generateIndexForType(type)}`;
|
|
671
671
|
}
|
|
672
672
|
|
|
673
|
-
/**
|
|
674
|
-
* @template T
|
|
675
|
-
* @param {T} data
|
|
676
|
-
* @param {(this: any, key: string, value: any) => any} [replacer]
|
|
677
|
-
* @return {T}
|
|
673
|
+
/**
|
|
674
|
+
* @template T
|
|
675
|
+
* @param {T} data
|
|
676
|
+
* @param {(this: any, key: string, value: any) => any} [replacer]
|
|
677
|
+
* @return {T}
|
|
678
678
|
*/
|
|
679
679
|
function clone(data, replacer) {
|
|
680
680
|
return JSON.parse(JSON.stringify(data, replacer));
|
|
681
681
|
}
|
|
682
682
|
|
|
683
|
-
/**
|
|
684
|
-
* Transform a LocalExpressionContext object into a usable FEEL context.
|
|
685
|
-
*
|
|
686
|
-
* @param {Object} context - The LocalExpressionContext object.
|
|
687
|
-
* @returns {Object} The usable FEEL context.
|
|
683
|
+
/**
|
|
684
|
+
* Transform a LocalExpressionContext object into a usable FEEL context.
|
|
685
|
+
*
|
|
686
|
+
* @param {Object} context - The LocalExpressionContext object.
|
|
687
|
+
* @returns {Object} The usable FEEL context.
|
|
688
688
|
*/
|
|
689
689
|
|
|
690
690
|
function buildExpressionContext(context) {
|
|
@@ -716,12 +716,12 @@ function _wrapObjectKeysWithUnderscores(obj) {
|
|
|
716
716
|
return newObj;
|
|
717
717
|
}
|
|
718
718
|
|
|
719
|
-
/**
|
|
720
|
-
* Evaluate if condition is met reactively based on the conditionChecker and form data.
|
|
721
|
-
*
|
|
722
|
-
* @param {string | undefined} condition
|
|
723
|
-
*
|
|
724
|
-
* @returns {boolean} true if condition is met or no condition or condition checker exists
|
|
719
|
+
/**
|
|
720
|
+
* Evaluate if condition is met reactively based on the conditionChecker and form data.
|
|
721
|
+
*
|
|
722
|
+
* @param {string | undefined} condition
|
|
723
|
+
*
|
|
724
|
+
* @returns {boolean} true if condition is met or no condition or condition checker exists
|
|
725
725
|
*/
|
|
726
726
|
function useCondition(condition) {
|
|
727
727
|
const conditionChecker = useService('conditionChecker', false);
|
|
@@ -731,17 +731,17 @@ function useCondition(condition) {
|
|
|
731
731
|
}, [conditionChecker, condition, expressionContextInfo]);
|
|
732
732
|
}
|
|
733
733
|
|
|
734
|
-
/**
|
|
735
|
-
* Custom hook to scroll an element into view only when it is not visible within the viewport.
|
|
736
|
-
*
|
|
737
|
-
* @param {Object} targetRef - A ref pointing to the DOM element to scroll into view.
|
|
738
|
-
* @param {Array} deps - An array of dependencies that trigger the effect.
|
|
739
|
-
* @param {Array} flagRefs - An array of refs that are used as flags to control when to scroll.
|
|
740
|
-
* @param {Object} [scrollOptions={}] - Options defining the behavior of the scrolling.
|
|
741
|
-
* @param {String} [scrollOptions.align='center'] - The alignment of the element within the viewport.
|
|
742
|
-
* @param {String} [scrollOptions.behavior='auto'] - The scrolling behavior.
|
|
743
|
-
* @param {Number} [scrollOptions.offset=0] - An offset that is added to the scroll position.
|
|
744
|
-
* @param {Boolean} [scrollOptions.scrollIfVisible=false] - Whether to scroll even if the element is visible.
|
|
734
|
+
/**
|
|
735
|
+
* Custom hook to scroll an element into view only when it is not visible within the viewport.
|
|
736
|
+
*
|
|
737
|
+
* @param {Object} targetRef - A ref pointing to the DOM element to scroll into view.
|
|
738
|
+
* @param {Array} deps - An array of dependencies that trigger the effect.
|
|
739
|
+
* @param {Array} flagRefs - An array of refs that are used as flags to control when to scroll.
|
|
740
|
+
* @param {Object} [scrollOptions={}] - Options defining the behavior of the scrolling.
|
|
741
|
+
* @param {String} [scrollOptions.align='center'] - The alignment of the element within the viewport.
|
|
742
|
+
* @param {String} [scrollOptions.behavior='auto'] - The scrolling behavior.
|
|
743
|
+
* @param {Number} [scrollOptions.offset=0] - An offset that is added to the scroll position.
|
|
744
|
+
* @param {Boolean} [scrollOptions.scrollIfVisible=false] - Whether to scroll even if the element is visible.
|
|
745
745
|
*/
|
|
746
746
|
function useScrollIntoView(targetRef, deps, scrollOptions = null, flagRefs = []) {
|
|
747
747
|
hooks.useEffect(() => {
|
|
@@ -806,13 +806,13 @@ function _getTopOffset(item, scrollContainer, options) {
|
|
|
806
806
|
return 0;
|
|
807
807
|
}
|
|
808
808
|
|
|
809
|
-
/**
|
|
810
|
-
* Evaluate a string reactively based on the expressionLanguage and form data.
|
|
811
|
-
* If the string is not an expression, it is returned as is.
|
|
812
|
-
* The function is memoized to minimize re-renders.
|
|
813
|
-
*
|
|
814
|
-
* @param {string} value - The string to evaluate.
|
|
815
|
-
* @returns {any} - Evaluated value or the original value if not an expression.
|
|
809
|
+
/**
|
|
810
|
+
* Evaluate a string reactively based on the expressionLanguage and form data.
|
|
811
|
+
* If the string is not an expression, it is returned as is.
|
|
812
|
+
* The function is memoized to minimize re-renders.
|
|
813
|
+
*
|
|
814
|
+
* @param {string} value - The string to evaluate.
|
|
815
|
+
* @returns {any} - Evaluated value or the original value if not an expression.
|
|
816
816
|
*/
|
|
817
817
|
function useExpressionEvaluation(value) {
|
|
818
818
|
const expressionLanguage = useService('expressionLanguage');
|
|
@@ -825,11 +825,11 @@ function useExpressionEvaluation(value) {
|
|
|
825
825
|
}, [expressionLanguage, expressionContextInfo, value]);
|
|
826
826
|
}
|
|
827
827
|
|
|
828
|
-
/**
|
|
829
|
-
* Returns the conditionally filtered data of a form reactively.
|
|
830
|
-
* Memoised to minimize re-renders
|
|
831
|
-
*
|
|
832
|
-
* Warning: costly operation, use with care
|
|
828
|
+
/**
|
|
829
|
+
* Returns the conditionally filtered data of a form reactively.
|
|
830
|
+
* Memoised to minimize re-renders
|
|
831
|
+
*
|
|
832
|
+
* Warning: costly operation, use with care
|
|
833
833
|
*/
|
|
834
834
|
function useFilteredFormData() {
|
|
835
835
|
const {
|
|
@@ -862,16 +862,16 @@ function useKeyDownAction(targetKey, action, listenerElement = window) {
|
|
|
862
862
|
});
|
|
863
863
|
}
|
|
864
864
|
|
|
865
|
-
/**
|
|
866
|
-
* Retrieve readonly value of a form field, given it can be an
|
|
867
|
-
* expression optionally or configured globally.
|
|
868
|
-
*
|
|
869
|
-
* @typedef { import('../../types').FormProperties } FormProperties
|
|
870
|
-
*
|
|
871
|
-
* @param {any} formField
|
|
872
|
-
* @param {FormProperties} properties
|
|
873
|
-
*
|
|
874
|
-
* @returns {boolean}
|
|
865
|
+
/**
|
|
866
|
+
* Retrieve readonly value of a form field, given it can be an
|
|
867
|
+
* expression optionally or configured globally.
|
|
868
|
+
*
|
|
869
|
+
* @typedef { import('../../types').FormProperties } FormProperties
|
|
870
|
+
*
|
|
871
|
+
* @param {any} formField
|
|
872
|
+
* @param {FormProperties} properties
|
|
873
|
+
*
|
|
874
|
+
* @returns {boolean}
|
|
875
875
|
*/
|
|
876
876
|
function useReadonly(formField, properties = {}) {
|
|
877
877
|
const expressionLanguage = useService('expressionLanguage');
|
|
@@ -895,12 +895,12 @@ function usePrevious(value, defaultValue, dependencies) {
|
|
|
895
895
|
return ref.current;
|
|
896
896
|
}
|
|
897
897
|
|
|
898
|
-
/**
|
|
899
|
-
* A custom hook to manage state changes with deep comparison.
|
|
900
|
-
*
|
|
901
|
-
* @param {any} value - The current value to manage.
|
|
902
|
-
* @param {any} defaultValue - The initial default value for the state.
|
|
903
|
-
* @returns {any} - Returns the current state.
|
|
898
|
+
/**
|
|
899
|
+
* A custom hook to manage state changes with deep comparison.
|
|
900
|
+
*
|
|
901
|
+
* @param {any} value - The current value to manage.
|
|
902
|
+
* @param {any} defaultValue - The initial default value for the state.
|
|
903
|
+
* @returns {any} - Returns the current state.
|
|
904
904
|
*/
|
|
905
905
|
function useDeepCompareState(value, defaultValue) {
|
|
906
906
|
const [state, setState] = hooks.useState(defaultValue);
|
|
@@ -920,16 +920,16 @@ function compare(a, b) {
|
|
|
920
920
|
return JSON.stringify(a) === JSON.stringify(b);
|
|
921
921
|
}
|
|
922
922
|
|
|
923
|
-
/**
|
|
924
|
-
* Template a string reactively based on form data. If the string is not a template, it is returned as is.
|
|
925
|
-
* Memoised to minimize re-renders
|
|
926
|
-
*
|
|
927
|
-
* @param {string} value
|
|
928
|
-
* @param {Object} options
|
|
929
|
-
* @param {boolean} [options.debug = false]
|
|
930
|
-
* @param {boolean} [options.strict = false]
|
|
931
|
-
* @param {Function} [options.buildDebugString]
|
|
932
|
-
*
|
|
923
|
+
/**
|
|
924
|
+
* Template a string reactively based on form data. If the string is not a template, it is returned as is.
|
|
925
|
+
* Memoised to minimize re-renders
|
|
926
|
+
*
|
|
927
|
+
* @param {string} value
|
|
928
|
+
* @param {Object} options
|
|
929
|
+
* @param {boolean} [options.debug = false]
|
|
930
|
+
* @param {boolean} [options.strict = false]
|
|
931
|
+
* @param {Function} [options.buildDebugString]
|
|
932
|
+
*
|
|
933
933
|
*/
|
|
934
934
|
function useTemplateEvaluation(value, options = {}) {
|
|
935
935
|
const templating = useService('templating');
|
|
@@ -942,17 +942,17 @@ function useTemplateEvaluation(value, options = {}) {
|
|
|
942
942
|
}, [templating, value, expressionContextInfo, options]);
|
|
943
943
|
}
|
|
944
944
|
|
|
945
|
-
/**
|
|
946
|
-
* Template a string reactively based on form data. If the string is not a template, it is returned as is.
|
|
947
|
-
* If the string contains multiple lines, only the first line is returned.
|
|
948
|
-
* Memoised to minimize re-renders
|
|
949
|
-
*
|
|
950
|
-
* @param {string} value
|
|
951
|
-
* @param {Object} [options]
|
|
952
|
-
* @param {boolean} [options.debug = false]
|
|
953
|
-
* @param {boolean} [options.strict = false]
|
|
954
|
-
* @param {Function} [options.buildDebugString]
|
|
955
|
-
*
|
|
945
|
+
/**
|
|
946
|
+
* Template a string reactively based on form data. If the string is not a template, it is returned as is.
|
|
947
|
+
* If the string contains multiple lines, only the first line is returned.
|
|
948
|
+
* Memoised to minimize re-renders
|
|
949
|
+
*
|
|
950
|
+
* @param {string} value
|
|
951
|
+
* @param {Object} [options]
|
|
952
|
+
* @param {boolean} [options.debug = false]
|
|
953
|
+
* @param {boolean} [options.strict = false]
|
|
954
|
+
* @param {Function} [options.buildDebugString]
|
|
955
|
+
*
|
|
956
956
|
*/
|
|
957
957
|
function useSingleLineTemplateEvaluation(value, options = {}) {
|
|
958
958
|
const evaluatedTemplate = useTemplateEvaluation(value, options);
|
|
@@ -1108,15 +1108,15 @@ function normalizeOptionsData(optionsData) {
|
|
|
1108
1108
|
return optionsData.filter(_isAllowedValue).map(_normalizeOption).filter(o => !minDash.isNil(o));
|
|
1109
1109
|
}
|
|
1110
1110
|
|
|
1111
|
-
/**
|
|
1112
|
-
* Converts the provided option to a normalized format.
|
|
1113
|
-
* If the option is not valid, null is returned.
|
|
1114
|
-
*
|
|
1115
|
-
* @param {object} option
|
|
1116
|
-
* @param {string} option.label
|
|
1117
|
-
* @param {*} option.value
|
|
1118
|
-
*
|
|
1119
|
-
* @returns
|
|
1111
|
+
/**
|
|
1112
|
+
* Converts the provided option to a normalized format.
|
|
1113
|
+
* If the option is not valid, null is returned.
|
|
1114
|
+
*
|
|
1115
|
+
* @param {object} option
|
|
1116
|
+
* @param {string} option.label
|
|
1117
|
+
* @param {*} option.value
|
|
1118
|
+
*
|
|
1119
|
+
* @returns
|
|
1120
1120
|
*/
|
|
1121
1121
|
function _normalizeOption(option) {
|
|
1122
1122
|
// (1) simple primitive case, use it as both label and value
|
|
@@ -1174,8 +1174,8 @@ function createEmptyOptions(options = {}) {
|
|
|
1174
1174
|
};
|
|
1175
1175
|
}
|
|
1176
1176
|
|
|
1177
|
-
/**
|
|
1178
|
-
* @enum { String }
|
|
1177
|
+
/**
|
|
1178
|
+
* @enum { String }
|
|
1179
1179
|
*/
|
|
1180
1180
|
const LOAD_STATES = {
|
|
1181
1181
|
LOADING: 'loading',
|
|
@@ -1183,17 +1183,17 @@ const LOAD_STATES = {
|
|
|
1183
1183
|
ERROR: 'error'
|
|
1184
1184
|
};
|
|
1185
1185
|
|
|
1186
|
-
/**
|
|
1187
|
-
* @typedef {Object} OptionsGetter
|
|
1188
|
-
* @property {Object[]} options - The options data
|
|
1189
|
-
* @property {(LOAD_STATES)} loadState - The options data's loading state, to use for conditional rendering
|
|
1186
|
+
/**
|
|
1187
|
+
* @typedef {Object} OptionsGetter
|
|
1188
|
+
* @property {Object[]} options - The options data
|
|
1189
|
+
* @property {(LOAD_STATES)} loadState - The options data's loading state, to use for conditional rendering
|
|
1190
1190
|
*/
|
|
1191
1191
|
|
|
1192
|
-
/**
|
|
1193
|
-
* A hook to load options for single and multiselect components.
|
|
1194
|
-
*
|
|
1195
|
-
* @param {Object} field - The form field to handle options for
|
|
1196
|
-
* @return {OptionsGetter} optionsGetter - A options getter object providing loading state and options
|
|
1192
|
+
/**
|
|
1193
|
+
* A hook to load options for single and multiselect components.
|
|
1194
|
+
*
|
|
1195
|
+
* @param {Object} field - The form field to handle options for
|
|
1196
|
+
* @return {OptionsGetter} optionsGetter - A options getter object providing loading state and options
|
|
1197
1197
|
*/
|
|
1198
1198
|
function useOptionsAsync (field) {
|
|
1199
1199
|
const {
|
|
@@ -1840,12 +1840,12 @@ FormComponent$1.config = {
|
|
|
1840
1840
|
})
|
|
1841
1841
|
};
|
|
1842
1842
|
|
|
1843
|
-
/**
|
|
1844
|
-
* Returns date format for the provided locale.
|
|
1845
|
-
* If the locale is not provided, uses the browser's locale.
|
|
1846
|
-
*
|
|
1847
|
-
* @param {string} [locale] - The locale to get date format for.
|
|
1848
|
-
* @returns {string} The date format for the locale.
|
|
1843
|
+
/**
|
|
1844
|
+
* Returns date format for the provided locale.
|
|
1845
|
+
* If the locale is not provided, uses the browser's locale.
|
|
1846
|
+
*
|
|
1847
|
+
* @param {string} [locale] - The locale to get date format for.
|
|
1848
|
+
* @returns {string} The date format for the locale.
|
|
1849
1849
|
*/
|
|
1850
1850
|
function getLocaleDateFormat(locale = 'default') {
|
|
1851
1851
|
const parts = new Intl.DateTimeFormat(locale).formatToParts(new Date(Date.UTC(2020, 5, 5)));
|
|
@@ -1864,12 +1864,12 @@ function getLocaleDateFormat(locale = 'default') {
|
|
|
1864
1864
|
}).join('');
|
|
1865
1865
|
}
|
|
1866
1866
|
|
|
1867
|
-
/**
|
|
1868
|
-
* Returns readable date format for the provided locale.
|
|
1869
|
-
* If the locale is not provided, uses the browser's locale.
|
|
1870
|
-
*
|
|
1871
|
-
* @param {string} [locale] - The locale to get readable date format for.
|
|
1872
|
-
* @returns {string} The readable date format for the locale.
|
|
1867
|
+
/**
|
|
1868
|
+
* Returns readable date format for the provided locale.
|
|
1869
|
+
* If the locale is not provided, uses the browser's locale.
|
|
1870
|
+
*
|
|
1871
|
+
* @param {string} [locale] - The locale to get readable date format for.
|
|
1872
|
+
* @returns {string} The readable date format for the locale.
|
|
1873
1873
|
*/
|
|
1874
1874
|
function getLocaleReadableDateFormat(locale) {
|
|
1875
1875
|
let format = getLocaleDateFormat(locale).toLowerCase();
|
|
@@ -1886,12 +1886,12 @@ function getLocaleReadableDateFormat(locale) {
|
|
|
1886
1886
|
return format;
|
|
1887
1887
|
}
|
|
1888
1888
|
|
|
1889
|
-
/**
|
|
1890
|
-
* Returns flatpickr config for the provided locale.
|
|
1891
|
-
* If the locale is not provided, uses the browser's locale.
|
|
1892
|
-
*
|
|
1893
|
-
* @param {string} [locale] - The locale to get flatpickr config for.
|
|
1894
|
-
* @returns {object} The flatpickr config for the locale.
|
|
1889
|
+
/**
|
|
1890
|
+
* Returns flatpickr config for the provided locale.
|
|
1891
|
+
* If the locale is not provided, uses the browser's locale.
|
|
1892
|
+
*
|
|
1893
|
+
* @param {string} [locale] - The locale to get flatpickr config for.
|
|
1894
|
+
* @returns {object} The flatpickr config for the locale.
|
|
1895
1895
|
*/
|
|
1896
1896
|
function getLocaleDateFlatpickrConfig(locale) {
|
|
1897
1897
|
return flatpickerizeDateFormat(getLocaleDateFormat(locale));
|
|
@@ -2603,10 +2603,10 @@ Datetime.config = {
|
|
|
2603
2603
|
}
|
|
2604
2604
|
};
|
|
2605
2605
|
|
|
2606
|
-
/**
|
|
2607
|
-
* This file must not be changed or exchanged.
|
|
2608
|
-
*
|
|
2609
|
-
* @see http://bpmn.io/license for more information.
|
|
2606
|
+
/**
|
|
2607
|
+
* This file must not be changed or exchanged.
|
|
2608
|
+
*
|
|
2609
|
+
* @see http://bpmn.io/license for more information.
|
|
2610
2610
|
*/
|
|
2611
2611
|
function Logo() {
|
|
2612
2612
|
return jsxRuntime.jsxs("svg", {
|
|
@@ -2792,11 +2792,11 @@ const ATTR_WHITESPACE_PATTERN = /[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u
|
|
|
2792
2792
|
|
|
2793
2793
|
const FORM_ELEMENT = document.createElement('form');
|
|
2794
2794
|
|
|
2795
|
-
/**
|
|
2796
|
-
* Sanitize a HTML string and return the cleaned, safe version.
|
|
2797
|
-
*
|
|
2798
|
-
* @param {string} html
|
|
2799
|
-
* @return {string}
|
|
2795
|
+
/**
|
|
2796
|
+
* Sanitize a HTML string and return the cleaned, safe version.
|
|
2797
|
+
*
|
|
2798
|
+
* @param {string} html
|
|
2799
|
+
* @return {string}
|
|
2800
2800
|
*/
|
|
2801
2801
|
|
|
2802
2802
|
// see https://github.com/developit/snarkdown/issues/70
|
|
@@ -2814,41 +2814,41 @@ function sanitizeHTML(html) {
|
|
|
2814
2814
|
}
|
|
2815
2815
|
}
|
|
2816
2816
|
|
|
2817
|
-
/**
|
|
2818
|
-
* Sanitizes an image source to ensure we only allow for data URI and links
|
|
2819
|
-
* that start with http(s).
|
|
2820
|
-
*
|
|
2821
|
-
* Note: Most browsers anyway do not support script execution in <img> elements.
|
|
2822
|
-
*
|
|
2823
|
-
* @param {string} src
|
|
2824
|
-
* @returns {string}
|
|
2817
|
+
/**
|
|
2818
|
+
* Sanitizes an image source to ensure we only allow for data URI and links
|
|
2819
|
+
* that start with http(s).
|
|
2820
|
+
*
|
|
2821
|
+
* Note: Most browsers anyway do not support script execution in <img> elements.
|
|
2822
|
+
*
|
|
2823
|
+
* @param {string} src
|
|
2824
|
+
* @returns {string}
|
|
2825
2825
|
*/
|
|
2826
2826
|
function sanitizeImageSource(src) {
|
|
2827
2827
|
const valid = ALLOWED_IMAGE_SRC_PATTERN.test(src);
|
|
2828
2828
|
return valid ? src : '';
|
|
2829
2829
|
}
|
|
2830
2830
|
|
|
2831
|
-
/**
|
|
2832
|
-
* Sanitizes an iframe source to ensure we only allow for links
|
|
2833
|
-
* that start with http(s).
|
|
2834
|
-
*
|
|
2835
|
-
* @param {string} src
|
|
2836
|
-
* @returns {string}
|
|
2831
|
+
/**
|
|
2832
|
+
* Sanitizes an iframe source to ensure we only allow for links
|
|
2833
|
+
* that start with http(s).
|
|
2834
|
+
*
|
|
2835
|
+
* @param {string} src
|
|
2836
|
+
* @returns {string}
|
|
2837
2837
|
*/
|
|
2838
2838
|
function sanitizeIFrameSource(src) {
|
|
2839
2839
|
const valid = ALLOWED_IFRAME_SRC_PATTERN.test(src);
|
|
2840
2840
|
return valid ? src : '';
|
|
2841
2841
|
}
|
|
2842
2842
|
|
|
2843
|
-
/**
|
|
2844
|
-
* Recursively sanitize a HTML node, potentially
|
|
2845
|
-
* removing it, its children or attributes.
|
|
2846
|
-
*
|
|
2847
|
-
* Inspired by https://github.com/developit/snarkdown/issues/70
|
|
2848
|
-
* and https://github.com/cure53/DOMPurify. Simplified
|
|
2849
|
-
* for our use-case.
|
|
2850
|
-
*
|
|
2851
|
-
* @param {Element} node
|
|
2843
|
+
/**
|
|
2844
|
+
* Recursively sanitize a HTML node, potentially
|
|
2845
|
+
* removing it, its children or attributes.
|
|
2846
|
+
*
|
|
2847
|
+
* Inspired by https://github.com/developit/snarkdown/issues/70
|
|
2848
|
+
* and https://github.com/cure53/DOMPurify. Simplified
|
|
2849
|
+
* for our use-case.
|
|
2850
|
+
*
|
|
2851
|
+
* @param {Element} node
|
|
2852
2852
|
*/
|
|
2853
2853
|
function sanitizeNode(node) {
|
|
2854
2854
|
// allow text nodes
|
|
@@ -2892,13 +2892,13 @@ function sanitizeNode(node) {
|
|
|
2892
2892
|
}
|
|
2893
2893
|
}
|
|
2894
2894
|
|
|
2895
|
-
/**
|
|
2896
|
-
* Validates attributes for validity.
|
|
2897
|
-
*
|
|
2898
|
-
* @param {string} lcTag
|
|
2899
|
-
* @param {string} lcName
|
|
2900
|
-
* @param {string} value
|
|
2901
|
-
* @return {boolean}
|
|
2895
|
+
/**
|
|
2896
|
+
* Validates attributes for validity.
|
|
2897
|
+
*
|
|
2898
|
+
* @param {string} lcTag
|
|
2899
|
+
* @param {string} lcName
|
|
2900
|
+
* @param {string} value
|
|
2901
|
+
* @return {boolean}
|
|
2902
2902
|
*/
|
|
2903
2903
|
function isValidAttribute(lcTag, lcName, value) {
|
|
2904
2904
|
// disallow most attributes based on whitelist
|
|
@@ -3513,9 +3513,9 @@ Radio.config = {
|
|
|
3513
3513
|
create: createEmptyOptions
|
|
3514
3514
|
};
|
|
3515
3515
|
|
|
3516
|
-
/**
|
|
3517
|
-
* This hook allows us to retrieve the label from a value in linear time by caching it in a map
|
|
3518
|
-
* @param {Array} options
|
|
3516
|
+
/**
|
|
3517
|
+
* This hook allows us to retrieve the label from a value in linear time by caching it in a map
|
|
3518
|
+
* @param {Array} options
|
|
3519
3519
|
*/
|
|
3520
3520
|
function useGetLabelCorrelation(options) {
|
|
3521
3521
|
// This allows us to retrieve the label from a value in linear time
|
|
@@ -4627,28 +4627,28 @@ var CaretRightIcon = SvgCaretRight;
|
|
|
4627
4627
|
|
|
4628
4628
|
const type = 'table';
|
|
4629
4629
|
|
|
4630
|
-
/**
|
|
4631
|
-
* @typedef {('asc'|'desc')} Direction
|
|
4632
|
-
*
|
|
4633
|
-
* @typedef Sorting
|
|
4634
|
-
* @property {string} key
|
|
4635
|
-
* @property {Direction} direction
|
|
4636
|
-
*
|
|
4637
|
-
* @typedef Column
|
|
4638
|
-
* @property {string} label
|
|
4639
|
-
* @property {string} key
|
|
4640
|
-
*
|
|
4641
|
-
* @typedef Props
|
|
4642
|
-
* @property {Object} field
|
|
4643
|
-
* @property {string} field.id
|
|
4644
|
-
* @property {Array<Column>} [field.columns]
|
|
4645
|
-
* @property {string} [field.columnsExpression]
|
|
4646
|
-
* @property {string} [field.label]
|
|
4647
|
-
* @property {number} [field.rowCount]
|
|
4648
|
-
* @property {string} [field.dataSource]
|
|
4649
|
-
*
|
|
4650
|
-
* @param {Props} props
|
|
4651
|
-
* @returns {import("preact").JSX.Element}
|
|
4630
|
+
/**
|
|
4631
|
+
* @typedef {('asc'|'desc')} Direction
|
|
4632
|
+
*
|
|
4633
|
+
* @typedef Sorting
|
|
4634
|
+
* @property {string} key
|
|
4635
|
+
* @property {Direction} direction
|
|
4636
|
+
*
|
|
4637
|
+
* @typedef Column
|
|
4638
|
+
* @property {string} label
|
|
4639
|
+
* @property {string} key
|
|
4640
|
+
*
|
|
4641
|
+
* @typedef Props
|
|
4642
|
+
* @property {Object} field
|
|
4643
|
+
* @property {string} field.id
|
|
4644
|
+
* @property {Array<Column>} [field.columns]
|
|
4645
|
+
* @property {string} [field.columnsExpression]
|
|
4646
|
+
* @property {string} [field.label]
|
|
4647
|
+
* @property {number} [field.rowCount]
|
|
4648
|
+
* @property {string} [field.dataSource]
|
|
4649
|
+
*
|
|
4650
|
+
* @param {Props} props
|
|
4651
|
+
* @returns {import("preact").JSX.Element}
|
|
4652
4652
|
*/
|
|
4653
4653
|
function Table(props) {
|
|
4654
4654
|
const {
|
|
@@ -4858,10 +4858,10 @@ Table.config = {
|
|
|
4858
4858
|
|
|
4859
4859
|
// helpers /////////////////////////////
|
|
4860
4860
|
|
|
4861
|
-
/**
|
|
4862
|
-
* @param {string|void} columnsExpression
|
|
4863
|
-
* @param {Column[]} fallbackColumns
|
|
4864
|
-
* @returns {Column[]}
|
|
4861
|
+
/**
|
|
4862
|
+
* @param {string|void} columnsExpression
|
|
4863
|
+
* @param {Column[]} fallbackColumns
|
|
4864
|
+
* @returns {Column[]}
|
|
4865
4865
|
*/
|
|
4866
4866
|
function useEvaluatedColumns(columnsExpression, fallbackColumns) {
|
|
4867
4867
|
/** @type {Column[]|null} */
|
|
@@ -4869,18 +4869,18 @@ function useEvaluatedColumns(columnsExpression, fallbackColumns) {
|
|
|
4869
4869
|
return Array.isArray(evaluation) && evaluation.every(isColumn) ? evaluation : fallbackColumns;
|
|
4870
4870
|
}
|
|
4871
4871
|
|
|
4872
|
-
/**
|
|
4873
|
-
* @param {any} column
|
|
4874
|
-
* @returns {column is Column}
|
|
4872
|
+
/**
|
|
4873
|
+
* @param {any} column
|
|
4874
|
+
* @returns {column is Column}
|
|
4875
4875
|
*/
|
|
4876
4876
|
function isColumn(column) {
|
|
4877
4877
|
return minDash.isObject(column) && minDash.isString(column['label']) && minDash.isString(column['key']);
|
|
4878
4878
|
}
|
|
4879
4879
|
|
|
4880
|
-
/**
|
|
4881
|
-
* @param {Array} array
|
|
4882
|
-
* @param {number} size
|
|
4883
|
-
* @returns {Array}
|
|
4880
|
+
/**
|
|
4881
|
+
* @param {Array} array
|
|
4882
|
+
* @param {number} size
|
|
4883
|
+
* @returns {Array}
|
|
4884
4884
|
*/
|
|
4885
4885
|
function chunk(array, size) {
|
|
4886
4886
|
return array.reduce((chunks, item, index) => {
|
|
@@ -4893,11 +4893,11 @@ function chunk(array, size) {
|
|
|
4893
4893
|
}, []);
|
|
4894
4894
|
}
|
|
4895
4895
|
|
|
4896
|
-
/**
|
|
4897
|
-
* @param {unknown[]} array
|
|
4898
|
-
* @param {string} key
|
|
4899
|
-
* @param {Direction} direction
|
|
4900
|
-
* @returns {unknown[]}
|
|
4896
|
+
/**
|
|
4897
|
+
* @param {unknown[]} array
|
|
4898
|
+
* @param {string} key
|
|
4899
|
+
* @param {Direction} direction
|
|
4900
|
+
* @returns {unknown[]}
|
|
4901
4901
|
*/
|
|
4902
4902
|
function sortByColumn(array, key, direction) {
|
|
4903
4903
|
return [...array].sort((a, b) => {
|
|
@@ -4911,10 +4911,10 @@ function sortByColumn(array, key, direction) {
|
|
|
4911
4911
|
});
|
|
4912
4912
|
}
|
|
4913
4913
|
|
|
4914
|
-
/**
|
|
4915
|
-
* @param {null|Sorting} sortBy
|
|
4916
|
-
* @param {string} key
|
|
4917
|
-
* @param {string} label
|
|
4914
|
+
/**
|
|
4915
|
+
* @param {null|Sorting} sortBy
|
|
4916
|
+
* @param {string} key
|
|
4917
|
+
* @param {string} label
|
|
4918
4918
|
*/
|
|
4919
4919
|
function getHeaderAriaLabel(sortBy, key, label) {
|
|
4920
4920
|
if (sortBy === null || sortBy.key !== key) {
|
|
@@ -5289,37 +5289,37 @@ class FormFields {
|
|
|
5289
5289
|
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'];
|
|
5290
5290
|
const TEMPLATE_PROPERTIES = ['alt', 'appearance.prefixAdorner', 'appearance.suffixAdorner', 'description', 'label', 'source', 'text', 'url'];
|
|
5291
5291
|
|
|
5292
|
-
/**
|
|
5293
|
-
* @typedef { import('../types').Schema } Schema
|
|
5292
|
+
/**
|
|
5293
|
+
* @typedef { import('../types').Schema } Schema
|
|
5294
5294
|
*/
|
|
5295
5295
|
|
|
5296
|
-
/**
|
|
5297
|
-
* Parse the schema for variables a form might make use of.
|
|
5298
|
-
*
|
|
5299
|
-
* @example
|
|
5300
|
-
*
|
|
5301
|
-
* // retrieve variables from schema
|
|
5302
|
-
* const variables = getSchemaVariables(schema);
|
|
5303
|
-
*
|
|
5304
|
-
* @example
|
|
5305
|
-
*
|
|
5306
|
-
* // retrieve input variables from schema
|
|
5307
|
-
* const inputVariables = getSchemaVariables(schema, { outputs: false });
|
|
5308
|
-
*
|
|
5309
|
-
* @example
|
|
5310
|
-
*
|
|
5311
|
-
* // retrieve output variables from schema
|
|
5312
|
-
* const outputVariables = getSchemaVariables(schema, { inputs: false });
|
|
5313
|
-
*
|
|
5314
|
-
* @param {Schema} schema
|
|
5315
|
-
* @param {object} [options]
|
|
5316
|
-
* @param {any} [options.expressionLanguage]
|
|
5317
|
-
* @param {any} [options.templating]
|
|
5318
|
-
* @param {any} [options.formFields]
|
|
5319
|
-
* @param {boolean} [options.inputs=true]
|
|
5320
|
-
* @param {boolean} [options.outputs=true]
|
|
5321
|
-
*
|
|
5322
|
-
* @return {string[]}
|
|
5296
|
+
/**
|
|
5297
|
+
* Parse the schema for variables a form might make use of.
|
|
5298
|
+
*
|
|
5299
|
+
* @example
|
|
5300
|
+
*
|
|
5301
|
+
* // retrieve variables from schema
|
|
5302
|
+
* const variables = getSchemaVariables(schema);
|
|
5303
|
+
*
|
|
5304
|
+
* @example
|
|
5305
|
+
*
|
|
5306
|
+
* // retrieve input variables from schema
|
|
5307
|
+
* const inputVariables = getSchemaVariables(schema, { outputs: false });
|
|
5308
|
+
*
|
|
5309
|
+
* @example
|
|
5310
|
+
*
|
|
5311
|
+
* // retrieve output variables from schema
|
|
5312
|
+
* const outputVariables = getSchemaVariables(schema, { inputs: false });
|
|
5313
|
+
*
|
|
5314
|
+
* @param {Schema} schema
|
|
5315
|
+
* @param {object} [options]
|
|
5316
|
+
* @param {any} [options.expressionLanguage]
|
|
5317
|
+
* @param {any} [options.templating]
|
|
5318
|
+
* @param {any} [options.formFields]
|
|
5319
|
+
* @param {boolean} [options.inputs=true]
|
|
5320
|
+
* @param {boolean} [options.outputs=true]
|
|
5321
|
+
*
|
|
5322
|
+
* @return {string[]}
|
|
5323
5323
|
*/
|
|
5324
5324
|
function getSchemaVariables(schema, options = {}) {
|
|
5325
5325
|
const {
|
|
@@ -5395,13 +5395,13 @@ function getSchemaVariables(schema, options = {}) {
|
|
|
5395
5395
|
return Array.from(new Set(variables));
|
|
5396
5396
|
}
|
|
5397
5397
|
|
|
5398
|
-
/**
|
|
5399
|
-
* Get the ancestry list of a form field.
|
|
5400
|
-
*
|
|
5401
|
-
* @param {string} formFieldId
|
|
5402
|
-
* @param {import('../core/FormFieldRegistry').default} formFieldRegistry
|
|
5403
|
-
*
|
|
5404
|
-
* @return {Array<string>} ancestry list
|
|
5398
|
+
/**
|
|
5399
|
+
* Get the ancestry list of a form field.
|
|
5400
|
+
*
|
|
5401
|
+
* @param {string} formFieldId
|
|
5402
|
+
* @param {import('../core/FormFieldRegistry').default} formFieldRegistry
|
|
5403
|
+
*
|
|
5404
|
+
* @return {Array<string>} ancestry list
|
|
5405
5405
|
*/
|
|
5406
5406
|
const getAncestryList = (formFieldId, formFieldRegistry) => {
|
|
5407
5407
|
const ids = [];
|
|
@@ -5413,9 +5413,9 @@ const getAncestryList = (formFieldId, formFieldRegistry) => {
|
|
|
5413
5413
|
return ids;
|
|
5414
5414
|
};
|
|
5415
5415
|
|
|
5416
|
-
/**
|
|
5417
|
-
* @typedef {object} Condition
|
|
5418
|
-
* @property {string} [hide]
|
|
5416
|
+
/**
|
|
5417
|
+
* @typedef {object} Condition
|
|
5418
|
+
* @property {string} [hide]
|
|
5419
5419
|
*/
|
|
5420
5420
|
|
|
5421
5421
|
class ConditionChecker {
|
|
@@ -5425,14 +5425,14 @@ class ConditionChecker {
|
|
|
5425
5425
|
this._eventBus = eventBus;
|
|
5426
5426
|
}
|
|
5427
5427
|
|
|
5428
|
-
/**
|
|
5429
|
-
* For given data, remove properties based on condition.
|
|
5430
|
-
*
|
|
5431
|
-
* @param {Object<string, any>} data
|
|
5432
|
-
* @param {Object<string, any>} contextData
|
|
5433
|
-
* @param {Object} [options]
|
|
5434
|
-
* @param {Function} [options.getFilterPath]
|
|
5435
|
-
* @param {boolean} [options.leafNodeDeletionOnly]
|
|
5428
|
+
/**
|
|
5429
|
+
* For given data, remove properties based on condition.
|
|
5430
|
+
*
|
|
5431
|
+
* @param {Object<string, any>} data
|
|
5432
|
+
* @param {Object<string, any>} contextData
|
|
5433
|
+
* @param {Object} [options]
|
|
5434
|
+
* @param {Function} [options.getFilterPath]
|
|
5435
|
+
* @param {boolean} [options.leafNodeDeletionOnly]
|
|
5436
5436
|
*/
|
|
5437
5437
|
applyConditions(data, contextData = {}, options = {}) {
|
|
5438
5438
|
const workingData = clone(data);
|
|
@@ -5526,13 +5526,13 @@ class ConditionChecker {
|
|
|
5526
5526
|
return workingData;
|
|
5527
5527
|
}
|
|
5528
5528
|
|
|
5529
|
-
/**
|
|
5530
|
-
* Check if given condition is met. Returns null for invalid/missing conditions.
|
|
5531
|
-
*
|
|
5532
|
-
* @param {string} condition
|
|
5533
|
-
* @param {import('../../types').Data} [data]
|
|
5534
|
-
*
|
|
5535
|
-
* @returns {boolean|null}
|
|
5529
|
+
/**
|
|
5530
|
+
* Check if given condition is met. Returns null for invalid/missing conditions.
|
|
5531
|
+
*
|
|
5532
|
+
* @param {string} condition
|
|
5533
|
+
* @param {import('../../types').Data} [data]
|
|
5534
|
+
*
|
|
5535
|
+
* @returns {boolean|null}
|
|
5536
5536
|
*/
|
|
5537
5537
|
check(condition, data = {}) {
|
|
5538
5538
|
if (!condition) {
|
|
@@ -5553,12 +5553,12 @@ class ConditionChecker {
|
|
|
5553
5553
|
}
|
|
5554
5554
|
}
|
|
5555
5555
|
|
|
5556
|
-
/**
|
|
5557
|
-
* Check if hide condition is met.
|
|
5558
|
-
*
|
|
5559
|
-
* @param {Condition} condition
|
|
5560
|
-
* @param {Object<string, any>} data
|
|
5561
|
-
* @returns {boolean}
|
|
5556
|
+
/**
|
|
5557
|
+
* Check if hide condition is met.
|
|
5558
|
+
*
|
|
5559
|
+
* @param {Condition} condition
|
|
5560
|
+
* @param {Object<string, any>} data
|
|
5561
|
+
* @returns {boolean}
|
|
5562
5562
|
*/
|
|
5563
5563
|
_checkHideCondition(condition, data) {
|
|
5564
5564
|
if (!condition.hide) {
|
|
@@ -5600,12 +5600,12 @@ class MarkdownRenderer {
|
|
|
5600
5600
|
this._converter = new showdown.Converter();
|
|
5601
5601
|
}
|
|
5602
5602
|
|
|
5603
|
-
/**
|
|
5604
|
-
* Render markdown to HTML.
|
|
5605
|
-
*
|
|
5606
|
-
* @param {string} markdown - The markdown to render
|
|
5607
|
-
*
|
|
5608
|
-
* @returns {string} HTML
|
|
5603
|
+
/**
|
|
5604
|
+
* Render markdown to HTML.
|
|
5605
|
+
*
|
|
5606
|
+
* @param {string} markdown - The markdown to render
|
|
5607
|
+
*
|
|
5608
|
+
* @returns {string} HTML
|
|
5609
5609
|
*/
|
|
5610
5610
|
render(markdown) {
|
|
5611
5611
|
return this._converter.makeHtml(markdown);
|
|
@@ -6226,11 +6226,11 @@ class RepeatRenderManager {
|
|
|
6226
6226
|
this.RepeatFooter = this.RepeatFooter.bind(this);
|
|
6227
6227
|
}
|
|
6228
6228
|
|
|
6229
|
-
/**
|
|
6230
|
-
* Checks whether a field is currently repeating its children.
|
|
6231
|
-
*
|
|
6232
|
-
* @param {string} id - The id of the field to check
|
|
6233
|
-
* @returns {boolean} - True if repeatable, false otherwise
|
|
6229
|
+
/**
|
|
6230
|
+
* Checks whether a field is currently repeating its children.
|
|
6231
|
+
*
|
|
6232
|
+
* @param {string} id - The id of the field to check
|
|
6233
|
+
* @returns {boolean} - True if repeatable, false otherwise
|
|
6234
6234
|
*/
|
|
6235
6235
|
isFieldRepeating(id) {
|
|
6236
6236
|
if (!id) {
|
|
@@ -6990,8 +6990,8 @@ Validator.$inject = ['expressionLanguage', 'conditionChecker', 'form'];
|
|
|
6990
6990
|
|
|
6991
6991
|
// helpers //////////
|
|
6992
6992
|
|
|
6993
|
-
/**
|
|
6994
|
-
* Helper function to evaluate optional FEEL validation values.
|
|
6993
|
+
/**
|
|
6994
|
+
* Helper function to evaluate optional FEEL validation values.
|
|
6995
6995
|
*/
|
|
6996
6996
|
function evaluateFEELValues(validate, expressionLanguage, conditionChecker, form) {
|
|
6997
6997
|
const evaluatedValidate = {
|
|
@@ -7025,12 +7025,12 @@ function evaluateFEELValues(validate, expressionLanguage, conditionChecker, form
|
|
|
7025
7025
|
}
|
|
7026
7026
|
|
|
7027
7027
|
class Importer {
|
|
7028
|
-
/**
|
|
7029
|
-
* @constructor
|
|
7030
|
-
* @param { import('./FormFieldRegistry').default } formFieldRegistry
|
|
7031
|
-
* @param { import('./PathRegistry').default } pathRegistry
|
|
7032
|
-
* @param { import('./FieldFactory').default } fieldFactory
|
|
7033
|
-
* @param { import('./FormLayouter').default } formLayouter
|
|
7028
|
+
/**
|
|
7029
|
+
* @constructor
|
|
7030
|
+
* @param { import('./FormFieldRegistry').default } formFieldRegistry
|
|
7031
|
+
* @param { import('./PathRegistry').default } pathRegistry
|
|
7032
|
+
* @param { import('./FieldFactory').default } fieldFactory
|
|
7033
|
+
* @param { import('./FormLayouter').default } formLayouter
|
|
7034
7034
|
*/
|
|
7035
7035
|
constructor(formFieldRegistry, pathRegistry, fieldFactory, formLayouter) {
|
|
7036
7036
|
this._formFieldRegistry = formFieldRegistry;
|
|
@@ -7039,21 +7039,21 @@ class Importer {
|
|
|
7039
7039
|
this._formLayouter = formLayouter;
|
|
7040
7040
|
}
|
|
7041
7041
|
|
|
7042
|
-
/**
|
|
7043
|
-
* Import schema creating rows, fields, attaching additional
|
|
7044
|
-
* information to each field and adding fields to the
|
|
7045
|
-
* field registry.
|
|
7046
|
-
*
|
|
7047
|
-
* Additional information attached:
|
|
7048
|
-
*
|
|
7049
|
-
* * `id` (unless present)
|
|
7050
|
-
* * `_parent`
|
|
7051
|
-
* * `_path`
|
|
7052
|
-
*
|
|
7053
|
-
* @param {any} schema
|
|
7054
|
-
*
|
|
7055
|
-
* @typedef {{ warnings: Error[], schema: any }} ImportResult
|
|
7056
|
-
* @returns {ImportResult}
|
|
7042
|
+
/**
|
|
7043
|
+
* Import schema creating rows, fields, attaching additional
|
|
7044
|
+
* information to each field and adding fields to the
|
|
7045
|
+
* field registry.
|
|
7046
|
+
*
|
|
7047
|
+
* Additional information attached:
|
|
7048
|
+
*
|
|
7049
|
+
* * `id` (unless present)
|
|
7050
|
+
* * `_parent`
|
|
7051
|
+
* * `_path`
|
|
7052
|
+
*
|
|
7053
|
+
* @param {any} schema
|
|
7054
|
+
*
|
|
7055
|
+
* @typedef {{ warnings: Error[], schema: any }} ImportResult
|
|
7056
|
+
* @returns {ImportResult}
|
|
7057
7057
|
*/
|
|
7058
7058
|
importSchema(schema) {
|
|
7059
7059
|
// TODO: Add warnings
|
|
@@ -7078,12 +7078,12 @@ class Importer {
|
|
|
7078
7078
|
this._pathRegistry.clear();
|
|
7079
7079
|
}
|
|
7080
7080
|
|
|
7081
|
-
/**
|
|
7082
|
-
* @param {{[x: string]: any}} fieldAttrs
|
|
7083
|
-
* @param {String} [parentId]
|
|
7084
|
-
* @param {number} [index]
|
|
7085
|
-
*
|
|
7086
|
-
* @return {any} field
|
|
7081
|
+
/**
|
|
7082
|
+
* @param {{[x: string]: any}} fieldAttrs
|
|
7083
|
+
* @param {String} [parentId]
|
|
7084
|
+
* @param {number} [index]
|
|
7085
|
+
*
|
|
7086
|
+
* @return {any} field
|
|
7087
7087
|
*/
|
|
7088
7088
|
importFormField(fieldAttrs, parentId, index) {
|
|
7089
7089
|
const {
|
|
@@ -7108,11 +7108,11 @@ class Importer {
|
|
|
7108
7108
|
return field;
|
|
7109
7109
|
}
|
|
7110
7110
|
|
|
7111
|
-
/**
|
|
7112
|
-
* @param {Array<any>} components
|
|
7113
|
-
* @param {string} parentId
|
|
7114
|
-
*
|
|
7115
|
-
* @return {Array<any>} imported components
|
|
7111
|
+
/**
|
|
7112
|
+
* @param {Array<any>} components
|
|
7113
|
+
* @param {string} parentId
|
|
7114
|
+
*
|
|
7115
|
+
* @return {Array<any>} imported components
|
|
7116
7116
|
*/
|
|
7117
7117
|
importFormFields(components, parentId) {
|
|
7118
7118
|
return components.map((component, index) => {
|
|
@@ -7123,11 +7123,11 @@ class Importer {
|
|
|
7123
7123
|
Importer.$inject = ['formFieldRegistry', 'pathRegistry', 'fieldFactory', 'formLayouter'];
|
|
7124
7124
|
|
|
7125
7125
|
class FieldFactory {
|
|
7126
|
-
/**
|
|
7127
|
-
* @constructor
|
|
7128
|
-
*
|
|
7129
|
-
* @param formFieldRegistry
|
|
7130
|
-
* @param formFields
|
|
7126
|
+
/**
|
|
7127
|
+
* @constructor
|
|
7128
|
+
*
|
|
7129
|
+
* @param formFieldRegistry
|
|
7130
|
+
* @param formFields
|
|
7131
7131
|
*/
|
|
7132
7132
|
constructor(formFieldRegistry, pathRegistry, formFields) {
|
|
7133
7133
|
this._formFieldRegistry = formFieldRegistry;
|
|
@@ -7237,36 +7237,36 @@ class FieldFactory {
|
|
|
7237
7237
|
}
|
|
7238
7238
|
FieldFactory.$inject = ['formFieldRegistry', 'pathRegistry', 'formFields'];
|
|
7239
7239
|
|
|
7240
|
-
/**
|
|
7241
|
-
* The PathRegistry class manages a hierarchical structure of paths associated with form fields.
|
|
7242
|
-
* It enables claiming, unclaiming, and validating paths within this structure.
|
|
7243
|
-
*
|
|
7244
|
-
* Example Tree Structure:
|
|
7245
|
-
*
|
|
7246
|
-
* [
|
|
7247
|
-
* {
|
|
7248
|
-
* segment: 'root',
|
|
7249
|
-
* claimCount: 1,
|
|
7250
|
-
* children: [
|
|
7251
|
-
* {
|
|
7252
|
-
* segment: 'child1',
|
|
7253
|
-
* claimCount: 2,
|
|
7254
|
-
* children: null // A leaf node (closed path)
|
|
7255
|
-
* },
|
|
7256
|
-
* {
|
|
7257
|
-
* segment: 'child2',
|
|
7258
|
-
* claimCount: 1,
|
|
7259
|
-
* children: [
|
|
7260
|
-
* {
|
|
7261
|
-
* segment: 'subChild1',
|
|
7262
|
-
* claimCount: 1,
|
|
7263
|
-
* children: [] // An open node (open path)
|
|
7264
|
-
* }
|
|
7265
|
-
* ]
|
|
7266
|
-
* }
|
|
7267
|
-
* ]
|
|
7268
|
-
* }
|
|
7269
|
-
* ]
|
|
7240
|
+
/**
|
|
7241
|
+
* The PathRegistry class manages a hierarchical structure of paths associated with form fields.
|
|
7242
|
+
* It enables claiming, unclaiming, and validating paths within this structure.
|
|
7243
|
+
*
|
|
7244
|
+
* Example Tree Structure:
|
|
7245
|
+
*
|
|
7246
|
+
* [
|
|
7247
|
+
* {
|
|
7248
|
+
* segment: 'root',
|
|
7249
|
+
* claimCount: 1,
|
|
7250
|
+
* children: [
|
|
7251
|
+
* {
|
|
7252
|
+
* segment: 'child1',
|
|
7253
|
+
* claimCount: 2,
|
|
7254
|
+
* children: null // A leaf node (closed path)
|
|
7255
|
+
* },
|
|
7256
|
+
* {
|
|
7257
|
+
* segment: 'child2',
|
|
7258
|
+
* claimCount: 1,
|
|
7259
|
+
* children: [
|
|
7260
|
+
* {
|
|
7261
|
+
* segment: 'subChild1',
|
|
7262
|
+
* claimCount: 1,
|
|
7263
|
+
* children: [] // An open node (open path)
|
|
7264
|
+
* }
|
|
7265
|
+
* ]
|
|
7266
|
+
* }
|
|
7267
|
+
* ]
|
|
7268
|
+
* }
|
|
7269
|
+
* ]
|
|
7270
7270
|
*/
|
|
7271
7271
|
class PathRegistry {
|
|
7272
7272
|
constructor(formFieldRegistry, formFields, injector) {
|
|
@@ -7382,16 +7382,16 @@ class PathRegistry {
|
|
|
7382
7382
|
}
|
|
7383
7383
|
}
|
|
7384
7384
|
|
|
7385
|
-
/**
|
|
7386
|
-
* Applies a function (fn) recursively on a given field and its children.
|
|
7387
|
-
*
|
|
7388
|
-
* - `field`: Starting field object.
|
|
7389
|
-
* - `fn`: Function to apply.
|
|
7390
|
-
* - `context`: Optional object for passing data between calls.
|
|
7391
|
-
*
|
|
7392
|
-
* Stops early if `fn` returns `false`. Useful for traversing the form field tree.
|
|
7393
|
-
*
|
|
7394
|
-
* @returns {boolean} Success status based on function execution.
|
|
7385
|
+
/**
|
|
7386
|
+
* Applies a function (fn) recursively on a given field and its children.
|
|
7387
|
+
*
|
|
7388
|
+
* - `field`: Starting field object.
|
|
7389
|
+
* - `fn`: Function to apply.
|
|
7390
|
+
* - `context`: Optional object for passing data between calls.
|
|
7391
|
+
*
|
|
7392
|
+
* Stops early if `fn` returns `false`. Useful for traversing the form field tree.
|
|
7393
|
+
*
|
|
7394
|
+
* @returns {boolean} Success status based on function execution.
|
|
7395
7395
|
*/
|
|
7396
7396
|
executeRecursivelyOnFields(field, fn, context = {}) {
|
|
7397
7397
|
let result = true;
|
|
@@ -7432,16 +7432,16 @@ class PathRegistry {
|
|
|
7432
7432
|
return result;
|
|
7433
7433
|
}
|
|
7434
7434
|
|
|
7435
|
-
/**
|
|
7436
|
-
* Generates an array representing the binding path to an underlying data object for a form field.
|
|
7437
|
-
*
|
|
7438
|
-
* @param {Object} field - The field object with properties: `key`, `path`, `id`, and optionally `_parent`.
|
|
7439
|
-
* @param {Object} [options={}] - Configuration options.
|
|
7440
|
-
* @param {Object} [options.replacements={}] - A map of field IDs to alternative path arrays.
|
|
7441
|
-
* @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.
|
|
7442
|
-
* @param {Object} [options.cutoffNode] - The ID of the parent field at which to stop generating the path.
|
|
7443
|
-
*
|
|
7444
|
-
* @returns {(Array<string>|undefined)} An array of strings representing the binding path, or undefined if not determinable.
|
|
7435
|
+
/**
|
|
7436
|
+
* Generates an array representing the binding path to an underlying data object for a form field.
|
|
7437
|
+
*
|
|
7438
|
+
* @param {Object} field - The field object with properties: `key`, `path`, `id`, and optionally `_parent`.
|
|
7439
|
+
* @param {Object} [options={}] - Configuration options.
|
|
7440
|
+
* @param {Object} [options.replacements={}] - A map of field IDs to alternative path arrays.
|
|
7441
|
+
* @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.
|
|
7442
|
+
* @param {Object} [options.cutoffNode] - The ID of the parent field at which to stop generating the path.
|
|
7443
|
+
*
|
|
7444
|
+
* @returns {(Array<string>|undefined)} An array of strings representing the binding path, or undefined if not determinable.
|
|
7445
7445
|
*/
|
|
7446
7446
|
getValuePath(field, options = {}) {
|
|
7447
7447
|
const {
|
|
@@ -7502,23 +7502,23 @@ const _getNextSegment = (node, segment) => {
|
|
|
7502
7502
|
};
|
|
7503
7503
|
PathRegistry.$inject = ['formFieldRegistry', 'formFields', 'injector'];
|
|
7504
7504
|
|
|
7505
|
-
/**
|
|
7506
|
-
* @typedef { { id: String, components: Array<String> } } FormRow
|
|
7507
|
-
* @typedef { { formFieldId: String, rows: Array<FormRow> } } FormRows
|
|
7505
|
+
/**
|
|
7506
|
+
* @typedef { { id: String, components: Array<String> } } FormRow
|
|
7507
|
+
* @typedef { { formFieldId: String, rows: Array<FormRow> } } FormRows
|
|
7508
7508
|
*/
|
|
7509
7509
|
|
|
7510
|
-
/**
|
|
7511
|
-
* Maintains the Form layout in a given structure, for example
|
|
7512
|
-
*
|
|
7513
|
-
* [
|
|
7514
|
-
* {
|
|
7515
|
-
* formFieldId: 'FormField_1',
|
|
7516
|
-
* rows: [
|
|
7517
|
-
* { id: 'Row_1', components: [ 'Text_1', 'Textdield_1', ... ] }
|
|
7518
|
-
* ]
|
|
7519
|
-
* }
|
|
7520
|
-
* ]
|
|
7521
|
-
*
|
|
7510
|
+
/**
|
|
7511
|
+
* Maintains the Form layout in a given structure, for example
|
|
7512
|
+
*
|
|
7513
|
+
* [
|
|
7514
|
+
* {
|
|
7515
|
+
* formFieldId: 'FormField_1',
|
|
7516
|
+
* rows: [
|
|
7517
|
+
* { id: 'Row_1', components: [ 'Text_1', 'Textdield_1', ... ] }
|
|
7518
|
+
* ]
|
|
7519
|
+
* }
|
|
7520
|
+
* ]
|
|
7521
|
+
*
|
|
7522
7522
|
*/
|
|
7523
7523
|
class FormLayouter {
|
|
7524
7524
|
constructor(eventBus) {
|
|
@@ -7528,8 +7528,8 @@ class FormLayouter {
|
|
|
7528
7528
|
this._eventBus = eventBus;
|
|
7529
7529
|
}
|
|
7530
7530
|
|
|
7531
|
-
/**
|
|
7532
|
-
* @param {FormRow} row
|
|
7531
|
+
/**
|
|
7532
|
+
* @param {FormRow} row
|
|
7533
7533
|
*/
|
|
7534
7534
|
addRow(formFieldId, row) {
|
|
7535
7535
|
let rowsPerComponent = this._rows.find(r => r.formFieldId === formFieldId);
|
|
@@ -7543,18 +7543,18 @@ class FormLayouter {
|
|
|
7543
7543
|
rowsPerComponent.rows.push(row);
|
|
7544
7544
|
}
|
|
7545
7545
|
|
|
7546
|
-
/**
|
|
7547
|
-
* @param {String} id
|
|
7548
|
-
* @returns {FormRow}
|
|
7546
|
+
/**
|
|
7547
|
+
* @param {String} id
|
|
7548
|
+
* @returns {FormRow}
|
|
7549
7549
|
*/
|
|
7550
7550
|
getRow(id) {
|
|
7551
7551
|
const rows = allRows(this._rows);
|
|
7552
7552
|
return rows.find(r => r.id === id);
|
|
7553
7553
|
}
|
|
7554
7554
|
|
|
7555
|
-
/**
|
|
7556
|
-
* @param {any} formField
|
|
7557
|
-
* @returns {FormRow}
|
|
7555
|
+
/**
|
|
7556
|
+
* @param {any} formField
|
|
7557
|
+
* @returns {FormRow}
|
|
7558
7558
|
*/
|
|
7559
7559
|
getRowForField(formField) {
|
|
7560
7560
|
return allRows(this._rows).find(r => {
|
|
@@ -7565,9 +7565,9 @@ class FormLayouter {
|
|
|
7565
7565
|
});
|
|
7566
7566
|
}
|
|
7567
7567
|
|
|
7568
|
-
/**
|
|
7569
|
-
* @param {String} formFieldId
|
|
7570
|
-
* @returns { Array<FormRow> }
|
|
7568
|
+
/**
|
|
7569
|
+
* @param {String} formFieldId
|
|
7570
|
+
* @returns { Array<FormRow> }
|
|
7571
7571
|
*/
|
|
7572
7572
|
getRows(formFieldId) {
|
|
7573
7573
|
const rowsForField = this._rows.find(r => formFieldId === r.formFieldId);
|
|
@@ -7577,15 +7577,15 @@ class FormLayouter {
|
|
|
7577
7577
|
return rowsForField.rows;
|
|
7578
7578
|
}
|
|
7579
7579
|
|
|
7580
|
-
/**
|
|
7581
|
-
* @returns {string}
|
|
7580
|
+
/**
|
|
7581
|
+
* @returns {string}
|
|
7582
7582
|
*/
|
|
7583
7583
|
nextRowId() {
|
|
7584
7584
|
return this._ids.nextPrefixed('Row_');
|
|
7585
7585
|
}
|
|
7586
7586
|
|
|
7587
|
-
/**
|
|
7588
|
-
* @param {any} formField
|
|
7587
|
+
/**
|
|
7588
|
+
* @param {any} formField
|
|
7589
7589
|
*/
|
|
7590
7590
|
calculateLayout(formField) {
|
|
7591
7591
|
const {
|
|
@@ -7639,9 +7639,9 @@ function groupByRow(components, ids) {
|
|
|
7639
7639
|
});
|
|
7640
7640
|
}
|
|
7641
7641
|
|
|
7642
|
-
/**
|
|
7643
|
-
* @param {Array<FormRows>} formRows
|
|
7644
|
-
* @returns {Array<FormRow>}
|
|
7642
|
+
/**
|
|
7643
|
+
* @param {Array<FormRows>} formRows
|
|
7644
|
+
* @returns {Array<FormRow>}
|
|
7645
7645
|
*/
|
|
7646
7646
|
function allRows(formRows) {
|
|
7647
7647
|
return minDash.flatten(formRows.map(c => c.rows));
|
|
@@ -7766,55 +7766,55 @@ var core = {
|
|
|
7766
7766
|
validator: ['type', Validator]
|
|
7767
7767
|
};
|
|
7768
7768
|
|
|
7769
|
-
/**
|
|
7770
|
-
* @typedef { import('./types').Injector } Injector
|
|
7771
|
-
* @typedef { import('./types').Data } Data
|
|
7772
|
-
* @typedef { import('./types').Errors } Errors
|
|
7773
|
-
* @typedef { import('./types').Schema } Schema
|
|
7774
|
-
* @typedef { import('./types').FormProperties } FormProperties
|
|
7775
|
-
* @typedef { import('./types').FormProperty } FormProperty
|
|
7776
|
-
* @typedef { import('./types').FormEvent } FormEvent
|
|
7777
|
-
* @typedef { import('./types').FormOptions } FormOptions
|
|
7778
|
-
*
|
|
7779
|
-
* @typedef { {
|
|
7780
|
-
* data: Data,
|
|
7781
|
-
* initialData: Data,
|
|
7782
|
-
* errors: Errors,
|
|
7783
|
-
* properties: FormProperties,
|
|
7784
|
-
* schema: Schema
|
|
7785
|
-
* } } State
|
|
7786
|
-
*
|
|
7787
|
-
* @typedef { (type:FormEvent, priority:number, handler:Function) => void } OnEventWithPriority
|
|
7788
|
-
* @typedef { (type:FormEvent, handler:Function) => void } OnEventWithOutPriority
|
|
7789
|
-
* @typedef { OnEventWithPriority & OnEventWithOutPriority } OnEventType
|
|
7769
|
+
/**
|
|
7770
|
+
* @typedef { import('./types').Injector } Injector
|
|
7771
|
+
* @typedef { import('./types').Data } Data
|
|
7772
|
+
* @typedef { import('./types').Errors } Errors
|
|
7773
|
+
* @typedef { import('./types').Schema } Schema
|
|
7774
|
+
* @typedef { import('./types').FormProperties } FormProperties
|
|
7775
|
+
* @typedef { import('./types').FormProperty } FormProperty
|
|
7776
|
+
* @typedef { import('./types').FormEvent } FormEvent
|
|
7777
|
+
* @typedef { import('./types').FormOptions } FormOptions
|
|
7778
|
+
*
|
|
7779
|
+
* @typedef { {
|
|
7780
|
+
* data: Data,
|
|
7781
|
+
* initialData: Data,
|
|
7782
|
+
* errors: Errors,
|
|
7783
|
+
* properties: FormProperties,
|
|
7784
|
+
* schema: Schema
|
|
7785
|
+
* } } State
|
|
7786
|
+
*
|
|
7787
|
+
* @typedef { (type:FormEvent, priority:number, handler:Function) => void } OnEventWithPriority
|
|
7788
|
+
* @typedef { (type:FormEvent, handler:Function) => void } OnEventWithOutPriority
|
|
7789
|
+
* @typedef { OnEventWithPriority & OnEventWithOutPriority } OnEventType
|
|
7790
7790
|
*/
|
|
7791
7791
|
|
|
7792
7792
|
const ids = new Ids([32, 36, 1]);
|
|
7793
7793
|
|
|
7794
|
-
/**
|
|
7795
|
-
* The form.
|
|
7794
|
+
/**
|
|
7795
|
+
* The form.
|
|
7796
7796
|
*/
|
|
7797
7797
|
class Form {
|
|
7798
|
-
/**
|
|
7799
|
-
* @constructor
|
|
7800
|
-
* @param {FormOptions} options
|
|
7798
|
+
/**
|
|
7799
|
+
* @constructor
|
|
7800
|
+
* @param {FormOptions} options
|
|
7801
7801
|
*/
|
|
7802
7802
|
constructor(options = {}) {
|
|
7803
|
-
/**
|
|
7804
|
-
* @public
|
|
7805
|
-
* @type {OnEventType}
|
|
7803
|
+
/**
|
|
7804
|
+
* @public
|
|
7805
|
+
* @type {OnEventType}
|
|
7806
7806
|
*/
|
|
7807
7807
|
this.on = this._onEvent;
|
|
7808
7808
|
|
|
7809
|
-
/**
|
|
7810
|
-
* @public
|
|
7811
|
-
* @type {String}
|
|
7809
|
+
/**
|
|
7810
|
+
* @public
|
|
7811
|
+
* @type {String}
|
|
7812
7812
|
*/
|
|
7813
7813
|
this._id = ids.next();
|
|
7814
7814
|
|
|
7815
|
-
/**
|
|
7816
|
-
* @private
|
|
7817
|
-
* @type {Element}
|
|
7815
|
+
/**
|
|
7816
|
+
* @private
|
|
7817
|
+
* @type {Element}
|
|
7818
7818
|
*/
|
|
7819
7819
|
this._container = createFormContainer();
|
|
7820
7820
|
const {
|
|
@@ -7823,9 +7823,9 @@ class Form {
|
|
|
7823
7823
|
properties = {}
|
|
7824
7824
|
} = options;
|
|
7825
7825
|
|
|
7826
|
-
/**
|
|
7827
|
-
* @private
|
|
7828
|
-
* @type {State}
|
|
7826
|
+
/**
|
|
7827
|
+
* @private
|
|
7828
|
+
* @type {State}
|
|
7829
7829
|
*/
|
|
7830
7830
|
this._state = {
|
|
7831
7831
|
initialData: null,
|
|
@@ -7849,9 +7849,9 @@ class Form {
|
|
|
7849
7849
|
this._emit('form.clear');
|
|
7850
7850
|
}
|
|
7851
7851
|
|
|
7852
|
-
/**
|
|
7853
|
-
* Destroy the form, removing it from DOM,
|
|
7854
|
-
* if attached.
|
|
7852
|
+
/**
|
|
7853
|
+
* Destroy the form, removing it from DOM,
|
|
7854
|
+
* if attached.
|
|
7855
7855
|
*/
|
|
7856
7856
|
destroy() {
|
|
7857
7857
|
// destroy form services
|
|
@@ -7862,13 +7862,13 @@ class Form {
|
|
|
7862
7862
|
this._detach(false);
|
|
7863
7863
|
}
|
|
7864
7864
|
|
|
7865
|
-
/**
|
|
7866
|
-
* Open a form schema with the given initial data.
|
|
7867
|
-
*
|
|
7868
|
-
* @param {Schema} schema
|
|
7869
|
-
* @param {Data} [data]
|
|
7870
|
-
*
|
|
7871
|
-
* @return Promise<{ warnings: Array<any> }>
|
|
7865
|
+
/**
|
|
7866
|
+
* Open a form schema with the given initial data.
|
|
7867
|
+
*
|
|
7868
|
+
* @param {Schema} schema
|
|
7869
|
+
* @param {Data} [data]
|
|
7870
|
+
*
|
|
7871
|
+
* @return Promise<{ warnings: Array<any> }>
|
|
7872
7872
|
*/
|
|
7873
7873
|
importSchema(schema, data = {}) {
|
|
7874
7874
|
return new Promise((resolve, reject) => {
|
|
@@ -7901,10 +7901,10 @@ class Form {
|
|
|
7901
7901
|
});
|
|
7902
7902
|
}
|
|
7903
7903
|
|
|
7904
|
-
/**
|
|
7905
|
-
* Submit the form, triggering all field validations.
|
|
7906
|
-
*
|
|
7907
|
-
* @returns { { data: Data, errors: Errors } }
|
|
7904
|
+
/**
|
|
7905
|
+
* Submit the form, triggering all field validations.
|
|
7906
|
+
*
|
|
7907
|
+
* @returns { { data: Data, errors: Errors } }
|
|
7908
7908
|
*/
|
|
7909
7909
|
submit() {
|
|
7910
7910
|
const {
|
|
@@ -7930,8 +7930,8 @@ class Form {
|
|
|
7930
7930
|
});
|
|
7931
7931
|
}
|
|
7932
7932
|
|
|
7933
|
-
/**
|
|
7934
|
-
* @returns {Errors}
|
|
7933
|
+
/**
|
|
7934
|
+
* @returns {Errors}
|
|
7935
7935
|
*/
|
|
7936
7936
|
validate() {
|
|
7937
7937
|
const formFields = this.get('formFields'),
|
|
@@ -8003,8 +8003,8 @@ class Form {
|
|
|
8003
8003
|
return filteredErrors;
|
|
8004
8004
|
}
|
|
8005
8005
|
|
|
8006
|
-
/**
|
|
8007
|
-
* @param {Element|string} parentNode
|
|
8006
|
+
/**
|
|
8007
|
+
* @param {Element|string} parentNode
|
|
8008
8008
|
*/
|
|
8009
8009
|
attachTo(parentNode) {
|
|
8010
8010
|
if (!parentNode) {
|
|
@@ -8022,10 +8022,10 @@ class Form {
|
|
|
8022
8022
|
this._detach();
|
|
8023
8023
|
}
|
|
8024
8024
|
|
|
8025
|
-
/**
|
|
8026
|
-
* @private
|
|
8027
|
-
*
|
|
8028
|
-
* @param {boolean} [emit]
|
|
8025
|
+
/**
|
|
8026
|
+
* @private
|
|
8027
|
+
*
|
|
8028
|
+
* @param {boolean} [emit]
|
|
8029
8029
|
*/
|
|
8030
8030
|
_detach(emit = true) {
|
|
8031
8031
|
const container = this._container,
|
|
@@ -8039,9 +8039,9 @@ class Form {
|
|
|
8039
8039
|
parentNode.removeChild(container);
|
|
8040
8040
|
}
|
|
8041
8041
|
|
|
8042
|
-
/**
|
|
8043
|
-
* @param {FormProperty} property
|
|
8044
|
-
* @param {any} value
|
|
8042
|
+
/**
|
|
8043
|
+
* @param {FormProperty} property
|
|
8044
|
+
* @param {any} value
|
|
8045
8045
|
*/
|
|
8046
8046
|
setProperty(property, value) {
|
|
8047
8047
|
const properties = minDash.set(this._getState().properties, [property], value);
|
|
@@ -8050,21 +8050,21 @@ class Form {
|
|
|
8050
8050
|
});
|
|
8051
8051
|
}
|
|
8052
8052
|
|
|
8053
|
-
/**
|
|
8054
|
-
* @param {FormEvent} type
|
|
8055
|
-
* @param {Function} handler
|
|
8053
|
+
/**
|
|
8054
|
+
* @param {FormEvent} type
|
|
8055
|
+
* @param {Function} handler
|
|
8056
8056
|
*/
|
|
8057
8057
|
off(type, handler) {
|
|
8058
8058
|
this.get('eventBus').off(type, handler);
|
|
8059
8059
|
}
|
|
8060
8060
|
|
|
8061
|
-
/**
|
|
8062
|
-
* @private
|
|
8063
|
-
*
|
|
8064
|
-
* @param {FormOptions} options
|
|
8065
|
-
* @param {Element} container
|
|
8066
|
-
*
|
|
8067
|
-
* @returns {Injector}
|
|
8061
|
+
/**
|
|
8062
|
+
* @private
|
|
8063
|
+
*
|
|
8064
|
+
* @param {FormOptions} options
|
|
8065
|
+
* @param {Element} container
|
|
8066
|
+
*
|
|
8067
|
+
* @returns {Injector}
|
|
8068
8068
|
*/
|
|
8069
8069
|
_createInjector(options, container) {
|
|
8070
8070
|
const {
|
|
@@ -8085,17 +8085,17 @@ class Form {
|
|
|
8085
8085
|
}, core, ...modules, ...additionalModules]);
|
|
8086
8086
|
}
|
|
8087
8087
|
|
|
8088
|
-
/**
|
|
8089
|
-
* @private
|
|
8088
|
+
/**
|
|
8089
|
+
* @private
|
|
8090
8090
|
*/
|
|
8091
8091
|
_emit(type, data) {
|
|
8092
8092
|
this.get('eventBus').fire(type, data);
|
|
8093
8093
|
}
|
|
8094
8094
|
|
|
8095
|
-
/**
|
|
8096
|
-
* @internal
|
|
8097
|
-
*
|
|
8098
|
-
* @param { { add?: boolean, field: any, indexes: object, remove?: number, value?: any } } update
|
|
8095
|
+
/**
|
|
8096
|
+
* @internal
|
|
8097
|
+
*
|
|
8098
|
+
* @param { { add?: boolean, field: any, indexes: object, remove?: number, value?: any } } update
|
|
8099
8099
|
*/
|
|
8100
8100
|
_update(update) {
|
|
8101
8101
|
const {
|
|
@@ -8121,15 +8121,15 @@ class Form {
|
|
|
8121
8121
|
});
|
|
8122
8122
|
}
|
|
8123
8123
|
|
|
8124
|
-
/**
|
|
8125
|
-
* @internal
|
|
8124
|
+
/**
|
|
8125
|
+
* @internal
|
|
8126
8126
|
*/
|
|
8127
8127
|
_getState() {
|
|
8128
8128
|
return this._state;
|
|
8129
8129
|
}
|
|
8130
8130
|
|
|
8131
|
-
/**
|
|
8132
|
-
* @internal
|
|
8131
|
+
/**
|
|
8132
|
+
* @internal
|
|
8133
8133
|
*/
|
|
8134
8134
|
_setState(state) {
|
|
8135
8135
|
this._state = {
|
|
@@ -8139,22 +8139,22 @@ class Form {
|
|
|
8139
8139
|
this._emit('changed', this._getState());
|
|
8140
8140
|
}
|
|
8141
8141
|
|
|
8142
|
-
/**
|
|
8143
|
-
* @internal
|
|
8142
|
+
/**
|
|
8143
|
+
* @internal
|
|
8144
8144
|
*/
|
|
8145
8145
|
_getModules() {
|
|
8146
8146
|
return [ExpressionLanguageModule, MarkdownModule, ViewerCommandsModule, RepeatRenderModule];
|
|
8147
8147
|
}
|
|
8148
8148
|
|
|
8149
|
-
/**
|
|
8150
|
-
* @internal
|
|
8149
|
+
/**
|
|
8150
|
+
* @internal
|
|
8151
8151
|
*/
|
|
8152
8152
|
_onEvent(type, priority, handler) {
|
|
8153
8153
|
this.get('eventBus').on(type, priority, handler);
|
|
8154
8154
|
}
|
|
8155
8155
|
|
|
8156
|
-
/**
|
|
8157
|
-
* @internal
|
|
8156
|
+
/**
|
|
8157
|
+
* @internal
|
|
8158
8158
|
*/
|
|
8159
8159
|
_getSubmitData() {
|
|
8160
8160
|
const formFieldRegistry = this.get('formFieldRegistry');
|
|
@@ -8211,16 +8211,16 @@ class Form {
|
|
|
8211
8211
|
return this._applyConditions(workingSubmitData, formData);
|
|
8212
8212
|
}
|
|
8213
8213
|
|
|
8214
|
-
/**
|
|
8215
|
-
* @internal
|
|
8214
|
+
/**
|
|
8215
|
+
* @internal
|
|
8216
8216
|
*/
|
|
8217
8217
|
_applyConditions(toFilter, data, options = {}) {
|
|
8218
8218
|
const conditionChecker = this.get('conditionChecker');
|
|
8219
8219
|
return conditionChecker.applyConditions(toFilter, data, options);
|
|
8220
8220
|
}
|
|
8221
8221
|
|
|
8222
|
-
/**
|
|
8223
|
-
* @internal
|
|
8222
|
+
/**
|
|
8223
|
+
* @internal
|
|
8224
8224
|
*/
|
|
8225
8225
|
_getInitializedFieldData(data, options = {}) {
|
|
8226
8226
|
const formFieldRegistry = this.get('formFieldRegistry');
|