@aemforms/af-core 0.22.133 → 0.22.135
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/esm/afb-runtime.js +27 -11
- package/esm/types/src/BaseNode.d.ts +2 -0
- package/esm/types/src/Form.d.ts +2 -1
- package/esm/types/src/types/Model.d.ts +1 -1
- package/lib/BaseNode.d.ts +2 -0
- package/lib/BaseNode.js +5 -1
- package/lib/Form.d.ts +2 -1
- package/lib/Form.js +23 -10
- package/lib/types/Model.d.ts +1 -1
- package/package.json +2 -2
package/esm/afb-runtime.js
CHANGED
|
@@ -1314,15 +1314,20 @@ class BaseNode {
|
|
|
1314
1314
|
_tokens = [];
|
|
1315
1315
|
_eventSource = EventSource.CODE;
|
|
1316
1316
|
_fragment = '$form';
|
|
1317
|
+
_idSet;
|
|
1318
|
+
createIdSet() {
|
|
1319
|
+
return new Set();
|
|
1320
|
+
}
|
|
1317
1321
|
get isContainer() {
|
|
1318
1322
|
return false;
|
|
1319
1323
|
}
|
|
1320
1324
|
constructor(params, _options) {
|
|
1321
1325
|
this._options = _options;
|
|
1326
|
+
this._idSet = this.createIdSet();
|
|
1322
1327
|
this[qualifiedName] = null;
|
|
1323
1328
|
this._jsonModel = {
|
|
1324
1329
|
...params,
|
|
1325
|
-
id:
|
|
1330
|
+
id: this.form.getUniqueId(params?.id)
|
|
1326
1331
|
};
|
|
1327
1332
|
if (this.parent?.isFragment) {
|
|
1328
1333
|
this._fragment = this.parent.qualifiedName;
|
|
@@ -3633,22 +3638,24 @@ class Form extends Container {
|
|
|
3633
3638
|
return children.filter(child => child.visible === true);
|
|
3634
3639
|
}
|
|
3635
3640
|
#getFirstNavigableChild(container) {
|
|
3636
|
-
const
|
|
3637
|
-
if (
|
|
3638
|
-
return
|
|
3641
|
+
const navigableChildren = this.#getNavigableChildren(container.items);
|
|
3642
|
+
if (navigableChildren && navigableChildren.length > 0) {
|
|
3643
|
+
return navigableChildren[0];
|
|
3639
3644
|
}
|
|
3640
3645
|
return null;
|
|
3641
3646
|
}
|
|
3642
3647
|
#setActiveFirstDeepChild(currentField) {
|
|
3643
3648
|
if (!currentField.isContainer) {
|
|
3644
|
-
|
|
3645
|
-
parent.activeChild = currentField;
|
|
3649
|
+
currentField.parent.activeChild = currentField;
|
|
3646
3650
|
return;
|
|
3647
3651
|
}
|
|
3648
3652
|
this.#clearCurrentFocus(currentField);
|
|
3649
|
-
|
|
3650
|
-
|
|
3651
|
-
|
|
3653
|
+
const activeChild = currentField.activeChild || this.#getFirstNavigableChild(currentField);
|
|
3654
|
+
if (activeChild === null) {
|
|
3655
|
+
currentField.parent.activeChild = currentField;
|
|
3656
|
+
return;
|
|
3657
|
+
}
|
|
3658
|
+
this.#setActiveFirstDeepChild(activeChild);
|
|
3652
3659
|
}
|
|
3653
3660
|
#getNextItem(currIndex, navigableChidren) {
|
|
3654
3661
|
if (currIndex < (navigableChidren.length - 1)) {
|
|
@@ -3728,11 +3735,20 @@ class Form extends Container {
|
|
|
3728
3735
|
get ruleEngine() {
|
|
3729
3736
|
return this._ruleEngine;
|
|
3730
3737
|
}
|
|
3731
|
-
getUniqueId() {
|
|
3738
|
+
getUniqueId(id) {
|
|
3739
|
+
if (id && !this._idSet?.has(id)) {
|
|
3740
|
+
this._idSet?.add(id);
|
|
3741
|
+
return id;
|
|
3742
|
+
}
|
|
3732
3743
|
if (this._ids == null) {
|
|
3733
3744
|
return '';
|
|
3734
3745
|
}
|
|
3735
|
-
|
|
3746
|
+
const newId = this._ids.next().value;
|
|
3747
|
+
this._idSet?.add(newId);
|
|
3748
|
+
return newId;
|
|
3749
|
+
}
|
|
3750
|
+
clearIdRegistry() {
|
|
3751
|
+
this._idSet?.clear();
|
|
3736
3752
|
}
|
|
3737
3753
|
fieldAdded(field) {
|
|
3738
3754
|
if (field.fieldType === 'captcha' && !this._captcha) {
|
|
@@ -21,6 +21,8 @@ export declare abstract class BaseNode<T extends BaseJson> implements BaseModel
|
|
|
21
21
|
private _tokens;
|
|
22
22
|
_eventSource: EventSource;
|
|
23
23
|
protected _fragment: string;
|
|
24
|
+
protected _idSet: Set<string> | undefined;
|
|
25
|
+
protected createIdSet(): Set<string> | undefined;
|
|
24
26
|
get isContainer(): boolean;
|
|
25
27
|
constructor(params: T, _options: {
|
|
26
28
|
form: FormModel;
|
package/esm/types/src/Form.d.ts
CHANGED
|
@@ -123,7 +123,8 @@ declare class Form extends Container<FormJson> implements FormModel {
|
|
|
123
123
|
isTransparent(): boolean;
|
|
124
124
|
get form(): FormModel;
|
|
125
125
|
get ruleEngine(): RuleEngine;
|
|
126
|
-
getUniqueId(): string;
|
|
126
|
+
getUniqueId(id?: string): string;
|
|
127
|
+
clearIdRegistry(): void;
|
|
127
128
|
fieldAdded(field: FieldModel | FieldsetModel): void;
|
|
128
129
|
visit(callBack: (field: FieldModel | FieldsetModel) => void): void;
|
|
129
130
|
traverseChild(container: Container<any>, callBack: (field: FieldModel | FieldsetModel) => void): void;
|
|
@@ -126,7 +126,7 @@ export interface FormModel extends ContainerModel, WithState<FormJson> {
|
|
|
126
126
|
readonly specVersion: Version;
|
|
127
127
|
exportData(): any;
|
|
128
128
|
getElement(id: string): FieldModel | FormModel | FieldsetModel;
|
|
129
|
-
getUniqueId(): string;
|
|
129
|
+
getUniqueId(id?: string): string;
|
|
130
130
|
getEventQueue(): EventQueue;
|
|
131
131
|
visit(callBack: (field: FieldModel | FieldsetModel) => void): void;
|
|
132
132
|
resolveQualifiedName(qualifiedName: string): FieldModel | FieldsetModel | null;
|
package/lib/BaseNode.d.ts
CHANGED
|
@@ -21,6 +21,8 @@ export declare abstract class BaseNode<T extends BaseJson> implements BaseModel
|
|
|
21
21
|
private _tokens;
|
|
22
22
|
_eventSource: EventSource;
|
|
23
23
|
protected _fragment: string;
|
|
24
|
+
protected _idSet: Set<string> | undefined;
|
|
25
|
+
protected createIdSet(): Set<string> | undefined;
|
|
24
26
|
get isContainer(): boolean;
|
|
25
27
|
constructor(params: T, _options: {
|
|
26
28
|
form: FormModel;
|
package/lib/BaseNode.js
CHANGED
|
@@ -124,8 +124,9 @@ class BaseNode {
|
|
|
124
124
|
this._tokens = [];
|
|
125
125
|
this._eventSource = index_1.EventSource.CODE;
|
|
126
126
|
this._fragment = '$form';
|
|
127
|
+
this._idSet = this.createIdSet();
|
|
127
128
|
this[exports.qualifiedName] = null;
|
|
128
|
-
this._jsonModel = Object.assign(Object.assign({}, params), { id:
|
|
129
|
+
this._jsonModel = Object.assign(Object.assign({}, params), { id: this.form.getUniqueId(params === null || params === void 0 ? void 0 : params.id) });
|
|
129
130
|
if ((_a = this.parent) === null || _a === void 0 ? void 0 : _a.isFragment) {
|
|
130
131
|
this._fragment = this.parent.qualifiedName;
|
|
131
132
|
}
|
|
@@ -133,6 +134,9 @@ class BaseNode {
|
|
|
133
134
|
this._fragment = this.parent.fragment;
|
|
134
135
|
}
|
|
135
136
|
}
|
|
137
|
+
createIdSet() {
|
|
138
|
+
return new Set();
|
|
139
|
+
}
|
|
136
140
|
get isContainer() {
|
|
137
141
|
return false;
|
|
138
142
|
}
|
package/lib/Form.d.ts
CHANGED
|
@@ -123,7 +123,8 @@ declare class Form extends Container<FormJson> implements FormModel {
|
|
|
123
123
|
isTransparent(): boolean;
|
|
124
124
|
get form(): FormModel;
|
|
125
125
|
get ruleEngine(): RuleEngine;
|
|
126
|
-
getUniqueId(): string;
|
|
126
|
+
getUniqueId(id?: string): string;
|
|
127
|
+
clearIdRegistry(): void;
|
|
127
128
|
fieldAdded(field: FieldModel | FieldsetModel): void;
|
|
128
129
|
visit(callBack: (field: FieldModel | FieldsetModel) => void): void;
|
|
129
130
|
traverseChild(container: Container<any>, callBack: (field: FieldModel | FieldsetModel) => void): void;
|
package/lib/Form.js
CHANGED
|
@@ -240,11 +240,22 @@ class Form extends Container_1.default {
|
|
|
240
240
|
get ruleEngine() {
|
|
241
241
|
return this._ruleEngine;
|
|
242
242
|
}
|
|
243
|
-
getUniqueId() {
|
|
243
|
+
getUniqueId(id) {
|
|
244
|
+
var _a, _b, _c;
|
|
245
|
+
if (id && !((_a = this._idSet) === null || _a === void 0 ? void 0 : _a.has(id))) {
|
|
246
|
+
(_b = this._idSet) === null || _b === void 0 ? void 0 : _b.add(id);
|
|
247
|
+
return id;
|
|
248
|
+
}
|
|
244
249
|
if (this._ids == null) {
|
|
245
250
|
return '';
|
|
246
251
|
}
|
|
247
|
-
|
|
252
|
+
const newId = this._ids.next().value;
|
|
253
|
+
(_c = this._idSet) === null || _c === void 0 ? void 0 : _c.add(newId);
|
|
254
|
+
return newId;
|
|
255
|
+
}
|
|
256
|
+
clearIdRegistry() {
|
|
257
|
+
var _a;
|
|
258
|
+
(_a = this._idSet) === null || _a === void 0 ? void 0 : _a.clear();
|
|
248
259
|
}
|
|
249
260
|
fieldAdded(field) {
|
|
250
261
|
if (field.fieldType === 'captcha' && !this._captcha) {
|
|
@@ -390,21 +401,23 @@ class Form extends Container_1.default {
|
|
|
390
401
|
_Form_instances = new WeakSet(), _Form_getNavigableChildren = function _Form_getNavigableChildren(children) {
|
|
391
402
|
return children.filter(child => child.visible === true);
|
|
392
403
|
}, _Form_getFirstNavigableChild = function _Form_getFirstNavigableChild(container) {
|
|
393
|
-
const
|
|
394
|
-
if (
|
|
395
|
-
return
|
|
404
|
+
const navigableChildren = __classPrivateFieldGet(this, _Form_instances, "m", _Form_getNavigableChildren).call(this, container.items);
|
|
405
|
+
if (navigableChildren && navigableChildren.length > 0) {
|
|
406
|
+
return navigableChildren[0];
|
|
396
407
|
}
|
|
397
408
|
return null;
|
|
398
409
|
}, _Form_setActiveFirstDeepChild = function _Form_setActiveFirstDeepChild(currentField) {
|
|
399
410
|
if (!currentField.isContainer) {
|
|
400
|
-
|
|
401
|
-
parent.activeChild = currentField;
|
|
411
|
+
currentField.parent.activeChild = currentField;
|
|
402
412
|
return;
|
|
403
413
|
}
|
|
404
414
|
__classPrivateFieldGet(this, _Form_instances, "m", _Form_clearCurrentFocus).call(this, currentField);
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
415
|
+
const activeChild = currentField.activeChild || __classPrivateFieldGet(this, _Form_instances, "m", _Form_getFirstNavigableChild).call(this, currentField);
|
|
416
|
+
if (activeChild === null) {
|
|
417
|
+
currentField.parent.activeChild = currentField;
|
|
418
|
+
return;
|
|
419
|
+
}
|
|
420
|
+
__classPrivateFieldGet(this, _Form_instances, "m", _Form_setActiveFirstDeepChild).call(this, activeChild);
|
|
408
421
|
}, _Form_getNextItem = function _Form_getNextItem(currIndex, navigableChidren) {
|
|
409
422
|
if (currIndex < (navigableChidren.length - 1)) {
|
|
410
423
|
return navigableChidren[currIndex + 1];
|
package/lib/types/Model.d.ts
CHANGED
|
@@ -126,7 +126,7 @@ export interface FormModel extends ContainerModel, WithState<FormJson> {
|
|
|
126
126
|
readonly specVersion: Version;
|
|
127
127
|
exportData(): any;
|
|
128
128
|
getElement(id: string): FieldModel | FormModel | FieldsetModel;
|
|
129
|
-
getUniqueId(): string;
|
|
129
|
+
getUniqueId(id?: string): string;
|
|
130
130
|
getEventQueue(): EventQueue;
|
|
131
131
|
visit(callBack: (field: FieldModel | FieldsetModel) => void): void;
|
|
132
132
|
resolveQualifiedName(qualifiedName: string): FieldModel | FieldsetModel | null;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aemforms/af-core",
|
|
3
|
-
"version": "0.22.
|
|
3
|
+
"version": "0.22.135",
|
|
4
4
|
"description": "Core Module for Forms Runtime",
|
|
5
5
|
"author": "Adobe Systems",
|
|
6
6
|
"license": "Adobe Proprietary",
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
39
|
"@adobe/json-formula": "0.1.50",
|
|
40
|
-
"@aemforms/af-formatters": "^0.22.
|
|
40
|
+
"@aemforms/af-formatters": "^0.22.135"
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
43
43
|
"@babel/preset-env": "^7.20.2",
|