@formio/js 5.1.0-dev.6156.9cd5779 → 5.1.0-dev.6162.d0510e0
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.builder.css +1 -0
- package/dist/formio.builder.min.css +1 -1
- package/dist/formio.form.css +1 -0
- package/dist/formio.form.js +21 -43
- 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 +23 -45
- package/dist/formio.full.min.css +1 -1
- package/dist/formio.full.min.js +1 -1
- package/dist/formio.js +8 -8
- package/dist/formio.min.js +1 -1
- package/dist/formio.utils.js +9 -9
- package/dist/formio.utils.min.js +1 -1
- package/lib/cjs/Element.d.ts +2 -1
- package/lib/cjs/Element.js +6 -4
- package/lib/cjs/PDFBuilder.d.ts +1 -0
- package/lib/cjs/PDFBuilder.js +8 -8
- package/lib/cjs/Webform.d.ts +2 -2
- package/lib/cjs/Webform.js +4 -3
- package/lib/cjs/WebformBuilder.d.ts +1 -1
- package/lib/cjs/WebformBuilder.js +36 -11
- package/lib/cjs/components/Components.js +1 -1
- package/lib/cjs/components/_classes/component/Component.js +10 -5
- package/lib/cjs/components/_classes/input/Input.d.ts +1 -1
- package/lib/cjs/components/_classes/input/Input.js +2 -2
- package/lib/cjs/components/_classes/nested/NestedComponent.js +2 -2
- package/lib/cjs/components/radio/Radio.d.ts +8 -0
- package/lib/cjs/components/radio/Radio.js +15 -5
- package/lib/cjs/components/select/Select.d.ts +1 -0
- package/lib/cjs/components/select/Select.js +19 -3
- package/lib/cjs/components/selectboxes/SelectBoxes.d.ts +6 -0
- package/lib/cjs/components/textarea/TextArea.js +6 -1
- package/lib/cjs/components/textfield/TextField.js +6 -1
- package/lib/cjs/formio.form.js +2 -2
- package/lib/cjs/translations/en.d.ts +1 -232
- package/lib/cjs/translations/en.js +4 -2
- package/lib/cjs/utils/formUtils.d.ts +2 -2
- package/lib/cjs/utils/index.d.ts +2 -2
- package/lib/cjs/utils/utils.js +10 -3
- package/lib/mjs/Element.d.ts +2 -1
- package/lib/mjs/Element.js +6 -4
- package/lib/mjs/PDFBuilder.d.ts +1 -0
- package/lib/mjs/PDFBuilder.js +8 -8
- package/lib/mjs/Webform.d.ts +2 -2
- package/lib/mjs/Webform.js +4 -3
- package/lib/mjs/WebformBuilder.d.ts +1 -1
- package/lib/mjs/WebformBuilder.js +36 -12
- package/lib/mjs/components/Components.js +1 -1
- package/lib/mjs/components/_classes/component/Component.js +10 -5
- package/lib/mjs/components/_classes/input/Input.d.ts +1 -1
- package/lib/mjs/components/_classes/input/Input.js +2 -2
- package/lib/mjs/components/_classes/nested/NestedComponent.js +2 -2
- package/lib/mjs/components/radio/Radio.d.ts +8 -0
- package/lib/mjs/components/radio/Radio.js +15 -5
- package/lib/mjs/components/select/Select.d.ts +1 -0
- package/lib/mjs/components/select/Select.js +19 -3
- package/lib/mjs/components/selectboxes/SelectBoxes.d.ts +6 -0
- package/lib/mjs/components/textarea/TextArea.js +6 -1
- package/lib/mjs/components/textfield/TextField.js +6 -1
- package/lib/mjs/formio.form.js +1 -1
- package/lib/mjs/translations/en.d.ts +1 -232
- package/lib/mjs/translations/en.js +8 -47
- package/lib/mjs/utils/formUtils.d.ts +2 -2
- package/lib/mjs/utils/index.d.ts +2 -2
- package/lib/mjs/utils/utils.js +10 -2
- package/package.json +2 -2
- 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/cjs/Element.d.ts
CHANGED
@@ -170,10 +170,11 @@ export default class Element {
|
|
170
170
|
/**
|
171
171
|
* Translate a text using the i18n system.
|
172
172
|
* @param {string|Array<string>} text - The i18n identifier.
|
173
|
+
* @param {any} data - contextual data object containing data, component, row, etc.
|
173
174
|
* @param {...any} args - The arguments to pass to the i18n translation.
|
174
175
|
* @returns {string} - The translated text.
|
175
176
|
*/
|
176
|
-
t(text: string | Array<string>, ...args: any[]): string;
|
177
|
+
t(text: string | Array<string>, data: any, ...args: any[]): string;
|
177
178
|
/**
|
178
179
|
* Alias to create a text node.
|
179
180
|
* @param {string} text - The text to create.
|
package/lib/cjs/Element.js
CHANGED
@@ -8,8 +8,9 @@ const moment_1 = __importDefault(require("moment"));
|
|
8
8
|
const vanilla_text_mask_1 = __importDefault(require("@formio/vanilla-text-mask"));
|
9
9
|
const EventEmitter_1 = __importDefault(require("./EventEmitter"));
|
10
10
|
const Formio_1 = require("./Formio");
|
11
|
-
const i18n_1 = require("./utils/i18n");
|
12
11
|
const utils_1 = __importDefault(require("./utils"));
|
12
|
+
const core_1 = require("@formio/core");
|
13
|
+
const en_1 = __importDefault(require("./translations/en"));
|
13
14
|
/**
|
14
15
|
* The root component for all elements within the Form.io renderer.
|
15
16
|
*/
|
@@ -44,7 +45,7 @@ class Element {
|
|
44
45
|
if ((_a = this.options) === null || _a === void 0 ? void 0 : _a.language) {
|
45
46
|
this.options.i18n.language = this.options.language;
|
46
47
|
}
|
47
|
-
this.options.i18next = this.i18next = this.options.i18next ||
|
48
|
+
this.options.i18next = this.i18next = this.options.i18next || core_1.I18n.init(Object.assign({ en: en_1.default }, this.options.i18n));
|
48
49
|
/**
|
49
50
|
* An instance of the EventEmitter class to handle the emitting and registration of events.
|
50
51
|
* @type {EventEmitter}
|
@@ -392,11 +393,12 @@ class Element {
|
|
392
393
|
/**
|
393
394
|
* Translate a text using the i18n system.
|
394
395
|
* @param {string|Array<string>} text - The i18n identifier.
|
396
|
+
* @param {any} data - contextual data object containing data, component, row, etc.
|
395
397
|
* @param {...any} args - The arguments to pass to the i18n translation.
|
396
398
|
* @returns {string} - The translated text.
|
397
399
|
*/
|
398
|
-
t(text, ...args) {
|
399
|
-
return this.i18next ? this.i18next.t(text, ...args) : text;
|
400
|
+
t(text, data, ...args) {
|
401
|
+
return this.i18next ? this.i18next.t(text, data, ...args) : text;
|
400
402
|
}
|
401
403
|
/**
|
402
404
|
* Alias to create a text node.
|
package/lib/cjs/PDFBuilder.d.ts
CHANGED
package/lib/cjs/PDFBuilder.js
CHANGED
@@ -451,21 +451,21 @@ class PDFBuilder extends WebformBuilder_1.default {
|
|
451
451
|
e.target.style.cursor = 'default';
|
452
452
|
}
|
453
453
|
highlightInvalidComponents() {
|
454
|
-
const
|
454
|
+
const repeatablePathsComps = this.findComponentsWithRepeatablePaths();
|
455
455
|
// update elements which path was duplicated if any pathes have been changed
|
456
|
-
if (!lodash_1.default.isEqual(this.
|
457
|
-
(0, utils_1.eachComponent)(this.webform.getComponents(), (comp
|
458
|
-
if (this.
|
456
|
+
if (!lodash_1.default.isEqual(this.repeatablePathsComps, repeatablePathsComps)) {
|
457
|
+
(0, utils_1.eachComponent)(this.webform.getComponents(), (comp) => {
|
458
|
+
if (this.repeatablePathsComps.includes(comp.component)) {
|
459
459
|
this.webform.postMessage({ name: 'updateElement', data: comp.component });
|
460
460
|
}
|
461
461
|
});
|
462
|
-
this.
|
462
|
+
this.repeatablePathsComps = repeatablePathsComps;
|
463
463
|
}
|
464
|
-
if (!
|
464
|
+
if (!repeatablePathsComps.length) {
|
465
465
|
return;
|
466
466
|
}
|
467
|
-
(0, utils_1.eachComponent)(this.webform.getComponents(), (comp
|
468
|
-
if (this.
|
467
|
+
(0, utils_1.eachComponent)(this.webform.getComponents(), (comp) => {
|
468
|
+
if (this.repeatablePathsComps.includes(comp)) {
|
469
469
|
this.webform.postMessage({
|
470
470
|
name: 'showBuilderErrors',
|
471
471
|
data: {
|
package/lib/cjs/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/cjs/Webform.js
CHANGED
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const lodash_1 = __importDefault(require("lodash"));
|
7
7
|
const compare_versions_1 = require("compare-versions");
|
8
8
|
const EventEmitter_1 = __importDefault(require("./EventEmitter"));
|
9
|
-
const
|
9
|
+
const en_1 = __importDefault(require("./translations/en"));
|
10
10
|
const Formio_1 = require("./Formio");
|
11
11
|
const Components_1 = __importDefault(require("./components/Components"));
|
12
12
|
const NestedDataComponent_1 = __importDefault(require("./components/_classes/nesteddata/NestedDataComponent"));
|
@@ -99,7 +99,7 @@ function getOptions(options) {
|
|
99
99
|
* @property {number} [saveDraftThrottle] - The throttle for the save draft feature.
|
100
100
|
* @property {boolean} [readOnly] - Set this form to readOnly.
|
101
101
|
* @property {boolean} [noAlerts] - Disable the alerts dialog.
|
102
|
-
* @property {{[key: string]: string}} [
|
102
|
+
* @property {{[key: string]: string}} [enTranslation] - The translation file for this rendering.
|
103
103
|
* @property {string} [template] - Custom logic for creation of elements.
|
104
104
|
* @property {boolean} [noDefaults] - Exclude default values from the settings.
|
105
105
|
* @property {any} [fileService] - The file service for this form.
|
@@ -369,7 +369,7 @@ class Webform extends NestedDataComponent_1.default {
|
|
369
369
|
*/
|
370
370
|
addLanguage(code, lang, active = false) {
|
371
371
|
if (this.i18next) {
|
372
|
-
var translations = lodash_1.default.assign((0, utils_1.fastCloneDeep)(
|
372
|
+
var translations = lodash_1.default.assign((0, utils_1.fastCloneDeep)(en_1.default), lang);
|
373
373
|
this.i18next.addResourceBundle(code, 'translation', translations, true, true);
|
374
374
|
if (active) {
|
375
375
|
this.language = code;
|
@@ -1320,6 +1320,7 @@ class Webform extends NestedDataComponent_1.default {
|
|
1320
1320
|
userAgent: navigator.userAgent,
|
1321
1321
|
pathName: window.location.pathname,
|
1322
1322
|
onLine: navigator.onLine,
|
1323
|
+
language: this.language,
|
1323
1324
|
});
|
1324
1325
|
}
|
1325
1326
|
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.
|
@@ -1125,28 +1125,53 @@ class WebformBuilder extends Component_1.default {
|
|
1125
1125
|
// Called when we update a component.
|
1126
1126
|
this.emit('updateComponent', component);
|
1127
1127
|
}
|
1128
|
-
|
1129
|
-
const repeatablePaths =
|
1128
|
+
findComponentsWithRepeatablePaths() {
|
1129
|
+
const repeatablePaths = {};
|
1130
1130
|
const keys = new Map();
|
1131
1131
|
(0, utils_1.eachComponent)(this.form.components, (comp, path, components, parent, paths) => {
|
1132
|
-
|
1133
|
-
|
1134
|
-
|
1135
|
-
|
1136
|
-
keys.
|
1132
|
+
var _a, _b;
|
1133
|
+
const isRadioCheckbox = comp.type === 'checkbox' && comp.inputType === 'radio';
|
1134
|
+
const isLayout = (0, utils_1.componentInfo)(comp).layout;
|
1135
|
+
if (!isLayout) {
|
1136
|
+
if (keys.has(paths.dataPath)) {
|
1137
|
+
const onlyRadioCheckboxes = ((_a = repeatablePaths[paths.dataPath]) === null || _a === void 0 ? void 0 : _a.onlyRadioCheckboxes) === false ? false : isRadioCheckbox;
|
1138
|
+
repeatablePaths[paths.dataPath] = {
|
1139
|
+
comps: [...(((_b = repeatablePaths[paths.dataPath]) === null || _b === void 0 ? void 0 : _b.comps) || []), keys.get(paths.dataPath), comp],
|
1140
|
+
onlyRadioCheckboxes,
|
1141
|
+
};
|
1142
|
+
}
|
1143
|
+
else {
|
1144
|
+
keys.set(paths.dataPath, comp);
|
1145
|
+
}
|
1137
1146
|
}
|
1138
1147
|
}, true);
|
1139
|
-
|
1148
|
+
const componentsWithRepeatablePaths = [];
|
1149
|
+
Object.keys(repeatablePaths).forEach((path) => {
|
1150
|
+
const { comps, onlyRadioCheckboxes } = repeatablePaths[path];
|
1151
|
+
if (!onlyRadioCheckboxes) {
|
1152
|
+
componentsWithRepeatablePaths.push(...comps);
|
1153
|
+
}
|
1154
|
+
});
|
1155
|
+
return componentsWithRepeatablePaths;
|
1140
1156
|
}
|
1141
1157
|
highlightInvalidComponents() {
|
1142
|
-
const
|
1158
|
+
const repeatablePathsComps = this.findComponentsWithRepeatablePaths();
|
1143
1159
|
let hasInvalidComponents = false;
|
1160
|
+
// Matches anything expect letters and '_' at the beginning of the key and anything except of letters, numbers,
|
1161
|
+
// '-', '.' and '_' in the rest of the key
|
1162
|
+
const badCharacters = /^[^A-Za-z_]+|[^A-Za-z0-9\-._]+/g;
|
1144
1163
|
this.webform.everyComponent((comp) => {
|
1145
|
-
|
1146
|
-
if (repeatablePaths.includes(path)) {
|
1164
|
+
if (repeatablePathsComps.includes(comp.component)) {
|
1147
1165
|
comp.setCustomValidity(this.t('apiKey', { key: comp.key }));
|
1148
1166
|
hasInvalidComponents = true;
|
1149
1167
|
}
|
1168
|
+
else if (comp.key.replace(badCharacters, '') === '') {
|
1169
|
+
comp.setCustomValidity(this.t('apiKeyNotValid', { key: comp.key }));
|
1170
|
+
hasInvalidComponents = true;
|
1171
|
+
}
|
1172
|
+
else {
|
1173
|
+
comp.setCustomValidity();
|
1174
|
+
}
|
1150
1175
|
});
|
1151
1176
|
this.emit('builderFormValidityChange', hasInvalidComponents);
|
1152
1177
|
}
|
@@ -57,7 +57,7 @@ class Components {
|
|
57
57
|
// eslint-disable-next-line new-cap
|
58
58
|
comp = new Components.components['datagrid'](component, options, data);
|
59
59
|
}
|
60
|
-
else if (component.tree) {
|
60
|
+
else if (component.tree || (component.input && Array.isArray(component.components))) {
|
61
61
|
// eslint-disable-next-line new-cap
|
62
62
|
comp = new Components.components['nesteddata'](component, options, data);
|
63
63
|
}
|
@@ -2375,12 +2375,14 @@ class Component extends Element_1.default {
|
|
2375
2375
|
ckeditor: {
|
2376
2376
|
image: {
|
2377
2377
|
toolbar: [
|
2378
|
+
'toggleImageCaption',
|
2378
2379
|
'imageTextAlternative',
|
2379
2380
|
'|',
|
2380
|
-
'imageStyle:
|
2381
|
-
'imageStyle:
|
2382
|
-
'imageStyle:
|
2383
|
-
'
|
2381
|
+
'imageStyle:inline',
|
2382
|
+
'imageStyle:wrapText',
|
2383
|
+
'imageStyle:breakText',
|
2384
|
+
'|',
|
2385
|
+
'resizeImage'
|
2384
2386
|
],
|
2385
2387
|
styles: [
|
2386
2388
|
'full',
|
@@ -2402,7 +2404,10 @@ class Component extends Element_1.default {
|
|
2402
2404
|
if (this.component.isUploadEnabled) {
|
2403
2405
|
settings.extraPlugins.push((0, uploadAdapter_1.getFormioUploadAdapterPlugin)(this.fileService, this));
|
2404
2406
|
}
|
2405
|
-
|
2407
|
+
Formio_1.Formio.requireLibrary(`ckeditor-css`, isIEBrowser ? 'CKEDITOR' : 'ClassicEditor', [
|
2408
|
+
{ type: 'styles', src: `${Formio_1.Formio.cdn.ckeditor}/ckeditor.css` }
|
2409
|
+
], true);
|
2410
|
+
return Formio_1.Formio.requireLibrary('ckeditor', isIEBrowser ? 'CKEDITOR' : 'ClassicEditor', lodash_1.default.get(this.options, 'editors.ckeditor.src', `${Formio_1.Formio.cdn.ckeditor}/ckeditor.umd.js`), true)
|
2406
2411
|
.then(() => {
|
2407
2412
|
if (!element.parentNode) {
|
2408
2413
|
return Promise.reject();
|
@@ -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;
|
@@ -118,7 +118,7 @@ class Input extends Multivalue_1.default {
|
|
118
118
|
}
|
119
119
|
const info = this.inputInfo;
|
120
120
|
info.attr = info.attr || {};
|
121
|
-
info.attr.value = this.getValueAsString(this.formatValue(this.parseValue(value)))
|
121
|
+
info.attr.value = this.getValueAsString(this.formatValue(this.parseValue(this.isMultipleMasksField ? value.value : value)))
|
122
122
|
.replace(/"/g, '"');
|
123
123
|
const valueMask = this.component.inputMask;
|
124
124
|
const displayMask = this.component.displayMask;
|
@@ -163,7 +163,7 @@ class Input extends Multivalue_1.default {
|
|
163
163
|
}));
|
164
164
|
}
|
165
165
|
}
|
166
|
-
updateValueAt(value, flags, index) {
|
166
|
+
updateValueAt(value, flags, index = 0) {
|
167
167
|
flags = flags || {};
|
168
168
|
if (lodash_1.default.get(this.component, 'showWordCount', false)) {
|
169
169
|
if (this.refs.wordcount && this.refs.wordcount[index]) {
|
@@ -664,7 +664,7 @@ class NestedComponent extends Field_1.default {
|
|
664
664
|
validationProcessor({ scope, data, row, instance, paths }, flags) {
|
665
665
|
var _a;
|
666
666
|
const { dirty } = flags;
|
667
|
-
if (this.root.hasSubWizards && this.page !== this.root.page) {
|
667
|
+
if (this.root && this.root.hasSubWizards && this.page !== this.root.page) {
|
668
668
|
instance = ((_a = this.componentsMap) === null || _a === void 0 ? void 0 : _a.hasOwnProperty(paths.dataPath))
|
669
669
|
? this.componentsMap[paths.dataPath]
|
670
670
|
: this.getComponent(paths.dataPath);
|
@@ -813,7 +813,7 @@ class NestedComponent extends Field_1.default {
|
|
813
813
|
return false;
|
814
814
|
}
|
815
815
|
if (component.type === 'components') {
|
816
|
-
if (component.tree && component.hasValue(value)) {
|
816
|
+
if ((component.tree || component.hasInput) && component.hasValue(value)) {
|
817
817
|
return component.setValue(lodash_1.default.get(value, component.key), flags);
|
818
818
|
}
|
819
819
|
return component.setValue(value, flags);
|
@@ -28,6 +28,7 @@ export default class RadioComponent extends ListComponent {
|
|
28
28
|
optionsLoaded: boolean | undefined;
|
29
29
|
loadedOptions: any[] | undefined;
|
30
30
|
beforeSubmit(): Promise<any>;
|
31
|
+
convertValues(values: any): any;
|
31
32
|
render(): string;
|
32
33
|
attach(element: any): Promise<void>;
|
33
34
|
detach(element: any): void;
|
@@ -41,5 +42,12 @@ export default class RadioComponent extends ListComponent {
|
|
41
42
|
setSelectedClasses(): void;
|
42
43
|
updateValue(value: any, flags: any): boolean;
|
43
44
|
currentValue: any;
|
45
|
+
/**
|
46
|
+
* Normalize values coming into updateValue. For example, depending on the configuration, string value `"true"` will be normalized to boolean `true`.
|
47
|
+
* @param {*} value - The value to normalize
|
48
|
+
* @returns {*} - Returns the normalized value
|
49
|
+
*/
|
50
|
+
convertByDataType(value: any): any;
|
51
|
+
normalizeValue(value: any): any;
|
44
52
|
}
|
45
53
|
import ListComponent from '../_classes/list/ListComponent';
|
@@ -153,6 +153,12 @@ class RadioComponent extends ListComponent_1.default {
|
|
153
153
|
this.dataReady.then(() => res(true));
|
154
154
|
});
|
155
155
|
}
|
156
|
+
convertValues(values) {
|
157
|
+
if (this.options.renderMode === 'html' && this.type === 'radio') {
|
158
|
+
return values.map(x => (Object.assign(Object.assign({}, x), { value: this.convertByDataType(x.value) })));
|
159
|
+
}
|
160
|
+
return values;
|
161
|
+
}
|
156
162
|
render() {
|
157
163
|
if (!this.optionsLoaded) {
|
158
164
|
return super.render(this.renderTemplate('loader'));
|
@@ -160,7 +166,7 @@ class RadioComponent extends ListComponent_1.default {
|
|
160
166
|
return super.render(this.renderTemplate('radio', {
|
161
167
|
input: this.inputInfo,
|
162
168
|
inline: this.component.inline,
|
163
|
-
values: this.component.dataSrc === 'values' ? this.component.values : this.loadedOptions,
|
169
|
+
values: this.component.dataSrc === 'values' ? this.convertValues(this.component.values) : this.loadedOptions,
|
164
170
|
value: this.dataValue,
|
165
171
|
row: this.row,
|
166
172
|
}));
|
@@ -406,7 +412,7 @@ class RadioComponent extends ListComponent_1.default {
|
|
406
412
|
* @param {*} value - The value to normalize
|
407
413
|
* @returns {*} - Returns the normalized value
|
408
414
|
*/
|
409
|
-
|
415
|
+
convertByDataType(value) {
|
410
416
|
const dataType = this.component.dataType || 'auto';
|
411
417
|
if (value === this.emptyValue) {
|
412
418
|
return value;
|
@@ -438,14 +444,18 @@ class RadioComponent extends ListComponent_1.default {
|
|
438
444
|
value = !(!value || value.toString() === 'false');
|
439
445
|
break;
|
440
446
|
}
|
441
|
-
|
447
|
+
return value;
|
448
|
+
}
|
449
|
+
normalizeValue(value) {
|
450
|
+
const valueConverted = this.convertByDataType(value);
|
451
|
+
if (this.isSelectURL && this.templateData && this.templateData[valueConverted]) {
|
442
452
|
const submission = this.root.submission;
|
443
453
|
if (!submission.metadata.selectData) {
|
444
454
|
submission.metadata.selectData = {};
|
445
455
|
}
|
446
|
-
lodash_1.default.set(submission.metadata.selectData, this.path, this.templateData[
|
456
|
+
lodash_1.default.set(submission.metadata.selectData, this.path, this.templateData[valueConverted]);
|
447
457
|
}
|
448
|
-
return super.normalizeValue(
|
458
|
+
return super.normalizeValue(valueConverted);
|
449
459
|
}
|
450
460
|
}
|
451
461
|
exports.default = RadioComponent;
|
@@ -89,6 +89,7 @@ export default class SelectComponent extends ListComponent {
|
|
89
89
|
disableInfiniteScroll(): void;
|
90
90
|
set serverCount(value: any);
|
91
91
|
get serverCount(): any;
|
92
|
+
shouldResetChoicesItems(items: any): boolean;
|
92
93
|
setItems(items: any, fromSearch: any): void;
|
93
94
|
selectItems: any;
|
94
95
|
set downloadedResources(value: any);
|
@@ -355,6 +355,18 @@ class SelectComponent extends ListComponent_1.default {
|
|
355
355
|
this.downloadedResources.serverCount = this.downloadedResources.length;
|
356
356
|
this.serverCount = this.downloadedResources.length;
|
357
357
|
}
|
358
|
+
shouldResetChoicesItems(items) {
|
359
|
+
if (this.choices._store.choices.length !== items.length) {
|
360
|
+
return true;
|
361
|
+
}
|
362
|
+
for (let item of items) {
|
363
|
+
const choicesItem = this.choices._store.choices.find((i) => i.label === item.label);
|
364
|
+
if (!choicesItem) {
|
365
|
+
return true;
|
366
|
+
}
|
367
|
+
}
|
368
|
+
return false;
|
369
|
+
}
|
358
370
|
/* eslint-disable max-statements */
|
359
371
|
setItems(items, fromSearch) {
|
360
372
|
var _a, _b;
|
@@ -441,7 +453,7 @@ class SelectComponent extends ListComponent_1.default {
|
|
441
453
|
this.addOption(itemValueAndLabel.value, itemValueAndLabel.label, {}, lodash_1.default.get(item, this.component.idPath, String(index)));
|
442
454
|
});
|
443
455
|
if (this.choices) {
|
444
|
-
this.choices.setChoices(this.selectOptions, 'value', 'label', true);
|
456
|
+
this.choices.setChoices(this.selectOptions, 'value', 'label', true, true, !fromSearch && this.shouldResetChoicesItems(this.selectOptions));
|
445
457
|
}
|
446
458
|
else if (this.loading) {
|
447
459
|
// Re-attach select input.
|
@@ -903,8 +915,9 @@ class SelectComponent extends ListComponent_1.default {
|
|
903
915
|
});
|
904
916
|
}
|
905
917
|
// Add value options.
|
918
|
+
const value = this.undoValueTyping(this.dataValue);
|
906
919
|
this.addValueOptions();
|
907
|
-
this.setChoicesValue(
|
920
|
+
this.setChoicesValue(value);
|
908
921
|
if (this.isSelectResource && this.refs.addResource) {
|
909
922
|
this.addEventListener(this.refs.addResource, 'click', (event) => {
|
910
923
|
event.preventDefault();
|
@@ -1219,7 +1232,7 @@ class SelectComponent extends ListComponent_1.default {
|
|
1219
1232
|
}
|
1220
1233
|
lodash_1.default.set(submission.metadata.selectData, this.path, templateData);
|
1221
1234
|
}
|
1222
|
-
if (flags.resetValue && ((_b = this.root) === null || _b === void 0 ? void 0 : _b.submission) && !this.options.readOnly) {
|
1235
|
+
if (flags.resetValue && !flags.fromSubmission && ((_b = this.root) === null || _b === void 0 ? void 0 : _b.submission) && !this.options.readOnly) {
|
1223
1236
|
const submission = this.root.submission;
|
1224
1237
|
if (!submission.metadata) {
|
1225
1238
|
submission.metadata = {};
|
@@ -1283,6 +1296,9 @@ class SelectComponent extends ListComponent_1.default {
|
|
1283
1296
|
this.lazyLoadInit = true;
|
1284
1297
|
const searchProperty = this.component.searchField || this.component.valueProperty;
|
1285
1298
|
this.triggerUpdate(lodash_1.default.get(value.data || value, searchProperty, value), true);
|
1299
|
+
this.itemsLoaded.then(() => {
|
1300
|
+
this.setChoicesValue(value, hasPreviousValue, flags);
|
1301
|
+
});
|
1286
1302
|
return changed;
|
1287
1303
|
}
|
1288
1304
|
// Add the value options.
|
@@ -8,6 +8,12 @@ export default class SelectBoxesComponent extends RadioComponent {
|
|
8
8
|
* @returns {boolean} - If the value is empty.
|
9
9
|
*/
|
10
10
|
isEmpty(value?: any): boolean;
|
11
|
+
/**
|
12
|
+
* Normalize values coming into updateValue.
|
13
|
+
* @param {any} value - The value to normalize.
|
14
|
+
* @returns {*} - The normalized value
|
15
|
+
*/
|
16
|
+
normalizeValue(value: any): any;
|
11
17
|
setInputsDisabled(value: any, onlyUnchecked: any): void;
|
12
18
|
checkComponentValidity(data: any, dirty: any, rowData: any, options: any, errors?: any[]): boolean;
|
13
19
|
}
|
@@ -193,7 +193,12 @@ class TextAreaComponent extends TextField_1.default {
|
|
193
193
|
const editorHeight = (numRows * 31) + 14;
|
194
194
|
editor.ui.view.editable.editableElement.style.height = `${(editorHeight)}px`;
|
195
195
|
}
|
196
|
-
|
196
|
+
if (isReadOnly) {
|
197
|
+
editor.enableReadOnlyMode(this.id);
|
198
|
+
}
|
199
|
+
else {
|
200
|
+
editor.disableReadOnlyMode(this.id);
|
201
|
+
}
|
197
202
|
editor.data.set(value);
|
198
203
|
}
|
199
204
|
editorReady(editor);
|
@@ -107,7 +107,12 @@ class TextFieldComponent extends Input_1.default {
|
|
107
107
|
// If no value is provided, then set the defaultValue.
|
108
108
|
if (!value.value) {
|
109
109
|
const defaultValue = flags.noDefault ? this.emptyValue : this.defaultValue;
|
110
|
-
|
110
|
+
if (Array.isArray(defaultValue)) {
|
111
|
+
value.value = lodash_1.default.isObject(defaultValue[0]) ? defaultValue[0].value : defaultValue;
|
112
|
+
}
|
113
|
+
else {
|
114
|
+
value.value = lodash_1.default.isObject(defaultValue) ? defaultValue.value : defaultValue;
|
115
|
+
}
|
111
116
|
}
|
112
117
|
return value;
|
113
118
|
}
|
package/lib/cjs/formio.form.js
CHANGED
@@ -28,7 +28,7 @@ const EventEmitter_1 = __importDefault(require("./EventEmitter"));
|
|
28
28
|
exports.EventEmitter = EventEmitter_1.default;
|
29
29
|
const Webform_1 = __importDefault(require("./Webform"));
|
30
30
|
exports.Webform = Webform_1.default;
|
31
|
-
const
|
31
|
+
const core_1 = require("@formio/core");
|
32
32
|
const utils_2 = require("./utils");
|
33
33
|
Formio_1.Formio.loadModules = (path = `${Formio_1.Formio.getApiUrl()}/externalModules.js`, name = 'externalModules') => {
|
34
34
|
Formio_1.Formio.requireLibrary(name, name, path, true)
|
@@ -103,7 +103,7 @@ function registerModule(mod, defaultFn = null, options = {}) {
|
|
103
103
|
(0, utils_2.registerEvaluator)(mod.evaluator);
|
104
104
|
break;
|
105
105
|
case 'translations':
|
106
|
-
|
106
|
+
core_1.I18n.setDefaultTranslations(mod.translations);
|
107
107
|
break;
|
108
108
|
case 'library':
|
109
109
|
options.license
|