@bpmn-io/form-js-viewer 1.21.1 → 1.21.3
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 +79 -8
- package/dist/index.cjs.map +1 -1
- package/dist/index.es.js +79 -9
- package/dist/index.es.js.map +1 -1
- package/dist/types/util/simple.d.ts +17 -0
- package/package.json +3 -3
package/dist/index.es.js
CHANGED
|
@@ -843,6 +843,50 @@ function runRecursively(formField, fn) {
|
|
|
843
843
|
});
|
|
844
844
|
fn(formField);
|
|
845
845
|
}
|
|
846
|
+
|
|
847
|
+
/**
|
|
848
|
+
* Returns a copy of `target` with the value at `path` removed, pruning any
|
|
849
|
+
* ancestor that becomes empty. Pure: the input is not mutated and untouched
|
|
850
|
+
* sibling branches keep their original references (path-cloning).
|
|
851
|
+
*
|
|
852
|
+
* Pruning rules:
|
|
853
|
+
* - An object ancestor is removed when it has no own keys left.
|
|
854
|
+
* - An array ancestor is removed when every entry is nullish. Arrays are
|
|
855
|
+
* never compacted; `delete` leaves a sparse hole so sibling indexes stay
|
|
856
|
+
* stable.
|
|
857
|
+
*
|
|
858
|
+
* @template T
|
|
859
|
+
* @param {T} target
|
|
860
|
+
* @param {Array<string|number>} path
|
|
861
|
+
* @returns {T}
|
|
862
|
+
*/
|
|
863
|
+
function pruneAt(target, path) {
|
|
864
|
+
if (!path.length) {
|
|
865
|
+
return target;
|
|
866
|
+
}
|
|
867
|
+
const cloneContainer = c => Array.isArray(c) ? c.slice() : {
|
|
868
|
+
...c
|
|
869
|
+
};
|
|
870
|
+
const clones = [cloneContainer(target)];
|
|
871
|
+
for (let i = 0; i < path.length - 1; i++) {
|
|
872
|
+
const next = clones[i][path[i]];
|
|
873
|
+
if (next == null || typeof next !== 'object') {
|
|
874
|
+
return target;
|
|
875
|
+
}
|
|
876
|
+
const cloned = cloneContainer(next);
|
|
877
|
+
clones[i][path[i]] = cloned;
|
|
878
|
+
clones.push(cloned);
|
|
879
|
+
}
|
|
880
|
+
delete clones[clones.length - 1][path[path.length - 1]];
|
|
881
|
+
for (let i = clones.length - 1; i > 0; i--) {
|
|
882
|
+
if (Object.values(clones[i]).every(v => v == null)) {
|
|
883
|
+
delete clones[i - 1][path[i - 1]];
|
|
884
|
+
} else {
|
|
885
|
+
break;
|
|
886
|
+
}
|
|
887
|
+
}
|
|
888
|
+
return clones[0];
|
|
889
|
+
}
|
|
846
890
|
function wrapObjectKeysWithUnderscores(obj) {
|
|
847
891
|
const newObj = {};
|
|
848
892
|
for (const [key, value] of Object.entries(obj)) {
|
|
@@ -7454,9 +7498,16 @@ class UpdateFieldInstanceValidationHandler {
|
|
|
7454
7498
|
} = this._form._getState();
|
|
7455
7499
|
context.oldErrors = clone(errors);
|
|
7456
7500
|
const fieldErrors = this._validator.validateFieldInstance(fieldInstance, value);
|
|
7457
|
-
const
|
|
7501
|
+
const errorPath = [id, ...Object.values(indexes || {})];
|
|
7502
|
+
let nextErrors;
|
|
7503
|
+
if (fieldErrors.length) {
|
|
7504
|
+
set(errors, errorPath, fieldErrors);
|
|
7505
|
+
nextErrors = errors;
|
|
7506
|
+
} else {
|
|
7507
|
+
nextErrors = pruneAt(errors, errorPath);
|
|
7508
|
+
}
|
|
7458
7509
|
this._form._setState({
|
|
7459
|
-
errors:
|
|
7510
|
+
errors: nextErrors
|
|
7460
7511
|
});
|
|
7461
7512
|
}
|
|
7462
7513
|
revert(context) {
|
|
@@ -8479,11 +8530,23 @@ function runPresetValidation(field, validation, value) {
|
|
|
8479
8530
|
errors.push('Field is required.');
|
|
8480
8531
|
}
|
|
8481
8532
|
}
|
|
8482
|
-
if ('min' in validation && (value || value === 0)
|
|
8483
|
-
|
|
8533
|
+
if ('min' in validation && (value || value === 0)) {
|
|
8534
|
+
try {
|
|
8535
|
+
if (Big(value).lt(Big(validation.min))) {
|
|
8536
|
+
errors.push(`Field must have minimum value of ${validation.min}.`);
|
|
8537
|
+
}
|
|
8538
|
+
} catch {
|
|
8539
|
+
errors.push('Min validation value is not a valid number.');
|
|
8540
|
+
}
|
|
8484
8541
|
}
|
|
8485
|
-
if ('max' in validation && (value || value === 0)
|
|
8486
|
-
|
|
8542
|
+
if ('max' in validation && (value || value === 0)) {
|
|
8543
|
+
try {
|
|
8544
|
+
if (Big(value).gt(Big(validation.max))) {
|
|
8545
|
+
errors.push(`Field must have maximum value of ${validation.max}.`);
|
|
8546
|
+
}
|
|
8547
|
+
} catch {
|
|
8548
|
+
errors.push('Max validation value is not a valid number.');
|
|
8549
|
+
}
|
|
8487
8550
|
}
|
|
8488
8551
|
if ('minLength' in validation && value && value.trim().length < validation.minLength) {
|
|
8489
8552
|
errors.push(`Field must have minimum length of ${validation.minLength}.`);
|
|
@@ -9805,11 +9868,18 @@ class Form {
|
|
|
9805
9868
|
const validator = this.get('validator');
|
|
9806
9869
|
const fieldErrors = validator.validateFieldInstance(fieldInstance, value);
|
|
9807
9870
|
set(data, valuePath, value);
|
|
9808
|
-
|
|
9871
|
+
const errorPath = [id, ...Object.values(indexes || {})];
|
|
9872
|
+
let nextErrors;
|
|
9873
|
+
if (fieldErrors.length) {
|
|
9874
|
+
set(errors, errorPath, fieldErrors);
|
|
9875
|
+
nextErrors = errors;
|
|
9876
|
+
} else {
|
|
9877
|
+
nextErrors = pruneAt(errors, errorPath);
|
|
9878
|
+
}
|
|
9809
9879
|
this._emit('field.updated', update);
|
|
9810
9880
|
this._setState({
|
|
9811
9881
|
data: clone(data),
|
|
9812
|
-
errors: clone(
|
|
9882
|
+
errors: clone(nextErrors)
|
|
9813
9883
|
});
|
|
9814
9884
|
}
|
|
9815
9885
|
|
|
@@ -9985,5 +10055,5 @@ function createForm(options) {
|
|
|
9985
10055
|
});
|
|
9986
10056
|
}
|
|
9987
10057
|
|
|
9988
|
-
export { ALLOW_ATTRIBUTE, Button, Checkbox, Checklist, ConditionChecker, DATETIME_SUBTYPES, DATETIME_SUBTYPES_LABELS, DATETIME_SUBTYPE_PATH, DATE_DISALLOW_PAST_PATH, DATE_LABEL_PATH, Datetime, Default, Description, DocumentPreview, DynamicList, Errors, ExpressionField, ExpressionFieldModule, ExpressionLanguageModule, ExpressionLoopPreventer, FeelExpressionLanguage, FeelersTemplating, FieldFactory, FilePicker, Form, FormComponent, FormContext, FormField, FormFieldRegistry, FormFields, FormLayouter, FormRenderContext, Group, Html, IFrame, Image, Importer, Label, LocalExpressionContext, MINUTES_IN_DAY, MarkdownRenderer, MarkdownRendererModule, Numberfield, OPTIONS_SOURCES, OPTIONS_SOURCES_DEFAULTS, OPTIONS_SOURCES_LABELS, OPTIONS_SOURCES_PATHS, OPTIONS_SOURCE_DEFAULT, PathRegistry, Radio, RenderModule, RepeatRenderManager, RepeatRenderModule, SANDBOX_ATTRIBUTE, SECURITY_ATTRIBUTES_DEFINITIONS, Select, Separator, Spacer, TEXT_VIEW_DEFAULT_TEXT, TIME_INTERVAL_PATH, TIME_LABEL_PATH, TIME_SERIALISINGFORMAT_LABELS, TIME_SERIALISING_FORMATS, TIME_SERIALISING_FORMAT_PATH, TIME_USE24H_PATH, Table, Taglist, Text, Textarea, Textfield, ViewerCommands, ViewerCommandsModule, buildExpressionContext, clone, createForm, createFormContainer, createInjector, escapeHTML, formFields, generateIdForType, generateIndexForType, getAncestryList, getOptionsSource, getSchemaVariables, getScrollContainer, hasEqualValue, iconsByType, isRequired, pathParse, pathsEqual, runExpressionEvaluation, runRecursively, runUnaryTestEvaluation, sanitizeDateTimePickerValue, sanitizeHTML, sanitizeIFrameSource, sanitizeImageSource, sanitizeMultiSelectValue, sanitizeSingleSelectValue, schemaVersion, useExpressionEvaluation, useSingleLineTemplateEvaluation, useTemplateEvaluation, wrapCSSStyles, wrapObjectKeysWithUnderscores };
|
|
10058
|
+
export { ALLOW_ATTRIBUTE, Button, Checkbox, Checklist, ConditionChecker, DATETIME_SUBTYPES, DATETIME_SUBTYPES_LABELS, DATETIME_SUBTYPE_PATH, DATE_DISALLOW_PAST_PATH, DATE_LABEL_PATH, Datetime, Default, Description, DocumentPreview, DynamicList, Errors, ExpressionField, ExpressionFieldModule, ExpressionLanguageModule, ExpressionLoopPreventer, FeelExpressionLanguage, FeelersTemplating, FieldFactory, FilePicker, Form, FormComponent, FormContext, FormField, FormFieldRegistry, FormFields, FormLayouter, FormRenderContext, Group, Html, IFrame, Image, Importer, Label, LocalExpressionContext, MINUTES_IN_DAY, MarkdownRenderer, MarkdownRendererModule, Numberfield, OPTIONS_SOURCES, OPTIONS_SOURCES_DEFAULTS, OPTIONS_SOURCES_LABELS, OPTIONS_SOURCES_PATHS, OPTIONS_SOURCE_DEFAULT, PathRegistry, Radio, RenderModule, RepeatRenderManager, RepeatRenderModule, SANDBOX_ATTRIBUTE, SECURITY_ATTRIBUTES_DEFINITIONS, Select, Separator, Spacer, TEXT_VIEW_DEFAULT_TEXT, TIME_INTERVAL_PATH, TIME_LABEL_PATH, TIME_SERIALISINGFORMAT_LABELS, TIME_SERIALISING_FORMATS, TIME_SERIALISING_FORMAT_PATH, TIME_USE24H_PATH, Table, Taglist, Text, Textarea, Textfield, ViewerCommands, ViewerCommandsModule, buildExpressionContext, clone, createForm, createFormContainer, createInjector, escapeHTML, formFields, generateIdForType, generateIndexForType, getAncestryList, getOptionsSource, getSchemaVariables, getScrollContainer, hasEqualValue, iconsByType, isRequired, pathParse, pathsEqual, pruneAt, runExpressionEvaluation, runRecursively, runUnaryTestEvaluation, sanitizeDateTimePickerValue, sanitizeHTML, sanitizeIFrameSource, sanitizeImageSource, sanitizeMultiSelectValue, sanitizeSingleSelectValue, schemaVersion, useExpressionEvaluation, useSingleLineTemplateEvaluation, useTemplateEvaluation, wrapCSSStyles, wrapObjectKeysWithUnderscores };
|
|
9989
10059
|
//# sourceMappingURL=index.es.js.map
|