@aemforms/af-core 0.22.65 → 0.22.67
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/lib/Form.js +28 -28
- package/lib/rules/FunctionRuntime.js +1 -1
- package/package.json +2 -2
package/lib/Form.js
CHANGED
|
@@ -7,7 +7,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
7
7
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
8
8
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
9
9
|
};
|
|
10
|
-
var _Form_instances, _Form_getNavigableChildren, _Form_getFirstNavigableChild, _Form_setActiveFirstDeepChild, _Form_getNextItem, _Form_getPreviousItem;
|
|
10
|
+
var _Form_instances, _Form_getNavigableChildren, _Form_getFirstNavigableChild, _Form_setActiveFirstDeepChild, _Form_getNextItem, _Form_getPreviousItem, _Form_clearCurrentFocus;
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
const Container_1 = __importDefault(require("./Container"));
|
|
13
13
|
const FormMetaData_1 = __importDefault(require("./FormMetaData"));
|
|
@@ -82,34 +82,28 @@ class Form extends Container_1.default {
|
|
|
82
82
|
return submitMetaInstance;
|
|
83
83
|
}
|
|
84
84
|
setFocus(field, focusOption) {
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
let activeChild = parent.activeChild;
|
|
90
|
-
let currActiveChildIndex = activeChild !== null ? navigableChidren.indexOf(activeChild) : -1;
|
|
91
|
-
if (parent.activeChild === null) {
|
|
92
|
-
parent.activeChild = navigableChidren[0];
|
|
93
|
-
currActiveChildIndex = 0;
|
|
94
|
-
return;
|
|
95
|
-
}
|
|
96
|
-
if (focusOption === Model_1.FocusOption.NEXT_ITEM) {
|
|
97
|
-
activeChild = __classPrivateFieldGet(this, _Form_instances, "m", _Form_getNextItem).call(this, currActiveChildIndex, navigableChidren);
|
|
98
|
-
}
|
|
99
|
-
else if (focusOption === Model_1.FocusOption.PREVIOUS_ITEM) {
|
|
100
|
-
activeChild = __classPrivateFieldGet(this, _Form_instances, "m", _Form_getPreviousItem).call(this, currActiveChildIndex, navigableChidren);
|
|
101
|
-
}
|
|
102
|
-
if (activeChild !== null) {
|
|
103
|
-
__classPrivateFieldGet(this, _Form_instances, "m", _Form_setActiveFirstDeepChild).call(this, activeChild);
|
|
104
|
-
}
|
|
85
|
+
if (!focusOption) {
|
|
86
|
+
__classPrivateFieldGet(this, _Form_instances, "m", _Form_clearCurrentFocus).call(this, field);
|
|
87
|
+
__classPrivateFieldGet(this, _Form_instances, "m", _Form_setActiveFirstDeepChild).call(this, field);
|
|
88
|
+
return;
|
|
105
89
|
}
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
90
|
+
const parent = ((field === null || field === void 0 ? void 0 : field.isContainer) ? field : field.parent);
|
|
91
|
+
const navigableChidren = __classPrivateFieldGet(this, _Form_instances, "m", _Form_getNavigableChildren).call(this, parent.items);
|
|
92
|
+
let activeChild = parent.activeChild;
|
|
93
|
+
let currActiveChildIndex = activeChild !== null ? navigableChidren.indexOf(activeChild) : -1;
|
|
94
|
+
if (parent.activeChild === null) {
|
|
95
|
+
__classPrivateFieldGet(this, _Form_instances, "m", _Form_setActiveFirstDeepChild).call(this, navigableChidren[0]);
|
|
96
|
+
currActiveChildIndex = 0;
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
if (focusOption === Model_1.FocusOption.NEXT_ITEM) {
|
|
100
|
+
activeChild = __classPrivateFieldGet(this, _Form_instances, "m", _Form_getNextItem).call(this, currActiveChildIndex, navigableChidren);
|
|
101
|
+
}
|
|
102
|
+
else if (focusOption === Model_1.FocusOption.PREVIOUS_ITEM) {
|
|
103
|
+
activeChild = __classPrivateFieldGet(this, _Form_instances, "m", _Form_getPreviousItem).call(this, currActiveChildIndex, navigableChidren);
|
|
104
|
+
}
|
|
105
|
+
if (activeChild !== null) {
|
|
106
|
+
__classPrivateFieldGet(this, _Form_instances, "m", _Form_setActiveFirstDeepChild).call(this, activeChild);
|
|
113
107
|
}
|
|
114
108
|
}
|
|
115
109
|
getState() {
|
|
@@ -246,6 +240,7 @@ _Form_instances = new WeakSet(), _Form_getNavigableChildren = function _Form_get
|
|
|
246
240
|
parent.activeChild = currentField;
|
|
247
241
|
return;
|
|
248
242
|
}
|
|
243
|
+
__classPrivateFieldGet(this, _Form_instances, "m", _Form_clearCurrentFocus).call(this, currentField);
|
|
249
244
|
let currentActiveChild = currentField.activeChild;
|
|
250
245
|
currentActiveChild = (currentActiveChild === null) ? __classPrivateFieldGet(this, _Form_instances, "m", _Form_getFirstNavigableChild).call(this, currentField) : currentField.activeChild;
|
|
251
246
|
__classPrivateFieldGet(this, _Form_instances, "m", _Form_setActiveFirstDeepChild).call(this, currentActiveChild);
|
|
@@ -259,5 +254,10 @@ _Form_instances = new WeakSet(), _Form_getNavigableChildren = function _Form_get
|
|
|
259
254
|
return navigableChidren[currIndex - 1];
|
|
260
255
|
}
|
|
261
256
|
return null;
|
|
257
|
+
}, _Form_clearCurrentFocus = function _Form_clearCurrentFocus(field) {
|
|
258
|
+
const parent = field.parent;
|
|
259
|
+
if (parent != null && parent.activeChild != null) {
|
|
260
|
+
parent.activeChild = null;
|
|
261
|
+
}
|
|
262
262
|
};
|
|
263
263
|
exports.default = Form;
|
|
@@ -253,7 +253,7 @@ class FunctionRuntimeImpl {
|
|
|
253
253
|
interpreter.globals.form.setFocus(field, flag);
|
|
254
254
|
}
|
|
255
255
|
catch (e) {
|
|
256
|
-
interpreter.globals.form.logger.error('
|
|
256
|
+
interpreter.globals.form.logger.error('An error has occurred within the setFocus API.');
|
|
257
257
|
}
|
|
258
258
|
},
|
|
259
259
|
_signature: []
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aemforms/af-core",
|
|
3
|
-
"version": "0.22.
|
|
3
|
+
"version": "0.22.67",
|
|
4
4
|
"description": "Core Module for Forms Runtime",
|
|
5
5
|
"author": "Adobe Systems",
|
|
6
6
|
"license": "Adobe Proprietary",
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
37
|
"@adobe/json-formula": "0.1.50",
|
|
38
|
-
"@aemforms/af-formatters": "^0.22.
|
|
38
|
+
"@aemforms/af-formatters": "^0.22.67"
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
|
41
41
|
"@babel/preset-env": "^7.20.2",
|