@formio/js 5.1.0-dev.6058.189ce78 → 5.1.0-dev.6059.845a6e3

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 (166) hide show
  1. package/Changelog.md +13 -131
  2. package/README.md +1 -28
  3. package/dist/formio.builder.css +17 -19
  4. package/dist/formio.builder.min.css +1 -1
  5. package/dist/formio.embed.js +1 -1
  6. package/dist/formio.embed.min.js +1 -1
  7. package/dist/formio.embed.min.js.LICENSE.txt +1 -1
  8. package/dist/formio.form.css +17 -19
  9. package/dist/formio.form.js +176 -102
  10. package/dist/formio.form.min.css +1 -1
  11. package/dist/formio.form.min.js +1 -1
  12. package/dist/formio.form.min.js.LICENSE.txt +3 -3
  13. package/dist/formio.full.css +17 -19
  14. package/dist/formio.full.js +86 -108
  15. package/dist/formio.full.min.css +2 -2
  16. package/dist/formio.full.min.js +1 -1
  17. package/dist/formio.full.min.js.LICENSE.txt +3 -3
  18. package/dist/formio.js +10 -10
  19. package/dist/formio.min.js +1 -1
  20. package/dist/formio.min.js.LICENSE.txt +1 -1
  21. package/dist/formio.utils.js +3 -3
  22. package/dist/formio.utils.min.js +1 -1
  23. package/dist/formio.utils.min.js.LICENSE.txt +1 -1
  24. package/lib/cjs/CDN.d.ts +1 -1
  25. package/lib/cjs/CDN.js +2 -2
  26. package/lib/cjs/Embed.js +1 -1
  27. package/lib/cjs/Form.d.ts +6 -4
  28. package/lib/cjs/Form.js +8 -16
  29. package/lib/cjs/Formio.js +1 -1
  30. package/lib/cjs/PDFBuilder.js +4 -4
  31. package/lib/cjs/Webform.d.ts +13 -16
  32. package/lib/cjs/Webform.js +148 -162
  33. package/lib/cjs/WebformBuilder.js +28 -17
  34. package/lib/cjs/Wizard.js +1 -1
  35. package/lib/cjs/WizardBuilder.js +2 -15
  36. package/lib/cjs/components/Components.d.ts +0 -3
  37. package/lib/cjs/components/_classes/component/Component.d.ts +0 -1
  38. package/lib/cjs/components/_classes/component/Component.js +11 -38
  39. package/lib/cjs/components/_classes/component/editForm/Component.edit.conditional.js +1 -1
  40. package/lib/cjs/components/_classes/component/editForm/Component.edit.data.d.ts +0 -37
  41. package/lib/cjs/components/_classes/component/editForm/Component.edit.data.js +2 -32
  42. package/lib/cjs/components/_classes/component/editForm/utils.d.ts +0 -1
  43. package/lib/cjs/components/_classes/component/editForm/utils.js +0 -3
  44. package/lib/cjs/components/_classes/input/Input.js +1 -23
  45. package/lib/cjs/components/_classes/list/ListComponent.js +4 -4
  46. package/lib/cjs/components/_classes/multivalue/Multivalue.d.ts +1 -1
  47. package/lib/cjs/components/_classes/multivalue/Multivalue.js +3 -10
  48. package/lib/cjs/components/_classes/nestedarray/NestedArrayComponent.d.ts +0 -2
  49. package/lib/cjs/components/_classes/nestedarray/NestedArrayComponent.js +31 -52
  50. package/lib/cjs/components/address/Address.js +1 -1
  51. package/lib/cjs/components/button/Button.js +6 -6
  52. package/lib/cjs/components/checkbox/Checkbox.d.ts +1 -1
  53. package/lib/cjs/components/checkbox/Checkbox.js +2 -2
  54. package/lib/cjs/components/datagrid/DataGrid.d.ts +0 -2
  55. package/lib/cjs/components/datagrid/DataGrid.js +26 -41
  56. package/lib/cjs/components/day/Day.js +7 -9
  57. package/lib/cjs/components/editgrid/EditGrid.d.ts +1 -1
  58. package/lib/cjs/components/editgrid/EditGrid.js +8 -26
  59. package/lib/cjs/components/file/File.d.ts +1 -1
  60. package/lib/cjs/components/file/File.js +17 -23
  61. package/lib/cjs/components/form/Form.d.ts +1 -1
  62. package/lib/cjs/components/form/Form.js +5 -9
  63. package/lib/cjs/components/form/editForm/Form.edit.form.js +3 -3
  64. package/lib/cjs/components/hidden/Hidden.d.ts +1 -0
  65. package/lib/cjs/components/hidden/Hidden.js +1 -1
  66. package/lib/cjs/components/number/Number.js +5 -12
  67. package/lib/cjs/components/radio/Radio.js +0 -10
  68. package/lib/cjs/components/recaptcha/ReCaptcha.js +2 -2
  69. package/lib/cjs/components/select/Select.d.ts +1 -0
  70. package/lib/cjs/components/select/Select.js +33 -12
  71. package/lib/cjs/components/select/editForm/Select.edit.data.d.ts +1 -1
  72. package/lib/cjs/components/select/editForm/Select.edit.data.js +2 -3
  73. package/lib/cjs/components/selectboxes/SelectBoxes.js +2 -2
  74. package/lib/cjs/components/signature/Signature.d.ts +1 -1
  75. package/lib/cjs/components/signature/Signature.js +3 -5
  76. package/lib/cjs/components/signature/editForm/Signature.edit.display.d.ts +6 -0
  77. package/lib/cjs/components/signature/editForm/Signature.edit.display.js +1 -0
  78. package/lib/cjs/components/survey/Survey.js +2 -2
  79. package/lib/cjs/components/tags/Tags.d.ts +1 -1
  80. package/lib/cjs/components/tags/Tags.js +2 -2
  81. package/lib/cjs/components/textarea/TextArea.js +6 -6
  82. package/lib/cjs/formio.form.js +0 -5
  83. package/lib/cjs/providers/storage/googleDrive.js +2 -3
  84. package/lib/cjs/providers/storage/s3.js +3 -3
  85. package/lib/cjs/providers/storage/xhr.d.ts +0 -1
  86. package/lib/cjs/providers/storage/xhr.js +1 -6
  87. package/lib/cjs/translations/en.d.ts +81 -234
  88. package/lib/cjs/translations/en.js +81 -8
  89. package/lib/cjs/utils/ChoicesWrapper.d.ts +25 -4
  90. package/lib/cjs/utils/ChoicesWrapper.js +124 -47
  91. package/lib/cjs/utils/formUtils.d.ts +2 -2
  92. package/lib/cjs/utils/i18n.d.ts +2 -5
  93. package/lib/cjs/utils/i18n.js +5 -32
  94. package/lib/cjs/widgets/CalendarWidget.js +27 -27
  95. package/lib/mjs/CDN.d.ts +1 -1
  96. package/lib/mjs/CDN.js +2 -2
  97. package/lib/mjs/Embed.js +1 -1
  98. package/lib/mjs/Form.d.ts +6 -4
  99. package/lib/mjs/Form.js +9 -17
  100. package/lib/mjs/Formio.js +1 -1
  101. package/lib/mjs/PDFBuilder.js +4 -4
  102. package/lib/mjs/Webform.d.ts +13 -16
  103. package/lib/mjs/Webform.js +158 -171
  104. package/lib/mjs/WebformBuilder.js +28 -17
  105. package/lib/mjs/Wizard.js +1 -1
  106. package/lib/mjs/WizardBuilder.js +2 -15
  107. package/lib/mjs/components/Components.d.ts +0 -3
  108. package/lib/mjs/components/_classes/component/Component.d.ts +0 -1
  109. package/lib/mjs/components/_classes/component/Component.js +11 -27
  110. package/lib/mjs/components/_classes/component/editForm/Component.edit.conditional.js +1 -1
  111. package/lib/mjs/components/_classes/component/editForm/Component.edit.data.d.ts +0 -37
  112. package/lib/mjs/components/_classes/component/editForm/Component.edit.data.js +2 -32
  113. package/lib/mjs/components/_classes/component/editForm/utils.d.ts +0 -1
  114. package/lib/mjs/components/_classes/component/editForm/utils.js +0 -3
  115. package/lib/mjs/components/_classes/input/Input.js +1 -22
  116. package/lib/mjs/components/_classes/list/ListComponent.js +4 -4
  117. package/lib/mjs/components/_classes/multivalue/Multivalue.d.ts +1 -1
  118. package/lib/mjs/components/_classes/multivalue/Multivalue.js +3 -10
  119. package/lib/mjs/components/_classes/nestedarray/NestedArrayComponent.d.ts +0 -2
  120. package/lib/mjs/components/_classes/nestedarray/NestedArrayComponent.js +31 -53
  121. package/lib/mjs/components/address/Address.js +1 -1
  122. package/lib/mjs/components/button/Button.js +6 -6
  123. package/lib/mjs/components/checkbox/Checkbox.d.ts +1 -1
  124. package/lib/mjs/components/checkbox/Checkbox.js +2 -2
  125. package/lib/mjs/components/datagrid/DataGrid.d.ts +0 -2
  126. package/lib/mjs/components/datagrid/DataGrid.js +26 -41
  127. package/lib/mjs/components/day/Day.js +7 -9
  128. package/lib/mjs/components/editgrid/EditGrid.d.ts +1 -1
  129. package/lib/mjs/components/editgrid/EditGrid.js +7 -25
  130. package/lib/mjs/components/file/File.d.ts +1 -1
  131. package/lib/mjs/components/file/File.js +17 -23
  132. package/lib/mjs/components/form/Form.d.ts +1 -1
  133. package/lib/mjs/components/form/Form.js +5 -8
  134. package/lib/mjs/components/form/editForm/Form.edit.form.js +3 -3
  135. package/lib/mjs/components/hidden/Hidden.d.ts +1 -0
  136. package/lib/mjs/components/hidden/Hidden.js +1 -1
  137. package/lib/mjs/components/number/Number.js +5 -12
  138. package/lib/mjs/components/radio/Radio.js +0 -10
  139. package/lib/mjs/components/recaptcha/ReCaptcha.js +2 -2
  140. package/lib/mjs/components/select/Select.d.ts +1 -0
  141. package/lib/mjs/components/select/Select.js +34 -14
  142. package/lib/mjs/components/select/editForm/Select.edit.data.d.ts +1 -1
  143. package/lib/mjs/components/select/editForm/Select.edit.data.js +2 -3
  144. package/lib/mjs/components/selectboxes/SelectBoxes.js +2 -2
  145. package/lib/mjs/components/signature/Signature.d.ts +1 -1
  146. package/lib/mjs/components/signature/Signature.js +3 -5
  147. package/lib/mjs/components/signature/editForm/Signature.edit.display.d.ts +6 -0
  148. package/lib/mjs/components/signature/editForm/Signature.edit.display.js +1 -0
  149. package/lib/mjs/components/survey/Survey.js +2 -2
  150. package/lib/mjs/components/tags/Tags.d.ts +1 -1
  151. package/lib/mjs/components/tags/Tags.js +2 -2
  152. package/lib/mjs/components/textarea/TextArea.js +6 -6
  153. package/lib/mjs/formio.form.js +0 -5
  154. package/lib/mjs/providers/storage/googleDrive.js +2 -3
  155. package/lib/mjs/providers/storage/s3.js +3 -3
  156. package/lib/mjs/providers/storage/xhr.d.ts +0 -1
  157. package/lib/mjs/providers/storage/xhr.js +1 -6
  158. package/lib/mjs/translations/en.d.ts +81 -234
  159. package/lib/mjs/translations/en.js +1 -87
  160. package/lib/mjs/utils/ChoicesWrapper.d.ts +25 -4
  161. package/lib/mjs/utils/ChoicesWrapper.js +119 -26
  162. package/lib/mjs/utils/formUtils.d.ts +2 -2
  163. package/lib/mjs/utils/i18n.d.ts +2 -5
  164. package/lib/mjs/utils/i18n.js +5 -32
  165. package/lib/mjs/widgets/CalendarWidget.js +27 -27
  166. package/package.json +11 -27
@@ -1,30 +1,48 @@
1
1
  "use strict";
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]; } };
7
- }
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;
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
24
4
  };
25
5
  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 });
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;
21
+ }
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,
45
+ };
28
46
  class ChoicesWrapper extends choices_js_1.default {
29
47
  constructor(...args) {
30
48
  super(...args);
@@ -51,13 +69,24 @@ class ChoicesWrapper extends choices_js_1.default {
51
69
  }
52
70
  this._wasTap = true;
53
71
  }
54
- _onEnterKey(...args) {
55
- const [event] = args;
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) {
56
85
  // Prevent dropdown form opening when removeItemButton was pressed using 'Enter' on keyboard
57
- if (event.target.className === 'choices__button') {
86
+ if (args.event.target.className === 'choices__button') {
58
87
  this.shouldOpenDropDown = false;
59
88
  }
60
- super._onEnterKey(...args);
89
+ super._onEnterKey(args);
61
90
  }
62
91
  _onDirectionKey(...args) {
63
92
  if (!this._isSelectOneElement) {
@@ -71,18 +100,17 @@ class ChoicesWrapper extends choices_js_1.default {
71
100
  this.isDirectionUsing = false;
72
101
  }, 250);
73
102
  }
74
- _onTabKey() {
75
- if (this.dropdown.isActive) {
76
- this._selectHighlightedChoice();
103
+ _onTabKey({ activeItems, hasActiveDropdown }) {
104
+ if (hasActiveDropdown) {
105
+ this._selectHighlightedChoice(activeItems);
77
106
  }
78
107
  }
79
108
  _selectHighlightedChoice() {
80
- const highlightedChoice = this.dropdown.element.querySelector(`.${this.config.classNames.highlightedState}`);
109
+ const highlightedChoice = this.dropdown.getChild(`.${this.config.classNames.highlightedState}`);
81
110
  if (highlightedChoice) {
82
111
  const id = highlightedChoice.dataset.id;
83
- const choice = id && this._store.getChoiceById(Number(id));
112
+ const choice = id && this._store.getChoiceById(id);
84
113
  this._addItem({
85
- id: choice.id,
86
114
  value: choice.value,
87
115
  label: choice.label,
88
116
  choiceId: choice.id,
@@ -93,16 +121,61 @@ class ChoicesWrapper extends choices_js_1.default {
93
121
  });
94
122
  this._triggerChange(choice.value);
95
123
  }
124
+ event.preventDefault();
96
125
  }
97
126
  _onKeyDown(event) {
98
- const keyCode = event.keyCode;
99
- return this._isSelectOneElement && keyCode === ExtendedKeyCodeMap.TAB_KEY
100
- ? this._onTabKey()
101
- : super._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
+ }
102
175
  }
103
- onSelectValue(event, hasActiveDropdown) {
176
+ onSelectValue({ event, activeItems, hasActiveDropdown }) {
104
177
  if (hasActiveDropdown) {
105
- this._selectHighlightedChoice();
178
+ this._selectHighlightedChoice(activeItems);
106
179
  }
107
180
  else if (this._isSelectOneElement) {
108
181
  this.showDropdown();
@@ -110,13 +183,11 @@ class ChoicesWrapper extends choices_js_1.default {
110
183
  }
111
184
  }
112
185
  showDropdown(...args) {
113
- setTimeout(() => {
114
- if (!this.shouldOpenDropDown) {
115
- this.shouldOpenDropDown = true;
116
- return;
117
- }
118
- super.showDropdown(...args);
119
- }, 0);
186
+ if (!this.shouldOpenDropDown) {
187
+ this.shouldOpenDropDown = true;
188
+ return;
189
+ }
190
+ super.showDropdown(...args);
120
191
  }
121
192
  hideDropdown(...args) {
122
193
  if (this.isDirectionUsing) {
@@ -124,5 +195,11 @@ class ChoicesWrapper extends choices_js_1.default {
124
195
  }
125
196
  super.hideDropdown(...args);
126
197
  }
198
+ _onBlur(...args) {
199
+ if (this._isScrollingOnIe) {
200
+ return;
201
+ }
202
+ super._onBlur(...args);
203
+ }
127
204
  }
128
205
  exports.default = ChoicesWrapper;
@@ -26,8 +26,8 @@ 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: Component[], data: DataObject, fn: EachComponentDataAsyncCallback, includeAll?: boolean | undefined, local?: boolean | undefined, parent?: any, parentPaths?: any) => Promise<void>;
30
- export const eachComponentData: (components: Component[], data: DataObject, fn: EachComponentDataCallback, includeAll?: boolean | undefined, local?: boolean | undefined, parent?: any, parentPaths?: any) => 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) => 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;
31
31
  export const getComponentKey: typeof Utils.getComponentKey;
32
32
  export const getContextualRowPath: typeof Utils.getContextualRowPath;
33
33
  export const getContextualRowData: typeof Utils.getContextualRowData;
@@ -2,16 +2,13 @@
2
2
  * This file is used to mimic the i18n library interface.
3
3
  */
4
4
  export class I18n {
5
- static languages: {};
6
- static setDefaultTranslations(languages: any): void;
7
5
  static init(languages?: {}): I18n;
8
6
  static createInstance(): I18n;
9
7
  constructor(languages?: {});
10
- languages: any;
11
- defaultKeys: any;
8
+ languages: {};
12
9
  language: string;
13
10
  currentLanguage: any;
14
- setLanguages(languages: any, noDefaultOverride: any): void;
11
+ setLanguages(languages: any): void;
15
12
  dir(lang?: string): "rtl" | "ltr";
16
13
  changeLanguage(language: any, ready?: null): void;
17
14
  addResourceBundle(language: any, type: any, strings: any): void;
@@ -6,8 +6,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.I18n = void 0;
7
7
  const utils_1 = require("@formio/core/utils");
8
8
  const i18n_1 = __importDefault(require("../i18n"));
9
- const lodash_1 = require("lodash");
10
- const core_1 = require("@formio/core");
11
9
  const i18Defaults = {};
12
10
  for (const lang in i18n_1.default.resources) {
13
11
  if (i18n_1.default.resources.hasOwnProperty(lang)) {
@@ -19,28 +17,13 @@ for (const lang in i18n_1.default.resources) {
19
17
  */
20
18
  class I18n {
21
19
  constructor(languages = {}) {
22
- var _a;
23
- this.languages = (0, core_1.fastCloneDeep)(I18n.languages || {});
24
- this.defaultKeys = ((_a = I18n.languages) === null || _a === void 0 ? void 0 : _a.en) || {};
20
+ this.languages = i18Defaults;
25
21
  this.language = 'en';
26
22
  this.currentLanguage = i18Defaults.en;
27
23
  this.setLanguages(languages);
28
24
  this.changeLanguage(this.language);
29
25
  }
30
- static setDefaultTranslations(languages) {
31
- if ((0, lodash_1.isEmpty)(languages)) {
32
- return;
33
- }
34
- for (const lang in languages) {
35
- if (lang !== 'language' && languages.hasOwnProperty(lang)) {
36
- if (!this.languages[lang]) {
37
- this.languages[lang] = {};
38
- }
39
- this.languages[lang] = Object.assign(Object.assign({}, languages[lang]), this.languages[lang]);
40
- }
41
- }
42
- }
43
- setLanguages(languages, noDefaultOverride) {
26
+ setLanguages(languages) {
44
27
  if (languages.resources) {
45
28
  for (const lang in languages.resources) {
46
29
  if (languages.resources.hasOwnProperty(lang)) {
@@ -67,8 +50,7 @@ class I18n {
67
50
  if (!this.languages[lang]) {
68
51
  this.languages[lang] = {};
69
52
  }
70
- this.languages[lang] = noDefaultOverride
71
- ? Object.assign(Object.assign({}, languages[lang]), this.languages[lang]) : Object.assign(Object.assign({}, this.languages[lang]), languages[lang]);
53
+ this.languages[lang] = Object.assign(Object.assign({}, this.languages[lang]), languages[lang]);
72
54
  }
73
55
  }
74
56
  }
@@ -98,23 +80,14 @@ class I18n {
98
80
  }
99
81
  t(text, ...args) {
100
82
  var _a;
101
- let currentTranslation = this.currentLanguage[text];
102
- // provide compatibility with cases where the entire phrase is used as a key
103
- // get the phrase that is possibly being used as a key
104
- const defaultKey = this.defaultKeys[text];
105
- if (defaultKey && this.currentLanguage[defaultKey]) {
106
- // get translation using the phrase as a key
107
- currentTranslation = this.currentLanguage[defaultKey];
108
- }
109
- if (currentTranslation) {
83
+ if (this.currentLanguage[text]) {
110
84
  const customTranslationFieldName = (_a = args[0]) === null || _a === void 0 ? void 0 : _a.field;
111
85
  if (customTranslationFieldName && this.currentLanguage[customTranslationFieldName]) {
112
86
  args[0].field = this.currentLanguage[customTranslationFieldName];
113
87
  }
114
- return utils_1.Evaluator.interpolateString(currentTranslation, ...args);
88
+ return utils_1.Evaluator.interpolateString(this.currentLanguage[text], ...args);
115
89
  }
116
90
  return utils_1.Evaluator.interpolateString(text, ...args);
117
91
  }
118
92
  }
119
93
  exports.I18n = I18n;
120
- I18n.languages = i18Defaults;
@@ -93,6 +93,8 @@ class CalendarWidget extends InputWidget_1.default {
93
93
  this.settings.disableWeekends ? this.settings.disable.push(this.disableWeekends) : '';
94
94
  this.settings.disableWeekdays ? this.settings.disable.push(this.disableWeekdays) : '';
95
95
  this.settings.disableFunction ? this.settings.disable.push(this.disableFunction) : '';
96
+ this.settings.wasDefaultValueChanged = false;
97
+ this.settings.defaultValue = '';
96
98
  this.settings.manualInputValue = '';
97
99
  this.settings.isManuallyOverriddenValue = false;
98
100
  this.settings.currentValue = '';
@@ -100,8 +102,14 @@ class CalendarWidget extends InputWidget_1.default {
100
102
  this.settings.dateFormat = (0, utils_1.convertFormatToFlatpickr)(this.settings.dateFormat);
101
103
  this.settings.position = 'auto center';
102
104
  this.settings.onChange = () => {
103
- if (this.settings.allowInput && this.settings.enableTime) {
104
- this.calendar._input.value = this.settings.isManuallyOverriddenValue ? this.settings.manualInputValue : this.calendar.altInput.value;
105
+ if (this.settings.allowInput) {
106
+ if (this.settings.isManuallyOverriddenValue && this.settings.enableTime) {
107
+ this.calendar._input.value = this.settings.manualInputValue;
108
+ }
109
+ else {
110
+ this.settings.manualInputValue = '';
111
+ }
112
+ this.settings.isManuallyOverriddenValue = false;
105
113
  }
106
114
  this.emit('update');
107
115
  };
@@ -110,15 +118,20 @@ class CalendarWidget extends InputWidget_1.default {
110
118
  this.hook('onCalendarClose');
111
119
  this.closedOn = Date.now();
112
120
  if (this.settings.allowInput && this.settings.enableTime) {
113
- this.calendar._input.value = this.settings.isManuallyOverriddenValue ? this.settings.manualInputValue : this.calendar.altInput.value;
121
+ this.calendar._input.value = this.settings.manualInputValue || this.calendar._input.value;
122
+ this.settings.isManuallyOverriddenValue = false;
114
123
  this.emit('update');
115
124
  }
125
+ if (this.settings.wasDefaultValueChanged) {
126
+ this.calendar._input.value = this.settings.defaultValue;
127
+ this.settings.wasDefaultValueChanged = false;
128
+ }
116
129
  if (this.calendar) {
117
130
  this.emit('blur');
118
131
  }
119
132
  };
120
133
  Formio_1.Formio.requireLibrary('flatpickr-css', 'flatpickr', [
121
- { type: 'styles', src: `${Formio_1.Formio.cdn['flatpickr']}/flatpickr.min.css` }
134
+ { type: 'styles', src: `${Formio_1.Formio.cdn['flatpickr-formio']}/flatpickr.min.css` }
122
135
  ], true);
123
136
  if (this.component.shortcutButtons) {
124
137
  this.component.shortcutButtons = this.component.shortcutButtons.filter((btn) => btn.label && btn.onClick);
@@ -136,7 +149,7 @@ class CalendarWidget extends InputWidget_1.default {
136
149
  }
137
150
  })
138
151
  .then((ShortcutButtonsPlugin) => {
139
- return Formio_1.Formio.requireLibrary('flatpickr', 'flatpickr', `${Formio_1.Formio.cdn['flatpickr']}/flatpickr.min.js`, true)
152
+ return Formio_1.Formio.requireLibrary('flatpickr', 'flatpickr', `${Formio_1.Formio.cdn['flatpickr-formio']}/flatpickr.min.js`, true)
140
153
  .then((Flatpickr) => {
141
154
  var _a;
142
155
  if (((_a = this.component.shortcutButtons) === null || _a === void 0 ? void 0 : _a.length) && ShortcutButtonsPlugin) {
@@ -146,7 +159,7 @@ class CalendarWidget extends InputWidget_1.default {
146
159
  if (this._input) {
147
160
  const { locale } = this.settings;
148
161
  if (locale && locale.length >= 2 && locale !== 'en') {
149
- return Formio_1.Formio.requireLibrary(`flatpickr-${locale}`, `flatpickr.l10ns.${locale}`, `${Formio_1.Formio.cdn['flatpickr']}/l10n/${locale}.js`, true).then(() => this.initFlatpickr(Flatpickr));
162
+ return Formio_1.Formio.requireLibrary(`flatpickr-${locale}`, `flatpickr-${locale}`, `${Formio_1.Formio.cdn['flatpickr-formio']}/l10n/flatpickr-${locale}.js`, true).then(() => this.initFlatpickr(Flatpickr));
150
163
  }
151
164
  else {
152
165
  this.initFlatpickr(Flatpickr);
@@ -345,28 +358,19 @@ class CalendarWidget extends InputWidget_1.default {
345
358
  this.calendar = new Flatpickr(this._input, Object.assign(Object.assign({}, this.settings), { disableMobile: true }));
346
359
  this.addEventListener(this.calendar.altInput, 'input', (event) => {
347
360
  if (this.settings.allowInput && this.settings.currentValue !== event.target.value) {
348
- if (event.target.mask) {
349
- event.target.mask.textMaskInputElement.update();
350
- }
351
361
  this.settings.manualInputValue = event.target.value;
352
- this._input.value = this.settings.manualInputValue;
353
362
  this.settings.isManuallyOverriddenValue = true;
354
363
  this.settings.currentValue = event.target.value;
355
- this.emit('update');
364
+ }
365
+ if (event.target.value === '' && this.calendar.selectedDates.length > 0) {
366
+ this.settings.wasDefaultValueChanged = true;
367
+ this.settings.defaultValue = event.target.value;
368
+ this.calendar.clear();
369
+ }
370
+ else {
371
+ this.settings.wasDefaultValueChanged = false;
356
372
  }
357
373
  });
358
- if (this.calendar.daysContainer) {
359
- this.calendar.daysContainer.addEventListener('click', () => {
360
- this.settings.isManuallyOverriddenValue = false;
361
- this.calendar.updateValue(false);
362
- });
363
- }
364
- if (this.calendar.timeContainer) {
365
- this.calendar.timeContainer.addEventListener('click', () => {
366
- this.settings.isManuallyOverriddenValue = false;
367
- this.calendar.updateValue(false);
368
- });
369
- }
370
374
  const excludedFromMaskFormats = ['MMMM'];
371
375
  if (!this.settings.readOnly && !lodash_1.default.some(excludedFromMaskFormats, format => lodash_1.default.includes(this.settings.format, format))) {
372
376
  // Enforce the input mask of the format.
@@ -393,10 +397,6 @@ class CalendarWidget extends InputWidget_1.default {
393
397
  // Make sure we commit the value after a blur event occurs.
394
398
  this.addEventListener(this.calendar._input, 'blur', (event) => {
395
399
  var _a, _b, _c, _d;
396
- // If we have manually overridden the value then we shouldn't call setDate because this will fill the input mask
397
- if (this.settings.isManuallyOverriddenValue) {
398
- return;
399
- }
400
400
  const activeElement = this.settings.shadowRoot ? this.settings.shadowRoot.activeElement : document.activeElement;
401
401
  const relatedTarget = event.relatedTarget ? event.relatedTarget : activeElement;
402
402
  if (!(isIEBrowser && !relatedTarget) && !this.isCalendarElement(relatedTarget)) {
package/lib/mjs/CDN.d.ts CHANGED
@@ -13,8 +13,8 @@ declare class CDN {
13
13
  bootswatch: string;
14
14
  'bootstrap-icons': string;
15
15
  ckeditor: string;
16
- dragula: string;
17
16
  flatpickr: string;
17
+ 'flatpickr-formio': string;
18
18
  'font-awesome': string;
19
19
  grid: string;
20
20
  'moment-timezone': string;
package/lib/mjs/CDN.js CHANGED
@@ -16,8 +16,8 @@ class CDN {
16
16
  'bootswatch': '5.3.3',
17
17
  'bootstrap-icons': '1.11.1',
18
18
  'ckeditor': '19.0.0',
19
- 'dragula': '3.7.3',
20
- 'flatpickr': '4.6.13',
19
+ 'flatpickr': '4.6.8',
20
+ 'flatpickr-formio': '4.6.13-formio.3',
21
21
  'font-awesome': '4.7.0',
22
22
  'grid': 'latest',
23
23
  'moment-timezone': 'latest',
package/lib/mjs/Embed.js CHANGED
@@ -14,7 +14,7 @@ export class Formio {
14
14
  Formio._formioReady = ready;
15
15
  Formio._formioReadyReject = reject;
16
16
  });
17
- static version = '5.1.0-dev.2';
17
+ static version = '5.1.0-rc.26';
18
18
  static setLicense(license, norecurse = false) {
19
19
  Formio.license = license;
20
20
  if (!norecurse && Formio.FormioClass) {
package/lib/mjs/Form.d.ts CHANGED
@@ -48,7 +48,7 @@ export default class Form extends Element {
48
48
  * @property {number} [saveDraftThrottle] - The throttle for the save draft feature.
49
49
  * @property {boolean} [readOnly] - Set this form to readOnly.
50
50
  * @property {boolean} [noAlerts] - Disable the alerts dialog.
51
- * @property {Record<string, Record<string, string>>} [i18n] - The translation file for this rendering.
51
+ * @property {{[key: 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,7 +117,9 @@ export default class Form extends Element {
117
117
  /**
118
118
  * - The translation file for this rendering.
119
119
  */
120
- i18n?: Record<string, Record<string, string>> | undefined;
120
+ i18n?: {
121
+ [key: string]: string;
122
+ } | undefined;
121
123
  /**
122
124
  * - Custom logic for creation of elements.
123
125
  */
@@ -396,10 +398,10 @@ export default class Form extends Element {
396
398
  getFormInitOptions(url: string, form: import('@formio/core').Form): object;
397
399
  /**
398
400
  * Sets the form to the JSON schema of a form.
399
- * @param {import('@formio/core').Form | string} formParam - The form JSON to set this form to.
401
+ * @param {import('@formio/core').Form} formParam - The form JSON to set this form to.
400
402
  * @returns {Promise<Webform|Wizard|PDF>} - The webform instance that was created.
401
403
  */
402
- setForm(formParam: import('@formio/core').Form | string): Promise<Webform | Wizard | PDF>;
404
+ setForm(formParam: import('@formio/core').Form): Promise<Webform | Wizard | PDF>;
403
405
  _form: any;
404
406
  getSubmission(formio: any, opts: any): any;
405
407
  /**
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 {Record<string, Record<string, string>>} [i18n] - The translation file for this rendering.
54
+ * @property {{[key: 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.
@@ -264,7 +264,7 @@ export default class Form extends Element {
264
264
  }
265
265
  /**
266
266
  * Sets the form to the JSON schema of a form.
267
- * @param {import('@formio/core').Form | string} formParam - The form JSON to set this form to.
267
+ * @param {import('@formio/core').Form} formParam - The form JSON to set this form to.
268
268
  * @returns {Promise<Webform|Wizard|PDF>} - The webform instance that was created.
269
269
  */
270
270
  setForm(formParam) {
@@ -291,14 +291,8 @@ export default class Form extends Element {
291
291
  }
292
292
  this.loading = false;
293
293
  this.instance = this.instance || this.create(form.display);
294
- // If we're in builder mode, instance.setUrl is not a function, so just manually set the URL.
295
- if (this.instance.setUrl) {
296
- const options = this.getFormInitOptions(formParam, form);
297
- this.instance.setUrl(formParam, options);
298
- }
299
- else {
300
- this.instance.url = formParam;
301
- }
294
+ const options = this.getFormInitOptions(formParam, form);
295
+ this.instance.setUrl(formParam, options);
302
296
  this.instance.nosubmit = false;
303
297
  this._form = this.instance.form = form;
304
298
  if (submission) {
@@ -350,9 +344,7 @@ export default class Form extends Element {
350
344
  this.form.display = display;
351
345
  this.instance.destroy();
352
346
  this.instance = this.create(display);
353
- return this.setForm(this.form).then(() => {
354
- this.instance.emit('setDisplay', this.form.display);
355
- });
347
+ return this.setForm(this.form);
356
348
  }
357
349
  empty() {
358
350
  if (this.element) {
@@ -408,10 +400,10 @@ export default class Form extends Element {
408
400
  */
409
401
  build() {
410
402
  if (!this.instance) {
411
- return Promise.reject(this.t('formNotReady'));
403
+ return Promise.reject('Form not ready. Use form.ready promise');
412
404
  }
413
405
  if (!this.element) {
414
- return Promise.reject(this.t('noFormElement'));
406
+ return Promise.reject('No DOM element for form.');
415
407
  }
416
408
  // Add temporary loader.
417
409
  const template = (this.options && this.options.template) ? this.options.template : 'bootstrap';
@@ -428,7 +420,7 @@ export default class Form extends Element {
428
420
  }
429
421
  render() {
430
422
  if (!this.instance) {
431
- return Promise.reject(this.t('formNotReady'));
423
+ return Promise.reject('Form not ready. Use form.ready promise');
432
424
  }
433
425
  return Promise.resolve(this.instance.render())
434
426
  .then((param) => {
@@ -438,7 +430,7 @@ export default class Form extends Element {
438
430
  }
439
431
  attach(element) {
440
432
  if (!this.instance) {
441
- return Promise.reject(this.t('formNotReady'));
433
+ return Promise.reject('Form not ready. Use form.ready promise');
442
434
  }
443
435
  if (this.element) {
444
436
  delete this.element.component;
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.1.0-dev.2';
7
+ FormioCore.version = '5.1.0-rc.26';
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) {
@@ -196,10 +196,10 @@ export default class PDFBuilder extends WebformBuilder {
196
196
  const progress = Math.floor((event.loaded / event.total) * 100);
197
197
  this.refs.uploadProgress.style.width = `${progress}%`;
198
198
  if (progress > 98) {
199
- this.refs.uploadProgress.innerHTML = this.t('waitPdfConverting');
199
+ this.refs.uploadProgress.innerHTML = this.t('Converting PDF. Please wait.');
200
200
  }
201
201
  else {
202
- this.refs.uploadProgress.innerHTML = `${this.t('uploading')} ${progress}%`;
202
+ this.refs.uploadProgress.innerHTML = `${this.t('Uploading')} ${progress}%`;
203
203
  }
204
204
  }
205
205
  }, `${this.projectUrl}/upload`, {}, 'file')
@@ -236,7 +236,7 @@ export default class PDFBuilder extends WebformBuilder {
236
236
  return;
237
237
  }
238
238
  this.refs.uploadError.style.display = message ? '' : 'none';
239
- this.refs.uploadError.innerHTML = this.t(`${message}`);
239
+ this.refs.uploadError.innerHTML = message;
240
240
  }
241
241
  createForm(options) {
242
242
  // Instantiate the webform from the PDF class instead of Webform
@@ -464,7 +464,7 @@ export default class PDFBuilder extends WebformBuilder {
464
464
  name: 'showBuilderErrors',
465
465
  data: {
466
466
  compId: comp.component.id,
467
- errorMessage: `${this.t('notUniqueKey')}: ${comp.key}`,
467
+ errorMessage: `API Key is not unique: ${comp.key}`,
468
468
  }
469
469
  });
470
470
  }