@bpmn-io/form-js-viewer 1.3.0 → 1.3.2
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 +164 -164
- package/dist/assets/form-js-base.css +987 -985
- package/dist/assets/form-js.css +14 -11
- package/dist/index.cjs +481 -475
- package/dist/index.cjs.map +1 -1
- package/dist/index.es.js +481 -475
- package/dist/index.es.js.map +1 -1
- package/dist/types/Form.d.ts +1 -1
- package/dist/types/features/expression-language/ConditionChecker.d.ts +4 -0
- package/dist/types/types.d.ts +35 -35
- package/package.json +4 -4
package/dist/index.cjs
CHANGED
|
@@ -67,26 +67,26 @@ const getFlavouredFeelVariableNames = (feelString, feelFlavour = 'expression', o
|
|
|
67
67
|
return [...new Set(variables)];
|
|
68
68
|
};
|
|
69
69
|
|
|
70
|
-
/**
|
|
71
|
-
* Get the variable name at the specified index in a given path expression.
|
|
72
|
-
*
|
|
73
|
-
* @param {Object} root - The root node of the path expression tree.
|
|
74
|
-
* @param {number} index - The index of the variable name to retrieve.
|
|
75
|
-
* @returns {string|null} The variable name at the specified index or null if index is out of bounds.
|
|
70
|
+
/**
|
|
71
|
+
* Get the variable name at the specified index in a given path expression.
|
|
72
|
+
*
|
|
73
|
+
* @param {Object} root - The root node of the path expression tree.
|
|
74
|
+
* @param {number} index - The index of the variable name to retrieve.
|
|
75
|
+
* @returns {string|null} The variable name at the specified index or null if index is out of bounds.
|
|
76
76
|
*/
|
|
77
77
|
const _getVariableNameAtPathIndex = (root, index) => {
|
|
78
78
|
const accessors = _deconstructPathExpression(root);
|
|
79
79
|
return accessors[index] || null;
|
|
80
80
|
};
|
|
81
81
|
|
|
82
|
-
/**
|
|
83
|
-
* Extracts the variables which are required of the external context for a given path expression.
|
|
84
|
-
* This is done by traversing the path expression tree and keeping track of the current depth relative to the external context.
|
|
85
|
-
*
|
|
86
|
-
* @param {Object} node - The root node of the path expression tree.
|
|
87
|
-
* @param {number} initialDepth - The depth at which the root node is located in the outer context.
|
|
88
|
-
* @param {Object} specialDepthAccessors - Definitions of special keywords which represent more complex accesses of the outer context.
|
|
89
|
-
* @returns {Set} - A set containing the extracted variable names.
|
|
82
|
+
/**
|
|
83
|
+
* Extracts the variables which are required of the external context for a given path expression.
|
|
84
|
+
* This is done by traversing the path expression tree and keeping track of the current depth relative to the external context.
|
|
85
|
+
*
|
|
86
|
+
* @param {Object} node - The root node of the path expression tree.
|
|
87
|
+
* @param {number} initialDepth - The depth at which the root node is located in the outer context.
|
|
88
|
+
* @param {Object} specialDepthAccessors - Definitions of special keywords which represent more complex accesses of the outer context.
|
|
89
|
+
* @returns {Set} - A set containing the extracted variable names.
|
|
90
90
|
*/
|
|
91
91
|
const _smartExtractVariableNames = (node, initialDepth, specialDepthAccessors) => {
|
|
92
92
|
// depth info represents the previous (initialised as null) and current depth of the current accessor in the path expression
|
|
@@ -132,11 +132,11 @@ const _smartExtractVariableNames = (node, initialDepth, specialDepthAccessors) =
|
|
|
132
132
|
return new Set(extractedVariables);
|
|
133
133
|
};
|
|
134
134
|
|
|
135
|
-
/**
|
|
136
|
-
* Deconstructs a path expression tree into an array of components.
|
|
137
|
-
*
|
|
138
|
-
* @param {Object} root - The root node of the path expression tree.
|
|
139
|
-
* @returns {Array<string>} An array of components in the path expression, in the correct order.
|
|
135
|
+
/**
|
|
136
|
+
* Deconstructs a path expression tree into an array of components.
|
|
137
|
+
*
|
|
138
|
+
* @param {Object} root - The root node of the path expression tree.
|
|
139
|
+
* @returns {Array<string>} An array of components in the path expression, in the correct order.
|
|
140
140
|
*/
|
|
141
141
|
const _deconstructPathExpression = root => {
|
|
142
142
|
let node = root;
|
|
@@ -155,13 +155,13 @@ const _deconstructPathExpression = root => {
|
|
|
155
155
|
return parts.reverse();
|
|
156
156
|
};
|
|
157
157
|
|
|
158
|
-
/**
|
|
159
|
-
* Builds a simplified feel structure tree from the given parse tree and feel string.
|
|
160
|
-
* The nodes follow this structure: `{ name: string, children: Array, variableName?: string }`
|
|
161
|
-
*
|
|
162
|
-
* @param {Object} parseTree - The parse tree generated by a parser.
|
|
163
|
-
* @param {string} feelString - The feel string used for parsing.
|
|
164
|
-
* @returns {Object} The simplified feel structure tree.
|
|
158
|
+
/**
|
|
159
|
+
* Builds a simplified feel structure tree from the given parse tree and feel string.
|
|
160
|
+
* The nodes follow this structure: `{ name: string, children: Array, variableName?: string }`
|
|
161
|
+
*
|
|
162
|
+
* @param {Object} parseTree - The parse tree generated by a parser.
|
|
163
|
+
* @param {string} feelString - The feel string used for parsing.
|
|
164
|
+
* @returns {Object} The simplified feel structure tree.
|
|
165
165
|
*/
|
|
166
166
|
const _buildSimpleFeelStructureTree = (parseTree, feelString) => {
|
|
167
167
|
const stack = [{
|
|
@@ -187,9 +187,9 @@ const _buildSimpleFeelStructureTree = (parseTree, feelString) => {
|
|
|
187
187
|
return _extractFilterExpressions(stack[0].children[0]);
|
|
188
188
|
};
|
|
189
189
|
|
|
190
|
-
/**
|
|
191
|
-
* Restructure the tree in such a way to bring filters (which create new contexts) to the root of the tree.
|
|
192
|
-
* This is done to simplify the extraction of variables and match the context hierarchy.
|
|
190
|
+
/**
|
|
191
|
+
* Restructure the tree in such a way to bring filters (which create new contexts) to the root of the tree.
|
|
192
|
+
* This is done to simplify the extraction of variables and match the context hierarchy.
|
|
193
193
|
*/
|
|
194
194
|
const _extractFilterExpressions = tree => {
|
|
195
195
|
const flattenedExpressionTree = {
|
|
@@ -230,25 +230,25 @@ class FeelExpressionLanguage {
|
|
|
230
230
|
this._eventBus = eventBus;
|
|
231
231
|
}
|
|
232
232
|
|
|
233
|
-
/**
|
|
234
|
-
* Determines if the given value is a FEEL expression.
|
|
235
|
-
*
|
|
236
|
-
* @param {any} value
|
|
237
|
-
* @returns {boolean}
|
|
238
|
-
*
|
|
233
|
+
/**
|
|
234
|
+
* Determines if the given value is a FEEL expression.
|
|
235
|
+
*
|
|
236
|
+
* @param {any} value
|
|
237
|
+
* @returns {boolean}
|
|
238
|
+
*
|
|
239
239
|
*/
|
|
240
240
|
isExpression(value) {
|
|
241
241
|
return minDash.isString(value) && value.startsWith('=');
|
|
242
242
|
}
|
|
243
243
|
|
|
244
|
-
/**
|
|
245
|
-
* Retrieve variable names from a given FEEL expression.
|
|
246
|
-
*
|
|
247
|
-
* @param {string} expression
|
|
248
|
-
* @param {object} [options]
|
|
249
|
-
* @param {string} [options.type]
|
|
250
|
-
*
|
|
251
|
-
* @returns {string[]}
|
|
244
|
+
/**
|
|
245
|
+
* Retrieve variable names from a given FEEL expression.
|
|
246
|
+
*
|
|
247
|
+
* @param {string} expression
|
|
248
|
+
* @param {object} [options]
|
|
249
|
+
* @param {string} [options.type]
|
|
250
|
+
*
|
|
251
|
+
* @returns {string[]}
|
|
252
252
|
*/
|
|
253
253
|
getVariableNames(expression, options = {}) {
|
|
254
254
|
const {
|
|
@@ -263,13 +263,13 @@ class FeelExpressionLanguage {
|
|
|
263
263
|
return getFlavouredFeelVariableNames(expression, type);
|
|
264
264
|
}
|
|
265
265
|
|
|
266
|
-
/**
|
|
267
|
-
* Evaluate an expression.
|
|
268
|
-
*
|
|
269
|
-
* @param {string} expression
|
|
270
|
-
* @param {import('../../types').Data} [data]
|
|
271
|
-
*
|
|
272
|
-
* @returns {any}
|
|
266
|
+
/**
|
|
267
|
+
* Evaluate an expression.
|
|
268
|
+
*
|
|
269
|
+
* @param {string} expression
|
|
270
|
+
* @param {import('../../types').Data} [data]
|
|
271
|
+
*
|
|
272
|
+
* @returns {any}
|
|
273
273
|
*/
|
|
274
274
|
evaluate(expression, data = {}) {
|
|
275
275
|
if (!expression) {
|
|
@@ -294,23 +294,23 @@ FeelExpressionLanguage.$inject = ['eventBus'];
|
|
|
294
294
|
class FeelersTemplating {
|
|
295
295
|
constructor() {}
|
|
296
296
|
|
|
297
|
-
/**
|
|
298
|
-
* Determines if the given value is a feelers template.
|
|
299
|
-
*
|
|
300
|
-
* @param {any} value
|
|
301
|
-
* @returns {boolean}
|
|
302
|
-
*
|
|
297
|
+
/**
|
|
298
|
+
* Determines if the given value is a feelers template.
|
|
299
|
+
*
|
|
300
|
+
* @param {any} value
|
|
301
|
+
* @returns {boolean}
|
|
302
|
+
*
|
|
303
303
|
*/
|
|
304
304
|
isTemplate(value) {
|
|
305
305
|
return minDash.isString(value) && (value.startsWith('=') || /{{.*?}}/.test(value));
|
|
306
306
|
}
|
|
307
307
|
|
|
308
|
-
/**
|
|
309
|
-
* Retrieve variable names from a given feelers template.
|
|
310
|
-
*
|
|
311
|
-
* @param {string} template
|
|
312
|
-
*
|
|
313
|
-
* @returns {string[]}
|
|
308
|
+
/**
|
|
309
|
+
* Retrieve variable names from a given feelers template.
|
|
310
|
+
*
|
|
311
|
+
* @param {string} template
|
|
312
|
+
*
|
|
313
|
+
* @returns {string[]}
|
|
314
314
|
*/
|
|
315
315
|
getVariableNames(template) {
|
|
316
316
|
if (!this.isTemplate(template)) {
|
|
@@ -336,17 +336,17 @@ class FeelersTemplating {
|
|
|
336
336
|
}, []);
|
|
337
337
|
}
|
|
338
338
|
|
|
339
|
-
/**
|
|
340
|
-
* Evaluate a template.
|
|
341
|
-
*
|
|
342
|
-
* @param {string} template
|
|
343
|
-
* @param {Object<string, any>} context
|
|
344
|
-
* @param {Object} options
|
|
345
|
-
* @param {boolean} [options.debug = false]
|
|
346
|
-
* @param {boolean} [options.strict = false]
|
|
347
|
-
* @param {Function} [options.buildDebugString]
|
|
348
|
-
*
|
|
349
|
-
* @returns
|
|
339
|
+
/**
|
|
340
|
+
* Evaluate a template.
|
|
341
|
+
*
|
|
342
|
+
* @param {string} template
|
|
343
|
+
* @param {Object<string, any>} context
|
|
344
|
+
* @param {Object} options
|
|
345
|
+
* @param {boolean} [options.debug = false]
|
|
346
|
+
* @param {boolean} [options.strict = false]
|
|
347
|
+
* @param {Function} [options.buildDebugString]
|
|
348
|
+
*
|
|
349
|
+
* @returns
|
|
350
350
|
*/
|
|
351
351
|
evaluate(template, context = {}, options = {}) {
|
|
352
352
|
const {
|
|
@@ -361,22 +361,22 @@ class FeelersTemplating {
|
|
|
361
361
|
});
|
|
362
362
|
}
|
|
363
363
|
|
|
364
|
-
/**
|
|
365
|
-
* @typedef {Object} ExpressionWithDepth
|
|
366
|
-
* @property {number} depth - The depth of the expression in the syntax tree.
|
|
367
|
-
* @property {string} expression - The extracted expression
|
|
364
|
+
/**
|
|
365
|
+
* @typedef {Object} ExpressionWithDepth
|
|
366
|
+
* @property {number} depth - The depth of the expression in the syntax tree.
|
|
367
|
+
* @property {string} expression - The extracted expression
|
|
368
368
|
*/
|
|
369
369
|
|
|
370
|
-
/**
|
|
371
|
-
* Extracts all feel expressions in the template along with their depth in the syntax tree.
|
|
372
|
-
* The depth is incremented for child expressions of loops to account for context drilling.
|
|
373
|
-
|
|
374
|
-
* @param {string} template - A feelers template string.
|
|
375
|
-
* @returns {Array<ExpressionWithDepth>} An array of objects, each containing the depth and the extracted expression.
|
|
376
|
-
*
|
|
377
|
-
* @example
|
|
378
|
-
* const template = "Hello {{user}}, you have:{{#loop items}}\n- {{amount}} {{name}}{{/loop}}.";
|
|
379
|
-
* const extractedExpressions = _extractExpressionsWithDepth(template);
|
|
370
|
+
/**
|
|
371
|
+
* Extracts all feel expressions in the template along with their depth in the syntax tree.
|
|
372
|
+
* The depth is incremented for child expressions of loops to account for context drilling.
|
|
373
|
+
* @name extractExpressionsWithDepth
|
|
374
|
+
* @param {string} template - A feelers template string.
|
|
375
|
+
* @returns {Array<ExpressionWithDepth>} An array of objects, each containing the depth and the extracted expression.
|
|
376
|
+
*
|
|
377
|
+
* @example
|
|
378
|
+
* const template = "Hello {{user}}, you have:{{#loop items}}\n- {{amount}} {{name}}{{/loop}}.";
|
|
379
|
+
* const extractedExpressions = _extractExpressionsWithDepth(template);
|
|
380
380
|
*/
|
|
381
381
|
_extractExpressionsWithDepth(template) {
|
|
382
382
|
// build simplified feelers syntax tree
|
|
@@ -482,10 +482,10 @@ function createInjector(bootstrapModules) {
|
|
|
482
482
|
return injector;
|
|
483
483
|
}
|
|
484
484
|
|
|
485
|
-
/**
|
|
486
|
-
* @param {string?} prefix
|
|
487
|
-
*
|
|
488
|
-
* @returns Element
|
|
485
|
+
/**
|
|
486
|
+
* @param {string?} prefix
|
|
487
|
+
*
|
|
488
|
+
* @returns Element
|
|
489
489
|
*/
|
|
490
490
|
function createFormContainer(prefix = 'fjs') {
|
|
491
491
|
const container = document.createElement('div');
|
|
@@ -522,22 +522,22 @@ function generateIdForType(type) {
|
|
|
522
522
|
return `${type}${generateIndexForType(type)}`;
|
|
523
523
|
}
|
|
524
524
|
|
|
525
|
-
/**
|
|
526
|
-
* @template T
|
|
527
|
-
* @param {T} data
|
|
528
|
-
* @param {(this: any, key: string, value: any) => any} [replacer]
|
|
529
|
-
* @return {T}
|
|
525
|
+
/**
|
|
526
|
+
* @template T
|
|
527
|
+
* @param {T} data
|
|
528
|
+
* @param {(this: any, key: string, value: any) => any} [replacer]
|
|
529
|
+
* @return {T}
|
|
530
530
|
*/
|
|
531
531
|
function clone(data, replacer) {
|
|
532
532
|
return JSON.parse(JSON.stringify(data, replacer));
|
|
533
533
|
}
|
|
534
534
|
|
|
535
|
-
/**
|
|
536
|
-
* Parse the schema for input variables a form might make use of
|
|
537
|
-
*
|
|
538
|
-
* @param {any} schema
|
|
539
|
-
*
|
|
540
|
-
* @return {string[]}
|
|
535
|
+
/**
|
|
536
|
+
* Parse the schema for input variables a form might make use of
|
|
537
|
+
*
|
|
538
|
+
* @param {any} schema
|
|
539
|
+
*
|
|
540
|
+
* @return {string[]}
|
|
541
541
|
*/
|
|
542
542
|
function getSchemaVariables(schema, options = {}) {
|
|
543
543
|
const {
|
|
@@ -622,9 +622,9 @@ function runRecursively(formField, fn) {
|
|
|
622
622
|
fn(formField);
|
|
623
623
|
}
|
|
624
624
|
|
|
625
|
-
/**
|
|
626
|
-
* @typedef {object} Condition
|
|
627
|
-
* @property {string} [hide]
|
|
625
|
+
/**
|
|
626
|
+
* @typedef {object} Condition
|
|
627
|
+
* @property {string} [hide]
|
|
628
628
|
*/
|
|
629
629
|
|
|
630
630
|
class ConditionChecker {
|
|
@@ -634,14 +634,19 @@ class ConditionChecker {
|
|
|
634
634
|
this._eventBus = eventBus;
|
|
635
635
|
}
|
|
636
636
|
|
|
637
|
-
/**
|
|
638
|
-
* For given data, remove properties based on condition.
|
|
639
|
-
*
|
|
640
|
-
* @param {Object<string, any>} properties
|
|
641
|
-
* @param {Object<string, any>} data
|
|
637
|
+
/**
|
|
638
|
+
* For given data, remove properties based on condition.
|
|
639
|
+
*
|
|
640
|
+
* @param {Object<string, any>} properties
|
|
641
|
+
* @param {Object<string, any>} data
|
|
642
|
+
* @param {Object} [options]
|
|
643
|
+
* @param {Function} [options.getFilterPath]
|
|
642
644
|
*/
|
|
643
|
-
applyConditions(properties, data = {}) {
|
|
645
|
+
applyConditions(properties, data = {}, options = {}) {
|
|
644
646
|
const newProperties = clone(properties);
|
|
647
|
+
const {
|
|
648
|
+
getFilterPath = field => this._pathRegistry.getValuePath(field)
|
|
649
|
+
} = options;
|
|
645
650
|
const form = this._formFieldRegistry.getAll().find(field => field.type === 'default');
|
|
646
651
|
if (!form) {
|
|
647
652
|
throw new Error('form field registry has no form');
|
|
@@ -658,20 +663,19 @@ class ConditionChecker {
|
|
|
658
663
|
|
|
659
664
|
// only clear the leaf nodes, as groups may both point to the same path
|
|
660
665
|
if (context.isHidden && isClosed) {
|
|
661
|
-
|
|
662
|
-
this._clearObjectValueRecursively(valuePath, newProperties);
|
|
666
|
+
this._clearObjectValueRecursively(getFilterPath(field), newProperties);
|
|
663
667
|
}
|
|
664
668
|
});
|
|
665
669
|
return newProperties;
|
|
666
670
|
}
|
|
667
671
|
|
|
668
|
-
/**
|
|
669
|
-
* Check if given condition is met. Returns null for invalid/missing conditions.
|
|
670
|
-
*
|
|
671
|
-
* @param {string} condition
|
|
672
|
-
* @param {import('../../types').Data} [data]
|
|
673
|
-
*
|
|
674
|
-
* @returns {boolean|null}
|
|
672
|
+
/**
|
|
673
|
+
* Check if given condition is met. Returns null for invalid/missing conditions.
|
|
674
|
+
*
|
|
675
|
+
* @param {string} condition
|
|
676
|
+
* @param {import('../../types').Data} [data]
|
|
677
|
+
*
|
|
678
|
+
* @returns {boolean|null}
|
|
675
679
|
*/
|
|
676
680
|
check(condition, data = {}) {
|
|
677
681
|
if (!condition) {
|
|
@@ -692,12 +696,12 @@ class ConditionChecker {
|
|
|
692
696
|
}
|
|
693
697
|
}
|
|
694
698
|
|
|
695
|
-
/**
|
|
696
|
-
* Check if hide condition is met.
|
|
697
|
-
*
|
|
698
|
-
* @param {Condition} condition
|
|
699
|
-
* @param {Object<string, any>} data
|
|
700
|
-
* @returns {boolean}
|
|
699
|
+
/**
|
|
700
|
+
* Check if hide condition is met.
|
|
701
|
+
*
|
|
702
|
+
* @param {Condition} condition
|
|
703
|
+
* @param {Object<string, any>} data
|
|
704
|
+
* @returns {boolean}
|
|
701
705
|
*/
|
|
702
706
|
_checkHideCondition(condition, data) {
|
|
703
707
|
if (!condition.hide) {
|
|
@@ -733,12 +737,12 @@ class MarkdownRenderer {
|
|
|
733
737
|
this._converter = new showdown.Converter();
|
|
734
738
|
}
|
|
735
739
|
|
|
736
|
-
/**
|
|
737
|
-
* Render markdown to HTML.
|
|
738
|
-
*
|
|
739
|
-
* @param {string} markdown - The markdown to render
|
|
740
|
-
*
|
|
741
|
-
* @returns {string} HTML
|
|
740
|
+
/**
|
|
741
|
+
* Render markdown to HTML.
|
|
742
|
+
*
|
|
743
|
+
* @param {string} markdown - The markdown to render
|
|
744
|
+
*
|
|
745
|
+
* @returns {string} HTML
|
|
742
746
|
*/
|
|
743
747
|
render(markdown) {
|
|
744
748
|
return this._converter.makeHtml(markdown);
|
|
@@ -1886,8 +1890,8 @@ Validator.$inject = ['expressionLanguage', 'conditionChecker', 'form'];
|
|
|
1886
1890
|
|
|
1887
1891
|
// helpers //////////
|
|
1888
1892
|
|
|
1889
|
-
/**
|
|
1890
|
-
* Helper function to evaluate optional FEEL validation values.
|
|
1893
|
+
/**
|
|
1894
|
+
* Helper function to evaluate optional FEEL validation values.
|
|
1891
1895
|
*/
|
|
1892
1896
|
function evaluateFEELValues(validate, expressionLanguage, conditionChecker, form) {
|
|
1893
1897
|
const evaluatedValidate = {
|
|
@@ -1921,12 +1925,12 @@ function evaluateFEELValues(validate, expressionLanguage, conditionChecker, form
|
|
|
1921
1925
|
}
|
|
1922
1926
|
|
|
1923
1927
|
class Importer {
|
|
1924
|
-
/**
|
|
1925
|
-
* @constructor
|
|
1926
|
-
* @param { import('./FormFieldRegistry').default } formFieldRegistry
|
|
1927
|
-
* @param { import('./PathRegistry').default } pathRegistry
|
|
1928
|
-
* @param { import('./FieldFactory').default } fieldFactory
|
|
1929
|
-
* @param { import('./FormLayouter').default } formLayouter
|
|
1928
|
+
/**
|
|
1929
|
+
* @constructor
|
|
1930
|
+
* @param { import('./FormFieldRegistry').default } formFieldRegistry
|
|
1931
|
+
* @param { import('./PathRegistry').default } pathRegistry
|
|
1932
|
+
* @param { import('./FieldFactory').default } fieldFactory
|
|
1933
|
+
* @param { import('./FormLayouter').default } formLayouter
|
|
1930
1934
|
*/
|
|
1931
1935
|
constructor(formFieldRegistry, pathRegistry, fieldFactory, formLayouter) {
|
|
1932
1936
|
this._formFieldRegistry = formFieldRegistry;
|
|
@@ -1935,21 +1939,21 @@ class Importer {
|
|
|
1935
1939
|
this._formLayouter = formLayouter;
|
|
1936
1940
|
}
|
|
1937
1941
|
|
|
1938
|
-
/**
|
|
1939
|
-
* Import schema creating rows, fields, attaching additional
|
|
1940
|
-
* information to each field and adding fields to the
|
|
1941
|
-
* field registry.
|
|
1942
|
-
*
|
|
1943
|
-
* Additional information attached:
|
|
1944
|
-
*
|
|
1945
|
-
* * `id` (unless present)
|
|
1946
|
-
* * `_parent`
|
|
1947
|
-
* * `_path`
|
|
1948
|
-
*
|
|
1949
|
-
* @param {any} schema
|
|
1950
|
-
*
|
|
1951
|
-
* @typedef {{ warnings: Error[], schema: any }} ImportResult
|
|
1952
|
-
* @returns {ImportResult}
|
|
1942
|
+
/**
|
|
1943
|
+
* Import schema creating rows, fields, attaching additional
|
|
1944
|
+
* information to each field and adding fields to the
|
|
1945
|
+
* field registry.
|
|
1946
|
+
*
|
|
1947
|
+
* Additional information attached:
|
|
1948
|
+
*
|
|
1949
|
+
* * `id` (unless present)
|
|
1950
|
+
* * `_parent`
|
|
1951
|
+
* * `_path`
|
|
1952
|
+
*
|
|
1953
|
+
* @param {any} schema
|
|
1954
|
+
*
|
|
1955
|
+
* @typedef {{ warnings: Error[], schema: any }} ImportResult
|
|
1956
|
+
* @returns {ImportResult}
|
|
1953
1957
|
*/
|
|
1954
1958
|
importSchema(schema) {
|
|
1955
1959
|
// TODO: Add warnings
|
|
@@ -1974,12 +1978,12 @@ class Importer {
|
|
|
1974
1978
|
this._pathRegistry.clear();
|
|
1975
1979
|
}
|
|
1976
1980
|
|
|
1977
|
-
/**
|
|
1978
|
-
* @param {{[x: string]: any}} fieldAttrs
|
|
1979
|
-
* @param {String} [parentId]
|
|
1980
|
-
* @param {number} [index]
|
|
1981
|
-
*
|
|
1982
|
-
* @return {any} field
|
|
1981
|
+
/**
|
|
1982
|
+
* @param {{[x: string]: any}} fieldAttrs
|
|
1983
|
+
* @param {String} [parentId]
|
|
1984
|
+
* @param {number} [index]
|
|
1985
|
+
*
|
|
1986
|
+
* @return {any} field
|
|
1983
1987
|
*/
|
|
1984
1988
|
importFormField(fieldAttrs, parentId, index) {
|
|
1985
1989
|
const {
|
|
@@ -2004,11 +2008,11 @@ class Importer {
|
|
|
2004
2008
|
return field;
|
|
2005
2009
|
}
|
|
2006
2010
|
|
|
2007
|
-
/**
|
|
2008
|
-
* @param {Array<any>} components
|
|
2009
|
-
* @param {string} parentId
|
|
2010
|
-
*
|
|
2011
|
-
* @return {Array<any>} imported components
|
|
2011
|
+
/**
|
|
2012
|
+
* @param {Array<any>} components
|
|
2013
|
+
* @param {string} parentId
|
|
2014
|
+
*
|
|
2015
|
+
* @return {Array<any>} imported components
|
|
2012
2016
|
*/
|
|
2013
2017
|
importFormFields(components, parentId) {
|
|
2014
2018
|
return components.map((component, index) => {
|
|
@@ -2019,11 +2023,11 @@ class Importer {
|
|
|
2019
2023
|
Importer.$inject = ['formFieldRegistry', 'pathRegistry', 'fieldFactory', 'formLayouter'];
|
|
2020
2024
|
|
|
2021
2025
|
class FieldFactory {
|
|
2022
|
-
/**
|
|
2023
|
-
* @constructor
|
|
2024
|
-
*
|
|
2025
|
-
* @param formFieldRegistry
|
|
2026
|
-
* @param formFields
|
|
2026
|
+
/**
|
|
2027
|
+
* @constructor
|
|
2028
|
+
*
|
|
2029
|
+
* @param formFieldRegistry
|
|
2030
|
+
* @param formFields
|
|
2027
2031
|
*/
|
|
2028
2032
|
constructor(formFieldRegistry, pathRegistry, formFields) {
|
|
2029
2033
|
this._formFieldRegistry = formFieldRegistry;
|
|
@@ -2105,36 +2109,36 @@ class FieldFactory {
|
|
|
2105
2109
|
}
|
|
2106
2110
|
FieldFactory.$inject = ['formFieldRegistry', 'pathRegistry', 'formFields'];
|
|
2107
2111
|
|
|
2108
|
-
/**
|
|
2109
|
-
* The PathRegistry class manages a hierarchical structure of paths associated with form fields.
|
|
2110
|
-
* It enables claiming, unclaiming, and validating paths within this structure.
|
|
2111
|
-
*
|
|
2112
|
-
* Example Tree Structure:
|
|
2113
|
-
*
|
|
2114
|
-
* [
|
|
2115
|
-
* {
|
|
2116
|
-
* segment: 'root',
|
|
2117
|
-
* claimCount: 1,
|
|
2118
|
-
* children: [
|
|
2119
|
-
* {
|
|
2120
|
-
* segment: 'child1',
|
|
2121
|
-
* claimCount: 2,
|
|
2122
|
-
* children: null // A leaf node (closed path)
|
|
2123
|
-
* },
|
|
2124
|
-
* {
|
|
2125
|
-
* segment: 'child2',
|
|
2126
|
-
* claimCount: 1,
|
|
2127
|
-
* children: [
|
|
2128
|
-
* {
|
|
2129
|
-
* segment: 'subChild1',
|
|
2130
|
-
* claimCount: 1,
|
|
2131
|
-
* children: [] // An open node (open path)
|
|
2132
|
-
* }
|
|
2133
|
-
* ]
|
|
2134
|
-
* }
|
|
2135
|
-
* ]
|
|
2136
|
-
* }
|
|
2137
|
-
* ]
|
|
2112
|
+
/**
|
|
2113
|
+
* The PathRegistry class manages a hierarchical structure of paths associated with form fields.
|
|
2114
|
+
* It enables claiming, unclaiming, and validating paths within this structure.
|
|
2115
|
+
*
|
|
2116
|
+
* Example Tree Structure:
|
|
2117
|
+
*
|
|
2118
|
+
* [
|
|
2119
|
+
* {
|
|
2120
|
+
* segment: 'root',
|
|
2121
|
+
* claimCount: 1,
|
|
2122
|
+
* children: [
|
|
2123
|
+
* {
|
|
2124
|
+
* segment: 'child1',
|
|
2125
|
+
* claimCount: 2,
|
|
2126
|
+
* children: null // A leaf node (closed path)
|
|
2127
|
+
* },
|
|
2128
|
+
* {
|
|
2129
|
+
* segment: 'child2',
|
|
2130
|
+
* claimCount: 1,
|
|
2131
|
+
* children: [
|
|
2132
|
+
* {
|
|
2133
|
+
* segment: 'subChild1',
|
|
2134
|
+
* claimCount: 1,
|
|
2135
|
+
* children: [] // An open node (open path)
|
|
2136
|
+
* }
|
|
2137
|
+
* ]
|
|
2138
|
+
* }
|
|
2139
|
+
* ]
|
|
2140
|
+
* }
|
|
2141
|
+
* ]
|
|
2138
2142
|
*/
|
|
2139
2143
|
class PathRegistry {
|
|
2140
2144
|
constructor(formFieldRegistry, formFields) {
|
|
@@ -2217,16 +2221,16 @@ class PathRegistry {
|
|
|
2217
2221
|
}
|
|
2218
2222
|
}
|
|
2219
2223
|
|
|
2220
|
-
/**
|
|
2221
|
-
* Applies a function (fn) recursively on a given field and its children.
|
|
2222
|
-
*
|
|
2223
|
-
* - `field`: Starting field object.
|
|
2224
|
-
* - `fn`: Function to apply.
|
|
2225
|
-
* - `context`: Optional object for passing data between calls.
|
|
2226
|
-
*
|
|
2227
|
-
* Stops early if `fn` returns `false`. Useful for traversing the form field tree.
|
|
2228
|
-
*
|
|
2229
|
-
* @returns {boolean} Success status based on function execution.
|
|
2224
|
+
/**
|
|
2225
|
+
* Applies a function (fn) recursively on a given field and its children.
|
|
2226
|
+
*
|
|
2227
|
+
* - `field`: Starting field object.
|
|
2228
|
+
* - `fn`: Function to apply.
|
|
2229
|
+
* - `context`: Optional object for passing data between calls.
|
|
2230
|
+
*
|
|
2231
|
+
* Stops early if `fn` returns `false`. Useful for traversing the form field tree.
|
|
2232
|
+
*
|
|
2233
|
+
* @returns {boolean} Success status based on function execution.
|
|
2230
2234
|
*/
|
|
2231
2235
|
executeRecursivelyOnFields(field, fn, context = {}) {
|
|
2232
2236
|
let result = true;
|
|
@@ -2260,15 +2264,15 @@ class PathRegistry {
|
|
|
2260
2264
|
return result;
|
|
2261
2265
|
}
|
|
2262
2266
|
|
|
2263
|
-
/**
|
|
2264
|
-
* Generates an array representing the binding path to an underlying data object for a form field.
|
|
2265
|
-
*
|
|
2266
|
-
* @param {Object} field - The field object with properties: `key`, `path`, `id`, and optionally `_parent`.
|
|
2267
|
-
* @param {Object} [options={}] - Configuration options.
|
|
2268
|
-
* @param {Object} [options.replacements={}] - A map of field IDs to alternative path arrays.
|
|
2269
|
-
* @param {Object} [options.cutoffNode] - The ID of the parent field at which to stop generating the path.
|
|
2270
|
-
*
|
|
2271
|
-
* @returns {(Array<string>|undefined)} An array of strings representing the binding path, or undefined if not determinable.
|
|
2267
|
+
/**
|
|
2268
|
+
* Generates an array representing the binding path to an underlying data object for a form field.
|
|
2269
|
+
*
|
|
2270
|
+
* @param {Object} field - The field object with properties: `key`, `path`, `id`, and optionally `_parent`.
|
|
2271
|
+
* @param {Object} [options={}] - Configuration options.
|
|
2272
|
+
* @param {Object} [options.replacements={}] - A map of field IDs to alternative path arrays.
|
|
2273
|
+
* @param {Object} [options.cutoffNode] - The ID of the parent field at which to stop generating the path.
|
|
2274
|
+
*
|
|
2275
|
+
* @returns {(Array<string>|undefined)} An array of strings representing the binding path, or undefined if not determinable.
|
|
2272
2276
|
*/
|
|
2273
2277
|
getValuePath(field, options = {}) {
|
|
2274
2278
|
const {
|
|
@@ -2312,23 +2316,23 @@ const _getNextSegment = (node, segment) => {
|
|
|
2312
2316
|
};
|
|
2313
2317
|
PathRegistry.$inject = ['formFieldRegistry', 'formFields'];
|
|
2314
2318
|
|
|
2315
|
-
/**
|
|
2316
|
-
* @typedef { { id: String, components: Array<String> } } FormRow
|
|
2317
|
-
* @typedef { { formFieldId: String, rows: Array<FormRow> } } FormRows
|
|
2319
|
+
/**
|
|
2320
|
+
* @typedef { { id: String, components: Array<String> } } FormRow
|
|
2321
|
+
* @typedef { { formFieldId: String, rows: Array<FormRow> } } FormRows
|
|
2318
2322
|
*/
|
|
2319
2323
|
|
|
2320
|
-
/**
|
|
2321
|
-
* Maintains the Form layout in a given structure, for example
|
|
2322
|
-
*
|
|
2323
|
-
* [
|
|
2324
|
-
* {
|
|
2325
|
-
* formFieldId: 'FormField_1',
|
|
2326
|
-
* rows: [
|
|
2327
|
-
* { id: 'Row_1', components: [ 'Text_1', 'Textdield_1', ... ] }
|
|
2328
|
-
* ]
|
|
2329
|
-
* }
|
|
2330
|
-
* ]
|
|
2331
|
-
*
|
|
2324
|
+
/**
|
|
2325
|
+
* Maintains the Form layout in a given structure, for example
|
|
2326
|
+
*
|
|
2327
|
+
* [
|
|
2328
|
+
* {
|
|
2329
|
+
* formFieldId: 'FormField_1',
|
|
2330
|
+
* rows: [
|
|
2331
|
+
* { id: 'Row_1', components: [ 'Text_1', 'Textdield_1', ... ] }
|
|
2332
|
+
* ]
|
|
2333
|
+
* }
|
|
2334
|
+
* ]
|
|
2335
|
+
*
|
|
2332
2336
|
*/
|
|
2333
2337
|
class FormLayouter {
|
|
2334
2338
|
constructor(eventBus) {
|
|
@@ -2338,8 +2342,8 @@ class FormLayouter {
|
|
|
2338
2342
|
this._eventBus = eventBus;
|
|
2339
2343
|
}
|
|
2340
2344
|
|
|
2341
|
-
/**
|
|
2342
|
-
* @param {FormRow} row
|
|
2345
|
+
/**
|
|
2346
|
+
* @param {FormRow} row
|
|
2343
2347
|
*/
|
|
2344
2348
|
addRow(formFieldId, row) {
|
|
2345
2349
|
let rowsPerComponent = this._rows.find(r => r.formFieldId === formFieldId);
|
|
@@ -2353,18 +2357,18 @@ class FormLayouter {
|
|
|
2353
2357
|
rowsPerComponent.rows.push(row);
|
|
2354
2358
|
}
|
|
2355
2359
|
|
|
2356
|
-
/**
|
|
2357
|
-
* @param {String} id
|
|
2358
|
-
* @returns {FormRow}
|
|
2360
|
+
/**
|
|
2361
|
+
* @param {String} id
|
|
2362
|
+
* @returns {FormRow}
|
|
2359
2363
|
*/
|
|
2360
2364
|
getRow(id) {
|
|
2361
2365
|
const rows = allRows(this._rows);
|
|
2362
2366
|
return rows.find(r => r.id === id);
|
|
2363
2367
|
}
|
|
2364
2368
|
|
|
2365
|
-
/**
|
|
2366
|
-
* @param {any} formField
|
|
2367
|
-
* @returns {FormRow}
|
|
2369
|
+
/**
|
|
2370
|
+
* @param {any} formField
|
|
2371
|
+
* @returns {FormRow}
|
|
2368
2372
|
*/
|
|
2369
2373
|
getRowForField(formField) {
|
|
2370
2374
|
return allRows(this._rows).find(r => {
|
|
@@ -2375,9 +2379,9 @@ class FormLayouter {
|
|
|
2375
2379
|
});
|
|
2376
2380
|
}
|
|
2377
2381
|
|
|
2378
|
-
/**
|
|
2379
|
-
* @param {String} formFieldId
|
|
2380
|
-
* @returns { Array<FormRow> }
|
|
2382
|
+
/**
|
|
2383
|
+
* @param {String} formFieldId
|
|
2384
|
+
* @returns { Array<FormRow> }
|
|
2381
2385
|
*/
|
|
2382
2386
|
getRows(formFieldId) {
|
|
2383
2387
|
const rowsForField = this._rows.find(r => formFieldId === r.formFieldId);
|
|
@@ -2387,15 +2391,15 @@ class FormLayouter {
|
|
|
2387
2391
|
return rowsForField.rows;
|
|
2388
2392
|
}
|
|
2389
2393
|
|
|
2390
|
-
/**
|
|
2391
|
-
* @returns {string}
|
|
2394
|
+
/**
|
|
2395
|
+
* @returns {string}
|
|
2392
2396
|
*/
|
|
2393
2397
|
nextRowId() {
|
|
2394
2398
|
return this._ids.nextPrefixed('Row_');
|
|
2395
2399
|
}
|
|
2396
2400
|
|
|
2397
|
-
/**
|
|
2398
|
-
* @param {any} formField
|
|
2401
|
+
/**
|
|
2402
|
+
* @param {any} formField
|
|
2399
2403
|
*/
|
|
2400
2404
|
calculateLayout(formField) {
|
|
2401
2405
|
const {
|
|
@@ -2449,9 +2453,9 @@ function groupByRow(components, ids) {
|
|
|
2449
2453
|
});
|
|
2450
2454
|
}
|
|
2451
2455
|
|
|
2452
|
-
/**
|
|
2453
|
-
* @param {Array<FormRows>} formRows
|
|
2454
|
-
* @returns {Array<FormRow>}
|
|
2456
|
+
/**
|
|
2457
|
+
* @param {Array<FormRows>} formRows
|
|
2458
|
+
* @returns {Array<FormRow>}
|
|
2455
2459
|
*/
|
|
2456
2460
|
function allRows(formRows) {
|
|
2457
2461
|
return minDash.flatten(formRows.map(c => c.rows));
|
|
@@ -2607,11 +2611,11 @@ const FormRenderContext = preact.createContext({
|
|
|
2607
2611
|
});
|
|
2608
2612
|
var FormRenderContext$1 = FormRenderContext;
|
|
2609
2613
|
|
|
2610
|
-
/**
|
|
2611
|
-
* @param {string} type
|
|
2612
|
-
* @param {boolean} [strict]
|
|
2613
|
-
*
|
|
2614
|
-
* @returns {any}
|
|
2614
|
+
/**
|
|
2615
|
+
* @param {string} type
|
|
2616
|
+
* @param {boolean} [strict]
|
|
2617
|
+
*
|
|
2618
|
+
* @returns {any}
|
|
2615
2619
|
*/
|
|
2616
2620
|
function getService(type, strict) {}
|
|
2617
2621
|
const FormContext = preact.createContext({
|
|
@@ -2627,10 +2631,10 @@ function useService(type, strict) {
|
|
|
2627
2631
|
return getService(type, strict);
|
|
2628
2632
|
}
|
|
2629
2633
|
|
|
2630
|
-
/**
|
|
2631
|
-
* Returns the conditionally filtered data of a form reactively.
|
|
2632
|
-
* Memoised to minimize re-renders
|
|
2633
|
-
*
|
|
2634
|
+
/**
|
|
2635
|
+
* Returns the conditionally filtered data of a form reactively.
|
|
2636
|
+
* Memoised to minimize re-renders
|
|
2637
|
+
*
|
|
2634
2638
|
*/
|
|
2635
2639
|
function useFilteredFormData() {
|
|
2636
2640
|
const {
|
|
@@ -2647,12 +2651,12 @@ function useFilteredFormData() {
|
|
|
2647
2651
|
}, [conditionChecker, data, initialData]);
|
|
2648
2652
|
}
|
|
2649
2653
|
|
|
2650
|
-
/**
|
|
2651
|
-
* Evaluate if condition is met reactively based on the conditionChecker and form data.
|
|
2652
|
-
*
|
|
2653
|
-
* @param {string | undefined} condition
|
|
2654
|
-
*
|
|
2655
|
-
* @returns {boolean} true if condition is met or no condition or condition checker exists
|
|
2654
|
+
/**
|
|
2655
|
+
* Evaluate if condition is met reactively based on the conditionChecker and form data.
|
|
2656
|
+
*
|
|
2657
|
+
* @param {string | undefined} condition
|
|
2658
|
+
*
|
|
2659
|
+
* @returns {boolean} true if condition is met or no condition or condition checker exists
|
|
2656
2660
|
*/
|
|
2657
2661
|
function useCondition(condition) {
|
|
2658
2662
|
const conditionChecker = useService('conditionChecker', false);
|
|
@@ -2662,13 +2666,13 @@ function useCondition(condition) {
|
|
|
2662
2666
|
}, [conditionChecker, condition, filteredData]);
|
|
2663
2667
|
}
|
|
2664
2668
|
|
|
2665
|
-
/**
|
|
2666
|
-
* Evaluate a string reactively based on the expressionLanguage and form data.
|
|
2667
|
-
* If the string is not an expression, it is returned as is.
|
|
2668
|
-
* Memoised to minimize re-renders.
|
|
2669
|
-
*
|
|
2670
|
-
* @param {string} value
|
|
2671
|
-
*
|
|
2669
|
+
/**
|
|
2670
|
+
* Evaluate a string reactively based on the expressionLanguage and form data.
|
|
2671
|
+
* If the string is not an expression, it is returned as is.
|
|
2672
|
+
* Memoised to minimize re-renders.
|
|
2673
|
+
*
|
|
2674
|
+
* @param {string} value
|
|
2675
|
+
*
|
|
2672
2676
|
*/
|
|
2673
2677
|
function useExpressionEvaluation(value) {
|
|
2674
2678
|
const formData = useFilteredFormData();
|
|
@@ -2697,16 +2701,16 @@ function useKeyDownAction(targetKey, action, listenerElement = window) {
|
|
|
2697
2701
|
});
|
|
2698
2702
|
}
|
|
2699
2703
|
|
|
2700
|
-
/**
|
|
2701
|
-
* Retrieve readonly value of a form field, given it can be an
|
|
2702
|
-
* expression optionally or configured globally.
|
|
2703
|
-
*
|
|
2704
|
-
* @typedef { import('../../types').FormProperties } FormProperties
|
|
2705
|
-
*
|
|
2706
|
-
* @param {any} formField
|
|
2707
|
-
* @param {FormProperties} properties
|
|
2708
|
-
*
|
|
2709
|
-
* @returns {boolean}
|
|
2704
|
+
/**
|
|
2705
|
+
* Retrieve readonly value of a form field, given it can be an
|
|
2706
|
+
* expression optionally or configured globally.
|
|
2707
|
+
*
|
|
2708
|
+
* @typedef { import('../../types').FormProperties } FormProperties
|
|
2709
|
+
*
|
|
2710
|
+
* @param {any} formField
|
|
2711
|
+
* @param {FormProperties} properties
|
|
2712
|
+
*
|
|
2713
|
+
* @returns {boolean}
|
|
2710
2714
|
*/
|
|
2711
2715
|
function useReadonly(formField, properties = {}) {
|
|
2712
2716
|
const expressionLanguage = useService('expressionLanguage');
|
|
@@ -2730,12 +2734,12 @@ function usePrevious(value, defaultValue, dependencies) {
|
|
|
2730
2734
|
return ref.current;
|
|
2731
2735
|
}
|
|
2732
2736
|
|
|
2733
|
-
/**
|
|
2734
|
-
* A custom hook to manage state changes with deep comparison.
|
|
2735
|
-
*
|
|
2736
|
-
* @param {any} value - The current value to manage.
|
|
2737
|
-
* @param {any} defaultValue - The initial default value for the state.
|
|
2738
|
-
* @returns {any} - Returns the current state.
|
|
2737
|
+
/**
|
|
2738
|
+
* A custom hook to manage state changes with deep comparison.
|
|
2739
|
+
*
|
|
2740
|
+
* @param {any} value - The current value to manage.
|
|
2741
|
+
* @param {any} defaultValue - The initial default value for the state.
|
|
2742
|
+
* @returns {any} - Returns the current state.
|
|
2739
2743
|
*/
|
|
2740
2744
|
function useDeepCompareState(value, defaultValue) {
|
|
2741
2745
|
const [state, setState] = hooks.useState(defaultValue);
|
|
@@ -2755,16 +2759,16 @@ function compare(a, b) {
|
|
|
2755
2759
|
return JSON.stringify(a) === JSON.stringify(b);
|
|
2756
2760
|
}
|
|
2757
2761
|
|
|
2758
|
-
/**
|
|
2759
|
-
* Template a string reactively based on form data. If the string is not a template, it is returned as is.
|
|
2760
|
-
* Memoised to minimize re-renders
|
|
2761
|
-
*
|
|
2762
|
-
* @param {string} value
|
|
2763
|
-
* @param {Object} options
|
|
2764
|
-
* @param {boolean} [options.debug = false]
|
|
2765
|
-
* @param {boolean} [options.strict = false]
|
|
2766
|
-
* @param {Function} [options.buildDebugString]
|
|
2767
|
-
*
|
|
2762
|
+
/**
|
|
2763
|
+
* Template a string reactively based on form data. If the string is not a template, it is returned as is.
|
|
2764
|
+
* Memoised to minimize re-renders
|
|
2765
|
+
*
|
|
2766
|
+
* @param {string} value
|
|
2767
|
+
* @param {Object} options
|
|
2768
|
+
* @param {boolean} [options.debug = false]
|
|
2769
|
+
* @param {boolean} [options.strict = false]
|
|
2770
|
+
* @param {Function} [options.buildDebugString]
|
|
2771
|
+
*
|
|
2768
2772
|
*/
|
|
2769
2773
|
function useTemplateEvaluation(value, options) {
|
|
2770
2774
|
const filteredData = useFilteredFormData();
|
|
@@ -2777,17 +2781,17 @@ function useTemplateEvaluation(value, options) {
|
|
|
2777
2781
|
}, [filteredData, templating, value, options]);
|
|
2778
2782
|
}
|
|
2779
2783
|
|
|
2780
|
-
/**
|
|
2781
|
-
* Template a string reactively based on form data. If the string is not a template, it is returned as is.
|
|
2782
|
-
* If the string contains multiple lines, only the first line is returned.
|
|
2783
|
-
* Memoised to minimize re-renders
|
|
2784
|
-
*
|
|
2785
|
-
* @param {string} value
|
|
2786
|
-
* @param {Object} [options]
|
|
2787
|
-
* @param {boolean} [options.debug = false]
|
|
2788
|
-
* @param {boolean} [options.strict = false]
|
|
2789
|
-
* @param {Function} [options.buildDebugString]
|
|
2790
|
-
*
|
|
2784
|
+
/**
|
|
2785
|
+
* Template a string reactively based on form data. If the string is not a template, it is returned as is.
|
|
2786
|
+
* If the string contains multiple lines, only the first line is returned.
|
|
2787
|
+
* Memoised to minimize re-renders
|
|
2788
|
+
*
|
|
2789
|
+
* @param {string} value
|
|
2790
|
+
* @param {Object} [options]
|
|
2791
|
+
* @param {boolean} [options.debug = false]
|
|
2792
|
+
* @param {boolean} [options.strict = false]
|
|
2793
|
+
* @param {Function} [options.buildDebugString]
|
|
2794
|
+
*
|
|
2791
2795
|
*/
|
|
2792
2796
|
function useSingleLineTemplateEvaluation(value, options = {}) {
|
|
2793
2797
|
const evaluatedTemplate = useTemplateEvaluation(value, options);
|
|
@@ -2991,8 +2995,8 @@ function createEmptyOptions(options = {}) {
|
|
|
2991
2995
|
};
|
|
2992
2996
|
}
|
|
2993
2997
|
|
|
2994
|
-
/**
|
|
2995
|
-
* @enum { String }
|
|
2998
|
+
/**
|
|
2999
|
+
* @enum { String }
|
|
2996
3000
|
*/
|
|
2997
3001
|
const LOAD_STATES = {
|
|
2998
3002
|
LOADING: 'loading',
|
|
@@ -3000,17 +3004,17 @@ const LOAD_STATES = {
|
|
|
3000
3004
|
ERROR: 'error'
|
|
3001
3005
|
};
|
|
3002
3006
|
|
|
3003
|
-
/**
|
|
3004
|
-
* @typedef {Object} ValuesGetter
|
|
3005
|
-
* @property {Object[]} values - The values data
|
|
3006
|
-
* @property {(LOAD_STATES)} state - The values data's loading state, to use for conditional rendering
|
|
3007
|
+
/**
|
|
3008
|
+
* @typedef {Object} ValuesGetter
|
|
3009
|
+
* @property {Object[]} values - The values data
|
|
3010
|
+
* @property {(LOAD_STATES)} state - The values data's loading state, to use for conditional rendering
|
|
3007
3011
|
*/
|
|
3008
3012
|
|
|
3009
|
-
/**
|
|
3010
|
-
* A hook to load values for single and multiselect components.
|
|
3011
|
-
*
|
|
3012
|
-
* @param {Object} field - The form field to handle values for
|
|
3013
|
-
* @return {ValuesGetter} valuesGetter - A values getter object providing loading state and values
|
|
3013
|
+
/**
|
|
3014
|
+
* A hook to load values for single and multiselect components.
|
|
3015
|
+
*
|
|
3016
|
+
* @param {Object} field - The form field to handle values for
|
|
3017
|
+
* @return {ValuesGetter} valuesGetter - A values getter object providing loading state and values
|
|
3014
3018
|
*/
|
|
3015
3019
|
function useValuesAsync (field) {
|
|
3016
3020
|
const {
|
|
@@ -3072,7 +3076,6 @@ const ENTER_KEYDOWN_EVENT = new KeyboardEvent('keydown', {
|
|
|
3072
3076
|
key: 'Enter',
|
|
3073
3077
|
charCode: 13,
|
|
3074
3078
|
keyCode: 13,
|
|
3075
|
-
view: window,
|
|
3076
3079
|
bubbles: true
|
|
3077
3080
|
});
|
|
3078
3081
|
function focusRelevantFlatpickerDay(flatpickrInstance) {
|
|
@@ -3519,12 +3522,12 @@ var SvgCalendar = function SvgCalendar(props) {
|
|
|
3519
3522
|
};
|
|
3520
3523
|
var CalendarIcon = SvgCalendar;
|
|
3521
3524
|
|
|
3522
|
-
/**
|
|
3523
|
-
* Returns date format for the provided locale.
|
|
3524
|
-
* If the locale is not provided, uses the browser's locale.
|
|
3525
|
-
*
|
|
3526
|
-
* @param {string} [locale] - The locale to get date format for.
|
|
3527
|
-
* @returns {string} The date format for the locale.
|
|
3525
|
+
/**
|
|
3526
|
+
* Returns date format for the provided locale.
|
|
3527
|
+
* If the locale is not provided, uses the browser's locale.
|
|
3528
|
+
*
|
|
3529
|
+
* @param {string} [locale] - The locale to get date format for.
|
|
3530
|
+
* @returns {string} The date format for the locale.
|
|
3528
3531
|
*/
|
|
3529
3532
|
function getLocaleDateFormat(locale = 'default') {
|
|
3530
3533
|
const parts = new Intl.DateTimeFormat(locale).formatToParts(new Date(Date.UTC(2020, 5, 5)));
|
|
@@ -3543,12 +3546,12 @@ function getLocaleDateFormat(locale = 'default') {
|
|
|
3543
3546
|
}).join('');
|
|
3544
3547
|
}
|
|
3545
3548
|
|
|
3546
|
-
/**
|
|
3547
|
-
* Returns readable date format for the provided locale.
|
|
3548
|
-
* If the locale is not provided, uses the browser's locale.
|
|
3549
|
-
*
|
|
3550
|
-
* @param {string} [locale] - The locale to get readable date format for.
|
|
3551
|
-
* @returns {string} The readable date format for the locale.
|
|
3549
|
+
/**
|
|
3550
|
+
* Returns readable date format for the provided locale.
|
|
3551
|
+
* If the locale is not provided, uses the browser's locale.
|
|
3552
|
+
*
|
|
3553
|
+
* @param {string} [locale] - The locale to get readable date format for.
|
|
3554
|
+
* @returns {string} The readable date format for the locale.
|
|
3552
3555
|
*/
|
|
3553
3556
|
function getLocaleReadableDateFormat(locale) {
|
|
3554
3557
|
let format = getLocaleDateFormat(locale).toLowerCase();
|
|
@@ -3565,12 +3568,12 @@ function getLocaleReadableDateFormat(locale) {
|
|
|
3565
3568
|
return format;
|
|
3566
3569
|
}
|
|
3567
3570
|
|
|
3568
|
-
/**
|
|
3569
|
-
* Returns flatpickr config for the provided locale.
|
|
3570
|
-
* If the locale is not provided, uses the browser's locale.
|
|
3571
|
-
*
|
|
3572
|
-
* @param {string} [locale] - The locale to get flatpickr config for.
|
|
3573
|
-
* @returns {object} The flatpickr config for the locale.
|
|
3571
|
+
/**
|
|
3572
|
+
* Returns flatpickr config for the provided locale.
|
|
3573
|
+
* If the locale is not provided, uses the browser's locale.
|
|
3574
|
+
*
|
|
3575
|
+
* @param {string} [locale] - The locale to get flatpickr config for.
|
|
3576
|
+
* @returns {object} The flatpickr config for the locale.
|
|
3574
3577
|
*/
|
|
3575
3578
|
function getLocaleDateFlatpickrConfig(locale) {
|
|
3576
3579
|
return flatpickerizeDateFormat(getLocaleDateFormat(locale));
|
|
@@ -4250,10 +4253,10 @@ Datetime.config = {
|
|
|
4250
4253
|
}
|
|
4251
4254
|
};
|
|
4252
4255
|
|
|
4253
|
-
/**
|
|
4254
|
-
* This file must not be changed or exchanged.
|
|
4255
|
-
*
|
|
4256
|
-
* @see http://bpmn.io/license for more information.
|
|
4256
|
+
/**
|
|
4257
|
+
* This file must not be changed or exchanged.
|
|
4258
|
+
*
|
|
4259
|
+
* @see http://bpmn.io/license for more information.
|
|
4257
4260
|
*/
|
|
4258
4261
|
function Logo() {
|
|
4259
4262
|
return jsxRuntime.jsxs("svg", {
|
|
@@ -4431,11 +4434,11 @@ const ATTR_WHITESPACE_PATTERN = /[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u
|
|
|
4431
4434
|
|
|
4432
4435
|
const FORM_ELEMENT = document.createElement('form');
|
|
4433
4436
|
|
|
4434
|
-
/**
|
|
4435
|
-
* Sanitize a HTML string and return the cleaned, safe version.
|
|
4436
|
-
*
|
|
4437
|
-
* @param {string} html
|
|
4438
|
-
* @return {string}
|
|
4437
|
+
/**
|
|
4438
|
+
* Sanitize a HTML string and return the cleaned, safe version.
|
|
4439
|
+
*
|
|
4440
|
+
* @param {string} html
|
|
4441
|
+
* @return {string}
|
|
4439
4442
|
*/
|
|
4440
4443
|
|
|
4441
4444
|
// see https://github.com/developit/snarkdown/issues/70
|
|
@@ -4453,29 +4456,29 @@ function sanitizeHTML(html) {
|
|
|
4453
4456
|
}
|
|
4454
4457
|
}
|
|
4455
4458
|
|
|
4456
|
-
/**
|
|
4457
|
-
* Sanitizes an image source to ensure we only allow for data URI and links
|
|
4458
|
-
* that start with http(s).
|
|
4459
|
-
*
|
|
4460
|
-
* Note: Most browsers anyway do not support script execution in <img> elements.
|
|
4461
|
-
*
|
|
4462
|
-
* @param {string} src
|
|
4463
|
-
* @returns {string}
|
|
4459
|
+
/**
|
|
4460
|
+
* Sanitizes an image source to ensure we only allow for data URI and links
|
|
4461
|
+
* that start with http(s).
|
|
4462
|
+
*
|
|
4463
|
+
* Note: Most browsers anyway do not support script execution in <img> elements.
|
|
4464
|
+
*
|
|
4465
|
+
* @param {string} src
|
|
4466
|
+
* @returns {string}
|
|
4464
4467
|
*/
|
|
4465
4468
|
function sanitizeImageSource(src) {
|
|
4466
4469
|
const valid = ALLOWED_IMAGE_SRC_PATTERN.test(src);
|
|
4467
4470
|
return valid ? src : '';
|
|
4468
4471
|
}
|
|
4469
4472
|
|
|
4470
|
-
/**
|
|
4471
|
-
* Recursively sanitize a HTML node, potentially
|
|
4472
|
-
* removing it, its children or attributes.
|
|
4473
|
-
*
|
|
4474
|
-
* Inspired by https://github.com/developit/snarkdown/issues/70
|
|
4475
|
-
* and https://github.com/cure53/DOMPurify. Simplified
|
|
4476
|
-
* for our use-case.
|
|
4477
|
-
*
|
|
4478
|
-
* @param {Element} node
|
|
4473
|
+
/**
|
|
4474
|
+
* Recursively sanitize a HTML node, potentially
|
|
4475
|
+
* removing it, its children or attributes.
|
|
4476
|
+
*
|
|
4477
|
+
* Inspired by https://github.com/developit/snarkdown/issues/70
|
|
4478
|
+
* and https://github.com/cure53/DOMPurify. Simplified
|
|
4479
|
+
* for our use-case.
|
|
4480
|
+
*
|
|
4481
|
+
* @param {Element} node
|
|
4479
4482
|
*/
|
|
4480
4483
|
function sanitizeNode(node) {
|
|
4481
4484
|
// allow text nodes
|
|
@@ -4519,13 +4522,13 @@ function sanitizeNode(node) {
|
|
|
4519
4522
|
}
|
|
4520
4523
|
}
|
|
4521
4524
|
|
|
4522
|
-
/**
|
|
4523
|
-
* Validates attributes for validity.
|
|
4524
|
-
*
|
|
4525
|
-
* @param {string} lcTag
|
|
4526
|
-
* @param {string} lcName
|
|
4527
|
-
* @param {string} value
|
|
4528
|
-
* @return {boolean}
|
|
4525
|
+
/**
|
|
4526
|
+
* Validates attributes for validity.
|
|
4527
|
+
*
|
|
4528
|
+
* @param {string} lcTag
|
|
4529
|
+
* @param {string} lcName
|
|
4530
|
+
* @param {string} value
|
|
4531
|
+
* @return {boolean}
|
|
4529
4532
|
*/
|
|
4530
4533
|
function isValidAttribute(lcTag, lcName, value) {
|
|
4531
4534
|
// disallow most attributes based on whitelist
|
|
@@ -6253,55 +6256,55 @@ var core = {
|
|
|
6253
6256
|
validator: ['type', Validator]
|
|
6254
6257
|
};
|
|
6255
6258
|
|
|
6256
|
-
/**
|
|
6257
|
-
* @typedef { import('./types').Injector } Injector
|
|
6258
|
-
* @typedef { import('./types').Data } Data
|
|
6259
|
-
* @typedef { import('./types').Errors } Errors
|
|
6260
|
-
* @typedef { import('./types').Schema } Schema
|
|
6261
|
-
* @typedef { import('./types').FormProperties } FormProperties
|
|
6262
|
-
* @typedef { import('./types').FormProperty } FormProperty
|
|
6263
|
-
* @typedef { import('./types').FormEvent } FormEvent
|
|
6264
|
-
* @typedef { import('./types').FormOptions } FormOptions
|
|
6265
|
-
*
|
|
6266
|
-
* @typedef { {
|
|
6267
|
-
* data: Data,
|
|
6268
|
-
* initialData: Data,
|
|
6269
|
-
* errors: Errors,
|
|
6270
|
-
* properties: FormProperties,
|
|
6271
|
-
* schema: Schema
|
|
6272
|
-
* } } State
|
|
6273
|
-
*
|
|
6274
|
-
* @typedef { (type:FormEvent, priority:number, handler:Function) => void } OnEventWithPriority
|
|
6275
|
-
* @typedef { (type:FormEvent, handler:Function) => void } OnEventWithOutPriority
|
|
6276
|
-
* @typedef { OnEventWithPriority & OnEventWithOutPriority } OnEventType
|
|
6259
|
+
/**
|
|
6260
|
+
* @typedef { import('./types').Injector } Injector
|
|
6261
|
+
* @typedef { import('./types').Data } Data
|
|
6262
|
+
* @typedef { import('./types').Errors } Errors
|
|
6263
|
+
* @typedef { import('./types').Schema } Schema
|
|
6264
|
+
* @typedef { import('./types').FormProperties } FormProperties
|
|
6265
|
+
* @typedef { import('./types').FormProperty } FormProperty
|
|
6266
|
+
* @typedef { import('./types').FormEvent } FormEvent
|
|
6267
|
+
* @typedef { import('./types').FormOptions } FormOptions
|
|
6268
|
+
*
|
|
6269
|
+
* @typedef { {
|
|
6270
|
+
* data: Data,
|
|
6271
|
+
* initialData: Data,
|
|
6272
|
+
* errors: Errors,
|
|
6273
|
+
* properties: FormProperties,
|
|
6274
|
+
* schema: Schema
|
|
6275
|
+
* } } State
|
|
6276
|
+
*
|
|
6277
|
+
* @typedef { (type:FormEvent, priority:number, handler:Function) => void } OnEventWithPriority
|
|
6278
|
+
* @typedef { (type:FormEvent, handler:Function) => void } OnEventWithOutPriority
|
|
6279
|
+
* @typedef { OnEventWithPriority & OnEventWithOutPriority } OnEventType
|
|
6277
6280
|
*/
|
|
6278
6281
|
|
|
6279
6282
|
const ids = new Ids([32, 36, 1]);
|
|
6280
6283
|
|
|
6281
|
-
/**
|
|
6282
|
-
* The form.
|
|
6284
|
+
/**
|
|
6285
|
+
* The form.
|
|
6283
6286
|
*/
|
|
6284
6287
|
class Form {
|
|
6285
|
-
/**
|
|
6286
|
-
* @constructor
|
|
6287
|
-
* @param {FormOptions} options
|
|
6288
|
+
/**
|
|
6289
|
+
* @constructor
|
|
6290
|
+
* @param {FormOptions} options
|
|
6288
6291
|
*/
|
|
6289
6292
|
constructor(options = {}) {
|
|
6290
|
-
/**
|
|
6291
|
-
* @public
|
|
6292
|
-
* @type {OnEventType}
|
|
6293
|
+
/**
|
|
6294
|
+
* @public
|
|
6295
|
+
* @type {OnEventType}
|
|
6293
6296
|
*/
|
|
6294
6297
|
this.on = this._onEvent;
|
|
6295
6298
|
|
|
6296
|
-
/**
|
|
6297
|
-
* @public
|
|
6298
|
-
* @type {String}
|
|
6299
|
+
/**
|
|
6300
|
+
* @public
|
|
6301
|
+
* @type {String}
|
|
6299
6302
|
*/
|
|
6300
6303
|
this._id = ids.next();
|
|
6301
6304
|
|
|
6302
|
-
/**
|
|
6303
|
-
* @private
|
|
6304
|
-
* @type {Element}
|
|
6305
|
+
/**
|
|
6306
|
+
* @private
|
|
6307
|
+
* @type {Element}
|
|
6305
6308
|
*/
|
|
6306
6309
|
this._container = createFormContainer();
|
|
6307
6310
|
const {
|
|
@@ -6310,9 +6313,9 @@ class Form {
|
|
|
6310
6313
|
properties = {}
|
|
6311
6314
|
} = options;
|
|
6312
6315
|
|
|
6313
|
-
/**
|
|
6314
|
-
* @private
|
|
6315
|
-
* @type {State}
|
|
6316
|
+
/**
|
|
6317
|
+
* @private
|
|
6318
|
+
* @type {State}
|
|
6316
6319
|
*/
|
|
6317
6320
|
this._state = {
|
|
6318
6321
|
initialData: null,
|
|
@@ -6336,9 +6339,9 @@ class Form {
|
|
|
6336
6339
|
this._emit('form.clear');
|
|
6337
6340
|
}
|
|
6338
6341
|
|
|
6339
|
-
/**
|
|
6340
|
-
* Destroy the form, removing it from DOM,
|
|
6341
|
-
* if attached.
|
|
6342
|
+
/**
|
|
6343
|
+
* Destroy the form, removing it from DOM,
|
|
6344
|
+
* if attached.
|
|
6342
6345
|
*/
|
|
6343
6346
|
destroy() {
|
|
6344
6347
|
// destroy form services
|
|
@@ -6349,13 +6352,13 @@ class Form {
|
|
|
6349
6352
|
this._detach(false);
|
|
6350
6353
|
}
|
|
6351
6354
|
|
|
6352
|
-
/**
|
|
6353
|
-
* Open a form schema with the given initial data.
|
|
6354
|
-
*
|
|
6355
|
-
* @param {Schema} schema
|
|
6356
|
-
* @param {Data} [data]
|
|
6357
|
-
*
|
|
6358
|
-
* @return Promise<{ warnings: Array<any> }>
|
|
6355
|
+
/**
|
|
6356
|
+
* Open a form schema with the given initial data.
|
|
6357
|
+
*
|
|
6358
|
+
* @param {Schema} schema
|
|
6359
|
+
* @param {Data} [data]
|
|
6360
|
+
*
|
|
6361
|
+
* @return Promise<{ warnings: Array<any> }>
|
|
6359
6362
|
*/
|
|
6360
6363
|
importSchema(schema, data = {}) {
|
|
6361
6364
|
return new Promise((resolve, reject) => {
|
|
@@ -6388,10 +6391,10 @@ class Form {
|
|
|
6388
6391
|
});
|
|
6389
6392
|
}
|
|
6390
6393
|
|
|
6391
|
-
/**
|
|
6392
|
-
* Submit the form, triggering all field validations.
|
|
6393
|
-
*
|
|
6394
|
-
* @returns { { data: Data, errors: Errors } }
|
|
6394
|
+
/**
|
|
6395
|
+
* Submit the form, triggering all field validations.
|
|
6396
|
+
*
|
|
6397
|
+
* @returns { { data: Data, errors: Errors } }
|
|
6395
6398
|
*/
|
|
6396
6399
|
submit() {
|
|
6397
6400
|
const {
|
|
@@ -6402,10 +6405,9 @@ class Form {
|
|
|
6402
6405
|
}
|
|
6403
6406
|
const data = this._getSubmitData();
|
|
6404
6407
|
const errors = this.validate();
|
|
6405
|
-
const filteredErrors = this._applyConditions(errors, data);
|
|
6406
6408
|
const result = {
|
|
6407
6409
|
data,
|
|
6408
|
-
errors
|
|
6410
|
+
errors
|
|
6409
6411
|
};
|
|
6410
6412
|
this._emit('submit', result);
|
|
6411
6413
|
return result;
|
|
@@ -6418,8 +6420,8 @@ class Form {
|
|
|
6418
6420
|
});
|
|
6419
6421
|
}
|
|
6420
6422
|
|
|
6421
|
-
/**
|
|
6422
|
-
* @returns {Errors}
|
|
6423
|
+
/**
|
|
6424
|
+
* @returns {Errors}
|
|
6423
6425
|
*/
|
|
6424
6426
|
validate() {
|
|
6425
6427
|
const formFieldRegistry = this.get('formFieldRegistry'),
|
|
@@ -6428,6 +6430,7 @@ class Form {
|
|
|
6428
6430
|
const {
|
|
6429
6431
|
data
|
|
6430
6432
|
} = this._getState();
|
|
6433
|
+
const getErrorPath = field => [field.id];
|
|
6431
6434
|
const errors = formFieldRegistry.getAll().reduce((errors, field) => {
|
|
6432
6435
|
const {
|
|
6433
6436
|
disabled
|
|
@@ -6437,16 +6440,19 @@ class Form {
|
|
|
6437
6440
|
}
|
|
6438
6441
|
const value = minDash.get(data, pathRegistry.getValuePath(field));
|
|
6439
6442
|
const fieldErrors = validator.validateField(field, value);
|
|
6440
|
-
return minDash.set(errors,
|
|
6443
|
+
return minDash.set(errors, getErrorPath(field), fieldErrors.length ? fieldErrors : undefined);
|
|
6441
6444
|
}, /** @type {Errors} */{});
|
|
6445
|
+
const filteredErrors = this._applyConditions(errors, data, {
|
|
6446
|
+
getFilterPath: getErrorPath
|
|
6447
|
+
});
|
|
6442
6448
|
this._setState({
|
|
6443
|
-
errors
|
|
6449
|
+
errors: filteredErrors
|
|
6444
6450
|
});
|
|
6445
|
-
return
|
|
6451
|
+
return filteredErrors;
|
|
6446
6452
|
}
|
|
6447
6453
|
|
|
6448
|
-
/**
|
|
6449
|
-
* @param {Element|string} parentNode
|
|
6454
|
+
/**
|
|
6455
|
+
* @param {Element|string} parentNode
|
|
6450
6456
|
*/
|
|
6451
6457
|
attachTo(parentNode) {
|
|
6452
6458
|
if (!parentNode) {
|
|
@@ -6464,10 +6470,10 @@ class Form {
|
|
|
6464
6470
|
this._detach();
|
|
6465
6471
|
}
|
|
6466
6472
|
|
|
6467
|
-
/**
|
|
6468
|
-
* @private
|
|
6469
|
-
*
|
|
6470
|
-
* @param {boolean} [emit]
|
|
6473
|
+
/**
|
|
6474
|
+
* @private
|
|
6475
|
+
*
|
|
6476
|
+
* @param {boolean} [emit]
|
|
6471
6477
|
*/
|
|
6472
6478
|
_detach(emit = true) {
|
|
6473
6479
|
const container = this._container,
|
|
@@ -6481,9 +6487,9 @@ class Form {
|
|
|
6481
6487
|
parentNode.removeChild(container);
|
|
6482
6488
|
}
|
|
6483
6489
|
|
|
6484
|
-
/**
|
|
6485
|
-
* @param {FormProperty} property
|
|
6486
|
-
* @param {any} value
|
|
6490
|
+
/**
|
|
6491
|
+
* @param {FormProperty} property
|
|
6492
|
+
* @param {any} value
|
|
6487
6493
|
*/
|
|
6488
6494
|
setProperty(property, value) {
|
|
6489
6495
|
const properties = minDash.set(this._getState().properties, [property], value);
|
|
@@ -6492,21 +6498,21 @@ class Form {
|
|
|
6492
6498
|
});
|
|
6493
6499
|
}
|
|
6494
6500
|
|
|
6495
|
-
/**
|
|
6496
|
-
* @param {FormEvent} type
|
|
6497
|
-
* @param {Function} handler
|
|
6501
|
+
/**
|
|
6502
|
+
* @param {FormEvent} type
|
|
6503
|
+
* @param {Function} handler
|
|
6498
6504
|
*/
|
|
6499
6505
|
off(type, handler) {
|
|
6500
6506
|
this.get('eventBus').off(type, handler);
|
|
6501
6507
|
}
|
|
6502
6508
|
|
|
6503
|
-
/**
|
|
6504
|
-
* @private
|
|
6505
|
-
*
|
|
6506
|
-
* @param {FormOptions} options
|
|
6507
|
-
* @param {Element} container
|
|
6508
|
-
*
|
|
6509
|
-
* @returns {Injector}
|
|
6509
|
+
/**
|
|
6510
|
+
* @private
|
|
6511
|
+
*
|
|
6512
|
+
* @param {FormOptions} options
|
|
6513
|
+
* @param {Element} container
|
|
6514
|
+
*
|
|
6515
|
+
* @returns {Injector}
|
|
6510
6516
|
*/
|
|
6511
6517
|
_createInjector(options, container) {
|
|
6512
6518
|
const {
|
|
@@ -6525,17 +6531,17 @@ class Form {
|
|
|
6525
6531
|
}, core, ...modules, ...additionalModules]);
|
|
6526
6532
|
}
|
|
6527
6533
|
|
|
6528
|
-
/**
|
|
6529
|
-
* @private
|
|
6534
|
+
/**
|
|
6535
|
+
* @private
|
|
6530
6536
|
*/
|
|
6531
6537
|
_emit(type, data) {
|
|
6532
6538
|
this.get('eventBus').fire(type, data);
|
|
6533
6539
|
}
|
|
6534
6540
|
|
|
6535
|
-
/**
|
|
6536
|
-
* @internal
|
|
6537
|
-
*
|
|
6538
|
-
* @param { { add?: boolean, field: any, remove?: number, value?: any } } update
|
|
6541
|
+
/**
|
|
6542
|
+
* @internal
|
|
6543
|
+
*
|
|
6544
|
+
* @param { { add?: boolean, field: any, remove?: number, value?: any } } update
|
|
6539
6545
|
*/
|
|
6540
6546
|
_update(update) {
|
|
6541
6547
|
const {
|
|
@@ -6557,15 +6563,15 @@ class Form {
|
|
|
6557
6563
|
});
|
|
6558
6564
|
}
|
|
6559
6565
|
|
|
6560
|
-
/**
|
|
6561
|
-
* @internal
|
|
6566
|
+
/**
|
|
6567
|
+
* @internal
|
|
6562
6568
|
*/
|
|
6563
6569
|
_getState() {
|
|
6564
6570
|
return this._state;
|
|
6565
6571
|
}
|
|
6566
6572
|
|
|
6567
|
-
/**
|
|
6568
|
-
* @internal
|
|
6573
|
+
/**
|
|
6574
|
+
* @internal
|
|
6569
6575
|
*/
|
|
6570
6576
|
_setState(state) {
|
|
6571
6577
|
this._state = {
|
|
@@ -6575,22 +6581,22 @@ class Form {
|
|
|
6575
6581
|
this._emit('changed', this._getState());
|
|
6576
6582
|
}
|
|
6577
6583
|
|
|
6578
|
-
/**
|
|
6579
|
-
* @internal
|
|
6584
|
+
/**
|
|
6585
|
+
* @internal
|
|
6580
6586
|
*/
|
|
6581
6587
|
_getModules() {
|
|
6582
6588
|
return [ExpressionLanguageModule, MarkdownModule, ViewerCommandsModule];
|
|
6583
6589
|
}
|
|
6584
6590
|
|
|
6585
|
-
/**
|
|
6586
|
-
* @internal
|
|
6591
|
+
/**
|
|
6592
|
+
* @internal
|
|
6587
6593
|
*/
|
|
6588
6594
|
_onEvent(type, priority, handler) {
|
|
6589
6595
|
this.get('eventBus').on(type, priority, handler);
|
|
6590
6596
|
}
|
|
6591
6597
|
|
|
6592
|
-
/**
|
|
6593
|
-
* @internal
|
|
6598
|
+
/**
|
|
6599
|
+
* @internal
|
|
6594
6600
|
*/
|
|
6595
6601
|
_getSubmitData() {
|
|
6596
6602
|
const formFieldRegistry = this.get('formFieldRegistry'),
|
|
@@ -6618,16 +6624,16 @@ class Form {
|
|
|
6618
6624
|
return filteredSubmitData;
|
|
6619
6625
|
}
|
|
6620
6626
|
|
|
6621
|
-
/**
|
|
6622
|
-
* @internal
|
|
6627
|
+
/**
|
|
6628
|
+
* @internal
|
|
6623
6629
|
*/
|
|
6624
|
-
_applyConditions(toFilter, data) {
|
|
6630
|
+
_applyConditions(toFilter, data, options = {}) {
|
|
6625
6631
|
const conditionChecker = this.get('conditionChecker');
|
|
6626
|
-
return conditionChecker.applyConditions(toFilter, data);
|
|
6632
|
+
return conditionChecker.applyConditions(toFilter, data, options);
|
|
6627
6633
|
}
|
|
6628
6634
|
|
|
6629
|
-
/**
|
|
6630
|
-
* @internal
|
|
6635
|
+
/**
|
|
6636
|
+
* @internal
|
|
6631
6637
|
*/
|
|
6632
6638
|
_initializeFieldData(data) {
|
|
6633
6639
|
const formFieldRegistry = this.get('formFieldRegistry'),
|