@formio/js 5.0.0-dev.5796.ee2613b → 5.0.0-dev.5797.3f96a70
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/Changelog.md +3 -0
- package/dist/formio.form.js +565 -573
- package/dist/formio.form.min.js +1 -1
- package/dist/formio.form.min.js.LICENSE.txt +0 -10
- package/dist/formio.full.js +572 -580
- package/dist/formio.full.min.js +1 -1
- package/dist/formio.full.min.js.LICENSE.txt +0 -10
- package/dist/formio.js +1 -1
- package/dist/formio.min.js +1 -1
- package/dist/formio.utils.js +50 -48
- package/dist/formio.utils.min.js +1 -1
- package/dist/formio.utils.min.js.LICENSE.txt +4 -4
- package/lib/cjs/components/_classes/multivalue/Multivalue.d.ts +8 -0
- package/lib/cjs/components/_classes/multivalue/Multivalue.js +12 -10
- package/lib/cjs/components/datetime/fixtures/comp14.d.ts +35 -0
- package/lib/cjs/components/datetime/fixtures/comp14.js +38 -0
- package/lib/cjs/components/datetime/fixtures/index.d.ts +6 -5
- package/lib/cjs/components/datetime/fixtures/index.js +3 -1
- package/lib/cjs/components/day/Day.d.ts +5 -0
- package/lib/cjs/components/day/Day.js +51 -11
- package/lib/cjs/components/day/editForm/Day.edit.day.d.ts +17 -0
- package/lib/cjs/components/day/editForm/Day.edit.day.js +19 -0
- package/lib/cjs/components/day/editForm/Day.edit.month.d.ts +5 -0
- package/lib/cjs/components/day/editForm/Day.edit.month.js +19 -0
- package/lib/cjs/components/day/editForm/Day.edit.year.d.ts +5 -0
- package/lib/cjs/components/day/editForm/Day.edit.year.js +13 -0
- package/lib/cjs/components/html/HTML.js +1 -1
- package/lib/cjs/components/radio/Radio.js +1 -1
- package/lib/cjs/components/select/Select.js +0 -3
- package/lib/cjs/components/select/editForm/Select.edit.validation.js +1 -2
- package/lib/cjs/components/selectboxes/SelectBoxes.js +1 -1
- package/lib/cjs/widgets/CalendarWidget.js +24 -10
- package/lib/mjs/components/_classes/multivalue/Multivalue.d.ts +8 -0
- package/lib/mjs/components/_classes/multivalue/Multivalue.js +12 -10
- package/lib/mjs/components/datetime/fixtures/comp14.d.ts +35 -0
- package/lib/mjs/components/datetime/fixtures/comp14.js +36 -0
- package/lib/mjs/components/datetime/fixtures/index.d.ts +6 -5
- package/lib/mjs/components/datetime/fixtures/index.js +2 -1
- package/lib/mjs/components/day/Day.d.ts +5 -0
- package/lib/mjs/components/day/Day.js +51 -11
- package/lib/mjs/components/day/editForm/Day.edit.day.d.ts +17 -0
- package/lib/mjs/components/day/editForm/Day.edit.day.js +16 -0
- package/lib/mjs/components/day/editForm/Day.edit.month.d.ts +5 -0
- package/lib/mjs/components/day/editForm/Day.edit.month.js +16 -0
- package/lib/mjs/components/day/editForm/Day.edit.year.d.ts +5 -0
- package/lib/mjs/components/day/editForm/Day.edit.year.js +10 -0
- package/lib/mjs/components/html/HTML.js +1 -1
- package/lib/mjs/components/radio/Radio.js +1 -1
- package/lib/mjs/components/select/Select.js +0 -3
- package/lib/mjs/components/select/editForm/Select.edit.validation.js +1 -2
- package/lib/mjs/components/selectboxes/SelectBoxes.js +1 -1
- package/lib/mjs/widgets/CalendarWidget.js +24 -10
- package/package.json +2 -2
|
@@ -4,37 +4,39 @@ export default class Multivalue extends Field {
|
|
|
4
4
|
/**
|
|
5
5
|
* Normalize values coming into updateValue.
|
|
6
6
|
* @param {*} value - The value to normalize before setting.
|
|
7
|
+
* @param {Object} flags - Flags to use when normalizing the value.
|
|
8
|
+
* @param {*} emptyValue - The empty value for the field.
|
|
7
9
|
* @returns {*} - The normalized value.
|
|
8
10
|
*/
|
|
9
|
-
normalizeValue(value) {
|
|
11
|
+
normalizeValue(value, flags = {}, emptyValue = this.emptyValue) {
|
|
10
12
|
if (this.component.multiple) {
|
|
11
13
|
if (Array.isArray(value)) {
|
|
12
14
|
if (value.length === 0) {
|
|
13
|
-
return [
|
|
15
|
+
return [emptyValue];
|
|
14
16
|
}
|
|
15
17
|
if (this.component.storeas === 'array') {
|
|
16
|
-
return super.normalizeValue([value]);
|
|
18
|
+
return super.normalizeValue([value], flags);
|
|
17
19
|
}
|
|
18
|
-
return super.normalizeValue(value);
|
|
20
|
+
return super.normalizeValue(value, flags);
|
|
19
21
|
}
|
|
20
22
|
else {
|
|
21
|
-
return super.normalizeValue(value == null ? [
|
|
23
|
+
return super.normalizeValue(value == null ? [emptyValue] : [value], flags);
|
|
22
24
|
}
|
|
23
25
|
}
|
|
24
26
|
else {
|
|
25
|
-
if (Array.isArray(value) &&
|
|
27
|
+
if (Array.isArray(value) && !Array.isArray(emptyValue)) {
|
|
26
28
|
if (this.component.storeas === 'string') {
|
|
27
|
-
return super.normalizeValue(value.join(this.delimiter || ''));
|
|
29
|
+
return super.normalizeValue(value.join(this.delimiter || ''), flags);
|
|
28
30
|
}
|
|
29
|
-
return super.normalizeValue(value[0] ||
|
|
31
|
+
return super.normalizeValue(value[0] || emptyValue, flags);
|
|
30
32
|
}
|
|
31
33
|
else {
|
|
32
|
-
return super.normalizeValue(value);
|
|
34
|
+
return super.normalizeValue(value, flags);
|
|
33
35
|
}
|
|
34
36
|
}
|
|
35
37
|
}
|
|
36
38
|
get dataValue() {
|
|
37
|
-
return super.dataValue;
|
|
39
|
+
return this.normalizeValue(super.dataValue);
|
|
38
40
|
}
|
|
39
41
|
set dataValue(value) {
|
|
40
42
|
super.dataValue = value;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
declare namespace _default {
|
|
2
|
+
let components: {
|
|
3
|
+
label: string;
|
|
4
|
+
tableView: boolean;
|
|
5
|
+
datePicker: {
|
|
6
|
+
disableWeekends: boolean;
|
|
7
|
+
disableWeekdays: boolean;
|
|
8
|
+
};
|
|
9
|
+
enableMinDateInput: boolean;
|
|
10
|
+
enableMaxDateInput: boolean;
|
|
11
|
+
validateWhenHidden: boolean;
|
|
12
|
+
key: string;
|
|
13
|
+
type: string;
|
|
14
|
+
input: boolean;
|
|
15
|
+
widget: {
|
|
16
|
+
type: string;
|
|
17
|
+
displayInTimezone: string;
|
|
18
|
+
locale: string;
|
|
19
|
+
useLocaleSettings: boolean;
|
|
20
|
+
allowInput: boolean;
|
|
21
|
+
mode: string;
|
|
22
|
+
enableTime: boolean;
|
|
23
|
+
noCalendar: boolean;
|
|
24
|
+
format: string;
|
|
25
|
+
hourIncrement: number;
|
|
26
|
+
minuteIncrement: number;
|
|
27
|
+
time_24hr: boolean;
|
|
28
|
+
minDate: null;
|
|
29
|
+
disableWeekends: boolean;
|
|
30
|
+
disableWeekdays: boolean;
|
|
31
|
+
maxDate: null;
|
|
32
|
+
};
|
|
33
|
+
}[];
|
|
34
|
+
}
|
|
35
|
+
export default _default;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
export default {
|
|
2
|
+
components: [
|
|
3
|
+
{
|
|
4
|
+
"label": "Date / Time",
|
|
5
|
+
"tableView": false,
|
|
6
|
+
"datePicker": {
|
|
7
|
+
"disableWeekends": false,
|
|
8
|
+
"disableWeekdays": false
|
|
9
|
+
},
|
|
10
|
+
"enableMinDateInput": false,
|
|
11
|
+
"enableMaxDateInput": false,
|
|
12
|
+
"validateWhenHidden": false,
|
|
13
|
+
"key": "dateTime",
|
|
14
|
+
"type": "datetime",
|
|
15
|
+
"input": true,
|
|
16
|
+
"widget": {
|
|
17
|
+
"type": "calendar",
|
|
18
|
+
"displayInTimezone": "viewer",
|
|
19
|
+
"locale": "en",
|
|
20
|
+
"useLocaleSettings": false,
|
|
21
|
+
"allowInput": true,
|
|
22
|
+
"mode": "single",
|
|
23
|
+
"enableTime": true,
|
|
24
|
+
"noCalendar": false,
|
|
25
|
+
"format": "yyyy-MM-dd hh:mm a",
|
|
26
|
+
"hourIncrement": 1,
|
|
27
|
+
"minuteIncrement": 1,
|
|
28
|
+
"time_24hr": false,
|
|
29
|
+
"minDate": null,
|
|
30
|
+
"disableWeekends": false,
|
|
31
|
+
"disableWeekdays": false,
|
|
32
|
+
"maxDate": null
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
]
|
|
36
|
+
};
|
|
@@ -1,8 +1,4 @@
|
|
|
1
1
|
import comp1 from './comp1';
|
|
2
|
-
import comp10 from './comp10';
|
|
3
|
-
import comp11 from './comp11';
|
|
4
|
-
import comp12 from './comp12';
|
|
5
|
-
import comp13 from './comp13';
|
|
6
2
|
import comp2 from './comp2';
|
|
7
3
|
import comp3 from './comp3';
|
|
8
4
|
import comp5 from './comp5';
|
|
@@ -10,4 +6,9 @@ import comp6 from './comp6';
|
|
|
10
6
|
import comp7 from './comp7';
|
|
11
7
|
import comp8 from './comp8';
|
|
12
8
|
import comp9 from './comp9';
|
|
13
|
-
|
|
9
|
+
import comp10 from './comp10';
|
|
10
|
+
import comp11 from './comp11';
|
|
11
|
+
import comp12 from './comp12';
|
|
12
|
+
import comp13 from './comp13';
|
|
13
|
+
import comp14 from './comp14';
|
|
14
|
+
export { comp1, comp2, comp3, comp5, comp6, comp7, comp8, comp9, comp10, comp11, comp12, comp13, comp14 };
|
|
@@ -10,4 +10,5 @@ import comp10 from './comp10';
|
|
|
10
10
|
import comp11 from './comp11';
|
|
11
11
|
import comp12 from './comp12';
|
|
12
12
|
import comp13 from './comp13';
|
|
13
|
-
|
|
13
|
+
import comp14 from './comp14';
|
|
14
|
+
export { comp1, comp2, comp3, comp5, comp6, comp7, comp8, comp9, comp10, comp11, comp12, comp13, comp14 };
|
|
@@ -97,6 +97,11 @@ export default class DayComponent extends Field {
|
|
|
97
97
|
* @returns {null|void} - Returns null if the value is invalid, otherwise void.
|
|
98
98
|
*/
|
|
99
99
|
setValueAt(index: number, value: any): null | void;
|
|
100
|
+
getDayWithHiddenFields(parts: any): {
|
|
101
|
+
month: any;
|
|
102
|
+
day: any;
|
|
103
|
+
year: any;
|
|
104
|
+
};
|
|
100
105
|
getFieldValue(name: any): number;
|
|
101
106
|
get parts(): {
|
|
102
107
|
day: number;
|
|
@@ -342,6 +342,18 @@ export default class DayComponent extends Field {
|
|
|
342
342
|
const valueParts = value.split('/');
|
|
343
343
|
const [DAY, MONTH, YEAR] = this.component.dayFirst ? [0, 1, 2] : [1, 0, 2];
|
|
344
344
|
const defaultValue = this.component.defaultValue ? this.component.defaultValue.split('/') : '';
|
|
345
|
+
let defaultDay = '';
|
|
346
|
+
let defaultMonth = '';
|
|
347
|
+
let defaultYear = '';
|
|
348
|
+
if (defaultValue) {
|
|
349
|
+
const hasHiddenFields = defaultValue.length !== 3;
|
|
350
|
+
defaultDay = hasHiddenFields ? this.getDayWithHiddenFields(defaultValue).day : defaultValue[DAY];
|
|
351
|
+
defaultMonth = hasHiddenFields ? this.getDayWithHiddenFields(defaultValue).month : defaultValue[MONTH];
|
|
352
|
+
defaultYear = hasHiddenFields ? this.getDayWithHiddenFields(defaultValue).year : defaultValue[YEAR];
|
|
353
|
+
}
|
|
354
|
+
if (this.options.building && defaultValue.length === 3) {
|
|
355
|
+
return this.component.defaultValue;
|
|
356
|
+
}
|
|
345
357
|
const getNextPart = (shouldTake, defaultValue) => {
|
|
346
358
|
// Only push the part if it's not an empty string
|
|
347
359
|
const part = shouldTake ? valueParts.shift() : defaultValue;
|
|
@@ -350,13 +362,13 @@ export default class DayComponent extends Field {
|
|
|
350
362
|
}
|
|
351
363
|
};
|
|
352
364
|
if (this.dayFirst) {
|
|
353
|
-
getNextPart(this.showDay,
|
|
365
|
+
getNextPart(this.showDay, defaultDay);
|
|
354
366
|
}
|
|
355
|
-
getNextPart(this.showMonth,
|
|
367
|
+
getNextPart(this.showMonth, defaultMonth);
|
|
356
368
|
if (!this.dayFirst) {
|
|
357
|
-
getNextPart(this.showDay,
|
|
369
|
+
getNextPart(this.showDay, defaultDay);
|
|
358
370
|
}
|
|
359
|
-
getNextPart(this.showYear,
|
|
371
|
+
getNextPart(this.showYear, defaultYear);
|
|
360
372
|
return dateParts.join('/');
|
|
361
373
|
}
|
|
362
374
|
/**
|
|
@@ -371,16 +383,23 @@ export default class DayComponent extends Field {
|
|
|
371
383
|
if (value === 'Invalid date') {
|
|
372
384
|
return null;
|
|
373
385
|
}
|
|
386
|
+
let day, month, year;
|
|
374
387
|
const parts = value.split('/');
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
388
|
+
if (parts.length !== 3) {
|
|
389
|
+
day = this.getDayWithHiddenFields(parts).day;
|
|
390
|
+
month = this.getDayWithHiddenFields(parts).month;
|
|
391
|
+
year = this.getDayWithHiddenFields(parts).year;
|
|
378
392
|
}
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
393
|
+
else {
|
|
394
|
+
if (this.component.dayFirst) {
|
|
395
|
+
day = parts.shift();
|
|
396
|
+
}
|
|
397
|
+
month = parts.shift();
|
|
398
|
+
if (!this.component.dayFirst) {
|
|
399
|
+
day = parts.shift();
|
|
400
|
+
}
|
|
401
|
+
year = parts.shift();
|
|
382
402
|
}
|
|
383
|
-
const year = parts.shift();
|
|
384
403
|
if (this.refs.day && this.showDay) {
|
|
385
404
|
this.refs.day.value = day === '00' ? '' : parseInt(day, 10);
|
|
386
405
|
}
|
|
@@ -391,6 +410,27 @@ export default class DayComponent extends Field {
|
|
|
391
410
|
this.refs.year.value = year === '0000' ? '' : parseInt(year, 10);
|
|
392
411
|
}
|
|
393
412
|
}
|
|
413
|
+
getDayWithHiddenFields(parts) {
|
|
414
|
+
let [DAY, MONTH, YEAR] = this.component.dayFirst ? [0, 1, 2] : [1, 0, 2];
|
|
415
|
+
if (!this.showDay) {
|
|
416
|
+
MONTH = MONTH === 0 ? 0 : MONTH - 1;
|
|
417
|
+
YEAR = YEAR - 1;
|
|
418
|
+
DAY = null;
|
|
419
|
+
}
|
|
420
|
+
if (!this.showMonth) {
|
|
421
|
+
DAY = DAY === 0 ? 0 : DAY - 1;
|
|
422
|
+
YEAR = YEAR - 1;
|
|
423
|
+
MONTH = null;
|
|
424
|
+
}
|
|
425
|
+
if (!this.showYear) {
|
|
426
|
+
YEAR = null;
|
|
427
|
+
}
|
|
428
|
+
return {
|
|
429
|
+
month: _.isNull(MONTH) ? '' : parts[MONTH],
|
|
430
|
+
day: _.isNull(DAY) ? '' : parts[DAY],
|
|
431
|
+
year: _.isNull(YEAR) ? '' : parts[YEAR],
|
|
432
|
+
};
|
|
433
|
+
}
|
|
394
434
|
getFieldValue(name) {
|
|
395
435
|
const parts = this.dataValue ? this.dataValue.split('/') : [];
|
|
396
436
|
let val = 0;
|
|
@@ -14,6 +14,7 @@ declare const _default: ({
|
|
|
14
14
|
input?: undefined;
|
|
15
15
|
placeholder?: undefined;
|
|
16
16
|
tooltip?: undefined;
|
|
17
|
+
onChange?: undefined;
|
|
17
18
|
} | {
|
|
18
19
|
weight: number;
|
|
19
20
|
type: string;
|
|
@@ -25,16 +26,32 @@ declare const _default: ({
|
|
|
25
26
|
wieght?: undefined;
|
|
26
27
|
datasrc?: undefined;
|
|
27
28
|
data?: undefined;
|
|
29
|
+
onChange?: undefined;
|
|
28
30
|
} | {
|
|
29
31
|
weight: number;
|
|
30
32
|
type: string;
|
|
31
33
|
label: string;
|
|
32
34
|
tooltip: string;
|
|
33
35
|
key: string;
|
|
36
|
+
onChange: ({ data }: {
|
|
37
|
+
data: any;
|
|
38
|
+
}) => void;
|
|
34
39
|
input: boolean;
|
|
35
40
|
wieght?: undefined;
|
|
36
41
|
datasrc?: undefined;
|
|
37
42
|
data?: undefined;
|
|
38
43
|
placeholder?: undefined;
|
|
44
|
+
} | {
|
|
45
|
+
weight: number;
|
|
46
|
+
type: string;
|
|
47
|
+
label: string;
|
|
48
|
+
tooltip: string;
|
|
49
|
+
key: string;
|
|
50
|
+
input: boolean;
|
|
51
|
+
wieght?: undefined;
|
|
52
|
+
datasrc?: undefined;
|
|
53
|
+
data?: undefined;
|
|
54
|
+
placeholder?: undefined;
|
|
55
|
+
onChange?: undefined;
|
|
39
56
|
})[];
|
|
40
57
|
export default _default;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import _ from 'lodash';
|
|
1
2
|
export default [
|
|
2
3
|
{
|
|
3
4
|
wieght: 200,
|
|
@@ -33,6 +34,21 @@ export default [
|
|
|
33
34
|
label: 'Hidden',
|
|
34
35
|
tooltip: 'Hide the Day part of the component.',
|
|
35
36
|
key: 'fields.day.hide',
|
|
37
|
+
onChange: ({ data }) => {
|
|
38
|
+
if (data.defaultValue) {
|
|
39
|
+
const defaultValueParts = data.defaultValue.split('/');
|
|
40
|
+
if (!data.fields.day.hide && defaultValueParts.length !== 3) {
|
|
41
|
+
const newDefaultValue = ['00'];
|
|
42
|
+
if (!data.fields.month.hide) {
|
|
43
|
+
data.dayFirst ? newDefaultValue.push(defaultValueParts[0]) : newDefaultValue.unshift(defaultValueParts[0]);
|
|
44
|
+
}
|
|
45
|
+
if (!data.fields.year.hide) {
|
|
46
|
+
newDefaultValue.push(defaultValueParts[1]);
|
|
47
|
+
}
|
|
48
|
+
_.set(data, 'defaultValue', newDefaultValue.join('/'));
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
},
|
|
36
52
|
input: true
|
|
37
53
|
},
|
|
38
54
|
{
|
|
@@ -14,6 +14,7 @@ declare const _default: ({
|
|
|
14
14
|
input?: undefined;
|
|
15
15
|
placeholder?: undefined;
|
|
16
16
|
tooltip?: undefined;
|
|
17
|
+
onChange?: undefined;
|
|
17
18
|
} | {
|
|
18
19
|
weight: number;
|
|
19
20
|
type: string;
|
|
@@ -25,12 +26,16 @@ declare const _default: ({
|
|
|
25
26
|
wieght?: undefined;
|
|
26
27
|
datasrc?: undefined;
|
|
27
28
|
data?: undefined;
|
|
29
|
+
onChange?: undefined;
|
|
28
30
|
} | {
|
|
29
31
|
weight: number;
|
|
30
32
|
type: string;
|
|
31
33
|
label: string;
|
|
32
34
|
tooltip: string;
|
|
33
35
|
key: string;
|
|
36
|
+
onChange: ({ data }: {
|
|
37
|
+
data: any;
|
|
38
|
+
}) => void;
|
|
34
39
|
input: boolean;
|
|
35
40
|
wieght?: undefined;
|
|
36
41
|
datasrc?: undefined;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import _ from 'lodash';
|
|
1
2
|
export default [
|
|
2
3
|
{
|
|
3
4
|
wieght: 200,
|
|
@@ -33,6 +34,21 @@ export default [
|
|
|
33
34
|
label: 'Hidden',
|
|
34
35
|
tooltip: 'Hide the Month part of the component.',
|
|
35
36
|
key: 'fields.month.hide',
|
|
37
|
+
onChange: ({ data }) => {
|
|
38
|
+
if (data.defaultValue) {
|
|
39
|
+
const defaultValueParts = data.defaultValue.split('/');
|
|
40
|
+
if (!data.fields.month.hide && defaultValueParts.length !== 3) {
|
|
41
|
+
const newDefaultValue = ['00'];
|
|
42
|
+
if (!data.fields.day.hide) {
|
|
43
|
+
data.dayFirst ? newDefaultValue.unshift(defaultValueParts[0]) : newDefaultValue.push(defaultValueParts[0]);
|
|
44
|
+
}
|
|
45
|
+
if (!data.fields.year.hide) {
|
|
46
|
+
newDefaultValue.push(defaultValueParts[1]);
|
|
47
|
+
}
|
|
48
|
+
_.set(data, 'defaultValue', newDefaultValue.join('/'));
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
},
|
|
36
52
|
input: true
|
|
37
53
|
},
|
|
38
54
|
];
|
|
@@ -14,6 +14,7 @@ declare const _default: ({
|
|
|
14
14
|
input?: undefined;
|
|
15
15
|
placeholder?: undefined;
|
|
16
16
|
tooltip?: undefined;
|
|
17
|
+
onChange?: undefined;
|
|
17
18
|
} | {
|
|
18
19
|
weight: number;
|
|
19
20
|
type: string;
|
|
@@ -25,12 +26,16 @@ declare const _default: ({
|
|
|
25
26
|
wieght?: undefined;
|
|
26
27
|
datasrc?: undefined;
|
|
27
28
|
data?: undefined;
|
|
29
|
+
onChange?: undefined;
|
|
28
30
|
} | {
|
|
29
31
|
weight: number;
|
|
30
32
|
type: string;
|
|
31
33
|
label: string;
|
|
32
34
|
tooltip: string;
|
|
33
35
|
key: string;
|
|
36
|
+
onChange: ({ data }: {
|
|
37
|
+
data: any;
|
|
38
|
+
}) => void;
|
|
34
39
|
input: boolean;
|
|
35
40
|
wieght?: undefined;
|
|
36
41
|
datasrc?: undefined;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import _ from 'lodash';
|
|
1
2
|
export default [
|
|
2
3
|
{
|
|
3
4
|
wieght: 200,
|
|
@@ -51,6 +52,15 @@ export default [
|
|
|
51
52
|
label: 'Hidden',
|
|
52
53
|
tooltip: 'Hide the Year part of the component.',
|
|
53
54
|
key: 'fields.year.hide',
|
|
55
|
+
onChange: ({ data }) => {
|
|
56
|
+
if (data.defaultValue) {
|
|
57
|
+
const defaultValueParts = data.defaultValue.split('/');
|
|
58
|
+
if (!data.fields.month.hide && defaultValueParts.length !== 3) {
|
|
59
|
+
defaultValueParts.push('0000');
|
|
60
|
+
_.set(data, 'defaultValue', defaultValueParts.join('/'));
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
},
|
|
54
64
|
input: true
|
|
55
65
|
},
|
|
56
66
|
];
|
|
@@ -212,7 +212,7 @@ export default class RadioComponent extends ListComponent {
|
|
|
212
212
|
if (!boolValue(setting) || !value) {
|
|
213
213
|
return true;
|
|
214
214
|
}
|
|
215
|
-
const values = this.component.
|
|
215
|
+
const values = this.component.values;
|
|
216
216
|
if (values) {
|
|
217
217
|
return values.findIndex(({ value: optionValue }) => this.normalizeValue(optionValue) === value) !== -1;
|
|
218
218
|
}
|
|
@@ -1457,9 +1457,6 @@ export default class SelectComponent extends ListComponent {
|
|
|
1457
1457
|
case 'custom':
|
|
1458
1458
|
rawItems = this.getCustomItems();
|
|
1459
1459
|
break;
|
|
1460
|
-
case 'url':
|
|
1461
|
-
rawItems = this.selectItems;
|
|
1462
|
-
break;
|
|
1463
1460
|
}
|
|
1464
1461
|
if (typeof rawItems === 'string') {
|
|
1465
1462
|
try {
|
|
@@ -256,7 +256,7 @@ export default class SelectBoxesComponent extends RadioComponent {
|
|
|
256
256
|
if (!boolValue(setting) || !value) {
|
|
257
257
|
return true;
|
|
258
258
|
}
|
|
259
|
-
const values = this.component.
|
|
259
|
+
const values = this.component.values;
|
|
260
260
|
const availableValueKeys = (values || []).map(({ value: optionValue }) => optionValue);
|
|
261
261
|
const valueKeys = Object.keys(value);
|
|
262
262
|
return valueKeys.every((key) => availableValueKeys.includes(key));
|
|
@@ -96,14 +96,8 @@ export default class CalendarWidget extends InputWidget {
|
|
|
96
96
|
this.settings.dateFormat = convertFormatToFlatpickr(this.settings.dateFormat);
|
|
97
97
|
this.settings.position = 'auto center';
|
|
98
98
|
this.settings.onChange = () => {
|
|
99
|
-
if (this.settings.allowInput) {
|
|
100
|
-
|
|
101
|
-
this.calendar._input.value = this.settings.manualInputValue;
|
|
102
|
-
}
|
|
103
|
-
else {
|
|
104
|
-
this.settings.manualInputValue = '';
|
|
105
|
-
}
|
|
106
|
-
this.settings.isManuallyOverriddenValue = false;
|
|
99
|
+
if (this.settings.allowInput && this.settings.enableTime) {
|
|
100
|
+
this.calendar._input.value = this.settings.isManuallyOverriddenValue ? this.settings.manualInputValue : this.calendar.altInput.value;
|
|
107
101
|
}
|
|
108
102
|
this.emit('update');
|
|
109
103
|
};
|
|
@@ -112,8 +106,7 @@ export default class CalendarWidget extends InputWidget {
|
|
|
112
106
|
this.hook('onCalendarClose');
|
|
113
107
|
this.closedOn = Date.now();
|
|
114
108
|
if (this.settings.allowInput && this.settings.enableTime) {
|
|
115
|
-
this.calendar._input.value = this.settings.manualInputValue
|
|
116
|
-
this.settings.isManuallyOverriddenValue = false;
|
|
109
|
+
this.calendar._input.value = this.settings.isManuallyOverriddenValue ? this.settings.manualInputValue : this.calendar.altInput.value;
|
|
117
110
|
this.emit('update');
|
|
118
111
|
}
|
|
119
112
|
if (this.settings.wasDefaultValueChanged) {
|
|
@@ -349,9 +342,14 @@ export default class CalendarWidget extends InputWidget {
|
|
|
349
342
|
this.calendar = new Flatpickr(this._input, { ...this.settings, disableMobile: true });
|
|
350
343
|
this.addEventListener(this.calendar.altInput, 'input', (event) => {
|
|
351
344
|
if (this.settings.allowInput && this.settings.currentValue !== event.target.value) {
|
|
345
|
+
if (event.target.mask) {
|
|
346
|
+
event.target.mask.textMaskInputElement.update();
|
|
347
|
+
}
|
|
352
348
|
this.settings.manualInputValue = event.target.value;
|
|
349
|
+
this._input.value = this.settings.manualInputValue;
|
|
353
350
|
this.settings.isManuallyOverriddenValue = true;
|
|
354
351
|
this.settings.currentValue = event.target.value;
|
|
352
|
+
this.emit('update');
|
|
355
353
|
}
|
|
356
354
|
if (event.target.value === '' && this.calendar.selectedDates.length > 0) {
|
|
357
355
|
this.settings.wasDefaultValueChanged = true;
|
|
@@ -362,6 +360,18 @@ export default class CalendarWidget extends InputWidget {
|
|
|
362
360
|
this.settings.wasDefaultValueChanged = false;
|
|
363
361
|
}
|
|
364
362
|
});
|
|
363
|
+
if (this.calendar.daysContainer) {
|
|
364
|
+
this.calendar.daysContainer.addEventListener('click', () => {
|
|
365
|
+
this.settings.isManuallyOverriddenValue = false;
|
|
366
|
+
this.calendar.updateValue(false);
|
|
367
|
+
});
|
|
368
|
+
}
|
|
369
|
+
if (this.calendar.timeContainer) {
|
|
370
|
+
this.calendar.timeContainer.addEventListener('click', () => {
|
|
371
|
+
this.settings.isManuallyOverriddenValue = false;
|
|
372
|
+
this.calendar.updateValue(false);
|
|
373
|
+
});
|
|
374
|
+
}
|
|
365
375
|
const excludedFromMaskFormats = ['MMMM'];
|
|
366
376
|
if (!this.settings.readOnly && !_.some(excludedFromMaskFormats, format => _.includes(this.settings.format, format))) {
|
|
367
377
|
// Enforce the input mask of the format.
|
|
@@ -387,6 +397,10 @@ export default class CalendarWidget extends InputWidget {
|
|
|
387
397
|
}
|
|
388
398
|
// Make sure we commit the value after a blur event occurs.
|
|
389
399
|
this.addEventListener(this.calendar._input, 'blur', (event) => {
|
|
400
|
+
// If we have manually overridden the value then we shouldn't call setDate because this will fill the input mask
|
|
401
|
+
if (this.settings.isManuallyOverriddenValue) {
|
|
402
|
+
return;
|
|
403
|
+
}
|
|
390
404
|
const activeElement = this.settings.shadowRoot ? this.settings.shadowRoot.activeElement : document.activeElement;
|
|
391
405
|
const relatedTarget = event.relatedTarget ? event.relatedTarget : activeElement;
|
|
392
406
|
if (!(isIEBrowser && !relatedTarget) && !this.isCalendarElement(relatedTarget)) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@formio/js",
|
|
3
|
-
"version": "5.0.0-dev.
|
|
3
|
+
"version": "5.0.0-dev.5797.3f96a70",
|
|
4
4
|
"description": "JavaScript powered Forms with JSON Form Builder",
|
|
5
5
|
"main": "lib/cjs/index.js",
|
|
6
6
|
"exports": {
|
|
@@ -81,7 +81,7 @@
|
|
|
81
81
|
"dependencies": {
|
|
82
82
|
"@formio/bootstrap": "3.0.0-dev.98.17ba6ea",
|
|
83
83
|
"@formio/choices.js": "^10.2.1",
|
|
84
|
-
"@formio/core": "2.1.0-dev.
|
|
84
|
+
"@formio/core": "2.1.0-dev.145.4491833",
|
|
85
85
|
"@formio/text-mask-addons": "^3.8.0-formio.2",
|
|
86
86
|
"@formio/vanilla-text-mask": "^5.1.1-formio.1",
|
|
87
87
|
"abortcontroller-polyfill": "^1.7.5",
|