@formio/js 5.1.0-dev.5936.fa0f253 → 5.1.0-dev.5939.f5aa9d6
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 +114 -147
- 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 +121 -154
- 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 +41 -57
- 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 +10 -8
- package/lib/cjs/components/_classes/nestedarray/NestedArrayComponent.js +1 -1
- package/lib/cjs/components/_classes/nesteddata/NestedDataComponent.js +1 -1
- package/lib/cjs/components/address/Address.js +2 -2
- package/lib/cjs/components/alert/Alert.js +1 -1
- package/lib/cjs/components/button/Button.js +1 -1
- package/lib/cjs/components/checkbox/Checkbox.js +1 -1
- package/lib/cjs/components/container/Container.js +1 -1
- package/lib/cjs/components/currency/Currency.js +1 -1
- package/lib/cjs/components/datagrid/DataGrid.js +1 -1
- package/lib/cjs/components/datetime/DateTime.d.ts +1 -1
- package/lib/cjs/components/datetime/DateTime.js +15 -13
- package/lib/cjs/components/day/Day.js +2 -2
- package/lib/cjs/components/editgrid/EditGrid.d.ts +0 -1
- package/lib/cjs/components/editgrid/EditGrid.js +1 -9
- package/lib/cjs/components/editgrid/editForm/EditGrid.edit.display.js +1 -1
- package/lib/cjs/components/file/File.js +1 -1
- package/lib/cjs/components/form/Form.js +14 -2
- package/lib/cjs/components/form/editForm/Form.edit.form.js +4 -3
- package/lib/cjs/components/number/Number.js +1 -1
- package/lib/cjs/components/panel/Panel.js +1 -1
- package/lib/cjs/components/radio/Radio.d.ts +9 -4
- package/lib/cjs/components/radio/Radio.js +40 -76
- 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 +3 -3
- 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 +14 -7
- 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 +10 -8
- package/lib/mjs/components/_classes/nestedarray/NestedArrayComponent.js +1 -1
- package/lib/mjs/components/_classes/nesteddata/NestedDataComponent.js +1 -1
- package/lib/mjs/components/address/Address.js +2 -2
- package/lib/mjs/components/alert/Alert.js +1 -1
- package/lib/mjs/components/button/Button.js +1 -1
- package/lib/mjs/components/checkbox/Checkbox.js +1 -1
- package/lib/mjs/components/container/Container.js +1 -1
- package/lib/mjs/components/currency/Currency.js +1 -1
- package/lib/mjs/components/datagrid/DataGrid.js +1 -1
- package/lib/mjs/components/datetime/DateTime.d.ts +1 -1
- package/lib/mjs/components/datetime/DateTime.js +15 -13
- package/lib/mjs/components/day/Day.js +2 -2
- package/lib/mjs/components/editgrid/EditGrid.d.ts +0 -1
- package/lib/mjs/components/editgrid/EditGrid.js +1 -9
- package/lib/mjs/components/editgrid/editForm/EditGrid.edit.display.js +1 -1
- package/lib/mjs/components/file/File.js +1 -1
- package/lib/mjs/components/form/Form.js +13 -2
- package/lib/mjs/components/form/editForm/Form.edit.form.js +3 -2
- package/lib/mjs/components/number/Number.js +1 -1
- package/lib/mjs/components/panel/Panel.js +1 -1
- package/lib/mjs/components/radio/Radio.d.ts +9 -4
- package/lib/mjs/components/radio/Radio.js +40 -75
- 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 +3 -3
- 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
@@ -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
|
}
|
@@ -101,7 +101,6 @@ export default class EditGridComponent extends NestedArrayComponent {
|
|
101
101
|
changeState(changed: any, flags: any): void;
|
102
102
|
openWhenEmpty(): void;
|
103
103
|
restoreRowContext(editRow: any, flags?: {}): void;
|
104
|
-
emptyRows(): void;
|
105
104
|
hasChanged: (newValue: any, oldValue: any) => boolean;
|
106
105
|
}
|
107
106
|
import NestedArrayComponent from '../_classes/nestedarray/NestedArrayComponent';
|
@@ -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',
|
@@ -1200,14 +1200,6 @@ class EditGridComponent extends NestedArrayComponent_1.default {
|
|
1200
1200
|
this.setNestedValue(component, editRow.data, flags);
|
1201
1201
|
});
|
1202
1202
|
}
|
1203
|
-
emptyRows() {
|
1204
|
-
this.editRows.forEach((editRow, index) => this.destroyComponents(false, index));
|
1205
|
-
this.editRows = [];
|
1206
|
-
}
|
1207
|
-
resetValue() {
|
1208
|
-
super.resetValue();
|
1209
|
-
this.emptyRows();
|
1210
|
-
}
|
1211
1203
|
}
|
1212
1204
|
exports.default = EditGridComponent;
|
1213
1205
|
EditGridComponent.prototype.hasChanged = Component_1.default.prototype.hasChanged;
|
@@ -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({
|
@@ -16,6 +16,7 @@ export default class RadioComponent extends ListComponent {
|
|
16
16
|
static savedValueTypes(schema: any): any[];
|
17
17
|
constructor(component: any, options: any, data: any);
|
18
18
|
previousValue: any;
|
19
|
+
uncheckValue(flags?: {}): void;
|
19
20
|
get inputInfo(): any;
|
20
21
|
get emptyValue(): string;
|
21
22
|
get isRadio(): boolean;
|
@@ -27,8 +28,8 @@ export default class RadioComponent extends ListComponent {
|
|
27
28
|
itemsLoadedResolve: ((value: any) => void) | undefined;
|
28
29
|
optionsLoaded: boolean | undefined;
|
29
30
|
loadedOptions: any[] | undefined;
|
30
|
-
valuesMap: Map<any, any> | undefined;
|
31
31
|
beforeSubmit(): Promise<any>;
|
32
|
+
convertValues(values: any): any;
|
32
33
|
render(): string;
|
33
34
|
attach(element: any): Promise<void>;
|
34
35
|
detach(element: any): void;
|
@@ -36,14 +37,18 @@ export default class RadioComponent extends ListComponent {
|
|
36
37
|
validateValueAvailability(setting: any, value: any): boolean;
|
37
38
|
getValueAsString(value: any, options?: {}): any;
|
38
39
|
setValueAt(index: any, value: any): void;
|
39
|
-
prepareValue(item: any, options?: {}): any;
|
40
|
-
getValueByInput(input: any): any;
|
41
40
|
loadItems(url: any, search: any, headers: any, options: any, method: any, body: any): void;
|
42
41
|
loadItemsFromMetadata(): void;
|
43
42
|
setItems(items: any): void;
|
44
43
|
setSelectedClasses(): void;
|
45
|
-
setMetadata(value: any): void;
|
46
44
|
updateValue(value: any, flags: any): boolean;
|
47
45
|
currentValue: any;
|
46
|
+
/**
|
47
|
+
* Normalize values coming into updateValue. For example, depending on the configuration, string value `"true"` will be normalized to boolean `true`.
|
48
|
+
* @param {*} value - The value to normalize
|
49
|
+
* @returns {*} - Returns the normalized value
|
50
|
+
*/
|
51
|
+
convertByDataType(value: any): any;
|
52
|
+
normalizeValue(value: any): any;
|
48
53
|
}
|
49
54
|
import ListComponent from '../_classes/list/ListComponent';
|
@@ -6,8 +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
|
10
|
-
const uuid_1 = require("uuid");
|
9
|
+
const utils_1 = require("../../utils");
|
11
10
|
class RadioComponent extends ListComponent_1.default {
|
12
11
|
static schema(...extend) {
|
13
12
|
return ListComponent_1.default.schema({
|
@@ -80,13 +79,15 @@ class RadioComponent extends ListComponent_1.default {
|
|
80
79
|
}
|
81
80
|
return defaultValue;
|
82
81
|
}
|
83
|
-
|
82
|
+
uncheckValue(flags = {}) {
|
84
83
|
this.unset();
|
85
84
|
this.setValue(this.emptyValue, {
|
86
85
|
noUpdateEvent: true,
|
87
86
|
noValidate: true,
|
88
87
|
resetValue: true
|
89
88
|
});
|
89
|
+
this.triggerChange(flags);
|
90
|
+
this.setSelectedClasses();
|
90
91
|
}
|
91
92
|
get inputInfo() {
|
92
93
|
var _a;
|
@@ -143,7 +144,6 @@ class RadioComponent extends ListComponent_1.default {
|
|
143
144
|
});
|
144
145
|
this.optionsLoaded = !this.component.dataSrc || this.component.dataSrc === 'values';
|
145
146
|
this.loadedOptions = [];
|
146
|
-
this.valuesMap = new Map();
|
147
147
|
if (!this.visible) {
|
148
148
|
this.itemsLoadedResolve();
|
149
149
|
}
|
@@ -155,6 +155,12 @@ class RadioComponent extends ListComponent_1.default {
|
|
155
155
|
this.dataReady.then(() => res(true));
|
156
156
|
});
|
157
157
|
}
|
158
|
+
convertValues(values) {
|
159
|
+
if (this.options.renderMode === 'html' && this.type === 'radio') {
|
160
|
+
return values.map(x => (Object.assign(Object.assign({}, x), { value: this.convertByDataType(x.value) })));
|
161
|
+
}
|
162
|
+
return values;
|
163
|
+
}
|
158
164
|
render() {
|
159
165
|
if (!this.optionsLoaded) {
|
160
166
|
return super.render(this.renderTemplate('loader'));
|
@@ -162,7 +168,7 @@ class RadioComponent extends ListComponent_1.default {
|
|
162
168
|
return super.render(this.renderTemplate('radio', {
|
163
169
|
input: this.inputInfo,
|
164
170
|
inline: this.component.inline,
|
165
|
-
values: this.component.dataSrc === 'values' ? this.component.values : this.loadedOptions,
|
171
|
+
values: this.component.dataSrc === 'values' ? this.convertValues(this.component.values) : this.loadedOptions,
|
166
172
|
value: this.dataValue,
|
167
173
|
row: this.row,
|
168
174
|
}));
|
@@ -183,12 +189,9 @@ class RadioComponent extends ListComponent_1.default {
|
|
183
189
|
if (!lodash_1.default.isString(this.dataValue)) {
|
184
190
|
dataValue = lodash_1.default.toString(this.dataValue);
|
185
191
|
}
|
186
|
-
if (this.isSelectURL) {
|
187
|
-
const
|
188
|
-
|
189
|
-
? this.valuesMap.get(valueKey)
|
190
|
-
: valueKey;
|
191
|
-
input.checked = lodash_1.default.isEqual(this.normalizeValue(optionValue), this.dataValue);
|
192
|
+
if (this.isSelectURL && lodash_1.default.isObject(this.loadedOptions[index].value)) {
|
193
|
+
const optionValue = this.component.dataType === 'string' ? JSON.stringify(this.loadedOptions[index].value) : this.loadedOptions[index].value;
|
194
|
+
input.checked = lodash_1.default.isEqual(optionValue, this.dataValue);
|
192
195
|
}
|
193
196
|
else {
|
194
197
|
input.checked = (dataValue === input.value && (input.value || this.component.dataSrc !== 'url'));
|
@@ -225,14 +228,9 @@ class RadioComponent extends ListComponent_1.default {
|
|
225
228
|
let value = this.component.inputType === 'checkbox' ? '' : this.dataValue;
|
226
229
|
this.refs.input.forEach((input, index) => {
|
227
230
|
if (input.checked) {
|
228
|
-
|
229
|
-
value
|
230
|
-
|
231
|
-
}
|
232
|
-
const optionValue = this.loadedOptions[index].value;
|
233
|
-
value = this.valuesMap.has(optionValue)
|
234
|
-
? this.valuesMap.get(optionValue)
|
235
|
-
: optionValue;
|
231
|
+
value = (this.isSelectURL && lodash_1.default.isObject(this.loadedOptions[index].value)) ?
|
232
|
+
this.loadedOptions[index].value :
|
233
|
+
input.value;
|
236
234
|
}
|
237
235
|
});
|
238
236
|
return value;
|
@@ -276,8 +274,8 @@ class RadioComponent extends ListComponent_1.default {
|
|
276
274
|
}
|
277
275
|
setValueAt(index, value) {
|
278
276
|
if (this.refs.input && this.refs.input[index] && value !== null && value !== undefined) {
|
279
|
-
const inputValue = this.
|
280
|
-
this.refs.input[index].checked =
|
277
|
+
const inputValue = this.refs.input[index].value;
|
278
|
+
this.refs.input[index].checked = (inputValue === value.toString());
|
281
279
|
}
|
282
280
|
}
|
283
281
|
get shouldLoad() {
|
@@ -287,23 +285,6 @@ class RadioComponent extends ListComponent_1.default {
|
|
287
285
|
}
|
288
286
|
return super.shouldLoad;
|
289
287
|
}
|
290
|
-
prepareValue(item, options = {}) {
|
291
|
-
const value = this.component.valueProperty && !options.skipValueProperty
|
292
|
-
? lodash_1.default.get(item, this.component.valueProperty)
|
293
|
-
: item;
|
294
|
-
if (this.component.type === 'radio' && typeof value !== 'string') {
|
295
|
-
const uuid = (0, uuid_1.v4)();
|
296
|
-
this.valuesMap.set(uuid, value);
|
297
|
-
return uuid;
|
298
|
-
}
|
299
|
-
return value;
|
300
|
-
}
|
301
|
-
getValueByInput(input) {
|
302
|
-
const inputValue = input.value;
|
303
|
-
return this.valuesMap.has(inputValue)
|
304
|
-
? this.valuesMap.get(inputValue)
|
305
|
-
: inputValue;
|
306
|
-
}
|
307
288
|
loadItems(url, search, headers, options, method, body) {
|
308
289
|
if (this.optionsLoaded) {
|
309
290
|
this.itemsLoadedResolve();
|
@@ -354,7 +335,7 @@ class RadioComponent extends ListComponent_1.default {
|
|
354
335
|
label: this.itemTemplate(item)
|
355
336
|
};
|
356
337
|
if (lodash_1.default.isEqual(item, this.selectData || lodash_1.default.pick(this.dataValue, lodash_1.default.keys(item)))) {
|
357
|
-
this.loadedOptions[i].value = this.
|
338
|
+
this.loadedOptions[i].value = this.dataValue;
|
358
339
|
}
|
359
340
|
});
|
360
341
|
this.optionsLoaded = true;
|
@@ -364,15 +345,12 @@ class RadioComponent extends ListComponent_1.default {
|
|
364
345
|
const listData = [];
|
365
346
|
items === null || items === void 0 ? void 0 : items.forEach((item, i) => {
|
366
347
|
const valueAtProperty = lodash_1.default.get(item, this.component.valueProperty);
|
367
|
-
|
368
|
-
|
369
|
-
? this.itemTemplate(item, valueAtProperty, i)
|
370
|
-
|
371
|
-
this.
|
372
|
-
|
373
|
-
if (this.valuesMap.has(value)) {
|
374
|
-
this.templateData[value] = this.templateData[i];
|
375
|
-
}
|
348
|
+
this.loadedOptions[i] = {
|
349
|
+
value: this.component.valueProperty ? valueAtProperty : item,
|
350
|
+
label: this.component.valueProperty ? this.itemTemplate(item, valueAtProperty) : this.itemTemplate(item, item, i)
|
351
|
+
};
|
352
|
+
listData.push(this.templateData[this.component.valueProperty ? valueAtProperty : i]);
|
353
|
+
const value = this.loadedOptions[i].value;
|
376
354
|
if (!this.isRadio && (lodash_1.default.isObject(value) || lodash_1.default.isBoolean(value) || lodash_1.default.isUndefined(value))) {
|
377
355
|
this.loadedOptions[i].invalid = true;
|
378
356
|
}
|
@@ -395,11 +373,7 @@ class RadioComponent extends ListComponent_1.default {
|
|
395
373
|
const value = this.dataValue;
|
396
374
|
this.refs.wrapper.forEach((wrapper, index) => {
|
397
375
|
const input = this.refs.input[index];
|
398
|
-
const checked = (value === undefined || value === null)
|
399
|
-
? false
|
400
|
-
: (input.type === 'checkbox')
|
401
|
-
? value[input.value] || input.checked
|
402
|
-
: lodash_1.default.isEqual(this.normalizeValue(this.getValueByInput(input)), value);
|
376
|
+
const checked = (value === undefined || value === null) ? false : (input.type === 'checkbox') ? value[input.value] || input.checked : (input.value.toString() === value.toString());
|
403
377
|
if (checked) {
|
404
378
|
//add class to container when selected
|
405
379
|
this.addClass(wrapper, this.optionSelectedClass);
|
@@ -413,26 +387,10 @@ class RadioComponent extends ListComponent_1.default {
|
|
413
387
|
});
|
414
388
|
}
|
415
389
|
}
|
416
|
-
setMetadata(value) {
|
417
|
-
var _a;
|
418
|
-
let key = value;
|
419
|
-
if (typeof value !== 'string') {
|
420
|
-
const checkedInput = Array.prototype.find.call((_a = this.refs.input) !== null && _a !== void 0 ? _a : [], (input => input.type === 'radio' && input.getAttribute('checked')));
|
421
|
-
key = (checkedInput === null || checkedInput === void 0 ? void 0 : checkedInput.value) || key;
|
422
|
-
}
|
423
|
-
if (this.isSelectURL && this.templateData && this.templateData[key]) {
|
424
|
-
const submission = this.root.submission;
|
425
|
-
if (!submission.metadata.selectData) {
|
426
|
-
submission.metadata.selectData = {};
|
427
|
-
}
|
428
|
-
lodash_1.default.set(submission.metadata.selectData, this.path, this.templateData[key]);
|
429
|
-
}
|
430
|
-
}
|
431
390
|
updateValue(value, flags) {
|
432
391
|
const changed = super.updateValue(value, flags);
|
433
392
|
if (changed) {
|
434
393
|
this.setSelectedClasses();
|
435
|
-
this.setMetadata(this.dataValue);
|
436
394
|
}
|
437
395
|
if (!flags || !flags.modified || !this.isRadio) {
|
438
396
|
if (changed) {
|
@@ -444,9 +402,7 @@ class RadioComponent extends ListComponent_1.default {
|
|
444
402
|
this.currentValue = this.dataValue;
|
445
403
|
const shouldResetValue = flags && flags.modified && !flags.noUpdateEvent && this.previousValue === this.currentValue;
|
446
404
|
if (shouldResetValue) {
|
447
|
-
this.
|
448
|
-
this.triggerChange(flags);
|
449
|
-
this.setSelectedClasses();
|
405
|
+
this.uncheckValue(flags);
|
450
406
|
}
|
451
407
|
this.previousValue = this.dataValue;
|
452
408
|
return changed;
|
@@ -456,7 +412,7 @@ class RadioComponent extends ListComponent_1.default {
|
|
456
412
|
* @param {*} value - The value to normalize
|
457
413
|
* @returns {*} - Returns the normalized value
|
458
414
|
*/
|
459
|
-
|
415
|
+
convertByDataType(value) {
|
460
416
|
const dataType = this.component.dataType || 'auto';
|
461
417
|
if (value === this.emptyValue) {
|
462
418
|
return value;
|
@@ -488,10 +444,18 @@ class RadioComponent extends ListComponent_1.default {
|
|
488
444
|
value = !(!value || value.toString() === 'false');
|
489
445
|
break;
|
490
446
|
}
|
491
|
-
return
|
447
|
+
return value;
|
492
448
|
}
|
493
|
-
|
494
|
-
|
449
|
+
normalizeValue(value) {
|
450
|
+
const valueConverted = this.convertByDataType(value);
|
451
|
+
if (this.isSelectURL && this.templateData && this.templateData[valueConverted]) {
|
452
|
+
const submission = this.root.submission;
|
453
|
+
if (!submission.metadata.selectData) {
|
454
|
+
submission.metadata.selectData = {};
|
455
|
+
}
|
456
|
+
lodash_1.default.set(submission.metadata.selectData, this.path, this.templateData[valueConverted]);
|
457
|
+
}
|
458
|
+
return super.normalizeValue(valueConverted);
|
495
459
|
}
|
496
460
|
}
|
497
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({
|