@formio/js 5.2.0-rc.9 → 5.2.1-rc.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/formio.builder.css +15 -17
- package/dist/formio.builder.min.css +1 -1
- package/dist/formio.embed.js +1 -1
- package/dist/formio.embed.min.js +1 -1
- package/dist/formio.embed.min.js.LICENSE.txt +1 -1
- package/dist/formio.form.css +15 -17
- package/dist/formio.form.js +31 -31
- package/dist/formio.form.min.css +1 -1
- package/dist/formio.form.min.js +1 -1
- package/dist/formio.form.min.js.LICENSE.txt +3 -3
- package/dist/formio.full.css +15 -17
- package/dist/formio.full.js +32 -32
- package/dist/formio.full.min.css +1 -1
- package/dist/formio.full.min.js +1 -1
- package/dist/formio.full.min.js.LICENSE.txt +3 -3
- package/dist/formio.js +6 -6
- package/dist/formio.min.js +1 -1
- package/dist/formio.min.js.LICENSE.txt +1 -1
- package/dist/formio.utils.js +5 -5
- package/dist/formio.utils.min.js +1 -1
- package/dist/formio.utils.min.js.LICENSE.txt +1 -1
- package/lib/cjs/Embed.js +1 -1
- package/lib/cjs/Formio.js +1 -1
- package/lib/cjs/Webform.js +2 -1
- package/lib/cjs/WebformBuilder.js +18 -11
- package/lib/cjs/Wizard.d.ts +1 -2
- package/lib/cjs/Wizard.js +17 -23
- package/lib/cjs/components/Components.js +7 -1
- package/lib/cjs/components/_classes/component/Component.d.ts +23 -2
- package/lib/cjs/components/_classes/component/Component.js +61 -35
- package/lib/cjs/components/_classes/nested/NestedComponent.d.ts +1 -0
- package/lib/cjs/components/_classes/nested/NestedComponent.js +11 -3
- package/lib/cjs/components/file/File.d.ts +1 -1
- package/lib/cjs/components/file/File.js +6 -1
- package/lib/cjs/components/form/Form.d.ts +0 -2
- package/lib/cjs/components/form/Form.js +12 -20
- package/lib/cjs/components/select/Select.d.ts +0 -1
- package/lib/cjs/components/select/Select.js +3 -23
- package/lib/cjs/components/tags/Tags.d.ts +1 -1
- package/lib/cjs/components/tags/Tags.js +2 -2
- package/lib/cjs/formio.form.js +1 -0
- package/lib/cjs/utils/ChoicesWrapper.d.ts +4 -25
- package/lib/cjs/utils/ChoicesWrapper.js +47 -124
- package/lib/cjs/utils/formUtils.d.ts +2 -2
- package/lib/cjs/utils/index.d.ts +4 -4
- package/lib/cjs/utils/utils.d.ts +4 -4
- package/lib/cjs/utils/utils.js +2 -2
- package/lib/cjs/widgets/CalendarWidget.d.ts +1 -1
- package/lib/cjs/widgets/CalendarWidget.js +1 -1
- package/lib/mjs/Embed.js +1 -1
- package/lib/mjs/Formio.js +1 -1
- package/lib/mjs/Webform.js +1 -1
- package/lib/mjs/WebformBuilder.js +19 -12
- package/lib/mjs/Wizard.d.ts +1 -2
- package/lib/mjs/Wizard.js +16 -22
- package/lib/mjs/components/Components.js +7 -1
- package/lib/mjs/components/_classes/component/Component.d.ts +23 -2
- package/lib/mjs/components/_classes/component/Component.js +61 -35
- package/lib/mjs/components/_classes/nested/NestedComponent.d.ts +1 -0
- package/lib/mjs/components/_classes/nested/NestedComponent.js +11 -3
- package/lib/mjs/components/file/File.d.ts +1 -1
- package/lib/mjs/components/file/File.js +6 -1
- package/lib/mjs/components/form/Form.d.ts +0 -2
- package/lib/mjs/components/form/Form.js +12 -20
- package/lib/mjs/components/select/Select.d.ts +0 -1
- package/lib/mjs/components/select/Select.js +3 -22
- package/lib/mjs/components/tags/Tags.d.ts +1 -1
- package/lib/mjs/components/tags/Tags.js +2 -2
- package/lib/mjs/formio.form.js +1 -0
- package/lib/mjs/utils/ChoicesWrapper.d.ts +4 -25
- package/lib/mjs/utils/ChoicesWrapper.js +26 -119
- package/lib/mjs/utils/formUtils.d.ts +2 -2
- package/lib/mjs/utils/index.d.ts +4 -4
- package/lib/mjs/utils/utils.d.ts +4 -4
- package/lib/mjs/utils/utils.js +2 -2
- package/lib/mjs/widgets/CalendarWidget.d.ts +1 -1
- package/lib/mjs/widgets/CalendarWidget.js +1 -1
- package/package.json +5 -5
package/lib/cjs/formio.form.js
CHANGED
@@ -73,6 +73,7 @@ function registerModule(mod, defaultFn = null, options = {}) {
|
|
73
73
|
case 'templates':
|
74
74
|
for (const framework of Object.keys(mod.templates)) {
|
75
75
|
Formio_1.Formio.Templates.extendTemplate(framework, mod.templates[framework]);
|
76
|
+
Formio_1.Formio.Templates.defaultTemplates = lodash_1.default.defaults(mod.templates[framework], Formio_1.Formio.Templates.defaultTemplates);
|
76
77
|
}
|
77
78
|
if (mod.templates[current]) {
|
78
79
|
Formio_1.Formio.Templates.current = mod.templates[current];
|
@@ -1,38 +1,17 @@
|
|
1
|
-
export namespace KEY_CODES {
|
2
|
-
let BACK_KEY: number;
|
3
|
-
let DELETE_KEY: number;
|
4
|
-
let TAB_KEY: number;
|
5
|
-
let ENTER_KEY: number;
|
6
|
-
let A_KEY: number;
|
7
|
-
let ESC_KEY: number;
|
8
|
-
let UP_KEY: number;
|
9
|
-
let DOWN_KEY: number;
|
10
|
-
let PAGE_UP_KEY: number;
|
11
|
-
let PAGE_DOWN_KEY: number;
|
12
|
-
}
|
13
1
|
export default ChoicesWrapper;
|
14
2
|
declare class ChoicesWrapper extends Choices {
|
15
3
|
constructor(...args: any[]);
|
16
|
-
_onTabKey(
|
17
|
-
activeItems: any;
|
18
|
-
hasActiveDropdown: any;
|
19
|
-
}): void;
|
4
|
+
_onTabKey(): void;
|
20
5
|
isDirectionUsing: boolean;
|
21
6
|
shouldOpenDropDown: boolean;
|
22
7
|
_onTouchEnd(event: any): void;
|
23
|
-
|
24
|
-
_onEnterKey(args: any): void;
|
8
|
+
_onEnterKey(...args: any[]): void;
|
25
9
|
_onDirectionKey(...args: any[]): void;
|
26
10
|
timeout: NodeJS.Timeout | undefined;
|
27
11
|
_selectHighlightedChoice(): void;
|
28
12
|
_onKeyDown(event: any): void;
|
29
|
-
onSelectValue(
|
30
|
-
event: any;
|
31
|
-
activeItems: any;
|
32
|
-
hasActiveDropdown: any;
|
33
|
-
}): void;
|
13
|
+
onSelectValue(event: any, hasActiveDropdown: any): void;
|
34
14
|
showDropdown(...args: any[]): void;
|
35
15
|
hideDropdown(...args: any[]): void;
|
36
|
-
_onBlur(...args: any[]): void;
|
37
16
|
}
|
38
|
-
import Choices from '
|
17
|
+
import Choices from 'choices.js';
|
@@ -1,48 +1,30 @@
|
|
1
1
|
"use strict";
|
2
|
-
var
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
const choices_js_1 = __importDefault(require("@formio/choices.js"));
|
8
|
-
/**
|
9
|
-
* TODO: REMOVE THIS ONCE THE PULL REQUEST HAS BEEN RESOLVED.
|
10
|
-
*
|
11
|
-
* https://github.com/jshjohnson/Choices/pull/788
|
12
|
-
*
|
13
|
-
* This is intentionally not part of the extended class, since other components use Choices and need this fix as well.
|
14
|
-
* @type {Choices._generatePlaceholderValue}
|
15
|
-
* @private
|
16
|
-
*/
|
17
|
-
choices_js_1.default.prototype._generatePlaceholderValue = function () {
|
18
|
-
if (this._isSelectElement && this.passedElement.placeholderOption) {
|
19
|
-
const { placeholderOption } = this.passedElement;
|
20
|
-
return placeholderOption ? placeholderOption.text : false;
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
3
|
+
if (k2 === undefined) k2 = k;
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
21
7
|
}
|
22
|
-
|
23
|
-
|
24
|
-
if (
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
ENTER_KEY: 13,
|
39
|
-
A_KEY: 65,
|
40
|
-
ESC_KEY: 27,
|
41
|
-
UP_KEY: 38,
|
42
|
-
DOWN_KEY: 40,
|
43
|
-
PAGE_UP_KEY: 33,
|
44
|
-
PAGE_DOWN_KEY: 34,
|
8
|
+
Object.defineProperty(o, k2, desc);
|
9
|
+
}) : (function(o, m, k, k2) {
|
10
|
+
if (k2 === undefined) k2 = k;
|
11
|
+
o[k2] = m[k];
|
12
|
+
}));
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
15
|
+
}) : function(o, v) {
|
16
|
+
o["default"] = v;
|
17
|
+
});
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
19
|
+
if (mod && mod.__esModule) return mod;
|
20
|
+
var result = {};
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
22
|
+
__setModuleDefault(result, mod);
|
23
|
+
return result;
|
45
24
|
};
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
26
|
+
const choices_js_1 = __importStar(require("choices.js"));
|
27
|
+
const ExtendedKeyCodeMap = Object.assign(Object.assign({}, choices_js_1.KeyCodeMap), { TAB_KEY: 9 });
|
46
28
|
class ChoicesWrapper extends choices_js_1.default {
|
47
29
|
constructor(...args) {
|
48
30
|
super(...args);
|
@@ -69,24 +51,13 @@ class ChoicesWrapper extends choices_js_1.default {
|
|
69
51
|
}
|
70
52
|
this._wasTap = true;
|
71
53
|
}
|
72
|
-
|
73
|
-
|
74
|
-
return super._handleButtonAction(activeItems, element);
|
75
|
-
}
|
76
|
-
if (!activeItems ||
|
77
|
-
!element ||
|
78
|
-
!this.config.removeItems ||
|
79
|
-
!this.config.removeItemButton) {
|
80
|
-
return;
|
81
|
-
}
|
82
|
-
super._handleButtonAction(activeItems, element);
|
83
|
-
}
|
84
|
-
_onEnterKey(args) {
|
54
|
+
_onEnterKey(...args) {
|
55
|
+
const [event] = args;
|
85
56
|
// Prevent dropdown form opening when removeItemButton was pressed using 'Enter' on keyboard
|
86
|
-
if (
|
57
|
+
if (event.target.className === 'choices__button') {
|
87
58
|
this.shouldOpenDropDown = false;
|
88
59
|
}
|
89
|
-
super._onEnterKey(args);
|
60
|
+
super._onEnterKey(...args);
|
90
61
|
}
|
91
62
|
_onDirectionKey(...args) {
|
92
63
|
if (!this._isSelectOneElement) {
|
@@ -100,17 +71,18 @@ class ChoicesWrapper extends choices_js_1.default {
|
|
100
71
|
this.isDirectionUsing = false;
|
101
72
|
}, 250);
|
102
73
|
}
|
103
|
-
_onTabKey(
|
104
|
-
if (
|
105
|
-
this._selectHighlightedChoice(
|
74
|
+
_onTabKey() {
|
75
|
+
if (this.dropdown.isActive) {
|
76
|
+
this._selectHighlightedChoice();
|
106
77
|
}
|
107
78
|
}
|
108
79
|
_selectHighlightedChoice() {
|
109
|
-
const highlightedChoice = this.dropdown.
|
80
|
+
const highlightedChoice = this.dropdown.element.querySelector(`.${this.config.classNames.highlightedState}`);
|
110
81
|
if (highlightedChoice) {
|
111
82
|
const id = highlightedChoice.dataset.id;
|
112
|
-
const choice = id && this._store.getChoiceById(id);
|
83
|
+
const choice = id && this._store.getChoiceById(Number(id));
|
113
84
|
this._addItem({
|
85
|
+
id: choice.id,
|
114
86
|
value: choice.value,
|
115
87
|
label: choice.label,
|
116
88
|
choiceId: choice.id,
|
@@ -121,61 +93,16 @@ class ChoicesWrapper extends choices_js_1.default {
|
|
121
93
|
});
|
122
94
|
this._triggerChange(choice.value);
|
123
95
|
}
|
124
|
-
event.preventDefault();
|
125
96
|
}
|
126
97
|
_onKeyDown(event) {
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
if (target !== this.input.element &&
|
132
|
-
!this.containerOuter.element.contains(target)) {
|
133
|
-
return;
|
134
|
-
}
|
135
|
-
const activeItems = this._store.activeItems;
|
136
|
-
const hasFocusedInput = this.input.isFocussed;
|
137
|
-
const hasActiveDropdown = this.dropdown.isActive;
|
138
|
-
const hasItems = this.itemList.hasChildren;
|
139
|
-
const keyString = String.fromCharCode(keyCode);
|
140
|
-
const { BACK_KEY, DELETE_KEY, TAB_KEY, ENTER_KEY, A_KEY, ESC_KEY, UP_KEY, DOWN_KEY, PAGE_UP_KEY, PAGE_DOWN_KEY, } = exports.KEY_CODES;
|
141
|
-
const hasCtrlDownKeyPressed = ctrlKey || metaKey;
|
142
|
-
// If a user is typing and the dropdown is not active
|
143
|
-
if (!hasActiveDropdown && !this._isTextElement && /[a-zA-Z0-9-_ ]/.test(keyString)) {
|
144
|
-
const currentValue = this.input.element.value;
|
145
|
-
this.input.element.value = currentValue ? `${currentValue}${keyString}` : keyString;
|
146
|
-
this.showDropdown();
|
147
|
-
}
|
148
|
-
// Map keys to key actions
|
149
|
-
const keyDownActions = {
|
150
|
-
[A_KEY]: this._onAKey,
|
151
|
-
[TAB_KEY]: this._onTabKey,
|
152
|
-
[ENTER_KEY]: this._onEnterKey,
|
153
|
-
[ESC_KEY]: this._onEscapeKey,
|
154
|
-
[UP_KEY]: this._onDirectionKey,
|
155
|
-
[PAGE_UP_KEY]: this._onDirectionKey,
|
156
|
-
[DOWN_KEY]: this._onDirectionKey,
|
157
|
-
[PAGE_DOWN_KEY]: this._onDirectionKey,
|
158
|
-
[DELETE_KEY]: this._onDeleteKey,
|
159
|
-
[BACK_KEY]: this._onDeleteKey,
|
160
|
-
};
|
161
|
-
// If keycode has a function, run it
|
162
|
-
if (keyDownActions[keyCode]) {
|
163
|
-
keyDownActions[keyCode]({
|
164
|
-
event,
|
165
|
-
target,
|
166
|
-
keyCode,
|
167
|
-
metaKey,
|
168
|
-
activeItems,
|
169
|
-
hasFocusedInput,
|
170
|
-
hasActiveDropdown,
|
171
|
-
hasItems,
|
172
|
-
hasCtrlDownKeyPressed,
|
173
|
-
});
|
174
|
-
}
|
98
|
+
const keyCode = event.keyCode;
|
99
|
+
return this._isSelectOneElement && keyCode === ExtendedKeyCodeMap.TAB_KEY
|
100
|
+
? this._onTabKey()
|
101
|
+
: super._onKeyDown(event);
|
175
102
|
}
|
176
|
-
onSelectValue(
|
103
|
+
onSelectValue(event, hasActiveDropdown) {
|
177
104
|
if (hasActiveDropdown) {
|
178
|
-
this._selectHighlightedChoice(
|
105
|
+
this._selectHighlightedChoice();
|
179
106
|
}
|
180
107
|
else if (this._isSelectOneElement) {
|
181
108
|
this.showDropdown();
|
@@ -183,11 +110,13 @@ class ChoicesWrapper extends choices_js_1.default {
|
|
183
110
|
}
|
184
111
|
}
|
185
112
|
showDropdown(...args) {
|
186
|
-
|
187
|
-
this.shouldOpenDropDown
|
188
|
-
|
189
|
-
|
190
|
-
|
113
|
+
setTimeout(() => {
|
114
|
+
if (!this.shouldOpenDropDown) {
|
115
|
+
this.shouldOpenDropDown = true;
|
116
|
+
return;
|
117
|
+
}
|
118
|
+
super.showDropdown(...args);
|
119
|
+
}, 0);
|
191
120
|
}
|
192
121
|
hideDropdown(...args) {
|
193
122
|
if (this.isDirectionUsing) {
|
@@ -195,11 +124,5 @@ class ChoicesWrapper extends choices_js_1.default {
|
|
195
124
|
}
|
196
125
|
super.hideDropdown(...args);
|
197
126
|
}
|
198
|
-
_onBlur(...args) {
|
199
|
-
if (this._isScrollingOnIe) {
|
200
|
-
return;
|
201
|
-
}
|
202
|
-
super._onBlur(...args);
|
203
|
-
}
|
204
127
|
}
|
205
128
|
exports.default = ChoicesWrapper;
|
@@ -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: 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) => 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) => 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;
|
package/lib/cjs/utils/index.d.ts
CHANGED
@@ -37,8 +37,8 @@ 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) => 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) => void;
|
42
42
|
getComponentKey: typeof import("@formio/core/lib/utils/formUtil").getComponentKey;
|
43
43
|
getContextualRowPath: typeof import("@formio/core/lib/utils/formUtil").getContextualRowPath;
|
44
44
|
getContextualRowData: typeof import("@formio/core/lib/utils/formUtil").getContextualRowData;
|
@@ -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):
|
141
|
-
getArrayFromComponentPath(pathStr: string):
|
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;
|
package/lib/cjs/utils/utils.d.ts
CHANGED
@@ -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 {
|
417
|
+
* @returns {boolean} - TRUE if the component is an input component; FALSE otherwise.
|
418
418
|
*/
|
419
|
-
export function isInputComponent(componentJson: import('@formio/core').Component):
|
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 {
|
423
|
+
* @returns {Array<string>} - The array of paths.
|
424
424
|
*/
|
425
|
-
export function getArrayFromComponentPath(pathStr: string):
|
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.
|
package/lib/cjs/utils/utils.js
CHANGED
@@ -1357,7 +1357,7 @@ exports.fastCloneDeep = fastCloneDeep;
|
|
1357
1357
|
/**
|
1358
1358
|
* Returns if the component is an input component.
|
1359
1359
|
* @param {import('@formio/core').Component} componentJson - The JSON of a component.
|
1360
|
-
* @returns {
|
1360
|
+
* @returns {boolean} - TRUE if the component is an input component; FALSE otherwise.
|
1361
1361
|
*/
|
1362
1362
|
function isInputComponent(componentJson) {
|
1363
1363
|
if (componentJson.input === false || componentJson.input === true) {
|
@@ -1382,7 +1382,7 @@ exports.isInputComponent = isInputComponent;
|
|
1382
1382
|
/**
|
1383
1383
|
* Takes a component path, and returns a component path array.
|
1384
1384
|
* @param {string} pathStr - The path string to convert to an array.
|
1385
|
-
* @returns {
|
1385
|
+
* @returns {Array<string>} - The array of paths.
|
1386
1386
|
*/
|
1387
1387
|
function getArrayFromComponentPath(pathStr) {
|
1388
1388
|
if (!pathStr || !lodash_1.default.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
|
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;
|
@@ -315,7 +315,7 @@ class CalendarWidget extends InputWidget_1.default {
|
|
315
315
|
this.calendar.clear(false);
|
316
316
|
}
|
317
317
|
}
|
318
|
-
getValueAsString(value, format) {
|
318
|
+
getValueAsString(value, format = '') {
|
319
319
|
const inputFormat = format || this.dateFormat;
|
320
320
|
const valueFormat = this.calendar ? this.valueFormat : this.settings.dateFormat;
|
321
321
|
if (this.settings.saveAs === 'text' && this.componentInstance.parent && !this.settings.readOnly) {
|
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.2.
|
17
|
+
static version = '5.2.1-rc.1';
|
18
18
|
static setLicense(license, norecurse = false) {
|
19
19
|
Formio.license = license;
|
20
20
|
if (!norecurse && Formio.FormioClass) {
|
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.2.
|
7
|
+
FormioCore.version = '5.2.1-rc.1';
|
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) {
|
package/lib/mjs/Webform.js
CHANGED
@@ -744,7 +744,7 @@ export default class Webform extends NestedDataComponent {
|
|
744
744
|
this.emit(restoreDraft ? "restoreDraftError" : "saveDraftError", errDetails || errorMessage);
|
745
745
|
}
|
746
746
|
saveDraft() {
|
747
|
-
if (!this.draftEnabled) {
|
747
|
+
if (!this.draftEnabled || this.parent?.component.reference === false) {
|
748
748
|
return;
|
749
749
|
}
|
750
750
|
if (!this.formio) {
|
@@ -3,7 +3,7 @@ import Component from './components/_classes/component/Component';
|
|
3
3
|
import tippy from 'tippy.js';
|
4
4
|
import Components from './components/Components';
|
5
5
|
import { Formio } from './Formio';
|
6
|
-
import { fastCloneDeep, bootstrapVersion, getArrayFromComponentPath, getStringFromComponentPath, eachComponent, getComponent, } from './utils';
|
6
|
+
import { fastCloneDeep, bootstrapVersion, getArrayFromComponentPath, getStringFromComponentPath, eachComponent, getComponent, componentInfo } from './utils';
|
7
7
|
import BuilderUtils from './utils/builder';
|
8
8
|
import _ from 'lodash';
|
9
9
|
import autoScroll from 'dom-autoscroller';
|
@@ -1115,15 +1115,18 @@ export default class WebformBuilder extends Component {
|
|
1115
1115
|
const keys = new Map();
|
1116
1116
|
eachComponent(this.form.components, (comp, path, components, parent, paths) => {
|
1117
1117
|
const isRadioCheckbox = comp.type === 'checkbox' && comp.inputType === 'radio';
|
1118
|
-
|
1119
|
-
|
1120
|
-
|
1121
|
-
|
1122
|
-
|
1123
|
-
|
1124
|
-
|
1125
|
-
|
1126
|
-
|
1118
|
+
const isLayout = componentInfo(comp).layout;
|
1119
|
+
if (!isLayout) {
|
1120
|
+
if (keys.has(paths.dataPath)) {
|
1121
|
+
const onlyRadioCheckboxes = repeatablePaths[paths.dataPath]?.onlyRadioCheckboxes === false ? false : isRadioCheckbox;
|
1122
|
+
repeatablePaths[paths.dataPath] = {
|
1123
|
+
comps: [...(repeatablePaths[paths.dataPath]?.comps || []), keys.get(paths.dataPath), comp],
|
1124
|
+
onlyRadioCheckboxes,
|
1125
|
+
};
|
1126
|
+
}
|
1127
|
+
else {
|
1128
|
+
keys.set(paths.dataPath, comp);
|
1129
|
+
}
|
1127
1130
|
}
|
1128
1131
|
}, true);
|
1129
1132
|
const componentsWithRepeatablePaths = [];
|
@@ -1143,6 +1146,9 @@ export default class WebformBuilder extends Component {
|
|
1143
1146
|
comp.setCustomValidity(this.t('apiKey', { key: comp.key }));
|
1144
1147
|
hasInvalidComponents = true;
|
1145
1148
|
}
|
1149
|
+
else {
|
1150
|
+
comp.setCustomValidity();
|
1151
|
+
}
|
1146
1152
|
});
|
1147
1153
|
this.emit('builderFormValidityChange', hasInvalidComponents);
|
1148
1154
|
}
|
@@ -1261,7 +1267,8 @@ export default class WebformBuilder extends Component {
|
|
1261
1267
|
helplinks: this.helplinks,
|
1262
1268
|
}));
|
1263
1269
|
this.editForm.attach(this.componentEdit.querySelector(`[${this._referenceAttributeName}="editForm"]`));
|
1264
|
-
this.
|
1270
|
+
const editFormData = this.editForm.submission?.data;
|
1271
|
+
this.updateComponent(editFormData?.componentJson || editFormData || component);
|
1265
1272
|
this.attachEditComponentControls(component, parent, isNew, original, ComponentClass);
|
1266
1273
|
});
|
1267
1274
|
});
|
@@ -1648,7 +1655,7 @@ export default class WebformBuilder extends Component {
|
|
1648
1655
|
}
|
1649
1656
|
hasEditTabs(type) {
|
1650
1657
|
// If the component type does not exist then it has no edit tabs
|
1651
|
-
if (!Components.components[type]) {
|
1658
|
+
if (!Components.components[type === 'custom' ? 'unknown' : type]) {
|
1652
1659
|
return false;
|
1653
1660
|
}
|
1654
1661
|
const editTabs = getComponent(Components.components[type === 'custom' ? 'unknown' : type].editForm().components, 'tabs', true).components;
|
package/lib/mjs/Wizard.d.ts
CHANGED
@@ -6,7 +6,6 @@ declare class Wizard extends Webform {
|
|
6
6
|
originalComponents: any[];
|
7
7
|
page: number;
|
8
8
|
currentPanel: any;
|
9
|
-
currentPanels: any[] | null;
|
10
9
|
currentNextPage: number;
|
11
10
|
_seenPages: number[];
|
12
11
|
subWizards: any[];
|
@@ -17,7 +16,7 @@ declare class Wizard extends Webform {
|
|
17
16
|
originalOptions: any;
|
18
17
|
isLastPage(): any;
|
19
18
|
getPages(args?: {}): any[];
|
20
|
-
get
|
19
|
+
get hasSubWizards(): boolean;
|
21
20
|
get localData(): any;
|
22
21
|
get wizardKey(): string;
|
23
22
|
set wizard(form: object);
|
package/lib/mjs/Wizard.js
CHANGED
@@ -29,7 +29,6 @@ export default class Wizard extends Webform {
|
|
29
29
|
this.originalComponents = [];
|
30
30
|
this.page = 0;
|
31
31
|
this.currentPanel = null;
|
32
|
-
this.currentPanels = null;
|
33
32
|
this.currentNextPage = 0;
|
34
33
|
this._seenPages = [0];
|
35
34
|
this.subWizards = [];
|
@@ -48,12 +47,12 @@ export default class Wizard extends Webform {
|
|
48
47
|
}
|
49
48
|
getPages(args = {}) {
|
50
49
|
const { all = false } = args;
|
51
|
-
const pages = this.
|
50
|
+
const pages = this.hasSubWizards ? this.components : this.pages;
|
52
51
|
const filteredPages = pages
|
53
52
|
.filter(all ? _.identity : (p, index) => this._seenPages.includes(index));
|
54
53
|
return filteredPages;
|
55
54
|
}
|
56
|
-
get
|
55
|
+
get hasSubWizards() {
|
57
56
|
return !_.isEmpty(this.subWizards);
|
58
57
|
}
|
59
58
|
get data() {
|
@@ -177,9 +176,9 @@ export default class Wizard extends Webform {
|
|
177
176
|
}
|
178
177
|
render() {
|
179
178
|
const ctx = this.renderContext;
|
180
|
-
if (this.component.
|
181
|
-
ctx.panels.
|
182
|
-
if (panel.
|
179
|
+
if (this.component.id) {
|
180
|
+
ctx.panels.forEach(panel => {
|
181
|
+
if (panel.id === this.component.id) {
|
183
182
|
this.currentPanel = panel;
|
184
183
|
ctx.wizardPageTooltip = this.getFormattedTooltip(panel.tooltip);
|
185
184
|
}
|
@@ -580,7 +579,7 @@ export default class Wizard extends Webform {
|
|
580
579
|
this.pageFieldLogic(num);
|
581
580
|
this.getNextPage();
|
582
581
|
let parentNum = num;
|
583
|
-
if (this.
|
582
|
+
if (this.hasSubWizards) {
|
584
583
|
const pageFromPages = this.pages[num];
|
585
584
|
const pageFromComponents = this.components[num];
|
586
585
|
if (!pageFromComponents || pageFromPages?.id !== pageFromComponents.id) {
|
@@ -869,23 +868,18 @@ export default class Wizard extends Webform {
|
|
869
868
|
this.showErrors(errors, true, true);
|
870
869
|
}
|
871
870
|
// If the pages change, need to redraw the header.
|
872
|
-
|
873
|
-
|
871
|
+
const currentPanels = this.pages;
|
872
|
+
// calling this.establishPages() updates/mutates this.pages to be the current pages
|
873
|
+
this.establishPages();
|
874
|
+
const newPanels = this.pages;
|
874
875
|
const currentNextPage = this.currentNextPage;
|
875
|
-
|
876
|
-
|
877
|
-
this.
|
878
|
-
|
879
|
-
|
880
|
-
else {
|
881
|
-
currentPanels = this.currentPanels || this.pages.map(page => page.component.key);
|
882
|
-
panels = this.establishPages().map(panel => panel.key);
|
883
|
-
this.currentPanels = panels;
|
884
|
-
if (this.currentPanel?.key && this.currentPanels?.length) {
|
885
|
-
this.setPage(this.currentPanels.findIndex(panel => panel === this.currentPanel.key));
|
886
|
-
}
|
876
|
+
const panelsUpdated = !_.isEqual(newPanels, currentPanels);
|
877
|
+
if (this.currentPanel?.id && this.pages.length && (!this.hasSubWizards || (this.hasSubWizards && panelsUpdated))) {
|
878
|
+
const newIndex = this.pages.findIndex(page => page.id === this.currentPanel.id);
|
879
|
+
if (newIndex !== -1)
|
880
|
+
this.setPage(newIndex);
|
887
881
|
}
|
888
|
-
if (
|
882
|
+
if (panelsUpdated || (flags && flags.fromSubmission)) {
|
889
883
|
this.redrawHeader();
|
890
884
|
}
|
891
885
|
// If the next page changes, then make sure to redraw navigation.
|
@@ -54,7 +54,7 @@ export default class Components {
|
|
54
54
|
// eslint-disable-next-line new-cap
|
55
55
|
comp = new Components.components['datagrid'](component, options, data);
|
56
56
|
}
|
57
|
-
else if (component.tree) {
|
57
|
+
else if (component.tree || (component.input && Array.isArray(component.components))) {
|
58
58
|
// eslint-disable-next-line new-cap
|
59
59
|
comp = new Components.components['nesteddata'](component, options, data);
|
60
60
|
}
|
@@ -72,6 +72,12 @@ export default class Components {
|
|
72
72
|
if (comp.path) {
|
73
73
|
comp.componentsMap[comp.path] = comp;
|
74
74
|
}
|
75
|
+
// Reset the componentMatches on the root element if any new component is created.
|
76
|
+
let parent = comp.parent;
|
77
|
+
while (parent) {
|
78
|
+
parent.componentMatches = {};
|
79
|
+
parent = parent.parent;
|
80
|
+
}
|
75
81
|
return comp;
|
76
82
|
}
|
77
83
|
}
|
@@ -165,10 +165,16 @@ declare class Component extends Element {
|
|
165
165
|
get componentsMap(): object;
|
166
166
|
/**
|
167
167
|
* Returns if the parent should conditionally clear.
|
168
|
+
*
|
168
169
|
* @returns {boolean} - If the parent should conditionally clear.
|
169
170
|
*/
|
170
171
|
parentShouldConditionallyClear(): boolean;
|
171
172
|
parentConditionallyHidden(): boolean;
|
173
|
+
/**
|
174
|
+
* Returns true if any of the parents default their component "hidden" property to true.
|
175
|
+
* @returns {boolean} - If any parent defaults the hidden property to true.
|
176
|
+
*/
|
177
|
+
anyParentDefaultsHidden(): boolean;
|
172
178
|
set data(value: any);
|
173
179
|
get data(): any;
|
174
180
|
mergeSchema(component?: {}): any;
|
@@ -232,8 +238,23 @@ declare class Component extends Element {
|
|
232
238
|
get visible(): boolean;
|
233
239
|
get logicallyHidden(): any;
|
234
240
|
_logicallyHidden: any;
|
235
|
-
|
236
|
-
|
241
|
+
/**
|
242
|
+
* Determines if the component should clear its value when the root form is pristine.
|
243
|
+
* @returns {boolean} - If the component should clear its value when the root form is pristine.
|
244
|
+
*/
|
245
|
+
shouldConditionallyClearOnPristine(): boolean;
|
246
|
+
/**
|
247
|
+
* Returns if the component should clear its value when conditionally hidden.
|
248
|
+
* @returns {boolean} - If the component should clear its value when conditionally hidden.
|
249
|
+
*/
|
250
|
+
shouldConditionallyClear(): boolean;
|
251
|
+
_conditionallyClear: boolean | undefined;
|
252
|
+
/**
|
253
|
+
* Returns if the component is conditionally hidden.
|
254
|
+
* @returns {boolean} - If the component is conditionally hidden.
|
255
|
+
*/
|
256
|
+
conditionallyHidden(): boolean;
|
257
|
+
_conditionallyHidden: boolean | undefined;
|
237
258
|
set currentForm(instance: any);
|
238
259
|
get currentForm(): any;
|
239
260
|
_currentForm: any;
|