@bpmn-io/form-js-viewer 1.3.0-alpha.0 → 1.3.0
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 +985 -985
- package/dist/index.cjs +499 -467
- package/dist/index.cjs.map +1 -1
- package/dist/index.es.js +500 -469
- package/dist/index.es.js.map +1 -1
- package/dist/types/render/components/index.d.ts +2 -1
- package/dist/types/render/hooks/index.d.ts +2 -0
- package/dist/types/render/hooks/useDeepCompareState.d.ts +8 -0
- package/dist/types/render/hooks/usePrevious.d.ts +1 -0
- package/dist/types/types.d.ts +35 -35
- package/package.json +2 -2
package/dist/index.es.js
CHANGED
|
@@ -5,7 +5,7 @@ import { parseExpression, parseUnaryTests, evaluate, unaryTest } from 'feelin';
|
|
|
5
5
|
import { evaluate as evaluate$1, parser, buildSimpleTree } from 'feelers';
|
|
6
6
|
import classNames from 'classnames';
|
|
7
7
|
import { jsx, jsxs, Fragment as Fragment$1 } from 'preact/jsx-runtime';
|
|
8
|
-
import { useContext, useMemo, useEffect,
|
|
8
|
+
import { useContext, useMemo, useEffect, useRef, useState, useCallback, useLayoutEffect } from 'preact/hooks';
|
|
9
9
|
import { createContext, createElement, Fragment, render } from 'preact';
|
|
10
10
|
import * as React from 'preact/compat';
|
|
11
11
|
import { createPortal } from 'preact/compat';
|
|
@@ -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,11 +614,11 @@ 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
622
|
*/
|
|
623
623
|
applyConditions(properties, data = {}) {
|
|
624
624
|
const newProperties = clone(properties);
|
|
@@ -645,13 +645,13 @@ class ConditionChecker {
|
|
|
645
645
|
return newProperties;
|
|
646
646
|
}
|
|
647
647
|
|
|
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}
|
|
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}
|
|
655
655
|
*/
|
|
656
656
|
check(condition, data = {}) {
|
|
657
657
|
if (!condition) {
|
|
@@ -672,12 +672,12 @@ class ConditionChecker {
|
|
|
672
672
|
}
|
|
673
673
|
}
|
|
674
674
|
|
|
675
|
-
/**
|
|
676
|
-
* Check if hide condition is met.
|
|
677
|
-
*
|
|
678
|
-
* @param {Condition} condition
|
|
679
|
-
* @param {Object<string, any>} data
|
|
680
|
-
* @returns {boolean}
|
|
675
|
+
/**
|
|
676
|
+
* Check if hide condition is met.
|
|
677
|
+
*
|
|
678
|
+
* @param {Condition} condition
|
|
679
|
+
* @param {Object<string, any>} data
|
|
680
|
+
* @returns {boolean}
|
|
681
681
|
*/
|
|
682
682
|
_checkHideCondition(condition, data) {
|
|
683
683
|
if (!condition.hide) {
|
|
@@ -713,12 +713,12 @@ class MarkdownRenderer {
|
|
|
713
713
|
this._converter = new showdown.Converter();
|
|
714
714
|
}
|
|
715
715
|
|
|
716
|
-
/**
|
|
717
|
-
* Render markdown to HTML.
|
|
718
|
-
*
|
|
719
|
-
* @param {string} markdown - The markdown to render
|
|
720
|
-
*
|
|
721
|
-
* @returns {string} HTML
|
|
716
|
+
/**
|
|
717
|
+
* Render markdown to HTML.
|
|
718
|
+
*
|
|
719
|
+
* @param {string} markdown - The markdown to render
|
|
720
|
+
*
|
|
721
|
+
* @returns {string} HTML
|
|
722
722
|
*/
|
|
723
723
|
render(markdown) {
|
|
724
724
|
return this._converter.makeHtml(markdown);
|
|
@@ -1866,8 +1866,8 @@ Validator.$inject = ['expressionLanguage', 'conditionChecker', 'form'];
|
|
|
1866
1866
|
|
|
1867
1867
|
// helpers //////////
|
|
1868
1868
|
|
|
1869
|
-
/**
|
|
1870
|
-
* Helper function to evaluate optional FEEL validation values.
|
|
1869
|
+
/**
|
|
1870
|
+
* Helper function to evaluate optional FEEL validation values.
|
|
1871
1871
|
*/
|
|
1872
1872
|
function evaluateFEELValues(validate, expressionLanguage, conditionChecker, form) {
|
|
1873
1873
|
const evaluatedValidate = {
|
|
@@ -1901,12 +1901,12 @@ function evaluateFEELValues(validate, expressionLanguage, conditionChecker, form
|
|
|
1901
1901
|
}
|
|
1902
1902
|
|
|
1903
1903
|
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
|
|
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
|
|
1910
1910
|
*/
|
|
1911
1911
|
constructor(formFieldRegistry, pathRegistry, fieldFactory, formLayouter) {
|
|
1912
1912
|
this._formFieldRegistry = formFieldRegistry;
|
|
@@ -1915,21 +1915,21 @@ class Importer {
|
|
|
1915
1915
|
this._formLayouter = formLayouter;
|
|
1916
1916
|
}
|
|
1917
1917
|
|
|
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}
|
|
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}
|
|
1933
1933
|
*/
|
|
1934
1934
|
importSchema(schema) {
|
|
1935
1935
|
// TODO: Add warnings
|
|
@@ -1954,12 +1954,12 @@ class Importer {
|
|
|
1954
1954
|
this._pathRegistry.clear();
|
|
1955
1955
|
}
|
|
1956
1956
|
|
|
1957
|
-
/**
|
|
1958
|
-
* @param {{[x: string]: any}} fieldAttrs
|
|
1959
|
-
* @param {String} [parentId]
|
|
1960
|
-
* @param {number} [index]
|
|
1961
|
-
*
|
|
1962
|
-
* @return {any} field
|
|
1957
|
+
/**
|
|
1958
|
+
* @param {{[x: string]: any}} fieldAttrs
|
|
1959
|
+
* @param {String} [parentId]
|
|
1960
|
+
* @param {number} [index]
|
|
1961
|
+
*
|
|
1962
|
+
* @return {any} field
|
|
1963
1963
|
*/
|
|
1964
1964
|
importFormField(fieldAttrs, parentId, index) {
|
|
1965
1965
|
const {
|
|
@@ -1984,11 +1984,11 @@ class Importer {
|
|
|
1984
1984
|
return field;
|
|
1985
1985
|
}
|
|
1986
1986
|
|
|
1987
|
-
/**
|
|
1988
|
-
* @param {Array<any>} components
|
|
1989
|
-
* @param {string} parentId
|
|
1990
|
-
*
|
|
1991
|
-
* @return {Array<any>} imported components
|
|
1987
|
+
/**
|
|
1988
|
+
* @param {Array<any>} components
|
|
1989
|
+
* @param {string} parentId
|
|
1990
|
+
*
|
|
1991
|
+
* @return {Array<any>} imported components
|
|
1992
1992
|
*/
|
|
1993
1993
|
importFormFields(components, parentId) {
|
|
1994
1994
|
return components.map((component, index) => {
|
|
@@ -1999,11 +1999,11 @@ class Importer {
|
|
|
1999
1999
|
Importer.$inject = ['formFieldRegistry', 'pathRegistry', 'fieldFactory', 'formLayouter'];
|
|
2000
2000
|
|
|
2001
2001
|
class FieldFactory {
|
|
2002
|
-
/**
|
|
2003
|
-
* @constructor
|
|
2004
|
-
*
|
|
2005
|
-
* @param formFieldRegistry
|
|
2006
|
-
* @param formFields
|
|
2002
|
+
/**
|
|
2003
|
+
* @constructor
|
|
2004
|
+
*
|
|
2005
|
+
* @param formFieldRegistry
|
|
2006
|
+
* @param formFields
|
|
2007
2007
|
*/
|
|
2008
2008
|
constructor(formFieldRegistry, pathRegistry, formFields) {
|
|
2009
2009
|
this._formFieldRegistry = formFieldRegistry;
|
|
@@ -2085,36 +2085,36 @@ class FieldFactory {
|
|
|
2085
2085
|
}
|
|
2086
2086
|
FieldFactory.$inject = ['formFieldRegistry', 'pathRegistry', 'formFields'];
|
|
2087
2087
|
|
|
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
|
-
* ]
|
|
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
|
+
* ]
|
|
2118
2118
|
*/
|
|
2119
2119
|
class PathRegistry {
|
|
2120
2120
|
constructor(formFieldRegistry, formFields) {
|
|
@@ -2197,16 +2197,16 @@ class PathRegistry {
|
|
|
2197
2197
|
}
|
|
2198
2198
|
}
|
|
2199
2199
|
|
|
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.
|
|
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.
|
|
2210
2210
|
*/
|
|
2211
2211
|
executeRecursivelyOnFields(field, fn, context = {}) {
|
|
2212
2212
|
let result = true;
|
|
@@ -2240,15 +2240,15 @@ class PathRegistry {
|
|
|
2240
2240
|
return result;
|
|
2241
2241
|
}
|
|
2242
2242
|
|
|
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.
|
|
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.
|
|
2252
2252
|
*/
|
|
2253
2253
|
getValuePath(field, options = {}) {
|
|
2254
2254
|
const {
|
|
@@ -2292,23 +2292,23 @@ const _getNextSegment = (node, segment) => {
|
|
|
2292
2292
|
};
|
|
2293
2293
|
PathRegistry.$inject = ['formFieldRegistry', 'formFields'];
|
|
2294
2294
|
|
|
2295
|
-
/**
|
|
2296
|
-
* @typedef { { id: String, components: Array<String> } } FormRow
|
|
2297
|
-
* @typedef { { formFieldId: String, rows: Array<FormRow> } } FormRows
|
|
2295
|
+
/**
|
|
2296
|
+
* @typedef { { id: String, components: Array<String> } } FormRow
|
|
2297
|
+
* @typedef { { formFieldId: String, rows: Array<FormRow> } } FormRows
|
|
2298
2298
|
*/
|
|
2299
2299
|
|
|
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
|
-
*
|
|
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
|
+
*
|
|
2312
2312
|
*/
|
|
2313
2313
|
class FormLayouter {
|
|
2314
2314
|
constructor(eventBus) {
|
|
@@ -2318,8 +2318,8 @@ class FormLayouter {
|
|
|
2318
2318
|
this._eventBus = eventBus;
|
|
2319
2319
|
}
|
|
2320
2320
|
|
|
2321
|
-
/**
|
|
2322
|
-
* @param {FormRow} row
|
|
2321
|
+
/**
|
|
2322
|
+
* @param {FormRow} row
|
|
2323
2323
|
*/
|
|
2324
2324
|
addRow(formFieldId, row) {
|
|
2325
2325
|
let rowsPerComponent = this._rows.find(r => r.formFieldId === formFieldId);
|
|
@@ -2333,18 +2333,18 @@ class FormLayouter {
|
|
|
2333
2333
|
rowsPerComponent.rows.push(row);
|
|
2334
2334
|
}
|
|
2335
2335
|
|
|
2336
|
-
/**
|
|
2337
|
-
* @param {String} id
|
|
2338
|
-
* @returns {FormRow}
|
|
2336
|
+
/**
|
|
2337
|
+
* @param {String} id
|
|
2338
|
+
* @returns {FormRow}
|
|
2339
2339
|
*/
|
|
2340
2340
|
getRow(id) {
|
|
2341
2341
|
const rows = allRows(this._rows);
|
|
2342
2342
|
return rows.find(r => r.id === id);
|
|
2343
2343
|
}
|
|
2344
2344
|
|
|
2345
|
-
/**
|
|
2346
|
-
* @param {any} formField
|
|
2347
|
-
* @returns {FormRow}
|
|
2345
|
+
/**
|
|
2346
|
+
* @param {any} formField
|
|
2347
|
+
* @returns {FormRow}
|
|
2348
2348
|
*/
|
|
2349
2349
|
getRowForField(formField) {
|
|
2350
2350
|
return allRows(this._rows).find(r => {
|
|
@@ -2355,9 +2355,9 @@ class FormLayouter {
|
|
|
2355
2355
|
});
|
|
2356
2356
|
}
|
|
2357
2357
|
|
|
2358
|
-
/**
|
|
2359
|
-
* @param {String} formFieldId
|
|
2360
|
-
* @returns { Array<FormRow> }
|
|
2358
|
+
/**
|
|
2359
|
+
* @param {String} formFieldId
|
|
2360
|
+
* @returns { Array<FormRow> }
|
|
2361
2361
|
*/
|
|
2362
2362
|
getRows(formFieldId) {
|
|
2363
2363
|
const rowsForField = this._rows.find(r => formFieldId === r.formFieldId);
|
|
@@ -2367,15 +2367,15 @@ class FormLayouter {
|
|
|
2367
2367
|
return rowsForField.rows;
|
|
2368
2368
|
}
|
|
2369
2369
|
|
|
2370
|
-
/**
|
|
2371
|
-
* @returns {string}
|
|
2370
|
+
/**
|
|
2371
|
+
* @returns {string}
|
|
2372
2372
|
*/
|
|
2373
2373
|
nextRowId() {
|
|
2374
2374
|
return this._ids.nextPrefixed('Row_');
|
|
2375
2375
|
}
|
|
2376
2376
|
|
|
2377
|
-
/**
|
|
2378
|
-
* @param {any} formField
|
|
2377
|
+
/**
|
|
2378
|
+
* @param {any} formField
|
|
2379
2379
|
*/
|
|
2380
2380
|
calculateLayout(formField) {
|
|
2381
2381
|
const {
|
|
@@ -2429,9 +2429,9 @@ function groupByRow(components, ids) {
|
|
|
2429
2429
|
});
|
|
2430
2430
|
}
|
|
2431
2431
|
|
|
2432
|
-
/**
|
|
2433
|
-
* @param {Array<FormRows>} formRows
|
|
2434
|
-
* @returns {Array<FormRow>}
|
|
2432
|
+
/**
|
|
2433
|
+
* @param {Array<FormRows>} formRows
|
|
2434
|
+
* @returns {Array<FormRow>}
|
|
2435
2435
|
*/
|
|
2436
2436
|
function allRows(formRows) {
|
|
2437
2437
|
return flatten(formRows.map(c => c.rows));
|
|
@@ -2587,11 +2587,11 @@ const FormRenderContext = createContext({
|
|
|
2587
2587
|
});
|
|
2588
2588
|
var FormRenderContext$1 = FormRenderContext;
|
|
2589
2589
|
|
|
2590
|
-
/**
|
|
2591
|
-
* @param {string} type
|
|
2592
|
-
* @param {boolean} [strict]
|
|
2593
|
-
*
|
|
2594
|
-
* @returns {any}
|
|
2590
|
+
/**
|
|
2591
|
+
* @param {string} type
|
|
2592
|
+
* @param {boolean} [strict]
|
|
2593
|
+
*
|
|
2594
|
+
* @returns {any}
|
|
2595
2595
|
*/
|
|
2596
2596
|
function getService(type, strict) {}
|
|
2597
2597
|
const FormContext = createContext({
|
|
@@ -2607,10 +2607,10 @@ function useService(type, strict) {
|
|
|
2607
2607
|
return getService(type, strict);
|
|
2608
2608
|
}
|
|
2609
2609
|
|
|
2610
|
-
/**
|
|
2611
|
-
* Returns the conditionally filtered data of a form reactively.
|
|
2612
|
-
* Memoised to minimize re-renders
|
|
2613
|
-
*
|
|
2610
|
+
/**
|
|
2611
|
+
* Returns the conditionally filtered data of a form reactively.
|
|
2612
|
+
* Memoised to minimize re-renders
|
|
2613
|
+
*
|
|
2614
2614
|
*/
|
|
2615
2615
|
function useFilteredFormData() {
|
|
2616
2616
|
const {
|
|
@@ -2627,12 +2627,12 @@ function useFilteredFormData() {
|
|
|
2627
2627
|
}, [conditionChecker, data, initialData]);
|
|
2628
2628
|
}
|
|
2629
2629
|
|
|
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
|
|
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
|
|
2636
2636
|
*/
|
|
2637
2637
|
function useCondition(condition) {
|
|
2638
2638
|
const conditionChecker = useService('conditionChecker', false);
|
|
@@ -2642,13 +2642,13 @@ function useCondition(condition) {
|
|
|
2642
2642
|
}, [conditionChecker, condition, filteredData]);
|
|
2643
2643
|
}
|
|
2644
2644
|
|
|
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
|
-
*
|
|
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
|
+
*
|
|
2652
2652
|
*/
|
|
2653
2653
|
function useExpressionEvaluation(value) {
|
|
2654
2654
|
const formData = useFilteredFormData();
|
|
@@ -2677,16 +2677,16 @@ function useKeyDownAction(targetKey, action, listenerElement = window) {
|
|
|
2677
2677
|
});
|
|
2678
2678
|
}
|
|
2679
2679
|
|
|
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}
|
|
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}
|
|
2690
2690
|
*/
|
|
2691
2691
|
function useReadonly(formField, properties = {}) {
|
|
2692
2692
|
const expressionLanguage = useService('expressionLanguage');
|
|
@@ -2704,16 +2704,47 @@ function useReadonly(formField, properties = {}) {
|
|
|
2704
2704
|
return readonly || false;
|
|
2705
2705
|
}
|
|
2706
2706
|
|
|
2707
|
-
|
|
2708
|
-
|
|
2709
|
-
|
|
2710
|
-
|
|
2711
|
-
|
|
2712
|
-
|
|
2713
|
-
|
|
2714
|
-
*
|
|
2715
|
-
*
|
|
2716
|
-
*
|
|
2707
|
+
function usePrevious(value, defaultValue, dependencies) {
|
|
2708
|
+
const ref = useRef(defaultValue);
|
|
2709
|
+
useEffect(() => ref.current = value, dependencies);
|
|
2710
|
+
return ref.current;
|
|
2711
|
+
}
|
|
2712
|
+
|
|
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.
|
|
2719
|
+
*/
|
|
2720
|
+
function useDeepCompareState(value, defaultValue) {
|
|
2721
|
+
const [state, setState] = useState(defaultValue);
|
|
2722
|
+
const previous = usePrevious(value, defaultValue, [value]);
|
|
2723
|
+
const changed = !compare(previous, value);
|
|
2724
|
+
useEffect(() => {
|
|
2725
|
+
if (changed) {
|
|
2726
|
+
setState(value);
|
|
2727
|
+
}
|
|
2728
|
+
}, [changed, value]);
|
|
2729
|
+
return state;
|
|
2730
|
+
}
|
|
2731
|
+
|
|
2732
|
+
// helpers //////////////////////////
|
|
2733
|
+
|
|
2734
|
+
function compare(a, b) {
|
|
2735
|
+
return JSON.stringify(a) === JSON.stringify(b);
|
|
2736
|
+
}
|
|
2737
|
+
|
|
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
|
+
*
|
|
2717
2748
|
*/
|
|
2718
2749
|
function useTemplateEvaluation(value, options) {
|
|
2719
2750
|
const filteredData = useFilteredFormData();
|
|
@@ -2726,17 +2757,17 @@ function useTemplateEvaluation(value, options) {
|
|
|
2726
2757
|
}, [filteredData, templating, value, options]);
|
|
2727
2758
|
}
|
|
2728
2759
|
|
|
2729
|
-
/**
|
|
2730
|
-
* Template a string reactively based on form data. If the string is not a template, it is returned as is.
|
|
2731
|
-
* If the string contains multiple lines, only the first line is returned.
|
|
2732
|
-
* Memoised to minimize re-renders
|
|
2733
|
-
*
|
|
2734
|
-
* @param {string} value
|
|
2735
|
-
* @param {Object} [options]
|
|
2736
|
-
* @param {boolean} [options.debug = false]
|
|
2737
|
-
* @param {boolean} [options.strict = false]
|
|
2738
|
-
* @param {Function} [options.buildDebugString]
|
|
2739
|
-
*
|
|
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
|
+
*
|
|
2740
2771
|
*/
|
|
2741
2772
|
function useSingleLineTemplateEvaluation(value, options = {}) {
|
|
2742
2773
|
const evaluatedTemplate = useTemplateEvaluation(value, options);
|
|
@@ -2940,8 +2971,8 @@ function createEmptyOptions(options = {}) {
|
|
|
2940
2971
|
};
|
|
2941
2972
|
}
|
|
2942
2973
|
|
|
2943
|
-
/**
|
|
2944
|
-
* @enum { String }
|
|
2974
|
+
/**
|
|
2975
|
+
* @enum { String }
|
|
2945
2976
|
*/
|
|
2946
2977
|
const LOAD_STATES = {
|
|
2947
2978
|
LOADING: 'loading',
|
|
@@ -2949,17 +2980,17 @@ const LOAD_STATES = {
|
|
|
2949
2980
|
ERROR: 'error'
|
|
2950
2981
|
};
|
|
2951
2982
|
|
|
2952
|
-
/**
|
|
2953
|
-
* @typedef {Object} ValuesGetter
|
|
2954
|
-
* @property {Object[]} values - The values data
|
|
2955
|
-
* @property {(LOAD_STATES)} state - The values data's loading state, to use for conditional rendering
|
|
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
|
|
2956
2987
|
*/
|
|
2957
2988
|
|
|
2958
|
-
/**
|
|
2959
|
-
* A hook to load values for single and multiselect components.
|
|
2960
|
-
*
|
|
2961
|
-
* @param {Object} field - The form field to handle values for
|
|
2962
|
-
* @return {ValuesGetter} valuesGetter - A values getter object providing loading state and values
|
|
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
|
|
2963
2994
|
*/
|
|
2964
2995
|
function useValuesAsync (field) {
|
|
2965
2996
|
const {
|
|
@@ -2973,11 +3004,8 @@ function useValuesAsync (field) {
|
|
|
2973
3004
|
state: LOAD_STATES.LOADING
|
|
2974
3005
|
});
|
|
2975
3006
|
const initialData = useService('form')._getState().initialData;
|
|
2976
|
-
const
|
|
2977
|
-
|
|
2978
|
-
return useExpressionEvaluation(valuesExpression);
|
|
2979
|
-
}
|
|
2980
|
-
}, [valuesExpression]);
|
|
3007
|
+
const expressionEvaluation = useExpressionEvaluation(valuesExpression);
|
|
3008
|
+
const evaluatedValues = useDeepCompareState(expressionEvaluation || [], []);
|
|
2981
3009
|
useEffect(() => {
|
|
2982
3010
|
let values = [];
|
|
2983
3011
|
|
|
@@ -2993,8 +3021,10 @@ function useValuesAsync (field) {
|
|
|
2993
3021
|
values = Array.isArray(staticValues) ? staticValues : [];
|
|
2994
3022
|
|
|
2995
3023
|
// expression
|
|
2996
|
-
} else if (
|
|
2997
|
-
|
|
3024
|
+
} else if (valuesExpression) {
|
|
3025
|
+
if (evaluatedValues && Array.isArray(evaluatedValues)) {
|
|
3026
|
+
values = evaluatedValues;
|
|
3027
|
+
}
|
|
2998
3028
|
} else {
|
|
2999
3029
|
setValuesGetter(buildErrorState('No values source defined in the form definition'));
|
|
3000
3030
|
return;
|
|
@@ -3003,7 +3033,7 @@ function useValuesAsync (field) {
|
|
|
3003
3033
|
// normalize data to support primitives and partially defined objects
|
|
3004
3034
|
values = normalizeValuesData(values);
|
|
3005
3035
|
setValuesGetter(buildLoadedState(values));
|
|
3006
|
-
}, [valuesKey, staticValues, initialData]);
|
|
3036
|
+
}, [valuesKey, staticValues, initialData, valuesExpression, evaluatedValues]);
|
|
3007
3037
|
return valuesGetter;
|
|
3008
3038
|
}
|
|
3009
3039
|
const buildErrorState = error => ({
|
|
@@ -3469,12 +3499,12 @@ var SvgCalendar = function SvgCalendar(props) {
|
|
|
3469
3499
|
};
|
|
3470
3500
|
var CalendarIcon = SvgCalendar;
|
|
3471
3501
|
|
|
3472
|
-
/**
|
|
3473
|
-
* Returns date format for the provided locale.
|
|
3474
|
-
* If the locale is not provided, uses the browser's locale.
|
|
3475
|
-
*
|
|
3476
|
-
* @param {string} [locale] - The locale to get date format for.
|
|
3477
|
-
* @returns {string} The date format for the locale.
|
|
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.
|
|
3478
3508
|
*/
|
|
3479
3509
|
function getLocaleDateFormat(locale = 'default') {
|
|
3480
3510
|
const parts = new Intl.DateTimeFormat(locale).formatToParts(new Date(Date.UTC(2020, 5, 5)));
|
|
@@ -3493,12 +3523,12 @@ function getLocaleDateFormat(locale = 'default') {
|
|
|
3493
3523
|
}).join('');
|
|
3494
3524
|
}
|
|
3495
3525
|
|
|
3496
|
-
/**
|
|
3497
|
-
* Returns readable date format for the provided locale.
|
|
3498
|
-
* If the locale is not provided, uses the browser's locale.
|
|
3499
|
-
*
|
|
3500
|
-
* @param {string} [locale] - The locale to get readable date format for.
|
|
3501
|
-
* @returns {string} The readable date format for the locale.
|
|
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.
|
|
3502
3532
|
*/
|
|
3503
3533
|
function getLocaleReadableDateFormat(locale) {
|
|
3504
3534
|
let format = getLocaleDateFormat(locale).toLowerCase();
|
|
@@ -3515,12 +3545,12 @@ function getLocaleReadableDateFormat(locale) {
|
|
|
3515
3545
|
return format;
|
|
3516
3546
|
}
|
|
3517
3547
|
|
|
3518
|
-
/**
|
|
3519
|
-
* Returns flatpickr config for the provided locale.
|
|
3520
|
-
* If the locale is not provided, uses the browser's locale.
|
|
3521
|
-
*
|
|
3522
|
-
* @param {string} [locale] - The locale to get flatpickr config for.
|
|
3523
|
-
* @returns {object} The flatpickr config for the locale.
|
|
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.
|
|
3524
3554
|
*/
|
|
3525
3555
|
function getLocaleDateFlatpickrConfig(locale) {
|
|
3526
3556
|
return flatpickerizeDateFormat(getLocaleDateFormat(locale));
|
|
@@ -3788,7 +3818,8 @@ function DropdownList(props) {
|
|
|
3788
3818
|
useEffect(() => {
|
|
3789
3819
|
const individualEntries = dropdownContainer.current.children;
|
|
3790
3820
|
if (individualEntries.length && !mouseControl) {
|
|
3791
|
-
individualEntries[focusedValueIndex]
|
|
3821
|
+
const focusedEntry = individualEntries[focusedValueIndex];
|
|
3822
|
+
focusedEntry && focusedEntry.scrollIntoView({
|
|
3792
3823
|
block: 'nearest',
|
|
3793
3824
|
inline: 'nearest'
|
|
3794
3825
|
});
|
|
@@ -4199,10 +4230,10 @@ Datetime.config = {
|
|
|
4199
4230
|
}
|
|
4200
4231
|
};
|
|
4201
4232
|
|
|
4202
|
-
/**
|
|
4203
|
-
* This file must not be changed or exchanged.
|
|
4204
|
-
*
|
|
4205
|
-
* @see http://bpmn.io/license for more information.
|
|
4233
|
+
/**
|
|
4234
|
+
* This file must not be changed or exchanged.
|
|
4235
|
+
*
|
|
4236
|
+
* @see http://bpmn.io/license for more information.
|
|
4206
4237
|
*/
|
|
4207
4238
|
function Logo() {
|
|
4208
4239
|
return jsxs("svg", {
|
|
@@ -4380,11 +4411,11 @@ const ATTR_WHITESPACE_PATTERN = /[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u
|
|
|
4380
4411
|
|
|
4381
4412
|
const FORM_ELEMENT = document.createElement('form');
|
|
4382
4413
|
|
|
4383
|
-
/**
|
|
4384
|
-
* Sanitize a HTML string and return the cleaned, safe version.
|
|
4385
|
-
*
|
|
4386
|
-
* @param {string} html
|
|
4387
|
-
* @return {string}
|
|
4414
|
+
/**
|
|
4415
|
+
* Sanitize a HTML string and return the cleaned, safe version.
|
|
4416
|
+
*
|
|
4417
|
+
* @param {string} html
|
|
4418
|
+
* @return {string}
|
|
4388
4419
|
*/
|
|
4389
4420
|
|
|
4390
4421
|
// see https://github.com/developit/snarkdown/issues/70
|
|
@@ -4402,29 +4433,29 @@ function sanitizeHTML(html) {
|
|
|
4402
4433
|
}
|
|
4403
4434
|
}
|
|
4404
4435
|
|
|
4405
|
-
/**
|
|
4406
|
-
* Sanitizes an image source to ensure we only allow for data URI and links
|
|
4407
|
-
* that start with http(s).
|
|
4408
|
-
*
|
|
4409
|
-
* Note: Most browsers anyway do not support script execution in <img> elements.
|
|
4410
|
-
*
|
|
4411
|
-
* @param {string} src
|
|
4412
|
-
* @returns {string}
|
|
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}
|
|
4413
4444
|
*/
|
|
4414
4445
|
function sanitizeImageSource(src) {
|
|
4415
4446
|
const valid = ALLOWED_IMAGE_SRC_PATTERN.test(src);
|
|
4416
4447
|
return valid ? src : '';
|
|
4417
4448
|
}
|
|
4418
4449
|
|
|
4419
|
-
/**
|
|
4420
|
-
* Recursively sanitize a HTML node, potentially
|
|
4421
|
-
* removing it, its children or attributes.
|
|
4422
|
-
*
|
|
4423
|
-
* Inspired by https://github.com/developit/snarkdown/issues/70
|
|
4424
|
-
* and https://github.com/cure53/DOMPurify. Simplified
|
|
4425
|
-
* for our use-case.
|
|
4426
|
-
*
|
|
4427
|
-
* @param {Element} node
|
|
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
|
|
4428
4459
|
*/
|
|
4429
4460
|
function sanitizeNode(node) {
|
|
4430
4461
|
// allow text nodes
|
|
@@ -4468,13 +4499,13 @@ function sanitizeNode(node) {
|
|
|
4468
4499
|
}
|
|
4469
4500
|
}
|
|
4470
4501
|
|
|
4471
|
-
/**
|
|
4472
|
-
* Validates attributes for validity.
|
|
4473
|
-
*
|
|
4474
|
-
* @param {string} lcTag
|
|
4475
|
-
* @param {string} lcName
|
|
4476
|
-
* @param {string} value
|
|
4477
|
-
* @return {boolean}
|
|
4502
|
+
/**
|
|
4503
|
+
* Validates attributes for validity.
|
|
4504
|
+
*
|
|
4505
|
+
* @param {string} lcTag
|
|
4506
|
+
* @param {string} lcName
|
|
4507
|
+
* @param {string} value
|
|
4508
|
+
* @return {boolean}
|
|
4478
4509
|
*/
|
|
4479
4510
|
function isValidAttribute(lcTag, lcName, value) {
|
|
4480
4511
|
// disallow most attributes based on whitelist
|
|
@@ -6202,55 +6233,55 @@ var core = {
|
|
|
6202
6233
|
validator: ['type', Validator]
|
|
6203
6234
|
};
|
|
6204
6235
|
|
|
6205
|
-
/**
|
|
6206
|
-
* @typedef { import('./types').Injector } Injector
|
|
6207
|
-
* @typedef { import('./types').Data } Data
|
|
6208
|
-
* @typedef { import('./types').Errors } Errors
|
|
6209
|
-
* @typedef { import('./types').Schema } Schema
|
|
6210
|
-
* @typedef { import('./types').FormProperties } FormProperties
|
|
6211
|
-
* @typedef { import('./types').FormProperty } FormProperty
|
|
6212
|
-
* @typedef { import('./types').FormEvent } FormEvent
|
|
6213
|
-
* @typedef { import('./types').FormOptions } FormOptions
|
|
6214
|
-
*
|
|
6215
|
-
* @typedef { {
|
|
6216
|
-
* data: Data,
|
|
6217
|
-
* initialData: Data,
|
|
6218
|
-
* errors: Errors,
|
|
6219
|
-
* properties: FormProperties,
|
|
6220
|
-
* schema: Schema
|
|
6221
|
-
* } } State
|
|
6222
|
-
*
|
|
6223
|
-
* @typedef { (type:FormEvent, priority:number, handler:Function) => void } OnEventWithPriority
|
|
6224
|
-
* @typedef { (type:FormEvent, handler:Function) => void } OnEventWithOutPriority
|
|
6225
|
-
* @typedef { OnEventWithPriority & OnEventWithOutPriority } OnEventType
|
|
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
|
|
6226
6257
|
*/
|
|
6227
6258
|
|
|
6228
6259
|
const ids = new Ids([32, 36, 1]);
|
|
6229
6260
|
|
|
6230
|
-
/**
|
|
6231
|
-
* The form.
|
|
6261
|
+
/**
|
|
6262
|
+
* The form.
|
|
6232
6263
|
*/
|
|
6233
6264
|
class Form {
|
|
6234
|
-
/**
|
|
6235
|
-
* @constructor
|
|
6236
|
-
* @param {FormOptions} options
|
|
6265
|
+
/**
|
|
6266
|
+
* @constructor
|
|
6267
|
+
* @param {FormOptions} options
|
|
6237
6268
|
*/
|
|
6238
6269
|
constructor(options = {}) {
|
|
6239
|
-
/**
|
|
6240
|
-
* @public
|
|
6241
|
-
* @type {OnEventType}
|
|
6270
|
+
/**
|
|
6271
|
+
* @public
|
|
6272
|
+
* @type {OnEventType}
|
|
6242
6273
|
*/
|
|
6243
6274
|
this.on = this._onEvent;
|
|
6244
6275
|
|
|
6245
|
-
/**
|
|
6246
|
-
* @public
|
|
6247
|
-
* @type {String}
|
|
6276
|
+
/**
|
|
6277
|
+
* @public
|
|
6278
|
+
* @type {String}
|
|
6248
6279
|
*/
|
|
6249
6280
|
this._id = ids.next();
|
|
6250
6281
|
|
|
6251
|
-
/**
|
|
6252
|
-
* @private
|
|
6253
|
-
* @type {Element}
|
|
6282
|
+
/**
|
|
6283
|
+
* @private
|
|
6284
|
+
* @type {Element}
|
|
6254
6285
|
*/
|
|
6255
6286
|
this._container = createFormContainer();
|
|
6256
6287
|
const {
|
|
@@ -6259,9 +6290,9 @@ class Form {
|
|
|
6259
6290
|
properties = {}
|
|
6260
6291
|
} = options;
|
|
6261
6292
|
|
|
6262
|
-
/**
|
|
6263
|
-
* @private
|
|
6264
|
-
* @type {State}
|
|
6293
|
+
/**
|
|
6294
|
+
* @private
|
|
6295
|
+
* @type {State}
|
|
6265
6296
|
*/
|
|
6266
6297
|
this._state = {
|
|
6267
6298
|
initialData: null,
|
|
@@ -6285,9 +6316,9 @@ class Form {
|
|
|
6285
6316
|
this._emit('form.clear');
|
|
6286
6317
|
}
|
|
6287
6318
|
|
|
6288
|
-
/**
|
|
6289
|
-
* Destroy the form, removing it from DOM,
|
|
6290
|
-
* if attached.
|
|
6319
|
+
/**
|
|
6320
|
+
* Destroy the form, removing it from DOM,
|
|
6321
|
+
* if attached.
|
|
6291
6322
|
*/
|
|
6292
6323
|
destroy() {
|
|
6293
6324
|
// destroy form services
|
|
@@ -6298,13 +6329,13 @@ class Form {
|
|
|
6298
6329
|
this._detach(false);
|
|
6299
6330
|
}
|
|
6300
6331
|
|
|
6301
|
-
/**
|
|
6302
|
-
* Open a form schema with the given initial data.
|
|
6303
|
-
*
|
|
6304
|
-
* @param {Schema} schema
|
|
6305
|
-
* @param {Data} [data]
|
|
6306
|
-
*
|
|
6307
|
-
* @return Promise<{ warnings: Array<any> }>
|
|
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> }>
|
|
6308
6339
|
*/
|
|
6309
6340
|
importSchema(schema, data = {}) {
|
|
6310
6341
|
return new Promise((resolve, reject) => {
|
|
@@ -6337,10 +6368,10 @@ class Form {
|
|
|
6337
6368
|
});
|
|
6338
6369
|
}
|
|
6339
6370
|
|
|
6340
|
-
/**
|
|
6341
|
-
* Submit the form, triggering all field validations.
|
|
6342
|
-
*
|
|
6343
|
-
* @returns { { data: Data, errors: Errors } }
|
|
6371
|
+
/**
|
|
6372
|
+
* Submit the form, triggering all field validations.
|
|
6373
|
+
*
|
|
6374
|
+
* @returns { { data: Data, errors: Errors } }
|
|
6344
6375
|
*/
|
|
6345
6376
|
submit() {
|
|
6346
6377
|
const {
|
|
@@ -6367,8 +6398,8 @@ class Form {
|
|
|
6367
6398
|
});
|
|
6368
6399
|
}
|
|
6369
6400
|
|
|
6370
|
-
/**
|
|
6371
|
-
* @returns {Errors}
|
|
6401
|
+
/**
|
|
6402
|
+
* @returns {Errors}
|
|
6372
6403
|
*/
|
|
6373
6404
|
validate() {
|
|
6374
6405
|
const formFieldRegistry = this.get('formFieldRegistry'),
|
|
@@ -6394,8 +6425,8 @@ class Form {
|
|
|
6394
6425
|
return errors;
|
|
6395
6426
|
}
|
|
6396
6427
|
|
|
6397
|
-
/**
|
|
6398
|
-
* @param {Element|string} parentNode
|
|
6428
|
+
/**
|
|
6429
|
+
* @param {Element|string} parentNode
|
|
6399
6430
|
*/
|
|
6400
6431
|
attachTo(parentNode) {
|
|
6401
6432
|
if (!parentNode) {
|
|
@@ -6413,10 +6444,10 @@ class Form {
|
|
|
6413
6444
|
this._detach();
|
|
6414
6445
|
}
|
|
6415
6446
|
|
|
6416
|
-
/**
|
|
6417
|
-
* @private
|
|
6418
|
-
*
|
|
6419
|
-
* @param {boolean} [emit]
|
|
6447
|
+
/**
|
|
6448
|
+
* @private
|
|
6449
|
+
*
|
|
6450
|
+
* @param {boolean} [emit]
|
|
6420
6451
|
*/
|
|
6421
6452
|
_detach(emit = true) {
|
|
6422
6453
|
const container = this._container,
|
|
@@ -6430,9 +6461,9 @@ class Form {
|
|
|
6430
6461
|
parentNode.removeChild(container);
|
|
6431
6462
|
}
|
|
6432
6463
|
|
|
6433
|
-
/**
|
|
6434
|
-
* @param {FormProperty} property
|
|
6435
|
-
* @param {any} value
|
|
6464
|
+
/**
|
|
6465
|
+
* @param {FormProperty} property
|
|
6466
|
+
* @param {any} value
|
|
6436
6467
|
*/
|
|
6437
6468
|
setProperty(property, value) {
|
|
6438
6469
|
const properties = set(this._getState().properties, [property], value);
|
|
@@ -6441,21 +6472,21 @@ class Form {
|
|
|
6441
6472
|
});
|
|
6442
6473
|
}
|
|
6443
6474
|
|
|
6444
|
-
/**
|
|
6445
|
-
* @param {FormEvent} type
|
|
6446
|
-
* @param {Function} handler
|
|
6475
|
+
/**
|
|
6476
|
+
* @param {FormEvent} type
|
|
6477
|
+
* @param {Function} handler
|
|
6447
6478
|
*/
|
|
6448
6479
|
off(type, handler) {
|
|
6449
6480
|
this.get('eventBus').off(type, handler);
|
|
6450
6481
|
}
|
|
6451
6482
|
|
|
6452
|
-
/**
|
|
6453
|
-
* @private
|
|
6454
|
-
*
|
|
6455
|
-
* @param {FormOptions} options
|
|
6456
|
-
* @param {Element} container
|
|
6457
|
-
*
|
|
6458
|
-
* @returns {Injector}
|
|
6483
|
+
/**
|
|
6484
|
+
* @private
|
|
6485
|
+
*
|
|
6486
|
+
* @param {FormOptions} options
|
|
6487
|
+
* @param {Element} container
|
|
6488
|
+
*
|
|
6489
|
+
* @returns {Injector}
|
|
6459
6490
|
*/
|
|
6460
6491
|
_createInjector(options, container) {
|
|
6461
6492
|
const {
|
|
@@ -6474,17 +6505,17 @@ class Form {
|
|
|
6474
6505
|
}, core, ...modules, ...additionalModules]);
|
|
6475
6506
|
}
|
|
6476
6507
|
|
|
6477
|
-
/**
|
|
6478
|
-
* @private
|
|
6508
|
+
/**
|
|
6509
|
+
* @private
|
|
6479
6510
|
*/
|
|
6480
6511
|
_emit(type, data) {
|
|
6481
6512
|
this.get('eventBus').fire(type, data);
|
|
6482
6513
|
}
|
|
6483
6514
|
|
|
6484
|
-
/**
|
|
6485
|
-
* @internal
|
|
6486
|
-
*
|
|
6487
|
-
* @param { { add?: boolean, field: any, remove?: number, value?: any } } update
|
|
6515
|
+
/**
|
|
6516
|
+
* @internal
|
|
6517
|
+
*
|
|
6518
|
+
* @param { { add?: boolean, field: any, remove?: number, value?: any } } update
|
|
6488
6519
|
*/
|
|
6489
6520
|
_update(update) {
|
|
6490
6521
|
const {
|
|
@@ -6506,15 +6537,15 @@ class Form {
|
|
|
6506
6537
|
});
|
|
6507
6538
|
}
|
|
6508
6539
|
|
|
6509
|
-
/**
|
|
6510
|
-
* @internal
|
|
6540
|
+
/**
|
|
6541
|
+
* @internal
|
|
6511
6542
|
*/
|
|
6512
6543
|
_getState() {
|
|
6513
6544
|
return this._state;
|
|
6514
6545
|
}
|
|
6515
6546
|
|
|
6516
|
-
/**
|
|
6517
|
-
* @internal
|
|
6547
|
+
/**
|
|
6548
|
+
* @internal
|
|
6518
6549
|
*/
|
|
6519
6550
|
_setState(state) {
|
|
6520
6551
|
this._state = {
|
|
@@ -6524,22 +6555,22 @@ class Form {
|
|
|
6524
6555
|
this._emit('changed', this._getState());
|
|
6525
6556
|
}
|
|
6526
6557
|
|
|
6527
|
-
/**
|
|
6528
|
-
* @internal
|
|
6558
|
+
/**
|
|
6559
|
+
* @internal
|
|
6529
6560
|
*/
|
|
6530
6561
|
_getModules() {
|
|
6531
6562
|
return [ExpressionLanguageModule, MarkdownModule, ViewerCommandsModule];
|
|
6532
6563
|
}
|
|
6533
6564
|
|
|
6534
|
-
/**
|
|
6535
|
-
* @internal
|
|
6565
|
+
/**
|
|
6566
|
+
* @internal
|
|
6536
6567
|
*/
|
|
6537
6568
|
_onEvent(type, priority, handler) {
|
|
6538
6569
|
this.get('eventBus').on(type, priority, handler);
|
|
6539
6570
|
}
|
|
6540
6571
|
|
|
6541
|
-
/**
|
|
6542
|
-
* @internal
|
|
6572
|
+
/**
|
|
6573
|
+
* @internal
|
|
6543
6574
|
*/
|
|
6544
6575
|
_getSubmitData() {
|
|
6545
6576
|
const formFieldRegistry = this.get('formFieldRegistry'),
|
|
@@ -6567,16 +6598,16 @@ class Form {
|
|
|
6567
6598
|
return filteredSubmitData;
|
|
6568
6599
|
}
|
|
6569
6600
|
|
|
6570
|
-
/**
|
|
6571
|
-
* @internal
|
|
6601
|
+
/**
|
|
6602
|
+
* @internal
|
|
6572
6603
|
*/
|
|
6573
6604
|
_applyConditions(toFilter, data) {
|
|
6574
6605
|
const conditionChecker = this.get('conditionChecker');
|
|
6575
6606
|
return conditionChecker.applyConditions(toFilter, data);
|
|
6576
6607
|
}
|
|
6577
6608
|
|
|
6578
|
-
/**
|
|
6579
|
-
* @internal
|
|
6609
|
+
/**
|
|
6610
|
+
* @internal
|
|
6580
6611
|
*/
|
|
6581
6612
|
_initializeFieldData(data) {
|
|
6582
6613
|
const formFieldRegistry = this.get('formFieldRegistry'),
|
|
@@ -6638,5 +6669,5 @@ function createForm(options) {
|
|
|
6638
6669
|
});
|
|
6639
6670
|
}
|
|
6640
6671
|
|
|
6641
|
-
export { Button, Checkbox, Checklist, ConditionChecker, DATETIME_SUBTYPES, DATETIME_SUBTYPES_LABELS, DATETIME_SUBTYPE_PATH, DATE_DISALLOW_PAST_PATH, DATE_LABEL_PATH, Datetime, FormComponent$1 as Default, ExpressionLanguageModule, FeelExpressionLanguage, FeelersTemplating, FieldFactory, Form, FormComponent, FormContext$1 as FormContext, FormFieldRegistry, FormFields, FormLayouter, FormRenderContext$1 as FormRenderContext, Group, Image, Importer, MINUTES_IN_DAY, MarkdownModule, MarkdownRenderer, Numberfield, PathRegistry, Radio, Select, Spacer, TIME_INTERVAL_PATH, TIME_LABEL_PATH, TIME_SERIALISINGFORMAT_LABELS, TIME_SERIALISING_FORMATS, TIME_SERIALISING_FORMAT_PATH, TIME_USE24H_PATH, Taglist, Text, Textarea, Textfield, VALUES_SOURCES, VALUES_SOURCES_DEFAULTS, VALUES_SOURCES_LABELS, VALUES_SOURCES_PATHS, VALUES_SOURCE_DEFAULT, ViewerCommands, ViewerCommandsModule, clone, createForm, createFormContainer, createInjector, formFields, generateIdForType, generateIndexForType, getSchemaVariables, getValuesSource, iconsByType, isRequired, pathParse, pathsEqual, runRecursively, schemaVersion };
|
|
6672
|
+
export { Button, Checkbox, Checklist, ConditionChecker, DATETIME_SUBTYPES, DATETIME_SUBTYPES_LABELS, DATETIME_SUBTYPE_PATH, DATE_DISALLOW_PAST_PATH, DATE_LABEL_PATH, Datetime, FormComponent$1 as Default, ExpressionLanguageModule, FeelExpressionLanguage, FeelersTemplating, FieldFactory, Form, FormComponent, FormContext$1 as FormContext, FormField, FormFieldRegistry, FormFields, FormLayouter, FormRenderContext$1 as FormRenderContext, Group, Image, Importer, MINUTES_IN_DAY, MarkdownModule, MarkdownRenderer, Numberfield, PathRegistry, Radio, Select, Spacer, TIME_INTERVAL_PATH, TIME_LABEL_PATH, TIME_SERIALISINGFORMAT_LABELS, TIME_SERIALISING_FORMATS, TIME_SERIALISING_FORMAT_PATH, TIME_USE24H_PATH, Taglist, Text, Textarea, Textfield, VALUES_SOURCES, VALUES_SOURCES_DEFAULTS, VALUES_SOURCES_LABELS, VALUES_SOURCES_PATHS, VALUES_SOURCE_DEFAULT, ViewerCommands, ViewerCommandsModule, clone, createForm, createFormContainer, createInjector, formFields, generateIdForType, generateIndexForType, getSchemaVariables, getValuesSource, iconsByType, isRequired, pathParse, pathsEqual, runRecursively, schemaVersion };
|
|
6642
6673
|
//# sourceMappingURL=index.es.js.map
|