@formio/js 5.1.0-dev.6026.929ea40 → 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.
Files changed (48) hide show
  1. package/dist/formio.builder.css +15 -17
  2. package/dist/formio.builder.min.css +1 -1
  3. package/dist/formio.form.css +15 -17
  4. package/dist/formio.form.js +17 -17
  5. package/dist/formio.form.min.css +1 -1
  6. package/dist/formio.form.min.js +1 -1
  7. package/dist/formio.form.min.js.LICENSE.txt +2 -2
  8. package/dist/formio.full.css +15 -17
  9. package/dist/formio.full.js +18 -18
  10. package/dist/formio.full.min.css +1 -1
  11. package/dist/formio.full.min.js +1 -1
  12. package/dist/formio.full.min.js.LICENSE.txt +2 -2
  13. package/dist/formio.js +1 -1
  14. package/dist/formio.min.js +1 -1
  15. package/dist/formio.min.js.LICENSE.txt +1 -1
  16. package/dist/formio.utils.js +1 -1
  17. package/dist/formio.utils.min.js +1 -1
  18. package/dist/formio.utils.min.js.LICENSE.txt +1 -1
  19. package/lib/cjs/Form.d.ts +2 -4
  20. package/lib/cjs/Webform.d.ts +1 -1
  21. package/lib/cjs/Webform.js +5 -3
  22. package/lib/cjs/Wizard.js +1 -0
  23. package/lib/cjs/WizardBuilder.d.ts +0 -1
  24. package/lib/cjs/WizardBuilder.js +7 -9
  25. package/lib/cjs/components/form/Form.d.ts +1 -1
  26. package/lib/cjs/components/form/Form.js +5 -1
  27. package/lib/cjs/components/select/Select.d.ts +0 -1
  28. package/lib/cjs/components/select/Select.js +3 -23
  29. package/lib/cjs/components/tags/Tags.d.ts +1 -1
  30. package/lib/cjs/components/tags/Tags.js +2 -2
  31. package/lib/cjs/utils/ChoicesWrapper.d.ts +4 -25
  32. package/lib/cjs/utils/ChoicesWrapper.js +47 -124
  33. package/lib/mjs/Form.d.ts +2 -4
  34. package/lib/mjs/Form.js +1 -1
  35. package/lib/mjs/Webform.d.ts +1 -1
  36. package/lib/mjs/Webform.js +5 -3
  37. package/lib/mjs/Wizard.js +1 -0
  38. package/lib/mjs/WizardBuilder.d.ts +0 -1
  39. package/lib/mjs/WizardBuilder.js +7 -9
  40. package/lib/mjs/components/form/Form.d.ts +1 -1
  41. package/lib/mjs/components/form/Form.js +4 -1
  42. package/lib/mjs/components/select/Select.d.ts +0 -1
  43. package/lib/mjs/components/select/Select.js +3 -22
  44. package/lib/mjs/components/tags/Tags.d.ts +1 -1
  45. package/lib/mjs/components/tags/Tags.js +2 -2
  46. package/lib/mjs/utils/ChoicesWrapper.d.ts +4 -25
  47. package/lib/mjs/utils/ChoicesWrapper.js +26 -119
  48. package/package.json +2 -2
@@ -18,7 +18,7 @@
18
18
  * MIT licensed
19
19
  */
20
20
 
21
- /*! @license DOMPurify 3.2.3 | (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.3/LICENSE */
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 {{[key: string]: string}} [i18n] - The translation file for this rendering.
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
  */
@@ -455,7 +455,7 @@ declare class Webform extends NestedDataComponent {
455
455
  */
456
456
  submit(before?: boolean, options?: any): Promise<any>;
457
457
  submitUrl(URL: any, headers: any): void;
458
- triggerCaptcha(): void;
458
+ triggerCaptcha(components?: null): void;
459
459
  _nosubmit: any;
460
460
  get conditions(): any;
461
461
  get variables(): any;
@@ -1534,17 +1534,20 @@ class Webform extends NestedDataComponent_1.default {
1534
1534
  return console.warn(message);
1535
1535
  }
1536
1536
  }
1537
- triggerCaptcha() {
1537
+ triggerCaptcha(components = null) {
1538
1538
  if (!this || !this.components || this.options.preview) {
1539
1539
  return;
1540
1540
  }
1541
1541
  const captchaComponent = [];
1542
- (0, formUtils_1.eachComponent)(this.components, (component) => {
1542
+ (0, formUtils_1.eachComponent)(components || this.components, (component) => {
1543
1543
  if (/^(re)?captcha$/.test(component.type) && component.component.eventType === 'formLoad') {
1544
1544
  captchaComponent.push(component);
1545
1545
  }
1546
1546
  }, true);
1547
1547
  if (captchaComponent.length > 0) {
1548
+ if (captchaComponent[0].component.provider === 'google' && components) {
1549
+ return;
1550
+ }
1548
1551
  if (this.parent) {
1549
1552
  this.parent.subFormReady.then(() => {
1550
1553
  captchaComponent[0].verify(`${this.form.name ? this.form.name : 'form'}Load`);
@@ -1553,7 +1556,6 @@ class Webform extends NestedDataComponent_1.default {
1553
1556
  else {
1554
1557
  captchaComponent[0].verify(`${this.form.name ? this.form.name : 'form'}Load`);
1555
1558
  }
1556
- ;
1557
1559
  }
1558
1560
  }
1559
1561
  set nosubmit(value) {
package/lib/cjs/Wizard.js CHANGED
@@ -602,6 +602,7 @@ class Wizard extends Webform_1.default {
602
602
  }
603
603
  this.redraw().then(() => {
604
604
  this.checkData(this.submission.data);
605
+ this.triggerCaptcha(this.currentPanel.components);
605
606
  const errors = this.submitted ? this.validate(this.localData, { dirty: true }) : this.validateCurrentPage();
606
607
  if (this.alert) {
607
608
  this.showErrors(errors, true, true);
@@ -46,6 +46,5 @@ export default class WizardBuilder extends WebformBuilder {
46
46
  components: any[];
47
47
  };
48
48
  pasteComponent(component: any): void;
49
- copyComponent(component: any): void;
50
49
  }
51
50
  import WebformBuilder from './WebformBuilder';
@@ -264,24 +264,22 @@ class WizardBuilder extends WebformBuilder_1.default {
264
264
  if (!window.sessionStorage) {
265
265
  return console.warn(this.t('sessionStorageSupportError'));
266
266
  }
267
- const isWizardPageCopied = window.sessionStorage.getItem('formio.isWizardPageCopied') === 'true' ? true : false;
268
- if (isWizardPageCopied) {
267
+ // If pasting after the Wizard's page, check if a full Wizard page was copied and pass it to addPage method
268
+ if (this._form.components.find(comp => lodash_1.default.isEqual(component.component, comp))) {
269
269
  const data = window.sessionStorage.getItem('formio.clipboard');
270
270
  if (data) {
271
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
+ }
272
276
  this.addPage(schema);
273
277
  }
274
278
  }
275
279
  else {
280
+ // If we are not trying to paster after the current Wizard's page, just pass it to the WebformBuilder
276
281
  return super.pasteComponent(component);
277
282
  }
278
283
  }
279
- copyComponent(component) {
280
- super.copyComponent(component);
281
- if (window.sessionStorage) {
282
- const isWizardPageCopied = this._form.components.indexOf(comp => lodash_1.default.isEqual(component.component, comp)) !== -1;
283
- window.sessionStorage.setItem('formio.isWizardPageCopied', isWizardPageCopied.toString());
284
- }
285
- }
286
284
  }
287
285
  exports.default = WizardBuilder;
@@ -13,7 +13,7 @@ export default class FormComponent extends Component {
13
13
  valueChanged: boolean | undefined;
14
14
  subForm: any;
15
15
  formSrc: any;
16
- get dataReady(): Promise<any>;
16
+ get dataReady(): any;
17
17
  get emptyValue(): {
18
18
  data: {};
19
19
  };
@@ -102,7 +102,8 @@ class FormComponent extends Component_1.default {
102
102
  return this.createSubForm();
103
103
  }
104
104
  get dataReady() {
105
- return this.subFormReady || Promise.resolve();
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') {
@@ -24,4 +24,4 @@ export default class TagsComponent extends Input {
24
24
  getValueAsString(value: any): any;
25
25
  }
26
26
  import Input from '../_classes/input/Input';
27
- import Choices from '@formio/choices.js';
27
+ import Choices from 'choices.js';
@@ -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("@formio/choices.js"));
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.removeActiveItems();
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({ activeItems, hasActiveDropdown }: {
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
- _handleButtonAction(activeItems: any, element: any): void;
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({ event, activeItems, hasActiveDropdown }: {
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 '@formio/choices.js';
17
+ import Choices from 'choices.js';
@@ -1,48 +1,30 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.KEY_CODES = void 0;
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
- const { placeholder, placeholderValue } = this.config;
23
- const { element: { dataset }, } = this.passedElement;
24
- if (placeholder) {
25
- if (placeholderValue) {
26
- return placeholderValue;
27
- }
28
- if (dataset.placeholder) {
29
- return dataset.placeholder;
30
- }
31
- }
32
- return false;
33
- };
34
- exports.KEY_CODES = {
35
- BACK_KEY: 46,
36
- DELETE_KEY: 8,
37
- TAB_KEY: 9,
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
- _handleButtonAction(activeItems, element) {
73
- if (!this._isSelectOneElement) {
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 (args.event.target.className === 'choices__button') {
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({ activeItems, hasActiveDropdown }) {
104
- if (hasActiveDropdown) {
105
- this._selectHighlightedChoice(activeItems);
74
+ _onTabKey() {
75
+ if (this.dropdown.isActive) {
76
+ this._selectHighlightedChoice();
106
77
  }
107
78
  }
108
79
  _selectHighlightedChoice() {
109
- const highlightedChoice = this.dropdown.getChild(`.${this.config.classNames.highlightedState}`);
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
- if (!this._isSelectOneElement) {
128
- return super._onKeyDown(event);
129
- }
130
- const { target, keyCode, ctrlKey, metaKey } = event;
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({ event, activeItems, hasActiveDropdown }) {
103
+ onSelectValue(event, hasActiveDropdown) {
177
104
  if (hasActiveDropdown) {
178
- this._selectHighlightedChoice(activeItems);
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
- if (!this.shouldOpenDropDown) {
187
- this.shouldOpenDropDown = true;
188
- return;
189
- }
190
- super.showDropdown(...args);
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 {{[key: string]: string}} [i18n] - The translation file for this rendering.
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 {{[key: string]: string}} [i18n] - The translation file for this rendering.
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.
@@ -455,7 +455,7 @@ declare class Webform extends NestedDataComponent {
455
455
  */
456
456
  submit(before?: boolean, options?: any): Promise<any>;
457
457
  submitUrl(URL: any, headers: any): void;
458
- triggerCaptcha(): void;
458
+ triggerCaptcha(components?: null): void;
459
459
  _nosubmit: any;
460
460
  get conditions(): any;
461
461
  get variables(): any;
@@ -1534,17 +1534,20 @@ export default class Webform extends NestedDataComponent {
1534
1534
  return console.warn(message);
1535
1535
  }
1536
1536
  }
1537
- triggerCaptcha() {
1537
+ triggerCaptcha(components = null) {
1538
1538
  if (!this || !this.components || this.options.preview) {
1539
1539
  return;
1540
1540
  }
1541
1541
  const captchaComponent = [];
1542
- eachComponent(this.components, (component) => {
1542
+ eachComponent(components || this.components, (component) => {
1543
1543
  if (/^(re)?captcha$/.test(component.type) && component.component.eventType === 'formLoad') {
1544
1544
  captchaComponent.push(component);
1545
1545
  }
1546
1546
  }, true);
1547
1547
  if (captchaComponent.length > 0) {
1548
+ if (captchaComponent[0].component.provider === 'google' && components) {
1549
+ return;
1550
+ }
1548
1551
  if (this.parent) {
1549
1552
  this.parent.subFormReady.then(() => {
1550
1553
  captchaComponent[0].verify(`${this.form.name ? this.form.name : 'form'}Load`);
@@ -1553,7 +1556,6 @@ export default class Webform extends NestedDataComponent {
1553
1556
  else {
1554
1557
  captchaComponent[0].verify(`${this.form.name ? this.form.name : 'form'}Load`);
1555
1558
  }
1556
- ;
1557
1559
  }
1558
1560
  }
1559
1561
  set nosubmit(value) {
package/lib/mjs/Wizard.js CHANGED
@@ -594,6 +594,7 @@ export default class Wizard extends Webform {
594
594
  }
595
595
  this.redraw().then(() => {
596
596
  this.checkData(this.submission.data);
597
+ this.triggerCaptcha(this.currentPanel.components);
597
598
  const errors = this.submitted ? this.validate(this.localData, { dirty: true }) : this.validateCurrentPage();
598
599
  if (this.alert) {
599
600
  this.showErrors(errors, true, true);
@@ -46,6 +46,5 @@ export default class WizardBuilder extends WebformBuilder {
46
46
  components: any[];
47
47
  };
48
48
  pasteComponent(component: any): void;
49
- copyComponent(component: any): void;
50
49
  }
51
50
  import WebformBuilder from './WebformBuilder';
@@ -258,23 +258,21 @@ export default class WizardBuilder extends WebformBuilder {
258
258
  if (!window.sessionStorage) {
259
259
  return console.warn(this.t('sessionStorageSupportError'));
260
260
  }
261
- const isWizardPageCopied = window.sessionStorage.getItem('formio.isWizardPageCopied') === 'true' ? true : false;
262
- if (isWizardPageCopied) {
261
+ // If pasting after the Wizard's page, check if a full Wizard page was copied and pass it to addPage method
262
+ if (this._form.components.find(comp => _.isEqual(component.component, comp))) {
263
263
  const data = window.sessionStorage.getItem('formio.clipboard');
264
264
  if (data) {
265
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
+ }
266
270
  this.addPage(schema);
267
271
  }
268
272
  }
269
273
  else {
274
+ // If we are not trying to paster after the current Wizard's page, just pass it to the WebformBuilder
270
275
  return super.pasteComponent(component);
271
276
  }
272
277
  }
273
- copyComponent(component) {
274
- super.copyComponent(component);
275
- if (window.sessionStorage) {
276
- const isWizardPageCopied = this._form.components.indexOf(comp => _.isEqual(component.component, comp)) !== -1;
277
- window.sessionStorage.setItem('formio.isWizardPageCopied', isWizardPageCopied.toString());
278
- }
279
- }
280
278
  }
@@ -13,7 +13,7 @@ export default class FormComponent extends Component {
13
13
  valueChanged: boolean | undefined;
14
14
  subForm: any;
15
15
  formSrc: any;
16
- get dataReady(): Promise<any>;
16
+ get dataReady(): any;
17
17
  get emptyValue(): {
18
18
  data: {};
19
19
  };