@formio/js 5.2.0-rc.9 → 5.2.1-dev.6186.ffe4f6c

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 (81) hide show
  1. package/Changelog.md +6945 -0
  2. package/dist/formio.builder.css +15 -17
  3. package/dist/formio.builder.min.css +1 -1
  4. package/dist/formio.embed.js +1 -1
  5. package/dist/formio.embed.min.js +1 -1
  6. package/dist/formio.embed.min.js.LICENSE.txt +1 -1
  7. package/dist/formio.form.css +15 -17
  8. package/dist/formio.form.js +44 -55
  9. package/dist/formio.form.min.css +1 -1
  10. package/dist/formio.form.min.js +1 -1
  11. package/dist/formio.form.min.js.LICENSE.txt +3 -3
  12. package/dist/formio.full.css +15 -17
  13. package/dist/formio.full.js +46 -57
  14. package/dist/formio.full.min.css +1 -1
  15. package/dist/formio.full.min.js +1 -1
  16. package/dist/formio.full.min.js.LICENSE.txt +3 -3
  17. package/dist/formio.js +19 -30
  18. package/dist/formio.min.js +1 -1
  19. package/dist/formio.min.js.LICENSE.txt +1 -1
  20. package/dist/formio.utils.js +18 -29
  21. package/dist/formio.utils.min.js +1 -1
  22. package/dist/formio.utils.min.js.LICENSE.txt +1 -1
  23. package/lib/cjs/Embed.js +1 -1
  24. package/lib/cjs/Formio.js +1 -1
  25. package/lib/cjs/PDFBuilder.js +8 -6
  26. package/lib/cjs/Webform.js +3 -2
  27. package/lib/cjs/WebformBuilder.js +18 -11
  28. package/lib/cjs/Wizard.d.ts +1 -2
  29. package/lib/cjs/Wizard.js +17 -23
  30. package/lib/cjs/components/Components.js +7 -1
  31. package/lib/cjs/components/_classes/component/Component.d.ts +23 -2
  32. package/lib/cjs/components/_classes/component/Component.js +61 -35
  33. package/lib/cjs/components/_classes/nested/NestedComponent.d.ts +1 -0
  34. package/lib/cjs/components/_classes/nested/NestedComponent.js +11 -3
  35. package/lib/cjs/components/file/File.d.ts +1 -1
  36. package/lib/cjs/components/file/File.js +6 -1
  37. package/lib/cjs/components/form/Form.d.ts +0 -2
  38. package/lib/cjs/components/form/Form.js +12 -20
  39. package/lib/cjs/components/select/Select.d.ts +1 -1
  40. package/lib/cjs/components/select/Select.js +17 -26
  41. package/lib/cjs/components/tags/Tags.d.ts +1 -1
  42. package/lib/cjs/components/tags/Tags.js +2 -2
  43. package/lib/cjs/formio.form.js +1 -0
  44. package/lib/cjs/utils/ChoicesWrapper.d.ts +4 -25
  45. package/lib/cjs/utils/ChoicesWrapper.js +47 -124
  46. package/lib/cjs/utils/formUtils.d.ts +3 -3
  47. package/lib/cjs/utils/index.d.ts +5 -5
  48. package/lib/cjs/utils/utils.d.ts +4 -4
  49. package/lib/cjs/utils/utils.js +2 -2
  50. package/lib/cjs/widgets/CalendarWidget.d.ts +1 -1
  51. package/lib/cjs/widgets/CalendarWidget.js +1 -1
  52. package/lib/mjs/Embed.js +1 -1
  53. package/lib/mjs/Formio.js +1 -1
  54. package/lib/mjs/PDFBuilder.js +8 -6
  55. package/lib/mjs/Webform.js +2 -2
  56. package/lib/mjs/WebformBuilder.js +19 -12
  57. package/lib/mjs/Wizard.d.ts +1 -2
  58. package/lib/mjs/Wizard.js +16 -22
  59. package/lib/mjs/components/Components.js +7 -1
  60. package/lib/mjs/components/_classes/component/Component.d.ts +23 -2
  61. package/lib/mjs/components/_classes/component/Component.js +61 -35
  62. package/lib/mjs/components/_classes/nested/NestedComponent.d.ts +1 -0
  63. package/lib/mjs/components/_classes/nested/NestedComponent.js +11 -3
  64. package/lib/mjs/components/file/File.d.ts +1 -1
  65. package/lib/mjs/components/file/File.js +6 -1
  66. package/lib/mjs/components/form/Form.d.ts +0 -2
  67. package/lib/mjs/components/form/Form.js +12 -20
  68. package/lib/mjs/components/select/Select.d.ts +1 -1
  69. package/lib/mjs/components/select/Select.js +17 -25
  70. package/lib/mjs/components/tags/Tags.d.ts +1 -1
  71. package/lib/mjs/components/tags/Tags.js +2 -2
  72. package/lib/mjs/formio.form.js +1 -0
  73. package/lib/mjs/utils/ChoicesWrapper.d.ts +4 -25
  74. package/lib/mjs/utils/ChoicesWrapper.js +26 -119
  75. package/lib/mjs/utils/formUtils.d.ts +3 -3
  76. package/lib/mjs/utils/index.d.ts +5 -5
  77. package/lib/mjs/utils/utils.d.ts +4 -4
  78. package/lib/mjs/utils/utils.js +2 -2
  79. package/lib/mjs/widgets/CalendarWidget.d.ts +1 -1
  80. package/lib/mjs/widgets/CalendarWidget.js +1 -1
  81. package/package.json +5 -5
@@ -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,10 +26,10 @@ 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: 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, noScopeReset?: boolean | undefined, afterFn?: import("@formio/core").EachComponentDataAsyncCallback | 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, noScopeReset?: boolean | undefined, afterFn?: import("@formio/core").EachComponentDataCallback | undefined) => void;
31
31
  export const getComponentKey: typeof Utils.getComponentKey;
32
- export const getContextualRowPath: typeof Utils.getContextualRowPath;
32
+ export const getContextualRowPath: any;
33
33
  export const getContextualRowData: typeof Utils.getContextualRowData;
34
34
  export const componentInfo: typeof Utils.componentInfo;
35
35
  export const eachComponent: typeof Utils.eachComponent;
@@ -37,10 +37,10 @@ declare const FormioUtils: {
37
37
  getComponentFromPath: typeof import("@formio/core/lib/utils/formUtil").getComponentFromPath;
38
38
  getComponentValue: typeof import("@formio/core/lib/utils/formUtil").getComponentValue;
39
39
  findComponents: typeof import("@formio/core/lib/utils/formUtil").findComponents;
40
- 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>;
41
- 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;
40
+ 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, noScopeReset?: boolean | undefined, afterFn?: import("@formio/core").EachComponentDataAsyncCallback | undefined) => Promise<void>;
41
+ 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, noScopeReset?: boolean | undefined, afterFn?: import("@formio/core").EachComponentDataCallback | undefined) => void;
42
42
  getComponentKey: typeof import("@formio/core/lib/utils/formUtil").getComponentKey;
43
- getContextualRowPath: typeof import("@formio/core/lib/utils/formUtil").getContextualRowPath;
43
+ getContextualRowPath: any;
44
44
  getContextualRowData: typeof import("@formio/core/lib/utils/formUtil").getContextualRowData;
45
45
  componentInfo: typeof import("@formio/core/lib/utils/formUtil").componentInfo;
46
46
  eachComponent: typeof import("@formio/core/lib/utils/formUtil").eachComponent;
@@ -137,8 +137,8 @@ declare const FormioUtils: {
137
137
  translateHTMLTemplate(template: string, translate: Function): string;
138
138
  sanitize(string: string, options: any): string;
139
139
  fastCloneDeep(obj: any): any;
140
- isInputComponent(componentJson: import("@formio/core").Component): bool;
141
- getArrayFromComponentPath(pathStr: string): Arryay<number>;
140
+ isInputComponent(componentJson: import("@formio/core").Component): boolean;
141
+ getArrayFromComponentPath(pathStr: string): string[];
142
142
  isChildOf(child: any, parent: any): boolean;
143
143
  getStringFromComponentPath(path: number[]): string;
144
144
  round(number: number, precision: number): string;
@@ -414,15 +414,15 @@ export function fastCloneDeep(obj: any): any;
414
414
  /**
415
415
  * Returns if the component is an input component.
416
416
  * @param {import('@formio/core').Component} componentJson - The JSON of a component.
417
- * @returns {bool} - TRUE if the component is an input component; FALSE otherwise.
417
+ * @returns {boolean} - TRUE if the component is an input component; FALSE otherwise.
418
418
  */
419
- export function isInputComponent(componentJson: import('@formio/core').Component): bool;
419
+ export function isInputComponent(componentJson: import('@formio/core').Component): boolean;
420
420
  /**
421
421
  * Takes a component path, and returns a component path array.
422
422
  * @param {string} pathStr - The path string to convert to an array.
423
- * @returns {Arryay<number>} - The array of paths.
423
+ * @returns {Array<string>} - The array of paths.
424
424
  */
425
- export function getArrayFromComponentPath(pathStr: string): Arryay<number>;
425
+ export function getArrayFromComponentPath(pathStr: string): Array<string>;
426
426
  /**
427
427
  * Returns true if the component is a child of the parent.
428
428
  * @param {any} child - The child component to check.
@@ -1295,7 +1295,7 @@ export function fastCloneDeep(obj) {
1295
1295
  /**
1296
1296
  * Returns if the component is an input component.
1297
1297
  * @param {import('@formio/core').Component} componentJson - The JSON of a component.
1298
- * @returns {bool} - TRUE if the component is an input component; FALSE otherwise.
1298
+ * @returns {boolean} - TRUE if the component is an input component; FALSE otherwise.
1299
1299
  */
1300
1300
  export function isInputComponent(componentJson) {
1301
1301
  if (componentJson.input === false || componentJson.input === true) {
@@ -1319,7 +1319,7 @@ export function isInputComponent(componentJson) {
1319
1319
  /**
1320
1320
  * Takes a component path, and returns a component path array.
1321
1321
  * @param {string} pathStr - The path string to convert to an array.
1322
- * @returns {Arryay<number>} - The array of paths.
1322
+ * @returns {Array<string>} - The array of paths.
1323
1323
  */
1324
1324
  export function getArrayFromComponentPath(pathStr) {
1325
1325
  if (!pathStr || !_.isString(pathStr)) {
@@ -84,7 +84,7 @@ export default class CalendarWidget extends InputWidget {
84
84
  * @returns {void}
85
85
  */
86
86
  setValue(value: any): void;
87
- getValueAsString(value: any, format: any): string;
87
+ getValueAsString(value: any, format?: string): string;
88
88
  setErrorClasses(hasErrors: any): void;
89
89
  isCalendarElement(element: any): any;
90
90
  initFlatpickr(Flatpickr: any): void;
@@ -307,7 +307,7 @@ export default class CalendarWidget extends InputWidget {
307
307
  this.calendar.clear(false);
308
308
  }
309
309
  }
310
- getValueAsString(value, format) {
310
+ getValueAsString(value, format = '') {
311
311
  const inputFormat = format || this.dateFormat;
312
312
  const valueFormat = this.calendar ? this.valueFormat : this.settings.dateFormat;
313
313
  if (this.settings.saveAs === 'text' && this.componentInstance.parent && !this.settings.readOnly) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@formio/js",
3
- "version": "5.2.0-rc.9",
3
+ "version": "5.2.1-dev.6186.ffe4f6c",
4
4
  "description": "JavaScript powered Forms with JSON Form Builder",
5
5
  "main": "lib/cjs/index.js",
6
6
  "exports": {
@@ -79,9 +79,8 @@
79
79
  },
80
80
  "homepage": "https://github.com/formio/formio.js#readme",
81
81
  "dependencies": {
82
- "@formio/bootstrap": "3.1.1",
83
- "@formio/choices.js": "^10.2.1",
84
- "@formio/core": "2.5.0-rc.5",
82
+ "@formio/bootstrap": "3.1.2-rc.1",
83
+ "@formio/core": "2.5.1-rc.5",
85
84
  "@formio/text-mask-addons": "^3.8.0-formio.4",
86
85
  "@formio/vanilla-text-mask": "^5.1.1-formio.1",
87
86
  "abortcontroller-polyfill": "^1.7.5",
@@ -89,7 +88,8 @@
89
88
  "bootstrap": "^5.3.3",
90
89
  "browser-cookies": "^1.2.0",
91
90
  "browser-md5-file": "^1.1.1",
92
- "compare-versions": "^6.0.0-rc.2",
91
+ "choices.js": "^11.0.6",
92
+ "compare-versions": "^6.1.1",
93
93
  "core-js": "^3.37.1",
94
94
  "dialog-polyfill": "^0.5.6",
95
95
  "dom-autoscroller": "^2.3.4",