@formio/js 5.1.0-dev.6109.79f22ad → 5.1.0-dev.6112.06b0f26
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 +116 -149
- 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 +123 -156
- package/dist/formio.full.min.css +1 -1
- package/dist/formio.full.min.js +1 -1
- package/dist/formio.js +65 -54
- 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 +9 -9
- 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/_classes/component/Component.d.ts +0 -1
- package/lib/cjs/components/_classes/component/Component.js +55 -62
- package/lib/cjs/components/_classes/component/editForm/Component.edit.conditional.js +1 -1
- 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.js +7 -7
- 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 +1 -1
- 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 +1 -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.js +1 -1
- 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 +8 -0
- package/lib/cjs/components/radio/Radio.js +16 -6
- 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/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 +64 -135
- 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 +7 -7
- 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/_classes/component/Component.d.ts +0 -1
- package/lib/mjs/components/_classes/component/Component.js +28 -12
- package/lib/mjs/components/_classes/component/editForm/Component.edit.conditional.js +1 -1
- 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.js +7 -7
- 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 +1 -1
- 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 +1 -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.js +1 -1
- 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 +8 -0
- package/lib/mjs/components/radio/Radio.js +16 -6
- 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/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 -109
- 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
@@ -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() {
|
@@ -2365,12 +2364,14 @@ export default class Component extends Element {
|
|
2365
2364
|
ckeditor: {
|
2366
2365
|
image: {
|
2367
2366
|
toolbar: [
|
2367
|
+
'toggleImageCaption',
|
2368
2368
|
'imageTextAlternative',
|
2369
2369
|
'|',
|
2370
|
-
'imageStyle:
|
2371
|
-
'imageStyle:
|
2372
|
-
'imageStyle:
|
2373
|
-
'
|
2370
|
+
'imageStyle:inline',
|
2371
|
+
'imageStyle:wrapText',
|
2372
|
+
'imageStyle:breakText',
|
2373
|
+
'|',
|
2374
|
+
'resizeImage'
|
2374
2375
|
],
|
2375
2376
|
styles: [
|
2376
2377
|
'full',
|
@@ -2392,7 +2393,10 @@ export default class Component extends Element {
|
|
2392
2393
|
if (this.component.isUploadEnabled) {
|
2393
2394
|
settings.extraPlugins.push(getFormioUploadAdapterPlugin(this.fileService, this));
|
2394
2395
|
}
|
2395
|
-
|
2396
|
+
Formio.requireLibrary(`ckeditor-css`, isIEBrowser ? 'CKEDITOR' : 'ClassicEditor', [
|
2397
|
+
{ type: 'styles', src: `${Formio.cdn.ckeditor}/ckeditor.css` }
|
2398
|
+
], true);
|
2399
|
+
return Formio.requireLibrary('ckeditor', isIEBrowser ? 'CKEDITOR' : 'ClassicEditor', _.get(this.options, 'editors.ckeditor.src', `${Formio.cdn.ckeditor}/ckeditor.umd.js`), true)
|
2396
2400
|
.then(() => {
|
2397
2401
|
if (!element.parentNode) {
|
2398
2402
|
return Promise.reject();
|
@@ -2578,6 +2582,15 @@ export default class Component extends Element {
|
|
2578
2582
|
noUpdateEvent: true,
|
2579
2583
|
noDefault: true
|
2580
2584
|
});
|
2585
|
+
if (FormioUtils.isLayoutComponent(this.component) && this.component.clearOnHide === true && !this.hasValue()) {
|
2586
|
+
FormioUtils.eachComponent(this.components, (component) => {
|
2587
|
+
component.setValue(null, {
|
2588
|
+
noUpdateEvent: true,
|
2589
|
+
noDefault: true
|
2590
|
+
});
|
2591
|
+
component.unset();
|
2592
|
+
});
|
2593
|
+
}
|
2581
2594
|
this.unset();
|
2582
2595
|
}
|
2583
2596
|
getCustomDefaultValue(defaultValue) {
|
@@ -2683,13 +2696,16 @@ export default class Component extends Element {
|
|
2683
2696
|
}
|
2684
2697
|
const isArray = Array.isArray(value);
|
2685
2698
|
const valueInput = this.refs.fileLink || this.refs.input;
|
2699
|
+
const isFilelink = !!this.refs.fileLink;
|
2686
2700
|
if (isArray &&
|
2687
2701
|
Array.isArray(this.defaultValue) &&
|
2688
2702
|
this.refs.hasOwnProperty('input') &&
|
2689
2703
|
valueInput &&
|
2690
2704
|
(valueInput.length !== value.length) &&
|
2691
2705
|
this.visible) {
|
2692
|
-
|
2706
|
+
if (isFilelink || valueInput.length) {
|
2707
|
+
this.redraw();
|
2708
|
+
}
|
2693
2709
|
}
|
2694
2710
|
if (this.isHtmlRenderMode() && flags && flags.fromSubmission && changed) {
|
2695
2711
|
this.redraw();
|
@@ -3196,6 +3212,9 @@ export default class Component extends Element {
|
|
3196
3212
|
data = data || this.rootValue;
|
3197
3213
|
flags = flags || {};
|
3198
3214
|
row = row || this.data;
|
3215
|
+
if (flags.noCheck) {
|
3216
|
+
return true;
|
3217
|
+
}
|
3199
3218
|
// Some components (for legacy reasons) have calls to "checkData" in inappropriate places such
|
3200
3219
|
// as setValue. Historically, this was bypassed by a series of cached states around the data model
|
3201
3220
|
// which caused its own problems. We need to ensure that premium and custom components do not fall into
|
@@ -3210,9 +3229,6 @@ export default class Component extends Element {
|
|
3210
3229
|
if (!flags.fromBlur) {
|
3211
3230
|
this.checkRefreshOn(flags.changes, flags);
|
3212
3231
|
}
|
3213
|
-
if (flags.noCheck) {
|
3214
|
-
return true;
|
3215
|
-
}
|
3216
3232
|
this.checkComponentConditions(data, flags, row);
|
3217
3233
|
if (this.id !== flags.triggeredComponentId) {
|
3218
3234
|
this.calculateComponentValue(data, flags, row);
|
@@ -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({
|
@@ -3,7 +3,7 @@ import _ from 'lodash';
|
|
3
3
|
import Field from '../field/Field';
|
4
4
|
import Components from '../../Components';
|
5
5
|
'';
|
6
|
-
import
|
6
|
+
import FormioUtils from '../../../utils';
|
7
7
|
import { process as processAsync, processSync } from '@formio/core/process';
|
8
8
|
/**
|
9
9
|
* NestedComponent class.
|
@@ -204,7 +204,7 @@ export default class NestedComponent extends Field {
|
|
204
204
|
*/
|
205
205
|
set rowIndex(value) {
|
206
206
|
this._rowIndex = value;
|
207
|
-
this.paths = getComponentPaths(this.component, this.parent?.component, {
|
207
|
+
this.paths = FormioUtils.getComponentPaths(this.component, this.parent?.component, {
|
208
208
|
...(this.parent?.paths || {}),
|
209
209
|
...{ dataIndex: value }
|
210
210
|
});
|
@@ -308,7 +308,7 @@ export default class NestedComponent extends Field {
|
|
308
308
|
* @returns {any} - The component that is located.
|
309
309
|
*/
|
310
310
|
getComponent(path) {
|
311
|
-
path = getStringFromComponentPath(path);
|
311
|
+
path = FormioUtils.getStringFromComponentPath(path);
|
312
312
|
const matches = {
|
313
313
|
path: undefined,
|
314
314
|
fullPath: undefined,
|
@@ -320,7 +320,7 @@ export default class NestedComponent extends Field {
|
|
320
320
|
};
|
321
321
|
this.everyComponent((component) => {
|
322
322
|
// All searches are relative to this component so replace this path from the child paths.
|
323
|
-
componentMatches(component.component, {
|
323
|
+
FormioUtils.componentMatches(component.component, {
|
324
324
|
path: component.paths?.path?.replace(new RegExp(`^${this.paths?.path}\\.?`), ''),
|
325
325
|
fullPath: component.paths?.fullPath?.replace(new RegExp(`^${this.paths?.fullPath}\\.?`), ''),
|
326
326
|
localPath: component.paths?.localPath?.replace(new RegExp(`^${this.paths?.localPath}\\.?`), ''),
|
@@ -332,7 +332,7 @@ export default class NestedComponent extends Field {
|
|
332
332
|
return match;
|
333
333
|
});
|
334
334
|
});
|
335
|
-
return getBestMatch(matches)?.instance;
|
335
|
+
return FormioUtils.getBestMatch(matches)?.instance;
|
336
336
|
}
|
337
337
|
/**
|
338
338
|
* Return a component provided the Id of the component.
|
@@ -374,7 +374,7 @@ export default class NestedComponent extends Field {
|
|
374
374
|
options.localRoot = this.localRoot;
|
375
375
|
options.skipInit = true;
|
376
376
|
if (!(options.display === 'pdf' && this.builderMode)) {
|
377
|
-
component.id = getRandomComponentId();
|
377
|
+
component.id = FormioUtils.getRandomComponentId();
|
378
378
|
}
|
379
379
|
const comp = Components.create(component, options, data, true);
|
380
380
|
comp.init();
|
@@ -659,7 +659,7 @@ export default class NestedComponent extends Field {
|
|
659
659
|
}
|
660
660
|
validationProcessor({ scope, data, row, instance, paths }, flags) {
|
661
661
|
const { dirty } = flags;
|
662
|
-
if (this.root.
|
662
|
+
if (this.root && this.root.hasSubWizards && this.page !== this.root.page) {
|
663
663
|
instance = this.componentsMap?.hasOwnProperty(paths.dataPath)
|
664
664
|
? this.componentsMap[paths.dataPath]
|
665
665
|
: this.getComponent(paths.dataPath);
|
@@ -2,7 +2,7 @@
|
|
2
2
|
import _ from 'lodash';
|
3
3
|
import { Utils } from '@formio/core/utils';
|
4
4
|
const { getComponentPaths } = Utils;
|
5
|
-
import { componentValueTypes, isLayoutComponent } from '../../../utils
|
5
|
+
import { componentValueTypes, isLayoutComponent } from '../../../utils';
|
6
6
|
import Component from '../component/Component';
|
7
7
|
import NestedDataComponent from '../nesteddata/NestedDataComponent';
|
8
8
|
export default class NestedArrayComponent extends NestedDataComponent {
|
@@ -2,7 +2,7 @@
|
|
2
2
|
import Component from '../component/Component';
|
3
3
|
import NestedComponent from '../nested/NestedComponent';
|
4
4
|
import _ from 'lodash';
|
5
|
-
import { componentValueTypes, getComponentSavedTypes } from '../../../utils
|
5
|
+
import { componentValueTypes, getComponentSavedTypes } from '../../../utils';
|
6
6
|
export default class NestedDataComponent extends NestedComponent {
|
7
7
|
hasChanged(newValue, oldValue) {
|
8
8
|
// If we do not have a value and are getting set to anything other than undefined or null, then we changed.
|
@@ -5,7 +5,7 @@ import { GoogleAddressProvider } from '../../providers/address/GoogleAddressProv
|
|
5
5
|
import Field from '../_classes/field/Field';
|
6
6
|
import NestedComponent from '../_classes/nested/NestedComponent';
|
7
7
|
import ContainerComponent from '../container/Container';
|
8
|
-
import { componentValueTypes, getComponentSavedTypes } from '../../utils
|
8
|
+
import { componentValueTypes, getComponentSavedTypes } from '../../utils';
|
9
9
|
export const AddressComponentMode = {
|
10
10
|
Autocomplete: 'autocomplete',
|
11
11
|
Manual: 'manual',
|
@@ -1,7 +1,7 @@
|
|
1
1
|
import _ from 'lodash';
|
2
2
|
import Field from '../_classes/field/Field';
|
3
3
|
import Input from '../_classes/input/Input';
|
4
|
-
import { componentValueTypes, eachComponent, getArrayFromComponentPath, getComponentSavedTypes } from '../../utils
|
4
|
+
import { componentValueTypes, eachComponent, getArrayFromComponentPath, getComponentSavedTypes } from '../../utils';
|
5
5
|
export default class ButtonComponent extends Field {
|
6
6
|
static schema(...extend) {
|
7
7
|
return Input.schema({
|
@@ -1,5 +1,5 @@
|
|
1
1
|
import _ from 'lodash';
|
2
|
-
import { componentValueTypes, getComponentSavedTypes } from '../../utils
|
2
|
+
import { componentValueTypes, getComponentSavedTypes } from '../../utils';
|
3
3
|
import Field from '../_classes/field/Field';
|
4
4
|
export default class CheckBoxComponent extends Field {
|
5
5
|
static schema(...extend) {
|
@@ -1,5 +1,5 @@
|
|
1
1
|
import _ from 'lodash';
|
2
|
-
import { componentValueTypes, getComponentSavedTypes, getFocusableElements } from '../../utils
|
2
|
+
import { componentValueTypes, getComponentSavedTypes, getFocusableElements } from '../../utils';
|
3
3
|
import Component from '../_classes/component/Component';
|
4
4
|
import Field from '../_classes/field/Field';
|
5
5
|
import NestedDataComponent from '../_classes/nesteddata/NestedDataComponent';
|
@@ -1,7 +1,7 @@
|
|
1
1
|
import { createNumberMask } from '@formio/text-mask-addons';
|
2
2
|
import { maskInput } from '@formio/vanilla-text-mask';
|
3
3
|
import _ from 'lodash';
|
4
|
-
import { getCurrencyAffixes } from '../../utils
|
4
|
+
import { getCurrencyAffixes } from '../../utils';
|
5
5
|
import NumberComponent from '../number/Number';
|
6
6
|
export default class CurrencyComponent extends NumberComponent {
|
7
7
|
static schema(...extend) {
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import _ from 'lodash';
|
2
2
|
import NestedArrayComponent from '../_classes/nestedarray/NestedArrayComponent';
|
3
|
-
import { fastCloneDeep, getFocusableElements, getComponent } from '../../utils
|
3
|
+
import { fastCloneDeep, getFocusableElements, getComponent } from '../../utils';
|
4
4
|
export default class DataGridComponent extends NestedArrayComponent {
|
5
5
|
static schema(...extend) {
|
6
6
|
return NestedArrayComponent.schema({
|
@@ -223,6 +223,9 @@ export default class DataMapComponent extends DataGridComponent {
|
|
223
223
|
options.name += `[${rowIndex}]`;
|
224
224
|
options.row = `${rowIndex}`;
|
225
225
|
options.rowIndex = rowIndex;
|
226
|
+
options.onChange = (flags, changed, modified) => {
|
227
|
+
this.triggerChange({ modified });
|
228
|
+
};
|
226
229
|
const components = {};
|
227
230
|
components['__key'] = this.createComponent(this.keySchema, options, { __key: this.builderMode ? this.defaultRowKey : key });
|
228
231
|
components['__key'].on('componentChange', (event) => {
|
@@ -238,7 +241,9 @@ export default class DataMapComponent extends DataGridComponent {
|
|
238
241
|
valueComponent.key = key;
|
239
242
|
const componentOptions = this.options;
|
240
243
|
componentOptions.row = options.row;
|
241
|
-
|
244
|
+
const componentOptionsCloned = _.clone(componentOptions);
|
245
|
+
componentOptionsCloned.onChange = options.onChange;
|
246
|
+
components[this.valueKey] = this.createComponent(valueComponent, componentOptionsCloned, this.dataValue);
|
242
247
|
return components;
|
243
248
|
}
|
244
249
|
get canAddColumn() {
|
@@ -261,7 +266,7 @@ export default class DataMapComponent extends DataGridComponent {
|
|
261
266
|
const index = this.rows.length;
|
262
267
|
this.rows[index] = this.createRowComponents(this.dataValue, index);
|
263
268
|
this.redraw();
|
264
|
-
this.triggerChange();
|
269
|
+
this.triggerChange({ modified: true });
|
265
270
|
}
|
266
271
|
removeRow(index) {
|
267
272
|
const keys = Object.keys(this.dataValue);
|
@@ -17,7 +17,7 @@ export default class DateTimeComponent extends Input {
|
|
17
17
|
};
|
18
18
|
static savedValueTypes(schema: any): string[];
|
19
19
|
get emptyValue(): string;
|
20
|
-
get
|
20
|
+
get dayjsFormat(): string;
|
21
21
|
createWrapper(): boolean;
|
22
22
|
checkValidity(data: any, dirty: any, rowData: any): boolean;
|
23
23
|
getValueAsString(value: any, options: any): any;
|
@@ -1,7 +1,7 @@
|
|
1
1
|
import _ from 'lodash';
|
2
|
-
import
|
2
|
+
import dayjs from 'dayjs';
|
3
3
|
import FormioUtils from '../../utils';
|
4
|
-
import { componentValueTypes, fastCloneDeep, getComponentSavedTypes } from '../../utils
|
4
|
+
import { componentValueTypes, fastCloneDeep, getComponentSavedTypes } from '../../utils';
|
5
5
|
import Input from '../_classes/input/Input';
|
6
6
|
export default class DateTimeComponent extends Input {
|
7
7
|
static schema(...extend) {
|
@@ -147,8 +147,8 @@ export default class DateTimeComponent extends Input {
|
|
147
147
|
get emptyValue() {
|
148
148
|
return '';
|
149
149
|
}
|
150
|
-
get
|
151
|
-
return FormioUtils.
|
150
|
+
get dayjsFormat() {
|
151
|
+
return FormioUtils.convertFormatToDayjs(this.component.format);
|
152
152
|
}
|
153
153
|
isEmpty(value = this.dataValue) {
|
154
154
|
if (value && (value.toString() === 'Invalid Date')) {
|
@@ -157,12 +157,14 @@ export default class DateTimeComponent extends Input {
|
|
157
157
|
return super.isEmpty(value);
|
158
158
|
}
|
159
159
|
formatValue(input) {
|
160
|
-
|
161
|
-
|
160
|
+
if (dayjs(input).isValid()) {
|
161
|
+
return dayjs.utc(input).toISOString();
|
162
|
+
}
|
163
|
+
return input;
|
162
164
|
}
|
163
165
|
isEqual(valueA, valueB = this.dataValue) {
|
164
166
|
return (this.isEmpty(valueA) && this.isEmpty(valueB))
|
165
|
-
||
|
167
|
+
|| dayjs.utc(valueA).format(this.dayjsFormat) === dayjs.utc(valueB).format(this.dayjsFormat);
|
166
168
|
}
|
167
169
|
createWrapper() {
|
168
170
|
return false;
|
@@ -178,18 +180,18 @@ export default class DateTimeComponent extends Input {
|
|
178
180
|
return super.checkValidity(data, dirty, rowData);
|
179
181
|
}
|
180
182
|
getValueAsString(value, options) {
|
181
|
-
let format = FormioUtils.
|
182
|
-
format += format.match(/z$/) ? '' : ' z';
|
183
|
+
let format = FormioUtils.convertFormatToDayjs(this.component.format);
|
183
184
|
const timezone = this.timezone;
|
184
185
|
if (value && !this.attached && timezone) {
|
186
|
+
format += format.match(/z$/) ? '' : ' z';
|
185
187
|
if (Array.isArray(value) && this.component.multiple) {
|
186
|
-
return value.map(item => _.trim(FormioUtils.
|
188
|
+
return value.map(item => _.trim(FormioUtils.dayjsDate(item, format, timezone, options).format(format))).join(', ');
|
187
189
|
}
|
188
|
-
return _.trim(FormioUtils.
|
190
|
+
return _.trim(FormioUtils.dayjsDate(value, format, timezone, options).format(format));
|
189
191
|
}
|
190
192
|
if (Array.isArray(value) && this.component.multiple) {
|
191
|
-
return value.map(item => _.trim(
|
193
|
+
return value.map(item => _.trim(dayjs(item).format(format))).join(', ');
|
192
194
|
}
|
193
|
-
return (value ? _.trim(
|
195
|
+
return (value ? _.trim(dayjs(value).format(format)) : value) || '';
|
194
196
|
}
|
195
197
|
}
|
@@ -1,7 +1,7 @@
|
|
1
1
|
import _ from 'lodash';
|
2
2
|
import moment from 'moment';
|
3
3
|
import Field from '../_classes/field/Field';
|
4
|
-
import { boolValue, componentValueTypes, getComponentSavedTypes, getLocaleDateFormatInfo } from '../../utils
|
4
|
+
import { boolValue, componentValueTypes, getComponentSavedTypes, getLocaleDateFormatInfo } from '../../utils';
|
5
5
|
import { getDayFormat } from '@formio/core';
|
6
6
|
export default class DayComponent extends Field {
|
7
7
|
static schema(...extend) {
|
@@ -53,7 +53,7 @@ export default class DayComponent extends Field {
|
|
53
53
|
// Empty value used before 9.3.x
|
54
54
|
static oldEmptyValue = '00/00/0000';
|
55
55
|
constructor(component, options, data) {
|
56
|
-
if (!options.inFormBuilder && !options.building) {
|
56
|
+
if (options && !options.inFormBuilder && !options.building) {
|
57
57
|
if (component.maxDate && component.maxDate.indexOf('moment(') === -1) {
|
58
58
|
component.maxDate = moment(component.maxDate, 'YYYY-MM-DD').toISOString();
|
59
59
|
}
|
@@ -4,7 +4,7 @@ import { editgrid as templates } from '@formio/bootstrap/components';
|
|
4
4
|
import NestedArrayComponent from '../_classes/nestedarray/NestedArrayComponent';
|
5
5
|
import Component from '../_classes/component/Component';
|
6
6
|
import Alert from '../alert/Alert';
|
7
|
-
import { fastCloneDeep, Evaluator, getArrayFromComponentPath, eachComponent } from '../../utils
|
7
|
+
import { fastCloneDeep, Evaluator, getArrayFromComponentPath, eachComponent } from '../../utils';
|
8
8
|
const EditRowState = {
|
9
9
|
New: 'new',
|
10
10
|
Editing: 'editing',
|
@@ -1,5 +1,5 @@
|
|
1
1
|
import Field from '../_classes/field/Field';
|
2
|
-
import { componentValueTypes, getComponentSavedTypes, uniqueName } from '../../utils
|
2
|
+
import { componentValueTypes, getComponentSavedTypes, uniqueName } from '../../utils';
|
3
3
|
import download from 'downloadjs';
|
4
4
|
import _ from 'lodash';
|
5
5
|
import fileProcessor from '../../providers/processor/fileProcessor';
|
@@ -3,7 +3,7 @@ import _ from 'lodash';
|
|
3
3
|
import Component from '../_classes/component/Component';
|
4
4
|
import ComponentModal from '../_classes/componentModal/ComponentModal';
|
5
5
|
import EventEmitter from 'eventemitter3';
|
6
|
-
import { isMongoId, eachComponent, componentValueTypes } from '../../utils
|
6
|
+
import { isMongoId, eachComponent, componentValueTypes } from '../../utils';
|
7
7
|
import { Formio } from '../../Formio';
|
8
8
|
import Form from '../../Form';
|
9
9
|
export default class FormComponent extends Component {
|
@@ -274,6 +274,9 @@ export default class FormComponent extends Component {
|
|
274
274
|
if (this.isSubFormLazyLoad() && !this.hasLoadedForm && !this.subFormLoading) {
|
275
275
|
this.createSubForm(true);
|
276
276
|
}
|
277
|
+
if (!this.subFormReady) {
|
278
|
+
return Promise.resolve();
|
279
|
+
}
|
277
280
|
return this.subFormReady.then(() => {
|
278
281
|
this.empty(element);
|
279
282
|
if (this.options.builder) {
|
@@ -408,7 +411,8 @@ export default class FormComponent extends Component {
|
|
408
411
|
const componentsMap = this.componentsMap;
|
409
412
|
const formComponentsMap = this.subForm.componentsMap;
|
410
413
|
_.assign(componentsMap, formComponentsMap);
|
411
|
-
this.component.components = this.subForm.components
|
414
|
+
this.component.components = this.subForm._form?.components;
|
415
|
+
this.component.display = this.subForm._form?.display;
|
412
416
|
this.subForm.on('change', () => {
|
413
417
|
if (this.subForm && !this.shouldConditionallyClear()) {
|
414
418
|
this.dataValue = this.subForm.getValue();
|
@@ -688,6 +692,13 @@ export default class FormComponent extends Component {
|
|
688
692
|
}
|
689
693
|
return errors;
|
690
694
|
}
|
695
|
+
conditionallyHidden() {
|
696
|
+
const conditionallyHidden = super.conditionallyHidden();
|
697
|
+
if (this.subForm) {
|
698
|
+
this.subForm._conditionallyHidden = conditionallyHidden;
|
699
|
+
}
|
700
|
+
return conditionallyHidden;
|
701
|
+
}
|
691
702
|
updateSubFormVisibility() {
|
692
703
|
if (this.subForm) {
|
693
704
|
this.subForm.parentVisible = this.visible;
|
@@ -30,9 +30,10 @@ export default [
|
|
30
30
|
tooltip: 'if it is checked, the subform is loaded after navigation to the page with this component within the wizard.',
|
31
31
|
input: true,
|
32
32
|
customConditional({ instance, data }) {
|
33
|
-
const
|
33
|
+
const formComp = instance.root?.getComponent('form');
|
34
|
+
const formInfo = formComp?.defaultDownloadedResources.find(res => res._id === data.form);
|
34
35
|
const displayMode = 'wizard';
|
35
|
-
return instance.options?.editForm?.display === displayMode && formInfo && formInfo.display !== displayMode;
|
36
|
+
return instance.options?.editForm?.display === displayMode && ((data.form && !formInfo) || (formInfo && formInfo.display !== displayMode));
|
36
37
|
},
|
37
38
|
},
|
38
39
|
{
|
@@ -2,7 +2,7 @@ import { createNumberMask } from '@formio/text-mask-addons';
|
|
2
2
|
import { conformToMask, maskInput } from '@formio/vanilla-text-mask';
|
3
3
|
import _ from 'lodash';
|
4
4
|
import Input from '../_classes/input/Input';
|
5
|
-
import { getNumberSeparators, getNumberDecimalLimit, componentValueTypes, getComponentSavedTypes } from '../../utils/
|
5
|
+
import { getNumberSeparators, getNumberDecimalLimit, componentValueTypes, getComponentSavedTypes } from '../../utils/';
|
6
6
|
export default class NumberComponent extends Input {
|
7
7
|
static schema(...extend) {
|
8
8
|
return Input.schema({
|
@@ -1,5 +1,5 @@
|
|
1
1
|
import NestedComponent from '../_classes/nested/NestedComponent';
|
2
|
-
import { isChildOf } from '../../utils
|
2
|
+
import { isChildOf } from '../../utils';
|
3
3
|
export default class PanelComponent extends NestedComponent {
|
4
4
|
static schema(...extend) {
|
5
5
|
return NestedComponent.schema({
|
@@ -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';
|
@@ -1,7 +1,7 @@
|
|
1
1
|
import _ from 'lodash';
|
2
2
|
import ListComponent from '../_classes/list/ListComponent';
|
3
3
|
import { Formio } from '../../Formio';
|
4
|
-
import { boolValue, componentValueTypes, getComponentSavedTypes } from '../../utils
|
4
|
+
import { boolValue, componentValueTypes, getComponentSavedTypes } from '../../utils';
|
5
5
|
export default class RadioComponent extends ListComponent {
|
6
6
|
static schema(...extend) {
|
7
7
|
return ListComponent.schema({
|
@@ -153,6 +153,12 @@ export default class RadioComponent extends ListComponent {
|
|
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 => ({ ...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 @@ export default class RadioComponent extends ListComponent {
|
|
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 @@ export default class RadioComponent extends ListComponent {
|
|
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,13 +444,17 @@ export default class RadioComponent extends ListComponent {
|
|
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
|
-
_.set(submission.metadata.selectData, this.path, this.templateData[
|
456
|
+
_.set(submission.metadata.selectData, this.path, this.templateData[valueConverted]);
|
447
457
|
}
|
448
|
-
return super.normalizeValue(
|
458
|
+
return super.normalizeValue(valueConverted);
|
449
459
|
}
|
450
460
|
}
|