@formio/js 5.1.0-dev.5974.1be1688 → 5.1.0-dev.5976.f61da27
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.builder.css +19 -17
- package/dist/formio.builder.min.css +1 -1
- package/dist/formio.embed.js +1 -1
- package/dist/formio.embed.min.js +1 -1
- package/dist/formio.embed.min.js.LICENSE.txt +1 -1
- package/dist/formio.form.css +19 -17
- package/dist/formio.form.js +37 -37
- package/dist/formio.form.min.css +1 -1
- package/dist/formio.form.min.js +1 -1
- package/dist/formio.form.min.js.LICENSE.txt +3 -3
- package/dist/formio.full.css +19 -17
- package/dist/formio.full.js +43 -43
- package/dist/formio.full.min.css +2 -2
- package/dist/formio.full.min.js +1 -1
- package/dist/formio.full.min.js.LICENSE.txt +3 -3
- package/dist/formio.js +9 -9
- package/dist/formio.min.js +1 -1
- package/dist/formio.min.js.LICENSE.txt +1 -1
- package/dist/formio.utils.js +5 -5
- package/dist/formio.utils.min.js +1 -1
- package/dist/formio.utils.min.js.LICENSE.txt +1 -1
- package/lib/cjs/Embed.js +1 -1
- package/lib/cjs/Form.d.ts +2 -4
- package/lib/cjs/Form.js +3 -1
- package/lib/cjs/Formio.js +1 -1
- package/lib/cjs/PDFBuilder.js +2 -2
- package/lib/cjs/Webform.d.ts +5 -2
- package/lib/cjs/Webform.js +31 -16
- package/lib/cjs/WebformBuilder.d.ts +1 -0
- package/lib/cjs/WebformBuilder.js +14 -3
- package/lib/cjs/Wizard.js +2 -1
- package/lib/cjs/WizardBuilder.js +14 -1
- package/lib/cjs/components/Components.d.ts +3 -0
- package/lib/cjs/components/_classes/component/Component.js +12 -2
- package/lib/cjs/components/_classes/component/editForm/Component.edit.conditional.js +1 -1
- package/lib/cjs/components/_classes/component/editForm/Component.edit.data.d.ts +37 -0
- package/lib/cjs/components/_classes/component/editForm/Component.edit.data.js +13 -2
- package/lib/cjs/components/_classes/component/editForm/utils.d.ts +1 -0
- package/lib/cjs/components/_classes/component/editForm/utils.js +3 -0
- package/lib/cjs/components/_classes/nesteddata/NestedDataComponent.d.ts +1 -0
- package/lib/cjs/components/_classes/nesteddata/NestedDataComponent.js +3 -0
- package/lib/cjs/components/address/Address.js +1 -1
- package/lib/cjs/components/datetime/DateTime.d.ts +1 -1
- package/lib/cjs/components/datetime/DateTime.js +5 -5
- package/lib/cjs/components/day/Day.js +7 -5
- package/lib/cjs/components/file/File.js +2 -1
- package/lib/cjs/components/form/Form.d.ts +4 -2
- package/lib/cjs/components/form/Form.js +25 -10
- package/lib/cjs/components/form/editForm/Form.edit.data.js +1 -1
- package/lib/cjs/components/form/editForm/Form.edit.form.js +2 -2
- package/lib/cjs/components/select/Select.d.ts +0 -1
- package/lib/cjs/components/select/Select.js +3 -23
- package/lib/cjs/components/select/editForm/Select.edit.data.js +2 -2
- package/lib/cjs/components/tags/Tags.d.ts +1 -1
- package/lib/cjs/components/tags/Tags.js +2 -2
- package/lib/cjs/providers/storage/googleDrive.js +3 -2
- package/lib/cjs/providers/storage/s3.js +3 -3
- package/lib/cjs/providers/storage/xhr.d.ts +1 -0
- package/lib/cjs/providers/storage/xhr.js +6 -1
- package/lib/cjs/utils/ChoicesWrapper.d.ts +4 -25
- package/lib/cjs/utils/ChoicesWrapper.js +47 -124
- package/lib/cjs/utils/utils.d.ts +2 -1
- package/lib/cjs/utils/utils.js +3 -2
- package/lib/cjs/widgets/CalendarWidget.js +0 -14
- package/lib/mjs/Embed.js +1 -1
- package/lib/mjs/Form.d.ts +2 -4
- package/lib/mjs/Form.js +4 -2
- package/lib/mjs/Formio.js +1 -1
- package/lib/mjs/PDFBuilder.js +2 -2
- package/lib/mjs/Webform.d.ts +5 -2
- package/lib/mjs/Webform.js +31 -16
- package/lib/mjs/WebformBuilder.d.ts +1 -0
- package/lib/mjs/WebformBuilder.js +13 -2
- package/lib/mjs/Wizard.js +2 -1
- package/lib/mjs/WizardBuilder.js +14 -1
- package/lib/mjs/components/Components.d.ts +3 -0
- package/lib/mjs/components/_classes/component/Component.js +12 -2
- package/lib/mjs/components/_classes/component/editForm/Component.edit.conditional.js +1 -1
- package/lib/mjs/components/_classes/component/editForm/Component.edit.data.d.ts +37 -0
- package/lib/mjs/components/_classes/component/editForm/Component.edit.data.js +13 -2
- package/lib/mjs/components/_classes/component/editForm/utils.d.ts +1 -0
- package/lib/mjs/components/_classes/component/editForm/utils.js +3 -0
- package/lib/mjs/components/_classes/nesteddata/NestedDataComponent.d.ts +1 -0
- package/lib/mjs/components/_classes/nesteddata/NestedDataComponent.js +3 -0
- package/lib/mjs/components/address/Address.js +1 -1
- package/lib/mjs/components/datetime/DateTime.d.ts +1 -1
- package/lib/mjs/components/datetime/DateTime.js +5 -5
- package/lib/mjs/components/day/Day.js +7 -5
- package/lib/mjs/components/file/File.js +2 -1
- package/lib/mjs/components/form/Form.d.ts +4 -2
- package/lib/mjs/components/form/Form.js +25 -10
- package/lib/mjs/components/form/editForm/Form.edit.data.js +1 -1
- package/lib/mjs/components/form/editForm/Form.edit.form.js +2 -2
- package/lib/mjs/components/select/Select.d.ts +0 -1
- package/lib/mjs/components/select/Select.js +3 -22
- package/lib/mjs/components/select/editForm/Select.edit.data.js +2 -2
- package/lib/mjs/components/tags/Tags.d.ts +1 -1
- package/lib/mjs/components/tags/Tags.js +2 -2
- package/lib/mjs/providers/storage/googleDrive.js +3 -2
- package/lib/mjs/providers/storage/s3.js +3 -3
- package/lib/mjs/providers/storage/xhr.d.ts +1 -0
- package/lib/mjs/providers/storage/xhr.js +6 -1
- package/lib/mjs/utils/ChoicesWrapper.d.ts +4 -25
- package/lib/mjs/utils/ChoicesWrapper.js +26 -119
- package/lib/mjs/utils/utils.d.ts +2 -1
- package/lib/mjs/utils/utils.js +3 -2
- package/lib/mjs/widgets/CalendarWidget.js +0 -14
- package/package.json +3 -3
@@ -380,10 +380,11 @@ class FormComponent extends Component_1.default {
|
|
380
380
|
/**
|
381
381
|
* Create a subform instance.
|
382
382
|
* @param {boolean} [fromAttach] - This function is being called from an `attach` method.
|
383
|
+
* @param {boolean} [beforeSubmit] - This function is being called from a `beforeSubmit` method.
|
383
384
|
* @returns {*} - The subform instance.
|
384
385
|
*/
|
385
|
-
createSubForm(fromAttach) {
|
386
|
-
this.subFormReady = this.loadSubForm(fromAttach).then((form) => {
|
386
|
+
createSubForm(fromAttach, beforeSubmit) {
|
387
|
+
this.subFormReady = this.loadSubForm(fromAttach, beforeSubmit).then((form) => {
|
387
388
|
if (!form) {
|
388
389
|
return;
|
389
390
|
}
|
@@ -440,11 +441,13 @@ class FormComponent extends Component_1.default {
|
|
440
441
|
/**
|
441
442
|
* Load the subform.
|
442
443
|
* @param {boolean} fromAttach - This function is being called from an `attach` method.
|
444
|
+
* @param {boolean} beforeSubmit - This function is being called from a `beforeSubmit` method.
|
443
445
|
* @returns {Promise} - The promise that resolves when the subform is loaded.
|
444
446
|
*/
|
445
|
-
loadSubForm(fromAttach) {
|
447
|
+
loadSubForm(fromAttach, beforeSubmit) {
|
446
448
|
var _a, _b, _c, _d, _e;
|
447
|
-
|
449
|
+
const loadHiddenForm = beforeSubmit && !this.component.clearOnHide;
|
450
|
+
if (this.builderMode || (this.conditionallyHidden && !loadHiddenForm) || (this.isSubFormLazyLoad() && !fromAttach)) {
|
448
451
|
return Promise.resolve();
|
449
452
|
}
|
450
453
|
if (this.hasLoadedForm && !this.isRevisionChanged &&
|
@@ -516,7 +519,7 @@ class FormComponent extends Component_1.default {
|
|
516
519
|
* @returns {*|boolean} - TRUE if the subform should be submitted, FALSE if it should not.
|
517
520
|
*/
|
518
521
|
get shouldSubmit() {
|
519
|
-
return this.subFormReady && (!this.component.hasOwnProperty('reference') || this.component.reference) && !this.conditionallyHidden;
|
522
|
+
return this.subFormReady && (!this.component.hasOwnProperty('reference') || this.component.reference) && (!this.conditionallyHidden || !this.component.clearOnHide);
|
520
523
|
}
|
521
524
|
/**
|
522
525
|
* Returns the data for the subform.
|
@@ -587,11 +590,23 @@ class FormComponent extends Component_1.default {
|
|
587
590
|
this.dataValue = submission;
|
588
591
|
return Promise.resolve(this.dataValue);
|
589
592
|
}
|
590
|
-
|
591
|
-
|
592
|
-
|
593
|
-
|
594
|
-
|
593
|
+
// we need to load a hidden form (when clearOnHide is disabled) in order to get and submit (if needed) its data
|
594
|
+
const loadHiddenForm = !this.subForm && !this.component.clearOnHide;
|
595
|
+
if ((this.isSubFormLazyLoad() || loadHiddenForm) && !this.subFormLoading) {
|
596
|
+
return this.createSubForm(true, true)
|
597
|
+
.then(this.submitSubForm(false))
|
598
|
+
.then(() => {
|
599
|
+
return this.dataValue;
|
600
|
+
})
|
601
|
+
.then(() => super.beforeSubmit());
|
602
|
+
}
|
603
|
+
else {
|
604
|
+
return this.submitSubForm(false)
|
605
|
+
.then(() => {
|
606
|
+
return this.dataValue;
|
607
|
+
})
|
608
|
+
.then(() => super.beforeSubmit());
|
609
|
+
}
|
595
610
|
}
|
596
611
|
isSubFormLazyLoad() {
|
597
612
|
var _a, _b;
|
@@ -11,7 +11,7 @@ exports.default = [
|
|
11
11
|
{
|
12
12
|
weight: 140,
|
13
13
|
type: 'checkbox',
|
14
|
-
label: '
|
14
|
+
label: 'Omit Value From Submission Data When Conditionally Hidden',
|
15
15
|
key: 'clearOnHide',
|
16
16
|
defaultValue: true,
|
17
17
|
tooltip: 'When a field is hidden, clear the value.',
|
@@ -69,7 +69,7 @@ exports.default = [
|
|
69
69
|
input: true,
|
70
70
|
weight: 20,
|
71
71
|
key: 'reference',
|
72
|
-
label: '
|
73
|
-
tooltip: '
|
72
|
+
label: 'Submit as reference',
|
73
|
+
tooltip: 'When "Submit as reference" is enabled, the form submission will be recorded against the Parent Form as well as the Child Form. When a submission recorded with "Submit as reference" is edited, the update is applied to each submission made against the Parent Form and Child Form.'
|
74
74
|
}
|
75
75
|
];
|
@@ -126,7 +126,6 @@ export default class SelectComponent extends ListComponent {
|
|
126
126
|
get isLoadingAvailable(): any;
|
127
127
|
onScroll(): void;
|
128
128
|
attachRefreshOnBlur(): void;
|
129
|
-
addPlaceholderItem(placeholderValue: any): void;
|
130
129
|
update(): void;
|
131
130
|
addCurrentChoices(values: any, items: any, keyValue: any): any;
|
132
131
|
getValueAsString(data: any, options: any): any;
|
@@ -767,10 +767,10 @@ class SelectComponent extends ListComponent_1.default {
|
|
767
767
|
distance: 1000,
|
768
768
|
};
|
769
769
|
return Object.assign({ removeItemButton: this.component.disabled ? false : lodash_1.default.get(this.component, 'removeItemButton', true), itemSelectText: '', classNames: {
|
770
|
-
containerOuter: 'choices form-group formio-choices',
|
771
|
-
containerInner: this.transform('class', 'form-control ui fluid selection dropdown')
|
770
|
+
containerOuter: ['choices', 'form-group', 'formio-choices'],
|
771
|
+
containerInner: this.transform('class', 'form-control ui fluid selection dropdown').split(' '),
|
772
772
|
}, addItemText: false, allowHTML: true, placeholder: !!this.component.placeholder, placeholderValue: placeholderValue, noResultsText: this.t('noResultsFound'), noChoicesText: this.t('noChoices'), searchPlaceholderValue: this.t('typeToSearch'), shouldSort: false, position: (this.component.dropdown || 'auto'), searchEnabled: useSearch, searchChoices: !this.component.searchField, searchFields: lodash_1.default.get(this, 'component.searchFields', ['label']), shadowRoot: this.root ? this.root.shadowRoot : null, fuseOptions: this.component.useExactSearch
|
773
|
-
? Object.assign({ tokenize: true, matchAllTokens: true }, commonFuseOptions) : Object.assign({}, lodash_1.default.get(this, 'component.fuseOptions', {}), Object.assign({ include: 'score', threshold: lodash_1.default.get(this, 'component.selectThreshold', 0.3) }, commonFuseOptions)), valueComparer: lodash_1.default.isEqual, resetScrollPosition: false }, customOptions);
|
773
|
+
? Object.assign({ tokenize: true, matchAllTokens: true }, commonFuseOptions) : Object.assign({}, lodash_1.default.get(this, 'component.fuseOptions', {}), Object.assign({ include: 'score', threshold: lodash_1.default.get(this, 'component.selectThreshold', 0.3) }, commonFuseOptions)), valueComparer: lodash_1.default.isEqual, resetScrollPosition: false, duplicateItemsAllowed: false }, customOptions);
|
774
774
|
}
|
775
775
|
/* eslint-disable max-statements */
|
776
776
|
attach(element) {
|
@@ -902,12 +902,6 @@ class SelectComponent extends ListComponent_1.default {
|
|
902
902
|
this.positionDropdown();
|
903
903
|
});
|
904
904
|
}
|
905
|
-
if (this.choices && choicesOptions.placeholderValue && this.choices._isSelectOneElement) {
|
906
|
-
this.addPlaceholderItem(choicesOptions.placeholderValue);
|
907
|
-
this.addEventListener(input, 'removeItem', () => {
|
908
|
-
this.addPlaceholderItem(choicesOptions.placeholderValue);
|
909
|
-
});
|
910
|
-
}
|
911
905
|
// Add value options.
|
912
906
|
this.addValueOptions();
|
913
907
|
this.setChoicesValue(this.dataValue);
|
@@ -995,20 +989,6 @@ class SelectComponent extends ListComponent_1.default {
|
|
995
989
|
});
|
996
990
|
}
|
997
991
|
}
|
998
|
-
addPlaceholderItem(placeholderValue) {
|
999
|
-
const items = this.choices._store.activeItems;
|
1000
|
-
if (!items.length) {
|
1001
|
-
this.choices._addItem({
|
1002
|
-
value: '',
|
1003
|
-
label: placeholderValue,
|
1004
|
-
choiceId: 0,
|
1005
|
-
groupId: -1,
|
1006
|
-
customProperties: null,
|
1007
|
-
placeholder: true,
|
1008
|
-
keyCode: null
|
1009
|
-
});
|
1010
|
-
}
|
1011
|
-
}
|
1012
992
|
/* eslint-enable max-statements */
|
1013
993
|
update() {
|
1014
994
|
if (this.component.dataSrc === 'custom') {
|
@@ -641,8 +641,8 @@ exports.default = [
|
|
641
641
|
input: true,
|
642
642
|
weight: 25,
|
643
643
|
key: 'reference',
|
644
|
-
label: '
|
645
|
-
tooltip: 'Using this option will
|
644
|
+
label: 'Submit as reference',
|
645
|
+
tooltip: 'Using this option will submit this field as a reference id and link its value to the value of the origin record.',
|
646
646
|
conditional: {
|
647
647
|
json: { '===': [{ var: 'data.dataSrc' }, 'resource'] },
|
648
648
|
},
|
@@ -5,7 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
6
6
|
const utils_1 = require("../../utils/utils");
|
7
7
|
const Input_1 = __importDefault(require("../_classes/input/Input"));
|
8
|
-
const choices_js_1 = __importDefault(require("
|
8
|
+
const choices_js_1 = __importDefault(require("choices.js"));
|
9
9
|
class TagsComponent extends Input_1.default {
|
10
10
|
static schema(...extend) {
|
11
11
|
return Input_1.default.schema({
|
@@ -129,7 +129,7 @@ class TagsComponent extends Input_1.default {
|
|
129
129
|
const changed = super.setValue(value, flags);
|
130
130
|
if (this.choices) {
|
131
131
|
let dataValue = this.dataValue;
|
132
|
-
this.choices.
|
132
|
+
this.choices.clearStore();
|
133
133
|
if (dataValue) {
|
134
134
|
if (typeof dataValue === 'string') {
|
135
135
|
dataValue = dataValue.split(this.delimiter).filter(result => result);
|
@@ -52,10 +52,11 @@ function googledrive(formio) {
|
|
52
52
|
xhr.send(fd);
|
53
53
|
}));
|
54
54
|
},
|
55
|
-
downloadFile(file) {
|
55
|
+
downloadFile(file, component) {
|
56
56
|
const token = formio.getToken();
|
57
|
+
// Constructed the url with the fileId, fileName, displayImage, imageSize if applicable
|
57
58
|
file.url =
|
58
|
-
`${formio.formUrl}/storage/gdrive?fileId=${file.id}&fileName=${file.originalName}${token ? `&x-jwt-token=${token}` : ''}`;
|
59
|
+
`${formio.formUrl}/storage/gdrive?fileId=${file.id}&fileName=${file.originalName}${token ? `&x-jwt-token=${token}` : ''}${component.image ? '&displayImage=true' : ''}${component.imageSize ? `&imageSize=${component.imageSize}` : ''}`;
|
59
60
|
return Promise.resolve(file);
|
60
61
|
},
|
61
62
|
deleteFile: function deleteFile(fileInfo) {
|
@@ -115,7 +115,7 @@ function s3(formio) {
|
|
115
115
|
const { changeMessage } = multipart;
|
116
116
|
changeMessage('Completing AWS S3 multipart upload...');
|
117
117
|
const token = formio.getToken();
|
118
|
-
const response = yield fetch(`${formio.formUrl}/storage/s3/multipart/complete`, {
|
118
|
+
const response = yield xhr_1.default.fetch(`${formio.formUrl}/storage/s3/multipart/complete`, {
|
119
119
|
method: 'POST',
|
120
120
|
headers: Object.assign({ 'Content-Type': 'application/json' }, (token ? { 'x-jwt-token': token } : {})),
|
121
121
|
body: JSON.stringify({ parts, uploadId: serverResponse.uploadId, key: serverResponse.key })
|
@@ -134,7 +134,7 @@ function s3(formio) {
|
|
134
134
|
abortMultipartUpload(serverResponse) {
|
135
135
|
const { uploadId, key } = serverResponse;
|
136
136
|
const token = formio.getToken();
|
137
|
-
fetch(`${formio.formUrl}/storage/s3/multipart/abort`, {
|
137
|
+
xhr_1.default.fetch(`${formio.formUrl}/storage/s3/multipart/abort`, {
|
138
138
|
method: 'POST',
|
139
139
|
headers: Object.assign({ 'Content-Type': 'application/json' }, (token ? { 'x-jwt-token': token } : {})),
|
140
140
|
body: JSON.stringify({ uploadId, key })
|
@@ -148,7 +148,7 @@ function s3(formio) {
|
|
148
148
|
const start = i * partSize;
|
149
149
|
const end = (i + 1) * partSize;
|
150
150
|
const blob = i < urls.length ? file.slice(start, end) : file.slice(start);
|
151
|
-
const promise = fetch(urls[i], {
|
151
|
+
const promise = xhr_1.default.fetch(urls[i], {
|
152
152
|
method: 'PUT',
|
153
153
|
headers,
|
154
154
|
body: blob,
|
@@ -3,6 +3,7 @@ export default XHR;
|
|
3
3
|
declare namespace XHR {
|
4
4
|
function trim(text: any): any;
|
5
5
|
function path(items: any): any;
|
6
|
+
function fetch(url: any, options: any): Promise<Response>;
|
6
7
|
function upload(formio: any, type: any, xhrCallback: any, file: any, fileName: any, dir: any, progressCallback: any, groupPermissions: any, groupId: any, abortCallback: any, multipartOptions: any): Promise<any>;
|
7
8
|
function makeXhrRequest(formio: any, xhrCallback: any, serverResponse: any, progressCallback: any, abortCallback: any): Promise<any>;
|
8
9
|
}
|
@@ -14,6 +14,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
15
15
|
exports.setXhrHeaders = void 0;
|
16
16
|
const trim_1 = __importDefault(require("lodash/trim"));
|
17
|
+
const Formio_1 = require("../../Formio");
|
17
18
|
const setXhrHeaders = (formio, xhr) => {
|
18
19
|
const { headers } = formio.options;
|
19
20
|
if (headers) {
|
@@ -36,13 +37,17 @@ const XHR = {
|
|
36
37
|
path(items) {
|
37
38
|
return items.filter(item => !!item).map(XHR.trim).join('/');
|
38
39
|
},
|
40
|
+
fetch(url, options) {
|
41
|
+
options = Formio_1.Formio.pluginAlter('requestOptions', options, url);
|
42
|
+
return fetch(url, options);
|
43
|
+
},
|
39
44
|
upload(formio, type, xhrCallback, file, fileName, dir, progressCallback, groupPermissions, groupId, abortCallback, multipartOptions) {
|
40
45
|
return __awaiter(this, void 0, void 0, function* () {
|
41
46
|
// make request to Form.io server
|
42
47
|
const token = formio.getToken();
|
43
48
|
let response;
|
44
49
|
try {
|
45
|
-
response = yield fetch(`${formio.formUrl}/storage/${type}`, {
|
50
|
+
response = yield XHR.fetch(`${formio.formUrl}/storage/${type}`, {
|
46
51
|
method: 'POST',
|
47
52
|
headers: Object.assign({ 'Accept': 'application/json', 'Content-Type': 'application/json; charset=UTF-8' }, (token ? { 'x-jwt-token': token } : {})),
|
48
53
|
body: JSON.stringify({
|
@@ -1,38 +1,17 @@
|
|
1
|
-
export namespace KEY_CODES {
|
2
|
-
let BACK_KEY: number;
|
3
|
-
let DELETE_KEY: number;
|
4
|
-
let TAB_KEY: number;
|
5
|
-
let ENTER_KEY: number;
|
6
|
-
let A_KEY: number;
|
7
|
-
let ESC_KEY: number;
|
8
|
-
let UP_KEY: number;
|
9
|
-
let DOWN_KEY: number;
|
10
|
-
let PAGE_UP_KEY: number;
|
11
|
-
let PAGE_DOWN_KEY: number;
|
12
|
-
}
|
13
1
|
export default ChoicesWrapper;
|
14
2
|
declare class ChoicesWrapper extends Choices {
|
15
3
|
constructor(...args: any[]);
|
16
|
-
_onTabKey(
|
17
|
-
activeItems: any;
|
18
|
-
hasActiveDropdown: any;
|
19
|
-
}): void;
|
4
|
+
_onTabKey(): void;
|
20
5
|
isDirectionUsing: boolean;
|
21
6
|
shouldOpenDropDown: boolean;
|
22
7
|
_onTouchEnd(event: any): void;
|
23
|
-
|
24
|
-
_onEnterKey(args: any): void;
|
8
|
+
_onEnterKey(...args: any[]): void;
|
25
9
|
_onDirectionKey(...args: any[]): void;
|
26
10
|
timeout: NodeJS.Timeout | undefined;
|
27
11
|
_selectHighlightedChoice(): void;
|
28
12
|
_onKeyDown(event: any): void;
|
29
|
-
onSelectValue(
|
30
|
-
event: any;
|
31
|
-
activeItems: any;
|
32
|
-
hasActiveDropdown: any;
|
33
|
-
}): void;
|
13
|
+
onSelectValue(event: any, hasActiveDropdown: any): void;
|
34
14
|
showDropdown(...args: any[]): void;
|
35
15
|
hideDropdown(...args: any[]): void;
|
36
|
-
_onBlur(...args: any[]): void;
|
37
16
|
}
|
38
|
-
import Choices from '
|
17
|
+
import Choices from 'choices.js';
|
@@ -1,48 +1,30 @@
|
|
1
1
|
"use strict";
|
2
|
-
var
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
const choices_js_1 = __importDefault(require("@formio/choices.js"));
|
8
|
-
/**
|
9
|
-
* TODO: REMOVE THIS ONCE THE PULL REQUEST HAS BEEN RESOLVED.
|
10
|
-
*
|
11
|
-
* https://github.com/jshjohnson/Choices/pull/788
|
12
|
-
*
|
13
|
-
* This is intentionally not part of the extended class, since other components use Choices and need this fix as well.
|
14
|
-
* @type {Choices._generatePlaceholderValue}
|
15
|
-
* @private
|
16
|
-
*/
|
17
|
-
choices_js_1.default.prototype._generatePlaceholderValue = function () {
|
18
|
-
if (this._isSelectElement && this.passedElement.placeholderOption) {
|
19
|
-
const { placeholderOption } = this.passedElement;
|
20
|
-
return placeholderOption ? placeholderOption.text : false;
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
3
|
+
if (k2 === undefined) k2 = k;
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
21
7
|
}
|
22
|
-
|
23
|
-
|
24
|
-
if (
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
ENTER_KEY: 13,
|
39
|
-
A_KEY: 65,
|
40
|
-
ESC_KEY: 27,
|
41
|
-
UP_KEY: 38,
|
42
|
-
DOWN_KEY: 40,
|
43
|
-
PAGE_UP_KEY: 33,
|
44
|
-
PAGE_DOWN_KEY: 34,
|
8
|
+
Object.defineProperty(o, k2, desc);
|
9
|
+
}) : (function(o, m, k, k2) {
|
10
|
+
if (k2 === undefined) k2 = k;
|
11
|
+
o[k2] = m[k];
|
12
|
+
}));
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
15
|
+
}) : function(o, v) {
|
16
|
+
o["default"] = v;
|
17
|
+
});
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
19
|
+
if (mod && mod.__esModule) return mod;
|
20
|
+
var result = {};
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
22
|
+
__setModuleDefault(result, mod);
|
23
|
+
return result;
|
45
24
|
};
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
26
|
+
const choices_js_1 = __importStar(require("choices.js"));
|
27
|
+
const ExtendedKeyCodeMap = Object.assign(Object.assign({}, choices_js_1.KeyCodeMap), { TAB_KEY: 9 });
|
46
28
|
class ChoicesWrapper extends choices_js_1.default {
|
47
29
|
constructor(...args) {
|
48
30
|
super(...args);
|
@@ -69,24 +51,13 @@ class ChoicesWrapper extends choices_js_1.default {
|
|
69
51
|
}
|
70
52
|
this._wasTap = true;
|
71
53
|
}
|
72
|
-
|
73
|
-
|
74
|
-
return super._handleButtonAction(activeItems, element);
|
75
|
-
}
|
76
|
-
if (!activeItems ||
|
77
|
-
!element ||
|
78
|
-
!this.config.removeItems ||
|
79
|
-
!this.config.removeItemButton) {
|
80
|
-
return;
|
81
|
-
}
|
82
|
-
super._handleButtonAction(activeItems, element);
|
83
|
-
}
|
84
|
-
_onEnterKey(args) {
|
54
|
+
_onEnterKey(...args) {
|
55
|
+
const [event] = args;
|
85
56
|
// Prevent dropdown form opening when removeItemButton was pressed using 'Enter' on keyboard
|
86
|
-
if (
|
57
|
+
if (event.target.className === 'choices__button') {
|
87
58
|
this.shouldOpenDropDown = false;
|
88
59
|
}
|
89
|
-
super._onEnterKey(args);
|
60
|
+
super._onEnterKey(...args);
|
90
61
|
}
|
91
62
|
_onDirectionKey(...args) {
|
92
63
|
if (!this._isSelectOneElement) {
|
@@ -100,17 +71,18 @@ class ChoicesWrapper extends choices_js_1.default {
|
|
100
71
|
this.isDirectionUsing = false;
|
101
72
|
}, 250);
|
102
73
|
}
|
103
|
-
_onTabKey(
|
104
|
-
if (
|
105
|
-
this._selectHighlightedChoice(
|
74
|
+
_onTabKey() {
|
75
|
+
if (this.dropdown.isActive) {
|
76
|
+
this._selectHighlightedChoice();
|
106
77
|
}
|
107
78
|
}
|
108
79
|
_selectHighlightedChoice() {
|
109
|
-
const highlightedChoice = this.dropdown.
|
80
|
+
const highlightedChoice = this.dropdown.element.querySelector(`.${this.config.classNames.highlightedState}`);
|
110
81
|
if (highlightedChoice) {
|
111
82
|
const id = highlightedChoice.dataset.id;
|
112
|
-
const choice = id && this._store.getChoiceById(id);
|
83
|
+
const choice = id && this._store.getChoiceById(Number(id));
|
113
84
|
this._addItem({
|
85
|
+
id: choice.id,
|
114
86
|
value: choice.value,
|
115
87
|
label: choice.label,
|
116
88
|
choiceId: choice.id,
|
@@ -121,61 +93,16 @@ class ChoicesWrapper extends choices_js_1.default {
|
|
121
93
|
});
|
122
94
|
this._triggerChange(choice.value);
|
123
95
|
}
|
124
|
-
event.preventDefault();
|
125
96
|
}
|
126
97
|
_onKeyDown(event) {
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
if (target !== this.input.element &&
|
132
|
-
!this.containerOuter.element.contains(target)) {
|
133
|
-
return;
|
134
|
-
}
|
135
|
-
const activeItems = this._store.activeItems;
|
136
|
-
const hasFocusedInput = this.input.isFocussed;
|
137
|
-
const hasActiveDropdown = this.dropdown.isActive;
|
138
|
-
const hasItems = this.itemList.hasChildren;
|
139
|
-
const keyString = String.fromCharCode(keyCode);
|
140
|
-
const { BACK_KEY, DELETE_KEY, TAB_KEY, ENTER_KEY, A_KEY, ESC_KEY, UP_KEY, DOWN_KEY, PAGE_UP_KEY, PAGE_DOWN_KEY, } = exports.KEY_CODES;
|
141
|
-
const hasCtrlDownKeyPressed = ctrlKey || metaKey;
|
142
|
-
// If a user is typing and the dropdown is not active
|
143
|
-
if (!hasActiveDropdown && !this._isTextElement && /[a-zA-Z0-9-_ ]/.test(keyString)) {
|
144
|
-
const currentValue = this.input.element.value;
|
145
|
-
this.input.element.value = currentValue ? `${currentValue}${keyString}` : keyString;
|
146
|
-
this.showDropdown();
|
147
|
-
}
|
148
|
-
// Map keys to key actions
|
149
|
-
const keyDownActions = {
|
150
|
-
[A_KEY]: this._onAKey,
|
151
|
-
[TAB_KEY]: this._onTabKey,
|
152
|
-
[ENTER_KEY]: this._onEnterKey,
|
153
|
-
[ESC_KEY]: this._onEscapeKey,
|
154
|
-
[UP_KEY]: this._onDirectionKey,
|
155
|
-
[PAGE_UP_KEY]: this._onDirectionKey,
|
156
|
-
[DOWN_KEY]: this._onDirectionKey,
|
157
|
-
[PAGE_DOWN_KEY]: this._onDirectionKey,
|
158
|
-
[DELETE_KEY]: this._onDeleteKey,
|
159
|
-
[BACK_KEY]: this._onDeleteKey,
|
160
|
-
};
|
161
|
-
// If keycode has a function, run it
|
162
|
-
if (keyDownActions[keyCode]) {
|
163
|
-
keyDownActions[keyCode]({
|
164
|
-
event,
|
165
|
-
target,
|
166
|
-
keyCode,
|
167
|
-
metaKey,
|
168
|
-
activeItems,
|
169
|
-
hasFocusedInput,
|
170
|
-
hasActiveDropdown,
|
171
|
-
hasItems,
|
172
|
-
hasCtrlDownKeyPressed,
|
173
|
-
});
|
174
|
-
}
|
98
|
+
const keyCode = event.keyCode;
|
99
|
+
return this._isSelectOneElement && keyCode === ExtendedKeyCodeMap.TAB_KEY
|
100
|
+
? this._onTabKey()
|
101
|
+
: super._onKeyDown(event);
|
175
102
|
}
|
176
|
-
onSelectValue(
|
103
|
+
onSelectValue(event, hasActiveDropdown) {
|
177
104
|
if (hasActiveDropdown) {
|
178
|
-
this._selectHighlightedChoice(
|
105
|
+
this._selectHighlightedChoice();
|
179
106
|
}
|
180
107
|
else if (this._isSelectOneElement) {
|
181
108
|
this.showDropdown();
|
@@ -183,11 +110,13 @@ class ChoicesWrapper extends choices_js_1.default {
|
|
183
110
|
}
|
184
111
|
}
|
185
112
|
showDropdown(...args) {
|
186
|
-
|
187
|
-
this.shouldOpenDropDown
|
188
|
-
|
189
|
-
|
190
|
-
|
113
|
+
setTimeout(() => {
|
114
|
+
if (!this.shouldOpenDropDown) {
|
115
|
+
this.shouldOpenDropDown = true;
|
116
|
+
return;
|
117
|
+
}
|
118
|
+
super.showDropdown(...args);
|
119
|
+
}, 0);
|
191
120
|
}
|
192
121
|
hideDropdown(...args) {
|
193
122
|
if (this.isDirectionUsing) {
|
@@ -195,11 +124,5 @@ class ChoicesWrapper extends choices_js_1.default {
|
|
195
124
|
}
|
196
125
|
super.hideDropdown(...args);
|
197
126
|
}
|
198
|
-
_onBlur(...args) {
|
199
|
-
if (this._isScrollingOnIe) {
|
200
|
-
return;
|
201
|
-
}
|
202
|
-
super._onBlur(...args);
|
203
|
-
}
|
204
127
|
}
|
205
128
|
exports.default = ChoicesWrapper;
|
package/lib/cjs/utils/utils.d.ts
CHANGED
@@ -208,9 +208,10 @@ export function loadZones(url: string, timezone: string): Promise<any> | any;
|
|
208
208
|
* @param {string|Date} value - The value to convert into a moment date.
|
209
209
|
* @param {string} format - The format to convert the date to.
|
210
210
|
* @param {string} timezone - The timezone to convert the date to.
|
211
|
+
* @param {object} options - The options object
|
211
212
|
* @returns {Date} - The moment date object.
|
212
213
|
*/
|
213
|
-
export function momentDate(value: string | Date, format: string, timezone: string): Date;
|
214
|
+
export function momentDate(value: string | Date, format: string, timezone: string, options: object): Date;
|
214
215
|
/**
|
215
216
|
* Format a date provided a value, format, and timezone object.
|
216
217
|
* @param {string} timezonesUrl - The URL to load the timezone data from.
|
package/lib/cjs/utils/utils.js
CHANGED
@@ -687,9 +687,10 @@ exports.loadZones = loadZones;
|
|
687
687
|
* @param {string|Date} value - The value to convert into a moment date.
|
688
688
|
* @param {string} format - The format to convert the date to.
|
689
689
|
* @param {string} timezone - The timezone to convert the date to.
|
690
|
+
* @param {object} options - The options object
|
690
691
|
* @returns {Date} - The moment date object.
|
691
692
|
*/
|
692
|
-
function momentDate(value, format, timezone) {
|
693
|
+
function momentDate(value, format, timezone, options) {
|
693
694
|
const momentDate = (0, moment_timezone_1.default)(value);
|
694
695
|
if (!timezone) {
|
695
696
|
return momentDate;
|
@@ -697,7 +698,7 @@ function momentDate(value, format, timezone) {
|
|
697
698
|
if (timezone === 'UTC') {
|
698
699
|
timezone = 'Etc/UTC';
|
699
700
|
}
|
700
|
-
if ((timezone !== currentTimezone() || (format && format.match(/\s(z$|z\s)/))) && moment_timezone_1.default.zonesLoaded) {
|
701
|
+
if ((timezone !== currentTimezone() || (format && format.match(/\s(z$|z\s)/))) && (moment_timezone_1.default.zonesLoaded || (options === null || options === void 0 ? void 0 : options.email))) {
|
701
702
|
return momentDate.tz(timezone);
|
702
703
|
}
|
703
704
|
return momentDate;
|
@@ -93,8 +93,6 @@ class CalendarWidget extends InputWidget_1.default {
|
|
93
93
|
this.settings.disableWeekends ? this.settings.disable.push(this.disableWeekends) : '';
|
94
94
|
this.settings.disableWeekdays ? this.settings.disable.push(this.disableWeekdays) : '';
|
95
95
|
this.settings.disableFunction ? this.settings.disable.push(this.disableFunction) : '';
|
96
|
-
this.settings.wasDefaultValueChanged = false;
|
97
|
-
this.settings.defaultValue = '';
|
98
96
|
this.settings.manualInputValue = '';
|
99
97
|
this.settings.isManuallyOverriddenValue = false;
|
100
98
|
this.settings.currentValue = '';
|
@@ -115,10 +113,6 @@ class CalendarWidget extends InputWidget_1.default {
|
|
115
113
|
this.calendar._input.value = this.settings.isManuallyOverriddenValue ? this.settings.manualInputValue : this.calendar.altInput.value;
|
116
114
|
this.emit('update');
|
117
115
|
}
|
118
|
-
if (this.settings.wasDefaultValueChanged) {
|
119
|
-
this.calendar._input.value = this.settings.defaultValue;
|
120
|
-
this.settings.wasDefaultValueChanged = false;
|
121
|
-
}
|
122
116
|
if (this.calendar) {
|
123
117
|
this.emit('blur');
|
124
118
|
}
|
@@ -360,14 +354,6 @@ class CalendarWidget extends InputWidget_1.default {
|
|
360
354
|
this.settings.currentValue = event.target.value;
|
361
355
|
this.emit('update');
|
362
356
|
}
|
363
|
-
if (event.target.value === '' && this.calendar.selectedDates.length > 0) {
|
364
|
-
this.settings.wasDefaultValueChanged = true;
|
365
|
-
this.settings.defaultValue = event.target.value;
|
366
|
-
this.calendar.clear();
|
367
|
-
}
|
368
|
-
else {
|
369
|
-
this.settings.wasDefaultValueChanged = false;
|
370
|
-
}
|
371
357
|
});
|
372
358
|
if (this.calendar.daysContainer) {
|
373
359
|
this.calendar.daysContainer.addEventListener('click', () => {
|
package/lib/mjs/Embed.js
CHANGED
@@ -14,7 +14,7 @@ export class Formio {
|
|
14
14
|
Formio._formioReady = ready;
|
15
15
|
Formio._formioReadyReject = reject;
|
16
16
|
});
|
17
|
-
static version = '5.1.0-dev.
|
17
|
+
static version = '5.1.0-dev.2';
|
18
18
|
static setLicense(license, norecurse = false) {
|
19
19
|
Formio.license = license;
|
20
20
|
if (!norecurse && Formio.FormioClass) {
|
package/lib/mjs/Form.d.ts
CHANGED
@@ -48,7 +48,7 @@ export default class Form extends Element {
|
|
48
48
|
* @property {number} [saveDraftThrottle] - The throttle for the save draft feature.
|
49
49
|
* @property {boolean} [readOnly] - Set this form to readOnly.
|
50
50
|
* @property {boolean} [noAlerts] - Disable the alerts dialog.
|
51
|
-
* @property {
|
51
|
+
* @property {Record<string, Record<string, string>>} [i18n] - The translation file for this rendering.
|
52
52
|
* @property {string} [template] - Custom logic for creation of elements.
|
53
53
|
* @property {boolean} [noDefaults] - Exclude default values from the settings.
|
54
54
|
* @property {any} [fileService] - The file service for this form.
|
@@ -117,9 +117,7 @@ export default class Form extends Element {
|
|
117
117
|
/**
|
118
118
|
* - The translation file for this rendering.
|
119
119
|
*/
|
120
|
-
i18n?:
|
121
|
-
[key: string]: string;
|
122
|
-
} | undefined;
|
120
|
+
i18n?: Record<string, Record<string, string>> | undefined;
|
123
121
|
/**
|
124
122
|
* - Custom logic for creation of elements.
|
125
123
|
*/
|