@formio/js 5.1.0-dev.6059.845a6e3 → 5.1.0-dev.6060.19e3bfc

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 (196) hide show
  1. package/Changelog.md +131 -13
  2. package/README.md +28 -1
  3. package/dist/formio.builder.css +19 -17
  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 +19 -17
  9. package/dist/formio.form.js +102 -176
  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 +19 -17
  14. package/dist/formio.full.js +123 -101
  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 +4 -6
  28. package/lib/cjs/Form.js +16 -8
  29. package/lib/cjs/Formio.js +1 -1
  30. package/lib/cjs/PDFBuilder.js +4 -4
  31. package/lib/cjs/Webform.d.ts +16 -13
  32. package/lib/cjs/Webform.js +162 -148
  33. package/lib/cjs/WebformBuilder.js +17 -28
  34. package/lib/cjs/Wizard.js +1 -1
  35. package/lib/cjs/WizardBuilder.js +15 -2
  36. package/lib/cjs/components/Components.d.ts +3 -0
  37. package/lib/cjs/components/_classes/component/Component.d.ts +1 -0
  38. package/lib/cjs/components/_classes/component/Component.js +38 -11
  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 +37 -0
  41. package/lib/cjs/components/_classes/component/editForm/Component.edit.data.js +32 -2
  42. package/lib/cjs/components/_classes/component/editForm/utils.d.ts +1 -0
  43. package/lib/cjs/components/_classes/component/editForm/utils.js +3 -0
  44. package/lib/cjs/components/_classes/input/Input.js +23 -1
  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 +10 -3
  48. package/lib/cjs/components/_classes/nested/NestedComponent.form.js +13 -0
  49. package/lib/cjs/components/_classes/nestedarray/NestedArrayComponent.d.ts +2 -0
  50. package/lib/cjs/components/_classes/nestedarray/NestedArrayComponent.js +52 -31
  51. package/lib/cjs/components/address/Address.js +14 -1
  52. package/lib/cjs/components/button/Button.js +6 -6
  53. package/lib/cjs/components/checkbox/Checkbox.d.ts +1 -1
  54. package/lib/cjs/components/checkbox/Checkbox.js +2 -2
  55. package/lib/cjs/components/content/editForm/Content.edit.display.js +8 -0
  56. package/lib/cjs/components/currency/editForm/Currency.edit.display.js +12 -0
  57. package/lib/cjs/components/datagrid/DataGrid.d.ts +2 -0
  58. package/lib/cjs/components/datagrid/DataGrid.js +41 -26
  59. package/lib/cjs/components/day/Day.js +9 -7
  60. package/lib/cjs/components/day/editForm/Day.edit.display.js +8 -0
  61. package/lib/cjs/components/editgrid/EditGrid.d.ts +1 -1
  62. package/lib/cjs/components/editgrid/EditGrid.js +26 -8
  63. package/lib/cjs/components/email/editForm/Email.edit.display.js +12 -0
  64. package/lib/cjs/components/fieldset/editForm/Fieldset.edit.display.js +8 -0
  65. package/lib/cjs/components/file/File.d.ts +1 -1
  66. package/lib/cjs/components/file/File.js +30 -19
  67. package/lib/cjs/components/form/Form.d.ts +1 -1
  68. package/lib/cjs/components/form/Form.js +9 -5
  69. package/lib/cjs/components/form/editForm/Form.edit.form.js +3 -3
  70. package/lib/cjs/components/hidden/Hidden.d.ts +0 -1
  71. package/lib/cjs/components/hidden/Hidden.js +1 -1
  72. package/lib/cjs/components/hidden/editForm/Hidden.edit.display.js +8 -0
  73. package/lib/cjs/components/html/editForm/HTML.edit.display.js +8 -0
  74. package/lib/cjs/components/number/Number.js +12 -5
  75. package/lib/cjs/components/number/editForm/Number.edit.display.js +12 -0
  76. package/lib/cjs/components/password/editForm/Password.edit.display.js +13 -1
  77. package/lib/cjs/components/phonenumber/PhoneNumber.form.js +9 -1
  78. package/lib/cjs/components/radio/Radio.js +10 -0
  79. package/lib/cjs/components/recaptcha/ReCaptcha.js +2 -2
  80. package/lib/cjs/components/select/Select.d.ts +0 -1
  81. package/lib/cjs/components/select/Select.js +12 -33
  82. package/lib/cjs/components/select/editForm/Select.edit.data.d.ts +1 -1
  83. package/lib/cjs/components/select/editForm/Select.edit.data.js +3 -2
  84. package/lib/cjs/components/selectboxes/SelectBoxes.js +2 -2
  85. package/lib/cjs/components/signature/Signature.d.ts +1 -1
  86. package/lib/cjs/components/signature/Signature.js +5 -3
  87. package/lib/cjs/components/signature/editForm/Signature.edit.display.d.ts +0 -6
  88. package/lib/cjs/components/signature/editForm/Signature.edit.display.js +0 -1
  89. package/lib/cjs/components/survey/Survey.js +2 -2
  90. package/lib/cjs/components/tabs/editForm/Tabs.edit.display.js +8 -0
  91. package/lib/cjs/components/tags/Tags.d.ts +1 -1
  92. package/lib/cjs/components/tags/Tags.js +2 -2
  93. package/lib/cjs/components/textarea/TextArea.js +6 -6
  94. package/lib/cjs/components/textarea/editForm/TextArea.edit.display.js +12 -0
  95. package/lib/cjs/components/url/editForm/Url.edit.display.js +12 -0
  96. package/lib/cjs/components/well/editForm/Well.edit.display.js +8 -0
  97. package/lib/cjs/formio.form.js +5 -0
  98. package/lib/cjs/providers/storage/googleDrive.js +3 -2
  99. package/lib/cjs/providers/storage/s3.js +3 -3
  100. package/lib/cjs/providers/storage/xhr.d.ts +1 -0
  101. package/lib/cjs/providers/storage/xhr.js +6 -1
  102. package/lib/cjs/translations/en.d.ts +234 -81
  103. package/lib/cjs/translations/en.js +8 -81
  104. package/lib/cjs/utils/ChoicesWrapper.d.ts +4 -25
  105. package/lib/cjs/utils/ChoicesWrapper.js +47 -124
  106. package/lib/cjs/utils/formUtils.d.ts +2 -2
  107. package/lib/cjs/utils/i18n.d.ts +5 -2
  108. package/lib/cjs/utils/i18n.js +32 -5
  109. package/lib/cjs/widgets/CalendarWidget.js +27 -27
  110. package/lib/mjs/CDN.d.ts +1 -1
  111. package/lib/mjs/CDN.js +2 -2
  112. package/lib/mjs/Embed.js +1 -1
  113. package/lib/mjs/Form.d.ts +4 -6
  114. package/lib/mjs/Form.js +17 -9
  115. package/lib/mjs/Formio.js +1 -1
  116. package/lib/mjs/PDFBuilder.js +4 -4
  117. package/lib/mjs/Webform.d.ts +16 -13
  118. package/lib/mjs/Webform.js +171 -158
  119. package/lib/mjs/WebformBuilder.js +17 -28
  120. package/lib/mjs/Wizard.js +1 -1
  121. package/lib/mjs/WizardBuilder.js +15 -2
  122. package/lib/mjs/components/Components.d.ts +3 -0
  123. package/lib/mjs/components/_classes/component/Component.d.ts +1 -0
  124. package/lib/mjs/components/_classes/component/Component.js +27 -11
  125. package/lib/mjs/components/_classes/component/editForm/Component.edit.conditional.js +1 -1
  126. package/lib/mjs/components/_classes/component/editForm/Component.edit.data.d.ts +37 -0
  127. package/lib/mjs/components/_classes/component/editForm/Component.edit.data.js +32 -2
  128. package/lib/mjs/components/_classes/component/editForm/utils.d.ts +1 -0
  129. package/lib/mjs/components/_classes/component/editForm/utils.js +3 -0
  130. package/lib/mjs/components/_classes/input/Input.js +22 -1
  131. package/lib/mjs/components/_classes/list/ListComponent.js +4 -4
  132. package/lib/mjs/components/_classes/multivalue/Multivalue.d.ts +1 -1
  133. package/lib/mjs/components/_classes/multivalue/Multivalue.js +10 -3
  134. package/lib/mjs/components/_classes/nested/NestedComponent.form.js +13 -0
  135. package/lib/mjs/components/_classes/nestedarray/NestedArrayComponent.d.ts +2 -0
  136. package/lib/mjs/components/_classes/nestedarray/NestedArrayComponent.js +53 -31
  137. package/lib/mjs/components/address/Address.js +14 -1
  138. package/lib/mjs/components/button/Button.js +6 -6
  139. package/lib/mjs/components/checkbox/Checkbox.d.ts +1 -1
  140. package/lib/mjs/components/checkbox/Checkbox.js +2 -2
  141. package/lib/mjs/components/content/editForm/Content.edit.display.js +8 -0
  142. package/lib/mjs/components/currency/editForm/Currency.edit.display.js +12 -0
  143. package/lib/mjs/components/datagrid/DataGrid.d.ts +2 -0
  144. package/lib/mjs/components/datagrid/DataGrid.js +41 -26
  145. package/lib/mjs/components/day/Day.js +9 -7
  146. package/lib/mjs/components/day/editForm/Day.edit.display.js +8 -0
  147. package/lib/mjs/components/editgrid/EditGrid.d.ts +1 -1
  148. package/lib/mjs/components/editgrid/EditGrid.js +25 -7
  149. package/lib/mjs/components/email/editForm/Email.edit.display.js +12 -0
  150. package/lib/mjs/components/fieldset/editForm/Fieldset.edit.display.js +8 -0
  151. package/lib/mjs/components/file/File.d.ts +1 -1
  152. package/lib/mjs/components/file/File.js +30 -19
  153. package/lib/mjs/components/form/Form.d.ts +1 -1
  154. package/lib/mjs/components/form/Form.js +8 -5
  155. package/lib/mjs/components/form/editForm/Form.edit.form.js +3 -3
  156. package/lib/mjs/components/hidden/Hidden.d.ts +0 -1
  157. package/lib/mjs/components/hidden/Hidden.js +1 -1
  158. package/lib/mjs/components/hidden/editForm/Hidden.edit.display.js +8 -0
  159. package/lib/mjs/components/html/editForm/HTML.edit.display.js +8 -0
  160. package/lib/mjs/components/number/Number.js +12 -5
  161. package/lib/mjs/components/number/editForm/Number.edit.display.js +12 -0
  162. package/lib/mjs/components/password/editForm/Password.edit.display.js +13 -1
  163. package/lib/mjs/components/phonenumber/PhoneNumber.form.js +9 -1
  164. package/lib/mjs/components/radio/Radio.js +10 -0
  165. package/lib/mjs/components/recaptcha/ReCaptcha.js +2 -2
  166. package/lib/mjs/components/select/Select.d.ts +0 -1
  167. package/lib/mjs/components/select/Select.js +14 -34
  168. package/lib/mjs/components/select/editForm/Select.edit.data.d.ts +1 -1
  169. package/lib/mjs/components/select/editForm/Select.edit.data.js +3 -2
  170. package/lib/mjs/components/selectboxes/SelectBoxes.js +2 -2
  171. package/lib/mjs/components/signature/Signature.d.ts +1 -1
  172. package/lib/mjs/components/signature/Signature.js +5 -3
  173. package/lib/mjs/components/signature/editForm/Signature.edit.display.d.ts +0 -6
  174. package/lib/mjs/components/signature/editForm/Signature.edit.display.js +0 -1
  175. package/lib/mjs/components/survey/Survey.js +2 -2
  176. package/lib/mjs/components/tabs/editForm/Tabs.edit.display.js +8 -0
  177. package/lib/mjs/components/tags/Tags.d.ts +1 -1
  178. package/lib/mjs/components/tags/Tags.js +2 -2
  179. package/lib/mjs/components/textarea/TextArea.js +6 -6
  180. package/lib/mjs/components/textarea/editForm/TextArea.edit.display.js +12 -0
  181. package/lib/mjs/components/url/editForm/Url.edit.display.js +12 -0
  182. package/lib/mjs/components/well/editForm/Well.edit.display.js +8 -0
  183. package/lib/mjs/formio.form.js +5 -0
  184. package/lib/mjs/providers/storage/googleDrive.js +3 -2
  185. package/lib/mjs/providers/storage/s3.js +3 -3
  186. package/lib/mjs/providers/storage/xhr.d.ts +1 -0
  187. package/lib/mjs/providers/storage/xhr.js +6 -1
  188. package/lib/mjs/translations/en.d.ts +234 -81
  189. package/lib/mjs/translations/en.js +87 -1
  190. package/lib/mjs/utils/ChoicesWrapper.d.ts +4 -25
  191. package/lib/mjs/utils/ChoicesWrapper.js +26 -119
  192. package/lib/mjs/utils/formUtils.d.ts +2 -2
  193. package/lib/mjs/utils/i18n.d.ts +5 -2
  194. package/lib/mjs/utils/i18n.js +32 -5
  195. package/lib/mjs/widgets/CalendarWidget.js +27 -27
  196. package/package.json +27 -11
@@ -1,4 +1,6 @@
1
+ import bootstrap from '@formio/bootstrap';
1
2
  export default {
3
+ ...(bootstrap?.translations?.en || {}),
2
4
  unsavedRowsError: 'Please save all rows before proceeding.',
3
5
  invalidRowsError: 'Please correct invalid rows before proceeding.',
4
6
  invalidRowError: 'Invalid row. Please correct it or delete.',
@@ -77,5 +79,89 @@ export default {
77
79
  requiredDayField: '{{ field }} is required',
78
80
  requiredDayEmpty: '{{ field }} is required',
79
81
  requiredMonthField: '{{ field }} is required',
80
- requiredYearField: '{{ field }} is required'
82
+ requiredYearField: '{{ field }} is required',
83
+ formNotReady: 'Form not ready. Use form.ready promise',
84
+ noFormElement: 'No DOM element for form.',
85
+ notUniqueKey: 'API Key is not unique',
86
+ newFormSchema: 'Form schema is for a newer version, please upgrade your renderer. Some functionality may not work.',
87
+ missingUrl: 'Missing URL argument',
88
+ urlNotAttachedToBtn: 'You should add a URL to this button.',
89
+ loadingProjectSettingsError: 'Could not load project settings',
90
+ sessionStorageSupportError: 'Session storage is not supported in this browser.',
91
+ builderUniqueError: `You cannot add more than one {{componentKeyOrTitle}} component to one page.`,
92
+ pageNotFound: 'Page not found',
93
+ noDragInfoError: 'There is no Drag Info available for either dragged or sibling element',
94
+ addonSupportTypeError: 'Addon {{label}} does not support component of type {{type}}',
95
+ setPathError: 'Should not be setting the path of a component.',
96
+ calculatedPathDeprecation: 'component.calculatedPath was deprecated, use component.path instead.',
97
+ unknownTemplate: 'Unknown template: {{name}}',
98
+ unknownComponent: 'Unknown component: {{type}}',
99
+ renderTemplateFunctionDeprecation: `Form.io 'render' template function is deprecated.
100
+ If you need to render template (template A) inside of another template (template B),
101
+ pass pre-compiled template A (use this.renderTemplate('template_A_name') as template context variable for template B`,
102
+ whenReadyDeprecation: 'The whenReady() method has been deprecated. Please use the dataReady property instead.',
103
+ loadResourcesError: 'Unable to load resources for {{componentKey}}',
104
+ noSelectDataConfiguration: 'Select component {{componentKey}} does not have data configuration.',
105
+ indexedDBSupportError: "Your browser doesn't support current version of indexedDB",
106
+ caretPositionSavingError: 'An error occurred while trying to save caret position',
107
+ iteratableRowsError: 'Getter #iteratableRows() is not implemented',
108
+ checkRowDeprecation: 'Deprecation Warning: checkRow method has been replaced with processRow',
109
+ noOAuthBtn: 'You must add the OAuth button to a form for it to function properly',
110
+ noOAuthConfiguration: 'OAuth not configured. You must configure oauth for your project before it will work.',
111
+ oAuthErrorsTitle: 'The Following Error Has Occured',
112
+ noOAuthFormUrl: 'You must attach a Form API url to your form in order to use OAuth buttons.',
113
+ oAuthStateError: 'OAuth state does not match. Please try logging in again.',
114
+ componentInvalidRowValidation: 'Invalid row validation for {{componentKey}}',
115
+ videoPlayerNotFound: 'Video player not found in template.',
116
+ synchronizationFailed: 'Synchronization is failed',
117
+ fileWithDuplicatedNameInProgress: 'File with the same name is already being uploaded',
118
+ fileWithDuplicatedNameLoaded: 'File with the same name is already uploaded',
119
+ nestedForm: 'Nested form',
120
+ noDataProvided: 'No data provided',
121
+ subformSubmissionLoadingError: 'Unable to load subform submission {{submissionId}}:',
122
+ noDelimiterSet: 'In order for thousands separator to work properly, you must set the delimiter to true in the component json',
123
+ noSiteKey: 'There is no Site Key specified in settings in form JSON',
124
+ failedToNormalize: 'Failed to normalize value',
125
+ failedToCompareItems: 'Error while comparing items',
126
+ editorFocusError: 'An editor did not initialize properly when trying to focus:',
127
+ quillImageUploadFailed: 'Quill image upload failed',
128
+ noFilesSelected: 'No files selected',
129
+ needConfigurationForQuill: 'The WYSIWYG settings are configured for CKEditor. For this renderer, you will need to use configurations for the Quill Editor. See https://quilljs.com/docs/configuration for more information.',
130
+ waitPdfConverting: 'Converting PDF. Please wait.',
131
+ uploading: 'Uploading',
132
+ pasteBelow: 'Paste below',
133
+ copy: 'Copy',
134
+ move: 'Move',
135
+ edit: 'Edit',
136
+ editJson: 'Edit JSON',
137
+ remove: 'Remove',
138
+ clickToSetValue: 'Click to set value',
139
+ words: 'words',
140
+ characters: 'characters',
141
+ addAnother: 'Add Another',
142
+ yes: 'Yes',
143
+ no: 'No',
144
+ wantToClearData: 'Do you want to clear data?',
145
+ yesDelete: 'Yes, delete it',
146
+ waitFileProcessing: 'Processing file. Please wait...',
147
+ wrongFileType: 'File is the wrong type; it must be {{ pattern }}',
148
+ fileTooSmall: 'File is too small; it must be at least {{ size }}',
149
+ fileTooBig: 'File is too big; it must be at most {{ size }}',
150
+ noFileService: 'File Service not provided.',
151
+ fileProcessingFailed: 'File processing has been failed.',
152
+ readyForUpload: 'Ready to be uploaded into storage',
153
+ readyForRemovingFromStorage: 'Ready to be removed from storage',
154
+ preparingFileToRemove: 'Preparing file to remove',
155
+ succefullyRemoved: 'Succefully removed',
156
+ succefullyUploaded: 'Succefully uploaded',
157
+ maxSelectItems: 'You may only select up to {{maxCount}} items',
158
+ minSelectItems: 'You must select at least {{minCount}} items',
159
+ clickToSign: 'Click to Sign',
160
+ surveyQuestion: 'Question',
161
+ surveyQuestionValue: 'Value',
162
+ success: 'Success',
163
+ noResultsFound: 'No results found',
164
+ noChoices: 'No choices to choose from',
165
+ typeToSearch: 'Type to search',
166
+ loading: 'Loading',
81
167
  };
@@ -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,41 +1,7 @@
1
- import Choices from '@formio/choices.js';
2
- /**
3
- * TODO: REMOVE THIS ONCE THE PULL REQUEST HAS BEEN RESOLVED.
4
- *
5
- * https://github.com/jshjohnson/Choices/pull/788
6
- *
7
- * This is intentionally not part of the extended class, since other components use Choices and need this fix as well.
8
- * @type {Choices._generatePlaceholderValue}
9
- * @private
10
- */
11
- Choices.prototype._generatePlaceholderValue = function () {
12
- if (this._isSelectElement && this.passedElement.placeholderOption) {
13
- const { placeholderOption } = this.passedElement;
14
- return placeholderOption ? placeholderOption.text : false;
15
- }
16
- const { placeholder, placeholderValue } = this.config;
17
- const { element: { dataset }, } = this.passedElement;
18
- if (placeholder) {
19
- if (placeholderValue) {
20
- return placeholderValue;
21
- }
22
- if (dataset.placeholder) {
23
- return dataset.placeholder;
24
- }
25
- }
26
- return false;
27
- };
28
- export const KEY_CODES = {
29
- BACK_KEY: 46,
30
- DELETE_KEY: 8,
1
+ import Choices, { KeyCodeMap } from 'choices.js';
2
+ const ExtendedKeyCodeMap = {
3
+ ...KeyCodeMap,
31
4
  TAB_KEY: 9,
32
- ENTER_KEY: 13,
33
- A_KEY: 65,
34
- ESC_KEY: 27,
35
- UP_KEY: 38,
36
- DOWN_KEY: 40,
37
- PAGE_UP_KEY: 33,
38
- PAGE_DOWN_KEY: 34,
39
5
  };
40
6
  class ChoicesWrapper extends Choices {
41
7
  constructor(...args) {
@@ -63,24 +29,13 @@ class ChoicesWrapper extends Choices {
63
29
  }
64
30
  this._wasTap = true;
65
31
  }
66
- _handleButtonAction(activeItems, element) {
67
- if (!this._isSelectOneElement) {
68
- return super._handleButtonAction(activeItems, element);
69
- }
70
- if (!activeItems ||
71
- !element ||
72
- !this.config.removeItems ||
73
- !this.config.removeItemButton) {
74
- return;
75
- }
76
- super._handleButtonAction(activeItems, element);
77
- }
78
- _onEnterKey(args) {
32
+ _onEnterKey(...args) {
33
+ const [event] = args;
79
34
  // Prevent dropdown form opening when removeItemButton was pressed using 'Enter' on keyboard
80
- if (args.event.target.className === 'choices__button') {
35
+ if (event.target.className === 'choices__button') {
81
36
  this.shouldOpenDropDown = false;
82
37
  }
83
- super._onEnterKey(args);
38
+ super._onEnterKey(...args);
84
39
  }
85
40
  _onDirectionKey(...args) {
86
41
  if (!this._isSelectOneElement) {
@@ -94,17 +49,18 @@ class ChoicesWrapper extends Choices {
94
49
  this.isDirectionUsing = false;
95
50
  }, 250);
96
51
  }
97
- _onTabKey({ activeItems, hasActiveDropdown }) {
98
- if (hasActiveDropdown) {
99
- this._selectHighlightedChoice(activeItems);
52
+ _onTabKey() {
53
+ if (this.dropdown.isActive) {
54
+ this._selectHighlightedChoice();
100
55
  }
101
56
  }
102
57
  _selectHighlightedChoice() {
103
- const highlightedChoice = this.dropdown.getChild(`.${this.config.classNames.highlightedState}`);
58
+ const highlightedChoice = this.dropdown.element.querySelector(`.${this.config.classNames.highlightedState}`);
104
59
  if (highlightedChoice) {
105
60
  const id = highlightedChoice.dataset.id;
106
- const choice = id && this._store.getChoiceById(id);
61
+ const choice = id && this._store.getChoiceById(Number(id));
107
62
  this._addItem({
63
+ id: choice.id,
108
64
  value: choice.value,
109
65
  label: choice.label,
110
66
  choiceId: choice.id,
@@ -115,61 +71,16 @@ class ChoicesWrapper extends Choices {
115
71
  });
116
72
  this._triggerChange(choice.value);
117
73
  }
118
- event.preventDefault();
119
74
  }
120
75
  _onKeyDown(event) {
121
- if (!this._isSelectOneElement) {
122
- return super._onKeyDown(event);
123
- }
124
- const { target, keyCode, ctrlKey, metaKey } = event;
125
- if (target !== this.input.element &&
126
- !this.containerOuter.element.contains(target)) {
127
- return;
128
- }
129
- const activeItems = this._store.activeItems;
130
- const hasFocusedInput = this.input.isFocussed;
131
- const hasActiveDropdown = this.dropdown.isActive;
132
- const hasItems = this.itemList.hasChildren;
133
- const keyString = String.fromCharCode(keyCode);
134
- const { BACK_KEY, DELETE_KEY, TAB_KEY, ENTER_KEY, A_KEY, ESC_KEY, UP_KEY, DOWN_KEY, PAGE_UP_KEY, PAGE_DOWN_KEY, } = KEY_CODES;
135
- const hasCtrlDownKeyPressed = ctrlKey || metaKey;
136
- // If a user is typing and the dropdown is not active
137
- if (!hasActiveDropdown && !this._isTextElement && /[a-zA-Z0-9-_ ]/.test(keyString)) {
138
- const currentValue = this.input.element.value;
139
- this.input.element.value = currentValue ? `${currentValue}${keyString}` : keyString;
140
- this.showDropdown();
141
- }
142
- // Map keys to key actions
143
- const keyDownActions = {
144
- [A_KEY]: this._onAKey,
145
- [TAB_KEY]: this._onTabKey,
146
- [ENTER_KEY]: this._onEnterKey,
147
- [ESC_KEY]: this._onEscapeKey,
148
- [UP_KEY]: this._onDirectionKey,
149
- [PAGE_UP_KEY]: this._onDirectionKey,
150
- [DOWN_KEY]: this._onDirectionKey,
151
- [PAGE_DOWN_KEY]: this._onDirectionKey,
152
- [DELETE_KEY]: this._onDeleteKey,
153
- [BACK_KEY]: this._onDeleteKey,
154
- };
155
- // If keycode has a function, run it
156
- if (keyDownActions[keyCode]) {
157
- keyDownActions[keyCode]({
158
- event,
159
- target,
160
- keyCode,
161
- metaKey,
162
- activeItems,
163
- hasFocusedInput,
164
- hasActiveDropdown,
165
- hasItems,
166
- hasCtrlDownKeyPressed,
167
- });
168
- }
76
+ const keyCode = event.keyCode;
77
+ return this._isSelectOneElement && keyCode === ExtendedKeyCodeMap.TAB_KEY
78
+ ? this._onTabKey()
79
+ : super._onKeyDown(event);
169
80
  }
170
- onSelectValue({ event, activeItems, hasActiveDropdown }) {
81
+ onSelectValue(event, hasActiveDropdown) {
171
82
  if (hasActiveDropdown) {
172
- this._selectHighlightedChoice(activeItems);
83
+ this._selectHighlightedChoice();
173
84
  }
174
85
  else if (this._isSelectOneElement) {
175
86
  this.showDropdown();
@@ -177,11 +88,13 @@ class ChoicesWrapper extends Choices {
177
88
  }
178
89
  }
179
90
  showDropdown(...args) {
180
- if (!this.shouldOpenDropDown) {
181
- this.shouldOpenDropDown = true;
182
- return;
183
- }
184
- super.showDropdown(...args);
91
+ setTimeout(() => {
92
+ if (!this.shouldOpenDropDown) {
93
+ this.shouldOpenDropDown = true;
94
+ return;
95
+ }
96
+ super.showDropdown(...args);
97
+ }, 0);
185
98
  }
186
99
  hideDropdown(...args) {
187
100
  if (this.isDirectionUsing) {
@@ -189,11 +102,5 @@ class ChoicesWrapper extends Choices {
189
102
  }
190
103
  super.hideDropdown(...args);
191
104
  }
192
- _onBlur(...args) {
193
- if (this._isScrollingOnIe) {
194
- return;
195
- }
196
- super._onBlur(...args);
197
- }
198
105
  }
199
106
  export 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: import("@formio/core").Component[], data: import("@formio/core").DataObject, fn: import("@formio/core").EachComponentDataAsyncCallback, includeAll?: boolean | undefined, local?: boolean | undefined, parent?: import("@formio/core").Component | undefined, parentPaths?: import("@formio/core").ComponentPaths | undefined) => Promise<void>;
30
- export const eachComponentData: (components: import("@formio/core").Component[], data: import("@formio/core").DataObject, fn: import("@formio/core").EachComponentDataCallback, includeAll?: boolean | undefined, local?: boolean | undefined, parent?: import("@formio/core").Component | undefined, parentPaths?: import("@formio/core").ComponentPaths | undefined) => void;
29
+ export const eachComponentDataAsync: (components: 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;
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,13 +2,16 @@
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;
5
7
  static init(languages?: {}): I18n;
6
8
  static createInstance(): I18n;
7
9
  constructor(languages?: {});
8
- languages: {};
10
+ languages: any;
11
+ defaultKeys: any;
9
12
  language: string;
10
13
  currentLanguage: any;
11
- setLanguages(languages: any): void;
14
+ setLanguages(languages: any, noDefaultOverride: any): void;
12
15
  dir(lang?: string): "rtl" | "ltr";
13
16
  changeLanguage(language: any, ready?: null): void;
14
17
  addResourceBundle(language: any, type: any, strings: any): void;
@@ -1,5 +1,7 @@
1
1
  import { Evaluator } from '@formio/core/utils';
2
2
  import i18n from '../i18n';
3
+ import { isEmpty } from 'lodash';
4
+ import { fastCloneDeep } from '@formio/core';
3
5
  const i18Defaults = {};
4
6
  for (const lang in i18n.resources) {
5
7
  if (i18n.resources.hasOwnProperty(lang)) {
@@ -10,14 +12,29 @@ for (const lang in i18n.resources) {
10
12
  * This file is used to mimic the i18n library interface.
11
13
  */
12
14
  export class I18n {
13
- languages = i18Defaults;
15
+ static languages = i18Defaults;
16
+ languages = fastCloneDeep(I18n.languages || {});
17
+ defaultKeys = I18n.languages?.en || {};
14
18
  language = 'en';
15
19
  currentLanguage = i18Defaults.en;
16
20
  constructor(languages = {}) {
17
21
  this.setLanguages(languages);
18
22
  this.changeLanguage(this.language);
19
23
  }
20
- setLanguages(languages) {
24
+ static setDefaultTranslations(languages) {
25
+ if (isEmpty(languages)) {
26
+ return;
27
+ }
28
+ for (const lang in languages) {
29
+ if (lang !== 'language' && languages.hasOwnProperty(lang)) {
30
+ if (!this.languages[lang]) {
31
+ this.languages[lang] = {};
32
+ }
33
+ this.languages[lang] = { ...languages[lang], ...this.languages[lang], };
34
+ }
35
+ }
36
+ }
37
+ setLanguages(languages, noDefaultOverride) {
21
38
  if (languages.resources) {
22
39
  for (const lang in languages.resources) {
23
40
  if (languages.resources.hasOwnProperty(lang)) {
@@ -44,7 +61,9 @@ export class I18n {
44
61
  if (!this.languages[lang]) {
45
62
  this.languages[lang] = {};
46
63
  }
47
- this.languages[lang] = { ...this.languages[lang], ...languages[lang] };
64
+ this.languages[lang] = noDefaultOverride
65
+ ? { ...languages[lang], ...this.languages[lang] }
66
+ : { ...this.languages[lang], ...languages[lang] };
48
67
  }
49
68
  }
50
69
  }
@@ -73,12 +92,20 @@ export class I18n {
73
92
  this.languages[language] = strings;
74
93
  }
75
94
  t(text, ...args) {
76
- if (this.currentLanguage[text]) {
95
+ let currentTranslation = this.currentLanguage[text];
96
+ // provide compatibility with cases where the entire phrase is used as a key
97
+ // get the phrase that is possibly being used as a key
98
+ const defaultKey = this.defaultKeys[text];
99
+ if (defaultKey && this.currentLanguage[defaultKey]) {
100
+ // get translation using the phrase as a key
101
+ currentTranslation = this.currentLanguage[defaultKey];
102
+ }
103
+ if (currentTranslation) {
77
104
  const customTranslationFieldName = args[0]?.field;
78
105
  if (customTranslationFieldName && this.currentLanguage[customTranslationFieldName]) {
79
106
  args[0].field = this.currentLanguage[customTranslationFieldName];
80
107
  }
81
- return Evaluator.interpolateString(this.currentLanguage[text], ...args);
108
+ return Evaluator.interpolateString(currentTranslation, ...args);
82
109
  }
83
110
  return Evaluator.interpolateString(text, ...args);
84
111
  }
@@ -87,8 +87,6 @@ export default class CalendarWidget extends InputWidget {
87
87
  this.settings.disableWeekends ? this.settings.disable.push(this.disableWeekends) : '';
88
88
  this.settings.disableWeekdays ? this.settings.disable.push(this.disableWeekdays) : '';
89
89
  this.settings.disableFunction ? this.settings.disable.push(this.disableFunction) : '';
90
- this.settings.wasDefaultValueChanged = false;
91
- this.settings.defaultValue = '';
92
90
  this.settings.manualInputValue = '';
93
91
  this.settings.isManuallyOverriddenValue = false;
94
92
  this.settings.currentValue = '';
@@ -96,14 +94,8 @@ export default class CalendarWidget extends InputWidget {
96
94
  this.settings.dateFormat = convertFormatToFlatpickr(this.settings.dateFormat);
97
95
  this.settings.position = 'auto center';
98
96
  this.settings.onChange = () => {
99
- if (this.settings.allowInput) {
100
- if (this.settings.isManuallyOverriddenValue && this.settings.enableTime) {
101
- this.calendar._input.value = this.settings.manualInputValue;
102
- }
103
- else {
104
- this.settings.manualInputValue = '';
105
- }
106
- this.settings.isManuallyOverriddenValue = false;
97
+ if (this.settings.allowInput && this.settings.enableTime) {
98
+ this.calendar._input.value = this.settings.isManuallyOverriddenValue ? this.settings.manualInputValue : this.calendar.altInput.value;
107
99
  }
108
100
  this.emit('update');
109
101
  };
@@ -112,20 +104,15 @@ export default class CalendarWidget extends InputWidget {
112
104
  this.hook('onCalendarClose');
113
105
  this.closedOn = Date.now();
114
106
  if (this.settings.allowInput && this.settings.enableTime) {
115
- this.calendar._input.value = this.settings.manualInputValue || this.calendar._input.value;
116
- this.settings.isManuallyOverriddenValue = false;
107
+ this.calendar._input.value = this.settings.isManuallyOverriddenValue ? this.settings.manualInputValue : this.calendar.altInput.value;
117
108
  this.emit('update');
118
109
  }
119
- if (this.settings.wasDefaultValueChanged) {
120
- this.calendar._input.value = this.settings.defaultValue;
121
- this.settings.wasDefaultValueChanged = false;
122
- }
123
110
  if (this.calendar) {
124
111
  this.emit('blur');
125
112
  }
126
113
  };
127
114
  Formio.requireLibrary('flatpickr-css', 'flatpickr', [
128
- { type: 'styles', src: `${Formio.cdn['flatpickr-formio']}/flatpickr.min.css` }
115
+ { type: 'styles', src: `${Formio.cdn['flatpickr']}/flatpickr.min.css` }
129
116
  ], true);
130
117
  if (this.component.shortcutButtons) {
131
118
  this.component.shortcutButtons = this.component.shortcutButtons.filter((btn) => btn.label && btn.onClick);
@@ -142,7 +129,7 @@ export default class CalendarWidget extends InputWidget {
142
129
  }
143
130
  })
144
131
  .then((ShortcutButtonsPlugin) => {
145
- return Formio.requireLibrary('flatpickr', 'flatpickr', `${Formio.cdn['flatpickr-formio']}/flatpickr.min.js`, true)
132
+ return Formio.requireLibrary('flatpickr', 'flatpickr', `${Formio.cdn['flatpickr']}/flatpickr.min.js`, true)
146
133
  .then((Flatpickr) => {
147
134
  if (this.component.shortcutButtons?.length && ShortcutButtonsPlugin) {
148
135
  this.initShortcutButtonsPlugin(ShortcutButtonsPlugin);
@@ -151,7 +138,7 @@ export default class CalendarWidget extends InputWidget {
151
138
  if (this._input) {
152
139
  const { locale } = this.settings;
153
140
  if (locale && locale.length >= 2 && locale !== 'en') {
154
- return Formio.requireLibrary(`flatpickr-${locale}`, `flatpickr-${locale}`, `${Formio.cdn['flatpickr-formio']}/l10n/flatpickr-${locale}.js`, true).then(() => this.initFlatpickr(Flatpickr));
141
+ return Formio.requireLibrary(`flatpickr-${locale}`, `flatpickr.l10ns.${locale}`, `${Formio.cdn['flatpickr']}/l10n/${locale}.js`, true).then(() => this.initFlatpickr(Flatpickr));
155
142
  }
156
143
  else {
157
144
  this.initFlatpickr(Flatpickr);
@@ -349,19 +336,28 @@ export default class CalendarWidget extends InputWidget {
349
336
  this.calendar = new Flatpickr(this._input, { ...this.settings, disableMobile: true });
350
337
  this.addEventListener(this.calendar.altInput, 'input', (event) => {
351
338
  if (this.settings.allowInput && this.settings.currentValue !== event.target.value) {
339
+ if (event.target.mask) {
340
+ event.target.mask.textMaskInputElement.update();
341
+ }
352
342
  this.settings.manualInputValue = event.target.value;
343
+ this._input.value = this.settings.manualInputValue;
353
344
  this.settings.isManuallyOverriddenValue = true;
354
345
  this.settings.currentValue = event.target.value;
355
- }
356
- if (event.target.value === '' && this.calendar.selectedDates.length > 0) {
357
- this.settings.wasDefaultValueChanged = true;
358
- this.settings.defaultValue = event.target.value;
359
- this.calendar.clear();
360
- }
361
- else {
362
- this.settings.wasDefaultValueChanged = false;
346
+ this.emit('update');
363
347
  }
364
348
  });
349
+ if (this.calendar.daysContainer) {
350
+ this.calendar.daysContainer.addEventListener('click', () => {
351
+ this.settings.isManuallyOverriddenValue = false;
352
+ this.calendar.updateValue(false);
353
+ });
354
+ }
355
+ if (this.calendar.timeContainer) {
356
+ this.calendar.timeContainer.addEventListener('click', () => {
357
+ this.settings.isManuallyOverriddenValue = false;
358
+ this.calendar.updateValue(false);
359
+ });
360
+ }
365
361
  const excludedFromMaskFormats = ['MMMM'];
366
362
  if (!this.settings.readOnly && !_.some(excludedFromMaskFormats, format => _.includes(this.settings.format, format))) {
367
363
  // Enforce the input mask of the format.
@@ -387,6 +383,10 @@ export default class CalendarWidget extends InputWidget {
387
383
  }
388
384
  // Make sure we commit the value after a blur event occurs.
389
385
  this.addEventListener(this.calendar._input, 'blur', (event) => {
386
+ // If we have manually overridden the value then we shouldn't call setDate because this will fill the input mask
387
+ if (this.settings.isManuallyOverriddenValue) {
388
+ return;
389
+ }
390
390
  const activeElement = this.settings.shadowRoot ? this.settings.shadowRoot.activeElement : document.activeElement;
391
391
  const relatedTarget = event.relatedTarget ? event.relatedTarget : activeElement;
392
392
  if (!(isIEBrowser && !relatedTarget) && !this.isCalendarElement(relatedTarget)) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@formio/js",
3
- "version": "5.1.0-dev.6059.845a6e3",
3
+ "version": "5.1.0-dev.6060.19e3bfc",
4
4
  "description": "JavaScript powered Forms with JSON Form Builder",
5
5
  "main": "lib/cjs/index.js",
6
6
  "exports": {
@@ -56,9 +56,10 @@
56
56
  "dopublish": "npm run build && npm run tag && npm publish",
57
57
  "lint": "eslint ./src --fix",
58
58
  "serve": "jekyll serve --config _config.yml,_config.dev.yml",
59
- "test": "mocha 'test/unit/*.unit.js'",
60
- "test:updateRenders": "npm run lib && TZ=UTC node --require jsdom-global/register test/updateRenders.js",
61
- "test:e2e": "NODE_OPTIONS=\"--max-old-space-size=4096\" karma start --verbose --single-run"
59
+ "test": "nyc --reporter=lcov --reporter=text --reporter=text-summary mocha test/unit/*.unit.js",
60
+ "test:updateRenders": "npm run lib && cross-env TZ=UTC node --require jsdom-global/register test/updateRenders.js",
61
+ "test:e2e": "NODE_OPTIONS=\"--max-old-space-size=4096\" karma start --verbose --single-run",
62
+ "show-coverage": "open coverage/lcov-report/index.html"
62
63
  },
63
64
  "repository": {
64
65
  "type": "git",
@@ -79,21 +80,21 @@
79
80
  },
80
81
  "homepage": "https://github.com/formio/formio.js#readme",
81
82
  "dependencies": {
82
- "@formio/bootstrap": "3.1.0-rc.4",
83
- "@formio/choices.js": "^10.2.1",
84
- "@formio/core": "2.4.0-rc.12",
85
- "@formio/text-mask-addons": "^3.8.0-formio.4",
83
+ "@formio/bootstrap": "v3.0.0-dev.121.085d187",
84
+ "@formio/core": "v2.4.0-dev.2",
85
+ "@formio/text-mask-addons": "3.8.0-formio.4",
86
86
  "@formio/vanilla-text-mask": "^5.1.1-formio.1",
87
87
  "abortcontroller-polyfill": "^1.7.5",
88
88
  "autocompleter": "^8.0.4",
89
89
  "bootstrap": "^5.3.3",
90
90
  "browser-cookies": "^1.2.0",
91
91
  "browser-md5-file": "^1.1.1",
92
- "compare-versions": "^6.0.0-rc.2",
92
+ "choices.js": "^11.0.6",
93
+ "compare-versions": "^6.1.1",
93
94
  "core-js": "^3.37.1",
94
95
  "dialog-polyfill": "^0.5.6",
95
96
  "dom-autoscroller": "^2.3.4",
96
- "dompurify": "^3.2.4",
97
+ "dompurify": "^3.1.6",
97
98
  "downloadjs": "^1.4.7",
98
99
  "dragula": "^3.7.3",
99
100
  "eventemitter3": "^5.0.1",
@@ -102,7 +103,7 @@
102
103
  "idb": "^7.1.1",
103
104
  "inputmask": "^5.0.8",
104
105
  "ismobilejs": "^1.1.1",
105
- "json-logic-js": "^2.0.2",
106
+ "json-logic-js": "^2.0.5",
106
107
  "jstimezonedetect": "^1.0.7",
107
108
  "jwt-decode": "^3.1.2",
108
109
  "lodash": "^4.17.21",
@@ -155,6 +156,7 @@
155
156
  "mocha": "^10.3.0",
156
157
  "mock-local-storage": "^1.1.24",
157
158
  "natives": "^1.1.6",
159
+ "nyc": "^17.0.0",
158
160
  "power-assert": "^1.6.1",
159
161
  "pre-commit": "^1.2.2",
160
162
  "pretty": "^2.0.0",
@@ -174,5 +176,19 @@
174
176
  "webpack-cli": "^5.1.1",
175
177
  "webpack-node-externals": "^3.0.0",
176
178
  "webpack-stream": "^7.0.0"
179
+ },
180
+ "nyc": {
181
+ "check-coverage": true,
182
+ "statements": 63,
183
+ "branches": 63,
184
+ "functions": 61,
185
+ "lines": 64,
186
+ "include": [
187
+ "src/**/*.js"
188
+ ],
189
+ "exclude": [
190
+ "src/**/fixtures"
191
+ ],
192
+ "all": true
177
193
  }
178
194
  }