@formio/js 5.1.0-dev.6109.79f22ad → 5.1.0-dev.6112.1314654
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/README.md +7 -0
- package/dist/formio.builder.css +1 -0
- package/dist/formio.builder.min.css +1 -1
- package/dist/formio.form.css +1 -0
- package/dist/formio.form.js +119 -152
- package/dist/formio.form.min.css +1 -1
- package/dist/formio.form.min.js +1 -1
- package/dist/formio.full.css +1 -0
- package/dist/formio.full.js +126 -159
- package/dist/formio.full.min.css +1 -1
- package/dist/formio.full.min.js +1 -1
- package/dist/formio.js +66 -55
- package/dist/formio.min.js +1 -1
- package/dist/formio.utils.js +76 -76
- package/dist/formio.utils.min.js +1 -1
- package/lib/cjs/Element.d.ts +2 -1
- package/lib/cjs/Element.js +18 -39
- package/lib/cjs/EventEmitter.js +2 -25
- package/lib/cjs/Form.js +2 -25
- package/lib/cjs/PDF.js +1 -1
- package/lib/cjs/PDFBuilder.d.ts +1 -0
- package/lib/cjs/PDFBuilder.js +10 -11
- package/lib/cjs/Webform.d.ts +2 -2
- package/lib/cjs/Webform.js +10 -10
- package/lib/cjs/WebformBuilder.d.ts +1 -1
- package/lib/cjs/WebformBuilder.js +45 -21
- package/lib/cjs/Wizard.d.ts +1 -2
- package/lib/cjs/Wizard.js +18 -24
- package/lib/cjs/WizardBuilder.js +1 -1
- package/lib/cjs/components/Components.js +7 -1
- package/lib/cjs/components/_classes/component/Component.d.ts +0 -1
- package/lib/cjs/components/_classes/component/Component.js +70 -64
- package/lib/cjs/components/_classes/component/editForm/Component.edit.conditional.js +1 -1
- package/lib/cjs/components/_classes/component/editForm/Component.edit.data.d.ts +7 -0
- package/lib/cjs/components/_classes/component/editForm/Component.edit.data.js +1 -0
- package/lib/cjs/components/_classes/component/editForm/Component.edit.logic.js +1 -1
- package/lib/cjs/components/_classes/componentModal/ComponentModal.js +1 -1
- package/lib/cjs/components/_classes/input/Input.d.ts +1 -1
- package/lib/cjs/components/_classes/input/Input.js +3 -3
- package/lib/cjs/components/_classes/list/ListComponent.js +1 -1
- package/lib/cjs/components/_classes/nested/NestedComponent.d.ts +1 -0
- package/lib/cjs/components/_classes/nested/NestedComponent.js +19 -9
- package/lib/cjs/components/_classes/nestedarray/NestedArrayComponent.js +1 -1
- package/lib/cjs/components/_classes/nesteddata/NestedDataComponent.js +1 -1
- package/lib/cjs/components/address/Address.js +2 -2
- package/lib/cjs/components/alert/Alert.js +1 -1
- package/lib/cjs/components/button/Button.js +1 -1
- package/lib/cjs/components/checkbox/Checkbox.js +1 -1
- package/lib/cjs/components/container/Container.js +1 -1
- package/lib/cjs/components/currency/Currency.js +1 -1
- package/lib/cjs/components/datagrid/DataGrid.js +5 -1
- package/lib/cjs/components/datamap/DataMap.js +7 -2
- package/lib/cjs/components/datetime/DateTime.d.ts +1 -1
- package/lib/cjs/components/datetime/DateTime.js +15 -13
- package/lib/cjs/components/day/Day.js +2 -2
- package/lib/cjs/components/editgrid/EditGrid.d.ts +0 -1
- package/lib/cjs/components/editgrid/EditGrid.js +1 -9
- package/lib/cjs/components/editgrid/editForm/EditGrid.edit.display.js +1 -1
- package/lib/cjs/components/fieldset/Fieldset.js +1 -0
- package/lib/cjs/components/file/File.js +1 -1
- package/lib/cjs/components/form/Form.js +14 -2
- package/lib/cjs/components/form/editForm/Form.edit.form.js +4 -3
- package/lib/cjs/components/number/Number.js +1 -1
- package/lib/cjs/components/panel/Panel.js +1 -1
- package/lib/cjs/components/radio/Radio.d.ts +9 -0
- package/lib/cjs/components/radio/Radio.js +20 -10
- package/lib/cjs/components/recaptcha/editForm/ReCaptcha.edit.display.js +1 -1
- package/lib/cjs/components/select/Select.js +7 -3
- package/lib/cjs/components/select/editForm/Select.edit.data.js +1 -1
- package/lib/cjs/components/selectboxes/SelectBoxes.d.ts +6 -0
- package/lib/cjs/components/selectboxes/SelectBoxes.js +1 -1
- package/lib/cjs/components/signature/Signature.js +1 -1
- package/lib/cjs/components/survey/Survey.js +1 -1
- package/lib/cjs/components/tags/Tags.js +1 -1
- package/lib/cjs/components/textarea/TextArea.js +9 -4
- package/lib/cjs/components/textfield/TextField.js +13 -31
- package/lib/cjs/components/time/Time.js +1 -1
- package/lib/cjs/formio.form.js +5 -5
- package/lib/cjs/providers/storage/uploadAdapter.js +1 -1
- package/lib/cjs/providers/storage/url.js +7 -3
- package/lib/cjs/translations/en.d.ts +1 -232
- package/lib/cjs/translations/en.js +4 -2
- package/lib/cjs/utils/Evaluator.d.ts +20 -6
- package/lib/cjs/utils/Evaluator.js +38 -15
- package/lib/cjs/utils/builder.js +5 -5
- package/lib/cjs/utils/conditionOperators/IsEqualTo.js +3 -3
- package/lib/cjs/utils/formUtils.d.ts +2 -2
- package/lib/cjs/utils/index.d.ts +169 -2
- package/lib/cjs/utils/index.js +22 -2
- package/lib/cjs/utils/utils.d.ts +22 -37
- package/lib/cjs/utils/utils.js +63 -138
- package/lib/cjs/widgets/CalendarWidget.d.ts +1 -8
- package/lib/cjs/widgets/CalendarWidget.js +17 -43
- package/lib/mjs/Element.d.ts +2 -1
- package/lib/mjs/Element.js +11 -9
- package/lib/mjs/EventEmitter.js +2 -2
- package/lib/mjs/Form.js +1 -1
- package/lib/mjs/PDF.js +1 -1
- package/lib/mjs/PDFBuilder.d.ts +1 -0
- package/lib/mjs/PDFBuilder.js +9 -10
- package/lib/mjs/Webform.d.ts +2 -2
- package/lib/mjs/Webform.js +8 -8
- package/lib/mjs/WebformBuilder.d.ts +1 -1
- package/lib/mjs/WebformBuilder.js +36 -13
- package/lib/mjs/Wizard.d.ts +1 -2
- package/lib/mjs/Wizard.js +17 -23
- package/lib/mjs/WizardBuilder.js +1 -1
- package/lib/mjs/components/Components.js +7 -1
- package/lib/mjs/components/_classes/component/Component.d.ts +0 -1
- package/lib/mjs/components/_classes/component/Component.js +42 -13
- package/lib/mjs/components/_classes/component/editForm/Component.edit.conditional.js +1 -1
- package/lib/mjs/components/_classes/component/editForm/Component.edit.data.d.ts +7 -0
- package/lib/mjs/components/_classes/component/editForm/Component.edit.data.js +1 -0
- package/lib/mjs/components/_classes/component/editForm/Component.edit.logic.js +1 -1
- package/lib/mjs/components/_classes/componentModal/ComponentModal.js +1 -1
- package/lib/mjs/components/_classes/input/Input.d.ts +1 -1
- package/lib/mjs/components/_classes/input/Input.js +3 -3
- package/lib/mjs/components/_classes/list/ListComponent.js +1 -1
- package/lib/mjs/components/_classes/nested/NestedComponent.d.ts +1 -0
- package/lib/mjs/components/_classes/nested/NestedComponent.js +19 -9
- package/lib/mjs/components/_classes/nestedarray/NestedArrayComponent.js +1 -1
- package/lib/mjs/components/_classes/nesteddata/NestedDataComponent.js +1 -1
- package/lib/mjs/components/address/Address.js +2 -2
- package/lib/mjs/components/alert/Alert.js +1 -1
- package/lib/mjs/components/button/Button.js +1 -1
- package/lib/mjs/components/checkbox/Checkbox.js +1 -1
- package/lib/mjs/components/container/Container.js +1 -1
- package/lib/mjs/components/currency/Currency.js +1 -1
- package/lib/mjs/components/datagrid/DataGrid.js +5 -1
- package/lib/mjs/components/datamap/DataMap.js +7 -2
- package/lib/mjs/components/datetime/DateTime.d.ts +1 -1
- package/lib/mjs/components/datetime/DateTime.js +15 -13
- package/lib/mjs/components/day/Day.js +2 -2
- package/lib/mjs/components/editgrid/EditGrid.d.ts +0 -1
- package/lib/mjs/components/editgrid/EditGrid.js +1 -9
- package/lib/mjs/components/editgrid/editForm/EditGrid.edit.display.js +1 -1
- package/lib/mjs/components/fieldset/Fieldset.js +1 -0
- package/lib/mjs/components/file/File.js +1 -1
- package/lib/mjs/components/form/Form.js +13 -2
- package/lib/mjs/components/form/editForm/Form.edit.form.js +3 -2
- package/lib/mjs/components/number/Number.js +1 -1
- package/lib/mjs/components/panel/Panel.js +1 -1
- package/lib/mjs/components/radio/Radio.d.ts +9 -0
- package/lib/mjs/components/radio/Radio.js +20 -10
- package/lib/mjs/components/recaptcha/editForm/ReCaptcha.edit.display.js +1 -1
- package/lib/mjs/components/select/Select.js +7 -3
- package/lib/mjs/components/select/editForm/Select.edit.data.js +1 -1
- package/lib/mjs/components/selectboxes/SelectBoxes.d.ts +6 -0
- package/lib/mjs/components/selectboxes/SelectBoxes.js +1 -1
- package/lib/mjs/components/signature/Signature.js +1 -1
- package/lib/mjs/components/survey/Survey.js +1 -1
- package/lib/mjs/components/tags/Tags.js +1 -1
- package/lib/mjs/components/textarea/TextArea.js +9 -4
- package/lib/mjs/components/textfield/TextField.js +7 -2
- package/lib/mjs/components/time/Time.js +1 -1
- package/lib/mjs/formio.form.js +3 -3
- package/lib/mjs/providers/storage/uploadAdapter.js +1 -1
- package/lib/mjs/providers/storage/url.js +7 -3
- package/lib/mjs/translations/en.d.ts +1 -232
- package/lib/mjs/translations/en.js +8 -47
- package/lib/mjs/utils/Evaluator.d.ts +20 -6
- package/lib/mjs/utils/Evaluator.js +31 -13
- package/lib/mjs/utils/builder.js +1 -1
- package/lib/mjs/utils/conditionOperators/IsEqualTo.js +1 -1
- package/lib/mjs/utils/formUtils.d.ts +2 -2
- package/lib/mjs/utils/index.d.ts +169 -2
- package/lib/mjs/utils/index.js +18 -1
- package/lib/mjs/utils/utils.d.ts +22 -37
- package/lib/mjs/utils/utils.js +57 -113
- package/lib/mjs/widgets/CalendarWidget.d.ts +1 -8
- package/lib/mjs/widgets/CalendarWidget.js +17 -43
- package/package.json +5 -3
- package/lib/cjs/i18n.d.ts +0 -13
- package/lib/cjs/i18n.js +0 -19
- package/lib/cjs/utils/i18n.d.ts +0 -19
- package/lib/cjs/utils/i18n.js +0 -120
- package/lib/mjs/i18n.d.ts +0 -13
- package/lib/mjs/i18n.js +0 -14
- package/lib/mjs/utils/i18n.d.ts +0 -19
- package/lib/mjs/utils/i18n.js +0 -112
package/lib/mjs/PDFBuilder.js
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import _ from 'lodash';
|
|
2
2
|
import { Formio } from './Formio';
|
|
3
3
|
import WebformBuilder from './WebformBuilder';
|
|
4
|
-
import { fastCloneDeep, getElementRect, getBrowserInfo } from './utils
|
|
5
|
-
import { eachComponent } from './utils/formUtils';
|
|
4
|
+
import { fastCloneDeep, getElementRect, getBrowserInfo, eachComponent } from './utils';
|
|
6
5
|
import BuilderUtils from './utils/builder';
|
|
7
6
|
import PDF from './PDF';
|
|
8
7
|
export default class PDFBuilder extends WebformBuilder {
|
|
@@ -445,21 +444,21 @@ export default class PDFBuilder extends WebformBuilder {
|
|
|
445
444
|
e.target.style.cursor = 'default';
|
|
446
445
|
}
|
|
447
446
|
highlightInvalidComponents() {
|
|
448
|
-
const
|
|
447
|
+
const repeatablePathsComps = this.findComponentsWithRepeatablePaths();
|
|
449
448
|
// update elements which path was duplicated if any pathes have been changed
|
|
450
|
-
if (!_.isEqual(this.
|
|
451
|
-
eachComponent(this.webform.getComponents(), (comp
|
|
452
|
-
if (this.
|
|
449
|
+
if (!_.isEqual(this.repeatablePathsComps, repeatablePathsComps)) {
|
|
450
|
+
eachComponent(this.webform.getComponents(), (comp) => {
|
|
451
|
+
if (this.repeatablePathsComps.includes(comp.component)) {
|
|
453
452
|
this.webform.postMessage({ name: 'updateElement', data: comp.component });
|
|
454
453
|
}
|
|
455
454
|
});
|
|
456
|
-
this.
|
|
455
|
+
this.repeatablePathsComps = repeatablePathsComps;
|
|
457
456
|
}
|
|
458
|
-
if (!
|
|
457
|
+
if (!repeatablePathsComps.length) {
|
|
459
458
|
return;
|
|
460
459
|
}
|
|
461
|
-
eachComponent(this.webform.getComponents(), (comp
|
|
462
|
-
if (this.
|
|
460
|
+
eachComponent(this.webform.getComponents(), (comp) => {
|
|
461
|
+
if (this.repeatablePathsComps.includes(comp)) {
|
|
463
462
|
this.webform.postMessage({
|
|
464
463
|
name: 'showBuilderErrors',
|
|
465
464
|
data: {
|
package/lib/mjs/Webform.d.ts
CHANGED
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
* @property {number} [saveDraftThrottle] - The throttle for the save draft feature.
|
|
46
46
|
* @property {boolean} [readOnly] - Set this form to readOnly.
|
|
47
47
|
* @property {boolean} [noAlerts] - Disable the alerts dialog.
|
|
48
|
-
* @property {{[key: string]: string}} [
|
|
48
|
+
* @property {{[key: string]: string}} [enTranslation] - The translation file for this rendering.
|
|
49
49
|
* @property {string} [template] - Custom logic for creation of elements.
|
|
50
50
|
* @property {boolean} [noDefaults] - Exclude default values from the settings.
|
|
51
51
|
* @property {any} [fileService] - The file service for this form.
|
|
@@ -586,7 +586,7 @@ export type FormOptions = {
|
|
|
586
586
|
/**
|
|
587
587
|
* - The translation file for this rendering.
|
|
588
588
|
*/
|
|
589
|
-
|
|
589
|
+
enTranslation?: {
|
|
590
590
|
[key: string]: string;
|
|
591
591
|
} | undefined;
|
|
592
592
|
/**
|
package/lib/mjs/Webform.js
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
import _ from 'lodash';
|
|
2
|
-
import moment from 'moment';
|
|
3
2
|
import { compareVersions } from 'compare-versions';
|
|
4
3
|
import EventEmitter from './EventEmitter';
|
|
5
|
-
import
|
|
4
|
+
import enTranslation from './translations/en';
|
|
6
5
|
import { Formio } from './Formio';
|
|
7
6
|
import Components from './components/Components';
|
|
8
7
|
import NestedDataComponent from './components/_classes/nesteddata/NestedDataComponent';
|
|
9
|
-
import { fastCloneDeep, currentTimezone, unescapeHTML, getStringFromComponentPath, convertStringToHTMLElement, getArrayFromComponentPath, } from './utils
|
|
10
|
-
import
|
|
8
|
+
import { fastCloneDeep, currentTimezone, unescapeHTML, getStringFromComponentPath, convertStringToHTMLElement, getArrayFromComponentPath, eachComponent } from './utils';
|
|
9
|
+
import dayjs from "dayjs";
|
|
11
10
|
// We need this here because dragula pulls in CustomEvent class that requires global to exist.
|
|
12
11
|
if (typeof window !== 'undefined' && typeof window.global === 'undefined') {
|
|
13
12
|
window.global = window;
|
|
@@ -95,7 +94,7 @@ function getOptions(options) {
|
|
|
95
94
|
* @property {number} [saveDraftThrottle] - The throttle for the save draft feature.
|
|
96
95
|
* @property {boolean} [readOnly] - Set this form to readOnly.
|
|
97
96
|
* @property {boolean} [noAlerts] - Disable the alerts dialog.
|
|
98
|
-
* @property {{[key: string]: string}} [
|
|
97
|
+
* @property {{[key: string]: string}} [enTranslation] - The translation file for this rendering.
|
|
99
98
|
* @property {string} [template] - Custom logic for creation of elements.
|
|
100
99
|
* @property {boolean} [noDefaults] - Exclude default values from the settings.
|
|
101
100
|
* @property {any} [fileService] - The file service for this form.
|
|
@@ -342,7 +341,7 @@ export default class Webform extends NestedDataComponent {
|
|
|
342
341
|
*/
|
|
343
342
|
addLanguage(code, lang, active = false) {
|
|
344
343
|
if (this.i18next) {
|
|
345
|
-
var translations = _.assign(fastCloneDeep(
|
|
344
|
+
var translations = _.assign(fastCloneDeep(enTranslation), lang);
|
|
346
345
|
this.i18next.addResourceBundle(code, 'translation', translations, true, true);
|
|
347
346
|
if (active) {
|
|
348
347
|
this.language = code;
|
|
@@ -1122,7 +1121,7 @@ export default class Webform extends NestedDataComponent {
|
|
|
1122
1121
|
// Mark any components as invalid if in a custom message.
|
|
1123
1122
|
const componentErrors = {};
|
|
1124
1123
|
errors.forEach((err) => {
|
|
1125
|
-
const path = err.path || err.context?.path || err.component?.key;
|
|
1124
|
+
const path = getStringFromComponentPath(err.path) || err.context?.path || err.component?.key;
|
|
1126
1125
|
if (!componentErrors[path]) {
|
|
1127
1126
|
componentErrors[path] = [];
|
|
1128
1127
|
}
|
|
@@ -1317,13 +1316,14 @@ export default class Webform extends NestedDataComponent {
|
|
|
1317
1316
|
submission.metadata = submission.metadata || {};
|
|
1318
1317
|
_.defaults(submission.metadata, {
|
|
1319
1318
|
timezone: _.get(this, '_submission.metadata.timezone', currentTimezone()),
|
|
1320
|
-
offset: parseInt(_.get(this, '_submission.metadata.offset',
|
|
1319
|
+
offset: parseInt(_.get(this, '_submission.metadata.offset', dayjs().utcOffset()), 10),
|
|
1321
1320
|
origin: document.location.origin,
|
|
1322
1321
|
referrer: document.referrer,
|
|
1323
1322
|
browserName: navigator.appName,
|
|
1324
1323
|
userAgent: navigator.userAgent,
|
|
1325
1324
|
pathName: window.location.pathname,
|
|
1326
1325
|
onLine: navigator.onLine,
|
|
1326
|
+
language: this.language,
|
|
1327
1327
|
});
|
|
1328
1328
|
}
|
|
1329
1329
|
submitForm(options = {}, local = false) {
|
|
@@ -78,7 +78,7 @@ export default class WebformBuilder extends Component {
|
|
|
78
78
|
replaceDoubleQuotes(data: any, fieldsToRemoveDoubleQuotes?: any[]): any;
|
|
79
79
|
updateComponent(component: any, changed: any): void;
|
|
80
80
|
originalDefaultValue: any;
|
|
81
|
-
|
|
81
|
+
findComponentsWithRepeatablePaths(): any[];
|
|
82
82
|
highlightInvalidComponents(): void;
|
|
83
83
|
/**
|
|
84
84
|
* Called when a new component is saved.
|
|
@@ -3,8 +3,7 @@ import Component from './components/_classes/component/Component';
|
|
|
3
3
|
import tippy from 'tippy.js';
|
|
4
4
|
import Components from './components/Components';
|
|
5
5
|
import { Formio } from './Formio';
|
|
6
|
-
import { fastCloneDeep, bootstrapVersion, getArrayFromComponentPath, getStringFromComponentPath } from './utils
|
|
7
|
-
import { eachComponent, getComponent } from './utils/formUtils';
|
|
6
|
+
import { fastCloneDeep, bootstrapVersion, getArrayFromComponentPath, getStringFromComponentPath, eachComponent, getComponent, componentInfo } from './utils';
|
|
8
7
|
import BuilderUtils from './utils/builder';
|
|
9
8
|
import _ from 'lodash';
|
|
10
9
|
import autoScroll from 'dom-autoscroller';
|
|
@@ -1109,28 +1108,52 @@ export default class WebformBuilder extends Component {
|
|
|
1109
1108
|
// Called when we update a component.
|
|
1110
1109
|
this.emit('updateComponent', component);
|
|
1111
1110
|
}
|
|
1112
|
-
|
|
1113
|
-
const repeatablePaths =
|
|
1111
|
+
findComponentsWithRepeatablePaths() {
|
|
1112
|
+
const repeatablePaths = {};
|
|
1114
1113
|
const keys = new Map();
|
|
1115
1114
|
eachComponent(this.form.components, (comp, path, components, parent, paths) => {
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1115
|
+
const isRadioCheckbox = comp.type === 'checkbox' && comp.inputType === 'radio';
|
|
1116
|
+
const isLayout = componentInfo(comp).layout;
|
|
1117
|
+
if (!isLayout) {
|
|
1118
|
+
if (keys.has(paths.dataPath)) {
|
|
1119
|
+
const onlyRadioCheckboxes = repeatablePaths[paths.dataPath]?.onlyRadioCheckboxes === false ? false : isRadioCheckbox;
|
|
1120
|
+
repeatablePaths[paths.dataPath] = {
|
|
1121
|
+
comps: [...(repeatablePaths[paths.dataPath]?.comps || []), keys.get(paths.dataPath), comp],
|
|
1122
|
+
onlyRadioCheckboxes,
|
|
1123
|
+
};
|
|
1124
|
+
}
|
|
1125
|
+
else {
|
|
1126
|
+
keys.set(paths.dataPath, comp);
|
|
1127
|
+
}
|
|
1121
1128
|
}
|
|
1122
1129
|
}, true);
|
|
1123
|
-
|
|
1130
|
+
const componentsWithRepeatablePaths = [];
|
|
1131
|
+
Object.keys(repeatablePaths).forEach((path) => {
|
|
1132
|
+
const { comps, onlyRadioCheckboxes } = repeatablePaths[path];
|
|
1133
|
+
if (!onlyRadioCheckboxes) {
|
|
1134
|
+
componentsWithRepeatablePaths.push(...comps);
|
|
1135
|
+
}
|
|
1136
|
+
});
|
|
1137
|
+
return componentsWithRepeatablePaths;
|
|
1124
1138
|
}
|
|
1125
1139
|
highlightInvalidComponents() {
|
|
1126
|
-
const
|
|
1140
|
+
const repeatablePathsComps = this.findComponentsWithRepeatablePaths();
|
|
1127
1141
|
let hasInvalidComponents = false;
|
|
1142
|
+
// Matches anything expect letters and '_' at the beginning of the key and anything except of letters, numbers,
|
|
1143
|
+
// '-', '.' and '_' in the rest of the key
|
|
1144
|
+
const badCharacters = /^[^A-Za-z_]+|[^A-Za-z0-9\-._]+/g;
|
|
1128
1145
|
this.webform.everyComponent((comp) => {
|
|
1129
|
-
|
|
1130
|
-
if (repeatablePaths.includes(path)) {
|
|
1146
|
+
if (repeatablePathsComps.includes(comp.component)) {
|
|
1131
1147
|
comp.setCustomValidity(this.t('apiKey', { key: comp.key }));
|
|
1132
1148
|
hasInvalidComponents = true;
|
|
1133
1149
|
}
|
|
1150
|
+
else if (comp.key.replace(badCharacters, '') === '') {
|
|
1151
|
+
comp.setCustomValidity(this.t('apiKeyNotValid', { key: comp.key }));
|
|
1152
|
+
hasInvalidComponents = true;
|
|
1153
|
+
}
|
|
1154
|
+
else {
|
|
1155
|
+
comp.setCustomValidity();
|
|
1156
|
+
}
|
|
1134
1157
|
});
|
|
1135
1158
|
this.emit('builderFormValidityChange', hasInvalidComponents);
|
|
1136
1159
|
}
|
package/lib/mjs/Wizard.d.ts
CHANGED
|
@@ -6,7 +6,6 @@ declare class Wizard extends Webform {
|
|
|
6
6
|
originalComponents: any[];
|
|
7
7
|
page: number;
|
|
8
8
|
currentPanel: any;
|
|
9
|
-
currentPanels: any[] | null;
|
|
10
9
|
currentNextPage: number;
|
|
11
10
|
_seenPages: number[];
|
|
12
11
|
subWizards: any[];
|
|
@@ -17,7 +16,7 @@ declare class Wizard extends Webform {
|
|
|
17
16
|
originalOptions: any;
|
|
18
17
|
isLastPage(): any;
|
|
19
18
|
getPages(args?: {}): any[];
|
|
20
|
-
get
|
|
19
|
+
get hasSubWizards(): boolean;
|
|
21
20
|
get localData(): any;
|
|
22
21
|
get wizardKey(): string;
|
|
23
22
|
set wizard(form: object);
|
package/lib/mjs/Wizard.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import _ from 'lodash';
|
|
2
2
|
import Webform from './Webform';
|
|
3
3
|
import { Formio } from './Formio';
|
|
4
|
-
import { fastCloneDeep, checkCondition, firstNonNil, uniqueKey, eachComponent, } from './utils
|
|
4
|
+
import { fastCloneDeep, checkCondition, firstNonNil, uniqueKey, eachComponent, } from './utils';
|
|
5
5
|
export default class Wizard extends Webform {
|
|
6
6
|
/**
|
|
7
7
|
* Constructor for wizard-based forms.
|
|
@@ -29,7 +29,6 @@ export default class Wizard extends Webform {
|
|
|
29
29
|
this.originalComponents = [];
|
|
30
30
|
this.page = 0;
|
|
31
31
|
this.currentPanel = null;
|
|
32
|
-
this.currentPanels = null;
|
|
33
32
|
this.currentNextPage = 0;
|
|
34
33
|
this._seenPages = [0];
|
|
35
34
|
this.subWizards = [];
|
|
@@ -48,12 +47,12 @@ export default class Wizard extends Webform {
|
|
|
48
47
|
}
|
|
49
48
|
getPages(args = {}) {
|
|
50
49
|
const { all = false } = args;
|
|
51
|
-
const pages = this.
|
|
50
|
+
const pages = this.hasSubWizards ? this.components : this.pages;
|
|
52
51
|
const filteredPages = pages
|
|
53
52
|
.filter(all ? _.identity : (p, index) => this._seenPages.includes(index));
|
|
54
53
|
return filteredPages;
|
|
55
54
|
}
|
|
56
|
-
get
|
|
55
|
+
get hasSubWizards() {
|
|
57
56
|
return !_.isEmpty(this.subWizards);
|
|
58
57
|
}
|
|
59
58
|
get data() {
|
|
@@ -177,9 +176,9 @@ export default class Wizard extends Webform {
|
|
|
177
176
|
}
|
|
178
177
|
render() {
|
|
179
178
|
const ctx = this.renderContext;
|
|
180
|
-
if (this.component.
|
|
181
|
-
ctx.panels.
|
|
182
|
-
if (panel.
|
|
179
|
+
if (this.component.id) {
|
|
180
|
+
ctx.panels.forEach(panel => {
|
|
181
|
+
if (panel.id === this.component.id) {
|
|
183
182
|
this.currentPanel = panel;
|
|
184
183
|
ctx.wizardPageTooltip = this.getFormattedTooltip(panel.tooltip);
|
|
185
184
|
}
|
|
@@ -580,7 +579,7 @@ export default class Wizard extends Webform {
|
|
|
580
579
|
this.pageFieldLogic(num);
|
|
581
580
|
this.getNextPage();
|
|
582
581
|
let parentNum = num;
|
|
583
|
-
if (this.
|
|
582
|
+
if (this.hasSubWizards) {
|
|
584
583
|
const pageFromPages = this.pages[num];
|
|
585
584
|
const pageFromComponents = this.components[num];
|
|
586
585
|
if (!pageFromComponents || pageFromPages?.id !== pageFromComponents.id) {
|
|
@@ -869,23 +868,18 @@ export default class Wizard extends Webform {
|
|
|
869
868
|
this.showErrors(errors, true, true);
|
|
870
869
|
}
|
|
871
870
|
// If the pages change, need to redraw the header.
|
|
872
|
-
|
|
873
|
-
|
|
871
|
+
const currentPanels = this.pages;
|
|
872
|
+
// calling this.establishPages() updates/mutates this.pages to be the current pages
|
|
873
|
+
this.establishPages();
|
|
874
|
+
const newPanels = this.pages;
|
|
874
875
|
const currentNextPage = this.currentNextPage;
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
this.
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
else {
|
|
881
|
-
currentPanels = this.currentPanels || this.pages.map(page => page.component.key);
|
|
882
|
-
panels = this.establishPages().map(panel => panel.key);
|
|
883
|
-
this.currentPanels = panels;
|
|
884
|
-
if (this.currentPanel?.key && this.currentPanels?.length) {
|
|
885
|
-
this.setPage(this.currentPanels.findIndex(panel => panel === this.currentPanel.key));
|
|
886
|
-
}
|
|
876
|
+
const panelsUpdated = !_.isEqual(newPanels, currentPanels);
|
|
877
|
+
if (this.currentPanel?.id && this.pages.length && (!this.hasSubWizards || (this.hasSubWizards && panelsUpdated))) {
|
|
878
|
+
const newIndex = this.pages.findIndex(page => page.id === this.currentPanel.id);
|
|
879
|
+
if (newIndex !== -1)
|
|
880
|
+
this.setPage(newIndex);
|
|
887
881
|
}
|
|
888
|
-
if (
|
|
882
|
+
if (panelsUpdated || (flags && flags.fromSubmission)) {
|
|
889
883
|
this.redrawHeader();
|
|
890
884
|
}
|
|
891
885
|
// If the next page changes, then make sure to redraw navigation.
|
package/lib/mjs/WizardBuilder.js
CHANGED
|
@@ -2,7 +2,7 @@ import WebformBuilder from './WebformBuilder';
|
|
|
2
2
|
import Webform from './Webform';
|
|
3
3
|
import BuilderUtils from './utils/builder';
|
|
4
4
|
import _ from 'lodash';
|
|
5
|
-
import { fastCloneDeep } from './utils
|
|
5
|
+
import { fastCloneDeep } from './utils';
|
|
6
6
|
export default class WizardBuilder extends WebformBuilder {
|
|
7
7
|
constructor() {
|
|
8
8
|
let element, options;
|
|
@@ -54,7 +54,7 @@ export default class Components {
|
|
|
54
54
|
// eslint-disable-next-line new-cap
|
|
55
55
|
comp = new Components.components['datagrid'](component, options, data);
|
|
56
56
|
}
|
|
57
|
-
else if (component.tree) {
|
|
57
|
+
else if (component.tree || (component.input && Array.isArray(component.components))) {
|
|
58
58
|
// eslint-disable-next-line new-cap
|
|
59
59
|
comp = new Components.components['nesteddata'](component, options, data);
|
|
60
60
|
}
|
|
@@ -72,6 +72,12 @@ export default class Components {
|
|
|
72
72
|
if (comp.path) {
|
|
73
73
|
comp.componentsMap[comp.path] = comp;
|
|
74
74
|
}
|
|
75
|
+
// Reset the componentMatches on the root element if any new component is created.
|
|
76
|
+
let parent = comp.parent;
|
|
77
|
+
while (parent) {
|
|
78
|
+
parent.componentMatches = {};
|
|
79
|
+
parent = parent.parent;
|
|
80
|
+
}
|
|
75
81
|
return comp;
|
|
76
82
|
}
|
|
77
83
|
}
|
|
@@ -165,7 +165,6 @@ declare class Component extends Element {
|
|
|
165
165
|
get componentsMap(): object;
|
|
166
166
|
/**
|
|
167
167
|
* Returns if the parent should conditionally clear.
|
|
168
|
-
*
|
|
169
168
|
* @returns {boolean} - If the parent should conditionally clear.
|
|
170
169
|
*/
|
|
171
170
|
parentShouldConditionallyClear(): boolean;
|
|
@@ -5,8 +5,8 @@ import _ from 'lodash';
|
|
|
5
5
|
import isMobile from 'ismobilejs';
|
|
6
6
|
import { processOne, processOneSync, validateProcessInfo } from '@formio/core/process';
|
|
7
7
|
import { Formio } from '../../../Formio';
|
|
8
|
-
import
|
|
9
|
-
import { fastCloneDeep, boolValue, currentTimezone, getScriptPlugin, getContextualRowData } from '../../../utils
|
|
8
|
+
import FormioUtils from '../../../utils';
|
|
9
|
+
import { fastCloneDeep, boolValue, currentTimezone, getScriptPlugin, getContextualRowData } from '../../../utils';
|
|
10
10
|
import Element from '../../../Element';
|
|
11
11
|
import ComponentModal from '../componentModal/ComponentModal';
|
|
12
12
|
import Widgets from '../../../widgets';
|
|
@@ -424,7 +424,6 @@ export default class Component extends Element {
|
|
|
424
424
|
}
|
|
425
425
|
/**
|
|
426
426
|
* Returns if the parent should conditionally clear.
|
|
427
|
-
*
|
|
428
427
|
* @returns {boolean} - If the parent should conditionally clear.
|
|
429
428
|
*/
|
|
430
429
|
parentShouldConditionallyClear() {
|
|
@@ -1161,9 +1160,15 @@ export default class Component extends Element {
|
|
|
1161
1160
|
if (this.hasInput && this.component.validate?.required && !this.isPDFReadOnlyMode) {
|
|
1162
1161
|
modalLabel = { className: 'field-required' };
|
|
1163
1162
|
}
|
|
1163
|
+
let messages = '';
|
|
1164
|
+
if (this.errors?.length) {
|
|
1165
|
+
messages = this.errors.map((err) => {
|
|
1166
|
+
return err.level === 'error' ? this.renderTemplate('message', { ...err }) : '';
|
|
1167
|
+
}).join('');
|
|
1168
|
+
}
|
|
1164
1169
|
return this.renderModalPreview({
|
|
1165
1170
|
previewText: this.getValueAsString(dataValue, { modalPreview: true }) || this.t('clickToSetValue'),
|
|
1166
|
-
messages
|
|
1171
|
+
messages,
|
|
1167
1172
|
labelInfo: modalLabel,
|
|
1168
1173
|
});
|
|
1169
1174
|
}
|
|
@@ -2365,12 +2370,14 @@ export default class Component extends Element {
|
|
|
2365
2370
|
ckeditor: {
|
|
2366
2371
|
image: {
|
|
2367
2372
|
toolbar: [
|
|
2373
|
+
'toggleImageCaption',
|
|
2368
2374
|
'imageTextAlternative',
|
|
2369
2375
|
'|',
|
|
2370
|
-
'imageStyle:
|
|
2371
|
-
'imageStyle:
|
|
2372
|
-
'imageStyle:
|
|
2373
|
-
'
|
|
2376
|
+
'imageStyle:inline',
|
|
2377
|
+
'imageStyle:wrapText',
|
|
2378
|
+
'imageStyle:breakText',
|
|
2379
|
+
'|',
|
|
2380
|
+
'resizeImage'
|
|
2374
2381
|
],
|
|
2375
2382
|
styles: [
|
|
2376
2383
|
'full',
|
|
@@ -2392,7 +2399,10 @@ export default class Component extends Element {
|
|
|
2392
2399
|
if (this.component.isUploadEnabled) {
|
|
2393
2400
|
settings.extraPlugins.push(getFormioUploadAdapterPlugin(this.fileService, this));
|
|
2394
2401
|
}
|
|
2395
|
-
|
|
2402
|
+
Formio.requireLibrary(`ckeditor-css`, isIEBrowser ? 'CKEDITOR' : 'ClassicEditor', [
|
|
2403
|
+
{ type: 'styles', src: `${Formio.cdn.ckeditor}/ckeditor.css` }
|
|
2404
|
+
], true);
|
|
2405
|
+
return Formio.requireLibrary('ckeditor', isIEBrowser ? 'CKEDITOR' : 'ClassicEditor', _.get(this.options, 'editors.ckeditor.src', `${Formio.cdn.ckeditor}/ckeditor.umd.js`), true)
|
|
2396
2406
|
.then(() => {
|
|
2397
2407
|
if (!element.parentNode) {
|
|
2398
2408
|
return Promise.reject();
|
|
@@ -2578,6 +2588,17 @@ export default class Component extends Element {
|
|
|
2578
2588
|
noUpdateEvent: true,
|
|
2579
2589
|
noDefault: true
|
|
2580
2590
|
});
|
|
2591
|
+
if (FormioUtils.isLayoutComponent(this.component) && this.component.clearOnHide === true && !this.hasValue()) {
|
|
2592
|
+
FormioUtils.eachComponent(this.components, (component) => {
|
|
2593
|
+
if (component.component.clearOnHide !== false) {
|
|
2594
|
+
component.setValue(null, {
|
|
2595
|
+
noUpdateEvent: true,
|
|
2596
|
+
noDefault: true
|
|
2597
|
+
});
|
|
2598
|
+
component.unset();
|
|
2599
|
+
}
|
|
2600
|
+
});
|
|
2601
|
+
}
|
|
2581
2602
|
this.unset();
|
|
2582
2603
|
}
|
|
2583
2604
|
getCustomDefaultValue(defaultValue) {
|
|
@@ -2683,13 +2704,16 @@ export default class Component extends Element {
|
|
|
2683
2704
|
}
|
|
2684
2705
|
const isArray = Array.isArray(value);
|
|
2685
2706
|
const valueInput = this.refs.fileLink || this.refs.input;
|
|
2707
|
+
const isFilelink = !!this.refs.fileLink;
|
|
2686
2708
|
if (isArray &&
|
|
2687
2709
|
Array.isArray(this.defaultValue) &&
|
|
2688
2710
|
this.refs.hasOwnProperty('input') &&
|
|
2689
2711
|
valueInput &&
|
|
2690
2712
|
(valueInput.length !== value.length) &&
|
|
2691
2713
|
this.visible) {
|
|
2692
|
-
|
|
2714
|
+
if (isFilelink || valueInput.length) {
|
|
2715
|
+
this.redraw();
|
|
2716
|
+
}
|
|
2693
2717
|
}
|
|
2694
2718
|
if (this.isHtmlRenderMode() && flags && flags.fromSubmission && changed) {
|
|
2695
2719
|
this.redraw();
|
|
@@ -2700,6 +2724,11 @@ export default class Component extends Element {
|
|
|
2700
2724
|
this.setValueAt(i, isArray && !this.isSingleInputValue() ? value[i] : value, flags);
|
|
2701
2725
|
}
|
|
2702
2726
|
}
|
|
2727
|
+
// Also reset value of the modal component, otherwise it will keep the old value locally and the preview
|
|
2728
|
+
// element won't refresh
|
|
2729
|
+
if (this.componentModal && flags && flags.resetValue) {
|
|
2730
|
+
this.componentModal.setValue(value);
|
|
2731
|
+
}
|
|
2703
2732
|
return changed;
|
|
2704
2733
|
}
|
|
2705
2734
|
/**
|
|
@@ -3196,6 +3225,9 @@ export default class Component extends Element {
|
|
|
3196
3225
|
data = data || this.rootValue;
|
|
3197
3226
|
flags = flags || {};
|
|
3198
3227
|
row = row || this.data;
|
|
3228
|
+
if (flags.noCheck) {
|
|
3229
|
+
return true;
|
|
3230
|
+
}
|
|
3199
3231
|
// Some components (for legacy reasons) have calls to "checkData" in inappropriate places such
|
|
3200
3232
|
// as setValue. Historically, this was bypassed by a series of cached states around the data model
|
|
3201
3233
|
// which caused its own problems. We need to ensure that premium and custom components do not fall into
|
|
@@ -3210,9 +3242,6 @@ export default class Component extends Element {
|
|
|
3210
3242
|
if (!flags.fromBlur) {
|
|
3211
3243
|
this.checkRefreshOn(flags.changes, flags);
|
|
3212
3244
|
}
|
|
3213
|
-
if (flags.noCheck) {
|
|
3214
|
-
return true;
|
|
3215
|
-
}
|
|
3216
3245
|
this.checkComponentConditions(data, flags, row);
|
|
3217
3246
|
if (this.id !== flags.triggeredComponentId) {
|
|
3218
3247
|
this.calculateComponentValue(data, flags, row);
|
|
@@ -82,6 +82,7 @@ declare const _default: ({
|
|
|
82
82
|
inline?: undefined;
|
|
83
83
|
defaultValue?: undefined;
|
|
84
84
|
values?: undefined;
|
|
85
|
+
customConditional?: undefined;
|
|
85
86
|
logic?: undefined;
|
|
86
87
|
dataSrc?: undefined;
|
|
87
88
|
valueProperty?: undefined;
|
|
@@ -101,6 +102,7 @@ declare const _default: ({
|
|
|
101
102
|
inline?: undefined;
|
|
102
103
|
defaultValue?: undefined;
|
|
103
104
|
values?: undefined;
|
|
105
|
+
customConditional?: undefined;
|
|
104
106
|
logic?: undefined;
|
|
105
107
|
dataSrc?: undefined;
|
|
106
108
|
valueProperty?: undefined;
|
|
@@ -126,6 +128,7 @@ declare const _default: ({
|
|
|
126
128
|
value: string;
|
|
127
129
|
})[];
|
|
128
130
|
placeholder?: undefined;
|
|
131
|
+
customConditional?: undefined;
|
|
129
132
|
logic?: undefined;
|
|
130
133
|
dataSrc?: undefined;
|
|
131
134
|
valueProperty?: undefined;
|
|
@@ -141,6 +144,7 @@ declare const _default: ({
|
|
|
141
144
|
tooltip: string;
|
|
142
145
|
key: string;
|
|
143
146
|
input: boolean;
|
|
147
|
+
customConditional: string;
|
|
144
148
|
logic: ({
|
|
145
149
|
name: string;
|
|
146
150
|
trigger: {
|
|
@@ -211,6 +215,7 @@ declare const _default: ({
|
|
|
211
215
|
inline?: undefined;
|
|
212
216
|
defaultValue?: undefined;
|
|
213
217
|
values?: undefined;
|
|
218
|
+
customConditional?: undefined;
|
|
214
219
|
logic?: undefined;
|
|
215
220
|
as?: undefined;
|
|
216
221
|
editor?: undefined;
|
|
@@ -226,6 +231,7 @@ declare const _default: ({
|
|
|
226
231
|
placeholder?: undefined;
|
|
227
232
|
inline?: undefined;
|
|
228
233
|
values?: undefined;
|
|
234
|
+
customConditional?: undefined;
|
|
229
235
|
logic?: undefined;
|
|
230
236
|
dataSrc?: undefined;
|
|
231
237
|
valueProperty?: undefined;
|
|
@@ -248,6 +254,7 @@ declare const _default: ({
|
|
|
248
254
|
placeholder?: undefined;
|
|
249
255
|
inline?: undefined;
|
|
250
256
|
values?: undefined;
|
|
257
|
+
customConditional?: undefined;
|
|
251
258
|
logic?: undefined;
|
|
252
259
|
dataSrc?: undefined;
|
|
253
260
|
valueProperty?: undefined;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import _ from 'lodash';
|
|
2
|
-
import { fastCloneDeep } from '../../../utils
|
|
2
|
+
import { fastCloneDeep } from '../../../utils';
|
|
3
3
|
export default class ComponentModal {
|
|
4
4
|
static render(component, data, topLevel) {
|
|
5
5
|
const children = component.renderTemplate('component', data, topLevel);
|
|
@@ -25,7 +25,7 @@ export default class Input extends Multivalue {
|
|
|
25
25
|
get suffix(): any;
|
|
26
26
|
renderElement(value: any, index: any): any;
|
|
27
27
|
setCounter(type: any, element: any, count: any, max: any): void;
|
|
28
|
-
updateValueAt(value: any, flags: any, index
|
|
28
|
+
updateValueAt(value: any, flags: any, index?: number): void;
|
|
29
29
|
getValueAt(index: any): any;
|
|
30
30
|
updateValue(value: any, flags: any, index: any): boolean;
|
|
31
31
|
parseValue(value: any): any;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import Multivalue from '../multivalue/Multivalue';
|
|
2
|
-
import { convertStringToHTMLElement } from '../../../utils
|
|
2
|
+
import { convertStringToHTMLElement } from '../../../utils';
|
|
3
3
|
import Widgets from '../../../widgets';
|
|
4
4
|
import _ from 'lodash';
|
|
5
5
|
export default class Input extends Multivalue {
|
|
@@ -113,7 +113,7 @@ export default class Input extends Multivalue {
|
|
|
113
113
|
}
|
|
114
114
|
const info = this.inputInfo;
|
|
115
115
|
info.attr = info.attr || {};
|
|
116
|
-
info.attr.value = this.getValueAsString(this.formatValue(this.parseValue(value)))
|
|
116
|
+
info.attr.value = this.getValueAsString(this.formatValue(this.parseValue(this.isMultipleMasksField ? value.value : value)))
|
|
117
117
|
.replace(/"/g, '"');
|
|
118
118
|
const valueMask = this.component.inputMask;
|
|
119
119
|
const displayMask = this.component.displayMask;
|
|
@@ -158,7 +158,7 @@ export default class Input extends Multivalue {
|
|
|
158
158
|
}));
|
|
159
159
|
}
|
|
160
160
|
}
|
|
161
|
-
updateValueAt(value, flags, index) {
|
|
161
|
+
updateValueAt(value, flags, index = 0) {
|
|
162
162
|
flags = flags || {};
|
|
163
163
|
if (_.get(this.component, 'showWordCount', false)) {
|
|
164
164
|
if (this.refs.wordcount && this.refs.wordcount[index]) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import Field from '../field/Field';
|
|
2
2
|
import { Formio } from '../../../Formio';
|
|
3
3
|
import _ from 'lodash';
|
|
4
|
-
import { getItemTemplateKeys } from '../../../utils
|
|
4
|
+
import { getItemTemplateKeys } from '../../../utils';
|
|
5
5
|
export default class ListComponent extends Field {
|
|
6
6
|
static schema(...extend) {
|
|
7
7
|
return Field.schema({
|
|
@@ -108,6 +108,7 @@ export default class NestedComponent extends Field {
|
|
|
108
108
|
* @returns {any} - The component that is located.
|
|
109
109
|
*/
|
|
110
110
|
getComponent(path: string): any;
|
|
111
|
+
componentMatches: {} | undefined;
|
|
111
112
|
/**
|
|
112
113
|
* Return a component provided the Id of the component.
|
|
113
114
|
* @param {string} id - The Id of the component.
|