@formio/js 5.1.0-dev.6030.abc8cfc → 5.1.0-dev.6036.0df1d6a
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 +20 -20
- 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 +21 -21
- 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/_classes/component/Component.d.ts +2 -7
- package/lib/cjs/components/_classes/component/Component.js +23 -17
- package/lib/cjs/components/_classes/nested/NestedComponent.js +2 -5
- package/lib/cjs/components/editgrid/EditGrid.js +0 -4
- package/lib/cjs/components/form/Form.d.ts +1 -1
- package/lib/cjs/components/form/Form.js +5 -1
- package/lib/cjs/components/html/HTML.js +1 -2
- package/lib/cjs/components/select/Select.d.ts +0 -1
- package/lib/cjs/components/select/Select.js +3 -23
- package/lib/cjs/components/tabs/Tabs.js +1 -0
- 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/_classes/component/Component.d.ts +2 -7
- package/lib/mjs/components/_classes/component/Component.js +23 -17
- package/lib/mjs/components/_classes/nested/NestedComponent.js +2 -5
- package/lib/mjs/components/editgrid/EditGrid.js +0 -4
- package/lib/mjs/components/form/Form.d.ts +1 -1
- package/lib/mjs/components/form/Form.js +4 -1
- package/lib/mjs/components/html/HTML.js +1 -2
- package/lib/mjs/components/select/Select.d.ts +0 -1
- package/lib/mjs/components/select/Select.js +3 -22
- package/lib/mjs/components/tabs/Tabs.js +1 -0
- 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
|
}
|
@@ -119,13 +119,6 @@ declare class Component extends Element {
|
|
119
119
|
*/
|
120
120
|
paths: import('@formio/core').ComponentPaths;
|
121
121
|
_path: string;
|
122
|
-
/**
|
123
|
-
* Determines if this component is conditionally hidden. Should generally not be set outside of conditional logic pipeline.
|
124
|
-
* This is necessary because of clearOnHide behavior that only clears when conditionally hidden - we need to track
|
125
|
-
* conditionallyHidden separately from "regular" visibility.
|
126
|
-
*/
|
127
|
-
_parentConditionallyHidden: any;
|
128
|
-
_conditionallyHidden: any;
|
129
122
|
/**
|
130
123
|
* Determines if this component is visible, or not.
|
131
124
|
*/
|
@@ -170,6 +163,7 @@ declare class Component extends Element {
|
|
170
163
|
*/
|
171
164
|
info: any;
|
172
165
|
get componentsMap(): object;
|
166
|
+
get parentConditionallyHidden(): any;
|
173
167
|
set data(value: any);
|
174
168
|
get data(): any;
|
175
169
|
mergeSchema(component?: {}): any;
|
@@ -239,6 +233,7 @@ declare class Component extends Element {
|
|
239
233
|
* @returns {boolean} - Whether the component is conditionally hidden.
|
240
234
|
*/
|
241
235
|
checkConditionallyHidden(data?: object, row?: object): boolean;
|
236
|
+
_conditionallyHidden: any;
|
242
237
|
set currentForm(instance: any);
|
243
238
|
get currentForm(): any;
|
244
239
|
_currentForm: any;
|
@@ -356,8 +356,7 @@ class Component extends Element_1.default {
|
|
356
356
|
* This is necessary because of clearOnHide behavior that only clears when conditionally hidden - we need to track
|
357
357
|
* conditionallyHidden separately from "regular" visibility.
|
358
358
|
*/
|
359
|
-
this.
|
360
|
-
this._conditionallyHidden = this.checkConditionallyHidden(null, data) || this._parentConditionallyHidden;
|
359
|
+
this.checkConditionallyHidden(null, data);
|
361
360
|
/**
|
362
361
|
* Determines if this component is visible, or not.
|
363
362
|
*/
|
@@ -465,6 +464,18 @@ class Component extends Element_1.default {
|
|
465
464
|
var _a;
|
466
465
|
return ((_a = this.root) === null || _a === void 0 ? void 0 : _a.childComponentsMap) || {};
|
467
466
|
}
|
467
|
+
get parentConditionallyHidden() {
|
468
|
+
let parentHidden = false;
|
469
|
+
let currentParent = this.parent;
|
470
|
+
while (currentParent) {
|
471
|
+
parentHidden = parentHidden || currentParent._conditionallyHidden;
|
472
|
+
if (parentHidden) {
|
473
|
+
break;
|
474
|
+
}
|
475
|
+
currentParent = currentParent.parent;
|
476
|
+
}
|
477
|
+
return parentHidden;
|
478
|
+
}
|
468
479
|
get data() {
|
469
480
|
return this._data;
|
470
481
|
}
|
@@ -505,7 +516,7 @@ class Component extends Element_1.default {
|
|
505
516
|
init() {
|
506
517
|
var _a;
|
507
518
|
this.disabled = this.shouldDisabled;
|
508
|
-
this.
|
519
|
+
this.checkConditionallyHidden();
|
509
520
|
this._visible = (this.hasCondition() ? !this.conditionallyHidden : !this.component.hidden);
|
510
521
|
if ((_a = this.component.addons) === null || _a === void 0 ? void 0 : _a.length) {
|
511
522
|
this.component.addons.forEach((addon) => this.createAddon(addon));
|
@@ -672,7 +683,7 @@ class Component extends Element_1.default {
|
|
672
683
|
return this._visible && this._parentVisible;
|
673
684
|
}
|
674
685
|
get conditionallyHidden() {
|
675
|
-
return this._conditionallyHidden || this.
|
686
|
+
return this._conditionallyHidden || this.parentConditionallyHidden;
|
676
687
|
}
|
677
688
|
/**
|
678
689
|
* Evaluates whether the component is conditionally hidden (as opposed to intentionally hidden, e.g. via the `hidden` component schema property).
|
@@ -681,10 +692,13 @@ class Component extends Element_1.default {
|
|
681
692
|
* @returns {boolean} - Whether the component is conditionally hidden.
|
682
693
|
*/
|
683
694
|
checkConditionallyHidden(data = null, row = null) {
|
695
|
+
this._conditionallyHidden = false;
|
684
696
|
if (!this.hasCondition()) {
|
685
|
-
|
697
|
+
this._conditionallyHidden = this.parentConditionallyHidden;
|
698
|
+
return this._conditionallyHidden;
|
686
699
|
}
|
687
|
-
|
700
|
+
this._conditionallyHidden = !this.conditionallyVisible(data, row) || this.parentConditionallyHidden;
|
701
|
+
return this._conditionallyHidden;
|
688
702
|
}
|
689
703
|
get currentForm() {
|
690
704
|
return this._currentForm;
|
@@ -1951,12 +1965,7 @@ class Component extends Element_1.default {
|
|
1951
1965
|
this.redraw();
|
1952
1966
|
}
|
1953
1967
|
// Check advanced conditions (and cache the result)
|
1954
|
-
const
|
1955
|
-
let shouldClear = false;
|
1956
|
-
if (isConditionallyHidden !== this._conditionallyHidden) {
|
1957
|
-
this._conditionallyHidden = isConditionallyHidden;
|
1958
|
-
shouldClear = true;
|
1959
|
-
}
|
1968
|
+
const shouldClear = this.checkConditionallyHidden(data, row);
|
1960
1969
|
// Check visibility
|
1961
1970
|
const visible = (this.hasCondition() ? !this.conditionallyHidden : !this.component.hidden);
|
1962
1971
|
if (this.visible !== visible) {
|
@@ -2494,8 +2503,7 @@ class Component extends Element_1.default {
|
|
2494
2503
|
* @returns {*} - The value for this component.
|
2495
2504
|
*/
|
2496
2505
|
get dataValue() {
|
2497
|
-
if (!this.key
|
2498
|
-
(this.conditionallyHidden && this.component.clearOnHide && !this.rootPristine)) {
|
2506
|
+
if (!this.key) {
|
2499
2507
|
return this.emptyValue;
|
2500
2508
|
}
|
2501
2509
|
if (!this.hasValue() && this.shouldAddDefaultValue) {
|
@@ -2512,9 +2520,7 @@ class Component extends Element_1.default {
|
|
2512
2520
|
* @param {*} value - The value to set for this component.
|
2513
2521
|
*/
|
2514
2522
|
set dataValue(value) {
|
2515
|
-
if (!this.allowData ||
|
2516
|
-
!this.key ||
|
2517
|
-
(this.conditionallyHidden && this.component.clearOnHide && !this.rootPristine)) {
|
2523
|
+
if (!this.allowData || !this.key) {
|
2518
2524
|
return;
|
2519
2525
|
}
|
2520
2526
|
if ((value !== null) && (value !== undefined)) {
|
@@ -85,18 +85,16 @@ class NestedComponent extends Field_1.default {
|
|
85
85
|
const visibilityChanged = this._visible !== value;
|
86
86
|
this._visible = value;
|
87
87
|
const isVisible = this.visible;
|
88
|
-
|
88
|
+
this.checkConditionallyHidden();
|
89
89
|
const forceShow = this.shouldForceShow();
|
90
90
|
const forceHide = this.shouldForceHide();
|
91
91
|
this.components.forEach((component) => {
|
92
92
|
// Set the parent visibility first since we may have nested components within nested components
|
93
93
|
// and they need to be able to determine their visibility based on the parent visibility.
|
94
94
|
component.parentVisible = isVisible;
|
95
|
-
component._parentConditionallyHidden = isConditionallyHidden;
|
96
95
|
let visible;
|
97
96
|
if (component.hasCondition()) {
|
98
|
-
|
99
|
-
visible = !component.conditionallyHidden;
|
97
|
+
visible = !component.checkConditionallyHidden();
|
100
98
|
}
|
101
99
|
else {
|
102
100
|
visible = !component.component.hidden;
|
@@ -377,7 +375,6 @@ class NestedComponent extends Field_1.default {
|
|
377
375
|
data = data || this.data;
|
378
376
|
options.parent = this;
|
379
377
|
options.parentVisible = this.visible;
|
380
|
-
options.parentConditionallyHidden = this.conditionallyHidden;
|
381
378
|
options.root = (options === null || options === void 0 ? void 0 : options.root) || this.root || this;
|
382
379
|
options.localRoot = this.localRoot;
|
383
380
|
options.skipInit = true;
|
@@ -1159,9 +1159,6 @@ class EditGridComponent extends NestedArrayComponent_1.default {
|
|
1159
1159
|
}
|
1160
1160
|
}
|
1161
1161
|
const changed = this.hasChanged(value, this.dataValue);
|
1162
|
-
if (this.parent) {
|
1163
|
-
this.parent.checkComponentConditions();
|
1164
|
-
}
|
1165
1162
|
this.dataValue = value;
|
1166
1163
|
// Refresh editRow data when data changes.
|
1167
1164
|
this.dataValue.forEach((row, rowIndex) => {
|
@@ -1192,7 +1189,6 @@ class EditGridComponent extends NestedArrayComponent_1.default {
|
|
1192
1189
|
this.editRows = this.editRows.slice(0, dataLength);
|
1193
1190
|
this.openWhenEmpty();
|
1194
1191
|
this.updateOnChange(flags, changed);
|
1195
|
-
this.checkData();
|
1196
1192
|
this.changeState(changed, flags);
|
1197
1193
|
return changed;
|
1198
1194
|
}
|
@@ -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));
|
@@ -58,8 +58,7 @@ class HTMLComponent extends Component_1.default {
|
|
58
58
|
super.checkRefreshOn(changed);
|
59
59
|
let visible;
|
60
60
|
if (this.hasCondition()) {
|
61
|
-
|
62
|
-
visible = !this.conditionallyHidden;
|
61
|
+
visible = !this.checkConditionallyHidden();
|
63
62
|
}
|
64
63
|
else {
|
65
64
|
visible = !this.component.hidden;
|
@@ -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') {
|
@@ -143,6 +143,7 @@ class TabsComponent extends NestedComponent_1.default {
|
|
143
143
|
this.addClass(this.refs[this.tabLinkKey][index], 'active');
|
144
144
|
this.addClass(this.refs[this.tabLinkKey][index], 'formio-tab-link-active');
|
145
145
|
}
|
146
|
+
this.setValue(this.data);
|
146
147
|
this.triggerChange();
|
147
148
|
}
|
148
149
|
beforeFocus(component) {
|
@@ -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
|
*/
|