@formio/js 5.1.0-dev.6108.401a61f → 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.d.ts +1 -0
- package/lib/cjs/components/select/Select.js +20 -4
- 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.d.ts +1 -0
- package/lib/mjs/components/select/Select.js +20 -4
- 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 -5
- 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
@@ -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;
|
@@ -4,9 +4,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
4
4
|
};
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
6
6
|
const lodash_1 = __importDefault(require("lodash"));
|
7
|
-
const
|
7
|
+
const dayjs_1 = __importDefault(require("dayjs"));
|
8
8
|
const utils_1 = __importDefault(require("../../utils"));
|
9
|
-
const utils_2 = require("../../utils
|
9
|
+
const utils_2 = require("../../utils");
|
10
10
|
const Input_1 = __importDefault(require("../_classes/input/Input"));
|
11
11
|
class DateTimeComponent extends Input_1.default {
|
12
12
|
static schema(...extend) {
|
@@ -123,8 +123,8 @@ class DateTimeComponent extends Input_1.default {
|
|
123
123
|
get emptyValue() {
|
124
124
|
return '';
|
125
125
|
}
|
126
|
-
get
|
127
|
-
return utils_1.default.
|
126
|
+
get dayjsFormat() {
|
127
|
+
return utils_1.default.convertFormatToDayjs(this.component.format);
|
128
128
|
}
|
129
129
|
isEmpty(value = this.dataValue) {
|
130
130
|
if (value && (value.toString() === 'Invalid Date')) {
|
@@ -133,12 +133,14 @@ class DateTimeComponent extends Input_1.default {
|
|
133
133
|
return super.isEmpty(value);
|
134
134
|
}
|
135
135
|
formatValue(input) {
|
136
|
-
|
137
|
-
|
136
|
+
if ((0, dayjs_1.default)(input).isValid()) {
|
137
|
+
return dayjs_1.default.utc(input).toISOString();
|
138
|
+
}
|
139
|
+
return input;
|
138
140
|
}
|
139
141
|
isEqual(valueA, valueB = this.dataValue) {
|
140
142
|
return (this.isEmpty(valueA) && this.isEmpty(valueB))
|
141
|
-
||
|
143
|
+
|| dayjs_1.default.utc(valueA).format(this.dayjsFormat) === dayjs_1.default.utc(valueB).format(this.dayjsFormat);
|
142
144
|
}
|
143
145
|
createWrapper() {
|
144
146
|
return false;
|
@@ -154,19 +156,19 @@ class DateTimeComponent extends Input_1.default {
|
|
154
156
|
return super.checkValidity(data, dirty, rowData);
|
155
157
|
}
|
156
158
|
getValueAsString(value, options) {
|
157
|
-
let format = utils_1.default.
|
158
|
-
format += format.match(/z$/) ? '' : ' z';
|
159
|
+
let format = utils_1.default.convertFormatToDayjs(this.component.format);
|
159
160
|
const timezone = this.timezone;
|
160
161
|
if (value && !this.attached && timezone) {
|
162
|
+
format += format.match(/z$/) ? '' : ' z';
|
161
163
|
if (Array.isArray(value) && this.component.multiple) {
|
162
|
-
return value.map(item => lodash_1.default.trim(utils_1.default.
|
164
|
+
return value.map(item => lodash_1.default.trim(utils_1.default.dayjsDate(item, format, timezone, options).format(format))).join(', ');
|
163
165
|
}
|
164
|
-
return lodash_1.default.trim(utils_1.default.
|
166
|
+
return lodash_1.default.trim(utils_1.default.dayjsDate(value, format, timezone, options).format(format));
|
165
167
|
}
|
166
168
|
if (Array.isArray(value) && this.component.multiple) {
|
167
|
-
return value.map(item => lodash_1.default.trim((0,
|
169
|
+
return value.map(item => lodash_1.default.trim((0, dayjs_1.default)(item).format(format))).join(', ');
|
168
170
|
}
|
169
|
-
return (value ? lodash_1.default.trim((0,
|
171
|
+
return (value ? lodash_1.default.trim((0, dayjs_1.default)(value).format(format)) : value) || '';
|
170
172
|
}
|
171
173
|
}
|
172
174
|
exports.default = DateTimeComponent;
|
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const lodash_1 = __importDefault(require("lodash"));
|
7
7
|
const moment_1 = __importDefault(require("moment"));
|
8
8
|
const Field_1 = __importDefault(require("../_classes/field/Field"));
|
9
|
-
const utils_1 = require("../../utils
|
9
|
+
const utils_1 = require("../../utils");
|
10
10
|
const core_1 = require("@formio/core");
|
11
11
|
class DayComponent extends Field_1.default {
|
12
12
|
static schema(...extend) {
|
@@ -53,7 +53,7 @@ class DayComponent extends Field_1.default {
|
|
53
53
|
return (0, utils_1.getComponentSavedTypes)(schema) || [utils_1.componentValueTypes.string];
|
54
54
|
}
|
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 = (0, moment_1.default)(component.maxDate, 'YYYY-MM-DD').toISOString();
|
59
59
|
}
|
@@ -9,7 +9,7 @@ const components_1 = require("@formio/bootstrap/components");
|
|
9
9
|
const NestedArrayComponent_1 = __importDefault(require("../_classes/nestedarray/NestedArrayComponent"));
|
10
10
|
const Component_1 = __importDefault(require("../_classes/component/Component"));
|
11
11
|
const Alert_1 = __importDefault(require("../alert/Alert"));
|
12
|
-
const utils_1 = require("../../utils
|
12
|
+
const utils_1 = require("../../utils");
|
13
13
|
const EditRowState = {
|
14
14
|
New: 'new',
|
15
15
|
Editing: 'editing',
|
@@ -13,7 +13,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
13
13
|
};
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
15
15
|
const Field_1 = __importDefault(require("../_classes/field/Field"));
|
16
|
-
const utils_1 = require("../../utils
|
16
|
+
const utils_1 = require("../../utils");
|
17
17
|
const downloadjs_1 = __importDefault(require("downloadjs"));
|
18
18
|
const lodash_1 = __importDefault(require("lodash"));
|
19
19
|
const fileProcessor_1 = __importDefault(require("../../providers/processor/fileProcessor"));
|
@@ -8,7 +8,7 @@ const lodash_1 = __importDefault(require("lodash"));
|
|
8
8
|
const Component_1 = __importDefault(require("../_classes/component/Component"));
|
9
9
|
const ComponentModal_1 = __importDefault(require("../_classes/componentModal/ComponentModal"));
|
10
10
|
const eventemitter3_1 = __importDefault(require("eventemitter3"));
|
11
|
-
const utils_1 = require("../../utils
|
11
|
+
const utils_1 = require("../../utils");
|
12
12
|
const Formio_1 = require("../../Formio");
|
13
13
|
const Form_1 = __importDefault(require("../../Form"));
|
14
14
|
class FormComponent extends Component_1.default {
|
@@ -278,6 +278,9 @@ class FormComponent extends Component_1.default {
|
|
278
278
|
if (this.isSubFormLazyLoad() && !this.hasLoadedForm && !this.subFormLoading) {
|
279
279
|
this.createSubForm(true);
|
280
280
|
}
|
281
|
+
if (!this.subFormReady) {
|
282
|
+
return Promise.resolve();
|
283
|
+
}
|
281
284
|
return this.subFormReady.then(() => {
|
282
285
|
this.empty(element);
|
283
286
|
if (this.options.builder) {
|
@@ -408,13 +411,15 @@ class FormComponent extends Component_1.default {
|
|
408
411
|
}
|
409
412
|
// Render the form.
|
410
413
|
return (new Form_1.default(form, this.getSubOptions())).ready.then((instance) => {
|
414
|
+
var _a, _b;
|
411
415
|
this.subForm = instance;
|
412
416
|
this.subForm.currentForm = this;
|
413
417
|
this.subForm.parentVisible = this.visible;
|
414
418
|
const componentsMap = this.componentsMap;
|
415
419
|
const formComponentsMap = this.subForm.componentsMap;
|
416
420
|
lodash_1.default.assign(componentsMap, formComponentsMap);
|
417
|
-
this.component.components = this.subForm.
|
421
|
+
this.component.components = (_a = this.subForm._form) === null || _a === void 0 ? void 0 : _a.components;
|
422
|
+
this.component.display = (_b = this.subForm._form) === null || _b === void 0 ? void 0 : _b.display;
|
418
423
|
this.subForm.on('change', () => {
|
419
424
|
if (this.subForm && !this.shouldConditionallyClear()) {
|
420
425
|
this.dataValue = this.subForm.getValue();
|
@@ -699,6 +704,13 @@ class FormComponent extends Component_1.default {
|
|
699
704
|
}
|
700
705
|
return errors;
|
701
706
|
}
|
707
|
+
conditionallyHidden() {
|
708
|
+
const conditionallyHidden = super.conditionallyHidden();
|
709
|
+
if (this.subForm) {
|
710
|
+
this.subForm._conditionallyHidden = conditionallyHidden;
|
711
|
+
}
|
712
|
+
return conditionallyHidden;
|
713
|
+
}
|
702
714
|
updateSubFormVisibility() {
|
703
715
|
if (this.subForm) {
|
704
716
|
this.subForm.parentVisible = this.visible;
|
@@ -32,10 +32,11 @@ exports.default = [
|
|
32
32
|
tooltip: 'if it is checked, the subform is loaded after navigation to the page with this component within the wizard.',
|
33
33
|
input: true,
|
34
34
|
customConditional({ instance, data }) {
|
35
|
-
var _a, _b, _c
|
36
|
-
const
|
35
|
+
var _a, _b, _c;
|
36
|
+
const formComp = (_a = instance.root) === null || _a === void 0 ? void 0 : _a.getComponent('form');
|
37
|
+
const formInfo = formComp === null || formComp === void 0 ? void 0 : formComp.defaultDownloadedResources.find(res => res._id === data.form);
|
37
38
|
const displayMode = 'wizard';
|
38
|
-
return ((
|
39
|
+
return ((_c = (_b = instance.options) === null || _b === void 0 ? void 0 : _b.editForm) === null || _c === void 0 ? void 0 : _c.display) === displayMode && ((data.form && !formInfo) || (formInfo && formInfo.display !== displayMode));
|
39
40
|
},
|
40
41
|
},
|
41
42
|
{
|
@@ -7,7 +7,7 @@ const text_mask_addons_1 = require("@formio/text-mask-addons");
|
|
7
7
|
const vanilla_text_mask_1 = require("@formio/vanilla-text-mask");
|
8
8
|
const lodash_1 = __importDefault(require("lodash"));
|
9
9
|
const Input_1 = __importDefault(require("../_classes/input/Input"));
|
10
|
-
const utils_1 = require("../../utils/
|
10
|
+
const utils_1 = require("../../utils/");
|
11
11
|
class NumberComponent extends Input_1.default {
|
12
12
|
static schema(...extend) {
|
13
13
|
return Input_1.default.schema({
|
@@ -4,7 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
4
4
|
};
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
6
6
|
const NestedComponent_1 = __importDefault(require("../_classes/nested/NestedComponent"));
|
7
|
-
const utils_1 = require("../../utils
|
7
|
+
const utils_1 = require("../../utils");
|
8
8
|
class PanelComponent extends NestedComponent_1.default {
|
9
9
|
static schema(...extend) {
|
10
10
|
return NestedComponent_1.default.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';
|
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const lodash_1 = __importDefault(require("lodash"));
|
7
7
|
const ListComponent_1 = __importDefault(require("../_classes/list/ListComponent"));
|
8
8
|
const Formio_1 = require("../../Formio");
|
9
|
-
const utils_1 = require("../../utils
|
9
|
+
const utils_1 = require("../../utils");
|
10
10
|
class RadioComponent extends ListComponent_1.default {
|
11
11
|
static schema(...extend) {
|
12
12
|
return ListComponent_1.default.schema({
|
@@ -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);
|
@@ -7,7 +7,7 @@ const lodash_1 = __importDefault(require("lodash"));
|
|
7
7
|
const Formio_1 = require("../../Formio");
|
8
8
|
const ListComponent_1 = __importDefault(require("../_classes/list/ListComponent"));
|
9
9
|
const Form_1 = __importDefault(require("../../Form"));
|
10
|
-
const utils_1 = require("../../utils
|
10
|
+
const utils_1 = require("../../utils");
|
11
11
|
const ChoicesWrapper_1 = __importDefault(require("../../utils/ChoicesWrapper"));
|
12
12
|
class SelectComponent extends ListComponent_1.default {
|
13
13
|
static schema(...extend) {
|
@@ -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.
|
@@ -4,7 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
4
4
|
};
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
6
6
|
const lodash_1 = __importDefault(require("lodash"));
|
7
|
-
const utils_1 = require("../../../utils
|
7
|
+
const utils_1 = require("../../../utils");
|
8
8
|
const calculateSingleSelectData = (context, defaultValue) => {
|
9
9
|
const { instance, data } = context;
|
10
10
|
const rawDefaultValue = instance.downloadedResources.find(resource => lodash_1.default.get(resource, data.valueProperty) === defaultValue);
|
@@ -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
|
}
|
@@ -4,7 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
4
4
|
};
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
6
6
|
const lodash_1 = __importDefault(require("lodash"));
|
7
|
-
const utils_1 = require("../../utils
|
7
|
+
const utils_1 = require("../../utils");
|
8
8
|
const Radio_1 = __importDefault(require("../radio/Radio"));
|
9
9
|
class SelectBoxesComponent extends Radio_1.default {
|
10
10
|
static schema(...extend) {
|
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const signature_pad_1 = __importDefault(require("signature_pad"));
|
7
7
|
const Input_1 = __importDefault(require("../_classes/input/Input"));
|
8
8
|
const lodash_1 = __importDefault(require("lodash"));
|
9
|
-
const utils_1 = require("../../utils
|
9
|
+
const utils_1 = require("../../utils");
|
10
10
|
class SignatureComponent extends Input_1.default {
|
11
11
|
static schema(...extend) {
|
12
12
|
return Input_1.default.schema({
|
@@ -5,7 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
6
6
|
const lodash_1 = __importDefault(require("lodash"));
|
7
7
|
const Field_1 = __importDefault(require("../_classes/field/Field"));
|
8
|
-
const utils_1 = require("../../utils
|
8
|
+
const utils_1 = require("../../utils");
|
9
9
|
class SurveyComponent extends Field_1.default {
|
10
10
|
static schema(...extend) {
|
11
11
|
return Field_1.default.schema({
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
4
4
|
};
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
6
|
-
const utils_1 = require("../../utils
|
6
|
+
const utils_1 = require("../../utils");
|
7
7
|
const Input_1 = __importDefault(require("../_classes/input/Input"));
|
8
8
|
const choices_js_1 = __importDefault(require("choices.js"));
|
9
9
|
class TagsComponent extends Input_1.default {
|
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
/* global Quill */
|
7
7
|
const TextField_1 = __importDefault(require("../textfield/TextField"));
|
8
8
|
const lodash_1 = __importDefault(require("lodash"));
|
9
|
-
const utils_1 = require("../../utils
|
9
|
+
const utils_1 = require("../../utils");
|
10
10
|
class TextAreaComponent extends TextField_1.default {
|
11
11
|
static schema(...extend) {
|
12
12
|
return TextField_1.default.schema({
|
@@ -63,8 +63,8 @@ class TextAreaComponent extends TextField_1.default {
|
|
63
63
|
if ((this.options.readOnly || this.disabled) && !this.isHtmlRenderMode()) {
|
64
64
|
const elementStyle = this.info.attr.style || '';
|
65
65
|
const children = `
|
66
|
-
<div ${this._referenceAttributeName}="input"
|
67
|
-
class="formio-editor-read-only-content"
|
66
|
+
<div ${this._referenceAttributeName}="input"
|
67
|
+
class="formio-editor-read-only-content"
|
68
68
|
${elementStyle ? `style='${elementStyle}'` : ''}
|
69
69
|
role="textbox"
|
70
70
|
aria-multiline="true"
|
@@ -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);
|
@@ -1,27 +1,4 @@
|
|
1
1
|
"use strict";
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
3
|
-
if (k2 === undefined) k2 = k;
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
7
|
-
}
|
8
|
-
Object.defineProperty(o, k2, desc);
|
9
|
-
}) : (function(o, m, k, k2) {
|
10
|
-
if (k2 === undefined) k2 = k;
|
11
|
-
o[k2] = m[k];
|
12
|
-
}));
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
15
|
-
}) : function(o, v) {
|
16
|
-
o["default"] = v;
|
17
|
-
});
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
19
|
-
if (mod && mod.__esModule) return mod;
|
20
|
-
var result = {};
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
22
|
-
__setModuleDefault(result, mod);
|
23
|
-
return result;
|
24
|
-
};
|
25
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
26
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
27
4
|
};
|
@@ -29,7 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
6
|
const Input_1 = __importDefault(require("../_classes/input/Input"));
|
30
7
|
const vanilla_text_mask_1 = require("@formio/vanilla-text-mask");
|
31
8
|
const inputmask_1 = __importDefault(require("inputmask"));
|
32
|
-
const
|
9
|
+
const utils_1 = __importDefault(require("../../utils"));
|
33
10
|
const lodash_1 = __importDefault(require("lodash"));
|
34
11
|
class TextFieldComponent extends Input_1.default {
|
35
12
|
static schema(...extend) {
|
@@ -71,7 +48,7 @@ class TextFieldComponent extends Input_1.default {
|
|
71
48
|
} });
|
72
49
|
}
|
73
50
|
static savedValueTypes(schema) {
|
74
|
-
return
|
51
|
+
return utils_1.default.getComponentSavedTypes(schema) || [utils_1.default.componentValueTypes.string];
|
75
52
|
}
|
76
53
|
get defaultSchema() {
|
77
54
|
return TextFieldComponent.schema();
|
@@ -104,7 +81,7 @@ class TextFieldComponent extends Input_1.default {
|
|
104
81
|
displayInTimezone, locale: this.component.widget.locale || this.options.language, saveAs: 'text' });
|
105
82
|
// update originalComponent to include widget settings after component initialization
|
106
83
|
// originalComponent is used to restore the component (and widget) after evaluating field logic
|
107
|
-
this.originalComponent =
|
84
|
+
this.originalComponent = utils_1.default.fastCloneDeep(this.component);
|
108
85
|
}
|
109
86
|
}
|
110
87
|
attach(element) {
|
@@ -130,7 +107,12 @@ class TextFieldComponent extends Input_1.default {
|
|
130
107
|
// If no value is provided, then set the defaultValue.
|
131
108
|
if (!value.value) {
|
132
109
|
const defaultValue = flags.noDefault ? this.emptyValue : this.defaultValue;
|
133
|
-
|
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
|
+
}
|
134
116
|
}
|
135
117
|
return value;
|
136
118
|
}
|
@@ -175,7 +157,7 @@ class TextFieldComponent extends Input_1.default {
|
|
175
157
|
}
|
176
158
|
else {
|
177
159
|
const placeholderChar = this.placeholderChar;
|
178
|
-
textInput.value = (0, vanilla_text_mask_1.conformToMask)(textValue,
|
160
|
+
textInput.value = (0, vanilla_text_mask_1.conformToMask)(textValue, utils_1.default.getInputMask(mask), { placeholderChar }).conformedValue;
|
179
161
|
}
|
180
162
|
}
|
181
163
|
else {
|
@@ -183,8 +165,8 @@ class TextFieldComponent extends Input_1.default {
|
|
183
165
|
}
|
184
166
|
}
|
185
167
|
unmaskValue(value, format = this.component.displayMask) {
|
186
|
-
const mask =
|
187
|
-
return
|
168
|
+
const mask = utils_1.default.getInputMask(format, this.placeholderChar);
|
169
|
+
return utils_1.default.unmaskValue(value, mask, this.placeholderChar);
|
188
170
|
}
|
189
171
|
/**
|
190
172
|
* Returns the value at this index.
|
@@ -245,7 +227,7 @@ class TextFieldComponent extends Input_1.default {
|
|
245
227
|
return;
|
246
228
|
}
|
247
229
|
inputMask = inputMask || this.component.displayMask || this.component.inputMask;
|
248
|
-
const mask =
|
230
|
+
const mask = utils_1.default.getInputMask(inputMask, this.placeholderChar);
|
249
231
|
this.defaultMask = mask;
|
250
232
|
if (input && inputMask) {
|
251
233
|
try {
|
@@ -5,7 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
6
6
|
const moment_1 = __importDefault(require("moment"));
|
7
7
|
const TextField_1 = __importDefault(require("../textfield/TextField"));
|
8
|
-
const utils_1 = require("../../utils
|
8
|
+
const utils_1 = require("../../utils");
|
9
9
|
const defaultDataFormat = 'HH:mm:ss';
|
10
10
|
class TimeComponent extends TextField_1.default {
|
11
11
|
static schema(...extend) {
|
package/lib/cjs/formio.form.js
CHANGED
@@ -22,14 +22,14 @@ const Form_1 = __importDefault(require("./Form"));
|
|
22
22
|
exports.Form = Form_1.default;
|
23
23
|
const utils_1 = __importDefault(require("./utils"));
|
24
24
|
exports.Utils = utils_1.default;
|
25
|
-
const Evaluator_1 = require("./utils/Evaluator");
|
26
25
|
const licenses_1 = __importDefault(require("./licenses"));
|
27
26
|
exports.Licenses = licenses_1.default;
|
28
27
|
const EventEmitter_1 = __importDefault(require("./EventEmitter"));
|
29
28
|
exports.EventEmitter = EventEmitter_1.default;
|
30
29
|
const Webform_1 = __importDefault(require("./Webform"));
|
31
30
|
exports.Webform = Webform_1.default;
|
32
|
-
const
|
31
|
+
const core_1 = require("@formio/core");
|
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)
|
35
35
|
.then((modules) => {
|
@@ -45,7 +45,7 @@ Formio_1.Formio.Form = Form_1.default;
|
|
45
45
|
Formio_1.Formio.Displays = Displays_1.default;
|
46
46
|
Formio_1.Formio.Providers = providers_1.default;
|
47
47
|
Formio_1.Formio.Widgets = widgets_1.default;
|
48
|
-
Formio_1.Formio.Evaluator =
|
48
|
+
Formio_1.Formio.Evaluator = utils_2.Evaluator;
|
49
49
|
Formio_1.Formio.AllComponents = components_1.default;
|
50
50
|
Formio_1.Formio.Licenses = licenses_1.default;
|
51
51
|
// This is strange, but is needed for "premium" components to import correctly.
|
@@ -100,10 +100,10 @@ function registerModule(mod, defaultFn = null, options = {}) {
|
|
100
100
|
Formio_1.Formio.Displays.addDisplays(mod.displays);
|
101
101
|
break;
|
102
102
|
case 'evaluator':
|
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
|