@bpmn-io/form-js-viewer 1.21.2 → 1.23.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/dist/index.cjs +81 -18
- package/dist/index.cjs.map +1 -1
- package/dist/index.es.js +82 -20
- package/dist/index.es.js.map +1 -1
- package/dist/types/features/expressionLanguage/FeelersTemplating.d.ts +13 -13
- package/dist/types/render/components/util/numberFieldUtil.d.ts +1 -0
- package/dist/types/util/simple.d.ts +17 -0
- package/package.json +8 -8
package/dist/index.cjs
CHANGED
|
@@ -376,7 +376,7 @@ class FeelersTemplating {
|
|
|
376
376
|
* @param {Object} options
|
|
377
377
|
* @param {boolean} [options.debug = false]
|
|
378
378
|
* @param {boolean} [options.strict = false]
|
|
379
|
-
* @param {
|
|
379
|
+
* @param {(error: Error) => string} [options.buildDebugString]
|
|
380
380
|
* @param {Function} [options.sanitizer]
|
|
381
381
|
*
|
|
382
382
|
* @returns
|
|
@@ -403,20 +403,19 @@ class FeelersTemplating {
|
|
|
403
403
|
*/
|
|
404
404
|
|
|
405
405
|
/**
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
406
|
+
* Extracts all feel expressions in the template along with their depth in the syntax tree.
|
|
407
|
+
* The depth is incremented for child expressions of loops to account for context drilling.
|
|
408
|
+
* @name _extractExpressionsWithDepth
|
|
409
|
+
* @param {string} template - A feelers template string.
|
|
410
|
+
* @returns {Array<ExpressionWithDepth>} An array of objects, each containing the depth and the extracted expression.
|
|
411
|
+
*
|
|
412
|
+
* @example
|
|
413
|
+
* const template = "Hello {{user}}, you have:{{#loop items}}\n- {{amount}} {{name}}{{/loop}}.";
|
|
414
|
+
* const extractedExpressions = _extractExpressionsWithDepth(template);
|
|
415
|
+
*/
|
|
416
416
|
_extractExpressionsWithDepth(template) {
|
|
417
417
|
// build simplified feelers syntax tree
|
|
418
|
-
const
|
|
419
|
-
const tree = feelers.buildSimpleTree(parseTree, template);
|
|
418
|
+
const tree = feelers.parseToSimpleTree(template);
|
|
420
419
|
return function _traverse(n, depth = 0) {
|
|
421
420
|
if (['Feel', 'FeelBlock'].includes(n.name)) {
|
|
422
421
|
return [{
|
|
@@ -863,6 +862,50 @@ function runRecursively(formField, fn) {
|
|
|
863
862
|
});
|
|
864
863
|
fn(formField);
|
|
865
864
|
}
|
|
865
|
+
|
|
866
|
+
/**
|
|
867
|
+
* Returns a copy of `target` with the value at `path` removed, pruning any
|
|
868
|
+
* ancestor that becomes empty. Pure: the input is not mutated and untouched
|
|
869
|
+
* sibling branches keep their original references (path-cloning).
|
|
870
|
+
*
|
|
871
|
+
* Pruning rules:
|
|
872
|
+
* - An object ancestor is removed when it has no own keys left.
|
|
873
|
+
* - An array ancestor is removed when every entry is nullish. Arrays are
|
|
874
|
+
* never compacted; `delete` leaves a sparse hole so sibling indexes stay
|
|
875
|
+
* stable.
|
|
876
|
+
*
|
|
877
|
+
* @template T
|
|
878
|
+
* @param {T} target
|
|
879
|
+
* @param {Array<string|number>} path
|
|
880
|
+
* @returns {T}
|
|
881
|
+
*/
|
|
882
|
+
function pruneAt(target, path) {
|
|
883
|
+
if (!path.length) {
|
|
884
|
+
return target;
|
|
885
|
+
}
|
|
886
|
+
const cloneContainer = c => Array.isArray(c) ? c.slice() : {
|
|
887
|
+
...c
|
|
888
|
+
};
|
|
889
|
+
const clones = [cloneContainer(target)];
|
|
890
|
+
for (let i = 0; i < path.length - 1; i++) {
|
|
891
|
+
const next = clones[i][path[i]];
|
|
892
|
+
if (next == null || typeof next !== 'object') {
|
|
893
|
+
return target;
|
|
894
|
+
}
|
|
895
|
+
const cloned = cloneContainer(next);
|
|
896
|
+
clones[i][path[i]] = cloned;
|
|
897
|
+
clones.push(cloned);
|
|
898
|
+
}
|
|
899
|
+
delete clones[clones.length - 1][path[path.length - 1]];
|
|
900
|
+
for (let i = clones.length - 1; i > 0; i--) {
|
|
901
|
+
if (Object.values(clones[i]).every(v => v == null)) {
|
|
902
|
+
delete clones[i - 1][path[i - 1]];
|
|
903
|
+
} else {
|
|
904
|
+
break;
|
|
905
|
+
}
|
|
906
|
+
}
|
|
907
|
+
return clones[0];
|
|
908
|
+
}
|
|
866
909
|
function wrapObjectKeysWithUnderscores(obj) {
|
|
867
910
|
const newObj = {};
|
|
868
911
|
for (const [key, value] of Object.entries(obj)) {
|
|
@@ -3786,6 +3829,11 @@ function willKeyProduceValidNumber(key, previousValue, caretIndex, selectionWidt
|
|
|
3786
3829
|
function isNullEquivalentValue(value) {
|
|
3787
3830
|
return value === undefined || value === null || value === '';
|
|
3788
3831
|
}
|
|
3832
|
+
function serializeToInputString(value) {
|
|
3833
|
+
if (value === undefined || value === null) return '';
|
|
3834
|
+
if (typeof value !== 'string' && typeof value !== 'number') return '';
|
|
3835
|
+
return value.toString();
|
|
3836
|
+
}
|
|
3789
3837
|
|
|
3790
3838
|
const type$d = 'number';
|
|
3791
3839
|
function Numberfield(props) {
|
|
@@ -3869,7 +3917,7 @@ function Numberfield(props) {
|
|
|
3869
3917
|
const outerValueChanged = previousValue != value;
|
|
3870
3918
|
const outerValueEqualsCache = sanitize(value) === sanitize(cachedValue);
|
|
3871
3919
|
if (outerValueChanged && !outerValueEqualsCache) {
|
|
3872
|
-
setValue(value
|
|
3920
|
+
setValue(serializeToInputString(value));
|
|
3873
3921
|
}
|
|
3874
3922
|
|
|
3875
3923
|
// caches the value an increment/decrement operation will be based on
|
|
@@ -7474,9 +7522,16 @@ class UpdateFieldInstanceValidationHandler {
|
|
|
7474
7522
|
} = this._form._getState();
|
|
7475
7523
|
context.oldErrors = clone(errors);
|
|
7476
7524
|
const fieldErrors = this._validator.validateFieldInstance(fieldInstance, value);
|
|
7477
|
-
const
|
|
7525
|
+
const errorPath = [id, ...Object.values(indexes || {})];
|
|
7526
|
+
let nextErrors;
|
|
7527
|
+
if (fieldErrors.length) {
|
|
7528
|
+
minDash.set(errors, errorPath, fieldErrors);
|
|
7529
|
+
nextErrors = errors;
|
|
7530
|
+
} else {
|
|
7531
|
+
nextErrors = pruneAt(errors, errorPath);
|
|
7532
|
+
}
|
|
7478
7533
|
this._form._setState({
|
|
7479
|
-
errors:
|
|
7534
|
+
errors: nextErrors
|
|
7480
7535
|
});
|
|
7481
7536
|
}
|
|
7482
7537
|
revert(context) {
|
|
@@ -9837,11 +9892,18 @@ class Form {
|
|
|
9837
9892
|
const validator = this.get('validator');
|
|
9838
9893
|
const fieldErrors = validator.validateFieldInstance(fieldInstance, value);
|
|
9839
9894
|
minDash.set(data, valuePath, value);
|
|
9840
|
-
|
|
9895
|
+
const errorPath = [id, ...Object.values(indexes || {})];
|
|
9896
|
+
let nextErrors;
|
|
9897
|
+
if (fieldErrors.length) {
|
|
9898
|
+
minDash.set(errors, errorPath, fieldErrors);
|
|
9899
|
+
nextErrors = errors;
|
|
9900
|
+
} else {
|
|
9901
|
+
nextErrors = pruneAt(errors, errorPath);
|
|
9902
|
+
}
|
|
9841
9903
|
this._emit('field.updated', update);
|
|
9842
9904
|
this._setState({
|
|
9843
9905
|
data: clone(data),
|
|
9844
|
-
errors: clone(
|
|
9906
|
+
errors: clone(nextErrors)
|
|
9845
9907
|
});
|
|
9846
9908
|
}
|
|
9847
9909
|
|
|
@@ -10107,6 +10169,7 @@ exports.iconsByType = iconsByType;
|
|
|
10107
10169
|
exports.isRequired = isRequired;
|
|
10108
10170
|
exports.pathParse = pathParse;
|
|
10109
10171
|
exports.pathsEqual = pathsEqual;
|
|
10172
|
+
exports.pruneAt = pruneAt;
|
|
10110
10173
|
exports.runExpressionEvaluation = runExpressionEvaluation;
|
|
10111
10174
|
exports.runRecursively = runRecursively;
|
|
10112
10175
|
exports.runUnaryTestEvaluation = runUnaryTestEvaluation;
|