@bpmn-io/form-js-viewer 1.21.2 → 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 +63 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.es.js +63 -5
- 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) {
|
|
@@ -9817,11 +9868,18 @@ class Form {
|
|
|
9817
9868
|
const validator = this.get('validator');
|
|
9818
9869
|
const fieldErrors = validator.validateFieldInstance(fieldInstance, value);
|
|
9819
9870
|
set(data, valuePath, value);
|
|
9820
|
-
|
|
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
|
+
}
|
|
9821
9879
|
this._emit('field.updated', update);
|
|
9822
9880
|
this._setState({
|
|
9823
9881
|
data: clone(data),
|
|
9824
|
-
errors: clone(
|
|
9882
|
+
errors: clone(nextErrors)
|
|
9825
9883
|
});
|
|
9826
9884
|
}
|
|
9827
9885
|
|
|
@@ -9997,5 +10055,5 @@ function createForm(options) {
|
|
|
9997
10055
|
});
|
|
9998
10056
|
}
|
|
9999
10057
|
|
|
10000
|
-
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 };
|
|
10001
10059
|
//# sourceMappingURL=index.es.js.map
|