@formio/js 5.0.0-dev.5838.99aa253 → 5.0.0-dev.5840.acb2be3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/formio.form.js +4 -4
- package/dist/formio.form.min.js +1 -1
- package/dist/formio.full.js +4 -4
- package/dist/formio.full.min.js +1 -1
- package/lib/cjs/components/Components.js +4 -2
- package/lib/cjs/components/_classes/component/Component.js +2 -1
- package/lib/cjs/components/address/Address.js +10 -0
- package/lib/cjs/components/day/Day.js +3 -9
- package/lib/mjs/components/Components.js +4 -2
- package/lib/mjs/components/_classes/component/Component.js +2 -1
- package/lib/mjs/components/address/Address.js +10 -0
- package/lib/mjs/components/day/Day.js +3 -9
- package/package.json +1 -1
|
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
const Component_1 = __importDefault(require("./_classes/component/Component"));
|
|
7
7
|
const utils_1 = __importDefault(require("./_classes/component/editForm/utils"));
|
|
8
8
|
const Component_form_1 = __importDefault(require("./_classes/component/Component.form"));
|
|
9
|
+
const utils_2 = require("../utils/utils");
|
|
9
10
|
const lodash_1 = __importDefault(require("lodash"));
|
|
10
11
|
class Components {
|
|
11
12
|
static set EditFormUtils(value) {
|
|
@@ -56,7 +57,8 @@ class Components {
|
|
|
56
57
|
static getComponentPath(component) {
|
|
57
58
|
var _a;
|
|
58
59
|
let path = '';
|
|
59
|
-
|
|
60
|
+
const componentKey = (0, utils_2.getComponentKey)(component.component);
|
|
61
|
+
if (componentKey) {
|
|
60
62
|
let thisPath = ((_a = component.options) === null || _a === void 0 ? void 0 : _a.parent) || component;
|
|
61
63
|
while (thisPath && !thisPath.allowData && thisPath.parent) {
|
|
62
64
|
thisPath = thisPath.parent;
|
|
@@ -68,7 +70,7 @@ class Components {
|
|
|
68
70
|
const rowIndex = component.row;
|
|
69
71
|
const rowIndexPath = rowIndex && !['container'].includes(thisPath.component.type) ? `[${Number.parseInt(rowIndex)}]` : '';
|
|
70
72
|
path = `${thisPath.path}${rowIndexPath}.`;
|
|
71
|
-
path +=
|
|
73
|
+
path += componentKey;
|
|
72
74
|
return lodash_1.default.trim(path, '.');
|
|
73
75
|
}
|
|
74
76
|
return path;
|
|
@@ -2965,7 +2965,7 @@ class Component extends Element_1.default {
|
|
|
2965
2965
|
if (this.options.alwaysDirty) {
|
|
2966
2966
|
flags.dirty = true;
|
|
2967
2967
|
}
|
|
2968
|
-
if (flags.fromSubmission && this.hasValue(data)) {
|
|
2968
|
+
if (flags.fromSubmission && this.hasValue(data) && !(this.pristine && this.protected)) {
|
|
2969
2969
|
flags.dirty = true;
|
|
2970
2970
|
}
|
|
2971
2971
|
this.setDirty(flags.dirty);
|
|
@@ -2992,6 +2992,7 @@ class Component extends Element_1.default {
|
|
|
2992
2992
|
value: this.validationValue,
|
|
2993
2993
|
path: this.path || this.component.key,
|
|
2994
2994
|
instance: this,
|
|
2995
|
+
form: this.root ? this.root._form : {},
|
|
2995
2996
|
scope: { errors: [] },
|
|
2996
2997
|
processors: [
|
|
2997
2998
|
process_1.validateProcessInfo
|
|
@@ -214,6 +214,16 @@ class AddressComponent extends Container_1.default {
|
|
|
214
214
|
isValueInLegacyFormat(value) {
|
|
215
215
|
return value && !value.mode;
|
|
216
216
|
}
|
|
217
|
+
set dataValue(value) {
|
|
218
|
+
super.dataValue = value;
|
|
219
|
+
}
|
|
220
|
+
get dataValue() {
|
|
221
|
+
const resultValue = lodash_1.default.get(this._data, this.component.path);
|
|
222
|
+
if (!lodash_1.default.isArray(resultValue) && this.component.multiple) {
|
|
223
|
+
return [resultValue];
|
|
224
|
+
}
|
|
225
|
+
return super.dataValue;
|
|
226
|
+
}
|
|
217
227
|
normalizeValue(value) {
|
|
218
228
|
return (this.manualModeEnabled && this.isValueInLegacyFormat(value))
|
|
219
229
|
? {
|
|
@@ -500,26 +500,20 @@ class DayComponent extends Field_1.default {
|
|
|
500
500
|
day = parseInt(this.refs.day.value, 10);
|
|
501
501
|
}
|
|
502
502
|
if (day === undefined || lodash_1.default.isNaN(day)) {
|
|
503
|
-
day =
|
|
504
|
-
this.getDayWithHiddenFields(defaults).day
|
|
505
|
-
: (defaults[DAY] && !lodash_1.default.isNaN(defaults[DAY]) ? defaults[DAY] : 0);
|
|
503
|
+
day = defaults[DAY] && !lodash_1.default.isNaN(defaults[DAY]) ? defaults[DAY] : 0;
|
|
506
504
|
}
|
|
507
505
|
if (this.showMonth && this.refs.month) {
|
|
508
506
|
// Months are 0 indexed.
|
|
509
507
|
month = parseInt(this.refs.month.value, 10);
|
|
510
508
|
}
|
|
511
509
|
if (month === undefined || lodash_1.default.isNaN(month)) {
|
|
512
|
-
month =
|
|
513
|
-
this.getDayWithHiddenFields(defaults).month
|
|
514
|
-
: (defaults[MONTH] && !lodash_1.default.isNaN(defaults[MONTH]) ? defaults[MONTH] : 0);
|
|
510
|
+
month = defaults[MONTH] && !lodash_1.default.isNaN(defaults[MONTH]) ? defaults[MONTH] : 0;
|
|
515
511
|
}
|
|
516
512
|
if (this.showYear && this.refs.year) {
|
|
517
513
|
year = parseInt(this.refs.year.value);
|
|
518
514
|
}
|
|
519
515
|
if (year === undefined || lodash_1.default.isNaN(year)) {
|
|
520
|
-
year =
|
|
521
|
-
this.getDayWithHiddenFields(defaults).year
|
|
522
|
-
: (defaults[YEAR] && !lodash_1.default.isNaN(defaults[YEAR]) ? defaults[YEAR] : 0);
|
|
516
|
+
year = defaults[YEAR] && !lodash_1.default.isNaN(defaults[YEAR]) ? defaults[YEAR] : 0;
|
|
523
517
|
}
|
|
524
518
|
let result;
|
|
525
519
|
if (!day && !month && !year) {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import Component from './_classes/component/Component';
|
|
2
2
|
import EditFormUtils from './_classes/component/editForm/utils';
|
|
3
3
|
import BaseEditForm from './_classes/component/Component.form';
|
|
4
|
+
import { getComponentKey } from '../utils/utils';
|
|
4
5
|
import _ from 'lodash';
|
|
5
6
|
export default class Components {
|
|
6
7
|
static _editFormUtils = EditFormUtils;
|
|
@@ -52,7 +53,8 @@ export default class Components {
|
|
|
52
53
|
*/
|
|
53
54
|
static getComponentPath(component) {
|
|
54
55
|
let path = '';
|
|
55
|
-
|
|
56
|
+
const componentKey = getComponentKey(component.component);
|
|
57
|
+
if (componentKey) {
|
|
56
58
|
let thisPath = component.options?.parent || component;
|
|
57
59
|
while (thisPath && !thisPath.allowData && thisPath.parent) {
|
|
58
60
|
thisPath = thisPath.parent;
|
|
@@ -64,7 +66,7 @@ export default class Components {
|
|
|
64
66
|
const rowIndex = component.row;
|
|
65
67
|
const rowIndexPath = rowIndex && !['container'].includes(thisPath.component.type) ? `[${Number.parseInt(rowIndex)}]` : '';
|
|
66
68
|
path = `${thisPath.path}${rowIndexPath}.`;
|
|
67
|
-
path +=
|
|
69
|
+
path += componentKey;
|
|
68
70
|
return _.trim(path, '.');
|
|
69
71
|
}
|
|
70
72
|
return path;
|
|
@@ -2929,7 +2929,7 @@ export default class Component extends Element {
|
|
|
2929
2929
|
if (this.options.alwaysDirty) {
|
|
2930
2930
|
flags.dirty = true;
|
|
2931
2931
|
}
|
|
2932
|
-
if (flags.fromSubmission && this.hasValue(data)) {
|
|
2932
|
+
if (flags.fromSubmission && this.hasValue(data) && !(this.pristine && this.protected)) {
|
|
2933
2933
|
flags.dirty = true;
|
|
2934
2934
|
}
|
|
2935
2935
|
this.setDirty(flags.dirty);
|
|
@@ -2956,6 +2956,7 @@ export default class Component extends Element {
|
|
|
2956
2956
|
value: this.validationValue,
|
|
2957
2957
|
path: this.path || this.component.key,
|
|
2958
2958
|
instance: this,
|
|
2959
|
+
form: this.root ? this.root._form : {},
|
|
2959
2960
|
scope: { errors: [] },
|
|
2960
2961
|
processors: [
|
|
2961
2962
|
validateProcessInfo
|
|
@@ -210,6 +210,16 @@ export default class AddressComponent extends ContainerComponent {
|
|
|
210
210
|
isValueInLegacyFormat(value) {
|
|
211
211
|
return value && !value.mode;
|
|
212
212
|
}
|
|
213
|
+
set dataValue(value) {
|
|
214
|
+
super.dataValue = value;
|
|
215
|
+
}
|
|
216
|
+
get dataValue() {
|
|
217
|
+
const resultValue = _.get(this._data, this.component.path);
|
|
218
|
+
if (!_.isArray(resultValue) && this.component.multiple) {
|
|
219
|
+
return [resultValue];
|
|
220
|
+
}
|
|
221
|
+
return super.dataValue;
|
|
222
|
+
}
|
|
213
223
|
normalizeValue(value) {
|
|
214
224
|
return (this.manualModeEnabled && this.isValueInLegacyFormat(value))
|
|
215
225
|
? {
|
|
@@ -498,26 +498,20 @@ export default class DayComponent extends Field {
|
|
|
498
498
|
day = parseInt(this.refs.day.value, 10);
|
|
499
499
|
}
|
|
500
500
|
if (day === undefined || _.isNaN(day)) {
|
|
501
|
-
day =
|
|
502
|
-
this.getDayWithHiddenFields(defaults).day
|
|
503
|
-
: (defaults[DAY] && !_.isNaN(defaults[DAY]) ? defaults[DAY] : 0);
|
|
501
|
+
day = defaults[DAY] && !_.isNaN(defaults[DAY]) ? defaults[DAY] : 0;
|
|
504
502
|
}
|
|
505
503
|
if (this.showMonth && this.refs.month) {
|
|
506
504
|
// Months are 0 indexed.
|
|
507
505
|
month = parseInt(this.refs.month.value, 10);
|
|
508
506
|
}
|
|
509
507
|
if (month === undefined || _.isNaN(month)) {
|
|
510
|
-
month =
|
|
511
|
-
this.getDayWithHiddenFields(defaults).month
|
|
512
|
-
: (defaults[MONTH] && !_.isNaN(defaults[MONTH]) ? defaults[MONTH] : 0);
|
|
508
|
+
month = defaults[MONTH] && !_.isNaN(defaults[MONTH]) ? defaults[MONTH] : 0;
|
|
513
509
|
}
|
|
514
510
|
if (this.showYear && this.refs.year) {
|
|
515
511
|
year = parseInt(this.refs.year.value);
|
|
516
512
|
}
|
|
517
513
|
if (year === undefined || _.isNaN(year)) {
|
|
518
|
-
year =
|
|
519
|
-
this.getDayWithHiddenFields(defaults).year
|
|
520
|
-
: (defaults[YEAR] && !_.isNaN(defaults[YEAR]) ? defaults[YEAR] : 0);
|
|
514
|
+
year = defaults[YEAR] && !_.isNaN(defaults[YEAR]) ? defaults[YEAR] : 0;
|
|
521
515
|
}
|
|
522
516
|
let result;
|
|
523
517
|
if (!day && !month && !year) {
|