@formio/js 5.0.0-dev.5734.79d4f47 → 5.0.0-dev.5739.0b95c46
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 +9 -0
- 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/Form.d.ts +2 -2
- package/lib/cjs/Form.js +9 -3
- package/lib/cjs/Webform.js +0 -1
- package/lib/cjs/components/datamap/DataMap.js +1 -1
- 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/widgets/CalendarWidget.js +33 -26
- package/lib/mjs/Form.d.ts +2 -2
- package/lib/mjs/Form.js +9 -3
- package/lib/mjs/Webform.js +0 -1
- package/lib/mjs/components/datamap/DataMap.js +1 -1
- 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/widgets/CalendarWidget.js +33 -26
- package/package.json +1 -1
package/lib/cjs/Form.d.ts
CHANGED
|
@@ -398,10 +398,10 @@ export default class Form extends Element {
|
|
|
398
398
|
getFormInitOptions(url: string, form: import('@formio/core').Form): object;
|
|
399
399
|
/**
|
|
400
400
|
* Sets the form to the JSON schema of a form.
|
|
401
|
-
* @param {import('@formio/core').Form} formParam - The form JSON to set this form to.
|
|
401
|
+
* @param {import('@formio/core').Form | string} formParam - The form JSON to set this form to.
|
|
402
402
|
* @returns {Promise<Webform|Wizard|PDF>} - The webform instance that was created.
|
|
403
403
|
*/
|
|
404
|
-
setForm(formParam: import('@formio/core').Form): Promise<Webform | Wizard | PDF>;
|
|
404
|
+
setForm(formParam: import('@formio/core').Form | string): Promise<Webform | Wizard | PDF>;
|
|
405
405
|
_form: any;
|
|
406
406
|
getSubmission(formio: any, opts: any): any;
|
|
407
407
|
/**
|
package/lib/cjs/Form.js
CHANGED
|
@@ -195,7 +195,7 @@ class Form extends Element_1.default {
|
|
|
195
195
|
}
|
|
196
196
|
/**
|
|
197
197
|
* Sets the form to the JSON schema of a form.
|
|
198
|
-
* @param {import('@formio/core').Form} formParam - The form JSON to set this form to.
|
|
198
|
+
* @param {import('@formio/core').Form | string} formParam - The form JSON to set this form to.
|
|
199
199
|
* @returns {Promise<Webform|Wizard|PDF>} - The webform instance that was created.
|
|
200
200
|
*/
|
|
201
201
|
setForm(formParam) {
|
|
@@ -222,8 +222,14 @@ class Form extends Element_1.default {
|
|
|
222
222
|
}
|
|
223
223
|
this.loading = false;
|
|
224
224
|
this.instance = this.instance || this.create(form.display);
|
|
225
|
-
|
|
226
|
-
this.instance.setUrl
|
|
225
|
+
// If we're in builder mode, instance.setUrl is not a function, so just manually set the URL.
|
|
226
|
+
if (this.instance.setUrl) {
|
|
227
|
+
const options = this.getFormInitOptions(formParam, form);
|
|
228
|
+
this.instance.setUrl(formParam, options);
|
|
229
|
+
}
|
|
230
|
+
else {
|
|
231
|
+
this.instance.url = formParam;
|
|
232
|
+
}
|
|
227
233
|
this.instance.nosubmit = false;
|
|
228
234
|
this._form = this.instance.form = form;
|
|
229
235
|
if (submission) {
|
package/lib/cjs/Webform.js
CHANGED
|
@@ -241,7 +241,7 @@ class DataMapComponent extends DataGrid_1.default {
|
|
|
241
241
|
delete dataValue[key];
|
|
242
242
|
const comp = components[this.valueKey];
|
|
243
243
|
comp.component.key = newKey;
|
|
244
|
-
comp.path = Components_1.default.
|
|
244
|
+
comp.path = Components_1.default.getComponentPath(comp);
|
|
245
245
|
key = newKey;
|
|
246
246
|
});
|
|
247
247
|
const valueComponent = lodash_1.default.clone(this.component.valueComponent);
|
|
@@ -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,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = {
|
|
4
|
+
components: [
|
|
5
|
+
{
|
|
6
|
+
"label": "Date / Time",
|
|
7
|
+
"tableView": false,
|
|
8
|
+
"datePicker": {
|
|
9
|
+
"disableWeekends": false,
|
|
10
|
+
"disableWeekdays": false
|
|
11
|
+
},
|
|
12
|
+
"enableMinDateInput": false,
|
|
13
|
+
"enableMaxDateInput": false,
|
|
14
|
+
"validateWhenHidden": false,
|
|
15
|
+
"key": "dateTime",
|
|
16
|
+
"type": "datetime",
|
|
17
|
+
"input": true,
|
|
18
|
+
"widget": {
|
|
19
|
+
"type": "calendar",
|
|
20
|
+
"displayInTimezone": "viewer",
|
|
21
|
+
"locale": "en",
|
|
22
|
+
"useLocaleSettings": false,
|
|
23
|
+
"allowInput": true,
|
|
24
|
+
"mode": "single",
|
|
25
|
+
"enableTime": true,
|
|
26
|
+
"noCalendar": false,
|
|
27
|
+
"format": "yyyy-MM-dd hh:mm a",
|
|
28
|
+
"hourIncrement": 1,
|
|
29
|
+
"minuteIncrement": 1,
|
|
30
|
+
"time_24hr": false,
|
|
31
|
+
"minDate": null,
|
|
32
|
+
"disableWeekends": false,
|
|
33
|
+
"disableWeekdays": false,
|
|
34
|
+
"maxDate": null
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
]
|
|
38
|
+
};
|
|
@@ -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 };
|
|
@@ -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
|
-
exports.
|
|
6
|
+
exports.comp14 = exports.comp13 = exports.comp12 = exports.comp11 = exports.comp10 = exports.comp9 = exports.comp8 = exports.comp7 = exports.comp6 = exports.comp5 = exports.comp3 = exports.comp2 = exports.comp1 = void 0;
|
|
7
7
|
const comp1_1 = __importDefault(require("./comp1"));
|
|
8
8
|
exports.comp1 = comp1_1.default;
|
|
9
9
|
const comp2_1 = __importDefault(require("./comp2"));
|
|
@@ -28,3 +28,5 @@ const comp12_1 = __importDefault(require("./comp12"));
|
|
|
28
28
|
exports.comp12 = comp12_1.default;
|
|
29
29
|
const comp13_1 = __importDefault(require("./comp13"));
|
|
30
30
|
exports.comp13 = comp13_1.default;
|
|
31
|
+
const comp14_1 = __importDefault(require("./comp14"));
|
|
32
|
+
exports.comp14 = comp14_1.default;
|
|
@@ -101,16 +101,10 @@ class CalendarWidget extends InputWidget_1.default {
|
|
|
101
101
|
this.settings.altFormat = (0, utils_1.convertFormatToFlatpickr)(this.settings.format);
|
|
102
102
|
this.settings.dateFormat = (0, utils_1.convertFormatToFlatpickr)(this.settings.dateFormat);
|
|
103
103
|
this.settings.position = 'auto center';
|
|
104
|
+
// This is called when a date is picked in Flatpickrs calendar
|
|
104
105
|
this.settings.onChange = () => {
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
this.calendar._input.value = this.settings.manualInputValue;
|
|
108
|
-
}
|
|
109
|
-
else {
|
|
110
|
-
this.settings.manualInputValue = '';
|
|
111
|
-
}
|
|
112
|
-
this.settings.isManuallyOverriddenValue = false;
|
|
113
|
-
}
|
|
106
|
+
// Because a date was picked using flatpickrs calendar we can be sure that we don't have a manually overridden value
|
|
107
|
+
this.settings.isManuallyOverriddenValue = false;
|
|
114
108
|
this.emit('update');
|
|
115
109
|
};
|
|
116
110
|
this.settings.onOpen = () => this.hook('onCalendarOpen');
|
|
@@ -118,9 +112,13 @@ class CalendarWidget extends InputWidget_1.default {
|
|
|
118
112
|
this.hook('onCalendarClose');
|
|
119
113
|
this.closedOn = Date.now();
|
|
120
114
|
if (this.settings.allowInput && this.settings.enableTime) {
|
|
121
|
-
this
|
|
122
|
-
|
|
123
|
-
|
|
115
|
+
// We need to make sure that this block of code runs after Flatpickr sets the inputs value so that we can
|
|
116
|
+
// override the value Flatpickr sets with a manual value if we are in the state of manually overridden value
|
|
117
|
+
setTimeout(() => {
|
|
118
|
+
this.calendar._input.value = this.settings.isManuallyOverriddenValue ? this.settings.manualInputValue : this.calendar.altInput.value;
|
|
119
|
+
this._input.value = this.settings.isManuallyOverriddenValue ? this.settings.manualInputValue : this.calendar.altInput.value;
|
|
120
|
+
this.emit('update');
|
|
121
|
+
});
|
|
124
122
|
}
|
|
125
123
|
if (this.settings.wasDefaultValueChanged) {
|
|
126
124
|
this.calendar._input.value = this.settings.defaultValue;
|
|
@@ -272,7 +270,7 @@ class CalendarWidget extends InputWidget_1.default {
|
|
|
272
270
|
*/
|
|
273
271
|
getValue() {
|
|
274
272
|
// Standard output format.
|
|
275
|
-
if (!this.calendar) {
|
|
273
|
+
if (!this.calendar || this.settings.isManuallyOverriddenValue) {
|
|
276
274
|
return super.getValue();
|
|
277
275
|
}
|
|
278
276
|
// Get the selected dates from the calendar widget.
|
|
@@ -357,19 +355,24 @@ class CalendarWidget extends InputWidget_1.default {
|
|
|
357
355
|
// Create a new flatpickr.
|
|
358
356
|
this.calendar = new Flatpickr(this._input, Object.assign(Object.assign({}, this.settings), { disableMobile: true }));
|
|
359
357
|
this.addEventListener(this.calendar.altInput, 'input', (event) => {
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
this.settings.
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
358
|
+
// Need to give time for the input mask to update so that the manualInputValue can be properly set
|
|
359
|
+
setTimeout(() => {
|
|
360
|
+
if (this.settings.allowInput && this.settings.currentValue !== event.target.value) {
|
|
361
|
+
this.settings.manualInputValue = event.target.value;
|
|
362
|
+
this._input.value = this.settings.manualInputValue;
|
|
363
|
+
this.settings.isManuallyOverriddenValue = true;
|
|
364
|
+
this.settings.currentValue = event.target.value;
|
|
365
|
+
this.emit('update');
|
|
366
|
+
}
|
|
367
|
+
if (event.target.value === '' && this.calendar.selectedDates.length > 0) {
|
|
368
|
+
this.settings.wasDefaultValueChanged = true;
|
|
369
|
+
this.settings.defaultValue = event.target.value;
|
|
370
|
+
this.calendar.clear();
|
|
371
|
+
}
|
|
372
|
+
else {
|
|
373
|
+
this.settings.wasDefaultValueChanged = false;
|
|
374
|
+
}
|
|
375
|
+
});
|
|
373
376
|
});
|
|
374
377
|
const excludedFromMaskFormats = ['MMMM'];
|
|
375
378
|
if (!this.settings.readOnly && !lodash_1.default.some(excludedFromMaskFormats, format => lodash_1.default.includes(this.settings.format, format))) {
|
|
@@ -397,6 +400,10 @@ class CalendarWidget extends InputWidget_1.default {
|
|
|
397
400
|
// Make sure we commit the value after a blur event occurs.
|
|
398
401
|
this.addEventListener(this.calendar._input, 'blur', (event) => {
|
|
399
402
|
var _a, _b, _c, _d;
|
|
403
|
+
// If we have manually overridden the value then we shouldn't call setDate because this will fill the input mask
|
|
404
|
+
if (this.settings.isManuallyOverriddenValue) {
|
|
405
|
+
return;
|
|
406
|
+
}
|
|
400
407
|
const activeElement = this.settings.shadowRoot ? this.settings.shadowRoot.activeElement : document.activeElement;
|
|
401
408
|
const relatedTarget = event.relatedTarget ? event.relatedTarget : activeElement;
|
|
402
409
|
if (!(isIEBrowser && !relatedTarget) && !this.isCalendarElement(relatedTarget)) {
|
package/lib/mjs/Form.d.ts
CHANGED
|
@@ -398,10 +398,10 @@ export default class Form extends Element {
|
|
|
398
398
|
getFormInitOptions(url: string, form: import('@formio/core').Form): object;
|
|
399
399
|
/**
|
|
400
400
|
* Sets the form to the JSON schema of a form.
|
|
401
|
-
* @param {import('@formio/core').Form} formParam - The form JSON to set this form to.
|
|
401
|
+
* @param {import('@formio/core').Form | string} formParam - The form JSON to set this form to.
|
|
402
402
|
* @returns {Promise<Webform|Wizard|PDF>} - The webform instance that was created.
|
|
403
403
|
*/
|
|
404
|
-
setForm(formParam: import('@formio/core').Form): Promise<Webform | Wizard | PDF>;
|
|
404
|
+
setForm(formParam: import('@formio/core').Form | string): Promise<Webform | Wizard | PDF>;
|
|
405
405
|
_form: any;
|
|
406
406
|
getSubmission(formio: any, opts: any): any;
|
|
407
407
|
/**
|
package/lib/mjs/Form.js
CHANGED
|
@@ -264,7 +264,7 @@ export default class Form extends Element {
|
|
|
264
264
|
}
|
|
265
265
|
/**
|
|
266
266
|
* Sets the form to the JSON schema of a form.
|
|
267
|
-
* @param {import('@formio/core').Form} formParam - The form JSON to set this form to.
|
|
267
|
+
* @param {import('@formio/core').Form | string} formParam - The form JSON to set this form to.
|
|
268
268
|
* @returns {Promise<Webform|Wizard|PDF>} - The webform instance that was created.
|
|
269
269
|
*/
|
|
270
270
|
setForm(formParam) {
|
|
@@ -291,8 +291,14 @@ export default class Form extends Element {
|
|
|
291
291
|
}
|
|
292
292
|
this.loading = false;
|
|
293
293
|
this.instance = this.instance || this.create(form.display);
|
|
294
|
-
|
|
295
|
-
this.instance.setUrl
|
|
294
|
+
// If we're in builder mode, instance.setUrl is not a function, so just manually set the URL.
|
|
295
|
+
if (this.instance.setUrl) {
|
|
296
|
+
const options = this.getFormInitOptions(formParam, form);
|
|
297
|
+
this.instance.setUrl(formParam, options);
|
|
298
|
+
}
|
|
299
|
+
else {
|
|
300
|
+
this.instance.url = formParam;
|
|
301
|
+
}
|
|
296
302
|
this.instance.nosubmit = false;
|
|
297
303
|
this._form = this.instance.form = form;
|
|
298
304
|
if (submission) {
|
package/lib/mjs/Webform.js
CHANGED
|
@@ -236,7 +236,7 @@ export default class DataMapComponent extends DataGridComponent {
|
|
|
236
236
|
delete dataValue[key];
|
|
237
237
|
const comp = components[this.valueKey];
|
|
238
238
|
comp.component.key = newKey;
|
|
239
|
-
comp.path = Components.
|
|
239
|
+
comp.path = Components.getComponentPath(comp);
|
|
240
240
|
key = newKey;
|
|
241
241
|
});
|
|
242
242
|
const valueComponent = _.clone(this.component.valueComponent);
|
|
@@ -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 };
|
|
@@ -95,16 +95,10 @@ export default class CalendarWidget extends InputWidget {
|
|
|
95
95
|
this.settings.altFormat = convertFormatToFlatpickr(this.settings.format);
|
|
96
96
|
this.settings.dateFormat = convertFormatToFlatpickr(this.settings.dateFormat);
|
|
97
97
|
this.settings.position = 'auto center';
|
|
98
|
+
// This is called when a date is picked in Flatpickrs calendar
|
|
98
99
|
this.settings.onChange = () => {
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
this.calendar._input.value = this.settings.manualInputValue;
|
|
102
|
-
}
|
|
103
|
-
else {
|
|
104
|
-
this.settings.manualInputValue = '';
|
|
105
|
-
}
|
|
106
|
-
this.settings.isManuallyOverriddenValue = false;
|
|
107
|
-
}
|
|
100
|
+
// Because a date was picked using flatpickrs calendar we can be sure that we don't have a manually overridden value
|
|
101
|
+
this.settings.isManuallyOverriddenValue = false;
|
|
108
102
|
this.emit('update');
|
|
109
103
|
};
|
|
110
104
|
this.settings.onOpen = () => this.hook('onCalendarOpen');
|
|
@@ -112,9 +106,13 @@ 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
|
|
116
|
-
|
|
117
|
-
|
|
109
|
+
// We need to make sure that this block of code runs after Flatpickr sets the inputs value so that we can
|
|
110
|
+
// override the value Flatpickr sets with a manual value if we are in the state of manually overridden value
|
|
111
|
+
setTimeout(() => {
|
|
112
|
+
this.calendar._input.value = this.settings.isManuallyOverriddenValue ? this.settings.manualInputValue : this.calendar.altInput.value;
|
|
113
|
+
this._input.value = this.settings.isManuallyOverriddenValue ? this.settings.manualInputValue : this.calendar.altInput.value;
|
|
114
|
+
this.emit('update');
|
|
115
|
+
});
|
|
118
116
|
}
|
|
119
117
|
if (this.settings.wasDefaultValueChanged) {
|
|
120
118
|
this.calendar._input.value = this.settings.defaultValue;
|
|
@@ -264,7 +262,7 @@ export default class CalendarWidget extends InputWidget {
|
|
|
264
262
|
*/
|
|
265
263
|
getValue() {
|
|
266
264
|
// Standard output format.
|
|
267
|
-
if (!this.calendar) {
|
|
265
|
+
if (!this.calendar || this.settings.isManuallyOverriddenValue) {
|
|
268
266
|
return super.getValue();
|
|
269
267
|
}
|
|
270
268
|
// Get the selected dates from the calendar widget.
|
|
@@ -348,19 +346,24 @@ export default class CalendarWidget extends InputWidget {
|
|
|
348
346
|
// Create a new flatpickr.
|
|
349
347
|
this.calendar = new Flatpickr(this._input, { ...this.settings, disableMobile: true });
|
|
350
348
|
this.addEventListener(this.calendar.altInput, 'input', (event) => {
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
this.settings.
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
349
|
+
// Need to give time for the input mask to update so that the manualInputValue can be properly set
|
|
350
|
+
setTimeout(() => {
|
|
351
|
+
if (this.settings.allowInput && this.settings.currentValue !== event.target.value) {
|
|
352
|
+
this.settings.manualInputValue = event.target.value;
|
|
353
|
+
this._input.value = this.settings.manualInputValue;
|
|
354
|
+
this.settings.isManuallyOverriddenValue = true;
|
|
355
|
+
this.settings.currentValue = event.target.value;
|
|
356
|
+
this.emit('update');
|
|
357
|
+
}
|
|
358
|
+
if (event.target.value === '' && this.calendar.selectedDates.length > 0) {
|
|
359
|
+
this.settings.wasDefaultValueChanged = true;
|
|
360
|
+
this.settings.defaultValue = event.target.value;
|
|
361
|
+
this.calendar.clear();
|
|
362
|
+
}
|
|
363
|
+
else {
|
|
364
|
+
this.settings.wasDefaultValueChanged = false;
|
|
365
|
+
}
|
|
366
|
+
});
|
|
364
367
|
});
|
|
365
368
|
const excludedFromMaskFormats = ['MMMM'];
|
|
366
369
|
if (!this.settings.readOnly && !_.some(excludedFromMaskFormats, format => _.includes(this.settings.format, format))) {
|
|
@@ -387,6 +390,10 @@ export default class CalendarWidget extends InputWidget {
|
|
|
387
390
|
}
|
|
388
391
|
// Make sure we commit the value after a blur event occurs.
|
|
389
392
|
this.addEventListener(this.calendar._input, 'blur', (event) => {
|
|
393
|
+
// If we have manually overridden the value then we shouldn't call setDate because this will fill the input mask
|
|
394
|
+
if (this.settings.isManuallyOverriddenValue) {
|
|
395
|
+
return;
|
|
396
|
+
}
|
|
390
397
|
const activeElement = this.settings.shadowRoot ? this.settings.shadowRoot.activeElement : document.activeElement;
|
|
391
398
|
const relatedTarget = event.relatedTarget ? event.relatedTarget : activeElement;
|
|
392
399
|
if (!(isIEBrowser && !relatedTarget) && !this.isCalendarElement(relatedTarget)) {
|