@formio/js 5.0.0-rc.99 → 5.1.0-rc.1
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/formio.embed.js +1 -1
- package/dist/formio.embed.min.js +1 -1
- package/dist/formio.embed.min.js.LICENSE.txt +1 -1
- package/dist/formio.form.js +122 -121
- package/dist/formio.form.min.js +1 -1
- package/dist/formio.form.min.js.LICENSE.txt +3 -11
- package/dist/formio.full.js +123 -122
- package/dist/formio.full.min.js +1 -1
- package/dist/formio.full.min.js.LICENSE.txt +3 -11
- package/dist/formio.js +3011 -281
- package/dist/formio.min.js +1 -1
- package/dist/formio.min.js.LICENSE.txt +14 -2
- package/dist/formio.utils.js +65 -54
- package/dist/formio.utils.min.js +1 -1
- package/dist/formio.utils.min.js.LICENSE.txt +7 -5
- package/lib/cjs/Webform.d.ts +8 -1
- package/lib/cjs/Webform.js +40 -32
- package/lib/cjs/WebformBuilder.js +22 -18
- package/lib/cjs/Wizard.d.ts +0 -1
- package/lib/cjs/Wizard.js +19 -33
- package/lib/cjs/components/Components.d.ts +0 -7
- package/lib/cjs/components/Components.js +1 -33
- package/lib/cjs/components/_classes/component/Component.d.ts +37 -7
- package/lib/cjs/components/_classes/component/Component.js +70 -26
- package/lib/cjs/components/_classes/component/editForm/Component.edit.validation.js +1 -1
- package/lib/cjs/components/_classes/componentModal/ComponentModal.d.ts +1 -0
- package/lib/cjs/components/_classes/componentModal/ComponentModal.js +1 -0
- package/lib/cjs/components/_classes/nested/NestedComponent.d.ts +4 -19
- package/lib/cjs/components/_classes/nested/NestedComponent.js +38 -53
- package/lib/cjs/components/_classes/nestedarray/NestedArrayComponent.d.ts +2 -1
- package/lib/cjs/components/_classes/nestedarray/NestedArrayComponent.js +7 -44
- package/lib/cjs/components/datagrid/DataGrid.d.ts +0 -1
- package/lib/cjs/components/datagrid/DataGrid.js +1 -45
- package/lib/cjs/components/datamap/DataMap.js +1 -2
- package/lib/cjs/components/editgrid/EditGrid.js +6 -6
- package/lib/cjs/components/form/Form.d.ts +8 -3
- package/lib/cjs/components/form/Form.js +26 -25
- package/lib/cjs/components/html/HTML.js +1 -1
- package/lib/cjs/components/selectboxes/SelectBoxes.js +8 -1
- package/lib/cjs/components/signature/Signature.d.ts +0 -1
- package/lib/cjs/components/signature/Signature.js +1 -1
- package/lib/cjs/utils/conditionOperators/DateGreaterThan.js +2 -2
- package/lib/cjs/utils/conditionOperators/IsEmptyValue.d.ts +2 -2
- package/lib/cjs/utils/conditionOperators/IsEmptyValue.js +2 -2
- package/lib/cjs/utils/conditionOperators/IsEqualTo.d.ts +2 -2
- package/lib/cjs/utils/conditionOperators/IsEqualTo.js +2 -2
- package/lib/cjs/utils/formUtils.d.ts +25 -14
- package/lib/cjs/utils/formUtils.js +11 -16
- package/lib/cjs/utils/utils.d.ts +1 -3
- package/lib/cjs/utils/utils.js +19 -35
- package/lib/mjs/Webform.d.ts +8 -1
- package/lib/mjs/Webform.js +37 -31
- package/lib/mjs/WebformBuilder.js +22 -18
- package/lib/mjs/Wizard.d.ts +0 -1
- package/lib/mjs/Wizard.js +16 -29
- package/lib/mjs/components/Components.d.ts +0 -7
- package/lib/mjs/components/Components.js +1 -32
- package/lib/mjs/components/_classes/component/Component.d.ts +37 -7
- package/lib/mjs/components/_classes/component/Component.js +80 -27
- package/lib/mjs/components/_classes/component/editForm/Component.edit.validation.js +1 -1
- package/lib/mjs/components/_classes/componentModal/ComponentModal.d.ts +1 -0
- package/lib/mjs/components/_classes/componentModal/ComponentModal.js +1 -0
- package/lib/mjs/components/_classes/nested/NestedComponent.d.ts +4 -19
- package/lib/mjs/components/_classes/nested/NestedComponent.js +39 -54
- package/lib/mjs/components/_classes/nestedarray/NestedArrayComponent.d.ts +2 -1
- package/lib/mjs/components/_classes/nestedarray/NestedArrayComponent.js +8 -43
- package/lib/mjs/components/datagrid/DataGrid.d.ts +0 -1
- package/lib/mjs/components/datagrid/DataGrid.js +1 -45
- package/lib/mjs/components/datamap/DataMap.js +1 -2
- package/lib/mjs/components/editgrid/EditGrid.js +9 -6
- package/lib/mjs/components/form/Form.d.ts +8 -3
- package/lib/mjs/components/form/Form.js +27 -25
- package/lib/mjs/components/html/HTML.js +1 -1
- package/lib/mjs/components/selectboxes/SelectBoxes.js +8 -1
- package/lib/mjs/components/signature/Signature.d.ts +0 -1
- package/lib/mjs/components/signature/Signature.js +1 -1
- package/lib/mjs/utils/conditionOperators/DateGreaterThan.js +2 -2
- package/lib/mjs/utils/conditionOperators/IsEmptyValue.d.ts +2 -2
- package/lib/mjs/utils/conditionOperators/IsEmptyValue.js +2 -2
- package/lib/mjs/utils/conditionOperators/IsEqualTo.d.ts +2 -2
- package/lib/mjs/utils/conditionOperators/IsEqualTo.js +2 -2
- package/lib/mjs/utils/formUtils.d.ts +25 -14
- package/lib/mjs/utils/formUtils.js +2 -12
- package/lib/mjs/utils/utils.d.ts +1 -3
- package/lib/mjs/utils/utils.js +18 -33
- package/package.json +4 -4
package/lib/mjs/Webform.js
CHANGED
@@ -590,6 +590,7 @@ export default class Webform extends NestedDataComponent {
|
|
590
590
|
try {
|
591
591
|
// Do not set the form again if it has been already set
|
592
592
|
if (isFormAlreadySet && JSON.stringify(this._form) === JSON.stringify(form)) {
|
593
|
+
this.formReadyResolve();
|
593
594
|
return Promise.resolve();
|
594
595
|
}
|
595
596
|
// Create the form.
|
@@ -597,13 +598,11 @@ export default class Webform extends NestedDataComponent {
|
|
597
598
|
if (this.onSetForm) {
|
598
599
|
this.onSetForm(_.cloneDeep(this._form), form);
|
599
600
|
}
|
600
|
-
if (this.parent?.component?.modalEdit) {
|
601
|
-
return Promise.resolve();
|
602
|
-
}
|
603
601
|
}
|
604
602
|
catch (err) {
|
605
603
|
console.warn(err);
|
606
604
|
// If provided form is not a valid JSON object, do not set it too
|
605
|
+
this.formReadyReject(err);
|
607
606
|
return Promise.resolve();
|
608
607
|
}
|
609
608
|
// Allow the form to provide component overrides.
|
@@ -702,6 +701,18 @@ export default class Webform extends NestedDataComponent {
|
|
702
701
|
set submission(submission) {
|
703
702
|
this.setSubmission(submission);
|
704
703
|
}
|
704
|
+
/**
|
705
|
+
* Sets the submission value
|
706
|
+
* @param {object|null|undefined} submission - The submission to set.
|
707
|
+
* @param {object|null|undefined} flags - Any flags to apply when setting the submission.
|
708
|
+
* @return {void}
|
709
|
+
*/
|
710
|
+
onSetSubmission(submission, flags = {}) {
|
711
|
+
this.submissionSet = true;
|
712
|
+
this.triggerChange(flags);
|
713
|
+
this.emit('beforeSetSubmission', submission);
|
714
|
+
this.setValue(submission, flags);
|
715
|
+
}
|
705
716
|
/**
|
706
717
|
* Sets a submission and returns the promise when it is ready.
|
707
718
|
* @param {any} submission - The submission to set.
|
@@ -721,10 +732,7 @@ export default class Webform extends NestedDataComponent {
|
|
721
732
|
...resolveFlags,
|
722
733
|
};
|
723
734
|
}
|
724
|
-
this.
|
725
|
-
this.triggerChange(flags);
|
726
|
-
this.emit("beforeSetSubmission", submission);
|
727
|
-
this.setValue(submission, flags);
|
735
|
+
this.onSetSubmission(submission, flags);
|
728
736
|
return this.submissionReadyResolve(submission);
|
729
737
|
}, (err) => this.submissionReadyReject(err))
|
730
738
|
.catch((err) => this.submissionReadyReject(err)));
|
@@ -843,6 +851,9 @@ export default class Webform extends NestedDataComponent {
|
|
843
851
|
return changed;
|
844
852
|
}
|
845
853
|
getValue() {
|
854
|
+
if (!this._submission) {
|
855
|
+
this._submission = {};
|
856
|
+
}
|
846
857
|
if (!this._submission.data) {
|
847
858
|
this._submission.data = {};
|
848
859
|
}
|
@@ -1102,29 +1113,23 @@ export default class Webform extends NestedDataComponent {
|
|
1102
1113
|
return;
|
1103
1114
|
}
|
1104
1115
|
// Mark any components as invalid if in a custom message.
|
1116
|
+
const componentErrors = {};
|
1105
1117
|
errors.forEach((err) => {
|
1106
|
-
const
|
1107
|
-
if (
|
1108
|
-
|
1109
|
-
}
|
1110
|
-
if (err.path) {
|
1111
|
-
components.push(err.path);
|
1118
|
+
const path = err.path || err.context?.path || err.component?.key;
|
1119
|
+
if (!componentErrors[path]) {
|
1120
|
+
componentErrors[path] = [];
|
1112
1121
|
}
|
1113
|
-
|
1114
|
-
const originalPath = getStringFromComponentPath(path);
|
1115
|
-
const component = this.getComponent(path, _.identity, originalPath);
|
1116
|
-
if (err.fromServer) {
|
1117
|
-
if (component.serverErrors) {
|
1118
|
-
component.serverErrors.push(err);
|
1119
|
-
}
|
1120
|
-
else {
|
1121
|
-
component.serverErrors = [err];
|
1122
|
-
}
|
1123
|
-
}
|
1124
|
-
const components = _.compact(Array.isArray(component) ? component : [component]);
|
1125
|
-
components.forEach((component) => component.setCustomValidity(err.message, true));
|
1126
|
-
});
|
1122
|
+
componentErrors[path].push(err);
|
1127
1123
|
});
|
1124
|
+
// Iterate through all of our component errors and apply them to the components.
|
1125
|
+
for (let path in componentErrors) {
|
1126
|
+
const component = this.getComponent(path);
|
1127
|
+
const errors = componentErrors[path];
|
1128
|
+
if (component) {
|
1129
|
+
component.serverErrors = errors.filter((err) => err.fromServer);
|
1130
|
+
component.setCustomValidity(errors, true);
|
1131
|
+
}
|
1132
|
+
}
|
1128
1133
|
const displayedErrors = [];
|
1129
1134
|
if (errors.length) {
|
1130
1135
|
errors = _.uniqBy(errors, (error) => [error.message, error.component?.id, error.context?.path].join());
|
@@ -1317,7 +1322,7 @@ export default class Webform extends NestedDataComponent {
|
|
1317
1322
|
onLine: navigator.onLine,
|
1318
1323
|
});
|
1319
1324
|
}
|
1320
|
-
submitForm(options = {}) {
|
1325
|
+
submitForm(options = {}, local = false) {
|
1321
1326
|
this.clearServerErrors();
|
1322
1327
|
return new Promise((resolve, reject) => {
|
1323
1328
|
// Read-only forms should never submit.
|
@@ -1342,6 +1347,7 @@ export default class Webform extends NestedDataComponent {
|
|
1342
1347
|
return reject("Invalid Submission");
|
1343
1348
|
}
|
1344
1349
|
const errors = this.validate(submission.data, {
|
1350
|
+
local,
|
1345
1351
|
dirty: true,
|
1346
1352
|
silentCheck: false,
|
1347
1353
|
process: "submit",
|
@@ -1357,11 +1363,11 @@ export default class Webform extends NestedDataComponent {
|
|
1357
1363
|
}
|
1358
1364
|
this.everyComponent((comp) => {
|
1359
1365
|
if (submission._vnote && comp.type === "form" && comp.component.reference) {
|
1360
|
-
_.get(submission.data, comp.path, {})._vnote = submission._vnote;
|
1366
|
+
_.get(submission.data, local ? comp.paths?.localDataPath : comp.path, {})._vnote = submission._vnote;
|
1361
1367
|
}
|
1362
1368
|
const { persistent } = comp.component;
|
1363
1369
|
if (persistent === "client-only") {
|
1364
|
-
_.unset(submission.data, comp.path);
|
1370
|
+
_.unset(submission.data, local ? comp.paths?.localDataPath : comp.path);
|
1365
1371
|
}
|
1366
1372
|
});
|
1367
1373
|
this.hook("customValidation", { ...submission, component: options.component }, (err) => {
|
@@ -1527,7 +1533,7 @@ export default class Webform extends NestedDataComponent {
|
|
1527
1533
|
return;
|
1528
1534
|
}
|
1529
1535
|
const captchaComponent = [];
|
1530
|
-
|
1536
|
+
this.eachComponent((component) => {
|
1531
1537
|
if (/^(re)?captcha$/.test(component.type) && component.component.eventType === 'formLoad') {
|
1532
1538
|
captchaComponent.push(component);
|
1533
1539
|
}
|
@@ -897,13 +897,16 @@ export default class WebformBuilder extends Component {
|
|
897
897
|
keyboardActionsEnabled = keyboardActionsEnabled === 'true';
|
898
898
|
}
|
899
899
|
this.keyboardActionsEnabled = keyboardActionsEnabled;
|
900
|
-
const
|
901
|
-
|
902
|
-
};
|
903
|
-
const
|
904
|
-
|
900
|
+
const { display, noAddSubmitButton, noDefaultSubmitButton } = this.options;
|
901
|
+
const { _id, components } = form;
|
902
|
+
const isSubmitButton = ({ type, action }) => type === 'button' && (action === 'submit' || !action);
|
903
|
+
const hasSubmitButton = components.some(isSubmitButton);
|
904
|
+
// Add submit button if form display was switched from wizard
|
905
|
+
// Don't add if there is noAddSubmitButton flag passed, or the form has id, or the form has a submit button already
|
906
|
+
const shouldAddSubmitButton = (display === 'wizard' && !hasSubmitButton) ||
|
907
|
+
(!noAddSubmitButton && !_id && !hasSubmitButton);
|
905
908
|
// Ensure there is at least a submit button.
|
906
|
-
if (
|
909
|
+
if (!noDefaultSubmitButton && shouldAddSubmitButton) {
|
907
910
|
form.components.push({
|
908
911
|
type: 'button',
|
909
912
|
label: 'Submit',
|
@@ -1052,6 +1055,7 @@ export default class WebformBuilder extends Component {
|
|
1052
1055
|
'conditional',
|
1053
1056
|
'customConditional',
|
1054
1057
|
'id',
|
1058
|
+
'logic',
|
1055
1059
|
'fields.day.required',
|
1056
1060
|
'fields.month.required',
|
1057
1061
|
'fields.year.required',
|
@@ -1077,6 +1081,12 @@ export default class WebformBuilder extends Component {
|
|
1077
1081
|
parentComponent.tabs[tabIndex].splice(index, 1, newComp);
|
1078
1082
|
newComp.checkValidity = () => true;
|
1079
1083
|
newComp.build(defaultValueComponent.element);
|
1084
|
+
if (this.preview && !this.preview.defaultChanged) {
|
1085
|
+
const defaultValue = _.get(this.preview._data, this.editForm._data.key);
|
1086
|
+
if (_.isObject(defaultValue) && !_.isArray(defaultValue)) {
|
1087
|
+
this.editForm._data.defaultValue = defaultValue;
|
1088
|
+
}
|
1089
|
+
}
|
1080
1090
|
}
|
1081
1091
|
}
|
1082
1092
|
else {
|
@@ -1087,6 +1097,7 @@ export default class WebformBuilder extends Component {
|
|
1087
1097
|
path.unshift(component.key);
|
1088
1098
|
dataPath = getStringFromComponentPath(path);
|
1089
1099
|
}
|
1100
|
+
this.preview.defaultChanged = true;
|
1090
1101
|
_.set(this.preview._data, dataPath, changed.value);
|
1091
1102
|
_.set(this.webform._data, dataPath, changed.value);
|
1092
1103
|
}
|
@@ -1097,20 +1108,12 @@ export default class WebformBuilder extends Component {
|
|
1097
1108
|
findRepeatablePaths() {
|
1098
1109
|
const repeatablePaths = [];
|
1099
1110
|
const keys = new Map();
|
1100
|
-
eachComponent(this.form.components, (comp, path) => {
|
1101
|
-
if (
|
1102
|
-
|
1103
|
-
}
|
1104
|
-
if (keys.has(comp.key)) {
|
1105
|
-
if (keys.get(comp.key).includes(path)) {
|
1106
|
-
repeatablePaths.push(path);
|
1107
|
-
}
|
1108
|
-
else {
|
1109
|
-
keys.set(comp.key, [...keys.get(comp.key), path]);
|
1110
|
-
}
|
1111
|
+
eachComponent(this.form.components, (comp, path, components, parent, paths) => {
|
1112
|
+
if (keys.has(paths.dataPath)) {
|
1113
|
+
repeatablePaths.push(paths.dataPath);
|
1111
1114
|
}
|
1112
1115
|
else {
|
1113
|
-
keys.set(
|
1116
|
+
keys.set(paths.dataPath, true);
|
1114
1117
|
}
|
1115
1118
|
}, true);
|
1116
1119
|
return repeatablePaths;
|
@@ -1171,6 +1174,7 @@ export default class WebformBuilder extends Component {
|
|
1171
1174
|
}
|
1172
1175
|
const rebuild = parentComponent.rebuild() || Promise.resolve();
|
1173
1176
|
return rebuild.then(() => {
|
1177
|
+
parentComponent.resetValue();
|
1174
1178
|
const schema = parentContainer ? parentContainer[index] : (comp ? comp.schema : []);
|
1175
1179
|
this.emitSaveComponentEvent(schema, originalComp, parentComponent.schema, path, index, isNew, originalComponentSchema);
|
1176
1180
|
this.emit('change', this.form);
|
package/lib/mjs/Wizard.d.ts
CHANGED
@@ -105,7 +105,6 @@ declare class Wizard extends Webform {
|
|
105
105
|
pageId(page: any): any;
|
106
106
|
onChange(flags: any, changed: any, modified: any, changes: any): void;
|
107
107
|
checkValidity(data: any, dirty: any, row: any, currentPageOnly: any, childErrors?: any[]): any;
|
108
|
-
showErrors(errors: any, triggerEvent: any): void | any[];
|
109
108
|
focusOnComponent(key: any): void | Promise<void>;
|
110
109
|
}
|
111
110
|
declare namespace Wizard {
|
package/lib/mjs/Wizard.js
CHANGED
@@ -369,7 +369,7 @@ export default class Wizard extends Webform {
|
|
369
369
|
}
|
370
370
|
attachHeader() {
|
371
371
|
const isAllowPrevious = this.isAllowPrevious();
|
372
|
-
this.attachTooltips(this.refs[`${this.wizardKey}-tooltip`], this.currentPanel
|
372
|
+
this.attachTooltips(this.refs[`${this.wizardKey}-tooltip`], this.currentPanel?.tooltip);
|
373
373
|
if (this.isBreadcrumbClickable() || isAllowPrevious) {
|
374
374
|
this.refs[`${this.wizardKey}-link`]?.forEach((link, index) => {
|
375
375
|
if (!isAllowPrevious || index <= this.enabledIndex) {
|
@@ -594,7 +594,10 @@ export default class Wizard extends Webform {
|
|
594
594
|
}
|
595
595
|
this.redraw().then(() => {
|
596
596
|
this.checkData(this.submission.data);
|
597
|
-
this.validateCurrentPage();
|
597
|
+
const errors = this.submitted ? this.validate(this.localData, { dirty: true }) : this.validateCurrentPage();
|
598
|
+
if (this.alert) {
|
599
|
+
this.showErrors(errors, true, true);
|
600
|
+
}
|
598
601
|
});
|
599
602
|
return Promise.resolve();
|
600
603
|
}
|
@@ -689,9 +692,11 @@ export default class Wizard extends Webform {
|
|
689
692
|
});
|
690
693
|
});
|
691
694
|
}
|
692
|
-
// Validate the form
|
693
|
-
const
|
694
|
-
|
695
|
+
// Validate the form before going to the next page
|
696
|
+
const currentPageErrors = this.validateCurrentPage({ dirty: true });
|
697
|
+
const errors = this.submitted ? this.validate(this.localData, { dirty: true }) : currentPageErrors;
|
698
|
+
// allow going to the next page if the current page is valid, even if there are form level errors
|
699
|
+
if (currentPageErrors.length === 0) {
|
695
700
|
this.checkData(this.submission.data);
|
696
701
|
return this.beforePage(true).then(() => {
|
697
702
|
return this.setPage(this.getNextPage()).then(() => {
|
@@ -706,12 +711,13 @@ export default class Wizard extends Webform {
|
|
706
711
|
else {
|
707
712
|
this.currentPage.components.forEach((comp) => comp.setPristine(false));
|
708
713
|
this.scrollIntoView(this.element, true);
|
709
|
-
return Promise.reject(
|
714
|
+
return Promise.reject(this.showErrors(errors, true));
|
710
715
|
}
|
711
716
|
}
|
712
717
|
validateCurrentPage(flags = {}) {
|
718
|
+
const components = this.currentPage?.components.map((component) => component.component);
|
713
719
|
// Accessing the parent ensures the right instance (whether it's the parent Wizard or a nested Wizard) performs its validation
|
714
|
-
return this.currentPage?.parent.validateComponents(
|
720
|
+
return this.currentPage?.parent.validateComponents(components, this.root.data, flags);
|
715
721
|
}
|
716
722
|
emitPrevPage() {
|
717
723
|
this.emit('prevPage', { page: this.page, submission: this.submission });
|
@@ -852,7 +858,8 @@ export default class Wizard extends Webform {
|
|
852
858
|
}
|
853
859
|
onChange(flags, changed, modified, changes) {
|
854
860
|
super.onChange(flags, changed, modified, changes);
|
855
|
-
|
861
|
+
// The onChange loop doesn't need all components for wizards
|
862
|
+
const errors = this.submitted ? this.validate(this.localData, { dirty: true }) : this.validateCurrentPage();
|
856
863
|
if (this.alert) {
|
857
864
|
this.showErrors(errors, true, true);
|
858
865
|
}
|
@@ -884,12 +891,6 @@ export default class Wizard extends Webform {
|
|
884
891
|
this.redraw();
|
885
892
|
}
|
886
893
|
}
|
887
|
-
redraw() {
|
888
|
-
if (this.parent?.component?.modalEdit) {
|
889
|
-
return this.parent.redraw();
|
890
|
-
}
|
891
|
-
return super.redraw();
|
892
|
-
}
|
893
894
|
rebuild() {
|
894
895
|
const currentPage = this.page;
|
895
896
|
const setCurrentPage = () => this.setPage(currentPage);
|
@@ -906,21 +907,7 @@ export default class Wizard extends Webform {
|
|
906
907
|
return components.reduce((check, comp) => comp.checkValidity(data, dirty, row, currentPageOnly, childErrors) && check, true);
|
907
908
|
}
|
908
909
|
get errors() {
|
909
|
-
|
910
|
-
return this.currentPage.errors;
|
911
|
-
}
|
912
|
-
return super.errors;
|
913
|
-
}
|
914
|
-
showErrors(errors, triggerEvent) {
|
915
|
-
if (this.hasExtraPages) {
|
916
|
-
this.subWizards.forEach((subWizard) => {
|
917
|
-
if (Array.isArray(subWizard.errors)) {
|
918
|
-
errors = [...errors, ...subWizard.errors];
|
919
|
-
}
|
920
|
-
});
|
921
|
-
}
|
922
|
-
;
|
923
|
-
return super.showErrors(errors, triggerEvent);
|
910
|
+
return !this.isLastPage() && !this.submitted ? this.currentPage.errors : super.errors;
|
924
911
|
}
|
925
912
|
focusOnComponent(key) {
|
926
913
|
const component = this.getComponent(key);
|
@@ -256,13 +256,6 @@ export default class Components {
|
|
256
256
|
static setComponents(comps: any): void;
|
257
257
|
static addComponent(name: any, comp: any): void;
|
258
258
|
static setComponent(name: any, comp: any): void;
|
259
|
-
/**
|
260
|
-
* Return a path of component's value.
|
261
|
-
* @param {Component} component - The component instance.
|
262
|
-
* @returns {string} - The component's value path.
|
263
|
-
*/
|
264
|
-
static getComponentPath(component: Component): string;
|
265
259
|
static create(component: any, options: any, data: any): any;
|
266
260
|
}
|
267
261
|
import BaseEditForm from './_classes/component/Component.form';
|
268
|
-
import Component from './_classes/component/Component';
|
@@ -1,7 +1,6 @@
|
|
1
1
|
import Component from './_classes/component/Component';
|
2
2
|
import EditFormUtils from './_classes/component/editForm/utils';
|
3
3
|
import BaseEditForm from './_classes/component/Component.form';
|
4
|
-
import { getComponentKey, getModelType } from '../utils/utils';
|
5
4
|
import _ from 'lodash';
|
6
5
|
export default class Components {
|
7
6
|
static _editFormUtils = EditFormUtils;
|
@@ -46,34 +45,6 @@ export default class Components {
|
|
46
45
|
static setComponent(name, comp) {
|
47
46
|
Components.components[name] = comp;
|
48
47
|
}
|
49
|
-
/**
|
50
|
-
* Return a path of component's value.
|
51
|
-
* @param {Component} component - The component instance.
|
52
|
-
* @returns {string} - The component's value path.
|
53
|
-
*/
|
54
|
-
static getComponentPath(component) {
|
55
|
-
let path = '';
|
56
|
-
const componentKey = getComponentKey(component.component);
|
57
|
-
if (componentKey) {
|
58
|
-
let thisPath = component.options?.parent || component;
|
59
|
-
while (thisPath && !thisPath.allowData && thisPath.parent) {
|
60
|
-
thisPath = thisPath.parent;
|
61
|
-
}
|
62
|
-
// TODO: any component that is nested in e.g. a Data Grid or an Edit Grid is going to receive a row prop; the problem
|
63
|
-
// is that options.row is passed to each further nested component, which results in erroneous paths like
|
64
|
-
// `editGrid[0].container[0].textField` rather than `editGrid[0].container.textField`. This should be adapted for other
|
65
|
-
// components with a tree-like data model
|
66
|
-
const rowIndex = component.row;
|
67
|
-
const rowIndexPath = rowIndex && !['container'].includes(thisPath.component.type) ? `[${Number.parseInt(rowIndex)}]` : '';
|
68
|
-
path = `${thisPath.path}${rowIndexPath}.`;
|
69
|
-
if (rowIndexPath && getModelType(thisPath) === 'nestedDataArray') {
|
70
|
-
path = `${path}data.`;
|
71
|
-
}
|
72
|
-
path += componentKey;
|
73
|
-
return _.trim(path, '.');
|
74
|
-
}
|
75
|
-
return path;
|
76
|
-
}
|
77
48
|
static create(component, options, data) {
|
78
49
|
let comp = null;
|
79
50
|
if (component.type && Components.components.hasOwnProperty(component.type)) {
|
@@ -98,9 +69,7 @@ export default class Components {
|
|
98
69
|
else {
|
99
70
|
comp = new Component(component, options, data);
|
100
71
|
}
|
101
|
-
|
102
|
-
if (path) {
|
103
|
-
comp.path = path;
|
72
|
+
if (comp.path) {
|
104
73
|
comp.componentsMap[comp.path] = comp;
|
105
74
|
}
|
106
75
|
return comp;
|
@@ -42,14 +42,13 @@ declare class Component extends Element {
|
|
42
42
|
*/
|
43
43
|
private _hasCondition;
|
44
44
|
/**
|
45
|
-
*
|
45
|
+
* The row index for this component.
|
46
46
|
*/
|
47
|
-
|
47
|
+
_rowIndex: number | undefined;
|
48
48
|
/**
|
49
|
-
*
|
50
|
-
* @type {string}
|
49
|
+
* References to dom elements
|
51
50
|
*/
|
52
|
-
|
51
|
+
refs: {};
|
53
52
|
/**
|
54
53
|
* An array of all the children components errors.
|
55
54
|
*/
|
@@ -114,6 +113,11 @@ declare class Component extends Element {
|
|
114
113
|
* @type {Component}
|
115
114
|
*/
|
116
115
|
parent: Component;
|
116
|
+
/**
|
117
|
+
* The component paths for this component.
|
118
|
+
* @type {import('@formio/core').ComponentPaths} - The component paths.
|
119
|
+
*/
|
120
|
+
paths: import('@formio/core').ComponentPaths;
|
117
121
|
_path: string;
|
118
122
|
/**
|
119
123
|
* Determines if this component is visible, or not.
|
@@ -158,7 +162,7 @@ declare class Component extends Element {
|
|
158
162
|
* @type {*}
|
159
163
|
*/
|
160
164
|
info: any;
|
161
|
-
get componentsMap():
|
165
|
+
get componentsMap(): object;
|
162
166
|
set data(value: any);
|
163
167
|
get data(): any;
|
164
168
|
mergeSchema(component?: {}): any;
|
@@ -182,6 +186,17 @@ declare class Component extends Element {
|
|
182
186
|
* @returns {boolean} - TRUE if the component is disabled.
|
183
187
|
*/
|
184
188
|
get disabled(): boolean;
|
189
|
+
/**
|
190
|
+
* Set Row Index to row and update each component.
|
191
|
+
* @param {number} value - The row index.
|
192
|
+
* @returns {void}
|
193
|
+
*/
|
194
|
+
set rowIndex(value: number);
|
195
|
+
/**
|
196
|
+
* Get Row Index.
|
197
|
+
* @returns {number} - The row index.
|
198
|
+
*/
|
199
|
+
get rowIndex(): number;
|
185
200
|
afterComponentAssign(): void;
|
186
201
|
createAddon(addonConfiguration: any): any;
|
187
202
|
get shouldDisabled(): any;
|
@@ -190,6 +205,8 @@ declare class Component extends Element {
|
|
190
205
|
get hasInput(): any;
|
191
206
|
get defaultSchema(): any;
|
192
207
|
get key(): any;
|
208
|
+
set path(path: string | undefined);
|
209
|
+
get path(): string | undefined;
|
193
210
|
set parentVisible(value: any);
|
194
211
|
get parentVisible(): any;
|
195
212
|
set parentDisabled(value: boolean);
|
@@ -212,7 +229,7 @@ declare class Component extends Element {
|
|
212
229
|
_currentForm: any;
|
213
230
|
get fullMode(): boolean;
|
214
231
|
get builderMode(): boolean;
|
215
|
-
get calculatedPath(): string;
|
232
|
+
get calculatedPath(): string | undefined;
|
216
233
|
get labelPosition(): any;
|
217
234
|
get labelWidth(): any;
|
218
235
|
get labelMargin(): any;
|
@@ -343,6 +360,12 @@ declare class Component extends Element {
|
|
343
360
|
* @param {string} template - The template to use for the modal dialog.
|
344
361
|
*/
|
345
362
|
setOpenModalElement(template?: string): void;
|
363
|
+
/**
|
364
|
+
* Renders a modal preview template and returns the markup as a string
|
365
|
+
* @param {object|null|undefined} ctx - The rendering context
|
366
|
+
* @return {string} - The modal preview markup
|
367
|
+
*/
|
368
|
+
renderModalPreview(ctx: object | null | undefined): string;
|
346
369
|
/**
|
347
370
|
* Returns the modal preview template.
|
348
371
|
* @returns {string} - The modal preview template.
|
@@ -362,6 +385,13 @@ declare class Component extends Element {
|
|
362
385
|
* @returns {string} - The rendered HTML string of a component.
|
363
386
|
*/
|
364
387
|
render(children?: string, topLevel?: boolean): string;
|
388
|
+
/**
|
389
|
+
* Creates the tooltip instance using tippy.js and returns it
|
390
|
+
* @param {HTMLElement} tooltipEl - HTML element to attach the tooltip
|
391
|
+
* @param {object|null|undefined} settings - tippy.js options
|
392
|
+
* @return {import('tippy.js').Tippy} - tippy.js instance
|
393
|
+
*/
|
394
|
+
createTooltip(tooltipEl: HTMLElement, settings?: object | null | undefined): import('tippy.js').Tippy;
|
365
395
|
/**
|
366
396
|
* Attaches all the tooltips provided the refs object.
|
367
397
|
* @param {object} toolTipsRefs - The refs for the tooltips within your template.
|