@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.es.js
CHANGED
|
@@ -47,26 +47,26 @@ const getFlavouredFeelVariableNames = (feelString, feelFlavour = 'expression', o
|
|
|
47
47
|
return [...new Set(variables)];
|
|
48
48
|
};
|
|
49
49
|
|
|
50
|
-
/**
|
|
51
|
-
* Get the variable name at the specified index in a given path expression.
|
|
52
|
-
*
|
|
53
|
-
* @param {Object} root - The root node of the path expression tree.
|
|
54
|
-
* @param {number} index - The index of the variable name to retrieve.
|
|
55
|
-
* @returns {string|null} The variable name at the specified index or null if index is out of bounds.
|
|
50
|
+
/**
|
|
51
|
+
* Get the variable name at the specified index in a given path expression.
|
|
52
|
+
*
|
|
53
|
+
* @param {Object} root - The root node of the path expression tree.
|
|
54
|
+
* @param {number} index - The index of the variable name to retrieve.
|
|
55
|
+
* @returns {string|null} The variable name at the specified index or null if index is out of bounds.
|
|
56
56
|
*/
|
|
57
57
|
const _getVariableNameAtPathIndex = (root, index) => {
|
|
58
58
|
const accessors = _deconstructPathExpression(root);
|
|
59
59
|
return accessors[index] || null;
|
|
60
60
|
};
|
|
61
61
|
|
|
62
|
-
/**
|
|
63
|
-
* Extracts the variables which are required of the external context for a given path expression.
|
|
64
|
-
* This is done by traversing the path expression tree and keeping track of the current depth relative to the external context.
|
|
65
|
-
*
|
|
66
|
-
* @param {Object} node - The root node of the path expression tree.
|
|
67
|
-
* @param {number} initialDepth - The depth at which the root node is located in the outer context.
|
|
68
|
-
* @param {Object} specialDepthAccessors - Definitions of special keywords which represent more complex accesses of the outer context.
|
|
69
|
-
* @returns {Set} - A set containing the extracted variable names.
|
|
62
|
+
/**
|
|
63
|
+
* Extracts the variables which are required of the external context for a given path expression.
|
|
64
|
+
* This is done by traversing the path expression tree and keeping track of the current depth relative to the external context.
|
|
65
|
+
*
|
|
66
|
+
* @param {Object} node - The root node of the path expression tree.
|
|
67
|
+
* @param {number} initialDepth - The depth at which the root node is located in the outer context.
|
|
68
|
+
* @param {Object} specialDepthAccessors - Definitions of special keywords which represent more complex accesses of the outer context.
|
|
69
|
+
* @returns {Set} - A set containing the extracted variable names.
|
|
70
70
|
*/
|
|
71
71
|
const _smartExtractVariableNames = (node, initialDepth, specialDepthAccessors) => {
|
|
72
72
|
// depth info represents the previous (initialised as null) and current depth of the current accessor in the path expression
|
|
@@ -112,11 +112,11 @@ const _smartExtractVariableNames = (node, initialDepth, specialDepthAccessors) =
|
|
|
112
112
|
return new Set(extractedVariables);
|
|
113
113
|
};
|
|
114
114
|
|
|
115
|
-
/**
|
|
116
|
-
* Deconstructs a path expression tree into an array of components.
|
|
117
|
-
*
|
|
118
|
-
* @param {Object} root - The root node of the path expression tree.
|
|
119
|
-
* @returns {Array<string>} An array of components in the path expression, in the correct order.
|
|
115
|
+
/**
|
|
116
|
+
* Deconstructs a path expression tree into an array of components.
|
|
117
|
+
*
|
|
118
|
+
* @param {Object} root - The root node of the path expression tree.
|
|
119
|
+
* @returns {Array<string>} An array of components in the path expression, in the correct order.
|
|
120
120
|
*/
|
|
121
121
|
const _deconstructPathExpression = root => {
|
|
122
122
|
let node = root;
|
|
@@ -135,13 +135,13 @@ const _deconstructPathExpression = root => {
|
|
|
135
135
|
return parts.reverse();
|
|
136
136
|
};
|
|
137
137
|
|
|
138
|
-
/**
|
|
139
|
-
* Builds a simplified feel structure tree from the given parse tree and feel string.
|
|
140
|
-
* The nodes follow this structure: `{ name: string, children: Array, variableName?: string }`
|
|
141
|
-
*
|
|
142
|
-
* @param {Object} parseTree - The parse tree generated by a parser.
|
|
143
|
-
* @param {string} feelString - The feel string used for parsing.
|
|
144
|
-
* @returns {Object} The simplified feel structure tree.
|
|
138
|
+
/**
|
|
139
|
+
* Builds a simplified feel structure tree from the given parse tree and feel string.
|
|
140
|
+
* The nodes follow this structure: `{ name: string, children: Array, variableName?: string }`
|
|
141
|
+
*
|
|
142
|
+
* @param {Object} parseTree - The parse tree generated by a parser.
|
|
143
|
+
* @param {string} feelString - The feel string used for parsing.
|
|
144
|
+
* @returns {Object} The simplified feel structure tree.
|
|
145
145
|
*/
|
|
146
146
|
const _buildSimpleFeelStructureTree = (parseTree, feelString) => {
|
|
147
147
|
const stack = [{
|
|
@@ -167,9 +167,9 @@ const _buildSimpleFeelStructureTree = (parseTree, feelString) => {
|
|
|
167
167
|
return _extractFilterExpressions(stack[0].children[0]);
|
|
168
168
|
};
|
|
169
169
|
|
|
170
|
-
/**
|
|
171
|
-
* Restructure the tree in such a way to bring filters (which create new contexts) to the root of the tree.
|
|
172
|
-
* This is done to simplify the extraction of variables and match the context hierarchy.
|
|
170
|
+
/**
|
|
171
|
+
* Restructure the tree in such a way to bring filters (which create new contexts) to the root of the tree.
|
|
172
|
+
* This is done to simplify the extraction of variables and match the context hierarchy.
|
|
173
173
|
*/
|
|
174
174
|
const _extractFilterExpressions = tree => {
|
|
175
175
|
const flattenedExpressionTree = {
|
|
@@ -210,25 +210,25 @@ class FeelExpressionLanguage {
|
|
|
210
210
|
this._eventBus = eventBus;
|
|
211
211
|
}
|
|
212
212
|
|
|
213
|
-
/**
|
|
214
|
-
* Determines if the given value is a FEEL expression.
|
|
215
|
-
*
|
|
216
|
-
* @param {any} value
|
|
217
|
-
* @returns {boolean}
|
|
218
|
-
*
|
|
213
|
+
/**
|
|
214
|
+
* Determines if the given value is a FEEL expression.
|
|
215
|
+
*
|
|
216
|
+
* @param {any} value
|
|
217
|
+
* @returns {boolean}
|
|
218
|
+
*
|
|
219
219
|
*/
|
|
220
220
|
isExpression(value) {
|
|
221
221
|
return isString(value) && value.startsWith('=');
|
|
222
222
|
}
|
|
223
223
|
|
|
224
|
-
/**
|
|
225
|
-
* Retrieve variable names from a given FEEL expression.
|
|
226
|
-
*
|
|
227
|
-
* @param {string} expression
|
|
228
|
-
* @param {object} [options]
|
|
229
|
-
* @param {string} [options.type]
|
|
230
|
-
*
|
|
231
|
-
* @returns {string[]}
|
|
224
|
+
/**
|
|
225
|
+
* Retrieve variable names from a given FEEL expression.
|
|
226
|
+
*
|
|
227
|
+
* @param {string} expression
|
|
228
|
+
* @param {object} [options]
|
|
229
|
+
* @param {string} [options.type]
|
|
230
|
+
*
|
|
231
|
+
* @returns {string[]}
|
|
232
232
|
*/
|
|
233
233
|
getVariableNames(expression, options = {}) {
|
|
234
234
|
const {
|
|
@@ -243,13 +243,13 @@ class FeelExpressionLanguage {
|
|
|
243
243
|
return getFlavouredFeelVariableNames(expression, type);
|
|
244
244
|
}
|
|
245
245
|
|
|
246
|
-
/**
|
|
247
|
-
* Evaluate an expression.
|
|
248
|
-
*
|
|
249
|
-
* @param {string} expression
|
|
250
|
-
* @param {import('../../types').Data} [data]
|
|
251
|
-
*
|
|
252
|
-
* @returns {any}
|
|
246
|
+
/**
|
|
247
|
+
* Evaluate an expression.
|
|
248
|
+
*
|
|
249
|
+
* @param {string} expression
|
|
250
|
+
* @param {import('../../types').Data} [data]
|
|
251
|
+
*
|
|
252
|
+
* @returns {any}
|
|
253
253
|
*/
|
|
254
254
|
evaluate(expression, data = {}) {
|
|
255
255
|
if (!expression) {
|
|
@@ -274,23 +274,23 @@ FeelExpressionLanguage.$inject = ['eventBus'];
|
|
|
274
274
|
class FeelersTemplating {
|
|
275
275
|
constructor() {}
|
|
276
276
|
|
|
277
|
-
/**
|
|
278
|
-
* Determines if the given value is a feelers template.
|
|
279
|
-
*
|
|
280
|
-
* @param {any} value
|
|
281
|
-
* @returns {boolean}
|
|
282
|
-
*
|
|
277
|
+
/**
|
|
278
|
+
* Determines if the given value is a feelers template.
|
|
279
|
+
*
|
|
280
|
+
* @param {any} value
|
|
281
|
+
* @returns {boolean}
|
|
282
|
+
*
|
|
283
283
|
*/
|
|
284
284
|
isTemplate(value) {
|
|
285
285
|
return isString(value) && (value.startsWith('=') || /{{.*?}}/.test(value));
|
|
286
286
|
}
|
|
287
287
|
|
|
288
|
-
/**
|
|
289
|
-
* Retrieve variable names from a given feelers template.
|
|
290
|
-
*
|
|
291
|
-
* @param {string} template
|
|
292
|
-
*
|
|
293
|
-
* @returns {string[]}
|
|
288
|
+
/**
|
|
289
|
+
* Retrieve variable names from a given feelers template.
|
|
290
|
+
*
|
|
291
|
+
* @param {string} template
|
|
292
|
+
*
|
|
293
|
+
* @returns {string[]}
|
|
294
294
|
*/
|
|
295
295
|
getVariableNames(template) {
|
|
296
296
|
if (!this.isTemplate(template)) {
|
|
@@ -316,17 +316,17 @@ class FeelersTemplating {
|
|
|
316
316
|
}, []);
|
|
317
317
|
}
|
|
318
318
|
|
|
319
|
-
/**
|
|
320
|
-
* Evaluate a template.
|
|
321
|
-
*
|
|
322
|
-
* @param {string} template
|
|
323
|
-
* @param {Object<string, any>} context
|
|
324
|
-
* @param {Object} options
|
|
325
|
-
* @param {boolean} [options.debug = false]
|
|
326
|
-
* @param {boolean} [options.strict = false]
|
|
327
|
-
* @param {Function} [options.buildDebugString]
|
|
328
|
-
*
|
|
329
|
-
* @returns
|
|
319
|
+
/**
|
|
320
|
+
* Evaluate a template.
|
|
321
|
+
*
|
|
322
|
+
* @param {string} template
|
|
323
|
+
* @param {Object<string, any>} context
|
|
324
|
+
* @param {Object} options
|
|
325
|
+
* @param {boolean} [options.debug = false]
|
|
326
|
+
* @param {boolean} [options.strict = false]
|
|
327
|
+
* @param {Function} [options.buildDebugString]
|
|
328
|
+
*
|
|
329
|
+
* @returns
|
|
330
330
|
*/
|
|
331
331
|
evaluate(template, context = {}, options = {}) {
|
|
332
332
|
const {
|
|
@@ -341,22 +341,22 @@ class FeelersTemplating {
|
|
|
341
341
|
});
|
|
342
342
|
}
|
|
343
343
|
|
|
344
|
-
/**
|
|
345
|
-
* @typedef {Object} ExpressionWithDepth
|
|
346
|
-
* @property {number} depth - The depth of the expression in the syntax tree.
|
|
347
|
-
* @property {string} expression - The extracted expression
|
|
344
|
+
/**
|
|
345
|
+
* @typedef {Object} ExpressionWithDepth
|
|
346
|
+
* @property {number} depth - The depth of the expression in the syntax tree.
|
|
347
|
+
* @property {string} expression - The extracted expression
|
|
348
348
|
*/
|
|
349
349
|
|
|
350
|
-
/**
|
|
351
|
-
* Extracts all feel expressions in the template along with their depth in the syntax tree.
|
|
352
|
-
* The depth is incremented for child expressions of loops to account for context drilling.
|
|
353
|
-
|
|
354
|
-
* @param {string} template - A feelers template string.
|
|
355
|
-
* @returns {Array<ExpressionWithDepth>} An array of objects, each containing the depth and the extracted expression.
|
|
356
|
-
*
|
|
357
|
-
* @example
|
|
358
|
-
* const template = "Hello {{user}}, you have:{{#loop items}}\n- {{amount}} {{name}}{{/loop}}.";
|
|
359
|
-
* const extractedExpressions = _extractExpressionsWithDepth(template);
|
|
350
|
+
/**
|
|
351
|
+
* Extracts all feel expressions in the template along with their depth in the syntax tree.
|
|
352
|
+
* The depth is incremented for child expressions of loops to account for context drilling.
|
|
353
|
+
* @name extractExpressionsWithDepth
|
|
354
|
+
* @param {string} template - A feelers template string.
|
|
355
|
+
* @returns {Array<ExpressionWithDepth>} An array of objects, each containing the depth and the extracted expression.
|
|
356
|
+
*
|
|
357
|
+
* @example
|
|
358
|
+
* const template = "Hello {{user}}, you have:{{#loop items}}\n- {{amount}} {{name}}{{/loop}}.";
|
|
359
|
+
* const extractedExpressions = _extractExpressionsWithDepth(template);
|
|
360
360
|
*/
|
|
361
361
|
_extractExpressionsWithDepth(template) {
|
|
362
362
|
// build simplified feelers syntax tree
|
|
@@ -462,10 +462,10 @@ function createInjector(bootstrapModules) {
|
|
|
462
462
|
return injector;
|
|
463
463
|
}
|
|
464
464
|
|
|
465
|
-
/**
|
|
466
|
-
* @param {string?} prefix
|
|
467
|
-
*
|
|
468
|
-
* @returns Element
|
|
465
|
+
/**
|
|
466
|
+
* @param {string?} prefix
|
|
467
|
+
*
|
|
468
|
+
* @returns Element
|
|
469
469
|
*/
|
|
470
470
|
function createFormContainer(prefix = 'fjs') {
|
|
471
471
|
const container = document.createElement('div');
|
|
@@ -502,22 +502,22 @@ function generateIdForType(type) {
|
|
|
502
502
|
return `${type}${generateIndexForType(type)}`;
|
|
503
503
|
}
|
|
504
504
|
|
|
505
|
-
/**
|
|
506
|
-
* @template T
|
|
507
|
-
* @param {T} data
|
|
508
|
-
* @param {(this: any, key: string, value: any) => any} [replacer]
|
|
509
|
-
* @return {T}
|
|
505
|
+
/**
|
|
506
|
+
* @template T
|
|
507
|
+
* @param {T} data
|
|
508
|
+
* @param {(this: any, key: string, value: any) => any} [replacer]
|
|
509
|
+
* @return {T}
|
|
510
510
|
*/
|
|
511
511
|
function clone(data, replacer) {
|
|
512
512
|
return JSON.parse(JSON.stringify(data, replacer));
|
|
513
513
|
}
|
|
514
514
|
|
|
515
|
-
/**
|
|
516
|
-
* Parse the schema for input variables a form might make use of
|
|
517
|
-
*
|
|
518
|
-
* @param {any} schema
|
|
519
|
-
*
|
|
520
|
-
* @return {string[]}
|
|
515
|
+
/**
|
|
516
|
+
* Parse the schema for input variables a form might make use of
|
|
517
|
+
*
|
|
518
|
+
* @param {any} schema
|
|
519
|
+
*
|
|
520
|
+
* @return {string[]}
|
|
521
521
|
*/
|
|
522
522
|
function getSchemaVariables(schema, options = {}) {
|
|
523
523
|
const {
|
|
@@ -602,9 +602,9 @@ function runRecursively(formField, fn) {
|
|
|
602
602
|
fn(formField);
|
|
603
603
|
}
|
|
604
604
|
|
|
605
|
-
/**
|
|
606
|
-
* @typedef {object} Condition
|
|
607
|
-
* @property {string} [hide]
|
|
605
|
+
/**
|
|
606
|
+
* @typedef {object} Condition
|
|
607
|
+
* @property {string} [hide]
|
|
608
608
|
*/
|
|
609
609
|
|
|
610
610
|
class ConditionChecker {
|
|
@@ -614,14 +614,19 @@ class ConditionChecker {
|
|
|
614
614
|
this._eventBus = eventBus;
|
|
615
615
|
}
|
|
616
616
|
|
|
617
|
-
/**
|
|
618
|
-
* For given data, remove properties based on condition.
|
|
619
|
-
*
|
|
620
|
-
* @param {Object<string, any>} properties
|
|
621
|
-
* @param {Object<string, any>} data
|
|
617
|
+
/**
|
|
618
|
+
* For given data, remove properties based on condition.
|
|
619
|
+
*
|
|
620
|
+
* @param {Object<string, any>} properties
|
|
621
|
+
* @param {Object<string, any>} data
|
|
622
|
+
* @param {Object} [options]
|
|
623
|
+
* @param {Function} [options.getFilterPath]
|
|
622
624
|
*/
|
|
623
|
-
applyConditions(properties, data = {}) {
|
|
625
|
+
applyConditions(properties, data = {}, options = {}) {
|
|
624
626
|
const newProperties = clone(properties);
|
|
627
|
+
const {
|
|
628
|
+
getFilterPath = field => this._pathRegistry.getValuePath(field)
|
|
629
|
+
} = options;
|
|
625
630
|
const form = this._formFieldRegistry.getAll().find(field => field.type === 'default');
|
|
626
631
|
if (!form) {
|
|
627
632
|
throw new Error('form field registry has no form');
|
|
@@ -638,20 +643,19 @@ class ConditionChecker {
|
|
|
638
643
|
|
|
639
644
|
// only clear the leaf nodes, as groups may both point to the same path
|
|
640
645
|
if (context.isHidden && isClosed) {
|
|
641
|
-
|
|
642
|
-
this._clearObjectValueRecursively(valuePath, newProperties);
|
|
646
|
+
this._clearObjectValueRecursively(getFilterPath(field), newProperties);
|
|
643
647
|
}
|
|
644
648
|
});
|
|
645
649
|
return newProperties;
|
|
646
650
|
}
|
|
647
651
|
|
|
648
|
-
/**
|
|
649
|
-
* Check if given condition is met. Returns null for invalid/missing conditions.
|
|
650
|
-
*
|
|
651
|
-
* @param {string} condition
|
|
652
|
-
* @param {import('../../types').Data} [data]
|
|
653
|
-
*
|
|
654
|
-
* @returns {boolean|null}
|
|
652
|
+
/**
|
|
653
|
+
* Check if given condition is met. Returns null for invalid/missing conditions.
|
|
654
|
+
*
|
|
655
|
+
* @param {string} condition
|
|
656
|
+
* @param {import('../../types').Data} [data]
|
|
657
|
+
*
|
|
658
|
+
* @returns {boolean|null}
|
|
655
659
|
*/
|
|
656
660
|
check(condition, data = {}) {
|
|
657
661
|
if (!condition) {
|
|
@@ -672,12 +676,12 @@ class ConditionChecker {
|
|
|
672
676
|
}
|
|
673
677
|
}
|
|
674
678
|
|
|
675
|
-
/**
|
|
676
|
-
* Check if hide condition is met.
|
|
677
|
-
*
|
|
678
|
-
* @param {Condition} condition
|
|
679
|
-
* @param {Object<string, any>} data
|
|
680
|
-
* @returns {boolean}
|
|
679
|
+
/**
|
|
680
|
+
* Check if hide condition is met.
|
|
681
|
+
*
|
|
682
|
+
* @param {Condition} condition
|
|
683
|
+
* @param {Object<string, any>} data
|
|
684
|
+
* @returns {boolean}
|
|
681
685
|
*/
|
|
682
686
|
_checkHideCondition(condition, data) {
|
|
683
687
|
if (!condition.hide) {
|
|
@@ -713,12 +717,12 @@ class MarkdownRenderer {
|
|
|
713
717
|
this._converter = new showdown.Converter();
|
|
714
718
|
}
|
|
715
719
|
|
|
716
|
-
/**
|
|
717
|
-
* Render markdown to HTML.
|
|
718
|
-
*
|
|
719
|
-
* @param {string} markdown - The markdown to render
|
|
720
|
-
*
|
|
721
|
-
* @returns {string} HTML
|
|
720
|
+
/**
|
|
721
|
+
* Render markdown to HTML.
|
|
722
|
+
*
|
|
723
|
+
* @param {string} markdown - The markdown to render
|
|
724
|
+
*
|
|
725
|
+
* @returns {string} HTML
|
|
722
726
|
*/
|
|
723
727
|
render(markdown) {
|
|
724
728
|
return this._converter.makeHtml(markdown);
|
|
@@ -1866,8 +1870,8 @@ Validator.$inject = ['expressionLanguage', 'conditionChecker', 'form'];
|
|
|
1866
1870
|
|
|
1867
1871
|
// helpers //////////
|
|
1868
1872
|
|
|
1869
|
-
/**
|
|
1870
|
-
* Helper function to evaluate optional FEEL validation values.
|
|
1873
|
+
/**
|
|
1874
|
+
* Helper function to evaluate optional FEEL validation values.
|
|
1871
1875
|
*/
|
|
1872
1876
|
function evaluateFEELValues(validate, expressionLanguage, conditionChecker, form) {
|
|
1873
1877
|
const evaluatedValidate = {
|
|
@@ -1901,12 +1905,12 @@ function evaluateFEELValues(validate, expressionLanguage, conditionChecker, form
|
|
|
1901
1905
|
}
|
|
1902
1906
|
|
|
1903
1907
|
class Importer {
|
|
1904
|
-
/**
|
|
1905
|
-
* @constructor
|
|
1906
|
-
* @param { import('./FormFieldRegistry').default } formFieldRegistry
|
|
1907
|
-
* @param { import('./PathRegistry').default } pathRegistry
|
|
1908
|
-
* @param { import('./FieldFactory').default } fieldFactory
|
|
1909
|
-
* @param { import('./FormLayouter').default } formLayouter
|
|
1908
|
+
/**
|
|
1909
|
+
* @constructor
|
|
1910
|
+
* @param { import('./FormFieldRegistry').default } formFieldRegistry
|
|
1911
|
+
* @param { import('./PathRegistry').default } pathRegistry
|
|
1912
|
+
* @param { import('./FieldFactory').default } fieldFactory
|
|
1913
|
+
* @param { import('./FormLayouter').default } formLayouter
|
|
1910
1914
|
*/
|
|
1911
1915
|
constructor(formFieldRegistry, pathRegistry, fieldFactory, formLayouter) {
|
|
1912
1916
|
this._formFieldRegistry = formFieldRegistry;
|
|
@@ -1915,21 +1919,21 @@ class Importer {
|
|
|
1915
1919
|
this._formLayouter = formLayouter;
|
|
1916
1920
|
}
|
|
1917
1921
|
|
|
1918
|
-
/**
|
|
1919
|
-
* Import schema creating rows, fields, attaching additional
|
|
1920
|
-
* information to each field and adding fields to the
|
|
1921
|
-
* field registry.
|
|
1922
|
-
*
|
|
1923
|
-
* Additional information attached:
|
|
1924
|
-
*
|
|
1925
|
-
* * `id` (unless present)
|
|
1926
|
-
* * `_parent`
|
|
1927
|
-
* * `_path`
|
|
1928
|
-
*
|
|
1929
|
-
* @param {any} schema
|
|
1930
|
-
*
|
|
1931
|
-
* @typedef {{ warnings: Error[], schema: any }} ImportResult
|
|
1932
|
-
* @returns {ImportResult}
|
|
1922
|
+
/**
|
|
1923
|
+
* Import schema creating rows, fields, attaching additional
|
|
1924
|
+
* information to each field and adding fields to the
|
|
1925
|
+
* field registry.
|
|
1926
|
+
*
|
|
1927
|
+
* Additional information attached:
|
|
1928
|
+
*
|
|
1929
|
+
* * `id` (unless present)
|
|
1930
|
+
* * `_parent`
|
|
1931
|
+
* * `_path`
|
|
1932
|
+
*
|
|
1933
|
+
* @param {any} schema
|
|
1934
|
+
*
|
|
1935
|
+
* @typedef {{ warnings: Error[], schema: any }} ImportResult
|
|
1936
|
+
* @returns {ImportResult}
|
|
1933
1937
|
*/
|
|
1934
1938
|
importSchema(schema) {
|
|
1935
1939
|
// TODO: Add warnings
|
|
@@ -1954,12 +1958,12 @@ class Importer {
|
|
|
1954
1958
|
this._pathRegistry.clear();
|
|
1955
1959
|
}
|
|
1956
1960
|
|
|
1957
|
-
/**
|
|
1958
|
-
* @param {{[x: string]: any}} fieldAttrs
|
|
1959
|
-
* @param {String} [parentId]
|
|
1960
|
-
* @param {number} [index]
|
|
1961
|
-
*
|
|
1962
|
-
* @return {any} field
|
|
1961
|
+
/**
|
|
1962
|
+
* @param {{[x: string]: any}} fieldAttrs
|
|
1963
|
+
* @param {String} [parentId]
|
|
1964
|
+
* @param {number} [index]
|
|
1965
|
+
*
|
|
1966
|
+
* @return {any} field
|
|
1963
1967
|
*/
|
|
1964
1968
|
importFormField(fieldAttrs, parentId, index) {
|
|
1965
1969
|
const {
|
|
@@ -1984,11 +1988,11 @@ class Importer {
|
|
|
1984
1988
|
return field;
|
|
1985
1989
|
}
|
|
1986
1990
|
|
|
1987
|
-
/**
|
|
1988
|
-
* @param {Array<any>} components
|
|
1989
|
-
* @param {string} parentId
|
|
1990
|
-
*
|
|
1991
|
-
* @return {Array<any>} imported components
|
|
1991
|
+
/**
|
|
1992
|
+
* @param {Array<any>} components
|
|
1993
|
+
* @param {string} parentId
|
|
1994
|
+
*
|
|
1995
|
+
* @return {Array<any>} imported components
|
|
1992
1996
|
*/
|
|
1993
1997
|
importFormFields(components, parentId) {
|
|
1994
1998
|
return components.map((component, index) => {
|
|
@@ -1999,11 +2003,11 @@ class Importer {
|
|
|
1999
2003
|
Importer.$inject = ['formFieldRegistry', 'pathRegistry', 'fieldFactory', 'formLayouter'];
|
|
2000
2004
|
|
|
2001
2005
|
class FieldFactory {
|
|
2002
|
-
/**
|
|
2003
|
-
* @constructor
|
|
2004
|
-
*
|
|
2005
|
-
* @param formFieldRegistry
|
|
2006
|
-
* @param formFields
|
|
2006
|
+
/**
|
|
2007
|
+
* @constructor
|
|
2008
|
+
*
|
|
2009
|
+
* @param formFieldRegistry
|
|
2010
|
+
* @param formFields
|
|
2007
2011
|
*/
|
|
2008
2012
|
constructor(formFieldRegistry, pathRegistry, formFields) {
|
|
2009
2013
|
this._formFieldRegistry = formFieldRegistry;
|
|
@@ -2085,36 +2089,36 @@ class FieldFactory {
|
|
|
2085
2089
|
}
|
|
2086
2090
|
FieldFactory.$inject = ['formFieldRegistry', 'pathRegistry', 'formFields'];
|
|
2087
2091
|
|
|
2088
|
-
/**
|
|
2089
|
-
* The PathRegistry class manages a hierarchical structure of paths associated with form fields.
|
|
2090
|
-
* It enables claiming, unclaiming, and validating paths within this structure.
|
|
2091
|
-
*
|
|
2092
|
-
* Example Tree Structure:
|
|
2093
|
-
*
|
|
2094
|
-
* [
|
|
2095
|
-
* {
|
|
2096
|
-
* segment: 'root',
|
|
2097
|
-
* claimCount: 1,
|
|
2098
|
-
* children: [
|
|
2099
|
-
* {
|
|
2100
|
-
* segment: 'child1',
|
|
2101
|
-
* claimCount: 2,
|
|
2102
|
-
* children: null // A leaf node (closed path)
|
|
2103
|
-
* },
|
|
2104
|
-
* {
|
|
2105
|
-
* segment: 'child2',
|
|
2106
|
-
* claimCount: 1,
|
|
2107
|
-
* children: [
|
|
2108
|
-
* {
|
|
2109
|
-
* segment: 'subChild1',
|
|
2110
|
-
* claimCount: 1,
|
|
2111
|
-
* children: [] // An open node (open path)
|
|
2112
|
-
* }
|
|
2113
|
-
* ]
|
|
2114
|
-
* }
|
|
2115
|
-
* ]
|
|
2116
|
-
* }
|
|
2117
|
-
* ]
|
|
2092
|
+
/**
|
|
2093
|
+
* The PathRegistry class manages a hierarchical structure of paths associated with form fields.
|
|
2094
|
+
* It enables claiming, unclaiming, and validating paths within this structure.
|
|
2095
|
+
*
|
|
2096
|
+
* Example Tree Structure:
|
|
2097
|
+
*
|
|
2098
|
+
* [
|
|
2099
|
+
* {
|
|
2100
|
+
* segment: 'root',
|
|
2101
|
+
* claimCount: 1,
|
|
2102
|
+
* children: [
|
|
2103
|
+
* {
|
|
2104
|
+
* segment: 'child1',
|
|
2105
|
+
* claimCount: 2,
|
|
2106
|
+
* children: null // A leaf node (closed path)
|
|
2107
|
+
* },
|
|
2108
|
+
* {
|
|
2109
|
+
* segment: 'child2',
|
|
2110
|
+
* claimCount: 1,
|
|
2111
|
+
* children: [
|
|
2112
|
+
* {
|
|
2113
|
+
* segment: 'subChild1',
|
|
2114
|
+
* claimCount: 1,
|
|
2115
|
+
* children: [] // An open node (open path)
|
|
2116
|
+
* }
|
|
2117
|
+
* ]
|
|
2118
|
+
* }
|
|
2119
|
+
* ]
|
|
2120
|
+
* }
|
|
2121
|
+
* ]
|
|
2118
2122
|
*/
|
|
2119
2123
|
class PathRegistry {
|
|
2120
2124
|
constructor(formFieldRegistry, formFields) {
|
|
@@ -2197,16 +2201,16 @@ class PathRegistry {
|
|
|
2197
2201
|
}
|
|
2198
2202
|
}
|
|
2199
2203
|
|
|
2200
|
-
/**
|
|
2201
|
-
* Applies a function (fn) recursively on a given field and its children.
|
|
2202
|
-
*
|
|
2203
|
-
* - `field`: Starting field object.
|
|
2204
|
-
* - `fn`: Function to apply.
|
|
2205
|
-
* - `context`: Optional object for passing data between calls.
|
|
2206
|
-
*
|
|
2207
|
-
* Stops early if `fn` returns `false`. Useful for traversing the form field tree.
|
|
2208
|
-
*
|
|
2209
|
-
* @returns {boolean} Success status based on function execution.
|
|
2204
|
+
/**
|
|
2205
|
+
* Applies a function (fn) recursively on a given field and its children.
|
|
2206
|
+
*
|
|
2207
|
+
* - `field`: Starting field object.
|
|
2208
|
+
* - `fn`: Function to apply.
|
|
2209
|
+
* - `context`: Optional object for passing data between calls.
|
|
2210
|
+
*
|
|
2211
|
+
* Stops early if `fn` returns `false`. Useful for traversing the form field tree.
|
|
2212
|
+
*
|
|
2213
|
+
* @returns {boolean} Success status based on function execution.
|
|
2210
2214
|
*/
|
|
2211
2215
|
executeRecursivelyOnFields(field, fn, context = {}) {
|
|
2212
2216
|
let result = true;
|
|
@@ -2240,15 +2244,15 @@ class PathRegistry {
|
|
|
2240
2244
|
return result;
|
|
2241
2245
|
}
|
|
2242
2246
|
|
|
2243
|
-
/**
|
|
2244
|
-
* Generates an array representing the binding path to an underlying data object for a form field.
|
|
2245
|
-
*
|
|
2246
|
-
* @param {Object} field - The field object with properties: `key`, `path`, `id`, and optionally `_parent`.
|
|
2247
|
-
* @param {Object} [options={}] - Configuration options.
|
|
2248
|
-
* @param {Object} [options.replacements={}] - A map of field IDs to alternative path arrays.
|
|
2249
|
-
* @param {Object} [options.cutoffNode] - The ID of the parent field at which to stop generating the path.
|
|
2250
|
-
*
|
|
2251
|
-
* @returns {(Array<string>|undefined)} An array of strings representing the binding path, or undefined if not determinable.
|
|
2247
|
+
/**
|
|
2248
|
+
* Generates an array representing the binding path to an underlying data object for a form field.
|
|
2249
|
+
*
|
|
2250
|
+
* @param {Object} field - The field object with properties: `key`, `path`, `id`, and optionally `_parent`.
|
|
2251
|
+
* @param {Object} [options={}] - Configuration options.
|
|
2252
|
+
* @param {Object} [options.replacements={}] - A map of field IDs to alternative path arrays.
|
|
2253
|
+
* @param {Object} [options.cutoffNode] - The ID of the parent field at which to stop generating the path.
|
|
2254
|
+
*
|
|
2255
|
+
* @returns {(Array<string>|undefined)} An array of strings representing the binding path, or undefined if not determinable.
|
|
2252
2256
|
*/
|
|
2253
2257
|
getValuePath(field, options = {}) {
|
|
2254
2258
|
const {
|
|
@@ -2292,23 +2296,23 @@ const _getNextSegment = (node, segment) => {
|
|
|
2292
2296
|
};
|
|
2293
2297
|
PathRegistry.$inject = ['formFieldRegistry', 'formFields'];
|
|
2294
2298
|
|
|
2295
|
-
/**
|
|
2296
|
-
* @typedef { { id: String, components: Array<String> } } FormRow
|
|
2297
|
-
* @typedef { { formFieldId: String, rows: Array<FormRow> } } FormRows
|
|
2299
|
+
/**
|
|
2300
|
+
* @typedef { { id: String, components: Array<String> } } FormRow
|
|
2301
|
+
* @typedef { { formFieldId: String, rows: Array<FormRow> } } FormRows
|
|
2298
2302
|
*/
|
|
2299
2303
|
|
|
2300
|
-
/**
|
|
2301
|
-
* Maintains the Form layout in a given structure, for example
|
|
2302
|
-
*
|
|
2303
|
-
* [
|
|
2304
|
-
* {
|
|
2305
|
-
* formFieldId: 'FormField_1',
|
|
2306
|
-
* rows: [
|
|
2307
|
-
* { id: 'Row_1', components: [ 'Text_1', 'Textdield_1', ... ] }
|
|
2308
|
-
* ]
|
|
2309
|
-
* }
|
|
2310
|
-
* ]
|
|
2311
|
-
*
|
|
2304
|
+
/**
|
|
2305
|
+
* Maintains the Form layout in a given structure, for example
|
|
2306
|
+
*
|
|
2307
|
+
* [
|
|
2308
|
+
* {
|
|
2309
|
+
* formFieldId: 'FormField_1',
|
|
2310
|
+
* rows: [
|
|
2311
|
+
* { id: 'Row_1', components: [ 'Text_1', 'Textdield_1', ... ] }
|
|
2312
|
+
* ]
|
|
2313
|
+
* }
|
|
2314
|
+
* ]
|
|
2315
|
+
*
|
|
2312
2316
|
*/
|
|
2313
2317
|
class FormLayouter {
|
|
2314
2318
|
constructor(eventBus) {
|
|
@@ -2318,8 +2322,8 @@ class FormLayouter {
|
|
|
2318
2322
|
this._eventBus = eventBus;
|
|
2319
2323
|
}
|
|
2320
2324
|
|
|
2321
|
-
/**
|
|
2322
|
-
* @param {FormRow} row
|
|
2325
|
+
/**
|
|
2326
|
+
* @param {FormRow} row
|
|
2323
2327
|
*/
|
|
2324
2328
|
addRow(formFieldId, row) {
|
|
2325
2329
|
let rowsPerComponent = this._rows.find(r => r.formFieldId === formFieldId);
|
|
@@ -2333,18 +2337,18 @@ class FormLayouter {
|
|
|
2333
2337
|
rowsPerComponent.rows.push(row);
|
|
2334
2338
|
}
|
|
2335
2339
|
|
|
2336
|
-
/**
|
|
2337
|
-
* @param {String} id
|
|
2338
|
-
* @returns {FormRow}
|
|
2340
|
+
/**
|
|
2341
|
+
* @param {String} id
|
|
2342
|
+
* @returns {FormRow}
|
|
2339
2343
|
*/
|
|
2340
2344
|
getRow(id) {
|
|
2341
2345
|
const rows = allRows(this._rows);
|
|
2342
2346
|
return rows.find(r => r.id === id);
|
|
2343
2347
|
}
|
|
2344
2348
|
|
|
2345
|
-
/**
|
|
2346
|
-
* @param {any} formField
|
|
2347
|
-
* @returns {FormRow}
|
|
2349
|
+
/**
|
|
2350
|
+
* @param {any} formField
|
|
2351
|
+
* @returns {FormRow}
|
|
2348
2352
|
*/
|
|
2349
2353
|
getRowForField(formField) {
|
|
2350
2354
|
return allRows(this._rows).find(r => {
|
|
@@ -2355,9 +2359,9 @@ class FormLayouter {
|
|
|
2355
2359
|
});
|
|
2356
2360
|
}
|
|
2357
2361
|
|
|
2358
|
-
/**
|
|
2359
|
-
* @param {String} formFieldId
|
|
2360
|
-
* @returns { Array<FormRow> }
|
|
2362
|
+
/**
|
|
2363
|
+
* @param {String} formFieldId
|
|
2364
|
+
* @returns { Array<FormRow> }
|
|
2361
2365
|
*/
|
|
2362
2366
|
getRows(formFieldId) {
|
|
2363
2367
|
const rowsForField = this._rows.find(r => formFieldId === r.formFieldId);
|
|
@@ -2367,15 +2371,15 @@ class FormLayouter {
|
|
|
2367
2371
|
return rowsForField.rows;
|
|
2368
2372
|
}
|
|
2369
2373
|
|
|
2370
|
-
/**
|
|
2371
|
-
* @returns {string}
|
|
2374
|
+
/**
|
|
2375
|
+
* @returns {string}
|
|
2372
2376
|
*/
|
|
2373
2377
|
nextRowId() {
|
|
2374
2378
|
return this._ids.nextPrefixed('Row_');
|
|
2375
2379
|
}
|
|
2376
2380
|
|
|
2377
|
-
/**
|
|
2378
|
-
* @param {any} formField
|
|
2381
|
+
/**
|
|
2382
|
+
* @param {any} formField
|
|
2379
2383
|
*/
|
|
2380
2384
|
calculateLayout(formField) {
|
|
2381
2385
|
const {
|
|
@@ -2429,9 +2433,9 @@ function groupByRow(components, ids) {
|
|
|
2429
2433
|
});
|
|
2430
2434
|
}
|
|
2431
2435
|
|
|
2432
|
-
/**
|
|
2433
|
-
* @param {Array<FormRows>} formRows
|
|
2434
|
-
* @returns {Array<FormRow>}
|
|
2436
|
+
/**
|
|
2437
|
+
* @param {Array<FormRows>} formRows
|
|
2438
|
+
* @returns {Array<FormRow>}
|
|
2435
2439
|
*/
|
|
2436
2440
|
function allRows(formRows) {
|
|
2437
2441
|
return flatten(formRows.map(c => c.rows));
|
|
@@ -2587,11 +2591,11 @@ const FormRenderContext = createContext({
|
|
|
2587
2591
|
});
|
|
2588
2592
|
var FormRenderContext$1 = FormRenderContext;
|
|
2589
2593
|
|
|
2590
|
-
/**
|
|
2591
|
-
* @param {string} type
|
|
2592
|
-
* @param {boolean} [strict]
|
|
2593
|
-
*
|
|
2594
|
-
* @returns {any}
|
|
2594
|
+
/**
|
|
2595
|
+
* @param {string} type
|
|
2596
|
+
* @param {boolean} [strict]
|
|
2597
|
+
*
|
|
2598
|
+
* @returns {any}
|
|
2595
2599
|
*/
|
|
2596
2600
|
function getService(type, strict) {}
|
|
2597
2601
|
const FormContext = createContext({
|
|
@@ -2607,10 +2611,10 @@ function useService(type, strict) {
|
|
|
2607
2611
|
return getService(type, strict);
|
|
2608
2612
|
}
|
|
2609
2613
|
|
|
2610
|
-
/**
|
|
2611
|
-
* Returns the conditionally filtered data of a form reactively.
|
|
2612
|
-
* Memoised to minimize re-renders
|
|
2613
|
-
*
|
|
2614
|
+
/**
|
|
2615
|
+
* Returns the conditionally filtered data of a form reactively.
|
|
2616
|
+
* Memoised to minimize re-renders
|
|
2617
|
+
*
|
|
2614
2618
|
*/
|
|
2615
2619
|
function useFilteredFormData() {
|
|
2616
2620
|
const {
|
|
@@ -2627,12 +2631,12 @@ function useFilteredFormData() {
|
|
|
2627
2631
|
}, [conditionChecker, data, initialData]);
|
|
2628
2632
|
}
|
|
2629
2633
|
|
|
2630
|
-
/**
|
|
2631
|
-
* Evaluate if condition is met reactively based on the conditionChecker and form data.
|
|
2632
|
-
*
|
|
2633
|
-
* @param {string | undefined} condition
|
|
2634
|
-
*
|
|
2635
|
-
* @returns {boolean} true if condition is met or no condition or condition checker exists
|
|
2634
|
+
/**
|
|
2635
|
+
* Evaluate if condition is met reactively based on the conditionChecker and form data.
|
|
2636
|
+
*
|
|
2637
|
+
* @param {string | undefined} condition
|
|
2638
|
+
*
|
|
2639
|
+
* @returns {boolean} true if condition is met or no condition or condition checker exists
|
|
2636
2640
|
*/
|
|
2637
2641
|
function useCondition(condition) {
|
|
2638
2642
|
const conditionChecker = useService('conditionChecker', false);
|
|
@@ -2642,13 +2646,13 @@ function useCondition(condition) {
|
|
|
2642
2646
|
}, [conditionChecker, condition, filteredData]);
|
|
2643
2647
|
}
|
|
2644
2648
|
|
|
2645
|
-
/**
|
|
2646
|
-
* Evaluate a string reactively based on the expressionLanguage and form data.
|
|
2647
|
-
* If the string is not an expression, it is returned as is.
|
|
2648
|
-
* Memoised to minimize re-renders.
|
|
2649
|
-
*
|
|
2650
|
-
* @param {string} value
|
|
2651
|
-
*
|
|
2649
|
+
/**
|
|
2650
|
+
* Evaluate a string reactively based on the expressionLanguage and form data.
|
|
2651
|
+
* If the string is not an expression, it is returned as is.
|
|
2652
|
+
* Memoised to minimize re-renders.
|
|
2653
|
+
*
|
|
2654
|
+
* @param {string} value
|
|
2655
|
+
*
|
|
2652
2656
|
*/
|
|
2653
2657
|
function useExpressionEvaluation(value) {
|
|
2654
2658
|
const formData = useFilteredFormData();
|
|
@@ -2677,16 +2681,16 @@ function useKeyDownAction(targetKey, action, listenerElement = window) {
|
|
|
2677
2681
|
});
|
|
2678
2682
|
}
|
|
2679
2683
|
|
|
2680
|
-
/**
|
|
2681
|
-
* Retrieve readonly value of a form field, given it can be an
|
|
2682
|
-
* expression optionally or configured globally.
|
|
2683
|
-
*
|
|
2684
|
-
* @typedef { import('../../types').FormProperties } FormProperties
|
|
2685
|
-
*
|
|
2686
|
-
* @param {any} formField
|
|
2687
|
-
* @param {FormProperties} properties
|
|
2688
|
-
*
|
|
2689
|
-
* @returns {boolean}
|
|
2684
|
+
/**
|
|
2685
|
+
* Retrieve readonly value of a form field, given it can be an
|
|
2686
|
+
* expression optionally or configured globally.
|
|
2687
|
+
*
|
|
2688
|
+
* @typedef { import('../../types').FormProperties } FormProperties
|
|
2689
|
+
*
|
|
2690
|
+
* @param {any} formField
|
|
2691
|
+
* @param {FormProperties} properties
|
|
2692
|
+
*
|
|
2693
|
+
* @returns {boolean}
|
|
2690
2694
|
*/
|
|
2691
2695
|
function useReadonly(formField, properties = {}) {
|
|
2692
2696
|
const expressionLanguage = useService('expressionLanguage');
|
|
@@ -2710,12 +2714,12 @@ function usePrevious(value, defaultValue, dependencies) {
|
|
|
2710
2714
|
return ref.current;
|
|
2711
2715
|
}
|
|
2712
2716
|
|
|
2713
|
-
/**
|
|
2714
|
-
* A custom hook to manage state changes with deep comparison.
|
|
2715
|
-
*
|
|
2716
|
-
* @param {any} value - The current value to manage.
|
|
2717
|
-
* @param {any} defaultValue - The initial default value for the state.
|
|
2718
|
-
* @returns {any} - Returns the current state.
|
|
2717
|
+
/**
|
|
2718
|
+
* A custom hook to manage state changes with deep comparison.
|
|
2719
|
+
*
|
|
2720
|
+
* @param {any} value - The current value to manage.
|
|
2721
|
+
* @param {any} defaultValue - The initial default value for the state.
|
|
2722
|
+
* @returns {any} - Returns the current state.
|
|
2719
2723
|
*/
|
|
2720
2724
|
function useDeepCompareState(value, defaultValue) {
|
|
2721
2725
|
const [state, setState] = useState(defaultValue);
|
|
@@ -2735,16 +2739,16 @@ function compare(a, b) {
|
|
|
2735
2739
|
return JSON.stringify(a) === JSON.stringify(b);
|
|
2736
2740
|
}
|
|
2737
2741
|
|
|
2738
|
-
/**
|
|
2739
|
-
* Template a string reactively based on form data. If the string is not a template, it is returned as is.
|
|
2740
|
-
* Memoised to minimize re-renders
|
|
2741
|
-
*
|
|
2742
|
-
* @param {string} value
|
|
2743
|
-
* @param {Object} options
|
|
2744
|
-
* @param {boolean} [options.debug = false]
|
|
2745
|
-
* @param {boolean} [options.strict = false]
|
|
2746
|
-
* @param {Function} [options.buildDebugString]
|
|
2747
|
-
*
|
|
2742
|
+
/**
|
|
2743
|
+
* Template a string reactively based on form data. If the string is not a template, it is returned as is.
|
|
2744
|
+
* Memoised to minimize re-renders
|
|
2745
|
+
*
|
|
2746
|
+
* @param {string} value
|
|
2747
|
+
* @param {Object} options
|
|
2748
|
+
* @param {boolean} [options.debug = false]
|
|
2749
|
+
* @param {boolean} [options.strict = false]
|
|
2750
|
+
* @param {Function} [options.buildDebugString]
|
|
2751
|
+
*
|
|
2748
2752
|
*/
|
|
2749
2753
|
function useTemplateEvaluation(value, options) {
|
|
2750
2754
|
const filteredData = useFilteredFormData();
|
|
@@ -2757,17 +2761,17 @@ function useTemplateEvaluation(value, options) {
|
|
|
2757
2761
|
}, [filteredData, templating, value, options]);
|
|
2758
2762
|
}
|
|
2759
2763
|
|
|
2760
|
-
/**
|
|
2761
|
-
* Template a string reactively based on form data. If the string is not a template, it is returned as is.
|
|
2762
|
-
* If the string contains multiple lines, only the first line is returned.
|
|
2763
|
-
* Memoised to minimize re-renders
|
|
2764
|
-
*
|
|
2765
|
-
* @param {string} value
|
|
2766
|
-
* @param {Object} [options]
|
|
2767
|
-
* @param {boolean} [options.debug = false]
|
|
2768
|
-
* @param {boolean} [options.strict = false]
|
|
2769
|
-
* @param {Function} [options.buildDebugString]
|
|
2770
|
-
*
|
|
2764
|
+
/**
|
|
2765
|
+
* Template a string reactively based on form data. If the string is not a template, it is returned as is.
|
|
2766
|
+
* If the string contains multiple lines, only the first line is returned.
|
|
2767
|
+
* Memoised to minimize re-renders
|
|
2768
|
+
*
|
|
2769
|
+
* @param {string} value
|
|
2770
|
+
* @param {Object} [options]
|
|
2771
|
+
* @param {boolean} [options.debug = false]
|
|
2772
|
+
* @param {boolean} [options.strict = false]
|
|
2773
|
+
* @param {Function} [options.buildDebugString]
|
|
2774
|
+
*
|
|
2771
2775
|
*/
|
|
2772
2776
|
function useSingleLineTemplateEvaluation(value, options = {}) {
|
|
2773
2777
|
const evaluatedTemplate = useTemplateEvaluation(value, options);
|
|
@@ -2971,8 +2975,8 @@ function createEmptyOptions(options = {}) {
|
|
|
2971
2975
|
};
|
|
2972
2976
|
}
|
|
2973
2977
|
|
|
2974
|
-
/**
|
|
2975
|
-
* @enum { String }
|
|
2978
|
+
/**
|
|
2979
|
+
* @enum { String }
|
|
2976
2980
|
*/
|
|
2977
2981
|
const LOAD_STATES = {
|
|
2978
2982
|
LOADING: 'loading',
|
|
@@ -2980,17 +2984,17 @@ const LOAD_STATES = {
|
|
|
2980
2984
|
ERROR: 'error'
|
|
2981
2985
|
};
|
|
2982
2986
|
|
|
2983
|
-
/**
|
|
2984
|
-
* @typedef {Object} ValuesGetter
|
|
2985
|
-
* @property {Object[]} values - The values data
|
|
2986
|
-
* @property {(LOAD_STATES)} state - The values data's loading state, to use for conditional rendering
|
|
2987
|
+
/**
|
|
2988
|
+
* @typedef {Object} ValuesGetter
|
|
2989
|
+
* @property {Object[]} values - The values data
|
|
2990
|
+
* @property {(LOAD_STATES)} state - The values data's loading state, to use for conditional rendering
|
|
2987
2991
|
*/
|
|
2988
2992
|
|
|
2989
|
-
/**
|
|
2990
|
-
* A hook to load values for single and multiselect components.
|
|
2991
|
-
*
|
|
2992
|
-
* @param {Object} field - The form field to handle values for
|
|
2993
|
-
* @return {ValuesGetter} valuesGetter - A values getter object providing loading state and values
|
|
2993
|
+
/**
|
|
2994
|
+
* A hook to load values for single and multiselect components.
|
|
2995
|
+
*
|
|
2996
|
+
* @param {Object} field - The form field to handle values for
|
|
2997
|
+
* @return {ValuesGetter} valuesGetter - A values getter object providing loading state and values
|
|
2994
2998
|
*/
|
|
2995
2999
|
function useValuesAsync (field) {
|
|
2996
3000
|
const {
|
|
@@ -3052,7 +3056,6 @@ const ENTER_KEYDOWN_EVENT = new KeyboardEvent('keydown', {
|
|
|
3052
3056
|
key: 'Enter',
|
|
3053
3057
|
charCode: 13,
|
|
3054
3058
|
keyCode: 13,
|
|
3055
|
-
view: window,
|
|
3056
3059
|
bubbles: true
|
|
3057
3060
|
});
|
|
3058
3061
|
function focusRelevantFlatpickerDay(flatpickrInstance) {
|
|
@@ -3499,12 +3502,12 @@ var SvgCalendar = function SvgCalendar(props) {
|
|
|
3499
3502
|
};
|
|
3500
3503
|
var CalendarIcon = SvgCalendar;
|
|
3501
3504
|
|
|
3502
|
-
/**
|
|
3503
|
-
* Returns date format for the provided locale.
|
|
3504
|
-
* If the locale is not provided, uses the browser's locale.
|
|
3505
|
-
*
|
|
3506
|
-
* @param {string} [locale] - The locale to get date format for.
|
|
3507
|
-
* @returns {string} The date format for the locale.
|
|
3505
|
+
/**
|
|
3506
|
+
* Returns date format for the provided locale.
|
|
3507
|
+
* If the locale is not provided, uses the browser's locale.
|
|
3508
|
+
*
|
|
3509
|
+
* @param {string} [locale] - The locale to get date format for.
|
|
3510
|
+
* @returns {string} The date format for the locale.
|
|
3508
3511
|
*/
|
|
3509
3512
|
function getLocaleDateFormat(locale = 'default') {
|
|
3510
3513
|
const parts = new Intl.DateTimeFormat(locale).formatToParts(new Date(Date.UTC(2020, 5, 5)));
|
|
@@ -3523,12 +3526,12 @@ function getLocaleDateFormat(locale = 'default') {
|
|
|
3523
3526
|
}).join('');
|
|
3524
3527
|
}
|
|
3525
3528
|
|
|
3526
|
-
/**
|
|
3527
|
-
* Returns readable date format for the provided locale.
|
|
3528
|
-
* If the locale is not provided, uses the browser's locale.
|
|
3529
|
-
*
|
|
3530
|
-
* @param {string} [locale] - The locale to get readable date format for.
|
|
3531
|
-
* @returns {string} The readable date format for the locale.
|
|
3529
|
+
/**
|
|
3530
|
+
* Returns readable date format for the provided locale.
|
|
3531
|
+
* If the locale is not provided, uses the browser's locale.
|
|
3532
|
+
*
|
|
3533
|
+
* @param {string} [locale] - The locale to get readable date format for.
|
|
3534
|
+
* @returns {string} The readable date format for the locale.
|
|
3532
3535
|
*/
|
|
3533
3536
|
function getLocaleReadableDateFormat(locale) {
|
|
3534
3537
|
let format = getLocaleDateFormat(locale).toLowerCase();
|
|
@@ -3545,12 +3548,12 @@ function getLocaleReadableDateFormat(locale) {
|
|
|
3545
3548
|
return format;
|
|
3546
3549
|
}
|
|
3547
3550
|
|
|
3548
|
-
/**
|
|
3549
|
-
* Returns flatpickr config for the provided locale.
|
|
3550
|
-
* If the locale is not provided, uses the browser's locale.
|
|
3551
|
-
*
|
|
3552
|
-
* @param {string} [locale] - The locale to get flatpickr config for.
|
|
3553
|
-
* @returns {object} The flatpickr config for the locale.
|
|
3551
|
+
/**
|
|
3552
|
+
* Returns flatpickr config for the provided locale.
|
|
3553
|
+
* If the locale is not provided, uses the browser's locale.
|
|
3554
|
+
*
|
|
3555
|
+
* @param {string} [locale] - The locale to get flatpickr config for.
|
|
3556
|
+
* @returns {object} The flatpickr config for the locale.
|
|
3554
3557
|
*/
|
|
3555
3558
|
function getLocaleDateFlatpickrConfig(locale) {
|
|
3556
3559
|
return flatpickerizeDateFormat(getLocaleDateFormat(locale));
|
|
@@ -4230,10 +4233,10 @@ Datetime.config = {
|
|
|
4230
4233
|
}
|
|
4231
4234
|
};
|
|
4232
4235
|
|
|
4233
|
-
/**
|
|
4234
|
-
* This file must not be changed or exchanged.
|
|
4235
|
-
*
|
|
4236
|
-
* @see http://bpmn.io/license for more information.
|
|
4236
|
+
/**
|
|
4237
|
+
* This file must not be changed or exchanged.
|
|
4238
|
+
*
|
|
4239
|
+
* @see http://bpmn.io/license for more information.
|
|
4237
4240
|
*/
|
|
4238
4241
|
function Logo() {
|
|
4239
4242
|
return jsxs("svg", {
|
|
@@ -4411,11 +4414,11 @@ const ATTR_WHITESPACE_PATTERN = /[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u
|
|
|
4411
4414
|
|
|
4412
4415
|
const FORM_ELEMENT = document.createElement('form');
|
|
4413
4416
|
|
|
4414
|
-
/**
|
|
4415
|
-
* Sanitize a HTML string and return the cleaned, safe version.
|
|
4416
|
-
*
|
|
4417
|
-
* @param {string} html
|
|
4418
|
-
* @return {string}
|
|
4417
|
+
/**
|
|
4418
|
+
* Sanitize a HTML string and return the cleaned, safe version.
|
|
4419
|
+
*
|
|
4420
|
+
* @param {string} html
|
|
4421
|
+
* @return {string}
|
|
4419
4422
|
*/
|
|
4420
4423
|
|
|
4421
4424
|
// see https://github.com/developit/snarkdown/issues/70
|
|
@@ -4433,29 +4436,29 @@ function sanitizeHTML(html) {
|
|
|
4433
4436
|
}
|
|
4434
4437
|
}
|
|
4435
4438
|
|
|
4436
|
-
/**
|
|
4437
|
-
* Sanitizes an image source to ensure we only allow for data URI and links
|
|
4438
|
-
* that start with http(s).
|
|
4439
|
-
*
|
|
4440
|
-
* Note: Most browsers anyway do not support script execution in <img> elements.
|
|
4441
|
-
*
|
|
4442
|
-
* @param {string} src
|
|
4443
|
-
* @returns {string}
|
|
4439
|
+
/**
|
|
4440
|
+
* Sanitizes an image source to ensure we only allow for data URI and links
|
|
4441
|
+
* that start with http(s).
|
|
4442
|
+
*
|
|
4443
|
+
* Note: Most browsers anyway do not support script execution in <img> elements.
|
|
4444
|
+
*
|
|
4445
|
+
* @param {string} src
|
|
4446
|
+
* @returns {string}
|
|
4444
4447
|
*/
|
|
4445
4448
|
function sanitizeImageSource(src) {
|
|
4446
4449
|
const valid = ALLOWED_IMAGE_SRC_PATTERN.test(src);
|
|
4447
4450
|
return valid ? src : '';
|
|
4448
4451
|
}
|
|
4449
4452
|
|
|
4450
|
-
/**
|
|
4451
|
-
* Recursively sanitize a HTML node, potentially
|
|
4452
|
-
* removing it, its children or attributes.
|
|
4453
|
-
*
|
|
4454
|
-
* Inspired by https://github.com/developit/snarkdown/issues/70
|
|
4455
|
-
* and https://github.com/cure53/DOMPurify. Simplified
|
|
4456
|
-
* for our use-case.
|
|
4457
|
-
*
|
|
4458
|
-
* @param {Element} node
|
|
4453
|
+
/**
|
|
4454
|
+
* Recursively sanitize a HTML node, potentially
|
|
4455
|
+
* removing it, its children or attributes.
|
|
4456
|
+
*
|
|
4457
|
+
* Inspired by https://github.com/developit/snarkdown/issues/70
|
|
4458
|
+
* and https://github.com/cure53/DOMPurify. Simplified
|
|
4459
|
+
* for our use-case.
|
|
4460
|
+
*
|
|
4461
|
+
* @param {Element} node
|
|
4459
4462
|
*/
|
|
4460
4463
|
function sanitizeNode(node) {
|
|
4461
4464
|
// allow text nodes
|
|
@@ -4499,13 +4502,13 @@ function sanitizeNode(node) {
|
|
|
4499
4502
|
}
|
|
4500
4503
|
}
|
|
4501
4504
|
|
|
4502
|
-
/**
|
|
4503
|
-
* Validates attributes for validity.
|
|
4504
|
-
*
|
|
4505
|
-
* @param {string} lcTag
|
|
4506
|
-
* @param {string} lcName
|
|
4507
|
-
* @param {string} value
|
|
4508
|
-
* @return {boolean}
|
|
4505
|
+
/**
|
|
4506
|
+
* Validates attributes for validity.
|
|
4507
|
+
*
|
|
4508
|
+
* @param {string} lcTag
|
|
4509
|
+
* @param {string} lcName
|
|
4510
|
+
* @param {string} value
|
|
4511
|
+
* @return {boolean}
|
|
4509
4512
|
*/
|
|
4510
4513
|
function isValidAttribute(lcTag, lcName, value) {
|
|
4511
4514
|
// disallow most attributes based on whitelist
|
|
@@ -6233,55 +6236,55 @@ var core = {
|
|
|
6233
6236
|
validator: ['type', Validator]
|
|
6234
6237
|
};
|
|
6235
6238
|
|
|
6236
|
-
/**
|
|
6237
|
-
* @typedef { import('./types').Injector } Injector
|
|
6238
|
-
* @typedef { import('./types').Data } Data
|
|
6239
|
-
* @typedef { import('./types').Errors } Errors
|
|
6240
|
-
* @typedef { import('./types').Schema } Schema
|
|
6241
|
-
* @typedef { import('./types').FormProperties } FormProperties
|
|
6242
|
-
* @typedef { import('./types').FormProperty } FormProperty
|
|
6243
|
-
* @typedef { import('./types').FormEvent } FormEvent
|
|
6244
|
-
* @typedef { import('./types').FormOptions } FormOptions
|
|
6245
|
-
*
|
|
6246
|
-
* @typedef { {
|
|
6247
|
-
* data: Data,
|
|
6248
|
-
* initialData: Data,
|
|
6249
|
-
* errors: Errors,
|
|
6250
|
-
* properties: FormProperties,
|
|
6251
|
-
* schema: Schema
|
|
6252
|
-
* } } State
|
|
6253
|
-
*
|
|
6254
|
-
* @typedef { (type:FormEvent, priority:number, handler:Function) => void } OnEventWithPriority
|
|
6255
|
-
* @typedef { (type:FormEvent, handler:Function) => void } OnEventWithOutPriority
|
|
6256
|
-
* @typedef { OnEventWithPriority & OnEventWithOutPriority } OnEventType
|
|
6239
|
+
/**
|
|
6240
|
+
* @typedef { import('./types').Injector } Injector
|
|
6241
|
+
* @typedef { import('./types').Data } Data
|
|
6242
|
+
* @typedef { import('./types').Errors } Errors
|
|
6243
|
+
* @typedef { import('./types').Schema } Schema
|
|
6244
|
+
* @typedef { import('./types').FormProperties } FormProperties
|
|
6245
|
+
* @typedef { import('./types').FormProperty } FormProperty
|
|
6246
|
+
* @typedef { import('./types').FormEvent } FormEvent
|
|
6247
|
+
* @typedef { import('./types').FormOptions } FormOptions
|
|
6248
|
+
*
|
|
6249
|
+
* @typedef { {
|
|
6250
|
+
* data: Data,
|
|
6251
|
+
* initialData: Data,
|
|
6252
|
+
* errors: Errors,
|
|
6253
|
+
* properties: FormProperties,
|
|
6254
|
+
* schema: Schema
|
|
6255
|
+
* } } State
|
|
6256
|
+
*
|
|
6257
|
+
* @typedef { (type:FormEvent, priority:number, handler:Function) => void } OnEventWithPriority
|
|
6258
|
+
* @typedef { (type:FormEvent, handler:Function) => void } OnEventWithOutPriority
|
|
6259
|
+
* @typedef { OnEventWithPriority & OnEventWithOutPriority } OnEventType
|
|
6257
6260
|
*/
|
|
6258
6261
|
|
|
6259
6262
|
const ids = new Ids([32, 36, 1]);
|
|
6260
6263
|
|
|
6261
|
-
/**
|
|
6262
|
-
* The form.
|
|
6264
|
+
/**
|
|
6265
|
+
* The form.
|
|
6263
6266
|
*/
|
|
6264
6267
|
class Form {
|
|
6265
|
-
/**
|
|
6266
|
-
* @constructor
|
|
6267
|
-
* @param {FormOptions} options
|
|
6268
|
+
/**
|
|
6269
|
+
* @constructor
|
|
6270
|
+
* @param {FormOptions} options
|
|
6268
6271
|
*/
|
|
6269
6272
|
constructor(options = {}) {
|
|
6270
|
-
/**
|
|
6271
|
-
* @public
|
|
6272
|
-
* @type {OnEventType}
|
|
6273
|
+
/**
|
|
6274
|
+
* @public
|
|
6275
|
+
* @type {OnEventType}
|
|
6273
6276
|
*/
|
|
6274
6277
|
this.on = this._onEvent;
|
|
6275
6278
|
|
|
6276
|
-
/**
|
|
6277
|
-
* @public
|
|
6278
|
-
* @type {String}
|
|
6279
|
+
/**
|
|
6280
|
+
* @public
|
|
6281
|
+
* @type {String}
|
|
6279
6282
|
*/
|
|
6280
6283
|
this._id = ids.next();
|
|
6281
6284
|
|
|
6282
|
-
/**
|
|
6283
|
-
* @private
|
|
6284
|
-
* @type {Element}
|
|
6285
|
+
/**
|
|
6286
|
+
* @private
|
|
6287
|
+
* @type {Element}
|
|
6285
6288
|
*/
|
|
6286
6289
|
this._container = createFormContainer();
|
|
6287
6290
|
const {
|
|
@@ -6290,9 +6293,9 @@ class Form {
|
|
|
6290
6293
|
properties = {}
|
|
6291
6294
|
} = options;
|
|
6292
6295
|
|
|
6293
|
-
/**
|
|
6294
|
-
* @private
|
|
6295
|
-
* @type {State}
|
|
6296
|
+
/**
|
|
6297
|
+
* @private
|
|
6298
|
+
* @type {State}
|
|
6296
6299
|
*/
|
|
6297
6300
|
this._state = {
|
|
6298
6301
|
initialData: null,
|
|
@@ -6316,9 +6319,9 @@ class Form {
|
|
|
6316
6319
|
this._emit('form.clear');
|
|
6317
6320
|
}
|
|
6318
6321
|
|
|
6319
|
-
/**
|
|
6320
|
-
* Destroy the form, removing it from DOM,
|
|
6321
|
-
* if attached.
|
|
6322
|
+
/**
|
|
6323
|
+
* Destroy the form, removing it from DOM,
|
|
6324
|
+
* if attached.
|
|
6322
6325
|
*/
|
|
6323
6326
|
destroy() {
|
|
6324
6327
|
// destroy form services
|
|
@@ -6329,13 +6332,13 @@ class Form {
|
|
|
6329
6332
|
this._detach(false);
|
|
6330
6333
|
}
|
|
6331
6334
|
|
|
6332
|
-
/**
|
|
6333
|
-
* Open a form schema with the given initial data.
|
|
6334
|
-
*
|
|
6335
|
-
* @param {Schema} schema
|
|
6336
|
-
* @param {Data} [data]
|
|
6337
|
-
*
|
|
6338
|
-
* @return Promise<{ warnings: Array<any> }>
|
|
6335
|
+
/**
|
|
6336
|
+
* Open a form schema with the given initial data.
|
|
6337
|
+
*
|
|
6338
|
+
* @param {Schema} schema
|
|
6339
|
+
* @param {Data} [data]
|
|
6340
|
+
*
|
|
6341
|
+
* @return Promise<{ warnings: Array<any> }>
|
|
6339
6342
|
*/
|
|
6340
6343
|
importSchema(schema, data = {}) {
|
|
6341
6344
|
return new Promise((resolve, reject) => {
|
|
@@ -6368,10 +6371,10 @@ class Form {
|
|
|
6368
6371
|
});
|
|
6369
6372
|
}
|
|
6370
6373
|
|
|
6371
|
-
/**
|
|
6372
|
-
* Submit the form, triggering all field validations.
|
|
6373
|
-
*
|
|
6374
|
-
* @returns { { data: Data, errors: Errors } }
|
|
6374
|
+
/**
|
|
6375
|
+
* Submit the form, triggering all field validations.
|
|
6376
|
+
*
|
|
6377
|
+
* @returns { { data: Data, errors: Errors } }
|
|
6375
6378
|
*/
|
|
6376
6379
|
submit() {
|
|
6377
6380
|
const {
|
|
@@ -6382,10 +6385,9 @@ class Form {
|
|
|
6382
6385
|
}
|
|
6383
6386
|
const data = this._getSubmitData();
|
|
6384
6387
|
const errors = this.validate();
|
|
6385
|
-
const filteredErrors = this._applyConditions(errors, data);
|
|
6386
6388
|
const result = {
|
|
6387
6389
|
data,
|
|
6388
|
-
errors
|
|
6390
|
+
errors
|
|
6389
6391
|
};
|
|
6390
6392
|
this._emit('submit', result);
|
|
6391
6393
|
return result;
|
|
@@ -6398,8 +6400,8 @@ class Form {
|
|
|
6398
6400
|
});
|
|
6399
6401
|
}
|
|
6400
6402
|
|
|
6401
|
-
/**
|
|
6402
|
-
* @returns {Errors}
|
|
6403
|
+
/**
|
|
6404
|
+
* @returns {Errors}
|
|
6403
6405
|
*/
|
|
6404
6406
|
validate() {
|
|
6405
6407
|
const formFieldRegistry = this.get('formFieldRegistry'),
|
|
@@ -6408,6 +6410,7 @@ class Form {
|
|
|
6408
6410
|
const {
|
|
6409
6411
|
data
|
|
6410
6412
|
} = this._getState();
|
|
6413
|
+
const getErrorPath = field => [field.id];
|
|
6411
6414
|
const errors = formFieldRegistry.getAll().reduce((errors, field) => {
|
|
6412
6415
|
const {
|
|
6413
6416
|
disabled
|
|
@@ -6417,16 +6420,19 @@ class Form {
|
|
|
6417
6420
|
}
|
|
6418
6421
|
const value = get(data, pathRegistry.getValuePath(field));
|
|
6419
6422
|
const fieldErrors = validator.validateField(field, value);
|
|
6420
|
-
return set(errors,
|
|
6423
|
+
return set(errors, getErrorPath(field), fieldErrors.length ? fieldErrors : undefined);
|
|
6421
6424
|
}, /** @type {Errors} */{});
|
|
6425
|
+
const filteredErrors = this._applyConditions(errors, data, {
|
|
6426
|
+
getFilterPath: getErrorPath
|
|
6427
|
+
});
|
|
6422
6428
|
this._setState({
|
|
6423
|
-
errors
|
|
6429
|
+
errors: filteredErrors
|
|
6424
6430
|
});
|
|
6425
|
-
return
|
|
6431
|
+
return filteredErrors;
|
|
6426
6432
|
}
|
|
6427
6433
|
|
|
6428
|
-
/**
|
|
6429
|
-
* @param {Element|string} parentNode
|
|
6434
|
+
/**
|
|
6435
|
+
* @param {Element|string} parentNode
|
|
6430
6436
|
*/
|
|
6431
6437
|
attachTo(parentNode) {
|
|
6432
6438
|
if (!parentNode) {
|
|
@@ -6444,10 +6450,10 @@ class Form {
|
|
|
6444
6450
|
this._detach();
|
|
6445
6451
|
}
|
|
6446
6452
|
|
|
6447
|
-
/**
|
|
6448
|
-
* @private
|
|
6449
|
-
*
|
|
6450
|
-
* @param {boolean} [emit]
|
|
6453
|
+
/**
|
|
6454
|
+
* @private
|
|
6455
|
+
*
|
|
6456
|
+
* @param {boolean} [emit]
|
|
6451
6457
|
*/
|
|
6452
6458
|
_detach(emit = true) {
|
|
6453
6459
|
const container = this._container,
|
|
@@ -6461,9 +6467,9 @@ class Form {
|
|
|
6461
6467
|
parentNode.removeChild(container);
|
|
6462
6468
|
}
|
|
6463
6469
|
|
|
6464
|
-
/**
|
|
6465
|
-
* @param {FormProperty} property
|
|
6466
|
-
* @param {any} value
|
|
6470
|
+
/**
|
|
6471
|
+
* @param {FormProperty} property
|
|
6472
|
+
* @param {any} value
|
|
6467
6473
|
*/
|
|
6468
6474
|
setProperty(property, value) {
|
|
6469
6475
|
const properties = set(this._getState().properties, [property], value);
|
|
@@ -6472,21 +6478,21 @@ class Form {
|
|
|
6472
6478
|
});
|
|
6473
6479
|
}
|
|
6474
6480
|
|
|
6475
|
-
/**
|
|
6476
|
-
* @param {FormEvent} type
|
|
6477
|
-
* @param {Function} handler
|
|
6481
|
+
/**
|
|
6482
|
+
* @param {FormEvent} type
|
|
6483
|
+
* @param {Function} handler
|
|
6478
6484
|
*/
|
|
6479
6485
|
off(type, handler) {
|
|
6480
6486
|
this.get('eventBus').off(type, handler);
|
|
6481
6487
|
}
|
|
6482
6488
|
|
|
6483
|
-
/**
|
|
6484
|
-
* @private
|
|
6485
|
-
*
|
|
6486
|
-
* @param {FormOptions} options
|
|
6487
|
-
* @param {Element} container
|
|
6488
|
-
*
|
|
6489
|
-
* @returns {Injector}
|
|
6489
|
+
/**
|
|
6490
|
+
* @private
|
|
6491
|
+
*
|
|
6492
|
+
* @param {FormOptions} options
|
|
6493
|
+
* @param {Element} container
|
|
6494
|
+
*
|
|
6495
|
+
* @returns {Injector}
|
|
6490
6496
|
*/
|
|
6491
6497
|
_createInjector(options, container) {
|
|
6492
6498
|
const {
|
|
@@ -6505,17 +6511,17 @@ class Form {
|
|
|
6505
6511
|
}, core, ...modules, ...additionalModules]);
|
|
6506
6512
|
}
|
|
6507
6513
|
|
|
6508
|
-
/**
|
|
6509
|
-
* @private
|
|
6514
|
+
/**
|
|
6515
|
+
* @private
|
|
6510
6516
|
*/
|
|
6511
6517
|
_emit(type, data) {
|
|
6512
6518
|
this.get('eventBus').fire(type, data);
|
|
6513
6519
|
}
|
|
6514
6520
|
|
|
6515
|
-
/**
|
|
6516
|
-
* @internal
|
|
6517
|
-
*
|
|
6518
|
-
* @param { { add?: boolean, field: any, remove?: number, value?: any } } update
|
|
6521
|
+
/**
|
|
6522
|
+
* @internal
|
|
6523
|
+
*
|
|
6524
|
+
* @param { { add?: boolean, field: any, remove?: number, value?: any } } update
|
|
6519
6525
|
*/
|
|
6520
6526
|
_update(update) {
|
|
6521
6527
|
const {
|
|
@@ -6537,15 +6543,15 @@ class Form {
|
|
|
6537
6543
|
});
|
|
6538
6544
|
}
|
|
6539
6545
|
|
|
6540
|
-
/**
|
|
6541
|
-
* @internal
|
|
6546
|
+
/**
|
|
6547
|
+
* @internal
|
|
6542
6548
|
*/
|
|
6543
6549
|
_getState() {
|
|
6544
6550
|
return this._state;
|
|
6545
6551
|
}
|
|
6546
6552
|
|
|
6547
|
-
/**
|
|
6548
|
-
* @internal
|
|
6553
|
+
/**
|
|
6554
|
+
* @internal
|
|
6549
6555
|
*/
|
|
6550
6556
|
_setState(state) {
|
|
6551
6557
|
this._state = {
|
|
@@ -6555,22 +6561,22 @@ class Form {
|
|
|
6555
6561
|
this._emit('changed', this._getState());
|
|
6556
6562
|
}
|
|
6557
6563
|
|
|
6558
|
-
/**
|
|
6559
|
-
* @internal
|
|
6564
|
+
/**
|
|
6565
|
+
* @internal
|
|
6560
6566
|
*/
|
|
6561
6567
|
_getModules() {
|
|
6562
6568
|
return [ExpressionLanguageModule, MarkdownModule, ViewerCommandsModule];
|
|
6563
6569
|
}
|
|
6564
6570
|
|
|
6565
|
-
/**
|
|
6566
|
-
* @internal
|
|
6571
|
+
/**
|
|
6572
|
+
* @internal
|
|
6567
6573
|
*/
|
|
6568
6574
|
_onEvent(type, priority, handler) {
|
|
6569
6575
|
this.get('eventBus').on(type, priority, handler);
|
|
6570
6576
|
}
|
|
6571
6577
|
|
|
6572
|
-
/**
|
|
6573
|
-
* @internal
|
|
6578
|
+
/**
|
|
6579
|
+
* @internal
|
|
6574
6580
|
*/
|
|
6575
6581
|
_getSubmitData() {
|
|
6576
6582
|
const formFieldRegistry = this.get('formFieldRegistry'),
|
|
@@ -6598,16 +6604,16 @@ class Form {
|
|
|
6598
6604
|
return filteredSubmitData;
|
|
6599
6605
|
}
|
|
6600
6606
|
|
|
6601
|
-
/**
|
|
6602
|
-
* @internal
|
|
6607
|
+
/**
|
|
6608
|
+
* @internal
|
|
6603
6609
|
*/
|
|
6604
|
-
_applyConditions(toFilter, data) {
|
|
6610
|
+
_applyConditions(toFilter, data, options = {}) {
|
|
6605
6611
|
const conditionChecker = this.get('conditionChecker');
|
|
6606
|
-
return conditionChecker.applyConditions(toFilter, data);
|
|
6612
|
+
return conditionChecker.applyConditions(toFilter, data, options);
|
|
6607
6613
|
}
|
|
6608
6614
|
|
|
6609
|
-
/**
|
|
6610
|
-
* @internal
|
|
6615
|
+
/**
|
|
6616
|
+
* @internal
|
|
6611
6617
|
*/
|
|
6612
6618
|
_initializeFieldData(data) {
|
|
6613
6619
|
const formFieldRegistry = this.get('formFieldRegistry'),
|