@formio/js 5.2.0-rc.9 → 5.2.1-dev.6186.ffe4f6c
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 +6945 -0
- package/dist/formio.builder.css +15 -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 +15 -17
- package/dist/formio.form.js +44 -55
- 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 +15 -17
- package/dist/formio.full.js +46 -57
- package/dist/formio.full.min.css +1 -1
- package/dist/formio.full.min.js +1 -1
- package/dist/formio.full.min.js.LICENSE.txt +3 -3
- package/dist/formio.js +19 -30
- package/dist/formio.min.js +1 -1
- package/dist/formio.min.js.LICENSE.txt +1 -1
- package/dist/formio.utils.js +18 -29
- 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/Formio.js +1 -1
- package/lib/cjs/PDFBuilder.js +8 -6
- package/lib/cjs/Webform.js +3 -2
- package/lib/cjs/WebformBuilder.js +18 -11
- package/lib/cjs/Wizard.d.ts +1 -2
- package/lib/cjs/Wizard.js +17 -23
- package/lib/cjs/components/Components.js +7 -1
- package/lib/cjs/components/_classes/component/Component.d.ts +23 -2
- package/lib/cjs/components/_classes/component/Component.js +61 -35
- package/lib/cjs/components/_classes/nested/NestedComponent.d.ts +1 -0
- package/lib/cjs/components/_classes/nested/NestedComponent.js +11 -3
- package/lib/cjs/components/file/File.d.ts +1 -1
- package/lib/cjs/components/file/File.js +6 -1
- package/lib/cjs/components/form/Form.d.ts +0 -2
- package/lib/cjs/components/form/Form.js +12 -20
- package/lib/cjs/components/select/Select.d.ts +1 -1
- package/lib/cjs/components/select/Select.js +17 -26
- package/lib/cjs/components/tags/Tags.d.ts +1 -1
- package/lib/cjs/components/tags/Tags.js +2 -2
- package/lib/cjs/formio.form.js +1 -0
- package/lib/cjs/utils/ChoicesWrapper.d.ts +4 -25
- package/lib/cjs/utils/ChoicesWrapper.js +47 -124
- package/lib/cjs/utils/formUtils.d.ts +3 -3
- package/lib/cjs/utils/index.d.ts +5 -5
- package/lib/cjs/utils/utils.d.ts +4 -4
- package/lib/cjs/utils/utils.js +2 -2
- package/lib/cjs/widgets/CalendarWidget.d.ts +1 -1
- package/lib/cjs/widgets/CalendarWidget.js +1 -1
- package/lib/mjs/Embed.js +1 -1
- package/lib/mjs/Formio.js +1 -1
- package/lib/mjs/PDFBuilder.js +8 -6
- package/lib/mjs/Webform.js +2 -2
- package/lib/mjs/WebformBuilder.js +19 -12
- package/lib/mjs/Wizard.d.ts +1 -2
- package/lib/mjs/Wizard.js +16 -22
- package/lib/mjs/components/Components.js +7 -1
- package/lib/mjs/components/_classes/component/Component.d.ts +23 -2
- package/lib/mjs/components/_classes/component/Component.js +61 -35
- package/lib/mjs/components/_classes/nested/NestedComponent.d.ts +1 -0
- package/lib/mjs/components/_classes/nested/NestedComponent.js +11 -3
- package/lib/mjs/components/file/File.d.ts +1 -1
- package/lib/mjs/components/file/File.js +6 -1
- package/lib/mjs/components/form/Form.d.ts +0 -2
- package/lib/mjs/components/form/Form.js +12 -20
- package/lib/mjs/components/select/Select.d.ts +1 -1
- package/lib/mjs/components/select/Select.js +17 -25
- package/lib/mjs/components/tags/Tags.d.ts +1 -1
- package/lib/mjs/components/tags/Tags.js +2 -2
- package/lib/mjs/formio.form.js +1 -0
- package/lib/mjs/utils/ChoicesWrapper.d.ts +4 -25
- package/lib/mjs/utils/ChoicesWrapper.js +26 -119
- package/lib/mjs/utils/formUtils.d.ts +3 -3
- package/lib/mjs/utils/index.d.ts +5 -5
- package/lib/mjs/utils/utils.d.ts +4 -4
- package/lib/mjs/utils/utils.js +2 -2
- package/lib/mjs/widgets/CalendarWidget.d.ts +1 -1
- package/lib/mjs/widgets/CalendarWidget.js +1 -1
- package/package.json +5 -5
@@ -6,7 +6,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const lodash_1 = __importDefault(require("lodash"));
|
7
7
|
const Formio_1 = require("../../Formio");
|
8
8
|
const ListComponent_1 = __importDefault(require("../_classes/list/ListComponent"));
|
9
|
-
const Input_1 = __importDefault(require("../_classes/input/Input"));
|
10
9
|
const Form_1 = __importDefault(require("../../Form"));
|
11
10
|
const utils_1 = require("../../utils");
|
12
11
|
const ChoicesWrapper_1 = __importDefault(require("../../utils/ChoicesWrapper"));
|
@@ -356,6 +355,18 @@ class SelectComponent extends ListComponent_1.default {
|
|
356
355
|
this.downloadedResources.serverCount = this.downloadedResources.length;
|
357
356
|
this.serverCount = this.downloadedResources.length;
|
358
357
|
}
|
358
|
+
shouldResetChoicesItems(items) {
|
359
|
+
if (this.choices._store.choices.length !== items.length) {
|
360
|
+
return true;
|
361
|
+
}
|
362
|
+
for (let item of items) {
|
363
|
+
const choicesItem = this.choices._store.choices.find((i) => i.label === item.label);
|
364
|
+
if (!choicesItem) {
|
365
|
+
return true;
|
366
|
+
}
|
367
|
+
}
|
368
|
+
return false;
|
369
|
+
}
|
359
370
|
/* eslint-disable max-statements */
|
360
371
|
setItems(items, fromSearch) {
|
361
372
|
var _a, _b;
|
@@ -442,7 +453,7 @@ class SelectComponent extends ListComponent_1.default {
|
|
442
453
|
this.addOption(itemValueAndLabel.value, itemValueAndLabel.label, {}, lodash_1.default.get(item, this.component.idPath, String(index)));
|
443
454
|
});
|
444
455
|
if (this.choices) {
|
445
|
-
this.choices.setChoices(this.selectOptions, 'value', 'label', true);
|
456
|
+
this.choices.setChoices(this.selectOptions, 'value', 'label', true, true, !fromSearch && this.shouldResetChoicesItems(this.selectOptions));
|
446
457
|
}
|
447
458
|
else if (this.loading) {
|
448
459
|
// Re-attach select input.
|
@@ -768,10 +779,10 @@ class SelectComponent extends ListComponent_1.default {
|
|
768
779
|
distance: 1000,
|
769
780
|
};
|
770
781
|
return Object.assign({ removeItemButton: this.component.disabled ? false : lodash_1.default.get(this.component, 'removeItemButton', true), itemSelectText: '', classNames: {
|
771
|
-
containerOuter: 'choices form-group formio-choices',
|
772
|
-
containerInner: this.transform('class', 'form-control ui fluid selection dropdown')
|
782
|
+
containerOuter: ['choices', 'form-group', 'formio-choices'],
|
783
|
+
containerInner: this.transform('class', 'form-control ui fluid selection dropdown').split(' '),
|
773
784
|
}, addItemText: false, allowHTML: true, placeholder: !!this.component.placeholder, placeholderValue: placeholderValue, noResultsText: this.t('No results found'), noChoicesText: this.t('No choices to choose from'), searchPlaceholderValue: this.t('Type to search'), 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
|
774
|
-
? 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);
|
785
|
+
? 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);
|
775
786
|
}
|
776
787
|
/* eslint-disable max-statements */
|
777
788
|
attach(element) {
|
@@ -837,7 +848,7 @@ class SelectComponent extends ListComponent_1.default {
|
|
837
848
|
this.choices.containerOuter.element.setAttribute('tabIndex', '-1');
|
838
849
|
this.addEventListener(this.choices.containerOuter.element, 'focus', () => this.focusableElement.focus());
|
839
850
|
}
|
840
|
-
|
851
|
+
this.addFocusBlurEvents(this.choices.input.element);
|
841
852
|
if (this.itemsFromUrl && !this.component.noRefreshOnScroll) {
|
842
853
|
this.scrollList = this.choices.choiceList.element;
|
843
854
|
this.addEventListener(this.scrollList, 'scroll', () => this.onScroll());
|
@@ -903,12 +914,6 @@ class SelectComponent extends ListComponent_1.default {
|
|
903
914
|
this.positionDropdown();
|
904
915
|
});
|
905
916
|
}
|
906
|
-
if (this.choices && choicesOptions.placeholderValue && this.choices._isSelectOneElement) {
|
907
|
-
this.addPlaceholderItem(choicesOptions.placeholderValue);
|
908
|
-
this.addEventListener(input, 'removeItem', () => {
|
909
|
-
this.addPlaceholderItem(choicesOptions.placeholderValue);
|
910
|
-
});
|
911
|
-
}
|
912
917
|
// Add value options.
|
913
918
|
this.addValueOptions();
|
914
919
|
this.setChoicesValue(this.dataValue);
|
@@ -996,20 +1001,6 @@ class SelectComponent extends ListComponent_1.default {
|
|
996
1001
|
});
|
997
1002
|
}
|
998
1003
|
}
|
999
|
-
addPlaceholderItem(placeholderValue) {
|
1000
|
-
const items = this.choices._store.activeItems;
|
1001
|
-
if (!items.length) {
|
1002
|
-
this.choices._addItem({
|
1003
|
-
value: '',
|
1004
|
-
label: placeholderValue,
|
1005
|
-
choiceId: 0,
|
1006
|
-
groupId: -1,
|
1007
|
-
customProperties: null,
|
1008
|
-
placeholder: true,
|
1009
|
-
keyCode: null
|
1010
|
-
});
|
1011
|
-
}
|
1012
|
-
}
|
1013
1004
|
/* eslint-enable max-statements */
|
1014
1005
|
update() {
|
1015
1006
|
if (this.component.dataSrc === 'custom') {
|
@@ -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");
|
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);
|
package/lib/cjs/formio.form.js
CHANGED
@@ -73,6 +73,7 @@ function registerModule(mod, defaultFn = null, options = {}) {
|
|
73
73
|
case 'templates':
|
74
74
|
for (const framework of Object.keys(mod.templates)) {
|
75
75
|
Formio_1.Formio.Templates.extendTemplate(framework, mod.templates[framework]);
|
76
|
+
Formio_1.Formio.Templates.defaultTemplates = lodash_1.default.defaults(mod.templates[framework], Formio_1.Formio.Templates.defaultTemplates);
|
76
77
|
}
|
77
78
|
if (mod.templates[current]) {
|
78
79
|
Formio_1.Formio.Templates.current = mod.templates[current];
|
@@ -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;
|
@@ -26,10 +26,10 @@ export const getBestMatch: typeof Utils.getBestMatch;
|
|
26
26
|
export const getComponentFromPath: typeof Utils.getComponentFromPath;
|
27
27
|
export const getComponentValue: typeof Utils.getComponentValue;
|
28
28
|
export const findComponents: typeof Utils.findComponents;
|
29
|
-
export const eachComponentDataAsync: (components: import("@formio/core").Component[], data: import("@formio/core").DataObject, fn: import("@formio/core").EachComponentDataAsyncCallback, includeAll?: boolean | undefined, local?: boolean | undefined, parent?: import("@formio/core").Component | undefined, parentPaths?: import("@formio/core").ComponentPaths | undefined) => Promise<void>;
|
30
|
-
export const eachComponentData: (components: import("@formio/core").Component[], data: import("@formio/core").DataObject, fn: import("@formio/core").EachComponentDataCallback, includeAll?: boolean | undefined, local?: boolean | undefined, parent?: import("@formio/core").Component | undefined, parentPaths?: import("@formio/core").ComponentPaths | undefined) => void;
|
29
|
+
export const eachComponentDataAsync: (components: import("@formio/core").Component[], data: import("@formio/core").DataObject, fn: import("@formio/core").EachComponentDataAsyncCallback, includeAll?: boolean | undefined, local?: boolean | undefined, parent?: import("@formio/core").Component | undefined, parentPaths?: import("@formio/core").ComponentPaths | undefined, noScopeReset?: boolean | undefined, afterFn?: import("@formio/core").EachComponentDataAsyncCallback | undefined) => Promise<void>;
|
30
|
+
export const eachComponentData: (components: import("@formio/core").Component[], data: import("@formio/core").DataObject, fn: import("@formio/core").EachComponentDataCallback, includeAll?: boolean | undefined, local?: boolean | undefined, parent?: import("@formio/core").Component | undefined, parentPaths?: import("@formio/core").ComponentPaths | undefined, noScopeReset?: boolean | undefined, afterFn?: import("@formio/core").EachComponentDataCallback | undefined) => void;
|
31
31
|
export const getComponentKey: typeof Utils.getComponentKey;
|
32
|
-
export const getContextualRowPath:
|
32
|
+
export const getContextualRowPath: any;
|
33
33
|
export const getContextualRowData: typeof Utils.getContextualRowData;
|
34
34
|
export const componentInfo: typeof Utils.componentInfo;
|
35
35
|
export const eachComponent: typeof Utils.eachComponent;
|
package/lib/cjs/utils/index.d.ts
CHANGED
@@ -37,10 +37,10 @@ declare const FormioUtils: {
|
|
37
37
|
getComponentFromPath: typeof import("@formio/core/lib/utils/formUtil").getComponentFromPath;
|
38
38
|
getComponentValue: typeof import("@formio/core/lib/utils/formUtil").getComponentValue;
|
39
39
|
findComponents: typeof import("@formio/core/lib/utils/formUtil").findComponents;
|
40
|
-
eachComponentDataAsync: (components: import("@formio/core").Component[], data: import("@formio/core").DataObject, fn: import("@formio/core").EachComponentDataAsyncCallback, includeAll?: boolean | undefined, local?: boolean | undefined, parent?: import("@formio/core").Component | undefined, parentPaths?: import("@formio/core").ComponentPaths | undefined) => Promise<void>;
|
41
|
-
eachComponentData: (components: import("@formio/core").Component[], data: import("@formio/core").DataObject, fn: import("@formio/core").EachComponentDataCallback, includeAll?: boolean | undefined, local?: boolean | undefined, parent?: import("@formio/core").Component | undefined, parentPaths?: import("@formio/core").ComponentPaths | undefined) => void;
|
40
|
+
eachComponentDataAsync: (components: import("@formio/core").Component[], data: import("@formio/core").DataObject, fn: import("@formio/core").EachComponentDataAsyncCallback, includeAll?: boolean | undefined, local?: boolean | undefined, parent?: import("@formio/core").Component | undefined, parentPaths?: import("@formio/core").ComponentPaths | undefined, noScopeReset?: boolean | undefined, afterFn?: import("@formio/core").EachComponentDataAsyncCallback | undefined) => Promise<void>;
|
41
|
+
eachComponentData: (components: import("@formio/core").Component[], data: import("@formio/core").DataObject, fn: import("@formio/core").EachComponentDataCallback, includeAll?: boolean | undefined, local?: boolean | undefined, parent?: import("@formio/core").Component | undefined, parentPaths?: import("@formio/core").ComponentPaths | undefined, noScopeReset?: boolean | undefined, afterFn?: import("@formio/core").EachComponentDataCallback | undefined) => void;
|
42
42
|
getComponentKey: typeof import("@formio/core/lib/utils/formUtil").getComponentKey;
|
43
|
-
getContextualRowPath:
|
43
|
+
getContextualRowPath: any;
|
44
44
|
getContextualRowData: typeof import("@formio/core/lib/utils/formUtil").getContextualRowData;
|
45
45
|
componentInfo: typeof import("@formio/core/lib/utils/formUtil").componentInfo;
|
46
46
|
eachComponent: typeof import("@formio/core/lib/utils/formUtil").eachComponent;
|
@@ -137,8 +137,8 @@ declare const FormioUtils: {
|
|
137
137
|
translateHTMLTemplate(template: string, translate: Function): string;
|
138
138
|
sanitize(string: string, options: any): string;
|
139
139
|
fastCloneDeep(obj: any): any;
|
140
|
-
isInputComponent(componentJson: import("@formio/core").Component):
|
141
|
-
getArrayFromComponentPath(pathStr: string):
|
140
|
+
isInputComponent(componentJson: import("@formio/core").Component): boolean;
|
141
|
+
getArrayFromComponentPath(pathStr: string): string[];
|
142
142
|
isChildOf(child: any, parent: any): boolean;
|
143
143
|
getStringFromComponentPath(path: number[]): string;
|
144
144
|
round(number: number, precision: number): string;
|
package/lib/cjs/utils/utils.d.ts
CHANGED
@@ -414,15 +414,15 @@ export function fastCloneDeep(obj: any): any;
|
|
414
414
|
/**
|
415
415
|
* Returns if the component is an input component.
|
416
416
|
* @param {import('@formio/core').Component} componentJson - The JSON of a component.
|
417
|
-
* @returns {
|
417
|
+
* @returns {boolean} - TRUE if the component is an input component; FALSE otherwise.
|
418
418
|
*/
|
419
|
-
export function isInputComponent(componentJson: import('@formio/core').Component):
|
419
|
+
export function isInputComponent(componentJson: import('@formio/core').Component): boolean;
|
420
420
|
/**
|
421
421
|
* Takes a component path, and returns a component path array.
|
422
422
|
* @param {string} pathStr - The path string to convert to an array.
|
423
|
-
* @returns {
|
423
|
+
* @returns {Array<string>} - The array of paths.
|
424
424
|
*/
|
425
|
-
export function getArrayFromComponentPath(pathStr: string):
|
425
|
+
export function getArrayFromComponentPath(pathStr: string): Array<string>;
|
426
426
|
/**
|
427
427
|
* Returns true if the component is a child of the parent.
|
428
428
|
* @param {any} child - The child component to check.
|
package/lib/cjs/utils/utils.js
CHANGED
@@ -1357,7 +1357,7 @@ exports.fastCloneDeep = fastCloneDeep;
|
|
1357
1357
|
/**
|
1358
1358
|
* Returns if the component is an input component.
|
1359
1359
|
* @param {import('@formio/core').Component} componentJson - The JSON of a component.
|
1360
|
-
* @returns {
|
1360
|
+
* @returns {boolean} - TRUE if the component is an input component; FALSE otherwise.
|
1361
1361
|
*/
|
1362
1362
|
function isInputComponent(componentJson) {
|
1363
1363
|
if (componentJson.input === false || componentJson.input === true) {
|
@@ -1382,7 +1382,7 @@ exports.isInputComponent = isInputComponent;
|
|
1382
1382
|
/**
|
1383
1383
|
* Takes a component path, and returns a component path array.
|
1384
1384
|
* @param {string} pathStr - The path string to convert to an array.
|
1385
|
-
* @returns {
|
1385
|
+
* @returns {Array<string>} - The array of paths.
|
1386
1386
|
*/
|
1387
1387
|
function getArrayFromComponentPath(pathStr) {
|
1388
1388
|
if (!pathStr || !lodash_1.default.isString(pathStr)) {
|
@@ -84,7 +84,7 @@ export default class CalendarWidget extends InputWidget {
|
|
84
84
|
* @returns {void}
|
85
85
|
*/
|
86
86
|
setValue(value: any): void;
|
87
|
-
getValueAsString(value: any, format
|
87
|
+
getValueAsString(value: any, format?: string): string;
|
88
88
|
setErrorClasses(hasErrors: any): void;
|
89
89
|
isCalendarElement(element: any): any;
|
90
90
|
initFlatpickr(Flatpickr: any): void;
|
@@ -315,7 +315,7 @@ class CalendarWidget extends InputWidget_1.default {
|
|
315
315
|
this.calendar.clear(false);
|
316
316
|
}
|
317
317
|
}
|
318
|
-
getValueAsString(value, format) {
|
318
|
+
getValueAsString(value, format = '') {
|
319
319
|
const inputFormat = format || this.dateFormat;
|
320
320
|
const valueFormat = this.calendar ? this.valueFormat : this.settings.dateFormat;
|
321
321
|
if (this.settings.saveAs === 'text' && this.componentInstance.parent && !this.settings.readOnly) {
|
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.2.
|
17
|
+
static version = '5.2.1-rc.5';
|
18
18
|
static setLicense(license, norecurse = false) {
|
19
19
|
Formio.license = license;
|
20
20
|
if (!norecurse && Formio.FormioClass) {
|
package/lib/mjs/Formio.js
CHANGED
@@ -4,7 +4,7 @@ import CDN from './CDN';
|
|
4
4
|
import Providers from './providers';
|
5
5
|
FormioCore.cdn = new CDN();
|
6
6
|
FormioCore.Providers = Providers;
|
7
|
-
FormioCore.version = '5.2.
|
7
|
+
FormioCore.version = '5.2.1-rc.5';
|
8
8
|
CDN.defaultCDN = FormioCore.version.includes('rc') ? 'https://cdn.test-form.io' : 'https://cdn.form.io';
|
9
9
|
const isNil = (val) => val === null || val === undefined;
|
10
10
|
FormioCore.prototype.uploadFile = function (storage, file, fileName, dir, progressCallback, url, options, fileKey, groupPermissions, groupId, uploadStartCallback, abortCallback, multipartOptions) {
|
package/lib/mjs/PDFBuilder.js
CHANGED
@@ -447,18 +447,20 @@ export default class PDFBuilder extends WebformBuilder {
|
|
447
447
|
const repeatablePathsComps = this.findComponentsWithRepeatablePaths();
|
448
448
|
// update elements which path was duplicated if any pathes have been changed
|
449
449
|
if (!_.isEqual(this.repeatablePathsComps, repeatablePathsComps)) {
|
450
|
-
|
451
|
-
|
452
|
-
this.
|
453
|
-
|
454
|
-
|
450
|
+
if (!_.isEmpty(this.repeatablePathsComps)) {
|
451
|
+
eachComponent(this.webform.getComponents(), (comp) => {
|
452
|
+
if (this.repeatablePathsComps.includes(comp.component)) {
|
453
|
+
this.webform.postMessage({ name: 'updateElement', data: comp.component });
|
454
|
+
}
|
455
|
+
});
|
456
|
+
}
|
455
457
|
this.repeatablePathsComps = repeatablePathsComps;
|
456
458
|
}
|
457
459
|
if (!repeatablePathsComps.length) {
|
458
460
|
return;
|
459
461
|
}
|
460
462
|
eachComponent(this.webform.getComponents(), (comp) => {
|
461
|
-
if (this.repeatablePathsComps.includes(comp)) {
|
463
|
+
if (this.repeatablePathsComps.includes(comp.component)) {
|
462
464
|
this.webform.postMessage({
|
463
465
|
name: 'showBuilderErrors',
|
464
466
|
data: {
|
package/lib/mjs/Webform.js
CHANGED
@@ -744,7 +744,7 @@ export default class Webform extends NestedDataComponent {
|
|
744
744
|
this.emit(restoreDraft ? "restoreDraftError" : "saveDraftError", errDetails || errorMessage);
|
745
745
|
}
|
746
746
|
saveDraft() {
|
747
|
-
if (!this.draftEnabled) {
|
747
|
+
if (!this.draftEnabled || this.parent?.component.reference === false) {
|
748
748
|
return;
|
749
749
|
}
|
750
750
|
if (!this.formio) {
|
@@ -1116,7 +1116,7 @@ export default class Webform extends NestedDataComponent {
|
|
1116
1116
|
// Mark any components as invalid if in a custom message.
|
1117
1117
|
const componentErrors = {};
|
1118
1118
|
errors.forEach((err) => {
|
1119
|
-
const path = err.path || err.context?.path || err.component?.key;
|
1119
|
+
const path = getStringFromComponentPath(err.path) || err.context?.path || err.component?.key;
|
1120
1120
|
if (!componentErrors[path]) {
|
1121
1121
|
componentErrors[path] = [];
|
1122
1122
|
}
|
@@ -3,7 +3,7 @@ import Component from './components/_classes/component/Component';
|
|
3
3
|
import tippy from 'tippy.js';
|
4
4
|
import Components from './components/Components';
|
5
5
|
import { Formio } from './Formio';
|
6
|
-
import { fastCloneDeep, bootstrapVersion, getArrayFromComponentPath, getStringFromComponentPath, eachComponent, getComponent, } from './utils';
|
6
|
+
import { fastCloneDeep, bootstrapVersion, getArrayFromComponentPath, getStringFromComponentPath, eachComponent, getComponent, componentInfo } from './utils';
|
7
7
|
import BuilderUtils from './utils/builder';
|
8
8
|
import _ from 'lodash';
|
9
9
|
import autoScroll from 'dom-autoscroller';
|
@@ -1115,15 +1115,18 @@ export default class WebformBuilder extends Component {
|
|
1115
1115
|
const keys = new Map();
|
1116
1116
|
eachComponent(this.form.components, (comp, path, components, parent, paths) => {
|
1117
1117
|
const isRadioCheckbox = comp.type === 'checkbox' && comp.inputType === 'radio';
|
1118
|
-
|
1119
|
-
|
1120
|
-
|
1121
|
-
|
1122
|
-
|
1123
|
-
|
1124
|
-
|
1125
|
-
|
1126
|
-
|
1118
|
+
const isLayout = componentInfo(comp).layout;
|
1119
|
+
if (!isLayout) {
|
1120
|
+
if (keys.has(paths.dataPath)) {
|
1121
|
+
const onlyRadioCheckboxes = repeatablePaths[paths.dataPath]?.onlyRadioCheckboxes === false ? false : isRadioCheckbox;
|
1122
|
+
repeatablePaths[paths.dataPath] = {
|
1123
|
+
comps: [...(repeatablePaths[paths.dataPath]?.comps || []), keys.get(paths.dataPath), comp],
|
1124
|
+
onlyRadioCheckboxes,
|
1125
|
+
};
|
1126
|
+
}
|
1127
|
+
else {
|
1128
|
+
keys.set(paths.dataPath, comp);
|
1129
|
+
}
|
1127
1130
|
}
|
1128
1131
|
}, true);
|
1129
1132
|
const componentsWithRepeatablePaths = [];
|
@@ -1143,6 +1146,9 @@ export default class WebformBuilder extends Component {
|
|
1143
1146
|
comp.setCustomValidity(this.t('apiKey', { key: comp.key }));
|
1144
1147
|
hasInvalidComponents = true;
|
1145
1148
|
}
|
1149
|
+
else {
|
1150
|
+
comp.setCustomValidity();
|
1151
|
+
}
|
1146
1152
|
});
|
1147
1153
|
this.emit('builderFormValidityChange', hasInvalidComponents);
|
1148
1154
|
}
|
@@ -1261,7 +1267,8 @@ export default class WebformBuilder extends Component {
|
|
1261
1267
|
helplinks: this.helplinks,
|
1262
1268
|
}));
|
1263
1269
|
this.editForm.attach(this.componentEdit.querySelector(`[${this._referenceAttributeName}="editForm"]`));
|
1264
|
-
this.
|
1270
|
+
const editFormData = this.editForm.submission?.data;
|
1271
|
+
this.updateComponent(editFormData?.componentJson || editFormData || component);
|
1265
1272
|
this.attachEditComponentControls(component, parent, isNew, original, ComponentClass);
|
1266
1273
|
});
|
1267
1274
|
});
|
@@ -1648,7 +1655,7 @@ export default class WebformBuilder extends Component {
|
|
1648
1655
|
}
|
1649
1656
|
hasEditTabs(type) {
|
1650
1657
|
// If the component type does not exist then it has no edit tabs
|
1651
|
-
if (!Components.components[type]) {
|
1658
|
+
if (!Components.components[type === 'custom' ? 'unknown' : type]) {
|
1652
1659
|
return false;
|
1653
1660
|
}
|
1654
1661
|
const editTabs = getComponent(Components.components[type === 'custom' ? 'unknown' : type].editForm().components, 'tabs', true).components;
|