@formio/js 5.1.0-dev.6030.abc8cfc → 5.1.0-dev.6035.9508dc1
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 +15 -17
- package/dist/formio.builder.min.css +1 -1
- package/dist/formio.form.css +15 -17
- package/dist/formio.form.js +15 -15
- package/dist/formio.form.min.css +1 -1
- package/dist/formio.form.min.js +1 -1
- package/dist/formio.form.min.js.LICENSE.txt +2 -2
- package/dist/formio.full.css +15 -17
- package/dist/formio.full.js +16 -16
- package/dist/formio.full.min.css +1 -1
- package/dist/formio.full.min.js +1 -1
- package/dist/formio.full.min.js.LICENSE.txt +2 -2
- package/dist/formio.js +1 -1
- package/dist/formio.min.js +1 -1
- package/dist/formio.min.js.LICENSE.txt +1 -1
- package/dist/formio.utils.js +1 -1
- package/dist/formio.utils.min.js +1 -1
- package/dist/formio.utils.min.js.LICENSE.txt +1 -1
- package/lib/cjs/Form.d.ts +2 -4
- package/lib/cjs/WizardBuilder.js +14 -1
- package/lib/cjs/components/form/Form.d.ts +1 -1
- package/lib/cjs/components/form/Form.js +5 -1
- package/lib/cjs/components/select/Select.d.ts +0 -1
- package/lib/cjs/components/select/Select.js +3 -23
- package/lib/cjs/components/tags/Tags.d.ts +1 -1
- package/lib/cjs/components/tags/Tags.js +2 -2
- package/lib/cjs/utils/ChoicesWrapper.d.ts +4 -25
- package/lib/cjs/utils/ChoicesWrapper.js +47 -124
- package/lib/mjs/Form.d.ts +2 -4
- package/lib/mjs/Form.js +1 -1
- package/lib/mjs/WizardBuilder.js +14 -1
- package/lib/mjs/components/form/Form.d.ts +1 -1
- package/lib/mjs/components/form/Form.js +4 -1
- package/lib/mjs/components/select/Select.d.ts +0 -1
- package/lib/mjs/components/select/Select.js +3 -22
- package/lib/mjs/components/tags/Tags.d.ts +1 -1
- package/lib/mjs/components/tags/Tags.js +2 -2
- package/lib/mjs/utils/ChoicesWrapper.d.ts +4 -25
- package/lib/mjs/utils/ChoicesWrapper.js +26 -119
- package/package.json +2 -2
@@ -18,7 +18,7 @@
|
|
18
18
|
* MIT licensed
|
19
19
|
*/
|
20
20
|
|
21
|
-
/*! @license DOMPurify 3.2.
|
21
|
+
/*! @license DOMPurify 3.2.4 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.2.4/LICENSE */
|
22
22
|
|
23
23
|
/*! formiojs v5.1.0-dev.2 | https://unpkg.com/formiojs@5.1.0-dev.2/LICENSE.txt */
|
24
24
|
|
package/lib/cjs/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
|
*/
|
package/lib/cjs/WizardBuilder.js
CHANGED
@@ -261,10 +261,23 @@ class WizardBuilder extends WebformBuilder_1.default {
|
|
261
261
|
if (component instanceof WizardBuilder) {
|
262
262
|
return;
|
263
263
|
}
|
264
|
+
if (!window.sessionStorage) {
|
265
|
+
return console.warn(this.t('sessionStorageSupportError'));
|
266
|
+
}
|
267
|
+
// If pasting after the Wizard's page, check if a full Wizard page was copied and pass it to addPage method
|
264
268
|
if (this._form.components.find(comp => lodash_1.default.isEqual(component.component, comp))) {
|
265
|
-
|
269
|
+
const data = window.sessionStorage.getItem('formio.clipboard');
|
270
|
+
if (data) {
|
271
|
+
const schema = JSON.parse(data);
|
272
|
+
// If the copied component is not a Wizard's page, do nothing since we can't paste outside the panel in Wizard
|
273
|
+
if (schema.type !== 'panel') {
|
274
|
+
return;
|
275
|
+
}
|
276
|
+
this.addPage(schema);
|
277
|
+
}
|
266
278
|
}
|
267
279
|
else {
|
280
|
+
// If we are not trying to paster after the current Wizard's page, just pass it to the WebformBuilder
|
268
281
|
return super.pasteComponent(component);
|
269
282
|
}
|
270
283
|
}
|
@@ -102,7 +102,8 @@ class FormComponent extends Component_1.default {
|
|
102
102
|
return this.createSubForm();
|
103
103
|
}
|
104
104
|
get dataReady() {
|
105
|
-
|
105
|
+
var _a;
|
106
|
+
return ((_a = this.subForm) === null || _a === void 0 ? void 0 : _a.dataReady) || this.subFormReady || Promise.resolve();
|
106
107
|
}
|
107
108
|
get defaultValue() {
|
108
109
|
// Not not provide a default value unless the subform is ready so that it will initialize correctly.
|
@@ -673,6 +674,9 @@ class FormComponent extends Component_1.default {
|
|
673
674
|
*/
|
674
675
|
onSetSubFormValue(submission, flags) {
|
675
676
|
this.subForm.setValue(submission, flags);
|
677
|
+
if (flags === null || flags === void 0 ? void 0 : flags.fromSubmission) {
|
678
|
+
this.subForm.submissionReadyResolve(submission);
|
679
|
+
}
|
676
680
|
}
|
677
681
|
isEmpty(value = this.dataValue) {
|
678
682
|
return value === null || lodash_1.default.isEqual(value, this.emptyValue) || (this.areAllComponentsEmpty(value === null || value === void 0 ? void 0 : value.data) && !(value === null || value === void 0 ? void 0 : value._id));
|
@@ -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') {
|
@@ -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);
|
@@ -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/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
|
*/
|
package/lib/mjs/Form.js
CHANGED
@@ -51,7 +51,7 @@ export default class Form extends Element {
|
|
51
51
|
* @property {number} [saveDraftThrottle] - The throttle for the save draft feature.
|
52
52
|
* @property {boolean} [readOnly] - Set this form to readOnly.
|
53
53
|
* @property {boolean} [noAlerts] - Disable the alerts dialog.
|
54
|
-
* @property {
|
54
|
+
* @property {Record<string, Record<string, string>>} [i18n] - The translation file for this rendering.
|
55
55
|
* @property {string} [template] - Custom logic for creation of elements.
|
56
56
|
* @property {boolean} [noDefaults] - Exclude default values from the settings.
|
57
57
|
* @property {any} [fileService] - The file service for this form.
|
package/lib/mjs/WizardBuilder.js
CHANGED
@@ -255,10 +255,23 @@ export default class WizardBuilder extends WebformBuilder {
|
|
255
255
|
if (component instanceof WizardBuilder) {
|
256
256
|
return;
|
257
257
|
}
|
258
|
+
if (!window.sessionStorage) {
|
259
|
+
return console.warn(this.t('sessionStorageSupportError'));
|
260
|
+
}
|
261
|
+
// If pasting after the Wizard's page, check if a full Wizard page was copied and pass it to addPage method
|
258
262
|
if (this._form.components.find(comp => _.isEqual(component.component, comp))) {
|
259
|
-
|
263
|
+
const data = window.sessionStorage.getItem('formio.clipboard');
|
264
|
+
if (data) {
|
265
|
+
const schema = JSON.parse(data);
|
266
|
+
// If the copied component is not a Wizard's page, do nothing since we can't paste outside the panel in Wizard
|
267
|
+
if (schema.type !== 'panel') {
|
268
|
+
return;
|
269
|
+
}
|
270
|
+
this.addPage(schema);
|
271
|
+
}
|
260
272
|
}
|
261
273
|
else {
|
274
|
+
// If we are not trying to paster after the current Wizard's page, just pass it to the WebformBuilder
|
262
275
|
return super.pasteComponent(component);
|
263
276
|
}
|
264
277
|
}
|
@@ -97,7 +97,7 @@ export default class FormComponent extends Component {
|
|
97
97
|
return this.createSubForm();
|
98
98
|
}
|
99
99
|
get dataReady() {
|
100
|
-
return this.subFormReady || Promise.resolve();
|
100
|
+
return this.subForm?.dataReady || this.subFormReady || Promise.resolve();
|
101
101
|
}
|
102
102
|
get defaultValue() {
|
103
103
|
// Not not provide a default value unless the subform is ready so that it will initialize correctly.
|
@@ -663,6 +663,9 @@ export default class FormComponent extends Component {
|
|
663
663
|
*/
|
664
664
|
onSetSubFormValue(submission, flags) {
|
665
665
|
this.subForm.setValue(submission, flags);
|
666
|
+
if (flags?.fromSubmission) {
|
667
|
+
this.subForm.submissionReadyResolve(submission);
|
668
|
+
}
|
666
669
|
}
|
667
670
|
isEmpty(value = this.dataValue) {
|
668
671
|
return value === null || _.isEqual(value, this.emptyValue) || (this.areAllComponentsEmpty(value?.data) && !value?._id);
|
@@ -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;
|
@@ -772,8 +772,8 @@ export default class SelectComponent extends ListComponent {
|
|
772
772
|
removeItemButton: this.component.disabled ? false : _.get(this.component, 'removeItemButton', true),
|
773
773
|
itemSelectText: '',
|
774
774
|
classNames: {
|
775
|
-
containerOuter: 'choices form-group formio-choices',
|
776
|
-
containerInner: this.transform('class', 'form-control ui fluid selection dropdown')
|
775
|
+
containerOuter: ['choices', 'form-group', 'formio-choices'],
|
776
|
+
containerInner: this.transform('class', 'form-control ui fluid selection dropdown').split(' '),
|
777
777
|
},
|
778
778
|
addItemText: false,
|
779
779
|
allowHTML: true,
|
@@ -801,6 +801,7 @@ export default class SelectComponent extends ListComponent {
|
|
801
801
|
}),
|
802
802
|
valueComparer: _.isEqual,
|
803
803
|
resetScrollPosition: false,
|
804
|
+
duplicateItemsAllowed: false,
|
804
805
|
...customOptions,
|
805
806
|
};
|
806
807
|
}
|
@@ -933,12 +934,6 @@ export default class SelectComponent extends ListComponent {
|
|
933
934
|
this.positionDropdown();
|
934
935
|
});
|
935
936
|
}
|
936
|
-
if (this.choices && choicesOptions.placeholderValue && this.choices._isSelectOneElement) {
|
937
|
-
this.addPlaceholderItem(choicesOptions.placeholderValue);
|
938
|
-
this.addEventListener(input, 'removeItem', () => {
|
939
|
-
this.addPlaceholderItem(choicesOptions.placeholderValue);
|
940
|
-
});
|
941
|
-
}
|
942
937
|
// Add value options.
|
943
938
|
this.addValueOptions();
|
944
939
|
this.setChoicesValue(this.dataValue);
|
@@ -1024,20 +1019,6 @@ export default class SelectComponent extends ListComponent {
|
|
1024
1019
|
});
|
1025
1020
|
}
|
1026
1021
|
}
|
1027
|
-
addPlaceholderItem(placeholderValue) {
|
1028
|
-
const items = this.choices._store.activeItems;
|
1029
|
-
if (!items.length) {
|
1030
|
-
this.choices._addItem({
|
1031
|
-
value: '',
|
1032
|
-
label: placeholderValue,
|
1033
|
-
choiceId: 0,
|
1034
|
-
groupId: -1,
|
1035
|
-
customProperties: null,
|
1036
|
-
placeholder: true,
|
1037
|
-
keyCode: null
|
1038
|
-
});
|
1039
|
-
}
|
1040
|
-
}
|
1041
1022
|
/* eslint-enable max-statements */
|
1042
1023
|
update() {
|
1043
1024
|
if (this.component.dataSrc === 'custom') {
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import { componentValueTypes, getComponentSavedTypes } from '../../utils/utils';
|
2
2
|
import Input from '../_classes/input/Input';
|
3
|
-
import Choices from '
|
3
|
+
import Choices from 'choices.js';
|
4
4
|
export default class TagsComponent extends Input {
|
5
5
|
static schema(...extend) {
|
6
6
|
return Input.schema({
|
@@ -127,7 +127,7 @@ export default class TagsComponent extends Input {
|
|
127
127
|
const changed = super.setValue(value, flags);
|
128
128
|
if (this.choices) {
|
129
129
|
let dataValue = this.dataValue;
|
130
|
-
this.choices.
|
130
|
+
this.choices.clearStore();
|
131
131
|
if (dataValue) {
|
132
132
|
if (typeof dataValue === 'string') {
|
133
133
|
dataValue = dataValue.split(this.delimiter).filter(result => result);
|
@@ -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';
|